Commit c922115f authored by Jean-Paul Saman's avatar Jean-Paul Saman

avcodec: add 'ffmpeg-hw-codec' to select a specific 'hw decoder'

Make it possible to select a specific 'hw decoder' module. Currently
only: vaapi, dxva2 and vdpau are supported choices.
parent 1b4b7667
...@@ -130,6 +130,7 @@ vlc_module_begin () ...@@ -130,6 +130,7 @@ vlc_module_begin ()
true ) true )
add_string( "ffmpeg-codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true ) add_string( "ffmpeg-codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
add_bool( "ffmpeg-hw", false, HW_TEXT, HW_LONGTEXT, false ) add_bool( "ffmpeg-hw", false, HW_TEXT, HW_LONGTEXT, false )
add_module( "ffmpeg-hw-codec", "hw decoder", "vaapi", HW_TEXT, HW_LONGTEXT, false )
#if defined(FF_THREAD_FRAME) #if defined(FF_THREAD_FRAME)
add_integer( "ffmpeg-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true ); add_integer( "ffmpeg-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true );
......
...@@ -147,7 +147,8 @@ int ffmpeg_OpenCodec( decoder_t *p_dec ); ...@@ -147,7 +147,8 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
"speedup for high definition streams." ) "speedup for high definition streams." )
#define HW_TEXT N_("Hardware decoding") #define HW_TEXT N_("Hardware decoding")
#define HW_LONGTEXT N_("This allows hardware decoding when available.") #define HW_LONGTEXT N_("This allows hardware decoding when available. " \
"Curent choices are: 'none', 'dxva2', 'vaapi' and 'vdpau'. The default is: 'vaapi'" )
#define THREADS_TEXT N_( "Threads" ) #define THREADS_TEXT N_( "Threads" )
#define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" ) #define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" )
......
...@@ -359,7 +359,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -359,7 +359,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
#endif #endif
const bool b_use_hw = var_CreateGetBool( p_dec, "ffmpeg-hw" ); const bool b_use_hw = var_CreateGetBool( p_dec, "ffmpeg-hw" );
if( b_use_hw && char *hw = var_CreateGetString( p_dec, "ffmpeg-hw-codec" ); /* FIXME */
if( (b_use_hw && (hw == NULL || strcasecmp( hw, "none" ))) &&
(i_codec_id == CODEC_ID_MPEG1VIDEO || i_codec_id == CODEC_ID_MPEG2VIDEO || (i_codec_id == CODEC_ID_MPEG1VIDEO || i_codec_id == CODEC_ID_MPEG2VIDEO ||
i_codec_id == CODEC_ID_MPEG4 || i_codec_id == CODEC_ID_MPEG4 ||
i_codec_id == CODEC_ID_H264 || i_codec_id == CODEC_ID_H264 ||
...@@ -382,6 +383,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context, ...@@ -382,6 +383,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
#endif #endif
p_sys->p_context->get_format = ffmpeg_GetFormat; p_sys->p_context->get_format = ffmpeg_GetFormat;
} }
free(hw);
#ifdef HAVE_AVCODEC_MT #ifdef HAVE_AVCODEC_MT
if( p_sys->p_context->thread_type & FF_THREAD_FRAME ) if( p_sys->p_context->thread_type & FF_THREAD_FRAME )
...@@ -1151,7 +1153,7 @@ static vlc_va_t *vlc_va_New( vlc_object_t *parent, int codec_id, ...@@ -1151,7 +1153,7 @@ static vlc_va_t *vlc_va_New( vlc_object_t *parent, int codec_id,
if( unlikely(p_va == NULL) ) if( unlikely(p_va == NULL) )
return NULL; return NULL;
p_va->module = vlc_module_load( p_va, "hw decoder", "$avcodec-hw", p_va->module = vlc_module_load( p_va, "hw decoder", "$ffmpeg-hw-codec",
true, ffmpeg_va_Start, p_va, true, ffmpeg_va_Start, p_va,
codec_id, fmt ); codec_id, fmt );
if( p_va->module == NULL ) if( p_va->module == NULL )
......
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