Title: [286953] trunk/Source/WebCore
Revision
286953
Author
jer.no...@apple.com
Date
2021-12-13 09:53:55 -0800 (Mon, 13 Dec 2021)

Log Message

Unreviewed build fix; add a convenience function to safely compare possibly null CFStringRefs.


* platform/graphics/avfoundation/FormatDescriptionUtilities.cpp:
(WebCore::presentationSizeFromFormatDescription):
(WebCore::colorSpaceFromFormatDescription):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286952 => 286953)


--- trunk/Source/WebCore/ChangeLog	2021-12-13 17:19:12 UTC (rev 286952)
+++ trunk/Source/WebCore/ChangeLog	2021-12-13 17:53:55 UTC (rev 286953)
@@ -1,3 +1,11 @@
+2021-12-13  Jer Noble  <jer.no...@apple.com>
+
+        Unreviewed build fix; add a convenience function to safely compare possibly null CFStringRefs.
+
+        * platform/graphics/avfoundation/FormatDescriptionUtilities.cpp:
+        (WebCore::presentationSizeFromFormatDescription):
+        (WebCore::colorSpaceFromFormatDescription):
+
 2021-12-13  Sergio Villar Senin  <svil...@igalia.com>
 
         [css-writing-modes] Use the correct margins in computeInlinePreferredLogicalWidths in orthogonal flows

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.cpp (286952 => 286953)


--- trunk/Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.cpp	2021-12-13 17:19:12 UTC (rev 286952)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.cpp	2021-12-13 17:53:55 UTC (rev 286953)
@@ -49,7 +49,7 @@
 {
     if (!formatDescription)
         return { };
-    
+
     return FloatSize(PAL::CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true));
 }
 
@@ -58,29 +58,35 @@
     if (!formatDescription)
         return std::nullopt;
 
+    auto safeCFStringEquals = [] (CFStringRef one, CFStringRef two) -> bool {
+        if (!one || !two)
+            return false;
+        return CFStringCompare(one, two, 0) == kCFCompareEqualTo;
+    };
+
     PlatformVideoColorSpace colorSpace;
     if (auto primaries = static_cast<CFStringRef>(PAL::CMFormatDescriptionGetExtension(formatDescription, PAL::get_CoreMedia_kCMFormatDescriptionExtension_ColorPrimaries()))) {
-        if (CFStringCompare(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_ITU_R_709_2(), 0) == kCFCompareEqualTo)
+        if (safeCFStringEquals(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_ITU_R_709_2()))
             colorSpace.primaries = PlatformVideoColorPrimaries::Bt709;
-        else if (CFStringCompare(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_EBU_3213(), 0) == kCFCompareEqualTo)
+        else if (safeCFStringEquals(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_EBU_3213()))
             colorSpace.primaries = PlatformVideoColorPrimaries::Bt470bg;
-        else if (CFStringCompare(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_SMPTE_C(), 0) == kCFCompareEqualTo)
+        else if (safeCFStringEquals(primaries, PAL::get_CoreMedia_kCMFormatDescriptionColorPrimaries_SMPTE_C()))
             colorSpace.primaries = PlatformVideoColorPrimaries::Smpte170m;
     }
 
     if (auto transfer = static_cast<CFStringRef>(PAL::CMFormatDescriptionGetExtension(formatDescription, PAL::get_CoreMedia_kCMFormatDescriptionExtension_TransferFunction()))) {
-        if (CFStringCompare(transfer, PAL::get_CoreMedia_kCMFormatDescriptionTransferFunction_ITU_R_709_2(), 0) == kCFCompareEqualTo)
+        if (safeCFStringEquals(transfer, PAL::get_CoreMedia_kCMFormatDescriptionTransferFunction_ITU_R_709_2()))
             colorSpace.transfer = PlatformVideoTransferCharacteristics::Bt709;
-        else if (CFStringCompare(transfer, PAL::get_CoreMedia_kCMFormatDescriptionTransferFunction_sRGB(), 0) == kCFCompareEqualTo)
+        else if (safeCFStringEquals(transfer, PAL::get_CoreMedia_kCMFormatDescriptionTransferFunction_sRGB()))
             colorSpace.transfer = PlatformVideoTransferCharacteristics::Iec6196621;
     }
 
     if (auto matrix = static_cast<CFStringRef>(PAL::CMFormatDescriptionGetExtension(formatDescription, PAL::get_CoreMedia_kCMFormatDescriptionExtension_YCbCrMatrix()))) {
-        if (CFStringCompare(matrix, PAL::get_CoreMedia_kCVImageBufferYCbCrMatrix_ITU_R_709_2(), 0) == kCFCompareEqualTo)
+        if (safeCFStringEquals(matrix, PAL::get_CoreMedia_kCVImageBufferYCbCrMatrix_ITU_R_709_2()))
             colorSpace.matrix = PlatformVideoMatrixCoefficients::Bt709;
-        else if (CFStringCompare(matrix, PAL::get_CoreMedia_kCVImageBufferYCbCrMatrix_ITU_R_601_4(), 0) == kCFCompareEqualTo)
+        else if (safeCFStringEquals(matrix, PAL::get_CoreMedia_kCVImageBufferYCbCrMatrix_ITU_R_601_4()))
             colorSpace.matrix = PlatformVideoMatrixCoefficients::Bt470bg;
-        else if (CFStringCompare(matrix, PAL::get_CoreMedia_kCMFormatDescriptionYCbCrMatrix_SMPTE_240M_1995(), 0) == kCFCompareEqualTo)
+        else if (safeCFStringEquals(matrix, PAL::get_CoreMedia_kCMFormatDescriptionYCbCrMatrix_SMPTE_240M_1995()))
             colorSpace.matrix = PlatformVideoMatrixCoefficients::Smpte170m;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to