Commit 577fcbb5 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi

Decode and SYS lib cleanup

* AAC-Encoder

   - Remove source snippets related to unsupported frame length of 960.
   - Adjust minBits initialization for disabled VBR configuration.
     Modified file(s):
        libAACenc/src/aacenc.h
        libAACenc/src/aacenc_lib.cpp
        libAACenc/src/aacenc_tns.cpp
        libAACenc/src/bandwidth.cpp
        libAACenc/src/psy_const.h
        libAACenc/src/transform.h

   - Revise encoder parameter restrictions: "Error Resilient(ER) AAC Low Complexity"
     is not supported. Where the AAC part of the FDK encoder threw an
     initialization error, now the aacEncoder_SetParam() returns an error
     before initialization if the application tries to configure this
     audio object type.
     Modified file(s):
        libAACenc/src/aacenc_lib.cpp

* SYS-Library

   - Portability fix for Mingw32.
     Modified file(s):
        libSYS/include/machine_type.h

   - Minor changes.
     Modified file(s):
        libSYS/include/wav_file.h
        libSYS/src/wav_file.cpp
        libSYS/src/cmdl_parser.cpp
        libSYS/src/genericStds.cpp

Bug 9428126

Change-Id: I9fa44923d34f033d0dc607f2b85abacb8a85eb61
parent 4f0d9705
......@@ -558,6 +558,13 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEnc,
qcInit.channelMapping = &hAacEnc->channelMapping;
qcInit.sceCpe = 0;
if ((config->bitrateMode>=1) && (config->bitrateMode<=5)) {
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
qcInit.bitRes = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
qcInit.maxBits = MIN_BUFSIZE_PER_EFF_CHAN*cm->nChannelsEff;
qcInit.minBits = 0;
}
else
{
int maxBitres;
qcInit.averageBits = (averageBitsPerFrame+7)&~7;
......
......@@ -113,7 +113,7 @@ typedef enum {
/* initialization errors */
aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call was invalid (probably NULL). */
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length (must be 1024 or 960). */
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length. */
AAC_ENC_INVALID_N_CHANNELS = 0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
......
......@@ -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 0
#define AACENCODER_LIB_VL2 1
#define AACENCODER_LIB_TITLE "AAC Encoder"
#define AACENCODER_LIB_BUILD_DATE __DATE__
#define AACENCODER_LIB_BUILD_TIME __TIME__
......@@ -506,7 +506,7 @@ INT aacEncoder_LimitBitrate(
bitRate = FDKmin(576000*nChannels, bitRate);
/*bitRate = FDKmax(0*nChannels, bitRate);*/
}
/* Limit bit rate in respect to the core coder */
bitRate = FDKaacEnc_LimitBitrate(
......@@ -535,7 +535,7 @@ INT aacEncoder_LimitBitrate(
aacEncDistributeSbrBits(&cm, sbrElInfo, bitRate);
for (e=0; e<cm.nElements; e++)
{
{
INT sbrElementBitRateIn, sbrBitRateOut;
if (cm.elInfo[e].elType != ID_SCE && cm.elInfo[e].elType != ID_CPE) {
......@@ -632,18 +632,7 @@ AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder,
case AOT_PS:
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_ADTS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
return AACENC_INVALID_CONFIG;
}
break;
case AOT_ER_AAC_LC:
hAacConfig->epConfig = 0;
hAacConfig->syntaxFlags |= AC_ER;
hAacConfig->syntaxFlags |= ((config->userErTools & 0x1) ? AC_ER_VCB11 : 0);
hAacConfig->syntaxFlags |= ((config->userErTools & 0x2) ? AC_ER_HCR : 0);
config->userTpType = (config->userTpType!=TT_UNKNOWN) ? config->userTpType : TT_MP4_LOAS;
hAacConfig->framelength = (config->userFramelength!=(UINT)-1) ? config->userFramelength : 1024;
if (hAacConfig->framelength != 1024 && hAacConfig->framelength != 960) {
if (hAacConfig->framelength != 1024) {
return AACENC_INVALID_CONFIG;
}
break;
......@@ -1573,7 +1562,6 @@ AACENC_ERROR aacEncoder_SetParam(
}
case AOT_AAC_LC:
case AOT_MP2_AAC_LC:
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LD:
case AOT_ER_AAC_ELD:
if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_AAC))) {
......
......@@ -281,7 +281,6 @@ static INT getTnsMaxBands(
int maxBandsTabSize = 0;
switch (granuleLength) {
case 960:
case 1024:
pMaxBandsTab = tnsMaxBandsTab1024;
maxBandsTabSize = sizeof(tnsMaxBandsTab1024)/sizeof(TNS_MAX_TAB_ENTRY);
......@@ -404,7 +403,6 @@ AAC_ENCODER_ERROR FDKaacEnc_InitTnsConfiguration(INT bitRate,
tC->lpcStopLine = pC->sfbOffset[tC->lpcStopBand];
switch (granuleLength) {
case 960:
case 1024:
/* TNS start line: skip lower MDCT lines to prevent artifacts due to filter mismatch */
tC->lpcStartBand[LOFILT] = (blockType == SHORT_WINDOW) ? 0 : ((sampleRate < 18783) ? 4 : 8);
......
......@@ -204,7 +204,6 @@ static INT GetBandwidthEntry(
INT bwTabSize = 0;
switch (frameLength) {
case 960:
case 1024:
pBwTab = bandWidthTable;
bwTabSize = sizeof(bandWidthTable)/sizeof(BANDWIDTH_TAB);
......@@ -253,7 +252,6 @@ static INT GetBandwidthEntry(
chanBitRate < pBwTab[i+1].chanBitRate)
{
switch (frameLength) {
case 960:
case 1024:
bandwidth = (entryNo==0)
? pBwTab[i].bandWidthMono
......
......@@ -98,7 +98,6 @@ amm-info@iis.fraunhofer.de
#define FRAME_MAXLEN_SHORT ((1024)/TRANS_FAC)
#define FRAME_LEN_SHORT_128 ((1024)/TRANS_FAC)
#define FRAME_LEN_SHORT_120 (FRAME_LEN_LONG_960/TRANS_FAC)
/* Filterbank type*/
enum FB_TYPE {
......
......@@ -105,7 +105,7 @@ amm-info@iis.fraunhofer.de
* LONG_WINDOW, START_WINDOW, SHORT_WINDOW or STOP_WINDOW.
* \param windowShape index indicating the window slope type to be used.
* Values allowed are either SINE_WINDOW or KBD_WINDOW.
* \param frameLength length of the block. Either 1024 or 960.
* \param frameLength length of the block.
* \param mdctData_e pointer to an INT where the exponent of the frequency
* domain output data is stored into.
* \return 0 in case of success, non-zero in case of error (inconsistent parameters).
......
......@@ -173,7 +173,7 @@ amm-info@iis.fraunhofer.de
/* Define 64 bit base integer type. */
#ifdef _WIN32
#ifdef _MSC_VER
typedef __int64 INT64;
typedef unsigned __int64 UINT64;
#else
......
......@@ -111,16 +111,36 @@ amm-info@iis.fraunhofer.de
extern "C" {
#endif
#define SPEAKER_FRONT_LEFT 0x1
#define SPEAKER_FRONT_RIGHT 0x2
#define SPEAKER_FRONT_CENTER 0x4
#define SPEAKER_LOW_FREQUENCY 0x8
#define SPEAKER_BACK_LEFT 0x10
#define SPEAKER_BACK_RIGHT 0x20
#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
#define SPEAKER_BACK_CENTER 0x100
#define SPEAKER_SIDE_LEFT 0x200
#define SPEAKER_SIDE_RIGHT 0x400
#define SPEAKER_TOP_CENTER 0x800
#define SPEAKER_TOP_FRONT_LEFT 0x1000
#define SPEAKER_TOP_FRONT_CENTER 0x2000
#define SPEAKER_TOP_FRONT_RIGHT 0x4000
#define SPEAKER_TOP_BACK_LEFT 0x8000
#define SPEAKER_TOP_BACK_CENTER 0x10000
#define SPEAKER_TOP_BACK_RIGHT 0x20000
#define SPEAKER_RESERVED 0x80000000
/*!
* RIFF WAVE file struct.
* For details see WAVE file format documentation (for example at http://www.wotsit.org).
*/
typedef struct WAV_HEADER
{
char riffType[4];
char riffType[4];
UINT riffSize;
char waveType[4];
char formatType[4];
char waveType[4];
char formatType[4];
UINT formatSize;
USHORT compressionCode;
USHORT numChannels;
......@@ -128,7 +148,7 @@ typedef struct WAV_HEADER
UINT bytesPerSecond;
USHORT blockAlign;
USHORT bitsPerSample;
char dataType[4];
char dataType[4];
UINT dataSize;
} WAV_HEADER;
......@@ -136,6 +156,7 @@ struct WAV
{
WAV_HEADER header;
FDKFILE *fp;
UINT channelMask;
};
typedef struct WAV *HANDLE_WAV;
......
......@@ -465,7 +465,7 @@ INT CheckArg(TEXTCHAR* arg, TEXTCHAR* str, UINT numArgs, TEXTCHAR type, TEXTCHAR
for ( i = 0; i < _tcslen(arg); ++i )
{
if ( (type == 'd') && !_istdigit(arg[i]) && arg[i] != 'x' )
if ( (type == 'd') && !_istdigit(arg[i]) && arg[i] != 'x' && arg[i] != '-')
{
#ifdef _UNICODE
_ftprintf(stderr, _TEXT("\n\nError: Argument '%ls' for switch '%ls' is not a valid number.\n" ), arg, cur_str);
......@@ -549,7 +549,7 @@ int IIS_ProcessCmdlList(const char* param_filename, int (*pFunction)(int, TEXTCH
/* Skip consecutive blanks. */
while (*line_ptr == ' ' && line_ptr < line+CMDL_MAX_STRLEN)
line_ptr++;
/* Assign argument. TODO: maybe handle quotes */
/* Assign argument. */
argv_ptr[argc] = line_ptr;
/* Get pointer to next blank. */
line_ptr = (char*)FDKstrchr(line_ptr, ' ');
......
......@@ -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 0
#define SYS_LIB_VL2 1
#define SYS_LIB_TITLE "System Integration Library"
#define SYS_LIB_BUILD_DATE __DATE__
#define SYS_LIB_BUILD_TIME __TIME__
......
......@@ -174,7 +174,6 @@ INT WAV_InputOpen (HANDLE_WAV *pWav, const char *filename)
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71
};
USHORT extraFormatBytes, validBitsPerSample;
UINT channelMask;
UCHAR guid[16];
INT i;
......@@ -184,7 +183,7 @@ INT WAV_InputOpen (HANDLE_WAV *pWav, const char *filename)
if (extraFormatBytes >= 22) {
FDKfread_EL(&(validBitsPerSample), 2, 1, wav->fp);
FDKfread_EL(&(channelMask), 4, 1, wav->fp);
FDKfread_EL(&(wav->channelMask), 4, 1, wav->fp);
FDKfread_EL(&(guid), 16, 1, wav->fp);
/* check for PCM GUID */
......@@ -228,12 +227,12 @@ INT WAV_InputOpen (HANDLE_WAV *pWav, const char *filename)
/* Error path */
error:
if (wav->fp) {
FDKfclose(wav->fp);
wav->fp = NULL;
}
if (wav) {
if (wav->fp) {
FDKfclose(wav->fp);
wav->fp = NULL;
}
FDKfree(wav);
}
......@@ -388,6 +387,11 @@ INT WAV_OutputOpen(HANDLE_WAV *pWav, const char *outputFilename, INT sampleRate,
HANDLE_WAV wav = (HANDLE_WAV)FDKcalloc(1, sizeof(struct WAV));
UINT size = 0;
if (wav == NULL) {
FDKprintfErr("WAV_OutputOpen(): Unable to allocate WAV struct.\n");
goto bail;
}
if (bitsPerSample != 16 && bitsPerSample != 24 && bitsPerSample != 32)
{
FDKprintfErr("WAV_OutputOpen(): Invalid argument (bitsPerSample).\n");
......@@ -433,10 +437,12 @@ INT WAV_OutputOpen(HANDLE_WAV *pWav, const char *outputFilename, INT sampleRate,
return 0;
bail:
if (wav->fp)
FDKfclose(wav->fp);
if (wav)
if (wav) {
if (wav->fp) {
FDKfclose(wav->fp);
}
FDKfree(wav);
}
pWav = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment