mirror of https://git.ffmpeg.org/ffmpeg.git
Add int64_t probesize2 instead of int probesize to AVFormatContext.
Allows to set a probesize >2G. Tested-by: Oliver Fromme
This commit is contained in:
parent
355121bcb5
commit
ff9a154157
|
@ -1296,9 +1296,7 @@ typedef struct AVFormatContext {
|
||||||
#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
|
#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Don't merge side data but keep it separate.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum size of the data read from input for determining
|
* @deprecated deprecated in favor of probesize2
|
||||||
* the input container format.
|
|
||||||
* Demuxing only, set by the caller before avformat_open_input().
|
|
||||||
*/
|
*/
|
||||||
unsigned int probesize;
|
unsigned int probesize;
|
||||||
|
|
||||||
|
@ -1671,6 +1669,14 @@ typedef struct AVFormatContext {
|
||||||
* Can be set to 0 to let avformat choose using a heuristic.
|
* Can be set to 0 to let avformat choose using a heuristic.
|
||||||
*/
|
*/
|
||||||
int64_t max_analyze_duration2;
|
int64_t max_analyze_duration2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum size of the data read from input for determining
|
||||||
|
* the input container format.
|
||||||
|
* Demuxing only, set by the caller before avformat_open_input()
|
||||||
|
* via AVOptions (NO direct access).
|
||||||
|
*/
|
||||||
|
int64_t probesize2;
|
||||||
} AVFormatContext;
|
} AVFormatContext;
|
||||||
|
|
||||||
int av_format_get_probe_score(const AVFormatContext *s);
|
int av_format_get_probe_score(const AVFormatContext *s);
|
||||||
|
|
|
@ -95,7 +95,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size);
|
||||||
* within the current pos and pos+buf_size is possible.
|
* within the current pos and pos+buf_size is possible.
|
||||||
* Once the stream position moves outside this window this guarantee is lost.
|
* Once the stream position moves outside this window this guarantee is lost.
|
||||||
*/
|
*/
|
||||||
int ffio_ensure_seekback(AVIOContext *s, int buf_size);
|
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size);
|
||||||
|
|
||||||
int ffio_limit(AVIOContext *s, int size);
|
int ffio_limit(AVIOContext *s, int size);
|
||||||
|
|
||||||
|
|
|
@ -767,7 +767,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ffio_ensure_seekback(AVIOContext *s, int buf_size)
|
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
|
||||||
{
|
{
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
int max_buffer_size = s->max_packet_size ?
|
int max_buffer_size = s->max_packet_size ?
|
||||||
|
|
|
@ -2242,12 +2242,13 @@ static void finished_reading_packet(AVFormatContext *s, int raw_packet_size)
|
||||||
avio_skip(pb, skip);
|
avio_skip(pb, skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_packets(MpegTSContext *ts, int nb_packets)
|
static int handle_packets(MpegTSContext *ts, int64_t nb_packets)
|
||||||
{
|
{
|
||||||
AVFormatContext *s = ts->stream;
|
AVFormatContext *s = ts->stream;
|
||||||
uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
|
||||||
const uint8_t *data;
|
const uint8_t *data;
|
||||||
int packet_num, ret = 0;
|
int64_t packet_num;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (avio_tell(s->pb) != ts->last_pos) {
|
if (avio_tell(s->pb) != ts->last_pos) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -2369,9 +2370,9 @@ static int mpegts_read_header(AVFormatContext *s)
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
uint8_t buf[8 * 1024] = {0};
|
uint8_t buf[8 * 1024] = {0};
|
||||||
int len;
|
int len;
|
||||||
int64_t pos;
|
int64_t pos, probesize = s->probesize ? s->probesize : s->probesize2;
|
||||||
|
|
||||||
ffio_ensure_seekback(pb, s->probesize);
|
ffio_ensure_seekback(pb, probesize);
|
||||||
|
|
||||||
/* read the first 8192 bytes to get packet size */
|
/* read the first 8192 bytes to get packet size */
|
||||||
pos = avio_tell(pb);
|
pos = avio_tell(pb);
|
||||||
|
@ -2394,7 +2395,7 @@ static int mpegts_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
|
mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
|
||||||
|
|
||||||
handle_packets(ts, s->probesize / ts->raw_packet_size);
|
handle_packets(ts, probesize / ts->raw_packet_size);
|
||||||
/* if could not find service, enable auto_guess */
|
/* if could not find service, enable auto_guess */
|
||||||
|
|
||||||
ts->auto_guess = 1;
|
ts->auto_guess = 1;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
static const AVOption avformat_options[] = {
|
static const AVOption avformat_options[] = {
|
||||||
{"avioflags", NULL, OFFSET(avio_flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "avioflags"},
|
{"avioflags", NULL, OFFSET(avio_flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, INT_MIN, INT_MAX, D|E, "avioflags"},
|
||||||
{"direct", "reduce buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVIO_FLAG_DIRECT }, INT_MIN, INT_MAX, D|E, "avioflags"},
|
{"direct", "reduce buffering", 0, AV_OPT_TYPE_CONST, {.i64 = AVIO_FLAG_DIRECT }, INT_MIN, INT_MAX, D|E, "avioflags"},
|
||||||
{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.i64 = 5000000 }, 32, INT_MAX, D},
|
{"probesize", "set probing size", OFFSET(probesize2), AV_OPT_TYPE_INT64, {.i64 = 5000000 }, 32, INT64_MAX, D},
|
||||||
{"formatprobesize", "number of bytes to probe file format", OFFSET(format_probesize), AV_OPT_TYPE_INT, {.i64 = PROBE_BUF_MAX}, 0, INT_MAX-1, D},
|
{"formatprobesize", "number of bytes to probe file format", OFFSET(format_probesize), AV_OPT_TYPE_INT, {.i64 = PROBE_BUF_MAX}, 0, INT_MAX-1, D},
|
||||||
{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, E},
|
{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, E},
|
||||||
{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D|E, "fflags"},
|
{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D|E, "fflags"},
|
||||||
|
|
|
@ -2950,10 +2950,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
|
||||||
int64_t old_offset = avio_tell(ic->pb);
|
int64_t old_offset = avio_tell(ic->pb);
|
||||||
// new streams might appear, no options for those
|
// new streams might appear, no options for those
|
||||||
int orig_nb_streams = ic->nb_streams;
|
int orig_nb_streams = ic->nb_streams;
|
||||||
int flush_codecs = ic->probesize > 0;
|
int flush_codecs;
|
||||||
int64_t max_analyze_duration = ic->max_analyze_duration2;
|
int64_t max_analyze_duration = ic->max_analyze_duration2;
|
||||||
|
int64_t probesize = ic->probesize2;
|
||||||
|
|
||||||
if (!max_analyze_duration)
|
if (!max_analyze_duration)
|
||||||
max_analyze_duration = ic->max_analyze_duration;
|
max_analyze_duration = ic->max_analyze_duration;
|
||||||
|
if (ic->probesize)
|
||||||
|
probesize = ic->probesize;
|
||||||
|
flush_codecs = probesize > 0;
|
||||||
|
|
||||||
av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN);
|
av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN);
|
||||||
|
|
||||||
|
@ -3081,10 +3086,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* We did not get all the codec info, but we read too much data. */
|
/* We did not get all the codec info, but we read too much data. */
|
||||||
if (read_size >= ic->probesize) {
|
if (read_size >= probesize) {
|
||||||
ret = count;
|
ret = count;
|
||||||
av_log(ic, AV_LOG_DEBUG,
|
av_log(ic, AV_LOG_DEBUG,
|
||||||
"Probe buffer size limit of %d bytes reached\n", ic->probesize);
|
"Probe buffer size limit of %"PRId64" bytes reached\n", probesize);
|
||||||
for (i = 0; i < ic->nb_streams; i++)
|
for (i = 0; i < ic->nb_streams; i++)
|
||||||
if (!ic->streams[i]->r_frame_rate.num &&
|
if (!ic->streams[i]->r_frame_rate.num &&
|
||||||
ic->streams[i]->info->duration_count <= 1 &&
|
ic->streams[i]->info->duration_count <= 1 &&
|
||||||
|
@ -3328,7 +3333,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ic->probesize)
|
if (probesize)
|
||||||
estimate_timings(ic, old_offset);
|
estimate_timings(ic, old_offset);
|
||||||
|
|
||||||
if (ret >= 0 && ic->nb_streams)
|
if (ret >= 0 && ic->nb_streams)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 55
|
#define LIBAVFORMAT_VERSION_MAJOR 55
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 49
|
#define LIBAVFORMAT_VERSION_MINOR 50
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 100
|
#define LIBAVFORMAT_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
|
|
Loading…
Reference in New Issue