aboutsummaryrefslogtreecommitdiff
path: root/video/qt_decoder.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-10-07 10:16:38 -0400
committerMatthew Hoops2011-10-07 11:34:30 -0400
commit6a54c7953a03b901e928c1a4c95bbcead1342c20 (patch)
treee1a4013ac0cc7bfb9d60c10ca7e856788ac3ed2c /video/qt_decoder.cpp
parenta064b7bc0b38268b14d52755d8d3747db28240ae (diff)
downloadscummvm-rg350-6a54c7953a03b901e928c1a4c95bbcead1342c20.tar.gz
scummvm-rg350-6a54c7953a03b901e928c1a4c95bbcead1342c20.tar.bz2
scummvm-rg350-6a54c7953a03b901e928c1a4c95bbcead1342c20.zip
VIDEO: Fix getNextFramePacket() to actually be efficient
Diffstat (limited to 'video/qt_decoder.cpp')
-rw-r--r--video/qt_decoder.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 2dfb56dcea..389acea86b 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -483,23 +483,18 @@ Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket(uint32 &descId)
int32 totalSampleCount = 0;
int32 sampleInChunk = 0;
int32 actualChunk = -1;
+ uint32 sampleToChunkIndex = 0;
for (uint32 i = 0; i < _tracks[_videoTrackIndex]->chunkCount; i++) {
- int32 sampleToChunkIndex = -1;
+ if (i >= _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].first)
+ sampleToChunkIndex++;
- for (uint32 j = 0; j < _tracks[_videoTrackIndex]->sampleToChunkCount; j++)
- if (i >= _tracks[_videoTrackIndex]->sampleToChunk[j].first)
- sampleToChunkIndex = j;
-
- if (sampleToChunkIndex < 0)
- error("This chunk (%d) is imaginary", sampleToChunkIndex);
-
- totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count;
+ totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count;
if (totalSampleCount > getCurFrame()) {
actualChunk = i;
- descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].id;
- sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count - totalSampleCount + getCurFrame();
+ descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].id;
+ sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count - totalSampleCount + getCurFrame();
break;
}
}