summaryrefslogtreecommitdiffstats
path: root/libAACenc/src/aacenc_lib.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libAACenc/src/aacenc_lib.cpp')
-rw-r--r--libAACenc/src/aacenc_lib.cpp103
1 files changed, 92 insertions, 11 deletions
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index fc58d6d..1ea9a5c 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -87,7 +87,7 @@ amm-info@iis.fraunhofer.de
contents/description: FDK HE-AAC Encoder interface library functions
****************************************************************************/
-
+#include <stdio.h>
#include "aacenc_lib.h"
#include "FDK_audio.h"
#include "aacenc.h"
@@ -327,7 +327,8 @@ static inline INT isSbrActive(const HANDLE_AACENC_CONFIG hAacConfig)
{
INT sbrUsed = 0;
- if ( (hAacConfig->audioObjectType==AOT_SBR) || (hAacConfig->audioObjectType==AOT_PS) )
+ if ( (hAacConfig->audioObjectType==AOT_SBR) || (hAacConfig->audioObjectType==AOT_PS)
+ || (hAacConfig->audioObjectType==AOT_DABPLUS_SBR) || (hAacConfig->audioObjectType==AOT_DABPLUS_PS) )
{
sbrUsed = 1;
}
@@ -343,7 +344,8 @@ static inline INT isPsActive(const AUDIO_OBJECT_TYPE audioObjectType)
{
INT psUsed = 0;
- if ( (audioObjectType==AOT_PS) )
+ if ( (audioObjectType==AOT_PS)
+ || (audioObjectType==AOT_DABPLUS_PS) )
{
psUsed = 1;
}
@@ -368,7 +370,8 @@ static SBR_PS_SIGNALING getSbrSignalingMode(
sbrSignaling = SIG_IMPLICIT; /* default: implicit signaling */
}
- if ( (audioObjectType==AOT_AAC_LC) || (audioObjectType==AOT_SBR) || (audioObjectType==AOT_PS) ) {
+ if ((audioObjectType==AOT_AAC_LC) || (audioObjectType==AOT_SBR) || (audioObjectType==AOT_PS) ||
+ (audioObjectType==AOT_DABPLUS_SBR) || (audioObjectType==AOT_DABPLUS_PS) ) {
switch (transportType) {
case TT_MP4_ADIF:
case TT_MP4_ADTS:
@@ -424,7 +427,22 @@ static void FDKaacEnc_MapConfig(
cc->flags = 0;
- transport_AOT = hAacConfig->audioObjectType;
+ /* Map virtual aot to transport aot. */
+ switch (hAacConfig->audioObjectType) {
+ case AOT_DABPLUS_AAC_LC:
+ transport_AOT = AOT_AAC_LC;
+ break;
+ case AOT_DABPLUS_SBR:
+ transport_AOT = AOT_SBR;
+ cc->flags |= CC_SBR;
+ break;
+ case AOT_DABPLUS_PS:
+ transport_AOT = AOT_PS;
+ cc->flags |= CC_SBR;
+ break;
+ default:
+ transport_AOT = hAacConfig->audioObjectType;
+ }
if (hAacConfig->audioObjectType == AOT_ER_AAC_ELD) {
cc->flags |= (hAacConfig->syntaxFlags & AC_SBR_PRESENT) ? CC_SBR : 0;
@@ -465,9 +483,27 @@ static void FDKaacEnc_MapConfig(
cc->flags |= CC_IS_BASELAYER;
cc->channelMode = hAacConfig->channelMode;
- cc->nSubFrames = (hAacConfig->nSubFrames > 1 && extCfg->userTpNsubFrames == 1)
+ if(extCfg->userTpType == TT_DABPLUS && hAacConfig->nSubFrames==1) {
+ switch(hAacConfig->sampleRate) {
+ case 48000:
+ cc->nSubFrames=6;
+ break;
+ case 32000:
+ cc->nSubFrames=4;
+ break;
+ case 24000:
+ cc->nSubFrames=3;
+ break;
+ case 16000:
+ cc->nSubFrames=2;
+ break;
+ }
+ //fprintf(stderr, "hAacConfig->nSubFrames=%d hAacConfig->sampleRate=%d\n", hAacConfig->nSubFrames, hAacConfig->sampleRate);
+ } else {
+ cc->nSubFrames = (hAacConfig->nSubFrames > 1 && extCfg->userTpNsubFrames == 1)
? hAacConfig->nSubFrames
: extCfg->userTpNsubFrames;
+ }
cc->flags |= (extCfg->userTpProtection) ? CC_PROTECTION : 0;
@@ -724,6 +760,7 @@ INT aacEncoder_LimitBitrate(
FDK_ASSERT(bitRate > 0);
+ //fprintf(stderr, "aacEncoder_LimitBitrate(): bitRate=%d\n", bitRate);
return bitRate;
}
@@ -734,7 +771,7 @@ INT aacEncoder_LimitBitrate(
*
* \hAacEncoder Internal encoder config which is to be updated
* \param config User provided config (public struct)
- * \return ´returns always AAC_ENC_OK
+ * \return �returns always AAC_ENC_OK
*/
static
AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
@@ -777,10 +814,36 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
case AOT_PS:
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_ADTS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
- if (hAacConfig->framelength != 1024) {
+ if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
return AACENC_INVALID_CONFIG;
}
break;
+ case AOT_DABPLUS_SBR:
+ case AOT_DABPLUS_PS:
+ hAacConfig->syntaxFlags |= ((config->userSbrEnabled) ? AC_SBR_PRESENT : 0);
+ case AOT_DABPLUS_AAC_LC:
+ config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_DABPLUS;
+ hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 960;
+ if (hAacConfig->framelength != 960) {
+ return AACENC_INVALID_CONFIG;
+ }
+ config->userTpSignaling=2;
+ if(config->userTpType == TT_DABPLUS)
+ hAacConfig->syntaxFlags |= AC_DAB;
+ break;
+#if 0
+ case AOT_ER_AAC_LC:
+ hAacConfig->epConfig = 0;
+ hAacConfig->syntaxFlags |= AC_ER;
+ hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
+ hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
+ config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
+ hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
+ if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
+ return AACENC_INVALID_CONFIG;
+ }
+ break;
+#endif
case AOT_ER_AAC_LD:
hAacConfig->epConfig = 0;
hAacConfig->syntaxFlags |= AC_ER|AC_LD;
@@ -810,6 +873,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
break;
}
+
switch ( hAacConfig->audioObjectType ) {
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
@@ -927,6 +991,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
+ //fprintf(stderr, "config->userBitrate=%d\n", config->userBitrate);
/* We need the frame length to call aacEncoder_LimitBitrate() */
hAacConfig->bitRate = aacEncoder_LimitBitrate(
NULL,
@@ -940,6 +1005,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacConfig->sbrRatio,
hAacConfig->audioObjectType
);
+ //fprintf(stderr, "hAacConfig->bitRate=%d\n", hAacConfig->bitRate);
/* Configure PNS */
if ( ((hAacConfig->bitrateMode>=1) && (hAacConfig->bitrateMode<=5)) /* VBR without PNS. */
@@ -984,6 +1050,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
hAacEncoder->metaDataAllowed = 0;
}
+ //fprintf(stderr, "hAacEncoder->metaDataAllowed=%d\n", hAacEncoder->metaDataAllowed);
return err;
}
@@ -1294,8 +1361,10 @@ AACENC_ERROR aacEncOpen(
}
{ /* Get bitstream outputbuffer size */
+ UINT buffer_bytes_min = (hAacEncoder->nMaxSubFrames*hAacEncoder->nMaxAacChannels*6144)>>3;
+ buffer_bytes_min = fixMax(buffer_bytes_min, (UINT) (24 * 110)); // consider maximum DAB+ Superframe size
UINT ld_M;
- for (ld_M=1; (UINT)(1<<ld_M) < (hAacEncoder->nMaxSubFrames*hAacEncoder->nMaxAacChannels*6144)>>3; ld_M++) ;
+ for (ld_M=1; (UINT)(1<<ld_M) < buffer_bytes_min; ld_M++) ;
hAacEncoder->outBufferInBytes = (1<<ld_M); /* buffer has to be 2^n */
}
hAacEncoder->outBuffer = GetRam_bsOutbuffer();
@@ -1744,6 +1813,7 @@ AACENC_ERROR aacEncGetLibInfo(LIB_INFO *info)
/* Capability flags */
info[i].flags = 0
| CAPF_AAC_1024 | CAPF_AAC_LC
+ | CAPF_AAC_960
| CAPF_AAC_512
| CAPF_AAC_480
| CAPF_AAC_DRC
@@ -1776,16 +1846,20 @@ AACENC_ERROR aacEncoder_SetParam(
/* check if AOT matches the allocated modules */
switch ( value ) {
case AOT_PS:
+ case AOT_DRM_SBR: // Added mfeilen
+ case AOT_DABPLUS_PS:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_PS))) {
err = AACENC_INVALID_CONFIG;
goto bail;
}
case AOT_SBR:
+ case AOT_DABPLUS_SBR:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_SBR))) {
err = AACENC_INVALID_CONFIG;
goto bail;
}
case AOT_AAC_LC:
+ case AOT_DABPLUS_AAC_LC:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_AAC))) {
@@ -1811,7 +1885,12 @@ AACENC_ERROR aacEncoder_SetParam(
if (settings->userBitrateMode != value) {
switch ( value ) {
case 0:
- case 1: case 2: case 3: case 4: case 5:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 7:
case 8:
settings->userBitrateMode = value;
hAacEncoder->InitFlags |= AACENC_INIT_CONFIG | AACENC_INIT_TRANSPORT;
@@ -1888,6 +1967,7 @@ AACENC_ERROR aacEncoder_SetParam(
if (settings->userFramelength != value) {
switch (value) {
case 1024:
+ case 960:
case 512:
case 480:
settings->userFramelength = value;
@@ -1927,6 +2007,7 @@ AACENC_ERROR aacEncoder_SetParam(
|| ((type==TT_MP4_LATM_MCP1) && ((flags&CAPF_LATM) && (flags&CAPF_RAWPACKETS)))
|| ((type==TT_MP4_LOAS) && (flags&CAPF_LOAS))
|| ((type==TT_MP4_RAW) && (flags&CAPF_RAWPACKETS))
+ || ((type==TT_DABPLUS) && ((flags&CAPF_DAB_AAC) && (flags&CAPF_RAWPACKETS)))
) )
{
err = AACENC_INVALID_CONFIG;
@@ -1974,7 +2055,7 @@ AACENC_ERROR aacEncoder_SetParam(
break;
case AACENC_TPSUBFRAMES:
if (settings->userTpNsubFrames != value) {
- if (! ( (value>=1) && (value<=4) ) ) {
+ if (! ( (value>=1) && (value<=6) ) ) {
err = AACENC_INVALID_CONFIG;
break;
}