On Tue, 12 Jan 2016 10:26:21 +0100
Anton Khirnov <[email protected]> wrote:

> This is properly namespaced and consistent with the naming in the rest
> of Libav. Also, add a constructor for this struct.
> ---
>  doc/APIchanges              |  4 ++++
>  libavcodec/Makefile         |  1 +
>  libavcodec/avcodec.h        |  2 +-
>  libavcodec/vaapi.c          | 18 ++++++++---------
>  libavcodec/vaapi.h          | 34 ++++++++++++++++++++++++++++++-
>  libavcodec/vaapi_api.c      | 49 
> +++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/vaapi_h264.c     |  4 ++--
>  libavcodec/vaapi_internal.h | 12 +++++------
>  libavcodec/vaapi_mpeg2.c    |  2 +-
>  libavcodec/vaapi_mpeg4.c    |  2 +-
>  libavcodec/vaapi_vc1.c      |  2 +-
>  libavcodec/version.h        |  2 +-
>  12 files changed, 109 insertions(+), 23 deletions(-)
>  create mode 100644 libavcodec/vaapi_api.c
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ffa270e..31a5789 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,10 @@ libavutil:     2015-08-28
>  
>  API changes, most recent first:
>  
> +2016-xx-xx - xxxxxxx - lavc 57.13.0 - vaapi.h
> +  Rename struct vaapi_context to AVVAAPIContext and add
> +  av_vaapi_context_alloc() for allocating it.
> +
>  2015-xx-xx - xxxxxxx - lavc 57.12.0 - avcodec.h
>    Add AVCodecDescriptor.profiles and avcodec_profile_name().
>  
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 4800779..fae6cc2 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -32,6 +32,7 @@ OBJS = allcodecs.o                                          
>             \
>         qsv_api.o                                                        \
>         raw.o                                                            \
>         utils.o                                                          \
> +       vaapi_api.o                                                      \
>         vorbis_parser.o                                                  \
>         xiph.o                                                           \
>  
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 8083111..25ab6c5 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2619,7 +2619,7 @@ typedef struct AVCodecContext {
>       * provided by the user. In that case, this holds display-dependent
>       * data Libav cannot instantiate itself. Please refer to the
>       * Libav HW accelerator documentation to know how to fill this
> -     * is. e.g. for VA API, this is a struct vaapi_context.
> +     * is. e.g. for VA API, this is a AVVAAPIContext.
>       * - encoding: unused
>       * - decoding: Set by user
>       */
> diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
> index befc681..faeb234 100644
> --- a/libavcodec/vaapi.c
> +++ b/libavcodec/vaapi.c
> @@ -42,7 +42,7 @@ static void destroy_buffers(VADisplay display, VABufferID 
> *buffers, unsigned int
>      }
>  }
>  
> -int ff_vaapi_render_picture(AVCodecContext *avctx, struct vaapi_context 
> *vactx,
> +int ff_vaapi_render_picture(AVCodecContext *avctx, AVVAAPIContext *vactx,
>                              VASurfaceID surface)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
> @@ -81,7 +81,7 @@ int ff_vaapi_render_picture(AVCodecContext *avctx, struct 
> vaapi_context *vactx,
>      return 0;
>  }
>  
> -int ff_vaapi_commit_slices(AVCodecContext *avctx, struct vaapi_context 
> *vactx)
> +int ff_vaapi_commit_slices(AVCodecContext *avctx, AVVAAPIContext *vactx)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
>      VABufferID *slice_buf_ids;
> @@ -122,7 +122,7 @@ int ff_vaapi_commit_slices(AVCodecContext *avctx, struct 
> vaapi_context *vactx)
>      return 0;
>  }
>  
> -static void *alloc_buffer(struct vaapi_context *vactx, int type, unsigned 
> int size, uint32_t *buf_id)
> +static void *alloc_buffer(AVVAAPIContext *vactx, int type, unsigned int 
> size, uint32_t *buf_id)
>  {
>      void *data = NULL;
>  
> @@ -134,25 +134,25 @@ static void *alloc_buffer(struct vaapi_context *vactx, 
> int type, unsigned int si
>      return data;
>  }
>  
> -void *ff_vaapi_alloc_pic_param(AVCodecContext *avctx, struct vaapi_context 
> *vactx, unsigned int size)
> +void *ff_vaapi_alloc_pic_param(AVCodecContext *avctx, AVVAAPIContext *vactx, 
> unsigned int size)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
>      return alloc_buffer(vactx, VAPictureParameterBufferType, size, 
> &s->pic_param_buf_id);
>  }
>  
> -void *ff_vaapi_alloc_iq_matrix(AVCodecContext *avctx, struct vaapi_context 
> *vactx, unsigned int size)
> +void *ff_vaapi_alloc_iq_matrix(AVCodecContext *avctx, AVVAAPIContext *vactx, 
> unsigned int size)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
>      return alloc_buffer(vactx, VAIQMatrixBufferType, size, 
> &s->iq_matrix_buf_id);
>  }
>  
> -uint8_t *ff_vaapi_alloc_bitplane(AVCodecContext *avctx, struct vaapi_context 
> *vactx, uint32_t size)
> +uint8_t *ff_vaapi_alloc_bitplane(AVCodecContext *avctx, AVVAAPIContext 
> *vactx, uint32_t size)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
>      return alloc_buffer(vactx, VABitPlaneBufferType, size, 
> &s->bitplane_buf_id);
>  }
>  
> -VASliceParameterBufferBase *ff_vaapi_alloc_slice(AVCodecContext *avctx, 
> struct vaapi_context *vactx,
> +VASliceParameterBufferBase *ff_vaapi_alloc_slice(AVCodecContext *avctx, 
> AVVAAPIContext *vactx,
>                                                   const uint8_t *buffer, 
> uint32_t size)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
> @@ -188,7 +188,7 @@ VASliceParameterBufferBase 
> *ff_vaapi_alloc_slice(AVCodecContext *avctx, struct v
>  void ff_vaapi_common_end_frame(AVCodecContext *avctx)
>  {
>      VAAPIContext *s = avctx->internal->hwaccel_priv_data;
> -    struct vaapi_context * const vactx = avctx->hwaccel_context;
> +    AVVAAPIContext * const vactx = avctx->hwaccel_context;
>  
>      ff_dlog(avctx, "ff_vaapi_common_end_frame()\n");
>  
> @@ -209,7 +209,7 @@ void ff_vaapi_common_end_frame(AVCodecContext *avctx)
>      CONFIG_VC1_VAAPI_HWACCEL   || CONFIG_WMV3_VAAPI_HWACCEL
>  int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx)
>  {
> -    struct vaapi_context * const vactx = avctx->hwaccel_context;
> +    AVVAAPIContext * const vactx = avctx->hwaccel_context;
>      MpegEncContext *s = avctx->priv_data;
>      int ret;
>  
> diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h
> index ea206a5..b75f6ab 100644
> --- a/libavcodec/vaapi.h
> +++ b/libavcodec/vaapi.h
> @@ -41,6 +41,7 @@
>   * @{
>   */
>  
> +#if FF_API_VAAPI_PRIVATE
>  /**
>   * This structure is used to share data between the Libav library and
>   * the client video application.
> @@ -49,6 +50,7 @@
>   * during initialization or through each AVCodecContext.get_buffer()
>   * function call. In any case, they must be valid prior to calling
>   * decoding functions.
> + * @deprecated use AVVAAPIContext instead
>   */
>  struct vaapi_context {
>      /**
> @@ -183,7 +185,37 @@ struct vaapi_context {
>      attribute_deprecated
>      uint32_t slice_data_size;
>  #endif
> -};
> +} attribute_deprecated;
> +#endif
> +
> +/**
> + * This structure is used to share data between caller and libavcodec.
> + * It must be allocated by the caller using av_vaapi_context_alloc()
> + * and made available as AVCodecContext.hwaccel_context after the
> + * AVCodecContext.get_buffer() call returns.
> + */
> +typedef struct AVVAAPIContext {
> +    /**
> +     * Window system dependent data
> +     */
> +    void *display;

Uh well, it's a VADisplay casted to void*?

> +
> +    /**
> +     * Configuration ID
> +     */
> +    uint32_t config_id;
> +
> +    /**
> +     * Context ID (video decode pipeline)
> +     */
> +    uint32_t context_id;

Why even bother with "documentation" here?

> +} AVVAAPIContext;
> +
> +/**
> + * Allocate and initialize a new context. When no longer needed, it must be
> + * freed by the caller using av_free().
> + */
> +AVVAAPIContext *av_vaapi_context_alloc(void);
>  

Maybe we should arrive at a consistent way to do this for hwaccels in
general, instead of changing the API over an over?

I for one can't tell when this has to be called, where the resulting
pointer has to be set, and when/how it has to be deallocated. (I could
look at my own vaapi client code, I'm sure it'd come back to me. But it
doesn't help anyone who is new to this.)

And it's the same (with subtle differences) for most other hwaccels.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to