Commit 52887aa4 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat: move default for max_analyze_duration into utils.c

this way we can do better tha a single fixed constant value
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 60ef6124
...@@ -1291,6 +1291,7 @@ typedef struct AVFormatContext { ...@@ -1291,6 +1291,7 @@ typedef struct AVFormatContext {
* Maximum duration (in AV_TIME_BASE units) of the data read * Maximum duration (in AV_TIME_BASE units) of the data read
* from input in avformat_find_stream_info(). * from input in avformat_find_stream_info().
* Demuxing only, set by the caller before avformat_find_stream_info(). * Demuxing only, set by the caller before avformat_find_stream_info().
* Can be set to 0 to let avformat choose using a heuristic.
*/ */
int max_analyze_duration; int max_analyze_duration;
......
...@@ -53,7 +53,7 @@ static const AVOption avformat_options[] = { ...@@ -53,7 +53,7 @@ static const AVOption avformat_options[] = {
{"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"}, {"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
{"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D}, {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", OFFSET(seek2any), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, D},
{"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" }, {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
{"analyzeduration", "specify how many microseconds are analyzed to probe the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.i64 = 5*AV_TIME_BASE }, 0, INT_MAX, D}, {"analyzeduration", "specify how many microseconds are analyzed to probe the input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, D},
{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D}, {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.i64 = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.i64 = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
......
...@@ -3289,6 +3289,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) ...@@ -3289,6 +3289,11 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
} }
if (st->codec_info_nb_frames>1) { if (st->codec_info_nb_frames>1) {
int64_t t = 0; int64_t t = 0;
int max_analyze_duration = ic->max_analyze_duration;
if (!max_analyze_duration)
max_analyze_duration = 5*AV_TIME_BASE;
if (st->time_base.den > 0) if (st->time_base.den > 0)
t = av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q); t = av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q);
if (st->avg_frame_rate.num > 0) if (st->avg_frame_rate.num > 0)
...@@ -3300,9 +3305,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) ...@@ -3300,9 +3305,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
&& st->info->fps_last_dts != AV_NOPTS_VALUE) && st->info->fps_last_dts != AV_NOPTS_VALUE)
t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q)); t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
if (t >= ic->max_analyze_duration) { if (t >= max_analyze_duration) {
av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %d reached at %"PRId64" microseconds\n", av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %d reached at %"PRId64" microseconds\n",
ic->max_analyze_duration, max_analyze_duration,
t); t);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment