[vlc-devel] [RFC PATCH] avcodec: add "codec-strict" to force an encoder name
Thomas Guillem
thomas at gllm.fr
Tue Mar 27 16:48:49 CEST 2018
I would prefer to not add this new "codec-strict" option and always return an
error if the "codec" is not found by avcodec_find_encoder_by_name() (instead of
using the default encoder).
---
modules/codec/avcodec/avcodec.c | 1 +
modules/codec/avcodec/avcodec.h | 4 ++++
modules/codec/avcodec/encoder.c | 6 +++++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 9325b1fb0e..8976b9c297 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -179,6 +179,7 @@ vlc_module_begin ()
add_string( ENC_CFG_PREFIX "codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
+ add_bool( ENC_CFG_PREFIX "codec-strict", false, CODEC_STRICT_TEXT, CODEC_STRICT_LONGTEXT, true )
add_string( ENC_CFG_PREFIX "hq", "rd", ENC_HQ_TEXT,
ENC_HQ_LONGTEXT, false )
change_string_list( enc_hq_list, enc_hq_list_text )
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index 52e522dc32..4c14155e53 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -105,6 +105,10 @@ int ffmpeg_OpenCodec( decoder_t *p_dec, AVCodecContext *, const AVCodec * );
#define CODEC_TEXT N_( "Codec name" )
#define CODEC_LONGTEXT N_( "Internal libavcodec codec name" )
+#define CODEC_STRICT_TEXT N_( "Use the strict codec name" )
+#define CODEC_STRICT_LONGTEXT N_( "If true, don't fallback to the default codec " \
+ "if the specified codec is not found." )
+
#define SKIPLOOPF_TEXT N_( "Skip the loop filter for H.264 decoding" )
#define SKIPLOOPF_LONGTEXT N_( "Skipping the loop filter (aka deblocking) " \
"usually has a detrimental effect on quality. However it provides a big " \
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 7bf2f0e1ba..d7f431a0c2 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -188,7 +188,7 @@ static const uint32_t channel_mask[][2] = {
};
static const char *const ppsz_enc_options[] = {
- "keyint", "bframes", "vt", "qmin", "qmax", "codec", "hq",
+ "keyint", "bframes", "vt", "qmin", "qmax", "codec", "codec-strict", "hq",
"rc-buffer-size", "rc-buffer-aggressivity", "pre-me", "hurry-up",
"interlace", "interlace-me", "i-quant-factor", "noise-reduction", "mpeg4-matrix",
"trellis", "qscale", "strict", "lumi-masking", "dark-masking",
@@ -344,7 +344,11 @@ int InitVideoEnc( vlc_object_t *p_this )
{
p_codec = avcodec_find_encoder_by_name( psz_encoder );
if( !p_codec )
+ {
+ if( var_GetBool( p_this, ENC_CFG_PREFIX "codec-strict" ) )
+ return VLC_EGENERIC;
msg_Err( p_this, "Encoder `%s' not found", psz_encoder );
+ }
else if( p_codec->id != i_codec_id )
{
msg_Err( p_this, "Encoder `%s' can't handle %4.4s",
--
2.11.0
More information about the vlc-devel
mailing list