1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

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:
Carl Eugen Hoyos 2014-07-30 11:09:25 +02:00
parent 355121bcb5
commit ff9a154157
7 changed files with 28 additions and 16 deletions

View File

@ -1296,9 +1296,7 @@ typedef struct AVFormatContext {
#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
* the input container format.
* Demuxing only, set by the caller before avformat_open_input().
* @deprecated deprecated in favor of probesize2
*/
unsigned int probesize;
@ -1671,6 +1669,14 @@ typedef struct AVFormatContext {
* Can be set to 0 to let avformat choose using a heuristic.
*/
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;
int av_format_get_probe_score(const AVFormatContext *s);

View File

@ -95,7 +95,7 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size);
* within the current pos and pos+buf_size is possible.
* 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);

View File

@ -767,7 +767,7 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
return 0;
}
int ffio_ensure_seekback(AVIOContext *s, int buf_size)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
{
uint8_t *buffer;
int max_buffer_size = s->max_packet_size ?

View File

@ -2242,12 +2242,13 @@ static void finished_reading_packet(AVFormatContext *s, int raw_packet_size)
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;
uint8_t packet[TS_PACKET_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
const uint8_t *data;
int packet_num, ret = 0;
int64_t packet_num;
int ret = 0;
if (avio_tell(s->pb) != ts->last_pos) {
int i;
@ -2369,9 +2370,9 @@ static int mpegts_read_header(AVFormatContext *s)
AVIOContext *pb = s->pb;
uint8_t buf[8 * 1024] = {0};
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 */
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);
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 */
ts->auto_guess = 1;

View File

@ -36,7 +36,7 @@
static const AVOption avformat_options[] = {
{"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"},
{"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},
{"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"},

View File

@ -2950,10 +2950,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int64_t old_offset = avio_tell(ic->pb);
// new streams might appear, no options for those
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 probesize = ic->probesize2;
if (!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);
@ -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. */
if (read_size >= ic->probesize) {
if (read_size >= probesize) {
ret = count;
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++)
if (!ic->streams[i]->r_frame_rate.num &&
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);
if (ret >= 0 && ic->nb_streams)

View File

@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 49
#define LIBAVFORMAT_VERSION_MINOR 50
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \