[FFmpeg-cvslog] lavc: add opt_find to AVCodecContext class.

Anton Khirnov git at videolan.org
Sat Jun 18 05:18:46 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Jun 17 06:39:42 2011 +0200| [78440c007cd310bb27ac2af5fb7ea5b7555efc84] | committer: Anton Khirnov

lavc: add opt_find to AVCodecContext class.

Fixes encoder private options, which are broken now in ffmpeg, because
opt_default2() can't find them, thus making opt_default() to fail.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78440c007cd310bb27ac2af5fb7ea5b7555efc84
---

 libavcodec/options.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 8f9aec4..ae9e0c9 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -37,6 +37,25 @@ static const char* context_to_name(void* ptr) {
         return "NULL";
 }
 
+static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
+{
+    AVCodecContext *s = obj;
+    AVCodec        *c = NULL;
+
+    if (s->priv_data) {
+        if (s->codec->priv_class)
+            return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags);
+        return NULL;
+    }
+
+    while ((c = av_codec_next(c))) {
+        const AVOption *o;
+        if (c->priv_class && (o = av_opt_find(&c->priv_class, name, unit, opt_flags, search_flags)))
+            return o;
+    }
+    return NULL;
+}
+
 #define OFFSET(x) offsetof(AVCodecContext,x)
 #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
 //these names are too long to be readable
@@ -457,7 +476,7 @@ static const AVOption options[]={
 #undef D
 #undef DEFAULT
 
-static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset) };
+static const AVClass av_codec_context_class = { "AVCodecContext", context_to_name, options, LIBAVUTIL_VERSION_INT, OFFSET(log_level_offset), .opt_find = opt_find};
 
 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
     int flags=0;



More information about the ffmpeg-cvslog mailing list