Matroska reader: don't buffer if reading next frame is forced

With very large video frames (one test file has h.264 from Blu-rays
with ten seconds between key frames and an average frame size of ~350
KB) buffering due to external timestamps being applied could easily
lead to the packetizer holding more than 128 MB of data in memory
while waiting for the next key frame before it can apply the
timestamps. The reader must not refuse to deliver frames in such a
case, otherwise the next I frame will never appear, the packetizer
will never write out those buffered frames and the whole process ends
up in an endless loop.

Fixes #2550.
This commit is contained in:
Moritz Bunkus 2019-05-18 12:37:43 +02:00
parent 970193a36e
commit 92f9ec9847
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,9 @@
wrong data in source files. Fixes #2541.
* mkvmerge: AV1: fixed frame timestamp calculation when reading bitstreams
that lack timing information from IVF files. Fixes #2553.
* mkvmerge: Matroska reader: fixed an infinite loop that could happen with
large video frames and applied timestamp files due to too much data being
buffered at the wrong time. Fixes #2550.
# Version 33.1.0 "Primrose" 2019-04-15

View File

@ -2272,7 +2272,7 @@ kax_reader_c::read(generic_packetizer_c *requested_ptzr,
auto requested_ptzr_track = m_ptzr_to_track_map[requested_ptzr];
if ( !requested_ptzr_track
|| (!force && ('a' != requested_ptzr_track->type) && ('v' != requested_ptzr_track->type))
|| (128 * 1024 * 1024 < num_queued_bytes))
|| (!force && (128 * 1024 * 1024 < num_queued_bytes)))
return FILE_STATUS_HOLDING;
}