diff options
author | Andreas Huber <andih@google.com> | 2010-07-20 15:04:28 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-07-21 08:51:29 -0700 |
commit | abd1f4f870925d6776dbe4b930b759a1ab6595ca (patch) | |
tree | 1b86ec19a16a2a340afecfd6207b1fd8236228b9 /media/libstagefright/codecs/m4v_h263 | |
parent | 3108231d90e8aa324923fd8864ca2477948c5d25 (diff) | |
download | frameworks_av-abd1f4f870925d6776dbe4b930b759a1ab6595ca.zip frameworks_av-abd1f4f870925d6776dbe4b930b759a1ab6595ca.tar.gz frameworks_av-abd1f4f870925d6776dbe4b930b759a1ab6595ca.tar.bz2 |
Support finer seek control on MediaSources.
related-to-bug: 2858448
Change-Id: Ifb4b13b990fd5889113e47e2c62249ac43391fa1
Diffstat (limited to 'media/libstagefright/codecs/m4v_h263')
-rw-r--r-- | media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp index 8350f7a..0f08f6e 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/M4vH263Decoder.cpp @@ -37,7 +37,8 @@ M4vH263Decoder::M4vH263Decoder(const sp<MediaSource> &source) mStarted(false), mHandle(new tagvideoDecControls), mInputBuffer(NULL), - mNumSamplesOutput(0) { + mNumSamplesOutput(0), + mTargetTimeUs(-1) { LOGV("M4vH263Decoder"); memset(mHandle, 0, sizeof(tagvideoDecControls)); @@ -146,6 +147,7 @@ status_t M4vH263Decoder::start(MetaData *) { mSource->start(); mNumSamplesOutput = 0; + mTargetTimeUs = -1; mStarted = true; return OK; @@ -175,8 +177,11 @@ status_t M4vH263Decoder::read( MediaBuffer **out, const ReadOptions *options) { *out = NULL; + bool seeking = false; int64_t seekTimeUs; - if (options && options->getSeekTo(&seekTimeUs)) { + ReadOptions::SeekMode mode; + if (options && options->getSeekTo(&seekTimeUs, &mode)) { + seeking = true; CHECK_EQ(PVResetVideoDecoder(mHandle), PV_TRUE); } @@ -186,6 +191,16 @@ status_t M4vH263Decoder::read( return err; } + if (seeking) { + int64_t targetTimeUs; + if (inputBuffer->meta_data()->findInt64(kKeyTargetTime, &targetTimeUs) + && targetTimeUs >= 0) { + mTargetTimeUs = targetTimeUs; + } else { + mTargetTimeUs = -1; + } + } + uint8_t *bitstream = (uint8_t *) inputBuffer->data() + inputBuffer->range_offset(); @@ -221,17 +236,40 @@ status_t M4vH263Decoder::read( return INFO_FORMAT_CHANGED; } - *out = mFrames[mNumSamplesOutput & 0x01]; - (*out)->add_ref(); - int64_t timeUs; CHECK(inputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)); - (*out)->meta_data()->setInt64(kKeyTime, timeUs); - ++mNumSamplesOutput; inputBuffer->release(); inputBuffer = NULL; + bool skipFrame = false; + + if (mTargetTimeUs >= 0) { + CHECK(timeUs <= mTargetTimeUs); + + if (timeUs < mTargetTimeUs) { + // We're still waiting for the frame with the matching + // timestamp and we won't return the current one. + skipFrame = true; + + LOGV("skipping frame at %lld us", timeUs); + } else { + LOGV("found target frame at %lld us", timeUs); + + mTargetTimeUs = -1; + } + } + + if (skipFrame) { + *out = new MediaBuffer(0); + } else { + *out = mFrames[mNumSamplesOutput & 0x01]; + (*out)->add_ref(); + (*out)->meta_data()->setInt64(kKeyTime, timeUs); + } + + ++mNumSamplesOutput; + return OK; } |