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

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


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. */
     av_opt_set_defaults2(s, flags, flags);
 
     s->time_base           = (AVRational){0,1};
-- 
1.9.1



More information about the ffmpeg-devel mailing list