summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/aacdec
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2009-12-07 16:32:37 -0800
committerAndreas Huber <andih@google.com>2009-12-07 16:41:16 -0800
commitebd0d94d2619280f9871ef2d0965d95fb880404c (patch)
tree8b71343070a2b78cb24de0751c093bbdbbd0392c /media/libstagefright/codecs/aacdec
parentd9618f23226f46c752e56f712bc4b505117d8b4b (diff)
downloadframeworks_av-ebd0d94d2619280f9871ef2d0965d95fb880404c.zip
frameworks_av-ebd0d94d2619280f9871ef2d0965d95fb880404c.tar.gz
frameworks_av-ebd0d94d2619280f9871ef2d0965d95fb880404c.tar.bz2
Minor tweaks to the mp3 and aac software decoders, propagate duration to output format.
Diffstat (limited to 'media/libstagefright/codecs/aacdec')
-rw-r--r--media/libstagefright/codecs/aacdec/AACDecoder.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
index 03ac88d..5c77a3a 100644
--- a/media/libstagefright/codecs/aacdec/AACDecoder.cpp
+++ b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
@@ -17,7 +17,7 @@ AACDecoder::AACDecoder(const sp<MediaSource> &source)
mBufferGroup(NULL),
mConfig(new tPVMP4AudioDecoderExternal),
mDecoderBuf(NULL),
- mLastSeekTimeUs(0),
+ mAnchorTimeUs(0),
mNumSamplesOutput(0),
mInputBuffer(NULL) {
}
@@ -79,7 +79,7 @@ status_t AACDecoder::start(MetaData *params) {
mSource->start();
- mLastSeekTimeUs = 0;
+ mAnchorTimeUs = 0;
mNumSamplesOutput = 0;
mStarted = true;
@@ -112,13 +112,16 @@ sp<MetaData> AACDecoder::getFormat() {
int32_t numChannels;
int32_t sampleRate;
+ int64_t durationUs;
CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
+ CHECK(srcFormat->findInt64(kKeyDuration, &durationUs));
sp<MetaData> meta = new MetaData;
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
meta->setInt32(kKeyChannelCount, numChannels);
meta->setInt32(kKeySampleRate, sampleRate);
+ meta->setInt64(kKeyDuration, durationUs);
return meta;
}
@@ -150,11 +153,13 @@ status_t AACDecoder::read(
return err;
}
- if (seekTimeUs >= 0) {
- CHECK(mInputBuffer->meta_data()->findInt64(
- kKeyTime, &mLastSeekTimeUs));
-
+ int64_t timeUs;
+ if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
+ mAnchorTimeUs = timeUs;
mNumSamplesOutput = 0;
+ } else {
+ // We must have a new timestamp after seeking.
+ CHECK(seekTimeUs < 0);
}
}
@@ -189,7 +194,7 @@ status_t AACDecoder::read(
buffer->meta_data()->setInt64(
kKeyTime,
- mLastSeekTimeUs
+ mAnchorTimeUs
+ (mNumSamplesOutput * 1000000) / mConfig->samplingRate);
mNumSamplesOutput += mConfig->frameLength;