Commit 0b137832 authored by Brad Werth's avatar Brad Werth
Browse files

Bug 1745492 Part 7: Set the color primaries and transfer functions for macOS...

Bug 1745492 Part 7: Set the color primaries and transfer functions for macOS HD and HDR video. r=media-playback-reviewers,bryce

This also reorders the colorspace if-elses to explicitly check for bt601,
bt709, and bt2020 in that order. This ensures that anything with the Identity
colorspace will be left with no attachments.

Differential Revision: https://phabricator.services.mozilla.com/D140576
parent 548f3cc2
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -427,6 +427,12 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
    // Unlock the returned image data.
    CVPixelBufferUnlockBaseAddress(aImage, kCVPixelBufferLock_ReadOnly);
  } else {
#if !defined(MAC_OS_VERSION_10_13) || \
    MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_10_13
    CFStringRef kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ =
        CFSTR("SMPTE_ST_2084_PQ");
#endif

#ifndef MOZ_WIDGET_UIKIT
    // Set pixel buffer properties on aImage before we extract its surface.
    // This ensures that we can use defined enums to set values instead
@@ -435,13 +441,25 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
      CVBufferSetAttachment(aImage, kCVImageBufferYCbCrMatrixKey,
                            kCVImageBufferYCbCrMatrix_ITU_R_601_4,
                            kCVAttachmentMode_ShouldPropagate);
    } else if (mColorSpace == gfx::YUVColorSpace::BT709) {
      CVBufferSetAttachment(aImage, kCVImageBufferYCbCrMatrixKey,
                            kCVImageBufferYCbCrMatrix_ITU_R_709_2,
                            kCVAttachmentMode_ShouldPropagate);
      CVBufferSetAttachment(aImage, kCVImageBufferColorPrimariesKey,
                            kCVImageBufferColorPrimaries_ITU_R_709_2,
                            kCVAttachmentMode_ShouldPropagate);
      CVBufferSetAttachment(aImage, kCVImageBufferTransferFunctionKey,
                            kCVImageBufferTransferFunction_ITU_R_709_2,
                            kCVAttachmentMode_ShouldPropagate);
    } else if (mColorSpace == gfx::YUVColorSpace::BT2020) {
      CVBufferSetAttachment(aImage, kCVImageBufferYCbCrMatrixKey,
                            kCVImageBufferYCbCrMatrix_ITU_R_2020,
                            kCVAttachmentMode_ShouldPropagate);
    } else {
      CVBufferSetAttachment(aImage, kCVImageBufferYCbCrMatrixKey,
                            kCVImageBufferYCbCrMatrix_ITU_R_709_2,
      CVBufferSetAttachment(aImage, kCVImageBufferColorPrimariesKey,
                            kCVImageBufferColorPrimaries_ITU_R_2020,
                            kCVAttachmentMode_ShouldPropagate);
      CVBufferSetAttachment(aImage, kCVImageBufferTransferFunctionKey,
                            kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ,
                            kCVAttachmentMode_ShouldPropagate);
    }