[Ffmpeg-cvslog] r6224 - in trunk: libavcodec/opt.c libavcodec/opt.h libavcodec/utils.c libavformat/utils.c

gpoirier subversion
Sun Sep 10 22:21:41 CEST 2006


Author: gpoirier
Date: Sun Sep 10 22:21:40 2006
New Revision: 6224

Modified:
   trunk/libavcodec/opt.c
   trunk/libavcodec/opt.h
   trunk/libavcodec/utils.c
   trunk/libavformat/utils.c

Log:
make AVOptions default value field work.
Patch by Panagiotis Issaris % takis P issaris A uhasselt P be %
Original thread:
Date: Sep 8, 2006 3:22 PM
Subject: [Ffmpeg-devel] [PATCH 1/2] Enable usage of AVOption default value


Modified: trunk/libavcodec/opt.c
==============================================================================
--- trunk/libavcodec/opt.c	(original)
+++ trunk/libavcodec/opt.c	Sun Sep 10 22:21:40 2006
@@ -299,3 +299,40 @@
     }
     return 0;
 }
+
+void av_opt_set_defaults(void *s)
+{
+    AVOption *opt = NULL;
+    while ((opt = av_next_option(s, opt)) != NULL) {
+        switch(opt->type) {
+            case FF_OPT_TYPE_CONST:
+                /* Nothing to be done here */
+            break;
+            case FF_OPT_TYPE_FLAGS:
+            case FF_OPT_TYPE_INT: {
+                int val;
+                val = opt->default_val;
+                av_set_int(s, opt->name, val);
+            }
+            break;
+            case FF_OPT_TYPE_FLOAT: {
+                double val;
+                val = opt->default_val;
+                av_set_double(s, opt->name, val);
+            }
+            break;
+            case FF_OPT_TYPE_RATIONAL: {
+                AVRational val;
+                val = av_d2q(opt->default_val, INT_MAX);
+                av_set_q(s, opt->name, val);
+            }
+            break;
+            case FF_OPT_TYPE_STRING:
+                /* Cannot set default for string as default_val is of type * double */
+            break;
+            default:
+                av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
+        }
+    }
+}
+

Modified: trunk/libavcodec/opt.h
==============================================================================
--- trunk/libavcodec/opt.h	(original)
+++ trunk/libavcodec/opt.h	Sun Sep 10 22:21:40 2006
@@ -76,5 +76,6 @@
 const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len);
 AVOption *av_next_option(void *obj, AVOption *last);
 int av_opt_show(void *obj, void *av_log_obj);
+void av_opt_set_defaults(void *s);
 
 #endif

Modified: trunk/libavcodec/utils.c
==============================================================================
--- trunk/libavcodec/utils.c	(original)
+++ trunk/libavcodec/utils.c	Sun Sep 10 22:21:40 2006
@@ -765,6 +765,9 @@
     memset(s, 0, sizeof(AVCodecContext));
 
     s->av_class= &av_codec_context_class;
+
+    av_opt_set_defaults(s);
+
     s->bit_rate= 800*1000;
     s->bit_rate_tolerance= s->bit_rate*10;
     s->qmin= 2;

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	(original)
+++ trunk/libavformat/utils.c	Sun Sep 10 22:21:40 2006
@@ -486,6 +486,10 @@
 void avformat_get_context_defaults(AVFormatContext *s){
     memset(s, 0, sizeof(AVFormatContext));
 
+    s->av_class = &av_format_context_class;
+
+    av_opt_set_defaults(s);
+
     /* from mpegts.c: 1.0 second at 24Mbit/s */
     s->probesize=32000;
 }




More information about the ffmpeg-cvslog mailing list