changeset 1278:f40d75601106 libavformat

initial support for AVOption in AVFormatContext
author nicodvb
date Sun, 27 Aug 2006 12:14:13 +0000
parents e27e94ac0c4b
children a12e0b434174
files avformat.h utils.c
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/avformat.h	Fri Aug 25 20:50:18 2006 +0000
+++ b/avformat.h	Sun Aug 27 12:14:13 2006 +0000
@@ -112,6 +112,7 @@
                                   mpeg2ts_raw is TRUE */
     int initial_pause:1;       /* do not begin to play the stream
                                   immediately (RTSP only) */
+    int prealloced_context:1;
     enum CodecID video_codec_id;
     enum CodecID audio_codec_id;
 } AVFormatParameters;
--- a/utils.c	Fri Aug 25 20:50:18 2006 +0000
+++ b/utils.c	Sun Aug 27 12:14:13 2006 +0000
@@ -18,6 +18,7 @@
  */
 #include "avformat.h"
 #include "allformats.h"
+#include "opt.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -453,13 +454,28 @@
     else return "NULL";
 }
 
-static const AVClass av_format_context_class = { "AVFormatContext", format_to_name };
+#define OFFSET(x) (int)&((AVFormatContext*)0)->x
+#define DEFAULT 0 //should be NAN but it doesnt work as its not a constant in glibc as required by ANSI/ISO C
+//these names are too long to be readable
+#define E AV_OPT_FLAG_ENCODING_PARAM
+#define D AV_OPT_FLAG_DECODING_PARAM
+
+static const AVOption options[]={
+{NULL},
+};
+
+static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
+
+void avformat_get_context_defaults(AVFormatContext *s){
+    memset(s, 0, sizeof(AVFormatContext));
+}
 
 AVFormatContext *av_alloc_format_context(void)
 {
     AVFormatContext *ic;
     ic = av_mallocz(sizeof(AVFormatContext));
     if (!ic) return ic;
+    avformat_get_context_defaults(ic);
     ic->av_class = &av_format_context_class;
     return ic;
 }
@@ -481,7 +497,10 @@
         memset(ap, 0, sizeof(default_ap));
     }
 
-    ic = av_alloc_format_context();
+    if(!ap->prealloced_context)
+        ic = av_alloc_format_context();
+    else
+        ic = *ic_ptr;
     if (!ic) {
         err = AVERROR_NOMEM;
         goto fail;