[vlc-devel] [PATCH 2/3] macosx: don't handle color primaries

Victorien Le Couviour--Tuffet victorien.lecouviour.tuffet at gmail.com
Thu Jul 27 12:06:33 CEST 2017


The GL shader already does this job.
---
 modules/video_output/macosx.m | 87 -------------------------------------------
 1 file changed, 87 deletions(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 3fa35c592d..2770c44305 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -49,14 +49,6 @@
 #include <vlc_dialog.h>
 #include "opengl/vout_helper.h"
 
-#define OSX_EL_CAPITAN (NSAppKitVersionNumber >= 1404)
-
-#if MAC_OS_X_VERSION_MIN_ALLOWED <= MAC_OS_X_VERSION_10_11
-const CFStringRef kCGColorSpaceDCIP3 = CFSTR("kCGColorSpaceDCIP3");
-const CFStringRef kCGColorSpaceITUR_709 = CFSTR("kCGColorSpaceITUR_709");
-const CFStringRef kCGColorSpaceITUR_2020 = CFSTR("kCGColorSpaceITUR_2020");
-#endif
-
 /**
  * Forward declarations
  */
@@ -112,9 +104,6 @@ struct vout_display_sys_t
     VLCOpenGLVideoView *glView;
     id<VLCOpenGLVideoViewEmbedding> container;
 
-    CGColorSpaceRef cgColorSpace;
-    NSColorSpace *nsColorSpace;
-
     vout_window_t *embed;
     vlc_gl_t *gl;
     vout_display_opengl_t *vgl;
@@ -176,57 +165,6 @@ static int Open (vlc_object_t *this)
          * main thread, after we are done using it. */
         sys->container = [container retain];
 
-        /* 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) {
-            switch (vd->fmt.primaries) {
-                case COLOR_PRIMARIES_BT601_525:
-                case COLOR_PRIMARIES_BT601_625:
-                {
-                    msg_Dbg(vd, "Using BT.601 color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
-                    break;
-                }
-                case COLOR_PRIMARIES_BT709:
-                {
-                    msg_Dbg(vd, "Using BT.709 color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_709);
-                    break;
-                }
-                case COLOR_PRIMARIES_BT2020:
-                {
-                    msg_Dbg(vd, "Using BT.2020 color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
-                    break;
-                }
-                case COLOR_PRIMARIES_DCI_P3:
-                {
-                    msg_Dbg(vd, "Using DCI P3 color space");
-                    sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceDCIP3);
-                    break;
-                }
-                default:
-                {
-                    msg_Dbg(vd, "Guessing color space based on video dimensions (%ix%i)", vd->fmt.i_visible_width, vd->fmt.i_visible_height);
-                    if (vd->fmt.i_visible_height >= 2000 || vd->fmt.i_visible_width >= 3800) {
-                        msg_Dbg(vd, "Using BT.2020 color space");
-                        sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceITUR_2020);
-                    } else if (vd->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");
-            sys->cgColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
-        }
-        sys->nsColorSpace = [[NSColorSpace alloc] initWithCGColorSpace:sys->cgColorSpace];
-
         /* Get our main view*/
         [VLCOpenGLVideoView performSelectorOnMainThread:@selector(getNewView:)
                                              withObject:[NSValue valueWithPointer:&sys->glView]
@@ -360,12 +298,6 @@ void Close (vlc_object_t *this)
 
         [sys->glView release];
 
-        if (sys->cgColorSpace != nil)
-            CGColorSpaceRelease(sys->cgColorSpace);
-
-        if (sys->nsColorSpace != nil)
-            [sys->nsColorSpace release];
-
         if (sys->embed)
             vout_display_DeleteWindow (vd, sys->embed);
         free (sys);
@@ -904,23 +836,4 @@ static void OpenglSwap (vlc_gl_t *gl)
     return YES;
 }
 
-- (void)viewWillMoveToWindow:(nullable NSWindow *)newWindow
-{
-    [super viewWillMoveToWindow:newWindow];
-
-    if (newWindow == nil)
-        return;
-
-    @synchronized (self) {
-        @try {
-            if (vd) [newWindow setColorSpace:vd->sys->nsColorSpace];
-        }
-        @catch (NSException *exception) {
-            msg_Warn(vd, "Setting the window color space failed due to an Obj-C exception (%s, %s", [exception.name UTF8String], [exception.reason UTF8String]);
-        }
-
-    }
-
-}
-
 @end
-- 
2.13.1



More information about the vlc-devel mailing list