[vlc-devel] [PATCH] core: add "decoder-hw" bool option
Thomas Guillem
thomas at gllm.fr
Mon Jan 20 16:46:04 CET 2020
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 | 7 ++++++-
src/libvlc-module.c | 6 ++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 17a36df3c9b..ebfb8d7db91 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -615,8 +615,13 @@ 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 =
+ var_InheritBool( p_dec, "decoder-hw" ) ? &dec_device : NULL;
+
+ int created_vout = CreateVoutIfNeeded(p_owner, NULL, &vout_order, dec_device_ptr);
if (created_vout == -1)
{
if ( dec_device )
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)
--
2.20.1
More information about the vlc-devel
mailing list