# HG changeset patch # User nicodvb # Date 1156680853 0 # Node ID f40d75601106a4bca399a398c64eaab35d1ba3b5 # Parent e27e94ac0c4bc488d6b1ebd9d6c47afeb506c61c initial support for AVOption in AVFormatContext diff -r e27e94ac0c4b -r f40d75601106 avformat.h --- 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; diff -r e27e94ac0c4b -r f40d75601106 utils.c --- 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 @@ -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;