[vlc-devel] [PATCH] avcodec: pass a dummy picture_sys_t to the va decoder Open()
Rémi Denis-Courmont
remi at remlab.net
Mon Apr 27 13:41:18 CEST 2015
Le 2015-04-27 14:22, Steve Lhomme a écrit :
> may share some resources between the decoder pool pictures and the
> va.
> ---
> modules/codec/avcodec/dxva2.c | 4 ++--
> modules/codec/avcodec/va.c | 10 ++++++----
> modules/codec/avcodec/va.h | 3 ++-
> modules/codec/avcodec/vaapi.c | 2 +-
> modules/codec/avcodec/vda.c | 4 ++--
> modules/codec/avcodec/video.c | 7 ++++++-
> modules/hw/vdpau/avcodec.c | 2 +-
> 7 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/modules/codec/avcodec/dxva2.c
> b/modules/codec/avcodec/dxva2.c
> index 05dff18..8c78132 100644
> --- a/modules/codec/avcodec/dxva2.c
> +++ b/modules/codec/avcodec/dxva2.c
> @@ -53,7 +53,7 @@
> #include "../../video_chroma/copy.h"
>
> static int Open(vlc_va_t *, AVCodecContext *, enum PixelFormat,
> - const es_format_t *);
> + const es_format_t *, const picture_sys_t *p_sys);
> static void Close(vlc_va_t *, AVCodecContext *);
>
> vlc_module_begin()
> @@ -546,7 +546,7 @@ static void Close(vlc_va_t *va, AVCodecContext
> *ctx)
> }
>
> static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat
> pix_fmt,
> - const es_format_t *fmt)
> + const es_format_t *fmt, const picture_sys_t *p_sys)
> {
> if (pix_fmt != AV_PIX_FMT_DXVA2_VLD)
> return VLC_EGENERIC;
> diff --git a/modules/codec/avcodec/va.c b/modules/codec/avcodec/va.c
> index 2da49ce..328d79f 100644
> --- a/modules/codec/avcodec/va.c
> +++ b/modules/codec/avcodec/va.c
> @@ -75,10 +75,11 @@ static int vlc_va_Start(void *func, va_list ap)
> AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
> enum PixelFormat pix_fmt = va_arg(ap, enum PixelFormat);
> const es_format_t *fmt = va_arg(ap, const es_format_t *);
> + const picture_sys_t *p_sys = va_arg(ap, const picture_sys_t *);
> int (*open)(vlc_va_t *, AVCodecContext *, enum PixelFormat,
> - const es_format_t *) = func;
> + const es_format_t *, const picture_sys_t *) = func;
>
> - return open(va, ctx, pix_fmt, fmt);
> + return open(va, ctx, pix_fmt, fmt, p_sys);
> }
>
> static void vlc_va_Stop(void *func, va_list ap)
> @@ -91,14 +92,15 @@ static void vlc_va_Stop(void *func, va_list ap)
> }
>
> vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
> - enum PixelFormat pix_fmt, const es_format_t
> *fmt)
> + enum PixelFormat pix_fmt, const es_format_t
> *fmt,
> + const picture_sys_t *p_sys)
> {
> vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
> if (unlikely(va == NULL))
> return NULL;
>
> va->module = vlc_module_load(va, "hw decoder", "$avcodec-hw",
> true,
> - vlc_va_Start, va, avctx, pix_fmt,
> fmt);
> + vlc_va_Start, va, avctx, pix_fmt,
> fmt, p_sys);
> if (va->module == NULL)
> {
> vlc_object_release(va);
> diff --git a/modules/codec/avcodec/va.h b/modules/codec/avcodec/va.h
> index fe5b947..ae385eb 100644
> --- a/modules/codec/avcodec/va.h
> +++ b/modules/codec/avcodec/va.h
> @@ -58,7 +58,8 @@ vlc_fourcc_t vlc_va_GetChroma(enum PixelFormat
> hwfmt, enum PixelFormat swfmt);
> * @return a new VLC object on success, NULL on error.
> */
> vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *,
> - enum PixelFormat, const es_format_t *fmt);
> + enum PixelFormat, const es_format_t *fmt,
> + const picture_sys_t *p_sys);
const does not seem like a good idea here. What if a mutex or a
reference counter is stored?
>
> /**
> * Initializes the acceleration video decoding back-end for
> libavcodec.
> diff --git a/modules/codec/avcodec/vaapi.c
> b/modules/codec/avcodec/vaapi.c
> index abc452f..63182ce 100644
> --- a/modules/codec/avcodec/vaapi.c
> +++ b/modules/codec/avcodec/vaapi.c
> @@ -291,7 +291,7 @@ static int FindFormat(vlc_va_sys_t *sys)
> }
>
> static int Create( vlc_va_t *va, AVCodecContext *ctx, enum
> PixelFormat pix_fmt,
> - const es_format_t *fmt )
> + const es_format_t *fmt, const picture_sys_t
> *p_sys )
Missing void cast. Ditto below.
> {
> if( pix_fmt != AV_PIX_FMT_VAAPI_VLD )
> return VLC_EGENERIC;
> diff --git a/modules/codec/avcodec/vda.c
> b/modules/codec/avcodec/vda.c
> index 58173c7..0161ebf 100644
> --- a/modules/codec/avcodec/vda.c
> +++ b/modules/codec/avcodec/vda.c
> @@ -45,7 +45,7 @@
> #pragma mark prototypes and definitions
>
> static int Open( vlc_va_t *, AVCodecContext *, enum PixelFormat,
> - const es_format_t * );
> + const es_format_t *, const picture_sys_t * );
> static void Close( vlc_va_t * , AVCodecContext *);
> static int Setup( vlc_va_t *, AVCodecContext *, vlc_fourcc_t *);
> static int Get( vlc_va_t *, picture_t *, uint8_t ** );
> @@ -117,7 +117,7 @@ static vlc_va_vda_t *vlc_va_vda_Get( vlc_va_t *va
> )
> #pragma mark - module handling
>
> static int Open( vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat
> pix_fmt,
> - const es_format_t *fmt )
> + const es_format_t *fmt, const picture_sys_t *p_sys
> )
> {
> if( pix_fmt != AV_PIX_FMT_VDA_VLD )
> return VLC_EGENERIC;
> diff --git a/modules/codec/avcodec/video.c
> b/modules/codec/avcodec/video.c
> index 75f1132..29af2ee 100644
> --- a/modules/codec/avcodec/video.c
> +++ b/modules/codec/avcodec/video.c
> @@ -1132,8 +1132,13 @@ static enum PixelFormat ffmpeg_GetFormat(
> AVCodecContext *p_context,
> if (lavc_UpdateVideoFormat(p_dec, p_context, true))
> continue; /* Unsupported brand of hardware acceleration
> */
>
> + picture_t *test_pic = decoder_NewPicture(p_dec);
> + assert(!test_pic || test_pic->format.i_chroma ==
> p_dec->fmt_out.video.i_chroma);
> vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context,
> hwfmt,
> - &p_dec->fmt_in);
> + &p_dec->fmt_in,
> + test_pic ? test_pic->p_sys :
> NULL);
> + if (test_pic)
> + picture_Release(test_pic);
> if (va == NULL)
> continue; /* Unsupported codec profile or such */
>
> diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
> index 910d742..c25c45a 100644
> --- a/modules/hw/vdpau/avcodec.c
> +++ b/modules/hw/vdpau/avcodec.c
> @@ -172,7 +172,7 @@ static int Setup(vlc_va_t *va, AVCodecContext
> *avctx, vlc_fourcc_t *chromap)
> }
>
> static int Open(vlc_va_t *va, AVCodecContext *avctx, enum
> PixelFormat pix_fmt,
> - const es_format_t *fmt)
> + const es_format_t *fmt, const picture_sys_t *p_sys)
> {
> if (pix_fmt != AV_PIX_FMT_VDPAU)
> return VLC_EGENERIC;
--
Rémi Denis-Courmont
More information about the vlc-devel
mailing list