From 4f0d97057c5c640b25518358886f8c47da9fc052 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Thu, 8 Aug 2013 17:26:40 -0700 Subject: Disclaimer update, lib version increment - Update disclaimer in all source files. - Increment library version in each FDK sub-module. Bug 9428126 Change-Id: I490b96d4ee472246b01483202b0bb4f1e9c2a5d7 --- libAACenc/src/interface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libAACenc/src/interface.h') diff --git a/libAACenc/src/interface.h b/libAACenc/src/interface.h index a1c3a96..177ddbf 100644 --- a/libAACenc/src/interface.h +++ b/libAACenc/src/interface.h @@ -2,7 +2,7 @@ /* ----------------------------------------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. +© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION -- cgit v1.2.3 From 7ad97579f8ccb843afdb5b184c4b209253839fe3 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Wed, 28 Aug 2013 17:54:51 -0700 Subject: AAC Encoder low delay quality * AAC-Encoder - Revise bit distribution for lowdelay configuration to improve encoder audio quality. - Adjust lowdelay bitreservoir for low bitreservoir configuration. Modified file(s): libAACenc\src\aacEnc_ram.cpp libAACenc\src\aacenc.cpp libAACenc\src\aacenc_lib.cpp libAACenc\src\aacenc_tns.cpp libAACenc\src\adj_thr.cpp libAACenc\src\adj_thr.h libAACenc\src\block_switch.cpp libAACenc\src\block_switch.h libAACenc\src\interface.h libAACenc\src\psy_main.cpp libAACenc\src\qc_data.h libAACenc\src\qc_main.cpp * FDK-Library - Increase the accuracy in CalcInvLdData() calculation which improves the encoder audio quality. Modified file(s): libFDK\src\fixpoint_math.cpp Bug 9428126 Change-Id: I302d7f4c3aeccf79e1b85f20e18a31e6e2b10544 --- libAACenc/src/aacEnc_ram.cpp | 6 +- libAACenc/src/aacenc.cpp | 2 + libAACenc/src/aacenc_lib.cpp | 4 +- libAACenc/src/aacenc_tns.cpp | 2 +- libAACenc/src/adj_thr.cpp | 565 +++++++++++++++++++++++++++++++---------- libAACenc/src/adj_thr.h | 23 +- libAACenc/src/block_switch.cpp | 34 +-- libAACenc/src/block_switch.h | 3 +- libAACenc/src/interface.h | 6 + libAACenc/src/psy_main.cpp | 19 +- libAACenc/src/qc_data.h | 4 +- libAACenc/src/qc_main.cpp | 22 +- libFDK/src/FDK_core.cpp | 2 +- libFDK/src/fixpoint_math.cpp | 82 ++++-- 14 files changed, 563 insertions(+), 211 deletions(-) (limited to 'libAACenc/src/interface.h') diff --git a/libAACenc/src/aacEnc_ram.cpp b/libAACenc/src/aacEnc_ram.cpp index 2268726..1844331 100644 --- a/libAACenc/src/aacEnc_ram.cpp +++ b/libAACenc/src/aacEnc_ram.cpp @@ -89,13 +89,13 @@ amm-info@iis.fraunhofer.de ******************************************************************************/ /*! \file - \brief Memory layout + \brief Memory layout \author Markus Lohwasser */ #include "aacEnc_ram.h" - C_ALLOC_MEM (AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE/sizeof(FIXP_DBL)) + C_AALLOC_MEM (AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE/sizeof(FIXP_DBL)) /* Static memory areas, must not be overwritten in other sections of the decoder ! @@ -175,7 +175,7 @@ C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1) */ C_ALLOC_MEM2 (Ram_aacEnc_QCout, QC_OUT, 1, (1)) -C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, 1, (1)*(6)) +C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (6)) QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM) { FDK_ASSERT(dynamic_RAM!=0); return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL))); diff --git a/libAACenc/src/aacenc.cpp b/libAACenc/src/aacenc.cpp index 29e588f..6ce7b22 100644 --- a/libAACenc/src/aacenc.cpp +++ b/libAACenc/src/aacenc.cpp @@ -578,6 +578,8 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc, qcInit.minBits = (config->minBitsPerFrame!=-1) ? fixMax(qcInit.minBits, config->minBitsPerFrame) : qcInit.minBits; } + qcInit.sampleRate = config->sampleRate; + qcInit.advancedBitsToPe = isLowDelay(config->audioObjectType) ? 1 : 0 ; qcInit.nSubFrames = config->nSubFrames; qcInit.padding.paddingRest = config->sampleRate; diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp index a256f05..4d5984d 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 7 +#define AACENCODER_LIB_VL2 8 #define AACENCODER_LIB_TITLE "AAC Encoder" #define AACENCODER_LIB_BUILD_DATE __DATE__ #define AACENCODER_LIB_BUILD_TIME __TIME__ @@ -689,7 +689,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, hAacConfig->bitrateMode = 0; } if (config->userBitrateMode==0) { - hAacConfig->bitreservoir = 50*config->nChannels; /* default, reduced bitreservoir */ + hAacConfig->bitreservoir = 100*config->nChannels; /* default, reduced bitreservoir */ } if (hAacConfig->bitrateMode!=0) { return AACENC_INVALID_CONFIG; diff --git a/libAACenc/src/aacenc_tns.cpp b/libAACenc/src/aacenc_tns.cpp index 9a0edd4..85aea65 100644 --- a/libAACenc/src/aacenc_tns.cpp +++ b/libAACenc/src/aacenc_tns.cpp @@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de /******************************** MPEG Audio Encoder ************************** - Initial author: Alex Groeschel + Initial author: Alex Groeschel, Tobias Chalupka contents/description: Temporal noise shaping ******************************************************************************/ diff --git a/libAACenc/src/adj_thr.cpp b/libAACenc/src/adj_thr.cpp index 3fcb0be..0bd5827 100644 --- a/libAACenc/src/adj_thr.cpp +++ b/libAACenc/src/adj_thr.cpp @@ -123,6 +123,117 @@ static const FIXP_DBL SnrLdMin4 = (FIXP_DBL)0x02000000; /*FL2FXCONST_DBL(FDKlog static const FIXP_DBL SnrLdMin5 = (FIXP_DBL)0xfc000000; /*FL2FXCONST_DBL(FDKlog(0.25) /FDKlog(2.0)/LD_DATA_SCALING);*/ +/* +The bits2Pe factors are choosen for the case that some times +the crash recovery strategy will be activated once. +*/ + +typedef struct { + INT bitrate; + LONG bits2PeFactor_mono; + LONG bits2PeFactor_mono_slope; + LONG bits2PeFactor_stereo; + LONG bits2PeFactor_stereo_slope; + LONG bits2PeFactor_mono_scfOpt; + LONG bits2PeFactor_mono_scfOpt_slope; + LONG bits2PeFactor_stereo_scfOpt; + LONG bits2PeFactor_stereo_scfOpt_slope; + +} BIT_PE_SFAC; + +typedef struct { + const INT sampleRate; + const BIT_PE_SFAC * pPeTab; + const INT nEntries; + +} BITS2PE_CFG_TAB; + +static const BIT_PE_SFAC S_Bits2PeTab16000[] = { + { 10000, 0x228F5C29, 0x02FEF55D, 0x1D70A3D7, 0x09BC9D6D, 0x228F5C29, 0x02FEF55D, 0x1C28F5C3, 0x0CBB92CA}, + { 24000, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413, 0x23D70A3D, 0x029F16B1, 0x2199999A, 0x07DD4413}, + { 32000, 0x247AE148, 0x11B1D92B, 0x23851EB8, 0x01F75105, 0x247AE148, 0x110A137F, 0x23851EB8, 0x01F75105}, + { 48000, 0x2D1EB852, 0x6833C600, 0x247AE148, 0x014F8B59, 0x2CCCCCCD, 0x68DB8BAC, 0x247AE148, 0x01F75105}, + { 64000, 0x60000000, 0x00000000, 0x251EB852, 0x154C985F, 0x60000000, 0x00000000, 0x2570A3D7, 0x154C985F}, + { 96000, 0x60000000, 0x00000000, 0x39EB851F, 0x088509C0, 0x60000000, 0x00000000, 0x3A3D70A4, 0x088509C0}, + {128000, 0x60000000, 0x00000000, 0x423D70A4, 0x18A43BB4, 0x60000000, 0x00000000, 0x428F5C29, 0x181E03F7}, + {148000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000, 0x60000000, 0x00000000, 0x5147AE14, 0x00000000} +}; + +static const BIT_PE_SFAC S_Bits2PeTab22050[] = { + { 16000, 0x1a8f5c29, 0x1797cc3a, 0x128f5c29, 0x18e75793, 0x175c28f6, 0x221426fe, 0x00000000, 0x5a708ede}, + { 24000, 0x2051eb85, 0x092ccf6c, 0x18a3d70a, 0x13a92a30, 0x1fae147b, 0xbcbe61d, 0x16147ae1, 0x18e75793}, + { 32000, 0x228f5c29, 0x029f16b1, 0x1d70a3d7, 0x088509c0, 0x228f5c29, 0x29f16b1, 0x1c28f5c3, 0x0b242071}, + { 48000, 0x23d70a3d, 0x014f8b59, 0x2199999a, 0x03eea20a, 0x23d70a3d, 0x14f8b59, 0x2199999a, 0x03eea20a}, + { 64000, 0x247ae148, 0x08d8ec96, 0x23851eb8, 0x00fba882, 0x247ae148, 0x88509c0, 0x23851eb8, 0x00fba882}, + { 96000, 0x2d1eb852, 0x3419e300, 0x247ae148, 0x00a7c5ac, 0x2ccccccd, 0x346dc5d6, 0x247ae148, 0x00fba882}, + {128000, 0x60000000, 0x00000000, 0x251eb852, 0x029f16b1, 0x60000000, 0x00000000, 0x2570a3d7, 0x009f16b1}, + {148000, 0x60000000, 0x00000000, 0x26b851ec, 0x00000000, 0x60000000, 0x00000000, 0x270a3d71, 0x00000000} +}; + +static const BIT_PE_SFAC S_Bits2PeTab24000[] = { + { 16000, 0x19eb851f, 0x13a92a30, 0x1147ae14, 0x164840e1, 0x1999999a, 0x12599ed8, 0x00000000, 0x46c764ae}, + { 24000, 0x1eb851ec, 0x0d1b7176, 0x16b851ec, 0x18e75793, 0x1e147ae1, 0x0fba8827, 0x1147ae14, 0x2c9081c3}, + { 32000, 0x21eb851f, 0x049667b6, 0x1ccccccd, 0x07357e67, 0x21eb851f, 0x03eea20a, 0x1c28f5c3, 0x07357e67}, + { 48000, 0x2428f5c3, 0x014f8b59, 0x2051eb85, 0x053e2d62, 0x23d70a3d, 0x01f75105, 0x1fae147b, 0x07357e67}, + { 64000, 0x24cccccd, 0x05e5f30e, 0x22e147ae, 0x01a36e2f, 0x24cccccd, 0x05e5f30e, 0x23333333, 0x014f8b59}, + { 96000, 0x2a8f5c29, 0x24b33db0, 0x247ae148, 0x00fba882, 0x2a8f5c29, 0x26fe718b, 0x247ae148, 0x00fba882}, + {128000, 0x4e666666, 0x1cd5f99c, 0x2570a3d7, 0x010c6f7a, 0x50a3d70a, 0x192a7371, 0x2570a3d7, 0x010c6f7a}, + {148000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000, 0x60000000, 0x00000000, 0x26147ae1, 0x00000000} +}; + +static const BIT_PE_SFAC S_Bits2PeTab32000[] = { + { 16000, 0x1199999a, 0x20c49ba6, 0x00000000, 0x4577d955, 0x00000000, 0x60fe4799, 0x00000000, 0x00000000}, + { 24000, 0x1999999a, 0x0fba8827, 0x10f5c28f, 0x1b866e44, 0x17ae147b, 0x0fba8827, 0x00000000, 0x4d551d69}, + { 32000, 0x1d70a3d7, 0x07357e67, 0x17ae147b, 0x09d49518, 0x1b851eb8, 0x0a7c5ac4, 0x12e147ae, 0x110a137f}, + { 48000, 0x20f5c28f, 0x049667b6, 0x1c7ae148, 0x053e2d62, 0x20a3d70a, 0x053e2d62, 0x1b333333, 0x05e5f30e}, + { 64000, 0x23333333, 0x029f16b1, 0x1f0a3d71, 0x02f2f987, 0x23333333, 0x029f16b1, 0x1e147ae1, 0x03eea20a}, + { 96000, 0x25c28f5c, 0x2c3c9eed, 0x21eb851f, 0x01f75105, 0x25c28f5c, 0x0a7c5ac4, 0x21eb851f, 0x01a36e2f}, + {128000, 0x50f5c28f, 0x18a43bb4, 0x23d70a3d, 0x010c6f7a, 0x30000000, 0x168b5cc0, 0x23851eb8, 0x0192a737}, + {148000, 0x60000000, 0x00000000, 0x247ae148, 0x00dfb23b, 0x3dc28f5c, 0x300f4aaf, 0x247ae148, 0x01bf6476}, + {160000, 0x60000000, 0xb15b5740, 0x24cccccd, 0x053e2d62, 0x4f5c28f6, 0xbefd0072, 0x251eb852, 0x04fb1184}, + {200000, 0x00000000, 0x00000000, 0x2b333333, 0x0836be91, 0x00000000, 0x00000000, 0x2b333333, 0x0890390f}, + {320000, 0x00000000, 0x00000000, 0x4947ae14, 0x00000000, 0x00000000, 0x00000000, 0x4a8f5c29, 0x00000000} +}; + +static const BIT_PE_SFAC S_Bits2PeTab44100[] = { + { 16000, 0x10a3d70a, 0x1797cc3a, 0x00000000, 0x00000000, 0x00000000, 0x59210386, 0x00000000, 0x00000000}, + { 24000, 0x16666666, 0x1797cc3a, 0x00000000, 0x639d5e4a, 0x15c28f5c, 0x12599ed8, 0x00000000, 0x5bc01a37}, + { 32000, 0x1c28f5c3, 0x049667b6, 0x1851eb85, 0x049667b6, 0x1a3d70a4, 0x088509c0, 0x16666666, 0x053e2d62}, + { 48000, 0x1e666666, 0x05e5f30e, 0x1a8f5c29, 0x049667b6, 0x1e666666, 0x05e5f30e, 0x18f5c28f, 0x05e5f30e}, + { 64000, 0x2147ae14, 0x0346dc5d, 0x1ccccccd, 0x02f2f987, 0x2147ae14, 0x02f2f987, 0x1bd70a3d, 0x039abf34}, + { 96000, 0x247ae148, 0x068db8bb, 0x1fae147b, 0x029f16b1, 0x2428f5c3, 0x0639d5e5, 0x1f5c28f6, 0x029f16b1}, + {128000, 0x2ae147ae, 0x1b435265, 0x223d70a4, 0x0192a737, 0x2a3d70a4, 0x1040bfe4, 0x21eb851f, 0x0192a737}, + {148000, 0x3b851eb8, 0x2832069c, 0x23333333, 0x00dfb23b, 0x3428f5c3, 0x2054c288, 0x22e147ae, 0x00dfb23b}, + {160000, 0x4a3d70a4, 0xc32ebe5a, 0x23851eb8, 0x01d5c316, 0x40000000, 0xcb923a2b, 0x23333333, 0x01d5c316}, + {200000, 0x00000000, 0x00000000, 0x25c28f5c, 0x0713f078, 0x00000000, 0x00000000, 0x2570a3d7, 0x072a4f17}, + {320000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000, 0x00000000, 0x00000000, 0x3fae147b, 0x00000000} +}; + +static const BIT_PE_SFAC S_Bits2PeTab48000[] = { + { 16000, 0x0f5c28f6, 0x31ceaf25, 0x00000000, 0x00000000, 0x00000000, 0x74a771c9, 0x00000000, 0x00000000}, + { 24000, 0x1b851eb8, 0x029f16b1, 0x00000000, 0x663c74fb, 0x1c7ae148, 0xe47991bd, 0x00000000, 0x49667b5f}, + { 32000, 0x1c28f5c3, 0x029f16b1, 0x18f5c28f, 0x07357e67, 0x15c28f5c, 0x0f12c27a, 0x11eb851f, 0x13016484}, + { 48000, 0x1d70a3d7, 0x053e2d62, 0x1c7ae148, 0xfe08aefc, 0x1d1eb852, 0x068db8bb, 0x1b333333, 0xfeb074a8}, + { 64000, 0x20000000, 0x03eea20a, 0x1b851eb8, 0x0346dc5d, 0x2051eb85, 0x0346dc5d, 0x1a8f5c29, 0x039abf34}, + { 96000, 0x23d70a3d, 0x053e2d62, 0x1eb851ec, 0x029f16b1, 0x23851eb8, 0x04ea4a8c, 0x1e147ae1, 0x02f2f987}, + {128000, 0x28f5c28f, 0x14727dcc, 0x2147ae14, 0x0218def4, 0x2851eb85, 0x0e27e0f0, 0x20f5c28f, 0x0218def4}, + {148000, 0x3570a3d7, 0x1cd5f99c, 0x228f5c29, 0x01bf6476, 0x30f5c28f, 0x18777e75, 0x223d70a4, 0x01bf6476}, + {160000, 0x40000000, 0xcb923a2b, 0x23333333, 0x0192a737, 0x39eb851f, 0xd08d4bae, 0x22e147ae, 0x0192a737}, + {200000, 0x00000000, 0x00000000, 0x251eb852, 0x06775a1b, 0x00000000, 0x00000000, 0x24cccccd, 0x06a4175a}, + {320000, 0x00000000, 0x00000000, 0x3ccccccd, 0x00000000, 0x00000000, 0x00000000, 0x3d1eb852, 0x00000000} +}; + +static const BITS2PE_CFG_TAB bits2PeConfigTab[] = { + { 16000, S_Bits2PeTab16000, sizeof(S_Bits2PeTab16000)/sizeof(BIT_PE_SFAC) }, + { 22050, S_Bits2PeTab22050, sizeof(S_Bits2PeTab22050)/sizeof(BIT_PE_SFAC) }, + { 24000, S_Bits2PeTab24000, sizeof(S_Bits2PeTab24000)/sizeof(BIT_PE_SFAC) }, + { 32000, S_Bits2PeTab32000, sizeof(S_Bits2PeTab32000)/sizeof(BIT_PE_SFAC) }, + { 44100, S_Bits2PeTab44100, sizeof(S_Bits2PeTab44100)/sizeof(BIT_PE_SFAC) }, + { 48000, S_Bits2PeTab48000, sizeof(S_Bits2PeTab48000)/sizeof(BIT_PE_SFAC) } +}; + + + /* values for avoid hole flag */ enum _avoid_hole_state { NO_AH =0, @@ -135,6 +246,99 @@ enum _avoid_hole_state { #define Q_BITFAC (24) /* Q scaling used in FDKaacEnc_bitresCalcBitFac() calculation */ #define Q_AVGBITS (17) /* scale bit values */ + +/***************************************************************************** + functionname: FDKaacEnc_InitBits2PeFactor + description: retrieve bits2PeFactor from table +*****************************************************************************/ +static void FDKaacEnc_InitBits2PeFactor( + FIXP_DBL *bits2PeFactor_m, + INT *bits2PeFactor_e, + const INT bitRate, + const INT nChannels, + const INT sampleRate, + const INT advancedBitsToPe, + const INT invQuant + ) +{ + /* default bits2pe factor */ + FIXP_DBL bit2PE_m = FL2FXCONST_DBL(1.18f/(1<<(1))); + INT bit2PE_e = 1; + + /* make use of advanced bits to pe factor table */ + if (advancedBitsToPe) { + + int i; + const BIT_PE_SFAC *peTab = NULL; + INT size = 0; + + + /* Get correct table entry */ + for (i=0; i<(INT)(sizeof(bits2PeConfigTab)/sizeof(BITS2PE_CFG_TAB)); i++) { + if (sampleRate >= bits2PeConfigTab[i].sampleRate) { + peTab = bits2PeConfigTab[i].pPeTab; + size = bits2PeConfigTab[i].nEntries; + } + } + + if ( (peTab!=NULL) && (size!=0) ) { + + INT startB = -1; + LONG startPF = 0; + LONG peSlope = 0; + + /* stereo or mono mode and invQuant used or not */ + for (i=0; ibitRate) || ((i==size-2)) )) + { + if (nChannels==1) + { + startPF = (!invQuant) ? peTab[i].bits2PeFactor_mono : peTab[i].bits2PeFactor_mono_scfOpt; + peSlope = (!invQuant) ? peTab[i].bits2PeFactor_mono_slope : peTab[i].bits2PeFactor_mono_scfOpt_slope; + /*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_mono : peTab[i+1].bits2PeFactor_mono_scfOpt; + endB=peTab[i+1].bitrate;*/ + startB=peTab[i].bitrate; + break; + } + else + { + startPF = (!invQuant) ? peTab[i].bits2PeFactor_stereo : peTab[i].bits2PeFactor_stereo_scfOpt; + peSlope = (!invQuant) ? peTab[i].bits2PeFactor_stereo_slope : peTab[i].bits2PeFactor_stereo_scfOpt_slope; + /*endPF = (!invQuant) ? peTab[i+1].bits2PeFactor_stereo : peTab[i+1].bits2PeFactor_stereo_scfOpt; + endB=peTab[i+1].bitrate;*/ + startB=peTab[i].bitrate; + break; + } + } + } /* for i */ + + /* if a configuration is available */ + if (startB!=-1) { + /* linear interpolate to actual PEfactor */ + FIXP_DBL peFac = fMult((FIXP_DBL)(bitRate-startB)<<14, (FIXP_DBL)peSlope) << 2; + FIXP_DBL bit2PE = peFac + (FIXP_DBL)startPF; /* startPF_float = startPF << 2 */ + + /* sanity check if bits2pe value is high enough */ + if ( bit2PE >= (FL2FXCONST_DBL(0.35f) >> 2) ) { + bit2PE_m = bit2PE; + bit2PE_e = 2; /* table is fixed scaled */ + } + } /* br */ + } /* sr */ + } /* advancedBitsToPe */ + + + /* return bits2pe factor */ + *bits2PeFactor_m = bit2PE_m; + *bits2PeFactor_e = bit2PE_e; +} + + +/***************************************************************************** +functionname: FDKaacEnc_bits2pe2 +description: convert from bits to pe +*****************************************************************************/ static INT FDKaacEnc_bits2pe2( const INT bits, const FIXP_DBL factor_m, @@ -450,22 +654,23 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData, FIXP_DBL nrgSum14, nrgSum12, nrgSum34, nrgTotal; FIXP_DBL nrgFacLd_14, nrgFacLd_12, nrgFacLd_34; INT usePatch, exePatch; - int sfb, nLinesSum = 0; + int sfb, sfbGrp, nLinesSum = 0; nrgSum14 = nrgSum12 = nrgSum34 = nrgTotal = FL2FXCONST_DBL(0.f); /* calculate flatness of audible spectrum, i.e. spectrum above masking threshold. */ - for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) { - - FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>1); /* nrg^(1/2) */ - FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfb]>>2); /* nrg^(1/4) */ + for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) { + for (sfb=0; sfbmaxSfbPerGroup; sfb++) { + FIXP_DBL nrgFac12 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1); /* nrg^(1/2) */ + FIXP_DBL nrgFac14 = CalcInvLdData(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>2); /* nrg^(1/4) */ /* maximal number of bands is 64, results scaling factor 6 */ - nLinesSum += peData->peChannelData[ch].sfbNLines[sfb]; /* relevant lines */ - nrgTotal += ( psyOutChan->sfbEnergy[sfb] >> 6 ); /* sum up nrg */ + nLinesSum += peData->peChannelData[ch].sfbNLines[sfbGrp+sfb]; /* relevant lines */ + nrgTotal += ( psyOutChan->sfbEnergy[sfbGrp+sfb] >> 6 ); /* sum up nrg */ nrgSum12 += ( nrgFac12 >> 6 ); /* sum up nrg^(2/4) */ nrgSum14 += ( nrgFac14 >> 6 ); /* sum up nrg^(1/4) */ nrgSum34 += ( fMult(nrgFac14, nrgFac12) >> 6 ); /* sum up nrg^(3/4) */ + } } nrgTotal = CalcLdData(nrgTotal); /* get ld64 of total nrg */ @@ -479,32 +684,35 @@ void FDKaacEnc_calcWeighting(PE_DATA *peData, usePatch = (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.78125f)); exePatch = ((usePatch) && (adjThrStateElement->lastEnFacPatch[ch])); - for (sfb = 0; sfb < psyOutChan->sfbCnt; sfb++) { + for (sfbGrp = 0;sfbGrp < psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutChannel[ch]->sfbPerGroup) { + for (sfb=0; sfbmaxSfbPerGroup; sfb++) { + INT sfbExePatch; /* for MS coupled SFBs, also execute patch in side channel if done in mid channel */ - if ((ch == 1) && (toolsInfo->msMask[sfb])) { + if ((ch == 1) && (toolsInfo->msMask[sfbGrp+sfb])) { sfbExePatch = exePatchM; } else { sfbExePatch = exePatch; } - if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfb]>FL2FXCONST_DBL(0.f)) ) + if ( (sfbExePatch) && (psyOutChan->sfbEnergy[sfbGrp+sfb]>FL2FXCONST_DBL(0.f)) ) { /* execute patch based on spectral flatness calculated above */ if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.8125f)) { - qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfb]+(psyOutChan->sfbEnergyLdData[sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */ + qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_14 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]+(psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1)))>>1 ); /* sfbEnergy^(3/4) */ } else if (adjThrStateElement->chaosMeasureEnFac[ch] > FL2FXCONST_DBL(0.796875f)) { - qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfb])>>1 ); /* sfbEnergy^(2/4) */ + qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_12 + psyOutChan->sfbEnergyLdData[sfbGrp+sfb])>>1 ); /* sfbEnergy^(2/4) */ } else { - qcOutChannel[ch]->sfbEnFacLd[sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */ + qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = ( (nrgFacLd_34 + (psyOutChan->sfbEnergyLdData[sfbGrp+sfb]>>1))>>1 ); /* sfbEnergy^(1/4) */ } - qcOutChannel[ch]->sfbEnFacLd[sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfb],(FIXP_DBL)0); + qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb] = fixMin(qcOutChannel[ch]->sfbEnFacLd[sfbGrp+sfb],(FIXP_DBL)0); } + } } /* sfb loop */ adjThrStateElement->lastEnFacPatch[ch] = usePatch; @@ -735,7 +943,6 @@ static FIXP_DBL FDKaacEnc_calcChaosMeasure(PSY_OUT_CHANNEL *psyOutChannel, return chaosMeasure; } - /* apply reduction formula for VBR-mode */ static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)], PSY_OUT_CHANNEL* psyOutChannel[(2)], @@ -923,7 +1130,6 @@ static void FDKaacEnc_reduceThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)], } } - /***************************************************************************** functionname: FDKaacEnc_correctThresh description: if pe difference deltaPe between desired pe and real pe is small enough, @@ -948,7 +1154,7 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, FIXP_DBL thrFactorLdData; FIXP_DBL sfbEnLdData, sfbThrLdData, sfbThrReducedLdData; FIXP_DBL *sfbPeFactorsLdData[(6)][(2)]; - FIXP_DBL sfbNActiveLinesLdData[(2)][MAX_GROUPED_SFB]; + FIXP_DBL sfbNActiveLinesLdData[(6)][(2)][MAX_GROUPED_SFB]; INT normFactorInt; FIXP_DBL normFactorLdData; @@ -979,13 +1185,13 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, for (sfb=0; sfbmaxSfbPerGroup; sfb++) { if ( peChanData->sfbNActiveLines[sfbGrp+sfb] == 0 ) { - sfbNActiveLinesLdData[ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f); + sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f); } else { /* Both CalcLdInt and CalcLdData can be used! * No offset has to be subtracted, because sfbNActiveLinesLdData * is shorted while thrFactor calculation */ - sfbNActiveLinesLdData[ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]); + sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] = CalcLdInt(peChanData->sfbNActiveLines[sfbGrp+sfb]); } if ( ((ahFlag[elementId][ch][sfbGrp+sfb] < AH_ACTIVE) || (deltaPe > 0)) && peChanData->sfbNActiveLines[sfbGrp+sfb] != 0 ) @@ -1002,14 +1208,14 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, - (FIXP_DBL)(minScale<<(DFRACT_BITS-1-LD_DATA_SHIFT)); if (sumLd < FL2FXCONST_DBL(0.f)) { - sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd; + sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd; } else { - if ( sfbNActiveLinesLdData[ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) { - sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb] - sumLd; + if ( sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] > (FL2FXCONST_DBL(-1.f) + sumLd) ) { + sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - sumLd; } else { - sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[ch][sfbGrp+sfb]; + sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] = sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb]; } } @@ -1050,7 +1256,7 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, } else { /* new threshold */ - FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING)); + FIXP_DBL tmp = CalcInvLdData(sfbPeFactorsLdData[elementId][ch][sfbGrp+sfb] + normFactorLdData - sfbNActiveLinesLdData[elementId][ch][sfbGrp+sfb] - FL2FXCONST_DBL((float)LD_DATA_SHIFT/LD_DATA_SCALING)); /* limit thrFactor to 60dB */ tmp = (deltaPe<0) ? tmp : (-tmp); @@ -1683,7 +1889,6 @@ static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm, } - /* similar to FDKaacEnc_adaptThresholdsToPe(), for VBR-mode */ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)], PSY_OUT_CHANNEL* psyOutChannel[(2)], @@ -1692,8 +1897,14 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)], PE_DATA *peData, const INT nChannels) { - UCHAR pAhFlag[(2)][MAX_GROUPED_SFB]; - FIXP_DBL pThrExp[(2)][MAX_GROUPED_SFB]; + UCHAR (*pAhFlag)[MAX_GROUPED_SFB]; + FIXP_DBL (*pThrExp)[MAX_GROUPED_SFB]; + + /* allocate scratch memory */ + C_ALLOC_SCRATCH_START(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB) + C_ALLOC_SCRATCH_START(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB) + pAhFlag = (UCHAR(*)[MAX_GROUPED_SFB])_pAhFlag; + pThrExp = (FIXP_DBL(*)[MAX_GROUPED_SFB])_pThrExp; /* thresholds to the power of redExp */ FDKaacEnc_calcThreshExp(pThrExp, qcOutChannel, psyOutChannel, nChannels); @@ -1711,6 +1922,9 @@ void FDKaacEnc_AdaptThresholdsVBR(QC_OUT_CHANNEL* qcOutChannel[(2)], AdjThrStateElement->vbrQualFactor, &AdjThrStateElement->chaosMeasureOld); + /* free scratch memory */ + C_ALLOC_SCRATCH_END(_pThrExp, FIXP_DBL, (2)*MAX_GROUPED_SFB) + C_ALLOC_SCRATCH_END(_pAhFlag, UCHAR, (2)*MAX_GROUPED_SFB) } @@ -2002,95 +2216,112 @@ bail: functionname: FDKaacEnc_AdjThrInit description: initialize ADJ_THR_STATE *****************************************************************************/ -void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr, - const INT meanPe, - ELEMENT_BITS *elBits[(6)], - INT nElements, - FIXP_DBL vbrQualFactor) +void FDKaacEnc_AdjThrInit( + ADJ_THR_STATE *hAdjThr, + const INT meanPe, + ELEMENT_BITS *elBits[(6)], + INT invQuant, + INT nElements, + INT nChannelsEff, + INT sampleRate, + INT advancedBitsToPe, + FIXP_DBL vbrQualFactor + ) { - INT i; - - FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f); - FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f); + INT i; + + FIXP_DBL POINT8 = FL2FXCONST_DBL(0.8f); + FIXP_DBL POINT6 = FL2FXCONST_DBL(0.6f); + + /* common for all elements: */ + /* parameters for bitres control */ + hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */ + hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */ + hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */ + hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */ + hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */ + hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */ + hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */ + hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */ + + hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ + hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */ + hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */ + hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ + hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ + hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */ + hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */ + hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */ + + /* specific for each element: */ + for (i=0; iadjThrStateElem[i]; + MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam; + INT chBitrate = elBits[i]->chBitrateEl; - /* common for all elements: */ /* parameters for bitres control */ - hAdjThr->bresParamLong.clipSaveLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */ - hAdjThr->bresParamLong.clipSaveHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */ - hAdjThr->bresParamLong.minBitSave = (FIXP_DBL)0xf999999a; /* FL2FXCONST_DBL(-0.05f); */ - hAdjThr->bresParamLong.maxBitSave = (FIXP_DBL)0x26666666; /* FL2FXCONST_DBL(0.3f); */ - hAdjThr->bresParamLong.clipSpendLow = (FIXP_DBL)0x1999999a; /* FL2FXCONST_DBL(0.2f); */ - hAdjThr->bresParamLong.clipSpendHigh = (FIXP_DBL)0x7999999a; /* FL2FXCONST_DBL(0.95f); */ - hAdjThr->bresParamLong.minBitSpend = (FIXP_DBL)0xf3333333; /* FL2FXCONST_DBL(-0.10f); */ - hAdjThr->bresParamLong.maxBitSpend = (FIXP_DBL)0x33333333; /* FL2FXCONST_DBL(0.4f); */ - - hAdjThr->bresParamShort.clipSaveLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ - hAdjThr->bresParamShort.clipSaveHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */ - hAdjThr->bresParamShort.minBitSave = (FIXP_DBL)0x00000000; /* FL2FXCONST_DBL(0.0f); */ - hAdjThr->bresParamShort.maxBitSave = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ - hAdjThr->bresParamShort.clipSpendLow = (FIXP_DBL)0x199999a0; /* FL2FXCONST_DBL(0.2f); */ - hAdjThr->bresParamShort.clipSpendHigh = (FIXP_DBL)0x5fffffff; /* FL2FXCONST_DBL(0.75f); */ - hAdjThr->bresParamShort.minBitSpend = (FIXP_DBL)0xf9999998; /* FL2FXCONST_DBL(-0.05f); */ - hAdjThr->bresParamShort.maxBitSpend = (FIXP_DBL)0x40000000; /* FL2FXCONST_DBL(0.5f); */ - - /* specific for each element: */ - for (i=0; iadjThrStateElem[i]; - MINSNR_ADAPT_PARAM *msaParam = &atsElem->minSnrAdaptParam; - INT chBitrate = elBits[i]->chBitrateEl; + atsElem->peMin = fMultI(POINT8, meanPe) >> 1; + atsElem->peMax = fMultI(POINT6, meanPe); - /* parameters for bitres control */ - atsElem->peMin = fMultI(POINT8, meanPe) >> 1; - atsElem->peMax = fMultI(POINT6, meanPe); + /* for use in FDKaacEnc_reduceThresholdsVBR */ + atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f); - /* for use in FDKaacEnc_reduceThresholdsVBR */ - atsElem->chaosMeasureOld = FL2FXCONST_DBL(0.3f); + /* additional pe offset to correct pe2bits for low bitrates */ + atsElem->peOffset = 0; - /* additional pe offset to correct pe2bits for low bitrates */ - atsElem->peOffset = 0; + /* vbr initialisation */ + atsElem->vbrQualFactor = vbrQualFactor; + if (chBitrate < 32000) + { + atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate)); + } - /* vbr initialisation */ - atsElem->vbrQualFactor = vbrQualFactor; - if (chBitrate < 32000) - { - atsElem->peOffset = fixMax(50, 100-fMultI((FIXP_DBL)0x666667, chBitrate)); - } + /* avoid hole parameters */ + if (chBitrate > 20000) { + atsElem->ahParam.modifyMinSnr = TRUE; + atsElem->ahParam.startSfbL = 15; + atsElem->ahParam.startSfbS = 3; + } + else { + atsElem->ahParam.modifyMinSnr = FALSE; + atsElem->ahParam.startSfbL = 0; + atsElem->ahParam.startSfbS = 0; + } - /* avoid hole parameters */ - if (chBitrate > 20000) { - atsElem->ahParam.modifyMinSnr = TRUE; - atsElem->ahParam.startSfbL = 15; - atsElem->ahParam.startSfbS = 3; - } - else { - atsElem->ahParam.modifyMinSnr = FALSE; - atsElem->ahParam.startSfbL = 0; - atsElem->ahParam.startSfbS = 0; - } + /* minSnr adaptation */ + msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */ + /* start adaptation of minSnr for avgEn/sfbEn > startRatio */ + msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */ + /* maximum minSnr reduction to minSnr^maxRed is reached for + avgEn/sfbEn >= maxRatio */ + /* msaParam->maxRatio = 1000.0f; */ + /*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/ + msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */ + /*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/ + msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */ + + /* init pe correction */ + atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */ + atsElem->peCorrectionFactor_e = 1; + + atsElem->dynBitsLast = -1; + atsElem->peLast = 0; + + /* init bits to pe factor */ + + /* init bits2PeFactor */ + FDKaacEnc_InitBits2PeFactor( + &atsElem->bits2PeFactor_m, + &atsElem->bits2PeFactor_e, + chBitrate, /* bitrate/channel*/ + nChannelsEff, /* number of channels */ + sampleRate, + advancedBitsToPe, + invQuant + ); + + } /* for nElements */ - /* minSnr adaptation */ - msaParam->maxRed = FL2FXCONST_DBL(0.00390625f); /* 0.25f/64.0f */ - /* start adaptation of minSnr for avgEn/sfbEn > startRatio */ - msaParam->startRatio = FL2FXCONST_DBL(0.05190512648f); /* ld64(10.0f) */ - /* maximum minSnr reduction to minSnr^maxRed is reached for - avgEn/sfbEn >= maxRatio */ - /* msaParam->maxRatio = 1000.0f; */ - /*msaParam->redRatioFac = ((float)1.0f - msaParam->maxRed) / ((float)10.0f*log10(msaParam->startRatio/msaParam->maxRatio)/log10(2.0f)*(float)0.3010299956f);*/ - msaParam->redRatioFac = FL2FXCONST_DBL(-0.375f); /* -0.0375f * 10.0f */ - /*msaParam->redOffs = (float)1.0f - msaParam->redRatioFac * (float)10.0f * log10(msaParam->startRatio)/log10(2.0f) * (float)0.3010299956f;*/ - msaParam->redOffs = FL2FXCONST_DBL(0.021484375); /* 1.375f/64.0f */ - - /* init pe correction */ - atsElem->peCorrectionFactor_m = FL2FXCONST_DBL(0.5f); /* 1.0 */ - atsElem->peCorrectionFactor_e = 1; - - atsElem->dynBitsLast = -1; - atsElem->peLast = 0; - - /* init bits to pe factor */ - atsElem->bits2PeFactor_m = FL2FXCONST_DBL(1.18f/(1<<(1))); - atsElem->bits2PeFactor_e = 1; - } } @@ -2154,6 +2385,67 @@ static void FDKaacEnc_FDKaacEnc_calcPeCorrection( } +static void FDKaacEnc_calcPeCorrectionLowBitRes( + FIXP_DBL *const correctionFac_m, + INT *const correctionFac_e, + const INT peLast, + const INT bitsLast, + const INT bitresLevel, + const INT nChannels, + const FIXP_DBL bits2PeFactor_m, + const INT bits2PeFactor_e + ) +{ + /* tuning params */ + const FIXP_DBL amp = FL2FXCONST_DBL(0.005); + const FIXP_DBL maxDiff = FL2FXCONST_DBL(0.25f); + + if (bitsLast > 0) { + + /* Estimate deviation of granted and used dynamic bits in previous frame, in PE units */ + const int bitsBalLast = peLast - FDKaacEnc_bits2pe2( + bitsLast, + bits2PeFactor_m, + bits2PeFactor_e); + + /* reserve n bits per channel */ + int headroom = (bitresLevel>=50*nChannels) ? 0 : (100*nChannels); + + /* in PE units */ + headroom = FDKaacEnc_bits2pe2( + headroom, + bits2PeFactor_m, + bits2PeFactor_e); + + /* + * diff = amp * ((bitsBalLast - headroom) / (bitresLevel + headroom) + * diff = max ( min ( diff, maxDiff, -maxDiff)) / 2 + */ + FIXP_DBL denominator = (FIXP_DBL)FDKaacEnc_bits2pe2(bitresLevel, bits2PeFactor_m, bits2PeFactor_e) + (FIXP_DBL)headroom; + + int scaling = 0; + FIXP_DBL diff = (bitsBalLast>=headroom) + ? fMult(amp, fDivNorm( (FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling)) + : -fMult(amp, fDivNorm(-(FIXP_DBL)(bitsBalLast - headroom), denominator, &scaling)) ; + + scaling -= 1; /* divide by 2 */ + + diff = (scaling<=0) ? FDKmax( FDKmin (diff>>(-scaling), maxDiff>>1), -maxDiff>>1) + : FDKmax( FDKmin (diff, maxDiff>>(1+scaling)), -maxDiff>>(1+scaling)) << scaling; + + /* + * corrFac += diff + * corrFac = max ( min ( corrFac/2.f, 1.f/2.f, 0.75f/2.f ) ) + */ + *correctionFac_m = FDKmax(FDKmin((*correctionFac_m)+diff, FL2FXCONST_DBL(1.0f/2.f)), FL2FXCONST_DBL(0.75f/2.f)) ; + *correctionFac_e = 1; + } + else { + *correctionFac_m = FL2FXCONST_DBL(0.75/2.f); + *correctionFac_e = 1; + } +} + void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, ATS_ELEMENT *AdjThrStateElement, PSY_OUT_CHANNEL *psyOutChannel[(2)], @@ -2166,7 +2458,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, const INT bitresBits, const INT maxBitresBits, const FIXP_DBL maxBitFac, - const INT bitDistributenMode) + const INT bitDistributionMode) { FIXP_DBL bitFactor; INT noRedPe = peData->pe; @@ -2184,7 +2476,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, } if (grantedDynBits >= 1) { - if (bitDistributenMode!=0) { + if (bitDistributionMode!=0) { *grantedPe = FDKaacEnc_bits2pe2(grantedDynBits, AdjThrStateElement->bits2PeFactor_m, AdjThrStateElement->bits2PeFactor_e); } else @@ -2208,16 +2500,32 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, } /* correction of pe value */ - { - FDKaacEnc_FDKaacEnc_calcPeCorrection( - &AdjThrStateElement->peCorrectionFactor_m, - &AdjThrStateElement->peCorrectionFactor_e, - fixMin(*grantedPe, noRedPe), - AdjThrStateElement->peLast, - AdjThrStateElement->dynBitsLast, - AdjThrStateElement->bits2PeFactor_m, - AdjThrStateElement->bits2PeFactor_e + switch (bitDistributionMode) { + case 2: + case 1: + FDKaacEnc_calcPeCorrectionLowBitRes( + &AdjThrStateElement->peCorrectionFactor_m, + &AdjThrStateElement->peCorrectionFactor_e, + AdjThrStateElement->peLast, + AdjThrStateElement->dynBitsLast, + bitresBits, + nChannels, + AdjThrStateElement->bits2PeFactor_m, + AdjThrStateElement->bits2PeFactor_e ); + break; + case 0: + default: + FDKaacEnc_FDKaacEnc_calcPeCorrection( + &AdjThrStateElement->peCorrectionFactor_m, + &AdjThrStateElement->peCorrectionFactor_e, + fixMin(*grantedPe, noRedPe), + AdjThrStateElement->peLast, + AdjThrStateElement->dynBitsLast, + AdjThrStateElement->bits2PeFactor_m, + AdjThrStateElement->bits2PeFactor_e + ); + break; } *grantedPeCorr = (INT)(fMult((FIXP_DBL)(*grantedPe<peCorrectionFactor_m) >> (Q_AVGBITS-AdjThrStateElement->peCorrectionFactor_e)); @@ -2291,20 +2599,19 @@ void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)], } /* -end- element loop */ } - for (i=0; inElements; i++) { - int ch,sfb,sfbGrp; - /* no weighting of threholds and energies for mlout */ - /* weight energies and thresholds */ - for (ch=0; chelInfo[i].nChannelsInEl; ch++) { - QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch]; - for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) { - for (sfb=0; sfbpsyOutChannel[ch]->maxSfbPerGroup; sfb++) { - pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp]; - } + for (i=0; inElements; i++) { + int ch,sfb,sfbGrp; + /* no weighting of threholds and energies for mlout */ + /* weight energies and thresholds */ + for (ch=0; chelInfo[i].nChannelsInEl; ch++) { + QC_OUT_CHANNEL* pQcOutCh = qcElement[i]->qcOutChannel[ch]; + for (sfbGrp = 0;sfbGrp < psyOutElement[i]->psyOutChannel[ch]->sfbCnt; sfbGrp+=psyOutElement[i]->psyOutChannel[ch]->sfbPerGroup) { + for (sfb=0; sfbpsyOutChannel[ch]->maxSfbPerGroup; sfb++) { + pQcOutCh->sfbThresholdLdData[sfb+sfbGrp] += pQcOutCh->sfbEnFacLd[sfb+sfbGrp]; } } } - + } } void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr) diff --git a/libAACenc/src/adj_thr.h b/libAACenc/src/adj_thr.h index d03375c..a429dff 100644 --- a/libAACenc/src/adj_thr.h +++ b/libAACenc/src/adj_thr.h @@ -98,13 +98,14 @@ amm-info@iis.fraunhofer.de #include "interface.h" - -void FDKaacEnc_peCalculation(PE_DATA *peData, - PSY_OUT_CHANNEL* psyOutChannel[(2)], - QC_OUT_CHANNEL* qcOutChannel[(2)], - struct TOOLSINFO *toolsInfo, - ATS_ELEMENT* adjThrStateElement, - const INT nChannels); +void FDKaacEnc_peCalculation( + PE_DATA *peData, + PSY_OUT_CHANNEL* psyOutChannel[(2)], + QC_OUT_CHANNEL* qcOutChannel[(2)], + struct TOOLSINFO *toolsInfo, + ATS_ELEMENT* adjThrStateElement, + const INT nChannels + ); INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr, INT nElements); @@ -112,9 +113,13 @@ INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr, void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr, const INT peMean, ELEMENT_BITS* elBits[(6)], + INT invQuant, INT nElements, + INT nChannelsEff, + INT sampleRate, + INT advancedBitsToPe, FIXP_DBL vbrQualFactor); - + void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, ATS_ELEMENT *AdjThrStateElement, @@ -128,7 +133,7 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, const INT bitresBits, const INT maxBitresBits, const FIXP_DBL maxBitFac, - const INT bitDistributenMode); + const INT bitDistributionMode); void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)], QC_OUT_ELEMENT* qcElement[(6)], diff --git a/libAACenc/src/block_switch.cpp b/libAACenc/src/block_switch.cpp index 948c89f..7b3e275 100644 --- a/libAACenc/src/block_switch.cpp +++ b/libAACenc/src/block_switch.cpp @@ -83,7 +83,7 @@ amm-info@iis.fraunhofer.de /***************************** MPEG-4 AAC Encoder ************************** - Author(s): M. Werner + Author(s): M. Werner, Tobias Chalupka Description: Block switching ******************************************************************************/ @@ -100,9 +100,11 @@ amm-info@iis.fraunhofer.de static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx); -static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, - INT windowLen); - +static void FDKaacEnc_CalcWindowEnergy( + BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, + INT windowLen, + const INT_PCM *pTimeSignal + ); /****************** Constants *****************************/ /* LONG START SHORT STOP LOWOV */ @@ -145,20 +147,9 @@ static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLO /**************** internal function prototypes ***********/ -static INT FDKaacEnc_GetWindowIndex(INT blockSwWindowIndex); - -static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT shortWndIdx); - -static void FDKaacEnc_CalcWindowEnergy( BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, - INT windowLen); - - - /****************** Routines ****************************/ void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay) { - /* note: the pointer to timeSignal can be zeroed here, because it is initialized for every call - to FDKaacEnc_BlockSwitching anew */ FDKmemclear (blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL)); if (isLowDelay) @@ -214,7 +205,7 @@ static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] = /*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} } /* attack */ }; -int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE) +int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal) { UINT i; FIXP_DBL enM1, enMax; @@ -263,7 +254,7 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con /* Calculate unfiltered and filtered energies in subwindows and combine to segments */ - FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 )); + FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ), pTimeSignal); /* now calculate if there is an attack */ @@ -335,8 +326,7 @@ static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWnd } - -static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen) +static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen, const INT_PCM *pTimeSignal) { INT i; UINT w; @@ -344,8 +334,6 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw FIXP_SGL hiPassCoeff0 = hiPassCoeff[0]; FIXP_SGL hiPassCoeff1 = hiPassCoeff[1]; - INT_PCM *timeSignal = blockSwitchingControl->timeSignal; - /* sum up scalarproduct of timesignal as windowed Energies */ for (w=0; w < blockSwitchingControl->nBlockSwitchWindows; w++) { @@ -361,9 +349,9 @@ static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSw FIXP_DBL tempUnfiltered, tempFiltred, t1, t2; /* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */ #if SAMPLE_BITS == DFRACT_BITS - tempUnfiltered = (FIXP_DBL) *timeSignal++ >> 1; + tempUnfiltered = (FIXP_DBL) *pTimeSignal++ >> 1; #else - tempUnfiltered = (FIXP_DBL) *timeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1); + tempUnfiltered = (FIXP_DBL) *pTimeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1); #endif t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered-temp_iirState0); t2 = fMultDiv2(hiPassCoeff0, temp_iirState1); diff --git a/libAACenc/src/block_switch.h b/libAACenc/src/block_switch.h index 174f05f..e94b6f5 100644 --- a/libAACenc/src/block_switch.h +++ b/libAACenc/src/block_switch.h @@ -107,7 +107,6 @@ amm-info@iis.fraunhofer.de /****************** Structures ***************************/ typedef struct{ - INT_PCM *timeSignal; INT lastWindowSequence; INT windowShape; INT lastWindowShape; @@ -136,7 +135,7 @@ typedef struct{ void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay); -int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE); +int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal); int FDKaacEnc_SyncBlockSwitching( BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft, diff --git a/libAACenc/src/interface.h b/libAACenc/src/interface.h index 177ddbf..2ec1852 100644 --- a/libAACenc/src/interface.h +++ b/libAACenc/src/interface.h @@ -92,6 +92,7 @@ amm-info@iis.fraunhofer.de #define _INTERFACE_H #include "common_fix.h" +#include "FDK_audio.h" #include "psy_data.h" #include "aacenc_tns.h" @@ -160,4 +161,9 @@ typedef struct { }PSY_OUT; +inline int isLowDelay( AUDIO_OBJECT_TYPE aot ) +{ + return (aot==AOT_ER_AAC_LD || aot==AOT_ER_AAC_ELD); +} + #endif /* _INTERFACE_H */ diff --git a/libAACenc/src/psy_main.cpp b/libAACenc/src/psy_main.cpp index 8649a7e..0949b6d 100644 --- a/libAACenc/src/psy_main.cpp +++ b/libAACenc/src/psy_main.cpp @@ -116,11 +116,6 @@ static const FIXP_DBL fadeOutFactor[FADE_OUT_LEN] = {1840644096, 1533870080, 122 /* forward definitions */ -static inline int isLowDelay( AUDIO_OBJECT_TYPE aot ) -{ - return (aot==AOT_ER_AAC_LD || aot==AOT_ER_AAC_ELD); -} - /***************************************************************************** functionname: FDKaacEnc_PsyNew @@ -513,28 +508,28 @@ AAC_ENCODER_ERROR FDKaacEnc_psyMain(INT channels, for(ch = 0; ch < channels; ch++) { - C_ALLOC_SCRATCH_START(timeSignal, INT_PCM, (1024)); - psyStatic[ch]->blockSwitchingControl.timeSignal = timeSignal; + C_ALLOC_SCRATCH_START(pTimeSignal, INT_PCM, (1024)) /* deinterleave input data and use for block switching */ - FDKaacEnc_deinterleaveInputBuffer( psyStatic[ch]->blockSwitchingControl.timeSignal, + FDKaacEnc_deinterleaveInputBuffer( pTimeSignal, &pInput[chIdx[ch]], psyConf->granuleLength, totalChannels); FDKaacEnc_BlockSwitching (&psyStatic[ch]->blockSwitchingControl, - psyConf->granuleLength - ,psyStatic[ch]->isLFE + psyConf->granuleLength, + psyStatic[ch]->isLFE, + pTimeSignal ); /* fill up internal input buffer, to 2xframelength samples */ FDKmemcpy(psyStatic[ch]->psyInputBuffer+blockSwitchingOffset, - psyStatic[ch]->blockSwitchingControl.timeSignal, + pTimeSignal, (2*psyConf->granuleLength-blockSwitchingOffset)*sizeof(INT_PCM)); - C_ALLOC_SCRATCH_END(timeSignal, INT_PCM, (1024)); + C_ALLOC_SCRATCH_END(pTimeSignal, INT_PCM, (1024)) } /* synch left and right block type */ diff --git a/libAACenc/src/qc_data.h b/libAACenc/src/qc_data.h index be6d158..51e66c6 100644 --- a/libAACenc/src/qc_data.h +++ b/libAACenc/src/qc_data.h @@ -143,6 +143,8 @@ struct QC_INIT{ INT maxBits; /* maximum number of bits in reservoir */ INT averageBits; /* average number of bits we should use */ INT bitRes; + INT sampleRate; /* output sample rate */ + INT advancedBitsToPe; /* if set, calc bits2PE factor depending on samplerate */ INT staticBits; /* Bits per frame consumed by transport layers. */ QCDATA_BR_MODE bitrateMode; INT meanPe; @@ -252,7 +254,7 @@ typedef struct INT minBitsPerFrame; /* minimal allowd bits per fram, superframing - DRM */ INT nElements; QCDATA_BR_MODE bitrateMode; - INT bitDistributenMode; /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */ + INT bitDistributionMode; /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */ INT bitResTot; INT bitResTotMax; INT maxIterations; /* Maximum number of allowed iterations before FDKaacEnc_crashRecovery() is applied. */ diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp index 0a4bcbc..15646e9 100644 --- a/libAACenc/src/qc_main.cpp +++ b/libAACenc/src/qc_main.cpp @@ -382,10 +382,10 @@ AAC_ENCODER_ERROR FDKaacEnc_QCInit(QC_STATE *hQC, if ( isConstantBitrateMode(hQC->bitrateMode) ) { INT bitresPerChannel = (hQC->bitResTotMax / init->channelMapping->nChannelsEff); /* 0: full bitreservoir, 1: reduced bitreservoir, 2: disabled bitreservoir */ - hQC->bitDistributenMode = (bitresPerChannel>50) ? 0 : (bitresPerChannel>0) ? 1 : 2; + hQC->bitDistributionMode = (bitresPerChannel>100) ? 0 : (bitresPerChannel>0) ? 1 : 2; } else { - hQC->bitDistributenMode = 0; /* full bitreservoir */ + hQC->bitDistributionMode = 0; /* full bitreservoir */ } @@ -420,11 +420,17 @@ AAC_ENCODER_ERROR FDKaacEnc_QCInit(QC_STATE *hQC, break; } - FDKaacEnc_AdjThrInit(hQC->hAdjThr, - init->meanPe, - hQC->elementBits, /* or channelBitrates, was: channelBitrate */ - init->channelMapping->nElements, - hQC->vbrQualFactor); + FDKaacEnc_AdjThrInit( + hQC->hAdjThr, + init->meanPe, + hQC->elementBits, /* or channelBitrates, was: channelBitrate */ + hQC->invQuant, + init->channelMapping->nElements, + init->channelMapping->nChannelsEff, + init->sampleRate, /* output sample rate */ + init->advancedBitsToPe, /* if set, calc bits2PE factor depending on samplerate */ + hQC->vbrQualFactor + ); return AAC_ENC_OK; } @@ -655,7 +661,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h hQC->elementBits[i]->bitResLevelEl, hQC->elementBits[i]->maxBitResBitsEl, hQC->maxBitFac, - hQC->bitDistributenMode); + hQC->bitDistributionMode); *totalAvailableBits += hQC->elementBits[i]->bitResLevelEl; /* get total corrected granted PE */ diff --git a/libFDK/src/FDK_core.cpp b/libFDK/src/FDK_core.cpp index ea0be6c..6db648d 100644 --- a/libFDK/src/FDK_core.cpp +++ b/libFDK/src/FDK_core.cpp @@ -93,7 +93,7 @@ amm-info@iis.fraunhofer.de /* FDK tools library info */ #define FDK_TOOLS_LIB_VL0 2 #define FDK_TOOLS_LIB_VL1 3 -#define FDK_TOOLS_LIB_VL2 1 +#define FDK_TOOLS_LIB_VL2 2 #define FDK_TOOLS_LIB_TITLE "FDK Tools" #define FDK_TOOLS_LIB_BUILD_DATE __DATE__ #define FDK_TOOLS_LIB_BUILD_TIME __TIME__ diff --git a/libFDK/src/fixpoint_math.cpp b/libFDK/src/fixpoint_math.cpp index 78cae2b..30283ff 100644 --- a/libFDK/src/fixpoint_math.cpp +++ b/libFDK/src/fixpoint_math.cpp @@ -242,30 +242,72 @@ FIXP_DBL mul_dbl_sgl_rnd (const FIXP_DBL op1, const FIXP_SGL op2) *****************************************************************************/ LNK_SECTION_CODE_L1 -FIXP_DBL CalcInvLdData(FIXP_DBL op) +/* This table is used for lookup 2^x with */ +/* x in range [0...1.0[ in steps of 1/32 */ +LNK_SECTION_DATA_L1 static const UINT exp2_tab_long[32]={ +0x40000000,0x4166C34C,0x42D561B4,0x444C0740, +0x45CAE0F2,0x47521CC6,0x48E1E9BA,0x4A7A77D4, +0x4C1BF829,0x4DC69CDD,0x4F7A9930,0x51382182, +0x52FF6B55,0x54D0AD5A,0x56AC1F75,0x5891FAC1, +0x5A82799A,0x5C7DD7A4,0x5E8451D0,0x60962665, +0x62B39509,0x64DCDEC3,0x6712460B,0x69540EC9, +0x6BA27E65,0x6DFDDBCC,0x70666F76,0x72DC8374, +0x75606374,0x77F25CCE,0x7A92BE8B,0x7D41D96E +// 0x80000000 +}; + +/* This table is used for lookup 2^x with */ +/* x in range [0...1/32[ in steps of 1/1024 */ +LNK_SECTION_DATA_L1 static const UINT exp2w_tab_long[32]={ +0x40000000,0x400B1818,0x4016321B,0x40214E0C, +0x402C6BE9,0x40378BB4,0x4042AD6D,0x404DD113, +0x4058F6A8,0x40641E2B,0x406F479E,0x407A7300, +0x4085A051,0x4090CF92,0x409C00C4,0x40A733E6, +0x40B268FA,0x40BD9FFF,0x40C8D8F5,0x40D413DD, +0x40DF50B8,0x40EA8F86,0x40F5D046,0x410112FA, +0x410C57A2,0x41179E3D,0x4122E6CD,0x412E3152, +0x41397DCC,0x4144CC3B,0x41501CA0,0x415B6EFB, +// 0x4166C34C, +}; +/* This table is used for lookup 2^x with */ +/* x in range [0...1/1024[ in steps of 1/32768 */ +LNK_SECTION_DATA_L1 static const UINT exp2x_tab_long[32]={ +0x40000000,0x400058B9,0x4000B173,0x40010A2D, +0x400162E8,0x4001BBA3,0x4002145F,0x40026D1B, +0x4002C5D8,0x40031E95,0x40037752,0x4003D011, +0x400428CF,0x4004818E,0x4004DA4E,0x4005330E, +0x40058BCE,0x4005E48F,0x40063D51,0x40069613, +0x4006EED5,0x40074798,0x4007A05B,0x4007F91F, +0x400851E4,0x4008AAA8,0x4009036E,0x40095C33, +0x4009B4FA,0x400A0DC0,0x400A6688,0x400ABF4F, +//0x400B1818 +}; + +LNK_SECTION_CODE_L1 FIXP_DBL CalcInvLdData(FIXP_DBL x) { - FIXP_DBL result_m; + int set_zero = (x < FL2FXCONST_DBL(-31.0/64.0))? 0 : 1; + int set_max = (x >= FL2FXCONST_DBL( 31.0/64.0)) | (x == FL2FXCONST_DBL(0.0)); - if ( op == FL2FXCONST_DBL(0.0f) ) { - result_m = (FIXP_DBL)MAXVAL_DBL; - } - else if ( op < FL2FXCONST_DBL(0.0f) ) { - result_m = f2Pow(op, LD_DATA_SHIFT); - } - else { - int result_e; + FIXP_SGL frac = (FIXP_SGL)(LONG)(x & 0x3FF); + UINT index3 = (UINT)(LONG)(x >> 10) & 0x1F; + UINT index2 = (UINT)(LONG)(x >> 15) & 0x1F; + UINT index1 = (UINT)(LONG)(x >> 20) & 0x1F; + int exp = (x > FL2FXCONST_DBL(0.0f)) ? (31 - (int)(x>>25)) : (int)(-(x>>25)); - result_m = f2Pow(op, LD_DATA_SHIFT, &result_e); - result_e = fixMin(fixMax(result_e+1-(DFRACT_BITS-1), -(DFRACT_BITS-1)), (DFRACT_BITS-1)); /* rounding and saturation */ + UINT lookup1 = exp2_tab_long[index1]*set_zero; + UINT lookup2 = exp2w_tab_long[index2]; + UINT lookup3 = exp2x_tab_long[index3]; + UINT lookup3f = lookup3 + (UINT)(LONG)fMultDiv2((FIXP_DBL)(0x0016302F),(FIXP_SGL)frac); + + UINT lookup12 = (UINT)(LONG)fMult((FIXP_DBL)lookup1, (FIXP_DBL) lookup2); + UINT lookup = (UINT)(LONG)fMult((FIXP_DBL)lookup12, (FIXP_DBL) lookup3f); - if ( (result_e>0) && ( result_m > (((FIXP_DBL)MAXVAL_DBL)>>result_e) ) ) { - result_m = (FIXP_DBL)MAXVAL_DBL; /* saturate to max representable value */ - } - else { - result_m = (scaleValue(result_m, result_e)+(FIXP_DBL)1)>>1; /* descale result + rounding */ - } - } - return result_m; + FIXP_DBL retVal = (lookup<<3) >> exp; + + if (set_max) + retVal=FL2FXCONST_DBL(1.0f); + + return retVal; } -- cgit v1.2.3 From fa3eba16446cc8f2f5e2dfc20d86a49dbd37299e Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Thu, 29 Aug 2013 16:05:22 -0700 Subject: Encoder 7.1 support * AAC-Encoder - Add 7.1 rear surround and 7.1 front center support to supported encoder channel modes. Change max channels from 6 to 8 and add 7.1 configuration to bandwidth and channel mapping functions. Modified file(s): libAACenc\include\aacenc_lib.h libAACenc\src\aacEnc_ram.cpp libAACenc\src\aacEnc_ram.h libAACenc\src\aacenc.cpp libAACenc\src\aacenc.h libAACenc\src\aacenc_lib.cpp libAACenc\src\adj_thr.cpp libAACenc\src\adj_thr.h libAACenc\src\adj_thr_data.h libAACenc\src\bandwidth.cpp libAACenc\src\bitenc.cpp libAACenc\src\channel_map.cpp libAACenc\src\interface.h libAACenc\src\metadata_compressor.cpp libAACenc\src\psy_main.cpp libAACenc\src\psy_main.h libAACenc\src\qc_data.h libAACenc\src\qc_main.cpp libAACenc\src\qc_main.h * SBR-Encoder - Support up to 7.1 audio channels. Changed max channels from 6 to 8. Modified file(s): libSBRenc\include\sbr_encoder.h libSBRenc\src\sbr.h libSBRenc\src\sbr_encoder.cpp libSBRenc\src\sbr_ram.cpp * Transport-Encoder - Add 7.1 channel configuration to audio specific config writer in transport encoder library. Modified file(s): libMpegTPEnc\src\tpenc_asc.cpp libMpegTPEnc\src\version * SYS-Library - Add 7.1 channel modes to CHANNEL_MODE description. Modified file(s): libSYS\include\FDK_audio.h libSYS\src\genericStds.cpp Bug 9428126 Change-Id: Ide53583aa8e03df4537b98db80740dfe0e7a9e0f --- libAACenc/include/aacenc_lib.h | 50 ++++++++++++++++++-------------- libAACenc/src/aacEnc_ram.cpp | 16 +++++------ libAACenc/src/aacEnc_ram.h | 4 +-- libAACenc/src/aacenc.cpp | 2 +- libAACenc/src/aacenc.h | 2 +- libAACenc/src/aacenc_lib.cpp | 28 +++++++++--------- libAACenc/src/adj_thr.cpp | 54 +++++++++++++++++------------------ libAACenc/src/adj_thr.h | 8 +++--- libAACenc/src/adj_thr_data.h | 2 +- libAACenc/src/bandwidth.cpp | 4 +++ libAACenc/src/bitenc.cpp | 2 +- libAACenc/src/channel_map.cpp | 51 +++++++++++++++++++-------------- libAACenc/src/interface.h | 4 +-- libAACenc/src/metadata_compressor.cpp | 27 ++++++++++++------ libAACenc/src/psy_main.cpp | 8 +++--- libAACenc/src/psy_main.h | 4 +-- libAACenc/src/qc_data.h | 8 +++--- libAACenc/src/qc_main.cpp | 26 ++++++++--------- libAACenc/src/qc_main.h | 2 +- libMpegTPEnc/src/tpenc_asc.cpp | 12 +++++--- libMpegTPEnc/src/version | 2 +- libSBRenc/include/sbr_encoder.h | 6 ++-- libSBRenc/src/sbr.h | 6 ++-- libSBRenc/src/sbr_encoder.cpp | 16 +++++------ libSBRenc/src/sbr_ram.cpp | 30 +++++++++---------- libSYS/include/FDK_audio.h | 48 +++++++++++++++++-------------- libSYS/src/genericStds.cpp | 2 +- 27 files changed, 231 insertions(+), 193 deletions(-) (limited to 'libAACenc/src/interface.h') diff --git a/libAACenc/include/aacenc_lib.h b/libAACenc/include/aacenc_lib.h index f693bf5..8c0e1cd 100644 --- a/libAACenc/include/aacenc_lib.h +++ b/libAACenc/include/aacenc_lib.h @@ -377,16 +377,20 @@ For user defined Configurations the Channel Configuration is set to 0 and the Ch Program Config Element. The present Encoder implementation does not allow the user to configure this Channel Configuration from extern. The Encoder implementation supports fixed Channel Modes which are mapped to Channel Configuration as follow. \verbatim --------------------------------------------------------------------- - ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El ------------------+--------+----------+----------+----------+-------- -MODE_1 | 1 | SCE | | | -MODE_2 | 2 | CPE | | | -MODE_1_2 | 3 | SCE, CPE | | | -MODE_1_2_1 | 4 | SCE, CPE | | SCE | -MODE_1_2_2 | 5 | SCE, CPE | | CPE | -MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE --------------------------------------------------------------------- +------------------------------------------------------------------------------- + ChannelMode | ChCfg | front_El | side_El | back_El | lfe_El +-----------------------+--------+---------------+----------+----------+-------- +MODE_1 | 1 | SCE | | | +MODE_2 | 2 | CPE | | | +MODE_1_2 | 3 | SCE, CPE | | | +MODE_1_2_1 | 4 | SCE, CPE | | SCE | +MODE_1_2_2 | 5 | SCE, CPE | | CPE | +MODE_1_2_2_1 | 6 | SCE, CPE | | CPE | LFE +MODE_1_2_2_2_1 | 7 | SCE, CPE, CPE | | CPE | LFE +-----------------------+--------+---------------+----------+----------+-------- +MODE_7_1_REAR_SURROUND | 0 | SCE, CPE | | CPE, CPE | LFE +MODE_7_1_FRONT_CENTER | 0 | SCE, CPE, CPE | | CPE | LFE +------------------------------------------------------------------------------- - SCE: Single Channel Element. - CPE: Channel Pair. - SCE: Low Frequency Element. @@ -402,16 +406,20 @@ Beside the Channel Element assignment the Channel Modes are resposible for audio of the audio data depends on the selected ::AACENC_CHANNELORDER which can be MPEG or WAV like order.\n Following Table describes the complete channel mapping for both Channel Order configurations. \verbatim ---------------------------------------------------------------------------------- -ChannelMode | MPEG-Channelorder | WAV-Channelorder ------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--- -MODE_1 | 0 | | | | | | | | 0 | | | | | | | -MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | | -MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | | -MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | | -MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | | -MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | | ---------------------------------------------------------------------------------- +--------------------------------------------------------------------------------------- +ChannelMode | MPEG-Channelorder | WAV-Channelorder +-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--- +MODE_1 | 0 | | | | | | | | 0 | | | | | | | +MODE_2 | 0 | 1 | | | | | | | 0 | 1 | | | | | | +MODE_1_2 | 0 | 1 | 2 | | | | | | 2 | 0 | 1 | | | | | +MODE_1_2_1 | 0 | 1 | 2 | 3 | | | | | 2 | 0 | 1 | 3 | | | | +MODE_1_2_2 | 0 | 1 | 2 | 3 | 4 | | | | 2 | 0 | 1 | 3 | 4 | | | +MODE_1_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | | | 2 | 0 | 1 | 4 | 5 | 3 | | +MODE_1_2_2_2_1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3 +-----------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--- +MODE_7_1_REAR_SURROUND | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 0 | 1 | 6 | 7 | 4 | 5 | 3 +MODE_7_1_FRONT_CENTER | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 2 | 6 | 7 | 0 | 1 | 4 | 5 | 3 +--------------------------------------------------------------------------------------- \endverbatim The denoted mapping is important for correct audio channel assignment when using MPEG or WAV ordering. The incoming audio @@ -920,7 +928,7 @@ typedef enum - 480: Optional length in LD/ELD configuration. */ AACENC_CHANNELMODE = 0x0106, /*!< Set explicit channel mode. Channel mode must match with number of input channels. - - 1-6: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */ + - 1-7 and 33,34: MPEG channel modes supported, see ::CHANNEL_MODE in FDK_audio.h. */ AACENC_CHANNELORDER = 0x0107, /*!< Input audio data channel ordering scheme: - 0: MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE). (default) diff --git a/libAACenc/src/aacEnc_ram.cpp b/libAACenc/src/aacEnc_ram.cpp index 1844331..be3eea2 100644 --- a/libAACenc/src/aacEnc_ram.cpp +++ b/libAACenc/src/aacEnc_ram.cpp @@ -119,12 +119,12 @@ C_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC, 1) PsyInputBuffer. */ -C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (6)) +C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (8)) C_ALLOC_MEM (Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1) -C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (6)) +C_ALLOC_MEM2 (Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8)) -C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6)) +C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8)) PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic (int n, UCHAR* dynamic_RAM) { FDK_ASSERT(dynamic_RAM!=0); @@ -139,8 +139,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (6)) */ C_ALLOC_MEM2 (Ram_aacEnc_PsyOut, PSY_OUT, 1, (1)) -C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(6)) -C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6)) +C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(8)) +C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(8)) /* @@ -155,8 +155,8 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1)*(6)) C_ALLOC_MEM (Ram_aacEnc_QCstate, QC_STATE, 1) C_ALLOC_MEM (Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1) -C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (6)) -C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (6)) +C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (8)) +C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (8)) C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1) INT *GetRam_aacEnc_BitLookUp(int n, UCHAR* dynamic_RAM) { @@ -175,7 +175,7 @@ C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1) */ C_ALLOC_MEM2 (Ram_aacEnc_QCout, QC_OUT, 1, (1)) -C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (6)) +C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (8)) QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel (int n, UCHAR* dynamic_RAM) { FDK_ASSERT(dynamic_RAM!=0); return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL))); diff --git a/libAACenc/src/aacEnc_ram.h b/libAACenc/src/aacEnc_ram.h index d2cad60..cf7da7c 100644 --- a/libAACenc/src/aacEnc_ram.h +++ b/libAACenc/src/aacEnc_ram.h @@ -118,7 +118,7 @@ amm-info@iis.fraunhofer.de */ /* define hBitstream size: max AAC framelength is 6144 bits/channel */ -/*#define BUFFER_BITSTR_SIZE ((6400*(6)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/ +/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/ struct AAC_ENC { @@ -173,7 +173,7 @@ struct AAC_ENC { ++++++++++++++++++++++++++++++++++++++++++++ */ -#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(6)) ) +#define BUF_SIZE_0 ( ALIGN_SIZE(sizeof(QC_OUT_CHANNEL)*(8)) ) #define BUF_SIZE_1 ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \ (BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) ) diff --git a/libAACenc/src/aacenc.cpp b/libAACenc/src/aacenc.cpp index 6ce7b22..569662b 100644 --- a/libAACenc/src/aacenc.cpp +++ b/libAACenc/src/aacenc.cpp @@ -393,7 +393,7 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc, /******************* sanity checks *******************/ /* check config structure */ - if (config->nChannels < 1 || config->nChannels > (6)) { + if (config->nChannels < 1 || config->nChannels > (8)) { return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; } diff --git a/libAACenc/src/aacenc.h b/libAACenc/src/aacenc.h index f07bc17..87fc3e8 100644 --- a/libAACenc/src/aacenc.h +++ b/libAACenc/src/aacenc.h @@ -154,7 +154,7 @@ typedef enum { #define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */ -#define MAX_TOTAL_EXT_PAYLOADS (((6) * (1)) + (2+2)) +#define MAX_TOTAL_EXT_PAYLOADS (((8) * (1)) + (2+2)) typedef enum { diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp index 056958b..49f8225 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 11 +#define AACENCODER_LIB_VL2 12 #define AACENCODER_LIB_TITLE "AAC Encoder" #define AACENCODER_LIB_BUILD_DATE __DATE__ #define AACENCODER_LIB_BUILD_TIME __TIME__ @@ -215,8 +215,8 @@ struct AACENCODER AACENC_EXT_PAYLOAD extPayload [MAX_TOTAL_EXT_PAYLOADS]; /* Extension payload */ - UCHAR extPayloadData [(1)][(6)][MAX_PAYLOAD_SIZE]; - UINT extPayloadSize [(1)][(6)]; /* payload sizes in bits */ + UCHAR extPayloadData [(1)][(8)][MAX_PAYLOAD_SIZE]; + UINT extPayloadSize [(1)][(8)]; /* payload sizes in bits */ ULONG InitFlags; /* internal status to treggier re-initialization */ @@ -699,8 +699,8 @@ INT aacEncoder_LimitBitrate( /* Find total bitrate which provides valid configuration for each SBR element. */ do { int e; - SBR_ELEMENT_INFO sbrElInfo[(6)]; - FDK_ASSERT(cm.nElements <= (6)); + SBR_ELEMENT_INFO sbrElInfo[(8)]; + FDK_ASSERT(cm.nElements <= (8)); initialBitrate = adjustedBitrate; @@ -1061,7 +1061,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder, ((InitFlags & AACENC_INIT_CONFIG) || (InitFlags & AACENC_INIT_STATES)) ) { INT sbrError; - SBR_ELEMENT_INFO sbrElInfo[(6)]; + SBR_ELEMENT_INFO sbrElInfo[(8)]; CHANNEL_MAPPING channelMapping; if ( FDKaacEnc_InitChannelMapping(hAacConfig->channelMode, @@ -1072,7 +1072,7 @@ static AACENC_ERROR aacEncInit(HANDLE_AACENCODER hAacEncoder, } /* Check return value and if the SBR encoder can handle enough elements */ - if (channelMapping.nElements > (6)) { + if (channelMapping.nElements > (8)) { return AACENC_INIT_ERROR; } @@ -1249,8 +1249,8 @@ AACENC_ERROR aacEncOpen( /* Determine max channel configuration. */ if (maxChannels==0) { - hAacEncoder->nMaxAacChannels = (6); - hAacEncoder->nMaxSbrChannels = (6); + hAacEncoder->nMaxAacChannels = (8); + hAacEncoder->nMaxSbrChannels = (8); } else { hAacEncoder->nMaxAacChannels = (maxChannels&0x00FF); @@ -1258,15 +1258,15 @@ AACENC_ERROR aacEncOpen( hAacEncoder->nMaxSbrChannels = (maxChannels&0xFF00) ? (maxChannels>>8) : hAacEncoder->nMaxAacChannels; } - if ( (hAacEncoder->nMaxAacChannels>(6)) || (hAacEncoder->nMaxSbrChannels>(6)) ) { + if ( (hAacEncoder->nMaxAacChannels>(8)) || (hAacEncoder->nMaxSbrChannels>(8)) ) { err = AACENC_INVALID_CONFIG; goto bail; } } /* maxChannels==0 */ /* Max number of elements could be tuned any more. */ - hAacEncoder->nMaxAacElements = fixMin((6), hAacEncoder->nMaxAacChannels); - hAacEncoder->nMaxSbrElements = fixMin((6), hAacEncoder->nMaxSbrChannels); + hAacEncoder->nMaxAacElements = fixMin((8), hAacEncoder->nMaxAacChannels); + hAacEncoder->nMaxSbrElements = fixMin((8), hAacEncoder->nMaxSbrChannels); hAacEncoder->nMaxSubFrames = (1); @@ -1595,7 +1595,7 @@ AACENC_ERROR aacEncEncode( } else { /* Add SBR extension payload */ - for (i = 0; i < (6); i++) { + for (i = 0; i < (8); i++) { if (hAacEncoder->extPayloadSize[nPayload][i] > 0) { hAacEncoder->extPayload[nExtensions].pData = hAacEncoder->extPayloadData[nPayload][i]; { @@ -1850,7 +1850,7 @@ AACENC_ERROR aacEncoder_SetParam( } if ( (pConfig->nElements > hAacEncoder->nMaxAacElements) || (pConfig->nChannelsEff > hAacEncoder->nMaxAacChannels) - || !((value>=1) && (value<=6)) + || !(((value>=1) && (value<=7))||((value>=33) && (value<=34))) ) { err = AACENC_INVALID_CONFIG; diff --git a/libAACenc/src/adj_thr.cpp b/libAACenc/src/adj_thr.cpp index 0bd5827..6433633 100644 --- a/libAACenc/src/adj_thr.cpp +++ b/libAACenc/src/adj_thr.cpp @@ -1137,12 +1137,12 @@ the difference can be distributed among the scale factor bands. New thresholds can be derived from this pe-difference *****************************************************************************/ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, - QC_OUT_ELEMENT* qcElement[(6)], - PSY_OUT_ELEMENT* psyOutElement[(6)], - UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB], - FIXP_DBL thrExp[(6)][(2)][MAX_GROUPED_SFB], - const FIXP_DBL redVal[(6)], - const SCHAR redValScaling[(6)], + QC_OUT_ELEMENT* qcElement[(8)], + PSY_OUT_ELEMENT* psyOutElement[(8)], + UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB], + FIXP_DBL thrExp[(8)][(2)][MAX_GROUPED_SFB], + const FIXP_DBL redVal[(8)], + const SCHAR redValScaling[(8)], const INT deltaPe, const INT processElements, const INT elementOffset) @@ -1153,8 +1153,8 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, PE_CHANNEL_DATA *peChanData; FIXP_DBL thrFactorLdData; FIXP_DBL sfbEnLdData, sfbThrLdData, sfbThrReducedLdData; - FIXP_DBL *sfbPeFactorsLdData[(6)][(2)]; - FIXP_DBL sfbNActiveLinesLdData[(6)][(2)][MAX_GROUPED_SFB]; + FIXP_DBL *sfbPeFactorsLdData[(8)][(2)]; + FIXP_DBL sfbNActiveLinesLdData[(8)][(2)][MAX_GROUPED_SFB]; INT normFactorInt; FIXP_DBL normFactorLdData; @@ -1308,9 +1308,9 @@ static void FDKaacEnc_correctThresh(CHANNEL_MAPPING* cm, reducing minSnr *****************************************************************************/ void FDKaacEnc_reduceMinSnr(CHANNEL_MAPPING* cm, - QC_OUT_ELEMENT* qcElement[(6)], - PSY_OUT_ELEMENT* psyOutElement[(6)], - UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB], + QC_OUT_ELEMENT* qcElement[(8)], + PSY_OUT_ELEMENT* psyOutElement[(8)], + UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB], const INT desiredPe, INT* redPeGlobal, const INT processElements, @@ -1410,10 +1410,10 @@ bail: bands have to be quantized to zero *****************************************************************************/ static void FDKaacEnc_allowMoreHoles(CHANNEL_MAPPING* cm, - QC_OUT_ELEMENT* qcElement[(6)], - PSY_OUT_ELEMENT* psyOutElement[(6)], - ATS_ELEMENT* AdjThrStateElement[(6)], - UCHAR ahFlag[(6)][(2)][MAX_GROUPED_SFB], + QC_OUT_ELEMENT* qcElement[(8)], + PSY_OUT_ELEMENT* psyOutElement[(8)], + ATS_ELEMENT* AdjThrStateElement[(8)], + UCHAR ahFlag[(8)][(2)][MAX_GROUPED_SFB], const INT desiredPe, const INT currentPe, const int processElements, @@ -1645,17 +1645,17 @@ functionname: FDKaacEnc_adaptThresholdsToPe description: two guesses for the reduction value and one final correction of the thresholds *****************************************************************************/ static void FDKaacEnc_adaptThresholdsToPe(CHANNEL_MAPPING* cm, - ATS_ELEMENT* AdjThrStateElement[(6)], - QC_OUT_ELEMENT* qcElement[(6)], - PSY_OUT_ELEMENT* psyOutElement[(6)], + ATS_ELEMENT* AdjThrStateElement[(8)], + QC_OUT_ELEMENT* qcElement[(8)], + PSY_OUT_ELEMENT* psyOutElement[(8)], const INT desiredPe, const INT processElements, const INT elementOffset) { - FIXP_DBL redValue[(6)]; - SCHAR redValScaling[(6)]; - UCHAR pAhFlag[(6)][(2)][MAX_GROUPED_SFB]; - FIXP_DBL pThrExp[(6)][(2)][MAX_GROUPED_SFB]; + FIXP_DBL redValue[(8)]; + SCHAR redValScaling[(8)]; + UCHAR pAhFlag[(8)][(2)][MAX_GROUPED_SFB]; + FIXP_DBL pThrExp[(8)][(2)][MAX_GROUPED_SFB]; int iter; INT constPartGlobal, noRedPeGlobal, nActiveLinesGlobal, redPeGlobal; @@ -2219,7 +2219,7 @@ description: initialize ADJ_THR_STATE void FDKaacEnc_AdjThrInit( ADJ_THR_STATE *hAdjThr, const INT meanPe, - ELEMENT_BITS *elBits[(6)], + ELEMENT_BITS *elBits[(8)], INT invQuant, INT nElements, INT nChannelsEff, @@ -2540,10 +2540,10 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, functionname: FDKaacEnc_AdjustThresholds description: adjust thresholds *****************************************************************************/ -void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)], - QC_OUT_ELEMENT* qcElement[(6)], +void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)], + QC_OUT_ELEMENT* qcElement[(8)], QC_OUT* qcOut, - PSY_OUT_ELEMENT* psyOutElement[(6)], + PSY_OUT_ELEMENT* psyOutElement[(8)], INT CBRbitrateMode, CHANNEL_MAPPING* cm) { @@ -2620,7 +2620,7 @@ void FDKaacEnc_AdjThrClose(ADJ_THR_STATE** phAdjThr) ADJ_THR_STATE* hAdjThr = *phAdjThr; if (hAdjThr!=NULL) { - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (hAdjThr->adjThrStateElem[i]!=NULL) { FreeRam_aacEnc_AdjThrStateElement(&hAdjThr->adjThrStateElem[i]); } diff --git a/libAACenc/src/adj_thr.h b/libAACenc/src/adj_thr.h index a429dff..69b1dcc 100644 --- a/libAACenc/src/adj_thr.h +++ b/libAACenc/src/adj_thr.h @@ -112,7 +112,7 @@ INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr, void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr, const INT peMean, - ELEMENT_BITS* elBits[(6)], + ELEMENT_BITS* elBits[(8)], INT invQuant, INT nElements, INT nChannelsEff, @@ -135,10 +135,10 @@ void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, const FIXP_DBL maxBitFac, const INT bitDistributionMode); -void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(6)], - QC_OUT_ELEMENT* qcElement[(6)], +void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)], + QC_OUT_ELEMENT* qcElement[(8)], QC_OUT* qcOut, - PSY_OUT_ELEMENT* psyOutElement[(6)], + PSY_OUT_ELEMENT* psyOutElement[(8)], INT CBRbitrateMode, CHANNEL_MAPPING* cm); diff --git a/libAACenc/src/adj_thr_data.h b/libAACenc/src/adj_thr_data.h index 675393e..3eb7678 100644 --- a/libAACenc/src/adj_thr_data.h +++ b/libAACenc/src/adj_thr_data.h @@ -144,7 +144,7 @@ typedef struct { typedef struct { BRES_PARAM bresParamLong, bresParamShort; - ATS_ELEMENT* adjThrStateElem[(6)]; + ATS_ELEMENT* adjThrStateElem[(8)]; } ADJ_THR_STATE; #endif diff --git a/libAACenc/src/bandwidth.cpp b/libAACenc/src/bandwidth.cpp index da9b850..6fc7d87 100644 --- a/libAACenc/src/bandwidth.cpp +++ b/libAACenc/src/bandwidth.cpp @@ -316,6 +316,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth, case MODE_1_2_2: case MODE_1_2_2_1: case MODE_1_2_2_2_1: + case MODE_7_1_REAR_SURROUND: + case MODE_7_1_FRONT_CENTER: *bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan; break; default: @@ -346,6 +348,8 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth, case MODE_1_2_2: /* sce + cpe + cpe */ case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */ case MODE_1_2_2_2_1: /* (7.1) sce + cpe + cpe + cpe + lfe */ + case MODE_7_1_REAR_SURROUND: + case MODE_7_1_FRONT_CENTER: entryNo = 1; /* use stereo bandwith settings */ break; diff --git a/libAACenc/src/bitenc.cpp b/libAACenc/src/bitenc.cpp index 5e9eaf9..8e477aa 100644 --- a/libAACenc/src/bitenc.cpp +++ b/libAACenc/src/bitenc.cpp @@ -1360,7 +1360,7 @@ AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc, if ( (syntaxFlags & AC_ER) && !(syntaxFlags & AC_DRM) ) { - UCHAR channelElementExtensionWritten[(6)][(1)]; /* 0: extension not touched, 1: extension already written */ + UCHAR channelElementExtensionWritten[(8)][(1)]; /* 0: extension not touched, 1: extension already written */ FDKmemclear(channelElementExtensionWritten, sizeof(channelElementExtensionWritten)); diff --git a/libAACenc/src/channel_map.cpp b/libAACenc/src/channel_map.cpp index 352f48c..559a4ce 100644 --- a/libAACenc/src/channel_map.cpp +++ b/libAACenc/src/channel_map.cpp @@ -124,7 +124,7 @@ amm-info@iis.fraunhofer.de typedef struct { CHANNEL_MODE encoderMode; - INT channel_assignment[/*(6)*/12]; + INT channel_assignment[/*(8)*/12]; } CHANNEL_ASSIGNMENT_INFO_TAB; @@ -139,6 +139,8 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabMpeg[] = { MODE_1_2_2, { 0, 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */ { MODE_1_2_2_1, { 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */ { MODE_1_2_2_2_1, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */ + { MODE_7_1_REAR_SURROUND, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */ + { MODE_7_1_FRONT_CENTER, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} } /* 7.1ch */ }; static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] = @@ -150,7 +152,9 @@ static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] = { MODE_1_2_1, { 2, 0, 1, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */ { MODE_1_2_2, { 2, 0, 1, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */ { MODE_1_2_2_1, { 2, 0, 1, 4, 5, 3,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */ - { MODE_1_2_2_2_1, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */ + { MODE_1_2_2_2_1, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */ + { MODE_7_1_REAR_SURROUND, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */ + { MODE_7_1_FRONT_CENTER, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */ }; /* Channel mode configuration tab provides, @@ -165,6 +169,8 @@ static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] = { MODE_1_2_2, 5, 5, 3 }, /* SCE,CPE,CPE */ { MODE_1_2_2_1, 6, 5, 4 }, /* SCE,CPE,CPE,LFE */ { MODE_1_2_2_2_1, 8, 7, 5 }, /* SCE,CPE,CPE,CPE,LFE */ + { MODE_7_1_REAR_SURROUND, 8, 7, 5 }, + { MODE_7_1_FRONT_CENTER, 8, 7, 5 }, }; #define MAX_MODES (sizeof(assignmentInfoTabWav)/sizeof(CHANNEL_ASSIGNMENT_INFO_TAB)) @@ -315,6 +321,8 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER break; case MODE_1_2_2_2_1: + case MODE_7_1_REAR_SURROUND: + case MODE_7_1_FRONT_CENTER: /* (7.1) sce + cpe + cpe + cpe + lfe */ FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.18f)); FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f)); @@ -322,14 +330,13 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f)); FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.04f)); break; - default: //*chMap=0; return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; }; - FDK_ASSERT(cm->nElements<=(6)); + FDK_ASSERT(cm->nElements<=(8)); return AAC_ENC_OK; @@ -442,19 +449,18 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC, break; } - - case MODE_1_2_2_2_1:{ - /* (7.1) sce + cpe + cpe + cpe + lfe */ - hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits; - hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits; - hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits; - hQC->elementBits[3]->relativeBitsEl = cm->elInfo[3].relativeBits; - hQC->elementBits[4]->relativeBitsEl = cm->elInfo[4].relativeBits; - FIXP_DBL sceRate = cm->elInfo[0].relativeBits; - FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits; - FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits; - FIXP_DBL cpe3Rate = cm->elInfo[3].relativeBits; - FIXP_DBL lfeRate = cm->elInfo[4].relativeBits; + case MODE_7_1_REAR_SURROUND: + case MODE_7_1_FRONT_CENTER: + case MODE_1_2_2_2_1: { + int cpe3Idx = 3; + int lfeIdx = 4; + + /* (7.1) sce + cpe + cpe + cpe + lfe */ + FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits; + FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits; + FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits; + FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl = cm->elInfo[cpe3Idx].relativeBits; + FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl = cm->elInfo[lfeIdx].relativeBits; int maxBitsTot = maxChannelBits * 7; /* LFE does not add to bit reservoir */ int sc = CountLeadingBits(fixMax(maxChannelBits,averageBitsTot)); @@ -466,17 +472,16 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC, hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<>sc_brTot; hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<>(sc_brTot+1); hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<>(sc_brTot+1); - hQC->elementBits[3]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<>(sc_brTot+1); - hQC->elementBits[4]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<>sc_brTot; + hQC->elementBits[cpe3Idx]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<>(sc_brTot+1); + hQC->elementBits[lfeIdx]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<>sc_brTot; hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2*maxChannelBits; hQC->elementBits[2]->maxBitsEl = 2*maxChannelBits; - hQC->elementBits[3]->maxBitsEl = 2*maxChannelBits; - hQC->elementBits[4]->maxBitsEl = maxLfeBits; + hQC->elementBits[cpe3Idx]->maxBitsEl = 2*maxChannelBits; + hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits; break; } - default: return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; } @@ -518,6 +523,8 @@ ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode){ case MODE_1_2_2: case MODE_1_2_2_1: case MODE_1_2_2_2_1: + case MODE_7_1_REAR_SURROUND: + case MODE_7_1_FRONT_CENTER: monoStereoSetting = EL_MODE_STEREO; break; default: /* error */ diff --git a/libAACenc/src/interface.h b/libAACenc/src/interface.h index 2ec1852..51fb72a 100644 --- a/libAACenc/src/interface.h +++ b/libAACenc/src/interface.h @@ -156,8 +156,8 @@ typedef struct { typedef struct { - PSY_OUT_ELEMENT* psyOutElement[(6)]; - PSY_OUT_CHANNEL* pPsyOutChannels[(6)]; + PSY_OUT_ELEMENT* psyOutElement[(8)]; + PSY_OUT_CHANNEL* pPsyOutChannels[(8)]; }PSY_OUT; diff --git a/libAACenc/src/metadata_compressor.cpp b/libAACenc/src/metadata_compressor.cpp index 6fd8266..876de57 100644 --- a/libAACenc/src/metadata_compressor.cpp +++ b/libAACenc/src/metadata_compressor.cpp @@ -539,14 +539,25 @@ INT FDK_DRC_Generator_Initialize( drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1]; break; case MODE_1_2_2_2_1: /* 7.1 ch */ - drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0]; - drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1]; - drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; - drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; - drcComp->channelIdx[LS] = channelMapping.elInfo[2].ChannelIndex[0]; - drcComp->channelIdx[RS] = channelMapping.elInfo[2].ChannelIndex[1]; - drcComp->channelIdx[LS2] = channelMapping.elInfo[3].ChannelIndex[0]; - drcComp->channelIdx[RS2] = channelMapping.elInfo[3].ChannelIndex[1]; + case MODE_7_1_FRONT_CENTER: + drcComp->channelIdx[L] = channelMapping.elInfo[2].ChannelIndex[0]; /* l */ + drcComp->channelIdx[R] = channelMapping.elInfo[2].ChannelIndex[1]; /* r */ + drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */ + drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */ + drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* ls */ + drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rs */ + drcComp->channelIdx[LS2] = channelMapping.elInfo[1].ChannelIndex[0]; /* lc */ + drcComp->channelIdx[RS2] = channelMapping.elInfo[1].ChannelIndex[1]; /* rc */ + break; + case MODE_7_1_REAR_SURROUND: + drcComp->channelIdx[L] = channelMapping.elInfo[1].ChannelIndex[0]; /* l */ + drcComp->channelIdx[R] = channelMapping.elInfo[1].ChannelIndex[1]; /* r */ + drcComp->channelIdx[C] = channelMapping.elInfo[0].ChannelIndex[0]; /* c */ + drcComp->channelIdx[LFE] = channelMapping.elInfo[4].ChannelIndex[0]; /* lfe */ + drcComp->channelIdx[LS] = channelMapping.elInfo[3].ChannelIndex[0]; /* lrear */ + drcComp->channelIdx[RS] = channelMapping.elInfo[3].ChannelIndex[1]; /* rrear */ + drcComp->channelIdx[LS2] = channelMapping.elInfo[2].ChannelIndex[0]; /* ls */ + drcComp->channelIdx[RS2] = channelMapping.elInfo[2].ChannelIndex[1]; /* rs */ break; case MODE_1_1: case MODE_1_1_1_1: diff --git a/libAACenc/src/psy_main.cpp b/libAACenc/src/psy_main.cpp index 0949b6d..59193c7 100644 --- a/libAACenc/src/psy_main.cpp +++ b/libAACenc/src/psy_main.cpp @@ -1340,7 +1340,7 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal, if (hPsyInternal) { - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (hPsyInternal->pStaticChannels[i]) { if (hPsyInternal->pStaticChannels[i]->psyInputBuffer) FreeRam_aacEnc_PsyInputBuffer(&hPsyInternal->pStaticChannels[i]->psyInputBuffer); /* AUDIO INPUT BUFFER */ @@ -1349,7 +1349,7 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal, } } - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (hPsyInternal->psyElement[i]) FreeRam_aacEnc_PsyElement(&hPsyInternal->psyElement[i]); /* PSY_ELEMENT */ } @@ -1363,12 +1363,12 @@ void FDKaacEnc_PsyClose(PSY_INTERNAL **phPsyInternal, for (n=0; n<(1); n++) { if (phPsyOut[n]) { - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (phPsyOut[n]->pPsyOutChannels[i]) FreeRam_aacEnc_PsyOutChannel(&phPsyOut[n]->pPsyOutChannels[i]); /* PSY_OUT_CHANNEL */ } - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (phPsyOut[n]->psyOutElement[i]) FreeRam_aacEnc_PsyOutElements(&phPsyOut[n]->psyOutElement[i]); /* PSY_OUT_ELEMENTS */ } diff --git a/libAACenc/src/psy_main.h b/libAACenc/src/psy_main.h index 29edca5..7bdcc38 100644 --- a/libAACenc/src/psy_main.h +++ b/libAACenc/src/psy_main.h @@ -117,8 +117,8 @@ typedef struct { typedef struct { PSY_CONFIGURATION psyConf[2]; /* LONG / SHORT */ - PSY_ELEMENT* psyElement[(6)]; - PSY_STATIC* pStaticChannels[(6)]; + PSY_ELEMENT* psyElement[(8)]; + PSY_STATIC* pStaticChannels[(8)]; PSY_DYNAMIC* psyDynamic; INT granuleLength; diff --git a/libAACenc/src/qc_data.h b/libAACenc/src/qc_data.h index 51e66c6..a9309c8 100644 --- a/libAACenc/src/qc_data.h +++ b/libAACenc/src/qc_data.h @@ -127,7 +127,7 @@ typedef struct { INT nChannels; INT nChannelsEff; INT nElements; - ELEMENT_INFO elInfo[(6)]; + ELEMENT_INFO elInfo[(8)]; } CHANNEL_MAPPING; typedef struct { @@ -217,8 +217,8 @@ typedef struct typedef struct { - QC_OUT_ELEMENT *qcElement[(6)]; - QC_OUT_CHANNEL *pQcOutChannels[(6)]; + QC_OUT_ELEMENT *qcElement[(8)]; + QC_OUT_CHANNEL *pQcOutChannels[(8)]; QC_OUT_EXTENSION extension[(2+2)]; /* global extension payload */ INT nExtensions; /* number of extension payloads for this AU */ INT maxDynBits; /* maximal allowed dynamic bits in frame */ @@ -265,7 +265,7 @@ typedef struct PADDING padding; - ELEMENT_BITS *elementBits[(6)]; + ELEMENT_BITS *elementBits[(8)]; BITCNTR_STATE *hBitCounter; ADJ_THR_STATE *hAdjThr; diff --git a/libAACenc/src/qc_main.cpp b/libAACenc/src/qc_main.cpp index 15646e9..b74510a 100644 --- a/libAACenc/src/qc_main.cpp +++ b/libAACenc/src/qc_main.cpp @@ -511,7 +511,7 @@ AAC_ENCODER_ERROR FDKaacEnc_AdjustBitrate(QC_STATE *RESTRICT hQC, } static AAC_ENCODER_ERROR FDKaacEnc_distributeElementDynBits(QC_STATE* hQC, - QC_OUT_ELEMENT* qcElement[(6)], + QC_OUT_ELEMENT* qcElement[(8)], CHANNEL_MAPPING* cm, INT codeBits) { @@ -610,7 +610,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h PSY_OUT** psyOut, QC_OUT** qcOut, CHANNEL_MAPPING* cm, - QC_OUT_ELEMENT* qcElement[(1)][(6)], + QC_OUT_ELEMENT* qcElement[(1)][(8)], INT avgTotalBits, INT *totalAvailableBits, INT *avgTotalDynBits) @@ -677,7 +677,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_prepareBitDistribution(QC_STATE* h //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static AAC_ENCODER_ERROR FDKaacEnc_updateUsedDynBits(INT* sumDynBitsConsumed, - QC_OUT_ELEMENT* qcElement[(6)], + QC_OUT_ELEMENT* qcElement[(8)], CHANNEL_MAPPING* cm) { INT i; @@ -720,7 +720,7 @@ static INT FDKaacEnc_getTotalConsumedDynBits(QC_OUT** qcOut, } static INT FDKaacEnc_getTotalConsumedBits(QC_OUT** qcOut, - QC_OUT_ELEMENT* qcElement[(1)][(6)], + QC_OUT_ELEMENT* qcElement[(1)][(8)], CHANNEL_MAPPING* cm, INT globHdrBits, INT nSubFrames) @@ -820,7 +820,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC, /*-------------------------------------------- */ /* helper pointer */ - QC_OUT_ELEMENT* qcElement[(1)][(6)]; + QC_OUT_ELEMENT* qcElement[(1)][(8)]; /* work on a copy of qcChannel and qcElement */ for (i=0; inElements; i++) @@ -897,10 +897,10 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC, } /* -end- sub frame counter */ /*-------------------------------------------- */ - INT iterations[(1)][(6)]; - INT chConstraintsFulfilled[(1)][(6)][(2)]; - INT calculateQuant[(1)][(6)][(2)]; - INT constraintsFulfilled[(1)][(6)]; + INT iterations[(1)][(8)]; + INT chConstraintsFulfilled[(1)][(8)][(2)]; + INT calculateQuant[(1)][(8)][(2)]; + INT constraintsFulfilled[(1)][(8)]; /*-------------------------------------------- */ @@ -1247,7 +1247,7 @@ static AAC_ENCODER_ERROR FDKaacEnc_reduceBitConsumption(int* iterati AAC_ENCODER_ERROR FDKaacEnc_updateFillBits(CHANNEL_MAPPING* cm, QC_STATE* qcKernel, - ELEMENT_BITS* RESTRICT elBits[(6)], + ELEMENT_BITS* RESTRICT elBits[(8)], QC_OUT** qcOut) { switch (qcKernel->bitrateMode) { @@ -1603,10 +1603,10 @@ void FDKaacEnc_QCClose (QC_STATE **phQCstate, QC_OUT **phQC) for (n=0;n<(1);n++) { if (phQC[n] != NULL) { QC_OUT *hQC = phQC[n]; - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { } - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (hQC->qcElement[i]) FreeRam_aacEnc_QCelement(&hQC->qcElement[i]); } @@ -1626,7 +1626,7 @@ void FDKaacEnc_QCClose (QC_STATE **phQCstate, QC_OUT **phQC) if (hQCstate->hBitCounter != NULL) FDKaacEnc_BCClose(&hQCstate->hBitCounter); - for (i=0; i<(6); i++) { + for (i=0; i<(8); i++) { if (hQCstate->elementBits[i]!=NULL) { FreeRam_aacEnc_ElementBits(&hQCstate->elementBits[i]); } diff --git a/libAACenc/src/qc_main.h b/libAACenc/src/qc_main.h index e1f5787..4e8c042 100644 --- a/libAACenc/src/qc_main.h +++ b/libAACenc/src/qc_main.h @@ -140,7 +140,7 @@ AAC_ENCODER_ERROR FDKaacEnc_QCMain(QC_STATE* RESTRICT hQC, AAC_ENCODER_ERROR FDKaacEnc_updateFillBits(CHANNEL_MAPPING* cm, QC_STATE* qcKernel, - ELEMENT_BITS* RESTRICT elBits[(6)], + ELEMENT_BITS* RESTRICT elBits[(8)], QC_OUT** qcOut); diff --git a/libMpegTPEnc/src/tpenc_asc.cpp b/libMpegTPEnc/src/tpenc_asc.cpp index 3f10ca4..bc4302e 100644 --- a/libMpegTPEnc/src/tpenc_asc.cpp +++ b/libMpegTPEnc/src/tpenc_asc.cpp @@ -127,8 +127,7 @@ typedef struct { * * The number of channel element parameter describes the kind of consecutively elements. * E.g. MODE_1_2_2_2_1 means: - * - First 2 elements (SCE,CPE) are front channel elements. - * - Following element (CPE) is a side channel element. + * - First 3 elements (SCE,CPE,CPE) are front channel elements. * - Next element (CPE) is a back channel element. * - Last element (LFE) is a lfe channel element. */ @@ -140,7 +139,8 @@ static const CHANNEL_CONFIGURATION pceConfigTab[] = { MODE_1_2_1, { 2, 0, 1, 0, { ID_SCE, ID_CPE, ID_SCE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, { MODE_1_2_2, { 2, 0, 1, 0, { ID_SCE, ID_CPE, ID_CPE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, { MODE_1_2_2_1, { 2, 0, 1, 1, { ID_SCE, ID_CPE, ID_CPE, ID_LFE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, - { MODE_1_2_2_2_1, { 2, 1, 1, 1, { ID_SCE, ID_CPE, ID_CPE, ID_CPE, ID_LFE, ID_NONE, ID_NONE, ID_NONE } } }, + { MODE_1_2_2_2_1, { 3, 0, 1, 1, { ID_SCE, ID_CPE, ID_CPE, ID_CPE, ID_LFE, ID_NONE, ID_NONE, ID_NONE } } }, + { MODE_1_1, { 2, 0, 0, 0, { ID_SCE, ID_SCE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, { MODE_1_1_1_1, { 2, 2, 0, 0, { ID_SCE, ID_SCE, ID_SCE, ID_SCE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, @@ -151,7 +151,11 @@ static const CHANNEL_CONFIGURATION pceConfigTab[] = { MODE_2_2_2, { 1, 1, 1, 0, { ID_CPE, ID_CPE, ID_CPE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, { MODE_2_2_2_2, { 4, 0, 0, 0, { ID_CPE, ID_CPE, ID_CPE, ID_CPE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, - { MODE_2_1, { 1, 0, 1, 0, { ID_CPE, ID_SCE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } } + { MODE_2_1, { 1, 0, 1, 0, { ID_CPE, ID_SCE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE, ID_NONE } } }, + + { MODE_7_1_REAR_SURROUND, { 2, 0, 2, 1, { ID_SCE, ID_CPE, ID_CPE, ID_CPE, ID_LFE, ID_NONE, ID_NONE, ID_NONE } } }, + { MODE_7_1_FRONT_CENTER, { 3, 0, 1, 1, { ID_SCE, ID_CPE, ID_CPE, ID_CPE, ID_LFE, ID_NONE, ID_NONE, ID_NONE } } }, + }; diff --git a/libMpegTPEnc/src/version b/libMpegTPEnc/src/version index 91c4c67..2803347 100644 --- a/libMpegTPEnc/src/version +++ b/libMpegTPEnc/src/version @@ -2,7 +2,7 @@ /* library info */ #define TP_LIB_VL0 2 #define TP_LIB_VL1 3 -#define TP_LIB_VL2 2 +#define TP_LIB_VL2 3 #define TP_LIB_TITLE "MPEG Transport" #define TP_LIB_BUILD_DATE __DATE__ #define TP_LIB_BUILD_TIME __TIME__ diff --git a/libSBRenc/include/sbr_encoder.h b/libSBRenc/include/sbr_encoder.h index 9d59ac7..93dc46d 100644 --- a/libSBRenc/include/sbr_encoder.h +++ b/libSBRenc/include/sbr_encoder.h @@ -324,7 +324,7 @@ UINT sbrEncoder_IsSingleRatePossible(AUDIO_OBJECT_TYPE aot); */ INT sbrEncoder_Init( HANDLE_SBR_ENCODER hSbrEncoder, - SBR_ELEMENT_INFO elInfo[(6)], + SBR_ELEMENT_INFO elInfo[(8)], int noElements, INT_PCM *inputBuffer, INT *coreBandwidth, @@ -369,8 +369,8 @@ void sbrEncoder_Close(HANDLE_SBR_ENCODER *phEbrEncoder); INT sbrEncoder_EncodeFrame(HANDLE_SBR_ENCODER hEnvEncoder, INT_PCM *samples, UINT timeInStride, - UINT sbrDataBits[(6)], - UCHAR sbrData[(6)][MAX_PAYLOAD_SIZE] + UINT sbrDataBits[(8)], + UCHAR sbrData[(8)][MAX_PAYLOAD_SIZE] ); /** diff --git a/libSBRenc/src/sbr.h b/libSBRenc/src/sbr.h index cfc595e..c74ad2a 100644 --- a/libSBRenc/src/sbr.h +++ b/libSBRenc/src/sbr.h @@ -131,9 +131,9 @@ typedef struct SBR_ELEMENT { typedef struct SBR_ENCODER { - HANDLE_SBR_ELEMENT sbrElement[(6)]; - HANDLE_SBR_CHANNEL pSbrChannel[(6)]; - QMF_FILTER_BANK QmfAnalysis[(6)]; + HANDLE_SBR_ELEMENT sbrElement[(8)]; + HANDLE_SBR_CHANNEL pSbrChannel[(8)]; + QMF_FILTER_BANK QmfAnalysis[(8)]; DOWNSAMPLER lfeDownSampler; int lfeChIdx; /* -1 default for no lfe, else assign channel index */ int noElements; /* Number of elements */ diff --git a/libSBRenc/src/sbr_encoder.cpp b/libSBRenc/src/sbr_encoder.cpp index 2d5bce2..3e95d6b 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 3 +#define SBRENCODER_LIB_VL2 4 @@ -653,7 +653,7 @@ void sbrEncoder_Close (HANDLE_SBR_ENCODER *phSbrEncoder) { int el, ch; - for (el=0; el<(6); el++) + for (el=0; el<(8); el++) { if (hSbrEncoder->sbrElement[el]!=NULL) { sbrEncoder_ElementClose(&hSbrEncoder->sbrElement[el]); @@ -661,7 +661,7 @@ void sbrEncoder_Close (HANDLE_SBR_ENCODER *phSbrEncoder) } /* Close sbr Channels */ - for (ch=0; ch<(6); ch++) + for (ch=0; ch<(8); ch++) { if (hSbrEncoder->pSbrChannel[ch]) { sbrEncoder_ChannelClose(hSbrEncoder->pSbrChannel[ch]); @@ -1468,7 +1468,7 @@ bail: static INT FDKsbrEnc_Reallocate( HANDLE_SBR_ENCODER hSbrEncoder, - SBR_ELEMENT_INFO elInfo[(6)], + SBR_ELEMENT_INFO elInfo[(8)], const INT noElements) { INT totalCh = 0; @@ -1806,7 +1806,7 @@ UINT sbrEncoder_IsSingleRatePossible(AUDIO_OBJECT_TYPE aot) INT sbrEncoder_Init( HANDLE_SBR_ENCODER hSbrEncoder, - SBR_ELEMENT_INFO elInfo[(6)], + SBR_ELEMENT_INFO elInfo[(8)], int noElements, INT_PCM *inputBuffer, INT *coreBandwidth, @@ -1823,7 +1823,7 @@ INT sbrEncoder_Init( ) { HANDLE_ERROR_INFO errorInfo = noError; - sbrConfiguration sbrConfig[(6)]; + sbrConfiguration sbrConfig[(8)]; INT error = 0; INT lowestBandwidth; /* Save input parameters */ @@ -2211,8 +2211,8 @@ INT sbrEncoder_EncodeFrame( HANDLE_SBR_ENCODER hSbrEncoder, INT_PCM *samples, UINT timeInStride, - UINT sbrDataBits[(6)], - UCHAR sbrData[(6)][MAX_PAYLOAD_SIZE] + UINT sbrDataBits[(8)], + UCHAR sbrData[(8)][MAX_PAYLOAD_SIZE] ) { INT error; diff --git a/libSBRenc/src/sbr_ram.cpp b/libSBRenc/src/sbr_ram.cpp index 3b99d09..ee6c37f 100644 --- a/libSBRenc/src/sbr_ram.cpp +++ b/libSBRenc/src/sbr_ram.cpp @@ -107,39 +107,39 @@ C_ALLOC_MEM (Ram_SbrDynamic_RAM, FIXP_DBL, ((SBR_ENC_DYN_RAM_SIZE)/sizeof(FIXP_D in module sbr_ram and sbr rom */ C_ALLOC_MEM (Ram_SbrEncoder, SBR_ENCODER, 1) -C_ALLOC_MEM2(Ram_SbrChannel, SBR_CHANNEL, 1, (6)) -C_ALLOC_MEM2(Ram_SbrElement, SBR_ELEMENT, 1, (6)) +C_ALLOC_MEM2(Ram_SbrChannel, SBR_CHANNEL, 1, (8)) +C_ALLOC_MEM2(Ram_SbrElement, SBR_ELEMENT, 1, (8)) /*! Filter states for QMF-analysis.
Dimension: #MAXNRSBRCHANNELS * #SBR_QMF_FILTER_LENGTH */ -C_AALLOC_MEM2_L (Ram_Sbr_QmfStatesAnalysis, FIXP_QAS, QMF_FILTER_LENGTH, (6), SECT_DATA_L1) +C_AALLOC_MEM2_L (Ram_Sbr_QmfStatesAnalysis, FIXP_QAS, QMF_FILTER_LENGTH, (8), SECT_DATA_L1) /*! Matrix holding the quota values for all estimates, all channels Dimension #MAXNRSBRCHANNELS * +#SBR_QMF_CHANNELS* #MAX_NO_OF_ESTIMATES */ -C_ALLOC_MEM2_L (Ram_Sbr_quotaMatrix, FIXP_DBL, (MAX_NO_OF_ESTIMATES*QMF_CHANNELS), (6), SECT_DATA_L1) +C_ALLOC_MEM2_L (Ram_Sbr_quotaMatrix, FIXP_DBL, (MAX_NO_OF_ESTIMATES*QMF_CHANNELS), (8), SECT_DATA_L1) /*! Matrix holding the sign values for all estimates, all channels Dimension #MAXNRSBRCHANNELS * +#SBR_QMF_CHANNELS* #MAX_NO_OF_ESTIMATES */ -C_ALLOC_MEM2 (Ram_Sbr_signMatrix, INT, (MAX_NO_OF_ESTIMATES*QMF_CHANNELS), (6)) +C_ALLOC_MEM2 (Ram_Sbr_signMatrix, INT, (MAX_NO_OF_ESTIMATES*QMF_CHANNELS), (8)) /*! Frequency band table (low res)
Dimension #MAX_FREQ_COEFFS/2+1 */ -C_ALLOC_MEM2 (Ram_Sbr_freqBandTableLO, UCHAR, (MAX_FREQ_COEFFS/2+1), (6)) +C_ALLOC_MEM2 (Ram_Sbr_freqBandTableLO, UCHAR, (MAX_FREQ_COEFFS/2+1), (8)) /*! Frequency band table (high res)
Dimension #MAX_FREQ_COEFFS +1 */ -C_ALLOC_MEM2 (Ram_Sbr_freqBandTableHI, UCHAR, (MAX_FREQ_COEFFS+1), (6)) +C_ALLOC_MEM2 (Ram_Sbr_freqBandTableHI, UCHAR, (MAX_FREQ_COEFFS+1), (8)) /*! vk matser table
Dimension #MAX_FREQ_COEFFS +1 */ -C_ALLOC_MEM2 (Ram_Sbr_v_k_master, UCHAR, (MAX_FREQ_COEFFS+1), (6)) +C_ALLOC_MEM2 (Ram_Sbr_v_k_master, UCHAR, (MAX_FREQ_COEFFS+1), (8)) /* @@ -149,23 +149,23 @@ C_ALLOC_MEM2 (Ram_Sbr_v_k_master, UCHAR, (MAX_FREQ_COEFFS+1), (6)) /*! sbr_detectionVectors
Dimension #MAX_NUM_CHANNELS*#MAX_NO_OF_ESTIMATES*#MAX_FREQ_COEFFS] */ -C_ALLOC_MEM2 (Ram_Sbr_detectionVectors, UCHAR, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (6)) +C_ALLOC_MEM2 (Ram_Sbr_detectionVectors, UCHAR, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (8)) /*! sbr_prevCompVec[
Dimension #MAX_NUM_CHANNELS*#MAX_FREQ_COEFFS] */ -C_ALLOC_MEM2 (Ram_Sbr_prevEnvelopeCompensation, UCHAR, MAX_FREQ_COEFFS, (6)) +C_ALLOC_MEM2 (Ram_Sbr_prevEnvelopeCompensation, UCHAR, MAX_FREQ_COEFFS, (8)) /*! sbr_guideScfb[
Dimension #MAX_NUM_CHANNELS*#MAX_FREQ_COEFFS] */ -C_ALLOC_MEM2 (Ram_Sbr_guideScfb, UCHAR, MAX_FREQ_COEFFS, (6)) +C_ALLOC_MEM2 (Ram_Sbr_guideScfb, UCHAR, MAX_FREQ_COEFFS, (8)) /*! sbr_guideVectorDetected
Dimension #MAX_NUM_CHANNELS*#MAX_NO_OF_ESTIMATES*#MAX_FREQ_COEFFS] */ -C_ALLOC_MEM2 (Ram_Sbr_guideVectorDetected, UCHAR, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (6)) -C_ALLOC_MEM2 (Ram_Sbr_guideVectorDiff, FIXP_DBL, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (6)) -C_ALLOC_MEM2 (Ram_Sbr_guideVectorOrig, FIXP_DBL, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (6)) +C_ALLOC_MEM2 (Ram_Sbr_guideVectorDetected, UCHAR, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (8)) +C_ALLOC_MEM2 (Ram_Sbr_guideVectorDiff, FIXP_DBL, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (8)) +C_ALLOC_MEM2 (Ram_Sbr_guideVectorOrig, FIXP_DBL, (MAX_NO_OF_ESTIMATES*MAX_FREQ_COEFFS), (8)) /* Static Parametric Stereo memory @@ -191,7 +191,7 @@ C_ALLOC_MEM (Ram_ParamStereo, PARAMETRIC_STEREO, 1) /*! Energy buffer for envelope extraction
Dimension #MAXNRSBRCHANNELS * +#SBR_QMF_SLOTS * #SBR_QMF_CHANNELS */ - C_ALLOC_MEM2 (Ram_Sbr_envYBuffer, FIXP_DBL, (QMF_MAX_TIME_SLOTS/2 * QMF_CHANNELS), (6)) + C_ALLOC_MEM2 (Ram_Sbr_envYBuffer, FIXP_DBL, (QMF_MAX_TIME_SLOTS/2 * QMF_CHANNELS), (8)) FIXP_DBL* GetRam_Sbr_envYBuffer (int n, UCHAR* dynamic_RAM) { FDK_ASSERT(dynamic_RAM!=0); diff --git a/libSYS/include/FDK_audio.h b/libSYS/include/FDK_audio.h index d2c5f9a..c8d9c19 100644 --- a/libSYS/include/FDK_audio.h +++ b/libSYS/include/FDK_audio.h @@ -234,28 +234,32 @@ typedef enum /** Channel Mode ( 1-7 equals MPEG channel configurations, others are arbitrary). */ typedef enum { - MODE_INVALID = -1, - MODE_UNKNOWN = 0, - MODE_1 = 1, /**< SCE */ - MODE_2 = 2, /**< CPE */ - MODE_1_2 = 3, /**< SCE,CPE */ - MODE_1_2_1 = 4, /**< SCE,CPE,SCE */ - MODE_1_2_2 = 5, /**< SCE,CPE,CPE */ - MODE_1_2_2_1 = 6, /**< SCE,CPE,CPE,LFE */ - MODE_1_2_2_2_1 = 7, /**< SCE,CPE,CPE,CPE,LFE */ - - MODE_1_1 = 16, /**< 2 SCEs (dual mono) */ - MODE_1_1_1_1 = 17, /**< 4 SCEs */ - MODE_1_1_1_1_1_1 = 18, /**< 6 SCEs */ - MODE_1_1_1_1_1_1_1_1 = 19, /**< 8 SCEs */ - MODE_1_1_1_1_1_1_1_1_1_1_1_1 = 20, /**< 12 SCEs */ - - MODE_2_2 = 21, /**< 2 CPEs */ - MODE_2_2_2 = 22, /**< 3 CPEs */ - MODE_2_2_2_2 = 23, /**< 4 CPEs */ - MODE_2_2_2_2_2_2 = 24, /**< 6 CPEs */ - - MODE_2_1 = 30 /**< CPE,SCE (ARIB standard) */ + MODE_INVALID = -1, + MODE_UNKNOWN = 0, + MODE_1 = 1, /**< C */ + MODE_2 = 2, /**< L+R */ + MODE_1_2 = 3, /**< C, L+R */ + MODE_1_2_1 = 4, /**< C, L+R, Rear */ + MODE_1_2_2 = 5, /**< C, L+R, LS+RS */ + MODE_1_2_2_1 = 6, /**< C, L+R, LS+RS, LFE */ + MODE_1_2_2_2_1 = 7, /**< C, LC+RC, L+R, LS+RS, LFE */ + + + MODE_1_1 = 16, /**< 2 SCEs (dual mono) */ + MODE_1_1_1_1 = 17, /**< 4 SCEs */ + MODE_1_1_1_1_1_1 = 18, /**< 6 SCEs */ + MODE_1_1_1_1_1_1_1_1 = 19, /**< 8 SCEs */ + MODE_1_1_1_1_1_1_1_1_1_1_1_1 = 20, /**< 12 SCEs */ + + MODE_2_2 = 21, /**< 2 CPEs */ + MODE_2_2_2 = 22, /**< 3 CPEs */ + MODE_2_2_2_2 = 23, /**< 4 CPEs */ + MODE_2_2_2_2_2_2 = 24, /**< 6 CPEs */ + + MODE_2_1 = 30, /**< CPE,SCE (ARIB standard B32) */ + + MODE_7_1_REAR_SURROUND = 33, /**< C, L+R, LS+RS, Lrear+Rrear, LFE */ + MODE_7_1_FRONT_CENTER = 34 /**< C, LC+RC, L+R, LS+RS, LFE */ } CHANNEL_MODE; diff --git a/libSYS/src/genericStds.cpp b/libSYS/src/genericStds.cpp index f293189..f0199fb 100644 --- a/libSYS/src/genericStds.cpp +++ b/libSYS/src/genericStds.cpp @@ -99,7 +99,7 @@ amm-info@iis.fraunhofer.de /* library info */ #define SYS_LIB_VL0 1 #define SYS_LIB_VL1 3 -#define SYS_LIB_VL2 3 +#define SYS_LIB_VL2 4 #define SYS_LIB_TITLE "System Integration Library" #define SYS_LIB_BUILD_DATE __DATE__ #define SYS_LIB_BUILD_TIME __TIME__ -- cgit v1.2.3