Commit a4ef9238 authored by Niklas Haas's avatar Niklas Haas Committed by Thomas Guillem

video_output: opengl: add BT.2020 decoding matrices

Generated the matrices using the following small program:

    #include <stdio.h>
    #include <libplacebo/colorspace.h>

    void main()
    {
        struct pl_color_repr repr = {
            .sys    = PL_COLOR_SYSTEM_BT_2020_NC,
            .levels = PL_COLOR_LEVELS_TV,
        };

        struct pl_transform3x3 tf = pl_color_repr_decode(&repr, NULL);
        for (int i = 0; i < 3; i++) {
            printf("% .15f, % .15f, % .15f, % .15f ,\n",
                  tf.mat.m[i][0], tf.mat.m[i][1], tf.mat.m[i][2], tf.c[i]);
        }
    }

I've also verified that the BT.709 and BT.601 matrices are identical
within an error margin of several orders of magnitude. (Probably due to
floating point inaccuracy)

P.s. VLC doesn't seem to distinguish between BT.2020-NC and BT.2020-CL,
which I believe is a bug. But anyway, we can only easily handle
BT.2020-NC anyway, so hard-code it as that. (BT.2020-CL support would
require some more libplacebo integration)
Signed-off-by: Thomas Guillem's avatarThomas Guillem <thomas@gllm.fr>
parent 77d8be7e
......@@ -231,6 +231,11 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
1.164383561643836, -0.21324861427373, -0.532909328559444, 0.301482665475862 ,
1.164383561643836, 2.112401785714286, 0.0000, -1.133402217873451 ,
};
static const float matrix_bt2020_tv2full[12] = {
1.164383530616760, 0.0000, 1.678674221038818, -0.915687978267670 ,
1.164383530616760, -0.187326118350029, -0.650424420833588, 0.347458571195602 ,
1.164383530616760, 2.141772270202637, 0.0000, -1.148145079612732 ,
};
const float *matrix;
switch (yuv_space)
......@@ -238,6 +243,9 @@ tc_yuv_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
case COLOR_SPACE_BT601:
matrix = matrix_bt601_tv2full;
break;
case COLOR_SPACE_BT2020:
matrix = matrix_bt2020_tv2full;
break;
default:
matrix = matrix_bt709_tv2full;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment