diff mbox series

[FFmpeg-devel,07/16] lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicable

Message ID 20211122205330.43546-7-rcombs@rcombs.me
State New
Headers show
Series [FFmpeg-devel,01/16] ffmpeg: remove ffmpeg_videotoolbox | 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

rcombs Nov. 22, 2021, 8:53 p.m. UTC
---
 libavcodec/videotoolbox.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 010f553e57..57b37bf3bf 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -1064,9 +1064,35 @@  static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx)
         return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context()
 
     int depth = descriptor->comp[0].depth;
+
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
+    if (depth > 10)
+        return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216;
+#endif
+
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
+    if (descriptor->log2_chroma_w == 0) {
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
+        if (depth <= 8)
+            return AV_PIX_FMT_NV24;
+#endif
+        return AV_PIX_FMT_P410;
+    }
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
+    if (descriptor->log2_chroma_h == 0) {
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
+        if (depth <= 8)
+            return AV_PIX_FMT_NV16;
+#endif
+        return AV_PIX_FMT_P210;
+    }
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
     if (depth > 8) {
         return AV_PIX_FMT_P010;
     }
+#endif
 
     return AV_PIX_FMT_NV12;
 }