Revision 708ec8fb libavformat/utils.c

View differences:

libavformat/utils.c
381 381
/**
382 382
 * Open a media file from an IO stream. 'fmt' must be specified.
383 383
 */
384
static const char* format_to_name(void* ptr)
385
{
386
    AVFormatContext* fc = (AVFormatContext*) ptr;
387
    if(fc->iformat) return fc->iformat->name;
388
    else if(fc->oformat) return fc->oformat->name;
389
    else return "NULL";
390
}
391

  
392
#define OFFSET(x) offsetof(AVFormatContext,x)
393
#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
394
//these names are too long to be readable
395
#define E AV_OPT_FLAG_ENCODING_PARAM
396
#define D AV_OPT_FLAG_DECODING_PARAM
397

  
398
static const AVOption options[]={
399
{"probesize", NULL, OFFSET(probesize), FF_OPT_TYPE_INT, 32000, 32, INT_MAX, D}, /* 32000 from mpegts.c: 1.0 second at 24Mbit/s */
400
{"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
401
{"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
402
{"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, DEFAULT, INT_MIN, INT_MAX, D|E, "fflags"},
403
{"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_IGNIDX, INT_MIN, INT_MAX, D, "fflags"},
404
{"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, AVFMT_FLAG_GENPTS, INT_MIN, INT_MAX, D, "fflags"},
405
{"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E},
406
{"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E},
407
{"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},
408
{"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D},
409
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
410
{"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 */
411
{"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
412
{"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
413
{NULL},
414
};
415

  
416
#undef E
417
#undef D
418
#undef DEFAULT
419

  
420
static const AVClass av_format_context_class = { "AVFormatContext", format_to_name, options };
421

  
422
static void avformat_get_context_defaults(AVFormatContext *s)
423
{
424
    memset(s, 0, sizeof(AVFormatContext));
425

  
426
    s->av_class = &av_format_context_class;
427

  
428
    av_opt_set_defaults(s);
429
}
430

  
431
AVFormatContext *av_alloc_format_context(void)
432
{
433
    AVFormatContext *ic;
434
    ic = av_malloc(sizeof(AVFormatContext));
435
    if (!ic) return ic;
436
    avformat_get_context_defaults(ic);
437
    ic->av_class = &av_format_context_class;
438
    return ic;
439
}
440

  
441 384
int av_open_input_stream(AVFormatContext **ic_ptr,
442 385
                         ByteIOContext *pb, const char *filename,
443 386
                         AVInputFormat *fmt, AVFormatParameters *ap)

Also available in: Unified diff