summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/avc
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2009-12-14 10:53:00 -0800
committerAndreas Huber <andih@google.com>2009-12-14 10:54:10 -0800
commitb5ae1c8712ee74ae30a115b80ecde9990bdb9a9f (patch)
treed81d84056cdf3becc3e7a764837cbcce32db87f6 /media/libstagefright/codecs/avc
parentb6ddc7ae3507f0e1ea9a76c76f829bc8b26a292c (diff)
downloadframeworks_base-b5ae1c8712ee74ae30a115b80ecde9990bdb9a9f.zip
frameworks_base-b5ae1c8712ee74ae30a115b80ecde9990bdb9a9f.tar.gz
frameworks_base-b5ae1c8712ee74ae30a115b80ecde9990bdb9a9f.tar.bz2
The software AVCDecoder now properly seeks as requested.
Diffstat (limited to 'media/libstagefright/codecs/avc')
-rw-r--r--media/libstagefright/codecs/avc/dec/AVCDecoder.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
index 7e18c1f..484c742 100644
--- a/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
+++ b/media/libstagefright/codecs/avc/dec/AVCDecoder.cpp
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "AVCDecoder"
+#include <utils/Log.h>
+
#include "AVCDecoder.h"
#include "avcdec_api.h"
@@ -44,7 +48,8 @@ AVCDecoder::AVCDecoder(const sp<MediaSource> &source)
mHandle(new tagAVCHandle),
mInputBuffer(NULL),
mAnchorTimeUs(0),
- mNumSamplesOutput(0) {
+ mNumSamplesOutput(0),
+ mPendingSeekTimeUs(-1) {
memset(mHandle, 0, sizeof(tagAVCHandle));
mHandle->AVCObject = NULL;
mHandle->userData = this;
@@ -152,6 +157,7 @@ status_t AVCDecoder::start(MetaData *) {
mAnchorTimeUs = 0;
mNumSamplesOutput = 0;
+ mPendingSeekTimeUs = -1;
mStarted = true;
return OK;
@@ -195,6 +201,21 @@ status_t AVCDecoder::read(
MediaBuffer **out, const ReadOptions *options) {
*out = NULL;
+ int64_t seekTimeUs;
+ if (options && options->getSeekTo(&seekTimeUs)) {
+ LOGV("seek requested to %lld us (%.2f secs)", seekTimeUs, seekTimeUs / 1E6);
+
+ CHECK(seekTimeUs >= 0);
+ mPendingSeekTimeUs = seekTimeUs;
+
+ if (mInputBuffer) {
+ mInputBuffer->release();
+ mInputBuffer = NULL;
+ }
+
+ PVAVCDecReset(mHandle);
+ }
+
if (mInputBuffer == NULL) {
LOGV("fetching new input buffer.");
@@ -203,7 +224,19 @@ status_t AVCDecoder::read(
mCodecSpecificData.removeAt(0);
} else {
for (;;) {
- status_t err = mSource->read(&mInputBuffer);
+ if (mPendingSeekTimeUs >= 0) {
+ LOGV("reading data from timestamp %lld (%.2f secs)",
+ mPendingSeekTimeUs, mPendingSeekTimeUs / 1E6);
+ }
+
+ ReadOptions seekOptions;
+ if (mPendingSeekTimeUs >= 0) {
+ seekOptions.setSeekTo(mPendingSeekTimeUs);
+ mPendingSeekTimeUs = -1;
+ }
+ status_t err = mSource->read(&mInputBuffer, &seekOptions);
+ seekOptions.clearSeekTo();
+
if (err != OK) {
return err;
}