[FFmpeg-devel] [PATCH 07/15] lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicable
rcombs
rcombs at rcombs.me
Sat Nov 13 23:09:08 EET 2021
---
libavcodec/videotoolbox.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index a5b0777c41..764021586b 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -1062,9 +1062,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_NV20;
+ }
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
if (depth > 8) {
return AV_PIX_FMT_P010;
}
+#endif
return AV_PIX_FMT_NV12;
}
--
2.33.1
More information about the ffmpeg-devel
mailing list