diff options
author | Gloria Wang <gwang@google.com> | 2011-02-02 14:12:49 -0800 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2011-02-15 17:16:22 -0800 |
commit | 50c44c79d2d7dd6cd1485d9d939f67f80b8da1ca (patch) | |
tree | 61d66fea96dd44389fc80833c7d033b696c9b000 /media/libstagefright/avc_utils.cpp | |
parent | 727a6f859841a1d421b680f56d4d4ca5ff8c6e4b (diff) | |
download | frameworks_av-50c44c79d2d7dd6cd1485d9d939f67f80b8da1ca.zip frameworks_av-50c44c79d2d7dd6cd1485d9d939f67f80b8da1ca.tar.gz frameworks_av-50c44c79d2d7dd6cd1485d9d939f67f80b8da1ca.tar.bz2 |
Add AAC extractor
Change-Id: Iedb08525ac72e65ba98e5c791734da0720a0e3f6
Diffstat (limited to 'media/libstagefright/avc_utils.cpp')
-rw-r--r-- | media/libstagefright/avc_utils.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index fa12cf0..95cf2d3 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -329,5 +329,52 @@ bool IsIDR(const sp<ABuffer> &buffer) { return foundIDR; } +sp<MetaData> MakeAACCodecSpecificData( + unsigned profile, unsigned sampling_freq_index, + unsigned channel_configuration) { + sp<MetaData> meta = new MetaData; + meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC); + + CHECK_LE(sampling_freq_index, 11u); + static const int32_t kSamplingFreq[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, + 16000, 12000, 11025, 8000 + }; + meta->setInt32(kKeySampleRate, kSamplingFreq[sampling_freq_index]); + meta->setInt32(kKeyChannelCount, channel_configuration); + + static const uint8_t kStaticESDS[] = { + 0x03, 22, + 0x00, 0x00, // ES_ID + 0x00, // streamDependenceFlag, URL_Flag, OCRstreamFlag + + 0x04, 17, + 0x40, // Audio ISO/IEC 14496-3 + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + + 0x05, 2, + // AudioSpecificInfo follows + + // oooo offf fccc c000 + // o - audioObjectType + // f - samplingFreqIndex + // c - channelConfig + }; + sp<ABuffer> csd = new ABuffer(sizeof(kStaticESDS) + 2); + memcpy(csd->data(), kStaticESDS, sizeof(kStaticESDS)); + + csd->data()[sizeof(kStaticESDS)] = + ((profile + 1) << 3) | (sampling_freq_index >> 1); + + csd->data()[sizeof(kStaticESDS) + 1] = + ((sampling_freq_index << 7) & 0x80) | (channel_configuration << 3); + + meta->setData(kKeyESDS, 0, csd->data(), csd->size()); + + return meta; +} + } // namespace android |