[vlc-commits] codec: videotoolbox: setup YUV->RGB matrix

Thomas Guillem git at videolan.org
Fri Nov 24 13:55:51 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Nov 24 13:31:55 2017 +0100| [e4fffa8b85d6cdb0a28621a76a1ae95b5144e4bd] | committer: Thomas Guillem

codec: videotoolbox: setup YUV->RGB matrix

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e4fffa8b85d6cdb0a28621a76a1ae95b5144e4bd
---

 modules/codec/videotoolbox.m | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/modules/codec/videotoolbox.m b/modules/codec/videotoolbox.m
index 517c18edd3..afc08915e1 100644
--- a/modules/codec/videotoolbox.m
+++ b/modules/codec/videotoolbox.m
@@ -1030,6 +1030,33 @@ static CFMutableDictionaryRef CreateSessionDescriptionFormat(decoder_t *p_dec,
         CFRelease(pixelaspectratio);
     }
 
+    /* Setup YUV->RGB matrix since VT can output BGRA directly. Don't setup
+     * transfer and primaries since the transformation is done via the GL
+     * fragment shader. */
+    CFStringRef yuvmatrix;
+    switch (p_dec->fmt_out.video.space)
+    {
+        case COLOR_SPACE_BT601:
+            yuvmatrix = kCVImageBufferYCbCrMatrix_ITU_R_601_4;
+            break;
+        case COLOR_SPACE_BT2020:
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+            if (&kCVImageBufferColorPrimaries_ITU_R_2020 != nil)
+            {
+                yuvmatrix = kCVImageBufferColorPrimaries_ITU_R_2020;
+                break;
+            }
+#pragma clang diagnostic pop
+            /* fall through */
+        case COLOR_SPACE_BT709:
+        default:
+            yuvmatrix = kCVImageBufferColorPrimaries_ITU_R_709_2;
+            break;
+    }
+    CFDictionarySetValue(decoderConfiguration, kCVImageBufferYCbCrMatrixKey,
+                         yuvmatrix);
+
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpartial-availability"
 



More information about the vlc-commits mailing list