mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1133955 - Record the last seek time to decide the direction to seek. r=sotaro
This commit is contained in:
parent
ca83d3a409
commit
a98559016b
@ -65,7 +65,7 @@ OmxDecoder::OmxDecoder(MediaResource *aResource,
|
||||
mAudioChannels(-1),
|
||||
mAudioSampleRate(-1),
|
||||
mDurationUs(-1),
|
||||
mVideoLastFrameTime(-1),
|
||||
mLastSeekTime(-1),
|
||||
mVideoBuffer(nullptr),
|
||||
mAudioBuffer(nullptr),
|
||||
mIsVideoSeeking(false),
|
||||
@ -386,6 +386,10 @@ void OmxDecoder::ReleaseMediaResources() {
|
||||
|
||||
mNativeWindowClient.clear();
|
||||
mNativeWindow.clear();
|
||||
|
||||
// Reset this variable to make the first seek go to the previous keyframe
|
||||
// when resuming
|
||||
mLastSeekTime = -1;
|
||||
}
|
||||
|
||||
bool OmxDecoder::SetVideoFormat() {
|
||||
@ -564,12 +568,13 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
MediaSource::ReadOptions::SeekMode seekMode;
|
||||
// If the last timestamp of decoded frame is smaller than seekTime,
|
||||
// seek to next key frame. Otherwise seek to the previos one.
|
||||
if (mVideoLastFrameTime > aTimeUs || mVideoLastFrameTime == -1) {
|
||||
OD_LOG("SeekTime: %lld, mLastSeekTime:%lld", aTimeUs, mLastSeekTime);
|
||||
if (mLastSeekTime == -1 || mLastSeekTime > aTimeUs) {
|
||||
seekMode = MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
|
||||
} else {
|
||||
seekMode = MediaSource::ReadOptions::SEEK_NEXT_SYNC;
|
||||
}
|
||||
|
||||
mLastSeekTime = aTimeUs;
|
||||
bool findNextBuffer = true;
|
||||
while (findNextBuffer) {
|
||||
options.setSeekTo(aTimeUs, seekMode);
|
||||
@ -675,7 +680,6 @@ bool OmxDecoder::ReadVideo(VideoFrame *aFrame, int64_t aTimeUs,
|
||||
if ((aKeyframeSkip && timeUs < aTimeUs) || length == 0) {
|
||||
aFrame->mShouldSkip = true;
|
||||
}
|
||||
mVideoLastFrameTime = timeUs;
|
||||
}
|
||||
else if (err == INFO_FORMAT_CHANGED) {
|
||||
// If the format changed, update our cached info.
|
||||
|
@ -60,7 +60,7 @@ class OmxDecoder : public OMXCodecProxy::EventListener {
|
||||
int32_t mAudioChannels;
|
||||
int32_t mAudioSampleRate;
|
||||
int64_t mDurationUs;
|
||||
int64_t mVideoLastFrameTime;
|
||||
int64_t mLastSeekTime;
|
||||
|
||||
VideoFrame mVideoFrame;
|
||||
AudioFrame mAudioFrame;
|
||||
|
Loading…
Reference in New Issue
Block a user