AUDIO: Fix M4A seeking with multiple time->sample chunks
This commit is contained in:
parent
65b3a91fb0
commit
4a0dc293b5
1 changed files with 16 additions and 9 deletions
|
@ -227,16 +227,23 @@ void QuickTimeAudioDecoder::setAudioStreamPos(const Timestamp &where) {
|
||||||
uint32 seekSample = sample;
|
uint32 seekSample = sample;
|
||||||
|
|
||||||
if (!isOldDemuxing()) {
|
if (!isOldDemuxing()) {
|
||||||
// We shouldn't have audio samples that are a different duration
|
// For MPEG-4 style demuxing, we need to track down the sample based on the time
|
||||||
// That would be quite bad!
|
// The old style demuxing doesn't require this because each "sample"'s duration
|
||||||
if (_tracks[_audioTrackIndex]->timeToSampleCount != 1) {
|
// is just 1
|
||||||
warning("Failed seeking");
|
uint32 curSample = 0;
|
||||||
return;
|
seekSample = 0;
|
||||||
}
|
|
||||||
|
|
||||||
// Note that duration is in terms of *one* channel
|
for (int32 i = 0; i < _tracks[_audioTrackIndex]->timeToSampleCount; i++) {
|
||||||
// This eases calculation a bit
|
uint32 sampleCount = _tracks[_audioTrackIndex]->timeToSample[i].count * _tracks[_audioTrackIndex]->timeToSample[i].duration;
|
||||||
seekSample /= _tracks[_audioTrackIndex]->timeToSample[0].duration;
|
|
||||||
|
if (sample < curSample + sampleCount) {
|
||||||
|
seekSample += (sample - curSample) / _tracks[_audioTrackIndex]->timeToSample[i].duration;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
seekSample += _tracks[_audioTrackIndex]->timeToSample[i].count;
|
||||||
|
curSample += sampleCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now to track down what chunk it's in
|
// Now to track down what chunk it's in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue