LCOV - code coverage report
Current view: top level - src/media/video - filter_transpose.cpp (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 0 40 0.0 %
Date: 2024-04-26 09:41:19 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Denys VIDAL <denys.vidal@savoirfairelinux.com>
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, write to the Free Software
      18             :  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
      19             :  */
      20             : 
      21             : #include "filter_transpose.h"
      22             : #include "logger.h"
      23             : 
      24             : namespace jami {
      25             : namespace video {
      26             : 
      27             : std::unique_ptr<MediaFilter>
      28           0 : getTransposeFilter(
      29             :     int rotation, std::string inputName, int width, int height, int format, bool rescale)
      30             : {
      31           0 :     JAMI_WARN("Rotation set to %d", rotation);
      32           0 :     if (rotation == 0) {
      33           0 :         return {};
      34             :     }
      35             : 
      36           0 :     std::stringstream ss;
      37           0 :     ss << "[" << inputName << "] ";
      38             : 
      39           0 :     switch (rotation) {
      40           0 :     case 90:
      41             :     case -270:
      42           0 :         ss << "transpose=2";
      43           0 :         if (rescale) {
      44           0 :             if (width > height)
      45           0 :                 ss << ", scale=w=-1:h=" << height << ", pad=" << width << ":" << height
      46           0 :                    << ":(ow-iw)/2";
      47             :             else
      48           0 :                 ss << ", scale=w=" << width << ":h=-1"
      49           0 :                    << ", pad=" << width << ":" << height << ":0:(oh-ih)/2";
      50             :         }
      51           0 :         break;
      52           0 :     case 180:
      53             :     case -180:
      54           0 :         ss << "transpose=1, transpose=1";
      55           0 :         break;
      56           0 :     case 270:
      57             :     case -90:
      58           0 :         ss << "transpose=1";
      59           0 :         if (rescale) {
      60           0 :             if (width > height)
      61           0 :                 ss << ", scale=w=-1:h=" << height << ", pad=" << width << ":" << height
      62           0 :                    << ":(ow-iw)/2";
      63             :             else
      64           0 :                 ss << ", scale=w=" << width << ":h=-1"
      65           0 :                    << ", pad=" << width << ":" << height << ":0:(oh-ih)/2";
      66             :         }
      67           0 :         break;
      68           0 :     default:
      69           0 :         return {};
      70             :     }
      71             : 
      72           0 :     constexpr auto one = rational<int>(1);
      73           0 :     std::vector<MediaStream> msv;
      74           0 :     msv.emplace_back(inputName, format, one, width, height, 0, one);
      75             : 
      76           0 :     std::unique_ptr<MediaFilter> filter(new MediaFilter);
      77           0 :     auto ret = filter->initialize(ss.str(), msv);
      78           0 :     if (ret < 0) {
      79           0 :         JAMI_ERR() << "filter init fail";
      80           0 :         return {};
      81             :     }
      82           0 :     return filter;
      83           0 : }
      84             : 
      85             : } // namespace video
      86             : } // namespace jami

Generated by: LCOV version 1.14