[FFmpeg-devel] [PATCH] lavc/options: set all codec options to defaults

Lukasz Marek lukasz.m.luki2 at gmail.com
Tue Nov 11 18:38:44 CET 2014


On 11.11.2014 18:30, Lukasz Marek wrote:
> avcodec_get_context_defaults3() sets only specific options to default the values.
> This commit force all options to be set to the defaults.
> This improves effectiveness of new ffm format.
> In particular it fixes "bt" option being out of range when context is created for
> non-video media type. (it is 0, when min=1)
>
> Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
> ---
>   libavcodec/options.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/options.c b/libavcodec/options.c
> index 461e4a1..bb472a9 100644
> --- a/libavcodec/options.c
> +++ b/libavcodec/options.c
> @@ -104,6 +104,9 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
>           flags= AV_OPT_FLAG_VIDEO_PARAM;
>       else if(s->codec_type == AVMEDIA_TYPE_SUBTITLE)
>           flags= AV_OPT_FLAG_SUBTITLE_PARAM;
> +    /* set all options to defaults */
> +    av_opt_set_defaults(s);
> +    /* some variables might be shared between different codec types so make sure correct ones are set. */

I just realized I haven't tested "[PATCH 9/9] lavf/ffm: use AVOption API 
to store/restore stream properties" with config that have audio stream. 
In fact I tested, but I had NoAudio added and probably was to tired to 
notice there is no audio.

I put fix for it in avcodec_get_context_defaults3, but I think it can be 
fixed in ffserver_config.c too, just for ffserver, in case someone don't 
like it here.



More information about the ffmpeg-devel mailing list