[vlc-commits] caopengllayer: use color primaries provided by decoder or demuxer

Felix Paul Kühne git at videolan.org
Sat Apr 16 17:23:12 CEST 2016


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Apr 16 18:19:09 2016 +0300| [86b164e2518e0d0b61ed90af9cf69eafdd1fff19] | committer: Felix Paul Kühne

caopengllayer: use color primaries provided by decoder or demuxer

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

 modules/video_output/caopengllayer.m |   48 ++++++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/modules/video_output/caopengllayer.m b/modules/video_output/caopengllayer.m
index 2335df0..d2da1f9 100644
--- a/modules/video_output/caopengllayer.m
+++ b/modules/video_output/caopengllayer.m
@@ -197,17 +197,43 @@ static int Open (vlc_object_t *p_this)
             /* support for BT.709 and BT.2020 color spaces was introduced with OS X 10.11
              * on older OS versions, we can't show correct colors, so we fallback on linear RGB */
             if (OSX_EL_CAPITAN) {
-                msg_Warn(vd, "Guessing color space based on video dimensions (height: %i", fmt.i_height);
-
-                if (fmt.i_height >= 2000 || fmt.i_width >= 3800) {
-                    msg_Dbg(vd, "Should use BT.2020 color space, but in reality it's BT.709");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
-                } else if (fmt.i_height > 576) {
-                    msg_Dbg(vd, "Using BT.709 color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
-                } else {
-                    msg_Dbg(vd, "SD content, using linear RGB color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+                switch (fmt.primaries) {
+                    case COLOR_PRIMARIES_BT601_525:
+                    case COLOR_PRIMARIES_BT601_625:
+                    {
+                        sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+                        break;
+                    }
+                    case COLOR_PRIMARIES_BT709:
+                    {
+                        sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
+                        break;
+                    }
+                    case COLOR_PRIMARIES_BT2020:
+                    {
+                        sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
+                        break;
+                    }
+                    case COLOR_PRIMARIES_DCI_P3:
+                    {
+                        sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDCIP3);
+                        break;
+                    }
+                    default:
+                    {
+                        msg_Dbg(vd, "Guessing color space based on video dimensions (%ix%i)", fmt.i_visible_width, fmt.i_visible_height);
+                        if (fmt.i_visible_height >= 2000 || fmt.i_visible_width >= 3800) {
+                            msg_Dbg(vd, "Using BT.2020 color space");
+                            sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
+                        } else if (fmt.i_height > 576) {
+                            msg_Dbg(vd, "Using BT.709 color space");
+                            sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
+                        } else {
+                            msg_Dbg(vd, "SD content, using linear RGB color space");
+                            sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+                        }
+                        break;
+                    }
                 }
             } else {
                 msg_Dbg(vd, "OS does not support BT.709 or BT.2020 color spaces, output may vary");



More information about the vlc-commits mailing list