avutil/hwcontext_videotoolbox: Fix build with older SDKs

I've accidentally used API not available on the checked version.
Additionally check for the SDK to be new enough to even have the
CVImageBufferCreateColorSpaceFromAttachments API to not fail
the build.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Marvin Scholz 2024-07-09 16:46:47 +02:00 committed by Zhao Zhili
parent 5d74dcf0e3
commit 2fc37c4239

View File

@ -588,13 +588,26 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
} else
CVBufferRemoveAttachment(pixbuf, kCVImageBufferGammaLevelKey);
if (__builtin_available(macOS 12.0, iOS 15.0, *)) {
CFDictionaryRef attachments = CVBufferCopyAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate);
#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800) || \
(TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)
if (__builtin_available(macOS 10.8, iOS 10, *)) {
CFDictionaryRef attachments = NULL;
if (__builtin_available(macOS 12.0, iOS 15.0, *))
attachments = CVBufferCopyAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate);
#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED <= 120000) || \
(TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED <= 150000)
else {
CFDictionaryRef tmp = CVBufferGetAttachments(pixbuf, kCVAttachmentMode_ShouldPropagate);
if (tmp)
attachments = CFDictionaryCreateCopy(NULL, tmp);
}
#endif
if (attachments) {
colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments);
CFRelease(attachments);
}
}
#endif
if (colorspace) {
CVBufferSetAttachment(pixbuf, kCVImageBufferCGColorSpaceKey,