colorspace: Add support for BT709
authorJan Ekström <jeebjp@gmail.com>
Sun, 24 Apr 2016 18:30:06 +0000 (20:30 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 10 May 2016 09:30:25 +0000 (11:30 +0200)
BT.709 coefficients were gathered from the first two parts of BT.709
to BT.2020 conversion guide in ARIB STD-B62 (Pt. 1, Chapter 6.2.2).
They were additionally confirmed by manually calculating values.

libavutil/colorspace.h

index 8757566..cc27f38 100644 (file)
     b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
 }
 
+#define YUV_TO_RGB1_CCIR_BT709(cb1, cr1)                      \
+    {                                                         \
+        cb    = (cb1) - 128;                                  \
+        cr    = (cr1) - 128;                                  \
+        r_add = ONE_HALF + FIX(1.5747 * 255.0 / 224.0) * cr;  \
+        g_add = ONE_HALF - FIX(0.1873 * 255.0 / 224.0) * cb - \
+                           FIX(0.4682 * 255.0 / 224.0) * cr;  \
+        b_add = ONE_HALF + FIX(1.8556 * 255.0 / 224.0) * cb;  \
+    }
+
+// To be used for the BT709 variant as well
 #define YUV_TO_RGB2_CCIR(r, g, b, y1)\
 {\
     y = ((y1) - 16) * FIX(255.0/219.0);\