[PORT FROM MAIN] Movie studio: enhance the HE-AAC profile support
BZ: 59776
It's an android original defect, enhance the HE-AAC profile support in Movie studio.
Change-Id: I5ae9e51811ca4f41f20f34d13bad33e0bf9279f7
Signed-off-by: Gu, Wangyi <wangyi.gu@intel.com>
Reviewed-on: http://android.intel.com:8080/76962
Tested-by: Tong, BoX <box.tong@intel.com>
Reviewed-by: Tong, BoX <box.tong@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/frameworks/videoedit/stagefrightshells/VideoEditorAudioDecoder.cpp b/frameworks/videoedit/stagefrightshells/VideoEditorAudioDecoder.cpp
index 2c5510d..2e8c5d1 100644
--- a/frameworks/videoedit/stagefrightshells/VideoEditorAudioDecoder.cpp
+++ b/frameworks/videoedit/stagefrightshells/VideoEditorAudioDecoder.cpp
@@ -349,6 +349,7 @@
M4OSA_ERR err = M4NO_ERROR;
M4OSA_UInt32 offset = 0;
M4OSA_Int32 result = 0;
+ M4OSA_Int32 extensionAudioObjectType = 0;
ALOGV("VideoEditorAudioDecoder_parse_AAC_DSI begin");
@@ -386,6 +387,11 @@
// Get the frequency index
err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 4, &result, &offset);
VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result == 0x0f) {
+ // Get the frequency index again
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 24, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ }
VIDEOEDITOR_CHECK((0 <= result) && (FREQ_TABLE_SIZE > result),
M4ERR_PARAMETER);
pProperties->aSampFreq = AD_AAC_FREQ_TABLE[result];
@@ -396,6 +402,76 @@
VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
pProperties->aNumChan = (M4OSA_UInt32)result;
+ if (pProperties->aAudioObjectType == 5) {
+ extensionAudioObjectType = pProperties->aAudioObjectType;
+ // Get extension sampling frequency index
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 4, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result == 0x0f) {
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 24, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ }
+ VIDEOEDITOR_CHECK((0 <= result) && (FREQ_TABLE_SIZE > result),
+ M4ERR_PARAMETER);
+ pProperties->aExtensionSampFreq = AD_AAC_FREQ_TABLE[result];
+ // Get the object type again
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 5, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ pProperties->aAudioObjectType = (M4OSA_Int32)result;
+ }
+
+ // It's for implicit signal the presence of SBR data with AAC-LC audio object type(AOT = 2)
+ if (pProperties->aAudioObjectType == 2) { /* parseGASpecificConfig begin*/
+ // Get frame length flag
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ // Get depends on core coder
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result) {
+ // Get core coder delay
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ }
+ // Get extension flag
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result) {
+ // Get extension flag3
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ }
+ }/* parseGASpecificConfig end*/
+
+ if (extensionAudioObjectType != 5 && (dsiSize*8 - offset) >= 16) {
+ // get sync extension type
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 11, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result == 0x2b7) {
+ ALOGV("found syncExtension");
+ // Get extension Audio Object Type
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 5, &extensionAudioObjectType, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ // get SBR present flag
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 1, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ pProperties->aSBRPresent = result;
+ if (result == 1) {
+ // Get extension sampling frequency index
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 4, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ if (result == 0x0f) {
+ // Get extension sampling frequency index again
+ err = VideoEditorAudioDecoder_getBits(pDSI, dsiSize, 24, &result, &offset);
+ VIDEOEDITOR_CHECK(M4NO_ERROR == err, err);
+ }
+ VIDEOEDITOR_CHECK((0 <= result) && (FREQ_TABLE_SIZE > result),
+ M4ERR_PARAMETER);
+ pProperties->aExtensionSampFreq = AD_AAC_FREQ_TABLE[result];
+ }
+ }
+ }
+
// Set the max PCM samples per channel
pProperties->aMaxPCMSamplesPerCh = (pProperties->aSBRPresent) ? 2048 : 1024;