summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-04-30 12:01:57 -0700
committerAndreas Huber <andih@google.com>2012-04-30 12:01:57 -0700
commit56ad61a253a94586d946cc09ed814e7a95a40ca7 (patch)
tree1f6b074f7fd23e121f8d95c88b71a1e7ba1774f2 /media
parent83faee053cfd4251dbb591b62039f563ffdac399 (diff)
downloadframeworks_av-56ad61a253a94586d946cc09ed814e7a95a40ca7.zip
frameworks_av-56ad61a253a94586d946cc09ed814e7a95a40ca7.tar.gz
frameworks_av-56ad61a253a94586d946cc09ed814e7a95a40ca7.tar.bz2
Make the transport stream extraction code output ADTS AAC frames.
Change-Id: I145f4b1265045750f1b0425269f3ffe5fb055f61 related-to-bug: 6419102
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.cpp46
1 files changed, 12 insertions, 34 deletions
diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp
index 7fd99a8..1cab077 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.cpp
+++ b/media/libstagefright/mpeg2ts/ESQueue.cpp
@@ -305,10 +305,7 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnit() {
}
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() {
- Vector<size_t> ranges;
- Vector<size_t> frameOffsets;
- Vector<size_t> frameSizes;
- size_t auSize = 0;
+ int64_t timeUs;
size_t offset = 0;
while (offset + 7 <= mBuffer->size()) {
@@ -332,6 +329,8 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() {
mFormat = MakeAACCodecSpecificData(
profile, sampling_freq_index, channel_configuration);
+ mFormat->setInt32(kKeyIsADTS, true);
+
int32_t sampleRate;
int32_t numChannels;
CHECK(mFormat->findInt32(kKeySampleRate, &sampleRate));
@@ -367,10 +366,12 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() {
size_t headerSize = protection_absent ? 7 : 9;
- ranges.push(aac_frame_length);
- frameOffsets.push(offset + headerSize);
- frameSizes.push(aac_frame_length - headerSize);
- auSize += aac_frame_length - headerSize;
+ int64_t tmpUs = fetchTimestamp(aac_frame_length);
+ CHECK_GE(tmpUs, 0ll);
+
+ if (offset == 0) {
+ timeUs = tmpUs;
+ }
offset += aac_frame_length;
}
@@ -379,37 +380,14 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() {
return NULL;
}
- int64_t timeUs = -1;
-
- for (size_t i = 0; i < ranges.size(); ++i) {
- int64_t tmpUs = fetchTimestamp(ranges.itemAt(i));
-
- if (i == 0) {
- timeUs = tmpUs;
- }
- }
-
- sp<ABuffer> accessUnit = new ABuffer(auSize);
- size_t dstOffset = 0;
- for (size_t i = 0; i < frameOffsets.size(); ++i) {
- size_t frameOffset = frameOffsets.itemAt(i);
-
- memcpy(accessUnit->data() + dstOffset,
- mBuffer->data() + frameOffset,
- frameSizes.itemAt(i));
-
- dstOffset += frameSizes.itemAt(i);
- }
+ sp<ABuffer> accessUnit = new ABuffer(offset);
+ memcpy(accessUnit->data(), mBuffer->data(), offset);
memmove(mBuffer->data(), mBuffer->data() + offset,
mBuffer->size() - offset);
mBuffer->setRange(0, mBuffer->size() - offset);
- if (timeUs >= 0) {
- accessUnit->meta()->setInt64("timeUs", timeUs);
- } else {
- ALOGW("no time for AAC access unit");
- }
+ accessUnit->meta()->setInt64("timeUs", timeUs);
return accessUnit;
}