[vlc-devel] [PATCH] DxVA2: use the same surface count as libav/FFMpeg (v2)
Steve Lhomme
robux4 at videolabs.io
Tue Apr 21 09:37:55 CEST 2015
This patch is replaced by (v3) aka https://patches.videolan.org/patch/8427/
On Mon, Apr 20, 2015 at 10:37 AM, Steve Lhomme <robux4 at videolabs.io> wrote:
> --
> replaces previous patch 8074
> ---
> modules/codec/avcodec/dxva2.c | 37 +++++++++++++++++++++++++++----------
> 1 file changed, 27 insertions(+), 10 deletions(-)
>
> diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
> index 206a45a..5e68f34 100644
> --- a/modules/codec/avcodec/dxva2.c
> +++ b/modules/codec/avcodec/dxva2.c
> @@ -333,7 +333,7 @@ static void DxDestroyVideoService(vlc_va_sys_t *);
> static int DxFindVideoServiceConversion(vlc_va_t *, GUID *input, D3DFORMAT *output);
>
> static int DxCreateVideoDecoder(vlc_va_t *,
> - int codec_id, const video_format_t *);
> + int codec_id, const video_format_t *, bool);
> static void DxDestroyVideoDecoder(vlc_va_sys_t *);
> static int DxResetVideoDecoder(vlc_va_t *);
>
> @@ -364,7 +364,7 @@ static int Setup(vlc_va_t *va, AVCodecContext *avctx, vlc_fourcc_t *chroma)
> fmt.i_width = avctx->coded_width;
> fmt.i_height = avctx->coded_height;
>
> - if (DxCreateVideoDecoder(va, sys->codec_id, &fmt))
> + if (DxCreateVideoDecoder(va, sys->codec_id, &fmt, avctx->active_thread_type & FF_THREAD_FRAME))
> return VLC_EGENERIC;
> /* */
> sys->hw.decoder = sys->decoder;
> @@ -889,10 +889,12 @@ static int DxFindVideoServiceConversion(vlc_va_t *va, GUID *input, D3DFORMAT *ou
> /**
> * It creates a DXVA2 decoder using the given video format
> */
> -static int DxCreateVideoDecoder(vlc_va_t *va,
> - int codec_id, const video_format_t *fmt)
> +static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
> + const video_format_t *fmt, bool b_threading)
> {
> vlc_va_sys_t *sys = va->sys;
> + int surface_alignment;
> + int surface_count;
>
> /* */
> msg_Dbg(va, "DxCreateVideoDecoder id %d %dx%d",
> @@ -902,22 +904,37 @@ static int DxCreateVideoDecoder(vlc_va_t *va,
> sys->height = fmt->i_height;
>
> /* Allocates all surfaces needed for the decoder */
> - sys->surface_width = (fmt->i_width + 15) & ~15;
> - sys->surface_height = (fmt->i_height + 15) & ~15;
> - int surface_count;
> switch (codec_id) {
> case AV_CODEC_ID_HEVC:
> + /* the HEVC DXVA2 spec asks for 128 pixel aligned surfaces to ensure
> + all coding features have enough room to work with */
> + surface_alignment = 128;
> + surface_count = 4 + 16;
> + break;
> case AV_CODEC_ID_H264:
> - surface_count = 16 + sys->thread_count + 2;
> + surface_alignment = 16;
> + surface_count = 4 + 16;
> break;
> case AV_CODEC_ID_MPEG1VIDEO:
> case AV_CODEC_ID_MPEG2VIDEO:
> - surface_count = 2 + 2;
> + /* decoding MPEG-2 requires additional alignment on some Intel GPUs,
> + but it causes issues for H.264 on certain AMD GPUs..... */
> + surface_alignment = 32;
> + surface_count = 4 + 2;
> break;
> default:
> - surface_count = 2 + 1;
> + surface_alignment = 16;
> + surface_count = 4 + 2;
> break;
> }
> +
> +#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
> + sys->surface_width = ALIGN(fmt->i_width, surface_alignment);
> + sys->surface_height = ALIGN(fmt->i_height, surface_alignment);
> +
> + if ( b_threading )
> + surface_count += sys->thread_count;
> +
> if (surface_count > VA_DXVA2_MAX_SURFACE_COUNT)
> return VLC_EGENERIC;
> sys->surface_count = surface_count;
> --
> 2.3.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list