From ff6e3c025658a5fa1affd094f220b623e7e1b24b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:38:23 +0200 Subject: Adding upstream version 6.338.2. Signed-off-by: Daniel Baumann --- src/shaders/film_grain.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/shaders/film_grain.h (limited to 'src/shaders/film_grain.h') diff --git a/src/shaders/film_grain.h b/src/shaders/film_grain.h new file mode 100644 index 0000000..f6498c1 --- /dev/null +++ b/src/shaders/film_grain.h @@ -0,0 +1,75 @@ +/* + * This file is part of libplacebo. + * + * libplacebo is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libplacebo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libplacebo. If not, see . + */ + +#pragma once + +#include "common.h" + +#include + +bool pl_needs_fg_av1(const struct pl_film_grain_params *); +bool pl_needs_fg_h274(const struct pl_film_grain_params *); + +bool pl_shader_fg_av1(pl_shader, pl_shader_obj *, const struct pl_film_grain_params *); +bool pl_shader_fg_h274(pl_shader, pl_shader_obj *, const struct pl_film_grain_params *); + +// Common helper function +static inline enum pl_channel channel_map(int i, const struct pl_film_grain_params *params) +{ + static const enum pl_channel map_rgb[3] = { + [PL_CHANNEL_G] = PL_CHANNEL_Y, + [PL_CHANNEL_B] = PL_CHANNEL_CB, + [PL_CHANNEL_R] = PL_CHANNEL_CR, + }; + + static const enum pl_channel map_xyz[3] = { + [1] = PL_CHANNEL_Y, // Y + [2] = PL_CHANNEL_CB, // Z + [0] = PL_CHANNEL_CR, // X + }; + + if (i >= params->components) + return PL_CHANNEL_NONE; + + int comp = params->component_mapping[i]; + if (comp < 0 || comp > 2) + return PL_CHANNEL_NONE; + + switch (params->repr->sys) { + case PL_COLOR_SYSTEM_UNKNOWN: + case PL_COLOR_SYSTEM_RGB: + return map_rgb[comp]; + case PL_COLOR_SYSTEM_XYZ: + return map_xyz[comp]; + + case PL_COLOR_SYSTEM_BT_601: + case PL_COLOR_SYSTEM_BT_709: + case PL_COLOR_SYSTEM_SMPTE_240M: + case PL_COLOR_SYSTEM_BT_2020_NC: + case PL_COLOR_SYSTEM_BT_2020_C: + case PL_COLOR_SYSTEM_BT_2100_PQ: + case PL_COLOR_SYSTEM_BT_2100_HLG: + case PL_COLOR_SYSTEM_DOLBYVISION: + case PL_COLOR_SYSTEM_YCGCO: + return comp; + + case PL_COLOR_SYSTEM_COUNT: + break; + } + + pl_unreachable(); +} -- cgit v1.2.3