[vlc-devel] [PATCH] core: add "decoder-hw" bool option
Thomas Guillem
thomas at gllm.fr
Mon Jan 20 15:25:13 CET 2020
On Mon, Jan 20, 2020, at 14:45, Rémi Denis-Courmont wrote:
> Hi,
>
> Conceptually okay but on the implementation level, why do you need to cache the value?
Because I know that some decoders call decoder_UpdateVideoFormat() a lot, for each frames, that is the case for avcodec.
I had an other look, it seems that the decoder device is only requested when needed, so we could get ride of this cache value.
>
> Le 20 janvier 2020 12:34:59 GMT+02:00, Thomas Guillem <thomas at gllm.fr> a écrit :
>> Enabled by default, this option be used to disable hardware decoders (with
>> "--no-decoder-hw"). This option can be set on input/media items and will be
>> forwarded to the decoder via the input_thread_t.
>>
>> To disable hardware decoders, the core decoder have to disable decoder devices. src/input/decoder.c | 8 +++++++-
>> src/libvlc-module.c | 6 ++++++
>> 2 files changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/input/decoder.c b/src/input/decoder.c
>> index 17a36df3c9b..03d92c429c2 100644
>> --- a/src/input/decoder.c
>> +++ b/src/input/decoder.c
>> @@ -129,6 +129,7 @@ struct decoder_owner
>> vout_thread_t *p_vout;
>> enum vlc_vout_order vout_order;
>> bool vout_thread_started;
>> + bool use_hw;
>>
>> /* -- Theses variables need locking on read *and* write -- */
>> /* Preroll */
>> @@ -615,8 +616,12 @@ static vlc_decoder_device * ModuleThread_GetDecoderDevice( decoder_t *p_dec )
>> struct decoder_owner *p_owner = dec_get_owner( p_dec );
>>
>> enum vlc_vout_order vout_order;
>> +
>> + /* Requesting a decoder device will automatically enable hw decoding */
>> vlc_decoder_device *dec_device = NULL;
>> - int created_vout = CreateVoutIfNeeded(p_owner, NULL, &vout_order, &dec_device);
>> + vlc_decoder_device **dec_device_ptr = p_owner->use_hw ? &dec_device : NULL;
>> +
>> + int created_vout = CreateVoutIfNeeded(p_owner, NULL, &vout_order, dec_device_ptr);
>> if (created_vout == -1)
>> {
>> if ( dec_device )
>> @@ -1848,6 +1853,7 @@ static struct decoder_owner * CreateDecoder( vlc_object_t *p_parent,
>> p_owner->p_aout = NULL;
>> p_owner->p_vout = NULL;
>> p_owner->vout_thread_started = false;
>> + p_owner->use_hw = var_InheritBool( p_parent, "decoder-hw" );
>> p_owner->i_spu_channel = VOUT_SPU_CHANNEL_INVALID;
>> p_owner->i_spu_order = 0;
>> p_owner->p_sout = p_sout;
>> diff --git a/src/libvlc-module.c b/src/libvlc-module.c
>> index 1e733662cf6..9839a8274a9 100644
>> --- a/src/libvlc-module.c
>> +++ b/src/libvlc-module.c
>> @@ -968,6 +968,11 @@ static const char *const ppsz_prefres[] = {
>> "before trying the other ones. Only advanced users should " \
>> "alter this option as it can break playback of all your streams." )
>>
>> +#define DECODER_HW_TEXT N_("Enable hardware decoders")
>> +#define DECODER_HW_LONGTEXT N_( \
>> + "This will enable hardware decoders. VLC will fallback automatically to " \
>> + "software decoders in case of hardware decoder failure." )
>> +
>> #define ENCODER_TEXT N_("Preferred encoders list")
>> #define ENCODER_LONGTEXT N_( \
>> "This allows you to select a list of encoders that VLC will use in " \
>> @@ -2044,6 +2049,7 @@ vlc_module_begin ()
>> add_category_hint(N_("Decoders"), CODEC_CAT_LONGTEXT)
>> add_string( "codec", NULL, CODEC_TEXT,
>> CODEC_LONGTEXT, true )
>> + add_bool( "decoder-hw", true, DECODER_HW_TEXT, DECODER_HW_LONGTEXT, true )
>> add_string( "encoder", NULL, ENCODER_TEXT,
>> ENCODER_LONGTEXT, true )
>> add_module("dec-dev", "decoder device", "any", DEC_DEV_TEXT, DEC_DEV_LONGTEXT)
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200120/7805445f/attachment.html>
More information about the vlc-devel
mailing list