Commit 16c472c2 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi

AAC encoder metadata improvement

AAC-Encoder

   - Introduce metadata support for parametric stereo audio object type.
     Write metadata matrix mixdown coefficient only for channel config 5 and 6.
     Modified file(s):
        libAACenc/src/aacenc_lib.cpp

   - Revise metadata encoder downmix gain and fix matrix mixdown coefficient.
     Modified file(s):
        libAACenc/src/aacenc_lib.cpp
        libAACenc/src/metadata_compressor.cpp
        libMpegTPEnc/src/tpenc_asc.cpp
        libMpegTPEnc/src/tpenc_lib.cpp
        libMpegTPEnc/src/version

Bug 9428126

Change-Id: I87f5f1a1fdddd8223187aa0f9dc733e0ecc3e7e4
parent a84864de
...@@ -98,7 +98,7 @@ amm-info@iis.fraunhofer.de ...@@ -98,7 +98,7 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */ /* Encoder library info */
#define AACENCODER_LIB_VL0 3 #define AACENCODER_LIB_VL0 3
#define AACENCODER_LIB_VL1 4 #define AACENCODER_LIB_VL1 4
#define AACENCODER_LIB_VL2 6 #define AACENCODER_LIB_VL2 7
#define AACENCODER_LIB_TITLE "AAC Encoder" #define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__ #define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__ #define AACENCODER_LIB_BUILD_TIME __TIME__
...@@ -759,6 +759,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, ...@@ -759,6 +759,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
/* Allow metadata support */ /* Allow metadata support */
case AOT_AAC_LC: case AOT_AAC_LC:
case AOT_SBR: case AOT_SBR:
case AOT_PS:
hAacEncoder->metaDataAllowed = 1; hAacEncoder->metaDataAllowed = 1;
if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) { if (((INT)hAacConfig->channelMode < 1) || ((INT)hAacConfig->channelMode > 7)) {
config->userMetaDataMode = 0; config->userMetaDataMode = 0;
...@@ -1337,8 +1338,12 @@ AACENC_ERROR aacEncEncode( ...@@ -1337,8 +1338,12 @@ AACENC_ERROR aacEncEncode(
for (i=0; i<(INT)nMetaDataExtensions; i++) { /* Get meta data extension payload. */ for (i=0; i<(INT)nMetaDataExtensions; i++) { /* Get meta data extension payload. */
hAacEncoder->extPayload[nExtensions++] = pMetaDataExtPayload[i]; hAacEncoder->extPayload[nExtensions++] = pMetaDataExtPayload[i];
} }
if (matrix_mixdown_idx!=-1) { /* Set matrix mixdown coefficient. */
UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x2)<<1) | 1 ); if ( (matrix_mixdown_idx!=-1)
&& ((hAacEncoder->extParam.userChannelMode==MODE_1_2_2)||(hAacEncoder->extParam.userChannelMode==MODE_1_2_2_1)) )
{
/* Set matrix mixdown coefficient. */
UINT pceValue = (UINT)( (1<<3) | ((matrix_mixdown_idx&0x3)<<1) | 1 );
if (hAacEncoder->extParam.userPceAdditions != pceValue) { if (hAacEncoder->extParam.userPceAdditions != pceValue) {
hAacEncoder->extParam.userPceAdditions = pceValue; hAacEncoder->extParam.userPceAdditions = pceValue;
hAacEncoder->InitFlags |= AACENC_INIT_TRANSPORT; hAacEncoder->InitFlags |= AACENC_INIT_TRANSPORT;
......
...@@ -421,7 +421,7 @@ static FIXP_DBL tc2Coeff( ...@@ -421,7 +421,7 @@ static FIXP_DBL tc2Coeff(
result = f2Pow(-exponent, DFRACT_BITS-1-METADATA_FRACT_BITS, &e_res); result = f2Pow(-exponent, DFRACT_BITS-1-METADATA_FRACT_BITS, &e_res);
/* result = 1.0 - exp(-1.0/((t) * (f))) */ /* result = 1.0 - exp(-1.0/((t) * (f))) */
result = FL2FXCONST_DBL(1.0f) - scaleValue(result, e_res); result = (FIXP_DBL)MAXVAL_DBL - scaleValue(result, e_res);
return result; return result;
} }
...@@ -832,12 +832,12 @@ INT FDK_DRC_Generator_Calc( ...@@ -832,12 +832,12 @@ INT FDK_DRC_Generator_Calc(
FIXP_DBL accu; FIXP_DBL accu;
/* drcComp->smoothLevel[i] = (1-alpha) * drcComp->smoothLevel[i] + alpha * level; */ /* drcComp->smoothLevel[i] = (1-alpha) * drcComp->smoothLevel[i] + alpha * level; */
accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothLevel[i]); accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothLevel[i]);
accu += fMult(alpha,level); accu += fMult(alpha,level);
drcComp->smoothLevel[i] = accu; drcComp->smoothLevel[i] = accu;
/* drcComp->smoothGain[i] = (1-alpha) * drcComp->smoothGain[i] + alpha * gain; */ /* drcComp->smoothGain[i] = (1-alpha) * drcComp->smoothGain[i] + alpha * gain; */
accu = fMult((FL2FXCONST_DBL(1.f)-alpha), drcComp->smoothGain[i]); accu = fMult(((FIXP_DBL)MAXVAL_DBL-alpha), drcComp->smoothGain[i]);
accu += fMult(alpha,gain); accu += fMult(alpha,gain);
drcComp->smoothGain[i] = accu; drcComp->smoothGain[i] = accu;
} }
...@@ -941,7 +941,7 @@ INT FDK_DRC_Generator_Calc( ...@@ -941,7 +941,7 @@ INT FDK_DRC_Generator_Calc(
if ((drcComp->channelIdx[LS] >= 0) && (drcComp->channelIdx[LS2] >= 0)) tmp = fMult(FL2FXCONST_DBL(0.707f), tmp); /* 7.1ch */ if ((drcComp->channelIdx[LS] >= 0) && (drcComp->channelIdx[LS2] >= 0)) tmp = fMult(FL2FXCONST_DBL(0.707f), tmp); /* 7.1ch */
/*if ((drcComp->channelIdx[RS] >= 0) && (drcComp->channelIdx[RS2] >= 0)) tmp *=0.707f;*/ /* 7.1ch */ /*if ((drcComp->channelIdx[RS] >= 0) && (drcComp->channelIdx[RS2] >= 0)) tmp *=0.707f;*/ /* 7.1ch */
if (drcComp->channelIdx[S] >= 0) tmp += fMultDiv2(slev, fMult(FL2FXCONST_DBL(0.7f), (FIXP_PCM)pSamples[drcComp->channelIdx[S]]))>>(DOWNMIX_SHIFT-1); /* S */ if (drcComp->channelIdx[S] >= 0) tmp += fMultDiv2(slev, fMult(FL2FXCONST_DBL(0.7f), (FIXP_PCM)pSamples[drcComp->channelIdx[S]]))>>(DOWNMIX_SHIFT-1); /* S */
if (drcComp->channelIdx[C] >= 0) tmp += fMultDiv2(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C */ if (drcComp->channelIdx[C] >= 0) tmp += fMult(clev, (FIXP_PCM)pSamples[drcComp->channelIdx[C]])>>(DOWNMIX_SHIFT-1); /* C (2*clev) */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[L]])>>DOWNMIX_SHIFT); /* L */ tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[L]])>>DOWNMIX_SHIFT); /* L */
tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[R]])>>DOWNMIX_SHIFT); /* R */ tmp += (FX_PCM2FX_DBL((FIXP_PCM)pSamples[drcComp->channelIdx[R]])>>DOWNMIX_SHIFT); /* R */
...@@ -973,7 +973,7 @@ INT FDK_DRC_Generator_Calc( ...@@ -973,7 +973,7 @@ INT FDK_DRC_Generator_Calc(
* + 0.2f*2^(-METADATA_FRACT_BITS) + drcComp->smoothGain[i] * + 0.2f*2^(-METADATA_FRACT_BITS) + drcComp->smoothGain[i]
*/ */
peak[i] = fMult((FIXP_DBL)(10<<(METADATA_FRACT_BITS+LD_DATA_SHIFT)), fMult( FL2FX_DBL(2*0.30102999566398119521373889472449f), ld_peak)); peak[i] = fMult((FIXP_DBL)(10<<(METADATA_FRACT_BITS+LD_DATA_SHIFT)), fMult( FL2FX_DBL(2*0.30102999566398119521373889472449f), ld_peak));
peak[i] += (FL2FX_DBL(0.2f)>>METADATA_INT_BITS); /* add a little bit headroom */ peak[i] += (FL2FX_DBL(0.5f)>>METADATA_INT_BITS); /* add a little bit headroom */
peak[i] += drcComp->smoothGain[i]; peak[i] += drcComp->smoothGain[i];
} }
......
...@@ -255,7 +255,7 @@ int transportEnc_writePCE(HANDLE_FDK_BITSTREAM hBs, ...@@ -255,7 +255,7 @@ int transportEnc_writePCE(HANDLE_FDK_BITSTREAM hBs,
if ( matrixMixdownA!=0 && ((channelMode==MODE_1_2_2)||(channelMode==MODE_1_2_2_1)) ) { if ( matrixMixdownA!=0 && ((channelMode==MODE_1_2_2)||(channelMode==MODE_1_2_2_1)) ) {
FDKwriteBits(hBs, 1, 1); /* Matrix mixdown present */ FDKwriteBits(hBs, 1, 1); /* Matrix mixdown present */
FDKwriteBits(hBs, (matrixMixdownA-1)&0x3, 2); /* matrix_mixdown_idx */ FDKwriteBits(hBs, (matrixMixdownA-1)&0x3, 2); /* matrix_mixdown_idx */
FDKwriteBits(hBs, pseudoSurroundEnable&0x1, 1); /* pseudo_surround_enable */ FDKwriteBits(hBs, (pseudoSurroundEnable)?1:0, 1); /* pseudo_surround_enable */
} }
else { else {
FDKwriteBits(hBs, 0, 1); /* Matrix mixdown not present */ FDKwriteBits(hBs, 0, 1); /* Matrix mixdown not present */
...@@ -379,7 +379,7 @@ int transportEnc_writeGASpecificConfig( ...@@ -379,7 +379,7 @@ int transportEnc_writeGASpecificConfig(
/* Write PCE if channel config is not 1-7 */ /* Write PCE if channel config is not 1-7 */
if (getChannelConfig(config->channelMode) == 0) { if (getChannelConfig(config->channelMode) == 0) {
transportEnc_writePCE(asc, config->channelMode, config->samplingRate, 0, 1, 0, 0, alignAnchor); transportEnc_writePCE(asc, config->channelMode, config->samplingRate, 0, 1, config->matrixMixdownA, (config->flags&CC_PSEUDO_SURROUND)?1:0, alignAnchor);
} }
if (extFlg) { if (extFlg) {
if (aot == AOT_ER_BSAC) { if (aot == AOT_ER_BSAC) {
......
...@@ -150,12 +150,18 @@ C_ALLOC_MEM(Ram_TransportEncoder, TRANSPORTENC, 1) ...@@ -150,12 +150,18 @@ C_ALLOC_MEM(Ram_TransportEncoder, TRANSPORTENC, 1)
TRANSPORTENC_ERROR transportEnc_Open( HANDLE_TRANSPORTENC *phTpEnc ) TRANSPORTENC_ERROR transportEnc_Open( HANDLE_TRANSPORTENC *phTpEnc )
{ {
HANDLE_TRANSPORTENC hTpEnc = GetRam_TransportEncoder(0); HANDLE_TRANSPORTENC hTpEnc;
if ( hTpEnc == NULL ) { if ( phTpEnc == NULL ){
return TRANSPORTENC_INVALID_PARAMETER; return TRANSPORTENC_INVALID_PARAMETER;
} }
hTpEnc = GetRam_TransportEncoder(0);
if ( hTpEnc == NULL ) {
return TRANSPORTENC_NO_MEM;
}
*phTpEnc = hTpEnc; *phTpEnc = hTpEnc;
return TRANSPORTENC_OK; return TRANSPORTENC_OK;
} }
...@@ -417,7 +423,7 @@ TRANSPORTENC_ERROR transportEnc_WriteAccessUnit( ...@@ -417,7 +423,7 @@ TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(
} }
/* Write PCE as first raw_data_block element */ /* Write PCE as first raw_data_block element */
transportEnc_writePCE(&hTp->bitStream, hTp->config.channelMode, hTp->config.samplingRate, 0, 1, hTp->config.matrixMixdownA, hTp->config.flags & CC_PSEUDO_SURROUND, alignAnchor); transportEnc_writePCE(&hTp->bitStream, hTp->config.channelMode, hTp->config.samplingRate, 0, 1, hTp->config.matrixMixdownA, (hTp->config.flags&CC_PSEUDO_SURROUND)?1:0, alignAnchor);
if ( (hTp->transportFmt==TT_MP4_ADTS) && !hTp->writer.adts.protection_absent) { if ( (hTp->transportFmt==TT_MP4_ADTS) && !hTp->writer.adts.protection_absent) {
adtsWrite_CrcEndReg(&hTp->writer.adts, &hTp->bitStream, crcIndex); adtsWrite_CrcEndReg(&hTp->writer.adts, &hTp->bitStream, crcIndex);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* library info */ /* library info */
#define TP_LIB_VL0 2 #define TP_LIB_VL0 2
#define TP_LIB_VL1 3 #define TP_LIB_VL1 3
#define TP_LIB_VL2 0 #define TP_LIB_VL2 1
#define TP_LIB_TITLE "MPEG Transport" #define TP_LIB_TITLE "MPEG Transport"
#define TP_LIB_BUILD_DATE __DATE__ #define TP_LIB_BUILD_DATE __DATE__
#define TP_LIB_BUILD_TIME __TIME__ #define TP_LIB_BUILD_TIME __TIME__
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment