summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2013-08-08 18:25:28 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2013-08-20 15:30:07 -0700
commita84864deb7c36b88f104f3116552d52d1ce64045 (patch)
treea980a80acc1006418ca2dbda5433cb1ba72e94b3
parent3c59acf1280ed5cbbf45a53743ea0ff635568769 (diff)
downloadfdk-aac-a84864deb7c36b88f104f3116552d52d1ce64045.tar.gz
fdk-aac-a84864deb7c36b88f104f3116552d52d1ce64045.tar.bz2
fdk-aac-a84864deb7c36b88f104f3116552d52d1ce64045.zip
SBR header period
AAC encoder: Connect SBR and PS header repetition rate with AACENC_HEADER_PERIOD parameter of the encoder API. Bug 9428126 Change-Id: Ia1ab965de9eaa2ac229d0c395a337cbd4d20cba1
-rw-r--r--libAACenc/src/aacenc_lib.cpp7
-rw-r--r--libSBRenc/include/sbr_encoder.h4
-rw-r--r--libSBRenc/src/ps_main.cpp2
-rw-r--r--libSBRenc/src/sbr_encoder.cpp16
4 files changed, 24 insertions, 5 deletions
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index 169400a..161ed1c 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.cpp
@@ -98,7 +98,7 @@ amm-info@iis.fraunhofer.de
/* Encoder library info */
#define AACENCODER_LIB_VL0 3
#define AACENCODER_LIB_VL1 4
-#define AACENCODER_LIB_VL2 5
+#define AACENCODER_LIB_VL2 6
#define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__
@@ -122,6 +122,8 @@ amm-info@iis.fraunhofer.de
#define INPUTBUFFER_SIZE (1537+100+2048)
+#define DEFAULT_HEADER_PERIOD_REPETITION_RATE 10 /*!< Default header repetition rate used in transport library and for SBR header. */
+
////////////////////////////////////////////////////////////////////////////////////
/**
* Flags to characterize encoder modules to be supported in present instance.
@@ -335,7 +337,7 @@ void FDKaacEnc_MapConfig(CODER_CONFIG *cc, USER_PARAM *extCfg, HANDLE_AACENC_CON
case TT_MP4_ADTS:
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP1:
- cc->headerPeriod = 10;
+ cc->headerPeriod = DEFAULT_HEADER_PERIOD_REPETITION_RATE;
break;
default:
cc->headerPeriod = 0;
@@ -876,6 +878,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder,
&hAacConfig->audioObjectType,
&hAacEncoder->nDelay,
(hAacConfig->audioObjectType == AOT_ER_AAC_ELD) ? 1 : TRANS_FAC,
+ (config->userTpHeaderPeriod!=0xFF) ? config->userTpHeaderPeriod : DEFAULT_HEADER_PERIOD_REPETITION_RATE,
initFlag
);
diff --git a/libSBRenc/include/sbr_encoder.h b/libSBRenc/include/sbr_encoder.h
index 5bbc197..f8f2a5c 100644
--- a/libSBRenc/include/sbr_encoder.h
+++ b/libSBRenc/include/sbr_encoder.h
@@ -298,6 +298,9 @@ UINT sbrEncoder_LimitBitRate(UINT bitRate, UINT numChannels, UINT coreSampleRate
* \param aot Input: Desired AOT. output AOT to be used after parameter checking.
* \param delay Input: core encoder delay. Output: total delay because of SBR.
* \param transformFactor The core encoder transform factor (blockswitching).
+ * \param headerPeriod Repetition rate of the SBR header:
+ * - (-1) means intern configuration.
+ * - (1-10) corresponds to header repetition rate in frames.
* \return 0 on success, and non-zero if failed.
*/
INT sbrEncoder_Init( HANDLE_SBR_ENCODER hSbrEncoder,
@@ -312,6 +315,7 @@ INT sbrEncoder_Init( HANDLE_SBR_ENCODER hSbrEncoder,
AUDIO_OBJECT_TYPE *aot,
int *delay,
int transformFactor,
+ const int headerPeriod,
ULONG statesInitFlag
);
diff --git a/libSBRenc/src/ps_main.cpp b/libSBRenc/src/ps_main.cpp
index 7e77a90..76b759a 100644
--- a/libSBRenc/src/ps_main.cpp
+++ b/libSBRenc/src/ps_main.cpp
@@ -227,6 +227,8 @@ FDK_PSENC_ERROR PSEnc_Init(
/* clear bs buffer */
FDKmemclear(hParametricStereo->psOut, sizeof(hParametricStereo->psOut));
+ hParametricStereo->psOut[0].enablePSHeader = 1; /* write ps header in first frame */
+
/* clear scaling buffer */
FDKmemclear(hParametricStereo->dynBandScale, sizeof(UCHAR)*PS_MAX_BANDS);
FDKmemclear(hParametricStereo->maxBandValue, sizeof(FIXP_QMF)*PS_MAX_BANDS);
diff --git a/libSBRenc/src/sbr_encoder.cpp b/libSBRenc/src/sbr_encoder.cpp
index ac0c869..d7ecae5 100644
--- a/libSBRenc/src/sbr_encoder.cpp
+++ b/libSBRenc/src/sbr_encoder.cpp
@@ -103,7 +103,7 @@ amm-info@iis.fraunhofer.de
#define SBRENCODER_LIB_VL0 3
#define SBRENCODER_LIB_VL1 3
-#define SBRENCODER_LIB_VL2 1
+#define SBRENCODER_LIB_VL2 2
@@ -1462,6 +1462,7 @@ INT FDKsbrEnc_EnvInit (
AUDIO_OBJECT_TYPE aot,
int nBitstrDelay,
int nElement,
+ const int headerPeriod,
ULONG statesInitFlag
,UCHAR *dynamic_RAM
)
@@ -1521,9 +1522,16 @@ INT FDKsbrEnc_EnvInit (
hSbrElement->sbrBitstreamData.CountSendHeaderData = 0;
if (params->SendHeaderDataTime > 0 ) {
- hSbrElement->sbrBitstreamData.NrSendHeaderData = (INT)(params->SendHeaderDataTime * hSbrElement->sbrConfigData.sampleFreq
+ if (headerPeriod==-1) {
+
+ hSbrElement->sbrBitstreamData.NrSendHeaderData = (INT)(params->SendHeaderDataTime * hSbrElement->sbrConfigData.sampleFreq
/ (1000 * hSbrElement->sbrConfigData.frameSize));
- hSbrElement->sbrBitstreamData.NrSendHeaderData = fixMax(hSbrElement->sbrBitstreamData.NrSendHeaderData,1);
+ hSbrElement->sbrBitstreamData.NrSendHeaderData = fixMax(hSbrElement->sbrBitstreamData.NrSendHeaderData,1);
+ }
+ else {
+ /* assure header period at least once per second */
+ hSbrElement->sbrBitstreamData.NrSendHeaderData = fixMin(fixMax(headerPeriod,1),(hSbrElement->sbrConfigData.sampleFreq/hSbrElement->sbrConfigData.frameSize));
+ }
}
else {
hSbrElement->sbrBitstreamData.NrSendHeaderData = 0;
@@ -1723,6 +1731,7 @@ INT sbrEncoder_Init(
AUDIO_OBJECT_TYPE *aot,
int *delay,
int transformFactor,
+ const int headerPeriod,
ULONG statesInitFlag
)
{
@@ -1962,6 +1971,7 @@ INT sbrEncoder_Init(
*aot,
nBitstrDelay,
el,
+ headerPeriod,
statesInitFlag
,hSbrEncoder->dynamicRam
);