diff mbox series

[FFmpeg-devel,03/15] lavu/videotoolbox: add 422 and 444 pixel format mappings

Message ID 20211113210916.49167-3-rcombs@rcombs.me
State New
Headers show
Series [FFmpeg-devel,01/15] lavu/pixfmt: add high-bit-depth semi-planar 4:2:2/4:4:4 formats
Related show

Checks

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

Commit Message

rcombs Nov. 13, 2021, 9:09 p.m. UTC
---
 configure                          | 12 ++++++++
 libavutil/hwcontext_videotoolbox.c | 44 ++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

Comments

Wang Bin Nov. 16, 2021, 1:35 a.m. UTC | #1
>
> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
> +    { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
> AV_PIX_FMT_NV20 },
> +    { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
> AV_PIX_FMT_NV20 },
> +#endif
>

It's p210, not nv20.

Regards
rcombs Nov. 16, 2021, 3:03 a.m. UTC | #2
> On Nov 15, 2021, at 19:35, Wang Bin <wbsecg1@gmail.com> wrote:
> 
>> 
>> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
>> +    { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
>> AV_PIX_FMT_NV20 },
>> +    { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
>> AV_PIX_FMT_NV20 },
>> +#endif
>> 
> 
> It's p210, not nv20.

I didn't add a P210 format (since that would've been equivalent to the existing NV20), only P410/P216/P416. I guess I could add P210 as an alias with appropriate enum values and macros? In which case maybe defining the rest of the group (P008 for NV12, P208 for NV16, P408 for NV24) would be worthwhile.

> 
> Regards
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Wang Bin Nov. 16, 2021, 7:21 a.m. UTC | #3
Ridley Combs <rcombs@rcombs.me> 于2021年11月16日周二 上午11:03写道:

>
>
> > On Nov 15, 2021, at 19:35, Wang Bin <wbsecg1@gmail.com> wrote:
> >
> >>
> >> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
> >> +    { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
> >> AV_PIX_FMT_NV20 },
> >> +    { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
> >> AV_PIX_FMT_NV20 },
> >> +#endif
> >>
> >
> > It's p210, not nv20.
>
> I didn't add a P210 format (since that would've been equivalent to the
> existing NV20), only P410/P216/P416.


P210 != NV20. The lower 6 bits of P210 are zeros and must be shifted away.


> I guess I could add P210 as an alias with appropriate enum values and
> macros?


Not an alias. Add a new one like p010, p410 etc.


> In which case maybe defining the rest of the group (P008 for NV12, P208
> for NV16, P408 for NV24) would be worthwhile.
>
>
Maybe.
rcombs Nov. 16, 2021, 8:05 a.m. UTC | #4
> On Nov 16, 2021, at 01:21, Wang Bin <wbsecg1@gmail.com> wrote:
> 
> Ridley Combs <rcombs@rcombs.me <mailto:rcombs@rcombs.me>> 于2021年11月16日周二 上午11:03写道:
> 
>> 
>> 
>>> On Nov 15, 2021, at 19:35, Wang Bin <wbsecg1@gmail.com> wrote:
>>> 
>>>> 
>>>> +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
>>>> +    { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false,
>>>> AV_PIX_FMT_NV20 },
>>>> +    { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,
>>>> AV_PIX_FMT_NV20 },
>>>> +#endif
>>>> 
>>> 
>>> It's p210, not nv20.
>> 
>> I didn't add a P210 format (since that would've been equivalent to the
>> existing NV20), only P410/P216/P416.
> 
> 
> P210 != NV20. The lower 6 bits of P210 are zeros and must be shifted away.

Oh dang, I'd totally missed NV20 being data-in-low-bits. This explains some oddities I'd run into with ProRes, and indeed adding a proper P210 pixfmt fixes them (so I can remove a wonky workaround). Thanks for the catch, fixed.

> 
> 
>> I guess I could add P210 as an alias with appropriate enum values and
>> macros?
> 
> 
> Not an alias. Add a new one like p010, p410 etc.
> 
> 
>> In which case maybe defining the rest of the group (P008 for NV12, P208
>> for NV16, P408 for NV24) would be worthwhile.
>> 
>> 
> Maybe.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org <mailto:ffmpeg-devel-request@ffmpeg.org> with subject "unsubscribe".
diff mbox series

Patch

diff --git a/configure b/configure
index 891824757b..97c0133f8c 100755
--- a/configure
+++ b/configure
@@ -2327,6 +2327,12 @@  TYPES_LIST="
     kCMVideoCodecType_HEVC
     kCMVideoCodecType_HEVCWithAlpha
     kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange
+    kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange
+    kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange
+    kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange
+    kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange
+    kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange
+    kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange
     kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ
     kCVImageBufferTransferFunction_ITU_R_2100_HLG
     kCVImageBufferTransferFunction_Linear
@@ -6277,6 +6283,12 @@  enabled videotoolbox && {
     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia"
     check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia"
     check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange "-framework CoreVideo"
+    check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange "-framework CoreVideo"
     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"
diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c
index 25f4e17715..0a6c9ecfb0 100644
--- a/libavutil/hwcontext_videotoolbox.c
+++ b/libavutil/hwcontext_videotoolbox.c
@@ -53,13 +53,57 @@  static const struct {
     { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P010 },
     { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange,  true,  AV_PIX_FMT_P010 },
 #endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
+    { kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange,  false, AV_PIX_FMT_NV16 },
+    { kCVPixelFormatType_422YpCbCr8BiPlanarFullRange,   true,  AV_PIX_FMT_NV16 },
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
+    { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_NV20 },
+    { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange,  true,  AV_PIX_FMT_NV20 },
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE
+    { kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P216 },
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
+    { kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange,  false, AV_PIX_FMT_NV24 },
+    { kCVPixelFormatType_444YpCbCr8BiPlanarFullRange,   true,  AV_PIX_FMT_NV24 },
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
+    { kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P410 },
+    { kCVPixelFormatType_444YpCbCr10BiPlanarFullRange,  true,  AV_PIX_FMT_P410 },
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
+    { kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P416 },
+#endif
 };
 
 static const enum AVPixelFormat supported_formats[] = {
+#ifdef kCFCoreFoundationVersionNumber10_7
     AV_PIX_FMT_NV12,
+#endif
     AV_PIX_FMT_YUV420P,
     AV_PIX_FMT_UYVY422,
+#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
     AV_PIX_FMT_P010,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE
+    AV_PIX_FMT_NV16,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE
+    AV_PIX_FMT_NV20,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE
+    AV_PIX_FMT_P216,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE
+    AV_PIX_FMT_NV24,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE
+    AV_PIX_FMT_P410,
+#endif
+#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
+    AV_PIX_FMT_P416,
+#endif
     AV_PIX_FMT_BGRA,
 };