[vlc-devel] [vlc-commits] va: mostly remove the setup callback

Steve Lhomme robux4 at gmail.com
Wed Apr 6 10:39:34 CEST 2016


On Mon, Feb 29, 2016 at 5:38 PM, Steve Lhomme <robux4 at gmail.com> wrote:
> On Sun, Sep 27, 2015 at 9:57 PM, Rémi Denis-Courmont <git at videolan.org> wrote:
>> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 27 16:01:52 2015 +0300| [0ce8fcaeb1050c323ecaeef3b25c548698597799] | committer: Rémi Denis-Courmont
>>
>> va: mostly remove the setup callback
>>
>> The coded video size is already fixed by the decoder when creating the
>> vidoe acceleration plugin, while the chroma is fixed by
>> vlc_va_GetChroma(). This callback is useless.
>>
>>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0ce8fcaeb1050c323ecaeef3b25c548698597799
>> ---
>>
>>  modules/codec/avcodec/va.c    |   10 ++++++++++
>>  modules/codec/avcodec/va.h    |   12 +++---------
>>  modules/codec/avcodec/vaapi.c |    6 ------
>>  modules/codec/avcodec/vda.c   |    7 -------
>>  modules/codec/avcodec/video.c |    2 --
>>  modules/hw/vdpau/avcodec.c    |   21 ---------------------
>>  6 files changed, 13 insertions(+), 45 deletions(-)
>>
>> diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
>> index 8c13e55..f534f89 100644
>> --- a/modules/codec/avcodec/va.c
>> +++ b/modules/codec/avcodec/va.c
>> @@ -109,6 +109,16 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
>>      if (va->module == NULL)
>>      {
>>          vlc_object_release(va);
>> +#ifdef _WIN32
>> +        return NULL;
>> +    }
>> +
>> +    vlc_fourcc_t chroma;
>> +    va->setup(va, &chroma);
>> +    if (chroma != vlc_va_GetChroma(pix_fmt, AV_PIX_FMT_YUV420P))
>> +    {   /* Mismatch, cannot work, fail */
>> +        vlc_va_Delete(va, avctx);
>> +#endif
>
> This broke the case of DXVA2 not outputting an opaque format when the
> vout cannot handle it. In that case it silently outputs VLC_CODEC_YV12
> and do the conversion on each frame coming out.
>
> vlc_va_GetChroma() has no way of knowing this is happening.

Can this be reverted or we need to find a solution for how to handle
DXVA2 and D3D11VA outputting textures that cannot be handled by the
vout (D3D11 vs D3D9 mismatch or D3D11/D3D9 textures on
DirectDraw/OpenGL/GDI output) ?

We may use 2 different pixel formats so they are both tried for the
same vout, but I doubt it works as libavcodec only provides one per
output. And in the end we would have 2 values for exactly the same
internal data.

We may even need 3 with DXGI_FORMAT_420_OPAQUE. It's a format that is
available for decoding, sometimes the only one available, but cannot
be rendered. So the vout will never provide this. A Video Processor
will need to be used to extract the pixels from the texture.

So IMO the old approach where the output pixel format from the VA is
dynamic was the right approach. Relying on a single value from
vlc_va_GetChroma() cannot handle many cases.

>>          va = NULL;
>>      }
>>      return va;
>> diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
>> index 5dc8b0a..e697118 100644
>> --- a/modules/codec/avcodec/va.h
>> +++ b/modules/codec/avcodec/va.h
>> @@ -36,7 +36,10 @@ struct vlc_va_t {
>>      module_t *module;
>>      const char *description;
>>
>> +#ifdef _WIN32
>> +    VLC_DEPRECATED
>>      void (*setup)(vlc_va_t *, vlc_fourcc_t *output);
>> +#endif
>>      int  (*get)(vlc_va_t *, picture_t *pic, uint8_t **data);
>>      void (*release)(void *pic, uint8_t *surface);
>>      int  (*extract)(vlc_va_t *, picture_t *pic, uint8_t *data);
>> @@ -62,15 +65,6 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
>>                       picture_sys_t *p_sys);
>>
>>  /**
>> - * Initializes the acceleration video decoding back-end for libavcodec.
>> - * @param output pointer to video chroma output by the back-end [OUT]
>> - */
>> -static inline void vlc_va_Setup(vlc_va_t *va, vlc_fourcc_t *output)
>> -{
>> -    va->setup(va, output);
>> -}
>> -
>> -/**
>>   * Allocates a hardware video surface for a libavcodec frame.
>>   * The surface will be used as output for the hardware decoder, and possibly
>>   * also as a reference frame to decode other surfaces.
>> diff --git a/modules/codec/avcodec/vaapi.c b/modules/codec/avcodec/vaapi.c
>> index 24ddda4..c4dc52a 100644
>> --- a/modules/codec/avcodec/vaapi.c
>> +++ b/modules/codec/avcodec/vaapi.c
>> @@ -187,11 +187,6 @@ static void Release( void *opaque, uint8_t *data )
>>      (void) data;
>>  }
>>
>> -static void Setup( vlc_va_t *va, vlc_fourcc_t *pi_chroma )
>> -{
>> -    *pi_chroma = VLC_CODEC_YV12;
>> -}
>> -
>>  static void Delete( vlc_va_t *va, AVCodecContext *avctx )
>>  {
>>      vlc_va_sys_t *sys = va->sys;
>> @@ -462,7 +457,6 @@ static int Create( vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
>>      ctx->hwaccel_context = &sys->hw_ctx;
>>      va->sys = sys;
>>      va->description = vaQueryVendorString(sys->hw_ctx.display);
>> -    va->setup = Setup;
>>      va->get = Get;
>>      va->release = Release;
>>      va->extract = Extract;
>> diff --git a/modules/codec/avcodec/vda.c b/modules/codec/avcodec/vda.c
>> index 979b882..2f248d2 100644
>> --- a/modules/codec/avcodec/vda.c
>> +++ b/modules/codec/avcodec/vda.c
>> @@ -48,7 +48,6 @@
>>  static int Open( vlc_va_t *, AVCodecContext *, enum PixelFormat,
>>                   const es_format_t *, picture_sys_t * );
>>  static void Close( vlc_va_t * , AVCodecContext *);
>> -static void Setup( vlc_va_t *, vlc_fourcc_t *);
>>  static int Get( vlc_va_t *, picture_t *, uint8_t ** );
>>  static int Extract( vlc_va_t *, picture_t *, uint8_t * );
>>  static void Release( void *opaque, uint8_t *data );
>> @@ -160,7 +159,6 @@ static int Open(vlc_va_t *va,
>>
>>      va->sys = sys;
>>      va->description = (char *)"VDA";
>> -    va->setup = Setup;
>>      va->get = Get;
>>      va->release = Release;
>>      va->extract = Extract;
>> @@ -174,11 +172,6 @@ static void Close( vlc_va_t *va, AVCodecContext *avctx )
>>      (void) va;
>>  }
>>
>> -static void Setup( vlc_va_t *va, vlc_fourcc_t *pi_chroma )
>> -{
>> -    *pi_chroma = VLC_CODEC_I420;
>> -}
>> -
>>  // Never called
>>  static int Get( vlc_va_t *va, picture_t *p_picture, uint8_t **data )
>>  {
>> diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
>> index 4f6a0e2..c8841e4 100644
>> --- a/modules/codec/avcodec/video.c
>> +++ b/modules/codec/avcodec/video.c
>> @@ -1133,8 +1133,6 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
>>              picture_Release(test_pic);
>>          if (va == NULL)
>>              continue; /* Unsupported codec profile or such */
>> -
>> -        vlc_va_Setup(va, &p_dec->fmt_out.video.i_chroma);
>>          post_mt(p_sys);
>>
>>          if (va->description != NULL)
>> diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
>> index 0db483f..71c17dd 100644
>> --- a/modules/hw/vdpau/avcodec.c
>> +++ b/modules/hw/vdpau/avcodec.c
>> @@ -140,26 +140,6 @@ static int Copy(vlc_va_t *va, picture_t *pic, uint8_t *data)
>>      return VLC_SUCCESS;
>>  }
>>
>> -static void Setup(vlc_va_t *va, vlc_fourcc_t *chromap)
>> -{
>> -    vlc_va_sys_t *sys = va->sys;
>> -
>> -    switch (sys->type)
>> -    {
>> -        case VDP_CHROMA_TYPE_420:
>> -            *chromap = VLC_CODEC_VDPAU_VIDEO_420;
>> -            break;
>> -        case VDP_CHROMA_TYPE_422:
>> -            *chromap = VLC_CODEC_VDPAU_VIDEO_422;
>> -            break;
>> -        case VDP_CHROMA_TYPE_444:
>> -            *chromap = VLC_CODEC_VDPAU_VIDEO_444;
>> -            break;
>> -        default:
>> -            vlc_assert_unreachable();
>> -    }
>> -}
>> -
>>  static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
>>                  const es_format_t *fmt, picture_sys_t *p_sys)
>>  {
>> @@ -336,7 +316,6 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, enum PixelFormat pix_fmt,
>>          infos = "VDPAU";
>>
>>      va->description = infos;
>> -    va->setup = Setup;
>>      va->get = Lock;
>>      va->release = NULL;
>>      va->extract = Copy;
>>
>> _______________________________________________
>> vlc-commits mailing list
>> vlc-commits at videolan.org
>> https://mailman.videolan.org/listinfo/vlc-commits


More information about the vlc-devel mailing list