void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime) { Audio::Timestamp timeDiff = time.convertToFramerate(_wvInfo.samplesPerSec) - frameTime.convertToFramerate(_wvInfo.samplesPerSec); int skipFrames = timeDiff.totalNumberOfFrames(); if (skipFrames <= 0) return; Audio::AudioStream *audioStream = getAudioStream(); if (!audioStream) return; if (audioStream->isStereo()) skipFrames *= 2; int16 *tempBuffer = new int16[skipFrames]; audioStream->readBuffer(tempBuffer, skipFrames); delete[] tempBuffer; }
bool QuickTimeDecoder::VideoTrackHandler::seek(const Audio::Timestamp &requestedTime) { uint32 convertedFrames = requestedTime.convertToFramerate(_decoder->_timeScale).totalNumberOfFrames(); for (_curEdit = 0; !atLastEdit(); _curEdit++) if (convertedFrames >= _parent->editList[_curEdit].timeOffset && convertedFrames < _parent->editList[_curEdit].timeOffset + _parent->editList[_curEdit].trackDuration) break; // If we did reach the end of the track, break out if (atLastEdit()) return true; // If this track is in an empty edit, position us at the next non-empty // edit. There's nothing else to do after this. if (_parent->editList[_curEdit].mediaTime == -1) { while (!atLastEdit() && _parent->editList[_curEdit].mediaTime == -1) _curEdit++; if (!atLastEdit()) enterNewEditList(true); return true; } enterNewEditList(false); // One extra check for the end of a track if (atLastEdit()) return true; // Now we're in the edit and need to figure out what frame we need Audio::Timestamp time = requestedTime.convertToFramerate(_parent->timeScale); while (getRateAdjustedFrameTime() < (uint32)time.totalNumberOfFrames()) { _curFrame++; if (_durationOverride >= 0) { _nextFrameStartTime += _durationOverride; _durationOverride = -1; } else { _nextFrameStartTime += getFrameDuration(); } } // All that's left is to figure out what our starting time is going to be // Compare the starting point for the frame to where we need to be _holdNextFrameStartTime = getRateAdjustedFrameTime() != (uint32)time.totalNumberOfFrames(); // If we went past the time, go back a frame. _curFrame before this point is at the frame // that should be displayed. This adjustment ensures it is on the frame before the one that // should be displayed. if (_holdNextFrameStartTime) _curFrame--; if (_reversed) { // Call setReverse again to update setReverse(true); } else { // Handle the keyframe here int32 destinationFrame = _curFrame + 1; assert(destinationFrame < (int32)_parent->frameCount); _curFrame = findKeyFrame(destinationFrame) - 1; while (_curFrame < destinationFrame - 1) bufferNextFrame(); } return true; }