summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Android (Google) Code Review <android-gerrit@google.com> 2009-12-08 09:16:00 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2009-12-08 09:16:00 -0800
commit3f5b28679bb31b8ba8f75a2bf330ec0dc0ea14cc (patch)
treeda9564282a557af265105fa263b9994940b737a4
parentee3a2443deb39ad9ce65293c045d34b9198cc57a (diff)
parent8f658214537c08e91616a3a283f940f759b65674 (diff)
Merge change I8f658214 into eclair-mr2
* changes: Minor tweaks to the mp3 and aac software decoders, propagate duration to output format.
-rw-r--r--media/libstagefright/codecs/aacdec/AACDecoder.cpp19
-rw-r--r--media/libstagefright/codecs/mp3dec/MP3Decoder.cpp6
-rw-r--r--media/libstagefright/include/AACDecoder.h2
3 files changed, 19 insertions, 8 deletions
diff --git a/media/libstagefright/codecs/aacdec/AACDecoder.cpp b/media/libstagefright/codecs/aacdec/AACDecoder.cpp
index 03ac88dc792f..5c77a3a3e474 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;
diff --git a/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp b/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp
index 45e20dc4a300..f9193c0d9280 100644
--- a/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp
+++ b/media/libstagefright/codecs/mp3dec/MP3Decoder.cpp
@@ -78,13 +78,16 @@ sp<MetaData> MP3Decoder::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;
}
@@ -120,6 +123,9 @@ status_t MP3Decoder::read(
if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
mAnchorTimeUs = timeUs;
mNumSamplesOutput = 0;
+ } else {
+ // We must have a new timestamp after seeking.
+ CHECK(seekTimeUs < 0);
}
}
diff --git a/media/libstagefright/include/AACDecoder.h b/media/libstagefright/include/AACDecoder.h
index 303d854b9a74..f09addd2d611 100644
--- a/media/libstagefright/include/AACDecoder.h
+++ b/media/libstagefright/include/AACDecoder.h
@@ -48,7 +48,7 @@ private:
tPVMP4AudioDecoderExternal *mConfig;
void *mDecoderBuf;
- int64_t mLastSeekTimeUs;
+ int64_t mAnchorTimeUs;
int64_t mNumSamplesOutput;
MediaBuffer *mInputBuffer;