[vlc-devel] [PATCH] avcodec VA: reuse the VA if possible disable thread safe buffer pool on WIN32
Sean McGovern
gseanmcg at gmail.com
Tue Apr 7 15:49:52 CEST 2015
Is there a way to blacklist this on machines where we know it doesn't work? Would that be desirable?
-- Sean McG.
-----Original Message-----
From: Steve Lhomme <robux4 at videolabs.io>
Sender: "vlc-devel" <vlc-devel-bounces at videolan.org>Date: Tue, 7 Apr 2015 15:46:08
To: Mailing list for VLC media player developers<vlc-devel at videolan.org>
Reply-To: Mailing list for VLC media player developers <vlc-devel at videolan.org>
Subject: Re: [vlc-devel] [PATCH] avcodec VA: reuse the VA if possible
disable thread safe buffer pool on WIN32
On Tue, Apr 7, 2015 at 12:04 PM, Steve Lhomme <robUx4 at videolabs.io> wrote:
> Fixes #11693
> ---
> modules/codec/avcodec/video.c | 40 +++++++++++++++++++++++++---------------
> 1 file changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
> index 381fe62..4e7f32f 100644
> --- a/modules/codec/avcodec/video.c
> +++ b/modules/codec/avcodec/video.c
> @@ -374,7 +374,11 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
> i_thread_count = __MIN( i_thread_count, 16 );
> msg_Dbg( p_dec, "allowing %d thread(s) for decoding", i_thread_count );
> p_context->thread_count = i_thread_count;
> +# if defined(_WIN32)
> + p_context->thread_safe_callbacks = false;
> +# else
> p_context->thread_safe_callbacks = true;
> +# endif
I tried putting a mutex in avcodec where it feeds DXVA with its data.
It was called by multiple threads. Even with that, decoding is still
bogus with Intel Graphics 4000. So I don't see an other way to make it
work with this chipset apart from disabling FF_THREAD_FRAME like we
used to do.
IMO this patch is OK. By default ffmpeg/avplay don't set
thread_safe_callbacks, but that's because they use their own buffer
pools and also check if their functions are used rather than custom
ones.
> switch( p_codec->id )
> {
> @@ -396,21 +400,6 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
> break;
> }
>
> - /* Workaround: frame multithreading is not compatible with
> - * DXVA2. When a frame is being copied to host memory, the frame
> - * is locked and cannot be used as a reference frame
> - * simultaneously and thus decoding fails for some frames. This
> - * causes major image corruption. */
> -# if defined(_WIN32)
> - char *avcodec_hw = var_InheritString( p_dec, "avcodec-hw" );
> - if( avcodec_hw == NULL || strcasecmp( avcodec_hw, "none" ) )
> - {
> - msg_Warn( p_dec, "threaded frame decoding is not compatible with DXVA2, disabled" );
> - p_context->thread_type &= ~FF_THREAD_FRAME;
> - }
> - free( avcodec_hw );
> -# endif
> -
> if( p_context->thread_type & FF_THREAD_FRAME )
> p_dec->i_extra_picture_buffers = 2 * p_context->thread_count;
> #endif
> @@ -1313,7 +1302,28 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
> vlc_va_t *p_va = p_sys->p_va;
>
> if( p_va != NULL )
> + {
> + for( size_t i = 0; pi_fmt[i] != PIX_FMT_NONE; i++ )
> + {
> + if( p_va->pix_fmt != pi_fmt[i] )
> + continue;
> +
> + if( p_context->width <= 0 || p_context->height <= 0
> + || vlc_va_Setup( p_va, p_context, &p_dec->fmt_out.video.i_chroma ) )
> + {
> + msg_Err( p_dec, "reusing acceleration failed" );
> + break;
> + }
> +
> + if( p_va->description )
> + msg_Info( p_dec, "Reusing %s for hardware decoding.",
> + p_va->description );
> +
> + return pi_fmt[i];
> + }
> +
> vlc_va_Delete( p_va, p_context );
> + }
>
> /* Enumerate available formats */
> bool can_hwaccel = false;
> --
> 2.3.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
_______________________________________________
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