1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/demux: allow total size of packets in raw_packet_buffer to reach probesize

Previously this was hardcoded to 2500000 bytes, so probing of the stream codecs
was always limited by this, and not probesize.

Also keep track of the actual size of packets in raw_packet_buffer and not the
remaining size for simplicity.

Fixes ticket #5860.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2021-11-07 18:21:17 +01:00
parent 0a9edac48e
commit 406ffd9b9b
4 changed files with 8 additions and 10 deletions

View File

@ -328,7 +328,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
if (s->pb && !si->data_offset)
si->data_offset = avio_tell(s->pb);
si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
si->raw_packet_buffer_size = 0;
update_stream_avctx(s);
@ -432,7 +432,7 @@ no_packet:
}
}
end = si->raw_packet_buffer_remaining_size <= 0
end = si->raw_packet_buffer_size >= s->probesize
|| sti->probe_packets <= 0;
if (end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) {
@ -544,13 +544,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (pktl) {
AVStream *const st = s->streams[pktl->pkt.stream_index];
if (si->raw_packet_buffer_remaining_size <= 0)
if (si->raw_packet_buffer_size >= s->probesize)
if ((err = probe_codec(s, st, NULL)) < 0)
return err;
if (ffstream(st)->request_probe <= 0) {
avpriv_packet_list_get(&si->raw_packet_buffer,
&si->raw_packet_buffer_end, pkt);
si->raw_packet_buffer_remaining_size += pkt->size;
si->raw_packet_buffer_size -= pkt->size;
return 0;
}
}
@ -631,7 +631,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return err;
}
pkt1 = &si->raw_packet_buffer_end->pkt;
si->raw_packet_buffer_remaining_size -= pkt1->size;
si->raw_packet_buffer_size += pkt1->size;
if ((err = probe_codec(s, st, pkt1)) < 0)
return err;

View File

@ -127,10 +127,9 @@ typedef struct FFFormatContext {
*/
AVPacket *pkt;
/**
* Remaining size available for raw_packet_buffer, in bytes.
* Sum of the size of packets in raw_packet_buffer, in bytes.
*/
#define RAW_PACKET_BUFFER_SIZE 2500000
int raw_packet_buffer_remaining_size;
int raw_packet_buffer_size;
/**
* Offset to remap timestamps to be non-negative.

View File

@ -174,7 +174,6 @@ AVFormatContext *avformat_alloc_context(void)
}
si->offset = AV_NOPTS_VALUE;
si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
si->shortest_end = AV_NOPTS_VALUE;
return s;

View File

@ -303,7 +303,7 @@ void ff_flush_packet_queue(AVFormatContext *s)
avpriv_packet_list_free(&si->packet_buffer, &si->packet_buffer_end);
avpriv_packet_list_free(&si->raw_packet_buffer, &si->raw_packet_buffer_end);
si->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
si->raw_packet_buffer_size = 0;
}
int av_find_default_stream_index(AVFormatContext *s)