diff options
author | Damiano Galassi <[email protected]> | 2020-11-09 08:29:40 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2020-11-09 08:29:40 +0100 |
commit | aa2d4d80fb40465e570b008adb418081f975dac8 (patch) | |
tree | 49e890676bb432e24b2ae8d315f5f66b53ab4ae0 /macosx | |
parent | a4ba4655eb67efe383227c15e5014c06f21b87ed (diff) |
MacGui: do not set NULL values in CVImageBufferCreateColorSpaceFromAttachments() input.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBImageUtilities.m | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/macosx/HBImageUtilities.m b/macosx/HBImageUtilities.m index da9a044d3..d17faf5c0 100644 --- a/macosx/HBImageUtilities.m +++ b/macosx/HBImageUtilities.m @@ -212,12 +212,25 @@ CGColorSpaceRef copyColorSpace(int primaries, int transfer, int matrix) matrixValue = kCVImageBufferYCbCrMatrix_ITU_R_709_2; } - const void *keys[4] = { kCVImageBufferColorPrimariesKey, kCVImageBufferTransferFunctionKey, kCVImageBufferYCbCrMatrixKey, kCVImageBufferGammaLevelKey }; - const void *values[4] = { primariesValue, transferValue, matrixValue, gammaValue}; - CFDictionaryRef attachments = CFDictionaryCreate(NULL, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + CGColorSpaceRef colorSpace = NULL; + if (transferValue == kCVImageBufferTransferFunction_UseGamma) + { + const void *keys[4] = { kCVImageBufferColorPrimariesKey, kCVImageBufferTransferFunctionKey, kCVImageBufferYCbCrMatrixKey, kCVImageBufferGammaLevelKey }; + const void *values[4] = { primariesValue, transferValue, matrixValue, gammaValue }; + CFDictionaryRef attachments = CFDictionaryCreate(NULL, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CGColorSpaceRef colorSpace = CVImageBufferCreateColorSpaceFromAttachments(attachments); - CFRelease(attachments); + colorSpace = CVImageBufferCreateColorSpaceFromAttachments(attachments); + CFRelease(attachments); + } + else + { + const void *keys[3] = { kCVImageBufferColorPrimariesKey, kCVImageBufferTransferFunctionKey, kCVImageBufferYCbCrMatrixKey }; + const void *values[3] = { primariesValue, transferValue, matrixValue }; + CFDictionaryRef attachments = CFDictionaryCreate(NULL, keys, values, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + + colorSpace = CVImageBufferCreateColorSpaceFromAttachments(attachments); + CFRelease(attachments); + } return colorSpace; } |