Commit 8f8b6c79 authored by Jean-Paul Saman's avatar Jean-Paul Saman

codec/avcodec/vaapi: new option ffmpeg-vaapi-x11

Use --ffmpeg-vaapi-x11 in combination with --ffmpeg-hw. It uses
the vaapi to decode pictures and display it without copying it back
to main memory.
When --no-ffmpeg-vaapi-x11 is used then the picture is copied from
the GPU to main memory and displayed later by another vout. This uses
more CPU then when the picture is displayed from the GPU contenxt directly.
parent 7f9d09bb
......@@ -136,6 +136,7 @@ vlc_module_begin ()
true )
#if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
add_bool( "ffmpeg-hw", false, HW_TEXT, HW_LONGTEXT, false )
add_bool( "ffmpeg-vaapi-x11", false, VAX11_TEXT, VAX11_LONGTEXT, false )
#endif
#if defined(FF_THREAD_FRAME)
add_integer( "ffmpeg-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true );
......
......@@ -143,6 +143,11 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
#define HW_TEXT N_("Hardware decoding")
#define HW_LONGTEXT N_("This allows hardware decoding when available.")
#define VAX11_TEXT N_("Display using vaapi-x11")
#define VAX11_LONGTEXT N_("Pass picture handle directly to vaapi-x11 " \
"video output without first copying it back to main memory. Use of " \
"-V vaapi-x11 is mandatory when using this option." )
#define THREADS_TEXT N_( "Threads" )
#define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" )
......
......@@ -100,6 +100,7 @@ struct decoder_sys_t
/* VA API */
vlc_va_t *p_va;
bool b_va_display; /* use vaapi-x11 vout */
vlc_sem_t sem_mt;
};
......@@ -223,6 +224,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
p_sys->p_ff_pic = avcodec_alloc_frame();
p_sys->b_delayed_open = true;
p_sys->p_va = NULL;
p_sys->b_va_display = var_InheritBool(p_dec, "ffmpeg-vaapi-x11");
vlc_sem_init( &p_sys->sem_mt, 0 );
/* ***** Fill p_context with init values ***** */
......@@ -889,7 +891,10 @@ static void ffmpeg_CopyPicture( decoder_t *p_dec,
if( p_sys->p_va )
{
vlc_va_Extract( p_sys->p_va, p_pic, p_ff_pic );
if (p_sys->b_va_display)
vlc_va_Display( p_sys->p_va, p_pic, p_ff_pic );
else
vlc_va_Extract( p_sys->p_va, p_pic, p_ff_pic );
}
else if( TestFfmpegChroma( p_sys->p_context->pix_fmt, -1 ) == VLC_SUCCESS )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment