Skip to content

Commit

Permalink
More precise YIQ -> RGB matrix from Poynton.
Browse files Browse the repository at this point in the history
As with PAL, we have about 5 s.f. in our samples, so the 6 s.f.
constants are worthwhile.
  • Loading branch information
atsampson committed Apr 10, 2020
1 parent 63ac823 commit 8b010a0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tools/ld-chroma-decoder/rgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ void RGB::convertLine(const YIQ *begin, const YIQ *end, quint16 *out)
i *= iqScale;
q *= iqScale;

// YIQ to RGB colour-space conversion (from page 18
// of Video Demystified, 5th edition)
//
// For RGB 0-255: Y 0-255. I 0- +-152. Q 0- +-134 :
double r = y + (0.956 * i) + (0.621 * q);
double g = y - (0.272 * i) - (0.647 * q);
double b = y - (1.107 * i) + (1.704 * q);
// Y'IQ to R'G'B' colour-space conversion.
// Coefficients from Poynton, "Digital Video and HDTV" first edition, p367 eq 30.3.
double r = y + (0.955986 * i) + (0.620825 * q);
double g = y - (0.272013 * i) - (0.647204 * q);
double b = y - (1.106740 * i) + (1.704230 * q);

r = qBound(0.0, r, 65535.0);
g = qBound(0.0, g, 65535.0);
Expand Down

0 comments on commit 8b010a0

Please sign in to comment.