[FFmpeg-devel] lavc/videotoolbox: allow not setting the kCVPixelBufferPixelFormatTypeKey

Submitted by wm4 on Feb. 24, 2017, 9:44 a.m.

Details

Message ID 20170224094423.12401-1-nfxjfg@googlemail.com
State New
Headers show

Commit Message

wm4 Feb. 24, 2017, 9:44 a.m.
If AVVideotoolboxContext.cv_pix_fmt_type is set to 0, don't set the
kCVPixelBufferPixelFormatTypeKey value on the VT decoder.

This makes VT output its native format, which can be much faster on
some hardware iterations (if the native format does not match with
the requested format, it will be converted, which is slow).

The default is still forcing nv12.
---
TODO: minor libavcodec bump
---
 libavcodec/videotoolbox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

wm4 March 2, 2017, 9:33 a.m.
On Fri, 24 Feb 2017 10:44:23 +0100
wm4 <nfxjfg@googlemail.com> wrote:

> If AVVideotoolboxContext.cv_pix_fmt_type is set to 0, don't set the
> kCVPixelBufferPixelFormatTypeKey value on the VT decoder.
> 
> This makes VT output its native format, which can be much faster on
> some hardware iterations (if the native format does not match with
> the requested format, it will be converted, which is slow).
> 
> The default is still forcing nv12.
> ---
> TODO: minor libavcodec bump
> ---
>  libavcodec/videotoolbox.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
> index 1288aa5087..2ebe60fb5c 100644
> --- a/libavcodec/videotoolbox.c
> +++ b/libavcodec/videotoolbox.c
> @@ -472,7 +472,8 @@ static CFDictionaryRef videotoolbox_buffer_attributes_create(int width,
>                                                        &kCFTypeDictionaryKeyCallBacks,
>                                                        &kCFTypeDictionaryValueCallBacks);
>  
> -    CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt);
> +    if (pix_fmt)
> +        CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt);
>      CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties);
>      CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w);
>      CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h);

Applied.

Patch hide | download patch | download mbox

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 1288aa5087..2ebe60fb5c 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -472,7 +472,8 @@  static CFDictionaryRef videotoolbox_buffer_attributes_create(int width,
                                                       &kCFTypeDictionaryKeyCallBacks,
                                                       &kCFTypeDictionaryValueCallBacks);
 
-    CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt);
+    if (pix_fmt)
+        CFDictionarySetValue(buffer_attributes, kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt);
     CFDictionarySetValue(buffer_attributes, kCVPixelBufferIOSurfacePropertiesKey, io_surface_properties);
     CFDictionarySetValue(buffer_attributes, kCVPixelBufferWidthKey, w);
     CFDictionarySetValue(buffer_attributes, kCVPixelBufferHeightKey, h);