381
400
* Open a media file from an IO stream. 'fmt' must be specified.
383
static const char* format_to_name(void* ptr)
385
AVFormatContext* fc = (AVFormatContext*) ptr;
386
if(fc->iformat) return fc->iformat->name;
387
else if(fc->oformat) return fc->oformat->name;
391
#define OFFSET(x) offsetof(AVFormatContext,x)
392
#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
393
//these names are too long to be readable
394
#define E AV_OPT_FLAG_ENCODING_PARAM
395
#define D AV_OPT_FLAG_DECODING_PARAM
397
static const AVOption options[]={
398
{"probesize", NULL, OFFSET(probesize), FF_OPT_TYPE_INT, 32000, 32, INT_MAX, D}, /* 32000 from mpegts.c: 1.0 second at 24Mbit/s */
399
{"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
400
{"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
401
{"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, D|E, "fflags"},
402
{"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNIDX, INT_MIN, INT_MAX, D, "fflags"},
403
{"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
404
{"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
405
{"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
406
{"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},
407
{"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
408
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
409
{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, 3041280, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
410
{"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
411
{"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
419
static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
421
static void avformat_get_context_defaults(AVFormatContext *s)
423
memset(s, 0, sizeof(AVFormatContext));
425
s->av_class = &av_format_context_class;
427
av_opt_set_defaults(s);
430
AVFormatContext *av_alloc_format_context(void)
433
ic = av_malloc(sizeof(AVFormatContext));
435
avformat_get_context_defaults(ic);
436
ic->av_class = &av_format_context_class;
440
402
int av_open_input_stream(AVFormatContext **ic_ptr,
441
403
ByteIOContext *pb, const char *filename,
442
404
AVInputFormat *fmt, AVFormatParameters *ap)