diff mbox series

[FFmpeg-devel,v2] avutil/hwcontext_videotoolbox: fix use of unknown builtin '__builtin_available'

Message ID 1635680650-1402-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 6cab5206b0ad94990c435cb7c5cf3b29675e0231
Headers show
Series [FFmpeg-devel,v2] avutil/hwcontext_videotoolbox: fix use of unknown builtin '__builtin_available' | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Limin Wang Oct. 31, 2021, 11:44 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

OSX version: 10.11.6
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 configure                          |  8 ++++++
 libavutil/hwcontext_videotoolbox.c | 54 +++++++++++++++++++++-----------------
 2 files changed, 38 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/configure b/configure
index ede8f97..c4fb1b7 100755
--- a/configure
+++ b/configure
@@ -2329,6 +2329,10 @@  TYPES_LIST="
     kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
     kCVImageBufferTransferFunction_ITU_R_2100_HLG
     kCVImageBufferTransferFunction_Linear
+    kCVImageBufferYCbCrMatrix_ITU_R_2020
+    kCVImageBufferColorPrimaries_ITU_R_2020
+    kCVImageBufferTransferFunction_ITU_R_2020
+    kCVImageBufferTransferFunction_SMPTE_ST_428_1
     socklen_t
     struct_addrinfo
     struct_group_source_req
@@ -6273,6 +6277,10 @@  enabled videotoolbox && {
     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo"
     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo"
     check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_Linear "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferYCbCrMatrix_ITU_R_2020 "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferColorPrimaries_ITU_R_2020 "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2020 "-framework CoreVideo"
+    check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_428_1 "-framework CoreVideo"
 }
 
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c
index 58095a1..25f4e17 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -375,10 +375,11 @@  static int vt_pixbuf_set_colorspace(AVHWFramesContext *hwfc,
     switch (src->colorspace) {
     case AVCOL_SPC_BT2020_CL:
     case AVCOL_SPC_BT2020_NCL:
-        if (__builtin_available(macOS 10.11, *))
-            colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020;
-        else
-            colormatrix = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERYCBCRMATRIX_ITU_R_2020
+        colormatrix = kCVImageBufferYCbCrMatrix_ITU_R_2020;
+#else
+        colormatrix = CFSTR("ITU_R_2020");
+#endif
         break;
     case AVCOL_SPC_BT470BG:
     case AVCOL_SPC_SMPTE170M:
@@ -398,10 +399,11 @@  static int vt_pixbuf_set_colorspace(AVHWFramesContext *hwfc,
 
     switch (src->color_primaries) {
     case AVCOL_PRI_BT2020:
-        if (__builtin_available(macOS 10.11, *))
-            colorpri = kCVImageBufferColorPrimaries_ITU_R_2020;
-        else
-            colorpri = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERCOLORPRIMARIES_ITU_R_2020
+        colorpri = kCVImageBufferColorPrimaries_ITU_R_2020;
+#else
+        colorpri = CFSTR("ITU_R_2020");
+#endif
         break;
     case AVCOL_PRI_BT709:
         colorpri = kCVImageBufferColorPrimaries_ITU_R_709_2;
@@ -420,17 +422,19 @@  static int vt_pixbuf_set_colorspace(AVHWFramesContext *hwfc,
 
     switch (src->color_trc) {
     case AVCOL_TRC_SMPTE2084:
-        if (__builtin_available(macOS 10.13, *))
-            colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
-        else
-            colortrc = CFSTR("SMPTE_ST_2084_PQ");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
+        colortrc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
+#else
+        colortrc = CFSTR("SMPTE_ST_2084_PQ");
+#endif
         break;
     case AVCOL_TRC_BT2020_10:
     case AVCOL_TRC_BT2020_12:
-        if (__builtin_available(macOS 10.11, *))
-            colortrc = kCVImageBufferTransferFunction_ITU_R_2020;
-        else
-            colortrc = CFSTR("ITU_R_2020");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2020
+        colortrc = kCVImageBufferTransferFunction_ITU_R_2020;
+#else
+        colortrc = CFSTR("ITU_R_2020");
+#endif
         break;
     case AVCOL_TRC_BT709:
         colortrc = kCVImageBufferTransferFunction_ITU_R_709_2;
@@ -439,16 +443,18 @@  static int vt_pixbuf_set_colorspace(AVHWFramesContext *hwfc,
         colortrc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
         break;
     case AVCOL_TRC_SMPTE428:
-        if (__builtin_available(macOS 10.12, *))
-            colortrc = kCVImageBufferTransferFunction_SMPTE_ST_428_1;
-        else
-            colortrc = CFSTR("SMPTE_ST_428_1");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_428_1
+        colortrc = kCVImageBufferTransferFunction_SMPTE_ST_428_1;
+#else
+        colortrc = CFSTR("SMPTE_ST_428_1");
+#endif
         break;
     case AVCOL_TRC_ARIB_STD_B67:
-        if (__builtin_available(macOS 10.13, *))
-            colortrc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
-        else
-            colortrc = CFSTR("ITU_R_2100_HLG");
+#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
+        colortrc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
+#else
+        colortrc = CFSTR("ITU_R_2100_HLG");
+#endif
         break;
     case AVCOL_TRC_GAMMA22:
         gamma = 2.2;