[libav-devel] [PATCH 4/6] vdpau: add a constructor for AVVDPAUContext.

Anton Khirnov anton at khirnov.net
Mon Nov 4 21:35:45 CET 2013


On Mon, 4 Nov 2013 21:02:02 +0100, wm4 <nfxjfg at googlemail.com> wrote:
> On Sun,  3 Nov 2013 23:27:48 +0100
> Anton Khirnov <anton at khirnov.net> wrote:
> 
> > We will likely want to add new fields to it in the future, so this is
> > needed to avoid breaking ABI.
> > ---
> >  doc/APIchanges     |    2 ++
> >  libavcodec/vdpau.c |    5 +++++
> >  libavcodec/vdpau.h |   11 +++++++++++
> >  3 files changed, 18 insertions(+)
> > 
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index 93d1608..db30bb9 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -15,6 +15,8 @@ API changes, most recent first:
> >  
> >  2013-11-xx - xxxxxxx - lavc 55.25.0 - vdpau.h
> >    Add av_vdpau_get_profile().
> > +  Add av_vdpau_alloc_context(). This function must from now on be
> > +  used for allocating AVVDPAUContext.
> >  
> >  2013-08-xx - xxxxxxx - lavu 52.17.0 - avframe.h
> >    Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT.
> > diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
> > index 5cabb7e..ba11195 100644
> > --- a/libavcodec/vdpau.c
> > +++ b/libavcodec/vdpau.c
> > @@ -127,4 +127,9 @@ int av_vdpau_get_profile(AVCodecContext *avctx)
> >      return AVERROR(EINVAL);
> >  }
> >  
> > +AVVDPAUContext *av_vdpau_alloc_context(void)
> > +{
> > +    return av_mallocz(sizeof(AVVDPAUContext));
> > +}
> > +
> >  /* @}*/
> > diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
> > index 49ca6f0..16547e4 100644
> > --- a/libavcodec/vdpau.h
> > +++ b/libavcodec/vdpau.h
> > @@ -72,6 +72,10 @@ union AVVDPAUPictureInfo {
> >   * during initialization or through each AVCodecContext.get_buffer()
> >   * function call. In any case, they must be valid prior to calling
> >   * decoding functions.
> > + *
> > + * This size of this structure is not a part of the public ABI and must not
> > + * be used outside of libavcodec. Use av_vdpau_alloc_context() to allocate an
> > + * AVVDPAUContext.
> >   */
> >  typedef struct AVVDPAUContext {
> >      /**
> > @@ -125,6 +129,13 @@ typedef struct AVVDPAUContext {
> >  } AVVDPAUContext;
> >  
> >  /**
> > + * Allocate an AVVDPAUContext.
> > + *
> > + * @return newly allocated AVVDPAUContext or NULL on failure.
> > + */
> > +AVVDPAUContext *av_vdpau_alloc_context(void);
> > +
> > +/**
> >   * Get a decoder profile that should be used for initializing a VDPAU decoder.
> >   * Should be called from the AVCodecContext.get_format() callback.
> >   *
> 
> As far as I'm aware, the only fields the user has to access are decoder
> and render. If you're going to change the API, maybe make this struct
> non-public, let libavcodec allocate it, and add setters for the
> decoder/render fields.

Those are also the only fields that exist in that struct. The whole point of it
is that it's all public. Non-public parts are hidden deeper in lavc.

So I really don't see any advantage to making it opaque.

-- 
Anton Khirnov


More information about the libav-devel mailing list