From 2e8c80cf58e03ad735a5b147f11d31f07e49e33a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 29 Dec 2016 16:54:13 -0500 Subject: VIDEO: Add support for AVI 2-track videos with missing track 2 indexes --- video/avi_decoder.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'video') diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index fc73cfaeac..c2c485c1eb 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -721,18 +721,31 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { AVIVideoTrack *videoTrack2 = static_cast(_videoTracks.back().track); videoTrack2->setCurFrame((int)frame - 1); - // Find the index entry for the frame and read it in - OldIndex *entry = _indexEntries.find(_videoTracks.back().index, frame); + // Find the index entry for the frame + int indexFrame = frame; + OldIndex *entry = nullptr; + do { + entry = _indexEntries.find(_videoTracks.back().index, indexFrame); + } while (!entry && --indexFrame >= 0); assert(entry); + // Read in the frame Common::SeekableReadStream *chunk = nullptr; _fileStream->seek(entry->offset + 8); _videoTracks.back().chunkSearchOffset = entry->offset; if (entry->size != 0) chunk = _fileStream->readStream(entry->size); - videoTrack2->decodeFrame(chunk); + + if (indexFrame < frame) { + TrackStatus &status = _videoTracks.back(); + while (indexFrame++ < frame) { + // There was no index entry for the desired frame, so an earlier one was decoded. + // We now have to sequentially decode frames until we get to the desired frame + handleNextPacket(status); + } + } } // Set the video track's frame -- cgit v1.2.3