LCOV - code coverage report
Current view: top level - src/shaders - film_grain.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 5 10 50.0 %
Date: 2025-03-29 09:04:10 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * This file is part of libplacebo.
       3                 :            :  *
       4                 :            :  * libplacebo is free software; you can redistribute it and/or
       5                 :            :  * modify it under the terms of the GNU Lesser General Public
       6                 :            :  * License as published by the Free Software Foundation; either
       7                 :            :  * version 2.1 of the License, or (at your option) any later version.
       8                 :            :  *
       9                 :            :  * libplacebo is distributed in the hope that it will be useful,
      10                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12                 :            :  * GNU Lesser General Public License for more details.
      13                 :            :  *
      14                 :            :  * You should have received a copy of the GNU Lesser General Public
      15                 :            :  * License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
      16                 :            :  */
      17                 :            : 
      18                 :            : #pragma once
      19                 :            : 
      20                 :            : #include "common.h"
      21                 :            : 
      22                 :            : #include <libplacebo/shaders/film_grain.h>
      23                 :            : 
      24                 :            : bool pl_needs_fg_av1(const struct pl_film_grain_params *);
      25                 :            : bool pl_needs_fg_h274(const struct pl_film_grain_params *);
      26                 :            : 
      27                 :            : bool pl_shader_fg_av1(pl_shader, pl_shader_obj *, const struct pl_film_grain_params *);
      28                 :            : bool pl_shader_fg_h274(pl_shader, pl_shader_obj *, const struct pl_film_grain_params *);
      29                 :            : 
      30                 :            : // Common helper function
      31                 :         82 : static inline enum pl_channel channel_map(int i, const struct pl_film_grain_params *params)
      32                 :            : {
      33                 :            :     static const enum pl_channel map_rgb[3] = {
      34                 :            :         [PL_CHANNEL_G] = PL_CHANNEL_Y,
      35                 :            :         [PL_CHANNEL_B] = PL_CHANNEL_CB,
      36                 :            :         [PL_CHANNEL_R] = PL_CHANNEL_CR,
      37                 :            :     };
      38                 :            : 
      39                 :            :     static const enum pl_channel map_xyz[3] = {
      40                 :            :         [1] = PL_CHANNEL_Y,  // Y
      41                 :            :         [2] = PL_CHANNEL_CB, // Z
      42                 :            :         [0] = PL_CHANNEL_CR, // X
      43                 :            :     };
      44                 :            : 
      45         [ +  + ]:         82 :     if (i >= params->components)
      46                 :            :         return PL_CHANNEL_NONE;
      47                 :            : 
      48                 :         74 :     int comp = params->component_mapping[i];
      49         [ +  - ]:         74 :     if (comp < 0 || comp > 2)
      50                 :            :         return PL_CHANNEL_NONE;
      51                 :            : 
      52   [ -  -  -  + ]:         74 :     switch (params->repr->sys) {
      53                 :          0 :     case PL_COLOR_SYSTEM_UNKNOWN:
      54                 :            :     case PL_COLOR_SYSTEM_RGB:
      55                 :          0 :         return map_rgb[comp];
      56                 :          0 :     case PL_COLOR_SYSTEM_XYZ:
      57                 :          0 :         return map_xyz[comp];
      58                 :            : 
      59                 :            :     case PL_COLOR_SYSTEM_BT_601:
      60                 :            :     case PL_COLOR_SYSTEM_BT_709:
      61                 :            :     case PL_COLOR_SYSTEM_SMPTE_240M:
      62                 :            :     case PL_COLOR_SYSTEM_BT_2020_NC:
      63                 :            :     case PL_COLOR_SYSTEM_BT_2020_C:
      64                 :            :     case PL_COLOR_SYSTEM_BT_2100_PQ:
      65                 :            :     case PL_COLOR_SYSTEM_BT_2100_HLG:
      66                 :            :     case PL_COLOR_SYSTEM_DOLBYVISION:
      67                 :            :     case PL_COLOR_SYSTEM_YCGCO:
      68                 :            :         return comp;
      69                 :            : 
      70                 :            :     case PL_COLOR_SYSTEM_COUNT:
      71                 :            :         break;
      72                 :            :     }
      73                 :            : 
      74                 :          0 :     pl_unreachable();
      75                 :            : }

Generated by: LCOV version 1.16