00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "avformat.h"
00021 #include "libavcodec/opt.h"
00022
00028 static const char* format_to_name(void* ptr)
00029 {
00030 AVFormatContext* fc = (AVFormatContext*) ptr;
00031 if(fc->iformat) return fc->iformat->name;
00032 else if(fc->oformat) return fc->oformat->name;
00033 else return "NULL";
00034 }
00035
00036 #define OFFSET(x) offsetof(AVFormatContext,x)
00037 #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
00038
00039 #define E AV_OPT_FLAG_ENCODING_PARAM
00040 #define D AV_OPT_FLAG_DECODING_PARAM
00041
00042 static const AVOption options[]={
00043 {"probesize", NULL, OFFSET(probesize), FF_OPT_TYPE_INT, 32000, 32, INT_MAX, D},
00044 {"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00045 {"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00046 {"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, D|E, "fflags"},
00047 {"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNIDX, INT_MIN, INT_MAX, D, "fflags"},
00048 {"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
00049 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00050 {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00051 {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
00052 #endif
00053 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 3*AV_TIME_BASE, 0, INT_MAX, D},
00054 {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
00055 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
00056 {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, 3041280, 0, INT_MAX, D},
00057 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
00058 {"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
00059 {NULL},
00060 };
00061
00062 #undef E
00063 #undef D
00064 #undef DEFAULT
00065
00066 static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
00067
00068 static void avformat_get_context_defaults(AVFormatContext *s)
00069 {
00070 memset(s, 0, sizeof(AVFormatContext));
00071
00072 s->av_class = &av_format_context_class;
00073
00074 av_opt_set_defaults(s);
00075 }
00076
00077 AVFormatContext *avformat_alloc_context(void)
00078 {
00079 AVFormatContext *ic;
00080 ic = av_malloc(sizeof(AVFormatContext));
00081 if (!ic) return ic;
00082 avformat_get_context_defaults(ic);
00083 ic->av_class = &av_format_context_class;
00084 return ic;
00085 }
00086
00087 #if LIBAVFORMAT_VERSION_MAJOR < 53
00088 AVFormatContext *av_alloc_format_context(void)
00089 {
00090 return avformat_alloc_context();
00091 }
00092 #endif