From e99f0f953e98ab7e0c2f9c1ba7ff05641e0afeff Mon Sep 17 00:00:00 2001 From: David Rosca Date: Fri, 18 Aug 2023 12:29:56 +0200 Subject: [PATCH] gallium/auxiliary/vl: Add BT.709 full csc matrix Used for converting from full range YUV. Reviewed-by: Leo Liu Part-of: --- src/gallium/auxiliary/vl/vl_csc.c | 15 +++++++++++++++ src/gallium/auxiliary/vl/vl_csc.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/gallium/auxiliary/vl/vl_csc.c b/src/gallium/auxiliary/vl/vl_csc.c index b015a44..d1a88b3 100644 --- a/src/gallium/auxiliary/vl/vl_csc.c +++ b/src/gallium/auxiliary/vl/vl_csc.c @@ -120,6 +120,18 @@ static const vl_csc_matrix bt_709 = }; /* + * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where: + * Y, Cb, and Cr are in [0,255] + * R, G, and B are in [16,235] + */ +static const vl_csc_matrix bt_709_full = +{ + { 0.859f, 0.0f, 1.352f, 0.0625f, }, + { 0.859f, -0.161f, -0.402f, 0.0625f, }, + { 0.859f, 1.594f, 0.0f, 0.0625f, } +}; + +/* * Converts SMPTE 240M YCbCr pixels to RGB pixels where: * Y is in [16,235], Cb and Cr are in [16,240] * R, G, and B are in [16,235] @@ -193,6 +205,9 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs, case VL_CSC_COLOR_STANDARD_BT_709: cstd = &bt_709; break; + case VL_CSC_COLOR_STANDARD_BT_709_FULL: + cstd = &bt_709_full; + break; case VL_CSC_COLOR_STANDARD_SMPTE_240M: cstd = &smpte240m; break; diff --git a/src/gallium/auxiliary/vl/vl_csc.h b/src/gallium/auxiliary/vl/vl_csc.h index b640b4e..43de802 100644 --- a/src/gallium/auxiliary/vl/vl_csc.h +++ b/src/gallium/auxiliary/vl/vl_csc.h @@ -45,6 +45,7 @@ enum VL_CSC_COLOR_STANDARD VL_CSC_COLOR_STANDARD_IDENTITY, VL_CSC_COLOR_STANDARD_BT_601, VL_CSC_COLOR_STANDARD_BT_709, + VL_CSC_COLOR_STANDARD_BT_709_FULL, VL_CSC_COLOR_STANDARD_SMPTE_240M, VL_CSC_COLOR_STANDARD_BT_709_REV }; -- 2.7.4