From 8217b186f6d210c2abebb7ec6c7d5152d11fa4bf Mon Sep 17 00:00:00 2001 From: Leo Izen Date: Mon, 27 Feb 2023 10:42:33 -0500 Subject: video/out/placebo/utils: add mappings from pl enums to mpv enums mp_trc_to_pl, mp_prim_to_pl, and mp_levels_to_pl have forward but not inverse mappings. This commit adds mp_trc_from_pl, mp_prim_from_pl, and mp_levels_from_pl inverse mapping functions, which just map the enums in the other direction. --- video/out/placebo/utils.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ video/out/placebo/utils.h | 3 +++ 2 files changed, 72 insertions(+) (limited to 'video/out') diff --git a/video/out/placebo/utils.c b/video/out/placebo/utils.c index 961ffc0b97..4e6cd44004 100644 --- a/video/out/placebo/utils.c +++ b/video/out/placebo/utils.c @@ -100,6 +100,35 @@ enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim) MP_ASSERT_UNREACHABLE(); } +enum mp_csp_prim mp_prim_from_pl(enum pl_color_primaries prim) +{ + switch (prim){ + case PL_COLOR_PRIM_UNKNOWN: return MP_CSP_PRIM_AUTO; + case PL_COLOR_PRIM_BT_601_525: return MP_CSP_PRIM_BT_601_525; + case PL_COLOR_PRIM_BT_601_625: return MP_CSP_PRIM_BT_601_625; + case PL_COLOR_PRIM_BT_709: return MP_CSP_PRIM_BT_709; + case PL_COLOR_PRIM_BT_2020: return MP_CSP_PRIM_BT_2020; + case PL_COLOR_PRIM_BT_470M: return MP_CSP_PRIM_BT_470M; + case PL_COLOR_PRIM_APPLE: return MP_CSP_PRIM_APPLE; + case PL_COLOR_PRIM_ADOBE: return MP_CSP_PRIM_ADOBE; + case PL_COLOR_PRIM_PRO_PHOTO: return MP_CSP_PRIM_PRO_PHOTO; + case PL_COLOR_PRIM_CIE_1931: return MP_CSP_PRIM_CIE_1931; + case PL_COLOR_PRIM_DCI_P3: return MP_CSP_PRIM_DCI_P3; + case PL_COLOR_PRIM_DISPLAY_P3: return MP_CSP_PRIM_DISPLAY_P3; + case PL_COLOR_PRIM_V_GAMUT: return MP_CSP_PRIM_V_GAMUT; + case PL_COLOR_PRIM_S_GAMUT: return MP_CSP_PRIM_S_GAMUT; + case PL_COLOR_PRIM_EBU_3213: return MP_CSP_PRIM_EBU_3213; + case PL_COLOR_PRIM_FILM_C: return MP_CSP_PRIM_FILM_C; +#if PL_API_VER >= 230 + case PL_COLOR_PRIM_ACES_AP0: return MP_CSP_PRIM_ACES_AP0; + case PL_COLOR_PRIM_ACES_AP1: return MP_CSP_PRIM_ACES_AP1; +#endif + case PL_COLOR_PRIM_COUNT: return MP_CSP_PRIM_COUNT; + } + + MP_ASSERT_UNREACHABLE(); +} + enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc) { switch (trc) { @@ -130,6 +159,34 @@ enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc) MP_ASSERT_UNREACHABLE(); } +enum mp_csp_trc mp_trc_from_pl(enum pl_color_transfer trc) +{ + switch (trc){ + case PL_COLOR_TRC_UNKNOWN: return MP_CSP_TRC_AUTO; + case PL_COLOR_TRC_BT_1886: return MP_CSP_TRC_BT_1886; + case PL_COLOR_TRC_SRGB: return MP_CSP_TRC_SRGB; + case PL_COLOR_TRC_LINEAR: return MP_CSP_TRC_LINEAR; + case PL_COLOR_TRC_GAMMA18: return MP_CSP_TRC_GAMMA18; + case PL_COLOR_TRC_GAMMA20: return MP_CSP_TRC_GAMMA20; + case PL_COLOR_TRC_GAMMA22: return MP_CSP_TRC_GAMMA22; + case PL_COLOR_TRC_GAMMA24: return MP_CSP_TRC_GAMMA24; + case PL_COLOR_TRC_GAMMA26: return MP_CSP_TRC_GAMMA26; + case PL_COLOR_TRC_GAMMA28: return MP_CSP_TRC_GAMMA28; + case PL_COLOR_TRC_PRO_PHOTO: return MP_CSP_TRC_PRO_PHOTO; + case PL_COLOR_TRC_PQ: return MP_CSP_TRC_PQ; + case PL_COLOR_TRC_HLG: return MP_CSP_TRC_HLG; + case PL_COLOR_TRC_V_LOG: return MP_CSP_TRC_V_LOG; + case PL_COLOR_TRC_S_LOG1: return MP_CSP_TRC_S_LOG1; + case PL_COLOR_TRC_S_LOG2: return MP_CSP_TRC_S_LOG2; +#if PL_API_VER >= 240 + case PL_COLOR_TRC_ST428: return MP_CSP_TRC_ST428; +#endif + case PL_COLOR_TRC_COUNT: return MP_CSP_TRC_COUNT; + } + + MP_ASSERT_UNREACHABLE(); +} + enum pl_color_system mp_csp_to_pl(enum mp_csp csp) { switch (csp) { @@ -160,6 +217,18 @@ enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels) MP_ASSERT_UNREACHABLE(); } +enum mp_csp_levels mp_levels_from_pl(enum pl_color_levels levels) +{ + switch (levels){ + case PL_COLOR_LEVELS_UNKNOWN: return MP_CSP_LEVELS_AUTO; + case PL_COLOR_LEVELS_TV: return MP_CSP_LEVELS_TV; + case PL_COLOR_LEVELS_PC: return MP_CSP_LEVELS_PC; + case PL_COLOR_LEVELS_COUNT: return MP_CSP_LEVELS_COUNT; + } + + MP_ASSERT_UNREACHABLE(); +} + enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha) { switch (alpha) { diff --git a/video/out/placebo/utils.h b/video/out/placebo/utils.h index 40da09f2d7..bf780a82b3 100644 --- a/video/out/placebo/utils.h +++ b/video/out/placebo/utils.h @@ -28,9 +28,12 @@ static inline struct pl_rect2d mp_rect2d_to_pl(struct mp_rect rc) } enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim); +enum mp_csp_prim mp_prim_from_pl(enum pl_color_primaries prim); enum pl_color_transfer mp_trc_to_pl(enum mp_csp_trc trc); +enum mp_csp_trc mp_trc_from_pl(enum pl_color_transfer trc); enum pl_color_system mp_csp_to_pl(enum mp_csp csp); enum pl_color_levels mp_levels_to_pl(enum mp_csp_levels levels); +enum mp_csp_levels mp_levels_from_pl(enum pl_color_levels levels); enum pl_alpha_mode mp_alpha_to_pl(enum mp_alpha_type alpha); enum pl_chroma_location mp_chroma_to_pl(enum mp_chroma_location chroma); -- cgit v1.2.3