summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Gelman <andriy.gelman@gmail.com>2019-10-17 10:49:20 -0400
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-03 11:52:32 +0100
commit5e3229df4ca86322f334bd098a9335f66ebdd649 (patch)
tree323d2b60daf824630cc304635746b1983f47268f
parent33583803e107b6d532def0f9d949364b01b6ad5a (diff)
avformat: Add max_probe_packets option
Allows user to set maximum number of buffered packets when probing a codec. It was a hard-coded parameter before this commit. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--doc/formats.texi4
-rw-r--r--libavformat/avformat.h7
-rw-r--r--libavformat/internal.h2
-rw-r--r--libavformat/options_table.h1
-rw-r--r--libavformat/utils.c6
-rw-r--r--libavformat/version.h2
6 files changed, 16 insertions, 6 deletions
diff --git a/doc/formats.texi b/doc/formats.texi
index d689fbadfa..fc80ce1d2b 100644
--- a/doc/formats.texi
+++ b/doc/formats.texi
@@ -27,6 +27,10 @@ stream information. A higher value will enable detecting more
information in case it is dispersed into the stream, but will increase
latency. Must be an integer not lesser than 32. It is 5000000 by default.
+@item max_probe_packets @var{integer} (@emph{input})
+Set the maximum number of buffered packets when probing a codec.
+Default is 2500 packets.
+
@item packetsize @var{integer} (@emph{output})
Set packet size.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6eb329f13f..d4d9a3b06e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
* - decoding: set by user
*/
int skip_estimate_duration_from_pts;
+
+ /**
+ * Maximum number of packets that can be probed
+ * - encoding: unused
+ * - decoding: set by user
+ */
+ int max_probe_packets;
} AVFormatContext;
#if FF_API_FORMAT_GET_SET
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 67c35cc3e1..ec9a29907a 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -33,8 +33,6 @@
#define PROBE_BUF_MIN 2048
#define PROBE_BUF_MAX (1 << 20)
-#define MAX_PROBE_PACKETS 2500
-
#ifdef DEBUG
# define hex_dump_debug(class, buf, size) av_hex_dump_log(class, AV_LOG_DEBUG, buf, size)
#else
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index f2f077b34f..432818f80d 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -111,6 +111,7 @@ static const AVOption avformat_options[] = {
{"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D },
{"max_streams", "maximum number of streams", OFFSET(max_streams), AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
{"skip_estimate_duration_from_pts", "skip duration calculation in estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
+{"max_probe_packets", "Maximum number of packets to probe a codec", OFFSET(max_probe_packets), AV_OPT_TYPE_INT, { .i64 = 2500 }, 0, INT_MAX, D },
{NULL},
};
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cfb6d03397..8196442dd1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -363,7 +363,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
int i;
av_log(s, AV_LOG_DEBUG,
"Probe with size=%d, packets=%d detected %s with score=%d\n",
- pd->buf_size, MAX_PROBE_PACKETS - st->probe_packets,
+ pd->buf_size, s->max_probe_packets - st->probe_packets,
fmt->name, score);
for (i = 0; fmt_id_type[i].name; i++) {
if (!strcmp(fmt->name, fmt_id_type[i].name)) {
@@ -1948,7 +1948,7 @@ void ff_read_frame_flush(AVFormatContext *s)
/* We set the current DTS to an unspecified origin. */
st->cur_dts = AV_NOPTS_VALUE;
- st->probe_packets = MAX_PROBE_PACKETS;
+ st->probe_packets = s->max_probe_packets;
for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
st->pts_buffer[j] = AV_NOPTS_VALUE;
@@ -4570,7 +4570,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
st->start_time = AV_NOPTS_VALUE;
st->duration = AV_NOPTS_VALUE;
st->first_dts = AV_NOPTS_VALUE;
- st->probe_packets = MAX_PROBE_PACKETS;
+ st->probe_packets = s->max_probe_packets;
st->pts_wrap_reference = AV_NOPTS_VALUE;
st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
diff --git a/libavformat/version.h b/libavformat/version.h
index bcd0408d28..dce5a124c7 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
-#define LIBAVFORMAT_VERSION_MINOR 33
+#define LIBAVFORMAT_VERSION_MINOR 34
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \