Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d842c0d2 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

codec2: adjust RGB to YUV matrices

Adjust matrices so white is encoded as Y=255.

Bug: 234641213
Change-Id: I4d01ee95f20e10739f6ebde5362ece4f43dfb56a
parent e054011b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -532,12 +532,14 @@ MediaImage2 CreateYUV420SemiPlanarMediaImage2(
// Matrix coefficient to convert RGB to Planar YUV data.
// Each sub-array represents the 3X3 coeff used with R, G and B
static const int16_t bt601Matrix[2][3][3] = {
    { { 76, 150, 29 }, { -43, -85, 128 }, { 128, -107, -21 } }, /* RANGE_FULL */
    { { 77, 150, 29 }, { -43, -85, 128 }, { 128, -107, -21 } }, /* RANGE_FULL */
    { { 66, 129, 25 }, { -38, -74, 112 }, { 112, -94, -18 } },  /* RANGE_LIMITED */
};

static const int16_t bt709Matrix[2][3][3] = {
    { { 54, 183, 18 }, { -29, -99, 128 }, { 128, -116, -12 } }, /* RANGE_FULL */
    // TRICKY: 18 is adjusted to 19 so that sum of row 1 is 256
    { { 54, 183, 19 }, { -29, -99, 128 }, { 128, -116, -12 } }, /* RANGE_FULL */
    // TRICKY: -87 is adjusted to -86 so that sum of row 2 is 0
    { { 47, 157, 16 }, { -26, -86, 112 }, { 112, -102, -10 } }, /* RANGE_LIMITED */
};