[libav-devel] [PATCH] hwaccel: OSX Video Decoder Acceleration support

Sebastien Zwickert dilaroga at gmail.com
Fri Nov 11 15:59:03 CET 2011


On Nov 11, 2011, at 10:25 AM, Diego Biurrun wrote:
> From: Sebastien Zwickert <dilaroga at free.fr>
> 
> Signed-off-by: Diego Biurrun <diego at biurrun.de>
> ---
> This iteration is updated to apply against HEAD, checks a malloc, eliminates
> many suspicious casts and does a few more cosmetic changes.  It's completely
> untested as I have no access to a suitable testing environment.  Compilation
> and runtime tests highly appreciated.  Please use this as base for changes.

The removing of casts in CFDictionaryCreate generates compiler warnings.
The compilation fails cause of the def/undef workaround is necessary.
The compilation fails with gcc-4.2.1 because the emmintrin.h workaround has
been removed.
I do some tests with VLC and I experienced invalid free when opening or closing
the stream. It looks like to be a conflict between ffmpeg-hw and ffmpeg-threads.
Otherwise video playback plays fine through the vda decoder.

Moreover, I put destination image buffer attributes in the vda_context struct in
order to the client is able to choose its preferred output pixel format for image buffers.

> [...]
> +/* Decoder callback that adds the VDA frame to the queue in display order. */
> +static void vda_decoder_callback(void *vda_hw_ctx,
> +                                 CFDictionaryRef user_info,
> +                                 OSStatus status,
> +                                 uint32_t infoFlags,
> +                                 CVImageBufferRef image_buffer)
> +{
> +    struct vda_context *vda_ctx = vda_hw_ctx;
> +    vda_frame *new_frame;
> +    vda_frame *queue_walker;
> +
> +    if (!image_buffer)
> +        return;
> +
> +    if (kCVPixelFormatType_422YpCbCr8 != CVPixelBufferGetPixelFormatType(image_buffer))
> +        return;
> +
> +    if (!(new_frame = av_mallocz(sizeof(vda_frame)));
> +        return AVERROR_ENOMEM;

I removed AVERROR_ENOMEM.

> [...]
> +
> +#ifndef AVCODEC_VDA_H
> +#define AVCODEC_VDA_H
> +
> +#include <pthread.h>
> +#include <stdint.h>
> +#include <VideoDecodeAcceleration/VDADecoder.h>

I added again emmintrin and def/undef Picture workarounds.

> [...]
> +static int end_frame(AVCodecContext *avctx)
> +{
> +    H264Context *h                      = avctx->priv_data;
> +    struct vda_context *vda_ctx         = avctx->hwaccel_context;
> +    struct vda_picture_context *pic_ctx = h->s.current_picture_ptr->f.hwaccel_picture_private;
> +    AVFrame *frame                      = &h->s.current_picture_ptr.f;

This line fails to compile i changed it with the following line

AVFrame *frame                      = &h->s.current_picture_ptr->f;

> […]

Patch updated in attachment.

Best regards,
Sebastien

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-hwaccel-OS-X-Video-Decoder-Acceleration-VDA-support.patch
Type: application/octet-stream
Size: 26804 bytes
Desc: not available
URL: <http://lists.libav.org/pipermail/libav-devel/attachments/20111111/329d8091/attachment-0001.obj>
-------------- next part --------------





More information about the libav-devel mailing list