[vlc-devel] [RFC] avcodec: Set lowres option according AV decoder

Rafaël Carré funman at videolan.org
Tue Apr 30 14:44:12 CEST 2013


Hello,

Le 30/04/2013 14:41, Nicolas Bertrand a écrit :
> ---
>  What do you think on managing discrepancy in libav/ffmpeg
>  for lowres parameter that way?
> 
>  modules/codec/avcodec/avcodec.c |   16 +++++++++++++++-
>  modules/codec/avcodec/avcodec.h |    3 +++
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
> index b126d7a..e62b2c6 100644
> --- a/modules/codec/avcodec/avcodec.c
> +++ b/modules/codec/avcodec/avcodec.c
> @@ -133,6 +133,8 @@ vlc_module_begin ()
>          true )
>  #endif
>  
> +    add_integer("avcodec-lowres", 0, LOWRES_TEXT, LOWRES_LONG_TEXT, true);
> +
>      add_obsolete_integer( "ffmpeg-debug" ) /* removed since 2.1.0 */
>      add_integer( "avcodec-debug", 0, DEBUG_TEXT, DEBUG_LONGTEXT,
>                   true )
> @@ -301,6 +303,10 @@ static int OpenDecoder( vlc_object_t *p_this )
>      p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" );
>      p_context->opaque = (void *)p_this;
>  
> +    /* set lowres option for ffmpeg */
> +    if(LIBAVUTIL_VERSION_MICRO >= 100)
> +        p_context->lowres  = var_InheritInteger( p_dec, "avcodec-lowres" );
> +
>      /* set CPU capabilities */
>  #if LIBAVUTIL_VERSION_CHECK(51, 25, 0, 42, 100)
>      av_set_cpu_flags_mask( INT_MAX & ~GetVlcDspMask() );
> @@ -419,8 +425,16 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
>                                                        p_sys->p_context->sample_rate;
>      }
>      int ret;
> +    AVDictionary *options = NULL;
> +    if ( LIBAVUTIL_VERSION_MICRO < 100 ) {
> +        /* set lowres option for libav */
> +        int lowres = var_InheritInteger( p_dec, "avcodec-lowres" );
> +        char psz_lowres[3] = "0";
> +        sprintf(psz_lowres,"%i",lowres);
> +        av_dict_set(&options,"lowres",psz_lowres,0);
> +    }
>      vlc_avcodec_lock();
> -    ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, NULL /* options */ );
> +    ret = avcodec_open2( p_sys->p_context, p_sys->p_codec, &options);
>      vlc_avcodec_unlock();
>      if( ret < 0 )
>          return VLC_EGENERIC;

I might as well test my patch for generic options, so one could use:

vlc --avcodec-options='{lowres=3}'

> diff --git a/modules/codec/avcodec/avcodec.h b/modules/codec/avcodec/avcodec.h
> index 1716733..bf0b4a1 100644
> --- a/modules/codec/avcodec/avcodec.h
> +++ b/modules/codec/avcodec/avcodec.h
> @@ -144,6 +144,9 @@ int ffmpeg_OpenCodec( decoder_t *p_dec );
>  #define THREADS_TEXT N_( "Threads" )
>  #define THREADS_LONGTEXT N_( "Number of threads used for decoding, 0 meaning auto" )
>  
> +#define LOWRES_TEXT N_("Video in low resolutions")
> +#define LOWRES_LONG_TEXT N_( \
> +     "Decode at 1 = 1/2, 2 = 1/4, 3 = 1/8, ...,of original resolution size" )

One would need to refer to libav doc to discover available options though

>  /*
>   * Encoder options
>   */
> 




More information about the vlc-devel mailing list