On Thu,  8 May 2014 15:15:06 +0200, Luca Barbato <[email protected]> wrote:
> It would reduce the boilerplate code users have to write.
> ---
>  libavcodec/avcodec.h       | 5 +++++
>  libavcodec/pthread_frame.c | 4 ++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index d89cbf8..4be8849 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2947,6 +2947,11 @@ typedef struct AVHWAccel {
>      struct AVHWAccel *next;
>  
>      /**
> +     * Allocate a custom buffer
> +     */
> +    int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
> +
> +    /**
>       * Called at the beginning of each frame or field picture.
>       *
>       * Meaningful frame information (codec specific) is guaranteed to
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 34ca9a6..645b3b9 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -694,10 +694,14 @@ void ff_thread_flush(AVCodecContext *avctx)
>  int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
>  {
>      PerThreadContext *p = avctx->internal->thread_ctx;
> +    const AVHWAccel *hwaccel = avctx->hwaccel;
>      int err;
>  
>      f->owner = avctx;
>  
> +    if (hwaccel && hwaccel->alloc_frame)
> +        return hwaccel->alloc_frame(avctx, f->f);
> +
>      if (!(avctx->active_thread_type & FF_THREAD_FRAME))
>          return ff_get_buffer(avctx, f->f, flags);
>  
> -- 
> 1.9.0
> 

This assumes every hwaccel user is frame-threaded.
Which might be true now, but there's no reason for it to be true in general.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to