[vlc-devel] [PATCH 2/3] Sanitize FFmpeg modules options

Rafaël Carré funman at videolan.org
Sun Apr 15 23:46:52 CEST 2012


Obsolete "ffmpeg" prefix
Use "avformat" or "avcodec" prefix
avio has no options (yet)
switcher uses "sout-switcher" prefix
Use "sout-avformat" for muxer
---
 modules/codec/avcodec/avcodec.c   |   75 +++++++++++++++++++++++++++++--------
 modules/codec/avcodec/avcodec.h   |    2 +-
 modules/codec/avcodec/encoder.c   |    2 +-
 modules/codec/avcodec/video.c     |   24 ++++++------
 modules/demux/avformat/avformat.c |    7 ++--
 modules/demux/avformat/demux.c    |    2 +-
 modules/demux/avformat/mux.c      |    4 +-
 7 files changed, 80 insertions(+), 36 deletions(-)

diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 9190acb..9a9770a 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -101,38 +101,52 @@ vlc_module_begin ()
     set_callbacks( OpenDecoder, CloseDecoder )
 
 
-    add_bool( "ffmpeg-dr", true, DR_TEXT, DR_TEXT, true )
-    add_integer ( "ffmpeg-error-resilience", 1, ERROR_TEXT,
+    add_obsolete_bool( "ffmpeg-dr" ) /* removed since 2.1.0 */
+    add_bool( "avcodec-dr", true, DR_TEXT, DR_TEXT, true )
+    add_obsolete_integer ( "ffmpeg-error-resilience" ) /* removed since 2.1.0 */
+    add_integer ( "avcodec-error-resilience", 1, ERROR_TEXT,
         ERROR_LONGTEXT, true )
-    add_integer ( "ffmpeg-workaround-bugs", 1, BUGS_TEXT, BUGS_LONGTEXT,
+    add_obsolete_integer ( "ffmpeg-workaround-bugs" ) /* removed since 2.1.0 */
+    add_integer ( "avcodec-workaround-bugs", 1, BUGS_TEXT, BUGS_LONGTEXT,
         false )
-    add_bool( "ffmpeg-hurry-up", true, HURRYUP_TEXT, HURRYUP_LONGTEXT,
+    add_obsolete_bool( "ffmpeg-hurry-up" ) /* removed since 2.1.0 */
+    add_bool( "avcodec-hurry-up", true, HURRYUP_TEXT, HURRYUP_LONGTEXT,
         false )
-    add_integer( "ffmpeg-skip-frame", 0, SKIP_FRAME_TEXT,
+    add_obsolete_integer( "ffmpeg-skip-frame") /* removed since 2.1.0 */
+    add_integer( "avcodec-skip-frame", 0, SKIP_FRAME_TEXT,
         SKIP_FRAME_LONGTEXT, true )
         change_integer_range( -1, 4 )
-    add_integer( "ffmpeg-skip-idct", 0, SKIP_IDCT_TEXT,
+    add_obsolete_integer( "ffmpeg-skip-idct" ) /* removed since 2.1.0 */
+    add_integer( "avcodec-skip-idct", 0, SKIP_IDCT_TEXT,
         SKIP_IDCT_LONGTEXT, true )
         change_integer_range( -1, 4 )
-    add_integer ( "ffmpeg-vismv", 0, VISMV_TEXT, VISMV_LONGTEXT,
+    add_obsolete_integer ( "ffmpeg-vismv" ) /* removed since 2.1.0 */
+    add_integer ( "avcodec-vismv", 0, VISMV_TEXT, VISMV_LONGTEXT,
         true )
-    add_integer ( "ffmpeg-lowres", 0, LOWRES_TEXT, LOWRES_LONGTEXT,
+    add_obsolete_integer ( "ffmpeg-lowres" ) /* removed since 2.1.0 */
+    add_integer ( "avcodec-lowres", 0, LOWRES_TEXT, LOWRES_LONGTEXT,
         true )
         change_integer_range( 0, 2 )
-    add_bool( "ffmpeg-fast", false, FAST_TEXT, FAST_LONGTEXT, false )
-    add_integer ( "ffmpeg-skiploopfilter", 0, SKIPLOOPF_TEXT,
+    add_obsolete_bool( "ffmpeg-fast" ) /* removed since 2.1.0 */
+    add_bool( "avcodec-fast", false, FAST_TEXT, FAST_LONGTEXT, false )
+    add_obsolete_integer ( "ffmpeg-skiploopfilter" ) /* removed since 2.1.0 */
+    add_integer ( "avcodec-skiploopfilter", 0, SKIPLOOPF_TEXT,
                   SKIPLOOPF_LONGTEXT, false)
         change_safe ()
         change_integer_list( nloopf_list, nloopf_list_text )
 
-    add_integer( "ffmpeg-debug", 0, DEBUG_TEXT, DEBUG_LONGTEXT,
+    add_obsolete_integer( "ffmpeg-debug" ) /* removed since 2.1.0 */
+    add_integer( "avcodec-debug", 0, DEBUG_TEXT, DEBUG_LONGTEXT,
                  true )
-    add_string( "ffmpeg-codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
+    add_obsolete_string( "ffmpeg-codec" ) /* removed since 2.1.0 */
+    add_string( "avcodec-codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
 #if defined(HAVE_AVCODEC_VAAPI) || defined(HAVE_AVCODEC_DXVA2)
-    add_bool( "ffmpeg-hw", false, HW_TEXT, HW_LONGTEXT, false )
+    add_obsolete_bool( "ffmpeg-hw" ) /* removed since 2.1.0 */
+    add_bool( "avcodec-hw", false, HW_TEXT, HW_LONGTEXT, false )
 #endif
 #if defined(FF_THREAD_FRAME)
-    add_integer( "ffmpeg-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true );
+    add_obsolete_integer( "ffmpeg-threads" ) /* removed since 2.1.0 */
+    add_integer( "avcodec-threads", 0, THREADS_TEXT, THREADS_LONGTEXT, true );
 #endif
 
 
@@ -145,6 +159,35 @@ vlc_module_begin ()
     set_capability( "encoder", 100 )
     set_callbacks( OpenEncoder, CloseEncoder )
 
+    /* removed in 2.1.0 */
+    add_obsolete_string( "sout-ffmpeg-codec" )
+    add_obsolete_string( "sout-ffmpeg-hq" )
+    add_obsolete_integer( "sout-ffmpeg-keyint" )
+    add_obsolete_integer( "sout-ffmpeg-bframes" )
+    add_obsolete_bool( "sout-ffmpeg-hurry-up" )
+    add_obsolete_bool( "sout-ffmpeg-interlace" )
+    add_obsolete_bool( "sout-ffmpeg-interlace-me" )
+    add_obsolete_integer( "sout-ffmpeg-vt" )
+    add_obsolete_bool( "sout-ffmpeg-pre-me" )
+    add_obsolete_integer( "sout-ffmpeg-rc-buffer-size" )
+    add_obsolete_float( "sout-ffmpeg-rc-buffer-aggressivity" )
+    add_obsolete_float( "sout-ffmpeg-i-quant-factor" )
+    add_obsolete_integer( "sout-ffmpeg-noise-reduction" )
+    add_obsolete_bool( "sout-ffmpeg-mpeg4-matrix" )
+    add_obsolete_integer( "sout-ffmpeg-qmin" )
+    add_obsolete_integer( "sout-ffmpeg-qmax" )
+    add_obsolete_bool( "sout-ffmpeg-trellis" )
+    add_obsolete_float( "sout-ffmpeg-qscale" )
+    add_obsolete_integer( "sout-ffmpeg-strict" )
+    add_obsolete_float( "sout-ffmpeg-lumi-masking" )
+    add_obsolete_float( "sout-ffmpeg-dark-masking" )
+    add_obsolete_float( "sout-ffmpeg-p-masking" )
+    add_obsolete_float( "sout-ffmpeg-border-masking" )
+    add_obsolete_integer( "sout-ffmpeg-luma-elim-threshold" )
+    add_obsolete_integer( "sout-ffmpeg-chroma-elim-threshold" )
+    add_obsolete_string( "sout-ffmpeg-aac-profile" )
+
+
     add_string( ENC_CFG_PREFIX "codec", NULL, CODEC_TEXT, CODEC_LONGTEXT, true )
     add_string( ENC_CFG_PREFIX "hq", "simple", ENC_HQ_TEXT,
                 ENC_HQ_LONGTEXT, false )
@@ -240,7 +283,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     vlc_init_avcodec();
 
     /* *** ask ffmpeg for a decoder *** */
-    char *psz_decoder = var_CreateGetString( p_this, "ffmpeg-codec" );
+    char *psz_decoder = var_CreateGetString( p_this, "avcodec-codec" );
     if( psz_decoder && *psz_decoder )
     {
         p_codec = avcodec_find_decoder_by_name( psz_decoder );
@@ -270,7 +313,7 @@ static int OpenDecoder( vlc_object_t *p_this )
 #endif
     if( !p_context )
         return VLC_ENOMEM;
-    p_context->debug = var_InheritInteger( p_dec, "ffmpeg-debug" );
+    p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" );
     p_context->opaque = (void *)p_this;
 
     /* Set CPU capabilities */
diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
index f1ce948..8219616 100644
--- a/modules/codec/avcodec/avcodec.h
+++ b/modules/codec/avcodec/avcodec.h
@@ -144,7 +144,7 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
 /*
  * Encoder options
  */
-#define ENC_CFG_PREFIX "sout-ffmpeg-"
+#define ENC_CFG_PREFIX "sout-avcodec-"
 
 #define ENC_KEYINT_TEXT N_( "Ratio of key frames" )
 #define ENC_KEYINT_LONGTEXT N_( "Number of frames " \
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index c9e16e4..aaf1481 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -313,7 +313,7 @@ int OpenEncoder( vlc_object_t *p_this )
 #endif
     p_sys->p_context = p_context;
     p_sys->p_context->codec_id = p_sys->p_codec->id;
-    p_context->debug = var_InheritInteger( p_enc, "ffmpeg-debug" );
+    p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" );
     p_context->opaque = (void *)p_this;
 
     /* Set CPU capabilities */
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 60ce6b6..2ea9b2d 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -234,36 +234,36 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
 
     /*  ***** Get configuration of ffmpeg plugin ***** */
     p_sys->p_context->workaround_bugs =
-        var_InheritInteger( p_dec, "ffmpeg-workaround-bugs" );
+        var_InheritInteger( p_dec, "avcodec-workaround-bugs" );
 #if LIBAVCODEC_VERSION_MAJOR < 54
     p_sys->p_context->error_recognition =
 #else
     p_sys->p_context->err_recognition =
 #endif
-        var_InheritInteger( p_dec, "ffmpeg-error-resilience" );
+        var_InheritInteger( p_dec, "avcodec-error-resilience" );
 
     if( var_CreateGetBool( p_dec, "grayscale" ) )
         p_sys->p_context->flags |= CODEC_FLAG_GRAY;
 
-    i_val = var_CreateGetInteger( p_dec, "ffmpeg-vismv" );
+    i_val = var_CreateGetInteger( p_dec, "avcodec-vismv" );
     if( i_val ) p_sys->p_context->debug_mv = i_val;
 
-    i_val = var_CreateGetInteger( p_dec, "ffmpeg-lowres" );
+    i_val = var_CreateGetInteger( p_dec, "avcodec-lowres" );
     if( i_val > 0 && i_val <= 2 ) p_sys->p_context->lowres = i_val;
 
-    i_val = var_CreateGetInteger( p_dec, "ffmpeg-skiploopfilter" );
+    i_val = var_CreateGetInteger( p_dec, "avcodec-skiploopfilter" );
     if( i_val >= 4 ) p_sys->p_context->skip_loop_filter = AVDISCARD_ALL;
     else if( i_val == 3 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONKEY;
     else if( i_val == 2 ) p_sys->p_context->skip_loop_filter = AVDISCARD_BIDIR;
     else if( i_val == 1 ) p_sys->p_context->skip_loop_filter = AVDISCARD_NONREF;
 
-    if( var_CreateGetBool( p_dec, "ffmpeg-fast" ) )
+    if( var_CreateGetBool( p_dec, "avcodec-fast" ) )
         p_sys->p_context->flags2 |= CODEC_FLAG2_FAST;
 
     /* ***** ffmpeg frame skipping ***** */
-    p_sys->b_hurry_up = var_CreateGetBool( p_dec, "ffmpeg-hurry-up" );
+    p_sys->b_hurry_up = var_CreateGetBool( p_dec, "avcodec-hurry-up" );
 
-    switch( var_CreateGetInteger( p_dec, "ffmpeg-skip-frame" ) )
+    switch( var_CreateGetInteger( p_dec, "avcodec-skip-frame" ) )
     {
         case -1:
             p_sys->p_context->skip_frame = AVDISCARD_NONE;
@@ -286,7 +286,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     }
     p_sys->i_skip_frame = p_sys->p_context->skip_frame;
 
-    switch( var_CreateGetInteger( p_dec, "ffmpeg-skip-idct" ) )
+    switch( var_CreateGetInteger( p_dec, "avcodec-skip-idct" ) )
     {
         case -1:
             p_sys->p_context->skip_idct = AVDISCARD_NONE;
@@ -312,7 +312,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     /* ***** ffmpeg direct rendering ***** */
     p_sys->b_direct_rendering = false;
     p_sys->i_direct_rendering_used = -1;
-    if( var_CreateGetBool( p_dec, "ffmpeg-dr" ) &&
+    if( var_CreateGetBool( p_dec, "avcodec-dr" ) &&
        (p_sys->p_codec->capabilities & CODEC_CAP_DR1) &&
         /* No idea why ... but this fixes flickering on some TSCC streams */
         p_sys->i_codec_id != CODEC_ID_TSCC && p_sys->i_codec_id != CODEC_ID_CSCD &&
@@ -349,7 +349,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_sys->p_context->opaque = p_dec;
 
 #ifdef HAVE_AVCODEC_MT
-    int i_thread_count = var_InheritInteger( p_dec, "ffmpeg-threads" );
+    int i_thread_count = var_InheritInteger( p_dec, "avcodec-threads" );
     if( i_thread_count <= 0 )
     {
         i_thread_count = vlc_GetCPUCount();
@@ -365,7 +365,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
 #endif
 
 #ifdef HAVE_AVCODEC_VA
-    const bool b_use_hw = var_CreateGetBool( p_dec, "ffmpeg-hw" );
+    const bool b_use_hw = var_CreateGetBool( p_dec, "avcodec-hw" );
     if( b_use_hw &&
         (i_codec_id == CODEC_ID_MPEG1VIDEO || i_codec_id == CODEC_ID_MPEG2VIDEO ||
          i_codec_id == CODEC_ID_MPEG4 ||
diff --git a/modules/demux/avformat/avformat.c b/modules/demux/avformat/avformat.c
index 24905f3..6d3e172 100644
--- a/modules/demux/avformat/avformat.c
+++ b/modules/demux/avformat/avformat.c
@@ -41,7 +41,8 @@ vlc_module_begin ()
     set_shortname( N_("Avformat") )
     set_capability( "demux", 2 )
     set_callbacks( OpenDemux, CloseDemux )
-    add_string( "ffmpeg-format", NULL, FORMAT_TEXT, FORMAT_LONGTEXT, true )
+    add_string( "avformat-format", NULL, FORMAT_TEXT, FORMAT_LONGTEXT, true )
+    add_obsolete_string("ffmpeg-format") /* removed since 2.1.0 */
 
 #ifdef ENABLE_SOUT
     /* mux submodule */
@@ -49,8 +50,8 @@ vlc_module_begin ()
     add_shortcut( "ffmpeg", "avformat" )
     set_description( N_("Avformat muxer" ) )
     set_capability( "sout mux", 2 )
-    add_string( "ffmpeg-mux", NULL, MUX_TEXT,
-                MUX_LONGTEXT, true )
+    add_string( "sout-avformat-mux", NULL, MUX_TEXT, MUX_LONGTEXT, true )
+    add_obsolete_string("ffmpeg-mux") /* removed since 2.1.0 */
     set_callbacks( OpenMux, CloseMux )
 #endif
 #ifndef MERGE_FFMPEG
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 22a2522..4596583 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -140,7 +140,7 @@ int OpenDemux( vlc_object_t *p_this )
 
     vlc_init_avformat();
 
-    char *psz_format = var_InheritString( p_this, "ffmpeg-format" );
+    char *psz_format = var_InheritString( p_this, "avformat-format" );
     if( psz_format )
     {
         if( fmt = av_find_input_format(psz_format) )
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index e2270f7..625b652 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -94,10 +94,10 @@ int OpenMux( vlc_object_t *p_this )
 
     vlc_init_avformat();
 
-    config_ChainParse( p_mux, "ffmpeg-", ppsz_mux_options, p_mux->p_cfg );
+    config_ChainParse( p_mux, "sout-avformat-", ppsz_mux_options, p_mux->p_cfg );
 
     /* Find the requested muxer */
-    psz_mux = var_GetNonEmptyString( p_mux, "ffmpeg-mux" );
+    psz_mux = var_GetNonEmptyString( p_mux, "sout-avformat-mux" );
     if( psz_mux )
     {
 #if( LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( 52, 45, 0 ) )
-- 
1.7.9.5



More information about the vlc-devel mailing list