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", "set probing size", OFFSET(probesize), FF_OPT_TYPE_INT, 5000000, 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 {"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOFILLIN, INT_MIN, INT_MAX, D, "fflags"},
00050 {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_NOPARSE, INT_MIN, INT_MAX, D, "fflags"},
00051 {"igndts", "ingore dts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNDTS, INT_MIN, INT_MAX, D, "fflags"},
00052 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00053 {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
00054 {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
00055 #endif
00056 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 5*AV_TIME_BASE, 0, INT_MAX, D},
00057 {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
00058 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
00059 {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, 3041280, 0, INT_MAX, D},
00060 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
00061 {"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
00062 {NULL},
00063 };
00064
00065 #undef E
00066 #undef D
00067 #undef DEFAULT
00068
00069 static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
00070
00071 static void avformat_get_context_defaults(AVFormatContext *s)
00072 {
00073 memset(s, 0, sizeof(AVFormatContext));
00074
00075 s->av_class = &av_format_context_class;
00076
00077 av_opt_set_defaults(s);
00078 }
00079
00080 AVFormatContext *avformat_alloc_context(void)
00081 {
00082 AVFormatContext *ic;
00083 ic = av_malloc(sizeof(AVFormatContext));
00084 if (!ic) return ic;
00085 avformat_get_context_defaults(ic);
00086 ic->av_class = &av_format_context_class;
00087 return ic;
00088 }
00089
00090 #if LIBAVFORMAT_VERSION_MAJOR < 53
00091 AVFormatContext *av_alloc_format_context(void)
00092 {
00093 return avformat_alloc_context();
00094 }
00095 #endif