VIDEO: Fix getNextFramePacket() to actually be efficient
This commit is contained in:
parent
a064b7bc0b
commit
6a54c7953a
1 changed files with 6 additions and 11 deletions
|
@ -483,23 +483,18 @@ Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket(uint32 &descId)
|
||||||
int32 totalSampleCount = 0;
|
int32 totalSampleCount = 0;
|
||||||
int32 sampleInChunk = 0;
|
int32 sampleInChunk = 0;
|
||||||
int32 actualChunk = -1;
|
int32 actualChunk = -1;
|
||||||
|
uint32 sampleToChunkIndex = 0;
|
||||||
|
|
||||||
for (uint32 i = 0; i < _tracks[_videoTrackIndex]->chunkCount; i++) {
|
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++)
|
totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count;
|
||||||
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;
|
|
||||||
|
|
||||||
if (totalSampleCount > getCurFrame()) {
|
if (totalSampleCount > getCurFrame()) {
|
||||||
actualChunk = i;
|
actualChunk = i;
|
||||||
descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].id;
|
descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].id;
|
||||||
sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count - totalSampleCount + getCurFrame();
|
sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count - totalSampleCount + getCurFrame();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue