summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/on2
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-07-20 15:04:28 -0700
committerAndreas Huber <andih@google.com>2010-07-21 08:51:29 -0700
commitabd1f4f870925d6776dbe4b930b759a1ab6595ca (patch)
tree1b86ec19a16a2a340afecfd6207b1fd8236228b9 /media/libstagefright/codecs/on2
parent3108231d90e8aa324923fd8864ca2477948c5d25 (diff)
downloadframeworks_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/on2')
-rw-r--r--media/libstagefright/codecs/on2/dec/VPXDecoder.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp b/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp
index bad8956..fbc97f4 100644
--- a/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp
+++ b/media/libstagefright/codecs/on2/dec/VPXDecoder.cpp
@@ -39,7 +39,8 @@ VPXDecoder::VPXDecoder(const sp<MediaSource> &source)
mStarted(false),
mBufferSize(0),
mCtx(NULL),
- mBufferGroup(NULL) {
+ mBufferGroup(NULL),
+ mTargetTimeUs(-1) {
sp<MetaData> inputFormat = source->getFormat();
const char *mime;
CHECK(inputFormat->findCString(kKeyMIMEType, &mime));
@@ -94,6 +95,8 @@ status_t VPXDecoder::start(MetaData *) {
mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
mBufferGroup->add_buffer(new MediaBuffer(mBufferSize));
+ mTargetTimeUs = -1;
+
mStarted = true;
return OK;
@@ -126,6 +129,13 @@ status_t VPXDecoder::read(
MediaBuffer **out, const ReadOptions *options) {
*out = NULL;
+ bool seeking = false;
+ int64_t seekTimeUs;
+ ReadOptions::SeekMode seekMode;
+ if (options && options->getSeekTo(&seekTimeUs, &seekMode)) {
+ seeking = true;
+ }
+
MediaBuffer *input;
status_t err = mSource->read(&input, options);
@@ -135,6 +145,16 @@ status_t VPXDecoder::read(
LOGV("read %d bytes from source\n", input->range_length());
+ if (seeking) {
+ int64_t targetTimeUs;
+ if (input->meta_data()->findInt64(kKeyTargetTime, &targetTimeUs)
+ && targetTimeUs >= 0) {
+ mTargetTimeUs = targetTimeUs;
+ } else {
+ mTargetTimeUs = -1;
+ }
+ }
+
if (vpx_codec_decode(
(vpx_codec_ctx_t *)mCtx,
(uint8_t *)input->data() + input->range_offset(),
@@ -156,6 +176,29 @@ status_t VPXDecoder::read(
input->release();
input = 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);
+ return OK;
+ }
+
vpx_codec_iter_t iter = NULL;
vpx_image_t *img = vpx_codec_get_frame((vpx_codec_ctx_t *)mCtx, &iter);