diff --git a/components/spotify/cspot/bell/CMakeLists.txt b/components/spotify/cspot/bell/CMakeLists.txt index f2244bf5..8631febe 100644 --- a/components/spotify/cspot/bell/CMakeLists.txt +++ b/components/spotify/cspot/bell/CMakeLists.txt @@ -5,7 +5,7 @@ project(bell) # Configurable options option(BELL_DISABLE_CODECS "Disable the entire audio codec wrapper" OFF) -option(BELL_CODEC_AAC "Support libhelix-aac codec" ON) +option(BELL_CODEC_AAC "Support opencore-aac codec" ON) option(BELL_CODEC_MP3 "Support libhelix-mp3 codec" ON) option(BELL_DISABLE_MQTT "Disable the built-in MQTT wrapper" OFF) option(BELL_DISABLE_WEBSERVER "Disable the built-in Web server" OFF) @@ -136,7 +136,11 @@ endfunction() if(ESP_PLATFORM) - list(APPEND EXTRA_LIBS idf::mdns idf::mbedtls idf::pthread idf::driver idf::lwip) + if (IDF_VERSION_MAJOR LESS_EQUAL 4) + list(APPEND EXTRA_LIBS idf::mdns idf::mbedtls idf::pthread idf::driver idf::lwip) + else() + list(APPEND EXTRA_LIBS idf::espressif__mdns idf::mbedtls idf::pthread idf::driver idf::lwip) + endif() add_definitions(-Wunused-const-variable -Wchar-subscripts -Wunused-label -Wmaybe-uninitialized -Wmisleading-indentation -Wno-stringop-overflow -Wno-error=format -Wno-format -Wno-stringop-overread -Wno-stringop-overflow) else() find_package(Threads REQUIRED) @@ -170,9 +174,8 @@ if(NOT BELL_DISABLE_CODECS) # AAC-LC codec if(BELL_CODEC_AAC) - file(GLOB LIBHELIX_AAC_SOURCES "external/libhelix-aac/*.c") - list(APPEND LIBHELIX_SOURCES ${LIBHELIX_AAC_SOURCES}) - list(APPEND EXTERNAL_INCLUDES "external/libhelix-aac") + add_subdirectory(external/opencore-aacdec) + list(APPEND EXTRA_LIBS opencore-aacdec) list(APPEND SOURCES "${AUDIO_CODEC_DIR}/AACDecoder.cpp") list(APPEND CODEC_FLAGS "-DBELL_CODEC_AAC") endif() @@ -303,6 +306,7 @@ if(NOT BELL_DISABLE_WEBSERVER) list(APPEND EXTRA_INCLUDES "external/civetweb/include") else() list(REMOVE_ITEM SOURCES "${IO_DIR}/BellHTTPServer.cpp") + list(REMOVE_ITEM SOURCES "${IO_DIR}/MGStreamAdapter.cpp") endif() add_library(bell STATIC ${SOURCES}) @@ -345,3 +349,4 @@ endif() if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "SunOS") target_compile_definitions(bell PUBLIC PB_NO_STATIC_ASSERT) endif() + diff --git a/components/spotify/cspot/bell/example/main.cpp b/components/spotify/cspot/bell/example/main.cpp index 0f043125..3344d61f 100644 --- a/components/spotify/cspot/bell/example/main.cpp +++ b/components/spotify/cspot/bell/example/main.cpp @@ -1,14 +1,22 @@ +#include #include +#include +#include +#include +#include #include -#include -#include - +#include +#include "AudioCodecs.h" +#include "AudioContainers.h" +#include "BellHTTPServer.h" #include "BellTask.h" #include "CentralAudioBuffer.h" +#include "Compressor.h" +#include "DecoderGlobals.h" +#include "EncodedAudioStream.h" +#include "HTTPClient.h" #include "PortAudioSink.h" -#include "StreamInfo.h" -#define DEBUG_LEVEL 4 #include #include @@ -33,8 +41,8 @@ class AudioPlayer : bell::Task { auto chunk = audioBuffer->readChunk(); if (chunk != nullptr && chunk->pcmSize > 0) { - this->dsp->process(chunk->pcmData, chunk->pcmSize, 2, 44100, - bell::BitWidth::BW_16); + // this->dsp->process(chunk->pcmData, chunk->pcmSize, 2, 44100, + // bell::BitWidth::BW_16); this->audioSink->feedPCMFrames(chunk->pcmData, chunk->pcmSize); } @@ -45,9 +53,51 @@ class AudioPlayer : bell::Task { int main() { bell::setDefaultLogger(); + bell::createDecoders(); + size_t size = sizeof(void*); + audioBuffer = std::make_shared(512); + auto task = AudioPlayer(); + auto url = "http://193.222.135.71/378"; + // std::ifstream file("aactest.aac", std::ios::binary); - BELL_LOG(info, "cock", "Published?"); + auto req = bell::HTTPClient::get(url); + auto container = AudioContainers::guessAudioContainer(req->stream()); + auto codec = AudioCodecs::getCodec(container.get()); + uint32_t dataLen; + while (true) { + uint8_t* data = codec->decode(container.get(), dataLen); + + if (!data) { + std::cout << "data invalid" << std::endl; + continue; + } + + size_t toWrite = dataLen; + while (toWrite > 0) { + toWrite -= audioBuffer->writePCM(data + dataLen - toWrite, toWrite, 0); + } + + // std::cout << dataLen << std::endl; + } + + // return 0; + + // std::vector frameData(1024 * 10); + // /* + // while (true) { + // size_t bytes =audioStream->decodeFrame(frameData.data()); + // std::cout << bytes < 0) { + // toWrite -= audioBuffer->writePCM(frameData.data() + bytes - toWrite, + // toWrite, 0); + // } + // } + // }*/ return 0; -} +} \ No newline at end of file diff --git a/components/spotify/cspot/bell/external/libhelix-aac/aaccommon.h b/components/spotify/cspot/bell/external/libhelix-aac/aaccommon.h deleted file mode 100644 index 9d862fab..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/aaccommon.h +++ /dev/null @@ -1,213 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * aaccommon.h - implementation-independent API's, datatypes, and definitions - **************************************************************************************/ - -#ifndef _AACCOMMON_H -#define _AACCOMMON_H - -#ifdef ESP8266 -# include "pgmspace.h" -#elif defined(ESP_PLATFORM) && __has_include() -# include -#else -# define PROGMEM -# define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -# define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif -// Can't fit in ESP8266 RAM -#ifndef ESP8266 - #define AAC_ENABLE_SBR 1 -#endif - -#pragma GCC optimize ("O3") - -#include "aacdec.h" -#include "statname.h" - -/* 12-bit syncword */ -#define SYNCWORDH 0xff -#define SYNCWORDL 0xf0 - -#define MAX_NCHANS_ELEM 2 /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */ - -#define ADTS_HEADER_BYTES 7 -#define NUM_SAMPLE_RATES 12 -#define NUM_DEF_CHAN_MAPS 8 -#define NUM_ELEMENTS 8 -#define MAX_NUM_PCE_ADIF 16 - -#define MAX_WIN_GROUPS 8 -#define MAX_SFB_SHORT 15 -#define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */ -#define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3) -#define MAX_PRED_SFB 41 -#define MAX_TNS_FILTERS 8 -#define MAX_TNS_COEFS 60 -#define MAX_TNS_ORDER 20 -#define MAX_PULSES 4 -#define MAX_GAIN_BANDS 3 -#define MAX_GAIN_WIN 8 -#define MAX_GAIN_ADJUST 7 - -#define NSAMPS_LONG 1024 -#define NSAMPS_SHORT 128 - -#define NUM_SYN_ID_BITS 3 -#define NUM_INST_TAG_BITS 4 - -#define EXT_SBR_DATA 0x0d -#define EXT_SBR_DATA_CRC 0x0e - -#define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F') -#define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS))) - -/* AAC file format */ -enum { - AAC_FF_Unknown = 0, /* should be 0 on init */ - - AAC_FF_ADTS = 1, - AAC_FF_ADIF = 2, - AAC_FF_RAW = 3 - -}; - -/* syntactic element type */ -enum { - AAC_ID_INVALID = -1, - - AAC_ID_SCE = 0, - AAC_ID_CPE = 1, - AAC_ID_CCE = 2, - AAC_ID_LFE = 3, - AAC_ID_DSE = 4, - AAC_ID_PCE = 5, - AAC_ID_FIL = 6, - AAC_ID_END = 7 -}; - -typedef struct _AACDecInfo { - /* pointers to platform-specific state information */ - void *psInfoBase; /* baseline MPEG-4 LC decoding */ - void *psInfoSBR; /* MPEG-4 SBR decoding */ - - /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */ - void *rawSampleBuf[AAC_MAX_NCHANS]; - int rawSampleBytes; - int rawSampleFBits; - - /* fill data (can be used for processing SBR or other extensions) */ - unsigned char *fillBuf; - int fillCount; - int fillExtType; - - /* block information */ - int prevBlockID; - int currBlockID; - int currInstTag; - int sbDeinterleaveReqd[MAX_NCHANS_ELEM]; - int adtsBlocksLeft; - - /* user-accessible info */ - int bitRate; - int nChans; - int sampRate; - int profile; - int format; - int sbrEnabled; - int tnsUsed; - int pnsUsed; - int frameCount; - -} AACDecInfo; - -/* decoder functions which must be implemented for each platform */ -AACDecInfo *AllocateBuffers(void); -AACDecInfo *AllocateBuffersPre(void **space, int *len); -void FreeBuffers(AACDecInfo *aacDecInfo); -void ClearBuffer(void *buf, int nBytes); - -int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail); -int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile); -int PrepareRawBlock(AACDecInfo *aacDecInfo); -int FlushCodec(AACDecInfo *aacDecInfo); - -int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch); - -int Dequantize(AACDecInfo *aacDecInfo, int ch); -int StereoProcess(AACDecInfo *aacDecInfo); -int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch); -int PNS(AACDecInfo *aacDecInfo, int ch); -int TNSFilter(AACDecInfo *aacDecInfo, int ch); -int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf); - -/* SBR specific functions */ -int InitSBR(AACDecInfo *aacDecInfo); -int InitSBRPre(AACDecInfo *aacDecInfo, void **ptr, int *sz); -void FreeSBR(AACDecInfo *aacDecInfo); -int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase); -int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf); -int FlushCodecSBR(AACDecInfo *aacDecInfo); - -/* aactabs.c - global ROM tables */ -extern const int sampRateTab[NUM_SAMPLE_RATES]; -extern const int predSFBMax[NUM_SAMPLE_RATES]; -extern const int channelMapTab[NUM_DEF_CHAN_MAPS]; -extern const int elementNumChans[NUM_ELEMENTS]; -extern const unsigned /*char*/ int sfBandTotalShort[NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int sfBandTotalLong[NUM_SAMPLE_RATES]; -extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES]; -extern const /*short*/ int sfBandTabShort[76]; -extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES]; -extern const /*short*/ int sfBandTabLong[325]; -extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES]; -extern const unsigned /*char*/ int tnsMaxBandsShort[2*NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int tnsMaxOrderShort[AAC_NUM_PROFILES]; -extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES]; -extern const unsigned /*char*/ int tnsMaxBandsLong[2*NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int tnsMaxOrderLong[AAC_NUM_PROFILES]; - -#endif /* _AACCOMMON_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/aacdec.c b/components/spotify/cspot/bell/external/libhelix-aac/aacdec.c deleted file mode 100644 index cb0e5041..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/aacdec.c +++ /dev/null @@ -1,476 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * aacdec.c - platform-independent top level decoder API - **************************************************************************************/ - -#include "aaccommon.h" - -//#include "profile.h" - -#define PROFILE_START(x) -#define PROFILE_END() - -/************************************************************************************** - * Function: AACInitDecoder - * - * Description: allocate memory for platform-specific data - * clear all the user-accessible fields - * initialize SBR decoder if enabled - * - * Inputs: none - * - * Outputs: none - * - * Return: handle to AAC decoder instance, 0 if malloc fails - **************************************************************************************/ -HAACDecoder AACInitDecoder(void) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = AllocateBuffers(); - if (!aacDecInfo) - return 0; - -#ifdef AAC_ENABLE_SBR - if (InitSBR(aacDecInfo)) { - AACFreeDecoder(aacDecInfo); - return 0; - } -#endif - - return (HAACDecoder)aacDecInfo; -} - -HAACDecoder AACInitDecoderPre(void *ptr, int sz) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = AllocateBuffersPre(&ptr, &sz); - if (!aacDecInfo) - return 0; - -#ifdef AAC_ENABLE_SBR - if (InitSBRPre(aacDecInfo, &ptr, &sz)) { - return 0; - } -#endif - - return (HAACDecoder)aacDecInfo; -} - -/************************************************************************************** - * Function: AACFreeDecoder - * - * Description: free platform-specific data allocated by AACInitDecoder - * free SBR decoder if enabled - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * - * Outputs: none - * - * Return: none - **************************************************************************************/ -void AACFreeDecoder(HAACDecoder hAACDecoder) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return; - -#ifdef AAC_ENABLE_SBR - FreeSBR(aacDecInfo); -#endif - FreeBuffers(aacDecInfo); -} - -/************************************************************************************** - * Function: AACFindSyncWord - * - * Description: locate the next byte-alinged sync word in the raw AAC stream - * - * Inputs: buffer to search for sync word - * max number of bytes to search in buffer - * - * Outputs: none - * - * Return: offset to first sync word (bytes from start of buf) - * -1 if sync not found after searching nBytes - **************************************************************************************/ -int AACFindSyncWord(unsigned char *buf, int nBytes) -{ - int i; - - /* find byte-aligned syncword (12 bits = 0xFFF) */ - for (i = 0; i < nBytes - 1; i++) { - if ( (buf[i+0] & SYNCWORDH) == SYNCWORDH && (buf[i+1] & SYNCWORDL) == SYNCWORDL ) - return i; - } - - return -1; -} - -/************************************************************************************** - * Function: AACGetLastFrameInfo - * - * Description: get info about last AAC frame decoded (number of samples decoded, - * sample rate, bit rate, etc.) - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * pointer to AACFrameInfo struct - * - * Outputs: filled-in AACFrameInfo struct - * - * Return: none - * - * Notes: call this right after calling AACDecode() - **************************************************************************************/ -void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) { - aacFrameInfo->bitRate = 0; - aacFrameInfo->nChans = 0; - aacFrameInfo->sampRateCore = 0; - aacFrameInfo->sampRateOut = 0; - aacFrameInfo->bitsPerSample = 0; - aacFrameInfo->outputSamps = 0; - aacFrameInfo->profile = 0; - aacFrameInfo->tnsUsed = 0; - aacFrameInfo->pnsUsed = 0; - } else { - aacFrameInfo->bitRate = aacDecInfo->bitRate; - aacFrameInfo->nChans = aacDecInfo->nChans; - aacFrameInfo->sampRateCore = aacDecInfo->sampRate; - aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1); - aacFrameInfo->bitsPerSample = 16; - aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1); - aacFrameInfo->profile = aacDecInfo->profile; - aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed; - aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed; - } -} - -/************************************************************************************** - * Function: AACSetRawBlockParams - * - * Description: set internal state variables for decoding a stream of raw data blocks - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * flag indicating source of parameters - * AACFrameInfo struct, with the members nChans, sampRate, and profile - * optionally filled-in - * - * Outputs: updated codec state - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: if copyLast == 1, then the codec sets up its internal state (for - * decoding raw blocks) based on previously-decoded ADTS header info - * if copyLast == 0, then the codec uses the values passed in - * aacFrameInfo to configure its internal state (useful when the - * source is MP4 format, for example) - **************************************************************************************/ -int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - aacDecInfo->format = AAC_FF_RAW; - if (copyLast) - return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0); - else - return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile); -} - -/************************************************************************************** - * Function: AACFlushCodec - * - * Description: flush internal codec state (after seeking, for example) - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int AACFlushCodec(HAACDecoder hAACDecoder) -{ - int ch; - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* reset common state variables which change per-frame - * don't touch state variables which are (usually) constant for entire clip - * (nChans, sampRate, profile, format, sbrEnabled) - */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - for (ch = 0; ch < MAX_NCHANS_ELEM; ch++) - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - aacDecInfo->adtsBlocksLeft = 0; - aacDecInfo->tnsUsed = 0; - aacDecInfo->pnsUsed = 0; - - /* reset internal codec state (flush overlap buffers, etc.) */ - FlushCodec(aacDecInfo); -#ifdef AAC_ENABLE_SBR - FlushCodecSBR(aacDecInfo); -#endif - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: AACDecode - * - * Description: decode AAC frame - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * double pointer to buffer of AAC data - * pointer to number of valid bytes remaining in inbuf - * pointer to outbuf, big enough to hold one frame of decoded PCM samples - * (outbuf must be double-sized if SBR enabled) - * - * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo - * number of output samples = 1024 per channel (2048 if SBR enabled) - * updated inbuf pointer - * updated bytesLeft - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: inbuf pointer and bytesLeft are not updated until whole frame is - * successfully decoded, so if ERR_AAC_INDATA_UNDERFLOW is returned - * just call AACDecode again with more data in inbuf - **************************************************************************************/ -int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf) -{ - int err, offset, bitOffset, bitsAvail; - int ch, baseChan, elementChans; - unsigned char *inptr; - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; -#ifdef AAC_ENABLE_SBR - int baseChanSBR, elementChansSBR; -#endif - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* make local copies (see "Notes" above) */ - inptr = *inbuf; - bitOffset = 0; - bitsAvail = (*bytesLeft) << 3; - - /* first time through figure out what the file format is */ - if (aacDecInfo->format == AAC_FF_Unknown) { - if (bitsAvail < 32) - return ERR_AAC_INDATA_UNDERFLOW; - - if (IS_ADIF(inptr)) { - /* unpack ADIF header */ - aacDecInfo->format = AAC_FF_ADIF; - err = UnpackADIFHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - } else { - /* assume ADTS by default */ - aacDecInfo->format = AAC_FF_ADTS; - } - } - - - - /* if ADTS, search for start of next frame */ - if (aacDecInfo->format == AAC_FF_ADTS) { - /* can have 1-4 raw data blocks per ADTS frame (header only present for first one) */ - if (aacDecInfo->adtsBlocksLeft == 0) { - offset = AACFindSyncWord(inptr, bitsAvail >> 3); - if (offset < 0) - return ERR_AAC_INDATA_UNDERFLOW; - inptr += offset; - bitsAvail -= (offset << 3); - - err = UnpackADTSHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - - if (aacDecInfo->nChans == -1) { - /* figure out implicit channel mapping if necessary */ - err = GetADTSChannelMapping(aacDecInfo, inptr, bitOffset, bitsAvail); - if (err) - return err; - } - } - aacDecInfo->adtsBlocksLeft--; - } else if (aacDecInfo->format == AAC_FF_RAW) { - err = PrepareRawBlock(aacDecInfo); - if (err) - return err; - } - - - - /* check for valid number of channels */ - if (aacDecInfo->nChans > AAC_MAX_NCHANS || aacDecInfo->nChans <= 0) - return ERR_AAC_NCHANS_TOO_HIGH; - - /* will be set later if active in this frame */ - aacDecInfo->tnsUsed = 0; - aacDecInfo->pnsUsed = 0; - - bitOffset = 0; - baseChan = 0; -#ifdef AAC_ENABLE_SBR - baseChanSBR = 0; -#endif - do { - - - - /* parse next syntactic element */ - err = DecodeNextElement(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - - elementChans = elementNumChans[aacDecInfo->currBlockID]; - if (baseChan + elementChans > AAC_MAX_NCHANS) - return ERR_AAC_NCHANS_TOO_HIGH; - - /* noiseless decoder and dequantizer */ - for (ch = 0; ch < elementChans; ch++) { - PROFILE_START("noiseless decoder"); - err = DecodeNoiselessData(aacDecInfo, &inptr, &bitOffset, &bitsAvail, ch); - PROFILE_END(); - - if (err) - return err; - - PROFILE_START("dequant"); - if (Dequantize(aacDecInfo, ch)) - return ERR_AAC_DEQUANT; - PROFILE_END(); - } - - PROFILE_START("mid-side and intensity stereo"); - /* mid-side and intensity stereo */ - if (aacDecInfo->currBlockID == AAC_ID_CPE) { - if (StereoProcess(aacDecInfo)) - return ERR_AAC_STEREO_PROCESS; - } - PROFILE_END(); - - - /* PNS, TNS, inverse transform */ - for (ch = 0; ch < elementChans; ch++) { - PROFILE_START("PNS"); - if (PNS(aacDecInfo, ch)) - return ERR_AAC_PNS; - PROFILE_END(); - - if (aacDecInfo->sbDeinterleaveReqd[ch]) { - /* deinterleave short blocks, if required */ - if (DeinterleaveShortBlocks(aacDecInfo, ch)) - return ERR_AAC_SHORT_BLOCK_DEINT; - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - } - - PROFILE_START("TNS"); - if (TNSFilter(aacDecInfo, ch)) - return ERR_AAC_TNS; - PROFILE_END(); - - PROFILE_START("IMDCT"); - if (IMDCT(aacDecInfo, ch, baseChan + ch, outbuf)) - return ERR_AAC_IMDCT; - PROFILE_END(); - } - -#ifdef AAC_ENABLE_SBR - if (aacDecInfo->sbrEnabled && (aacDecInfo->currBlockID == AAC_ID_FIL || aacDecInfo->currBlockID == AAC_ID_LFE)) { - if (aacDecInfo->currBlockID == AAC_ID_LFE) - elementChansSBR = elementNumChans[AAC_ID_LFE]; - else if (aacDecInfo->currBlockID == AAC_ID_FIL && (aacDecInfo->prevBlockID == AAC_ID_SCE || aacDecInfo->prevBlockID == AAC_ID_CPE)) - elementChansSBR = elementNumChans[aacDecInfo->prevBlockID]; - else - elementChansSBR = 0; - - if (baseChanSBR + elementChansSBR > AAC_MAX_NCHANS) - return ERR_AAC_SBR_NCHANS_TOO_HIGH; - - /* parse SBR extension data if present (contained in a fill element) */ - if (DecodeSBRBitstream(aacDecInfo, baseChanSBR)) - return ERR_AAC_SBR_BITSTREAM; - - /* apply SBR */ - if (DecodeSBRData(aacDecInfo, baseChanSBR, outbuf)) - return ERR_AAC_SBR_DATA; - - baseChanSBR += elementChansSBR; - } -#endif - - baseChan += elementChans; - } while (aacDecInfo->currBlockID != AAC_ID_END); - - /* byte align after each raw_data_block */ - if (bitOffset) { - inptr++; - bitsAvail -= (8-bitOffset); - bitOffset = 0; - if (bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - } - - /* update pointers */ - aacDecInfo->frameCount++; - *bytesLeft -= (inptr - *inbuf); - *inbuf = inptr; - - return ERR_AAC_NONE; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/aacdec.h b/components/spotify/cspot/bell/external/libhelix-aac/aacdec.h deleted file mode 100644 index 9cc738e7..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/aacdec.h +++ /dev/null @@ -1,175 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * aacdec.h - public C API for AAC decoder - **************************************************************************************/ - -#ifndef _AACDEC_H -#define _AACDEC_H - -#if defined(_WIN32) && !defined(_WIN32_WCE) -# -#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM) -# -#elif defined(_WIN32) && defined(WINCE_EMULATOR) -# -#elif defined (__arm) && defined (__ARMCC_VERSION) -# -#elif defined(_SYMBIAN) && defined(__WINS__) -# -#elif defined(__GNUC__) && defined(__arm__) -# -#elif defined(__GNUC__) && defined(__i386__) -# -#elif defined(__APPLE__) -# -#elif defined(__GNUC__) && defined(__amd64__) -# -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) -# -#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR) -# -#elif defined(_SOLARIS) && !defined(__GNUC__) -# -#elif defined(ESP_PLATFORM) -# -#else -#error No platform defined. See valid options in aacdec.h -#endif - -#ifndef USE_DEFAULT_STDLIB -#define USE_DEFAULT_STDLIB -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3) - * max size of input buffer = - * 6144 bits = 768 bytes per SCE or CCE-I - * 12288 bits = 1536 bytes per CPE - * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to) - */ -#ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */ -#define AAC_MAX_NCHANS 2 /* set to default max number of channels */ -#endif -#define AAC_MAX_NSAMPS 1024 -#define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS) - -#define AAC_NUM_PROFILES 3 -#define AAC_PROFILE_MP 0 -#define AAC_PROFILE_LC 1 -#define AAC_PROFILE_SSR 2 - -/* define these to enable decoder features */ -#if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR) -#define AAC_ENABLE_SBR -#endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR. -#define AAC_ENABLE_MPEG4 - -enum { - ERR_AAC_NONE = 0, - ERR_AAC_INDATA_UNDERFLOW = -1, - ERR_AAC_NULL_POINTER = -2, - ERR_AAC_INVALID_ADTS_HEADER = -3, - ERR_AAC_INVALID_ADIF_HEADER = -4, - ERR_AAC_INVALID_FRAME = -5, - ERR_AAC_MPEG4_UNSUPPORTED = -6, - ERR_AAC_CHANNEL_MAP = -7, - ERR_AAC_SYNTAX_ELEMENT = -8, - - ERR_AAC_DEQUANT = -9, - ERR_AAC_STEREO_PROCESS = -10, - ERR_AAC_PNS = -11, - ERR_AAC_SHORT_BLOCK_DEINT = -12, - ERR_AAC_TNS = -13, - ERR_AAC_IMDCT = -14, - ERR_AAC_NCHANS_TOO_HIGH = -15, - - ERR_AAC_SBR_INIT = -16, - ERR_AAC_SBR_BITSTREAM = -17, - ERR_AAC_SBR_DATA = -18, - ERR_AAC_SBR_PCM_FORMAT = -19, - ERR_AAC_SBR_NCHANS_TOO_HIGH = -20, - ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21, - - ERR_AAC_RAWBLOCK_PARAMS = -22, - - ERR_AAC_UNKNOWN = -9999 -}; - -typedef struct _AACFrameInfo { - int bitRate; - int nChans; - int sampRateCore; - int sampRateOut; - int bitsPerSample; - int outputSamps; - int profile; - int tnsUsed; - int pnsUsed; -} AACFrameInfo; - -typedef void *HAACDecoder; - -/* public C API */ -HAACDecoder AACInitDecoder(void); -HAACDecoder AACInitDecoderPre(void *ptr, int sz); -void AACFreeDecoder(HAACDecoder hAACDecoder); -int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf); - -int AACFindSyncWord(unsigned char *buf, int nBytes); -void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo); -int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo); -int AACFlushCodec(HAACDecoder hAACDecoder); - -#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT -int AACInitTrigtabsFloat(void); -void AACFreeTrigtabsFloat(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _AACDEC_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/aactabs.c b/components/spotify/cspot/bell/external/libhelix-aac/aactabs.c deleted file mode 100644 index 1efa20ca..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/aactabs.c +++ /dev/null @@ -1,157 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aactabs.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * aactabs.c - platform-independent tables for AAC decoder (global, read-only) - **************************************************************************************/ - -#include "aaccommon.h" - -/* sample rates (table 4.5.1) */ -const int sampRateTab[NUM_SAMPLE_RATES] PROGMEM = { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000 -}; - -/* max scalefactor band for prediction (main profile only) */ -const int predSFBMax[NUM_SAMPLE_RATES] PROGMEM = { - 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34 -}; - -/* channel mapping (table 1.6.3.4) (-1 = unknown, so need to determine mapping based on rules in 8.5.1) */ -const int channelMapTab[NUM_DEF_CHAN_MAPS] PROGMEM = { - -1, 1, 2, 3, 4, 5, 6, 8 -}; - -/* number of channels in each element (SCE, CPE, etc.) - * see AACElementID in aaccommon.h - */ -const int elementNumChans[NUM_ELEMENTS] PROGMEM = { - 1, 2, 0, 1, 0, 0, 0, 0 -}; - -/* total number of scale factor bands in one window */ -const unsigned int /*char*/ sfBandTotalShort[NUM_SAMPLE_RATES] PROGMEM = { - 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15 -}; - -const unsigned int /*char*/ sfBandTotalLong[NUM_SAMPLE_RATES] PROGMEM = { - 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40 -}; - -/* scale factor band tables */ -const int sfBandTabShortOffset[NUM_SAMPLE_RATES] PROGMEM = {0, 0, 0, 13, 13, 13, 28, 28, 44, 44, 44, 60}; - -const /*short*/ int sfBandTabShort[76] PROGMEM = { - /* short block 64, 88, 96 kHz [13] (tables 4.5.24, 4.5.26) */ - 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128, - - /* short block 32, 44, 48 kHz [15] (table 4.5.15) */ - 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128, - - /* short block 22, 24 kHz [16] (table 4.5.22) */ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128, - - /* short block 11, 12, 16 kHz [16] (table 4.5.20) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128, - - /* short block 8 kHz [16] (table 4.5.18) */ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128 -}; - -const int sfBandTabLongOffset[NUM_SAMPLE_RATES] PROGMEM = {0, 0, 42, 90, 90, 140, 192, 192, 240, 240, 240, 284}; - -const /*short*/ int sfBandTabLong[325] PROGMEM = { - /* long block 88, 96 kHz [42] (table 4.5.25) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, - 56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, - 240, 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, - - /* long block 64 kHz [48] (table 4.5.13) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, - 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, 304, 344, 384, - 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824, 864, 904, 944, 984, 1024, - - /* long block 44, 48 kHz [50] (table 4.5.14) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 88, - 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, 384, 416, 448, - 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 1024, - - /* long block 32 kHz [52] (table 4.5.16) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 88, 96, - 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, - 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, - - /* long block 22, 24 kHz [48] (table 4.5.21) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 76, - 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, 240, 260, 284, - 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, 768, 832, 896, 960, 1024, - - /* long block 11, 12, 16 kHz [44] (table 4.5.19) */ - 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, - 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, 368, - 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024, - - /* long block 8 kHz [41] (table 4.5.17) */ - 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, - 172, 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, - 448, 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024 -}; - - -/* TNS max bands (table 4.139) and max order (table 4.138) */ -const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES] PROGMEM = {0, 0, 12}; - -const unsigned /*char*/ int tnsMaxBandsShort[2*NUM_SAMPLE_RATES] PROGMEM = { - 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, /* short block, Main/LC */ - 7, 7, 7, 6, 6, 6, 7, 7, 8, 8, 8, 7 /* short block, SSR */ -}; - -const unsigned /*char*/ int tnsMaxOrderShort[AAC_NUM_PROFILES] PROGMEM = {7, 7, 7}; - -const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES] PROGMEM = {0, 0, 12}; - -const unsigned int /*char*/ tnsMaxBandsLong[2*NUM_SAMPLE_RATES] PROGMEM = { - 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, /* long block, Main/LC */ - 28, 28, 27, 26, 26, 26, 29, 29, 23, 23, 23, 19, /* long block, SSR */ -}; - -const unsigned /*char*/ int tnsMaxOrderLong[AAC_NUM_PROFILES] PROGMEM = {20, 12, 12}; diff --git a/components/spotify/cspot/bell/external/libhelix-aac/assembly.h b/components/spotify/cspot/bell/external/libhelix-aac/assembly.h deleted file mode 100644 index 4a45236d..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/assembly.h +++ /dev/null @@ -1,728 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * assembly.h - inline assembly language functions and prototypes - * - * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), - * returns top 32-bits of 64-bit result - * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short, - * clipping to [-32768, 32767] - * FASTABS(x) branchless absolute value of signed integer x - * CLZ(x) count leading zeros on signed integer x - * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y) - **************************************************************************************/ - -#ifndef _ASSEMBLY_H -#define _ASSEMBLY_H - -/* toolchain: MSFT Visual C++ - * target architecture: x86 - */ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR)) - -#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */ - -static __inline int MULSHIFT32(int x, int y) -{ - __asm { - mov eax, x - imul y - mov eax, edx - } -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -#ifdef __CW32__ -typedef long long Word64; -#else -typedef __int64 Word64; -#endif - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -/* returns 64-bit value in [edx:eax] */ -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ -#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__) -/* Workaround for the Symbian emulator because of non existing longlong.lib and - * hence __allmul not defined. */ - __asm { - mov eax, x - imul y - add dword ptr sum64, eax - adc dword ptr sum64 + 4, edx - } -#else - sum64 += (Word64)x * (Word64)y; -#endif - - return sum64; -} - -/* toolchain: MSFT Embedded Visual C++ - * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier) - */ -#elif defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM) - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -/* implemented in asmfunc.s */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef __int64 Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* ARM WinCE = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -/* manual name mangling for just this platform (must match labels in .s file) */ -#define MULSHIFT32 raac_MULSHIFT32 -#define MADD64 raac_MADD64 - -int MULSHIFT32(int x, int y); -Word64 MADD64(Word64 sum64, int x, int y); - -#ifdef __cplusplus -} -#endif - -/* toolchain: ARM ADS or RealView - * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier) - */ -#elif defined (XXX__arm) && defined (__ARMCC_VERSION) - -static __inline int MULSHIFT32(int x, int y) -{ - /* rules for smull RdLo, RdHi, Rm, Rs: - * RdHi != Rm - * RdLo != Rm - * RdHi != RdLo - */ - int zlow; - __asm { - smull zlow,y,x,y - } - - return y; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; - -/* ARM code would look like this, but do NOT use inline asm in ADS for this, - because you can't safely use the status register flags intermixed with C code - - __asm { - mov numZeros, #1 - tst x, 0xffff0000 - addeq numZeros, numZeros, #16 - moveq x, x, lsl #16 - tst x, 0xff000000 - addeq numZeros, numZeros, #8 - moveq x, x, lsl #8 - tst x, 0xf0000000 - addeq numZeros, numZeros, #4 - moveq x, x, lsl #4 - tst x, 0xc0000000 - addeq numZeros, numZeros, #2 - moveq x, x, lsl #2 - sub numZeros, numZeros, x, lsr #31 - } -*/ -/* reference: - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } -*/ -} - -typedef __int64 Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* ARM ADS = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - U64 u; - u.w64 = sum64; - - __asm { - smlal u.r.lo32, u.r.hi32, x, y - } - - return u.w64; -} - -/* toolchain: ARM gcc - * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier) - */ -#elif defined(__GNUC__) && defined(XXXX__arm__) - -static inline int MULSHIFT32(int x, int y) -{ - int zlow; - asm ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y) : "cc"); - return y; -} -/* -static inline short CLIPTOSHORT(int x) -{ - int sign; - - // clip to [-32768, 32767] // - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} -*/ -static inline short CLIPTOSHORT(int x) -{ - asm ("ssat %0, #16, %1" : "=r" (x) : "r" (x)); - return x; -} - -/* From coder.h, ORIGINAL: -clip to [-2^n, 2^n-1], valid range of n = [1, 30] -//TODO (FB) Is there a better way ? -*/ -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} - -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } - - - -#define FASTABS(x) abs(x) //FB -#define CLZ(x) __builtin_clz(x) //FB - -//Reverse byte order (16 bit) //FB -static inline unsigned int REV16( unsigned int value) -{ - asm ("rev16 %0, %1" : "=r" (value) : "r" (value) ); - return(value); -} - -//Reverse byte order (32 bit) //FB -static inline unsigned int REV32( unsigned int value) -{ - asm ("rev %0, %1" : "=r" (value) : "r" (value) ); - return(value); -} - - -typedef long long Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static inline Word64 MADD64(Word64 sum64, int x, int y) -{ - U64 u; - u.w64 = sum64; - asm ("smlal %0,%1,%2,%3" : "+&r" (u.r.lo32), "+&r" (u.r.hi32) : "r" (x), "r" (y) : "cc"); - return u.w64; -} - -/* toolchain: x86 gcc - * target architecture: x86 - */ -#elif defined(__APPLE__) || defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86)) - -typedef long long Word64; - -static __inline__ int MULSHIFT32(int x, int y) -{ - int z; - - z = (Word64)x * (Word64)y >> 32; - - return z; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} -#elif defined(__arm__) - -typedef long long Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - - -#if defined(ARM7DI) - -static __inline int MULSHIFT32(int x, int y) { - return x * y; -} - -#else - -static __inline int MULSHIFT32(int x, int y) -{ - /* important rules for smull RdLo, RdHi, Rm, Rs: - * RdHi and Rm can't be the same register - * RdLo and Rm can't be the same register - * RdHi and RdLo can't be the same register - * Note: Rs determines early termination (leading sign bits) so if you want to specify - * which operand is Rs, put it in the SECOND argument (y) - * For inline assembly, x and y are not assumed to be R0, R1 so it shouldn't matter - * which one is returned. (If this were a function call, returning y (R1) would - * require an extra "mov r0, r1") - */ - int zlow; - __asm__ volatile ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y)) ; - - return y; -} - -#endif - -static __inline int FASTABS(int x) -{ - int t=0; /*Really is not necessary to initialiaze only to avoid warning*/ - - __asm__ volatile ( - "eor %0,%2,%2, asr #31;" - "sub %0,%1,%2, asr #31;" - : "=&r" (t) - : "0" (t), "r" (x) - ); - - return t; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -#elif defined(ESP_PLATFORM) || defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86)) - -typedef long long Word64; - -static __inline__ int MULSHIFT32(int x, int y) -{ - int z; - - z = (Word64)x * (Word64)y >> 32; - - return z; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -typedef union _U64 { - Word64 w64; - struct { -#ifdef __XTENSA__ - unsigned int lo32; - signed int hi32; -#else - /* PowerPC = big endian */ - signed int hi32; - unsigned int lo32; -#endif - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} - -/* From coder.h, ORIGINAL: -clip to [-2^n, 2^n-1], valid range of n = [1, 30] -//TODO (FB) Is there a better way ? -*/ -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} - -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } - - - -//#define FASTABS(x) abs(x) //FB -//#define CLZ(x) __builtin_clz(x) //FB - -#else - -#error Unsupported platform in assembly.h - -#endif /* platforms */ - -#ifndef CLIP_2N -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} -#endif - -#ifndef CLIP_2N_SHIFT -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } -#endif - -#endif /* _ASSEMBLY_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/bitstream.c b/components/spotify/cspot/bell/external/libhelix-aac/bitstream.c deleted file mode 100644 index 09cb3f65..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/bitstream.c +++ /dev/null @@ -1,261 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: bitstream.c,v 1.2 2005/09/27 20:31:11 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * bitstream.c - bitstream parsing functions - **************************************************************************************/ - -#include "bitstream.h" - -/************************************************************************************** - * Function: SetBitstreamPointer - * - * Description: initialize bitstream reader - * - * Inputs: pointer to BitStreamInfo struct - * number of bytes in bitstream - * pointer to byte-aligned buffer of data to read from - * - * Outputs: initialized bitstream info struct - * - * Return: none - **************************************************************************************/ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf) -{ - /* init bitstream */ - bsi->bytePtr = buf; - bsi->iCache = 0; /* 4-byte unsigned int */ - bsi->cachedBits = 0; /* i.e. zero bits in cache */ - bsi->nBytes = nBytes; -} - -/************************************************************************************** - * Function: RefillBitstreamCache - * - * Description: read new data from bitstream buffer into 32-bit cache - * - * Inputs: pointer to initialized BitStreamInfo struct - * - * Outputs: updated bitstream info struct - * - * Return: none - * - * Notes: only call when iCache is completely drained (resets bitOffset to 0) - * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer) - * stores data as big-endian in cache, regardless of machine endian-ness - **************************************************************************************/ -//Optimized for REV16, REV32 (FB) -static __inline void RefillBitstreamCache(BitStreamInfo *bsi) -{ - int nBytes = bsi->nBytes; - if (nBytes >= 4) { - /* optimize for common case, independent of machine endian-ness */ - bsi->iCache = (*bsi->bytePtr++) << 24; - bsi->iCache |= (*bsi->bytePtr++) << 16; - bsi->iCache |= (*bsi->bytePtr++) << 8; - bsi->iCache |= (*bsi->bytePtr++); - - bsi->cachedBits = 32; - bsi->nBytes -= 4; - } else { - bsi->iCache = 0; - while (nBytes--) { - bsi->iCache |= (*bsi->bytePtr++); - bsi->iCache <<= 8; - } - bsi->iCache <<= ((3 - bsi->nBytes)*8); - bsi->cachedBits = 8*bsi->nBytes; - bsi->nBytes = 0; - } -} - -/************************************************************************************** - * Function: GetBits - * - * Description: get bits from bitstream, advance bitstream pointer - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to get from bitstream - * - * Outputs: updated bitstream info struct - * - * Return: the next nBits bits of data from bitstream buffer - * - * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f - * for speed, does not indicate error if you overrun bit buffer - * if nBits == 0, returns 0 - **************************************************************************************/ -unsigned int GetBits(BitStreamInfo *bsi, int nBits) -{ - unsigned int data, lowBits; - - nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */ - data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */ - data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */ - bsi->iCache <<= nBits; /* left-justify cache */ - bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */ - - /* if we cross an int boundary, refill the cache */ - if (bsi->cachedBits < 0) { - lowBits = -bsi->cachedBits; - RefillBitstreamCache(bsi); - data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */ - - bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */ - bsi->iCache <<= lowBits; /* left-justify cache */ - } - - return data; -} - -/************************************************************************************** - * Function: GetBitsNoAdvance - * - * Description: get bits from bitstream, do not advance bitstream pointer - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to get from bitstream - * - * Outputs: none (state of BitStreamInfo struct left unchanged) - * - * Return: the next nBits bits of data from bitstream buffer - * - * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f - * for speed, does not indicate error if you overrun bit buffer - * if nBits == 0, returns 0 - **************************************************************************************/ -unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits) -{ - unsigned char *buf; - unsigned int data, iCache; - signed int lowBits; - - nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */ - data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */ - data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */ - lowBits = nBits - bsi->cachedBits; /* how many bits do we have left to read */ - - /* if we cross an int boundary, read next bytes in buffer */ - if (lowBits > 0) { - iCache = 0; - buf = bsi->bytePtr; - while (lowBits > 0) { - iCache <<= 8; - if (buf < bsi->bytePtr + bsi->nBytes) - iCache |= (unsigned int)*buf++; - lowBits -= 8; - } - lowBits = -lowBits; - data |= iCache >> lowBits; - } - - return data; -} - -/************************************************************************************** - * Function: AdvanceBitstream - * - * Description: move bitstream pointer ahead - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to advance bitstream - * - * Outputs: updated bitstream info struct - * - * Return: none - * - * Notes: generally used following GetBitsNoAdvance(bsi, maxBits) - **************************************************************************************/ -void AdvanceBitstream(BitStreamInfo *bsi, int nBits) -{ - nBits &= 0x1f; - if (nBits > bsi->cachedBits) { - nBits -= bsi->cachedBits; - RefillBitstreamCache(bsi); - } - bsi->iCache <<= nBits; - bsi->cachedBits -= nBits; -} - -/************************************************************************************** - * Function: CalcBitsUsed - * - * Description: calculate how many bits have been read from bitstream - * - * Inputs: pointer to initialized BitStreamInfo struct - * pointer to start of bitstream buffer - * bit offset into first byte of startBuf (0-7) - * - * Outputs: none - * - * Return: number of bits read from bitstream, as offset from startBuf:startOffset - **************************************************************************************/ -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset) -{ - int bitsUsed; - - bitsUsed = (bsi->bytePtr - startBuf) * 8; - bitsUsed -= bsi->cachedBits; - bitsUsed -= startOffset; - - return bitsUsed; -} - -/************************************************************************************** - * Function: ByteAlignBitstream - * - * Description: bump bitstream pointer to start of next byte - * - * Inputs: pointer to initialized BitStreamInfo struct - * - * Outputs: byte-aligned bitstream BitStreamInfo struct - * - * Return: none - * - * Notes: if bitstream is already byte-aligned, do nothing - **************************************************************************************/ -void ByteAlignBitstream(BitStreamInfo *bsi) -{ - int offset; - - offset = bsi->cachedBits & 0x07; - AdvanceBitstream(bsi, offset); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/bitstream.h b/components/spotify/cspot/bell/external/libhelix-aac/bitstream.h deleted file mode 100644 index de68a989..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/bitstream.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: bitstream.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * bitstream.h - definitions of bitstream handling functions - **************************************************************************************/ - -#ifndef _BITSTREAM_H -#define _BITSTREAM_H - -#include "aaccommon.h" - -/* additional external symbols to name-mangle for static linking */ -#define SetBitstreamPointer STATNAME(SetBitstreamPointer) -#define GetBits STATNAME(GetBits) -#define GetBitsNoAdvance STATNAME(GetBitsNoAdvance) -#define AdvanceBitstream STATNAME(AdvanceBitstream) -#define CalcBitsUsed STATNAME(CalcBitsUsed) -#define ByteAlignBitstream STATNAME(ByteAlignBitstream) - -typedef struct _BitStreamInfo { - unsigned char *bytePtr; - unsigned int iCache; - int cachedBits; - int nBytes; -} BitStreamInfo; - -/* bitstream.c */ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf); -unsigned int GetBits(BitStreamInfo *bsi, int nBits); -unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits); -void AdvanceBitstream(BitStreamInfo *bsi, int nBits); -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset); -void ByteAlignBitstream(BitStreamInfo *bsi); - -#endif /* _BITSTREAM_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/buffers.c b/components/spotify/cspot/bell/external/libhelix-aac/buffers.c deleted file mode 100644 index 9ed39119..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/buffers.c +++ /dev/null @@ -1,165 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: buffers.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * buffers.c - allocation and deallocation of internal AAC decoder buffers - **************************************************************************************/ - -#if defined(USE_DEFAULT_STDLIB) || defined(ESP_PLATFORM) -#include -#else -#include "hlxclib/stdlib.h" -#endif - -#include "coder.h" - -/************************************************************************************** - * Function: ClearBuffer - * - * Description: fill buffer with 0's - * - * Inputs: pointer to buffer - * number of bytes to fill with 0 - * - * Outputs: cleared buffer - * - * Return: none - * - * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes) - **************************************************************************************/ -#include - void ClearBuffer(void *buf, int nBytes) -{ -/* int i; - unsigned char *cbuf = (unsigned char *)buf; - - for (i = 0; i < nBytes; i++) - cbuf[i] = 0; - - return; - */ - memset(buf, 0, nBytes); -} - -/************************************************************************************** - * Function: AllocateBuffers - * - * Description: allocate all the memory needed for the AAC decoder - * - * Inputs: none - * - * Outputs: none - * - * Return: pointer to AACDecInfo structure, cleared to all 0's (except for - * pointer to platform-specific data structure) - * - * Notes: if one or more mallocs fail, function frees any buffers already - * allocated before returning - **************************************************************************************/ -AACDecInfo *AllocateBuffers(void) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = (AACDecInfo *)malloc(sizeof(AACDecInfo)); - if (!aacDecInfo) - return 0; - ClearBuffer(aacDecInfo, sizeof(AACDecInfo)); - - aacDecInfo->psInfoBase = malloc(sizeof(PSInfoBase)); - if (!aacDecInfo->psInfoBase) { - FreeBuffers(aacDecInfo); - return 0; - } - ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase)); - - return aacDecInfo; -} - -AACDecInfo *AllocateBuffersPre(void **ptr, int *sz) -{ - AACDecInfo *aacDecInfo; - - char *p = (char*)*ptr; - aacDecInfo = (AACDecInfo *)p; - p += (sizeof(AACDecInfo) +7 ) & ~7; - *sz -= (sizeof(AACDecInfo) +7 ) & ~7; - if (*sz < 0) - return 0; - ClearBuffer(aacDecInfo, sizeof(AACDecInfo)); - - aacDecInfo->psInfoBase = (PSInfoBase*)p; - p += (sizeof(PSInfoBase) + 7) & ~7; - *sz -= (sizeof(PSInfoBase) + 7) & ~7; - if (*sz <0) { - return 0; - } - ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase)); - - *ptr = p; - - return aacDecInfo; -} - -#ifndef SAFE_FREE -#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */ -#endif - -/************************************************************************************** - * Function: FreeBuffers - * - * Description: frees all the memory used by the AAC decoder - * - * Inputs: pointer to initialized AACDecInfo structure - * - * Outputs: none - * - * Return: none - * - * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE) - **************************************************************************************/ -void FreeBuffers(AACDecInfo *aacDecInfo) -{ - if (!aacDecInfo) - return; - - SAFE_FREE(aacDecInfo->psInfoBase); - SAFE_FREE(aacDecInfo); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/coder.h b/components/spotify/cspot/bell/external/libhelix-aac/coder.h deleted file mode 100644 index 9609e393..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/coder.h +++ /dev/null @@ -1,373 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: coder.h,v 1.2 2005/06/27 21:06:00 gwright Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * coder.h - definitions of platform-specific data structures, functions, and tables - **************************************************************************************/ - -#ifndef _CODER_H -#define _CODER_H - -#include "aaccommon.h" -#include "bitstream.h" - -#ifndef ASSERT -#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS)) -#define ASSERT(x) if (!(x)) __asm int 3; -#else -#define ASSERT(x) /* do nothing */ -#endif -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define NWINDOWS_LONG 1 -#define NWINDOWS_SHORT 8 - -#define DATA_BUF_SIZE 510 /* max count = 255 + 255 */ -#define FILL_BUF_SIZE 269 /* max count = 15 + 255 - 1*/ -#define ADIF_COPYID_SIZE 9 -#define MAX_COMMENT_BYTES 255 - -#define MAX_NUM_FCE 15 -#define MAX_NUM_SCE 15 -#define MAX_NUM_BCE 15 -#define MAX_NUM_LCE 3 -#define MAX_NUM_ADE 7 -#define MAX_NUM_CCE 15 - -#define CHAN_ELEM_IS_CPE(x) (((x) & 0x10) >> 4) /* bit 4 = SCE/CPE flag */ -#define CHAN_ELEM_GET_TAG(x) (((x) & 0x0f) >> 0) /* bits 3-0 = instance tag */ - -#define CHAN_ELEM_SET_CPE(x) (((x) & 0x01) << 4) /* bit 4 = SCE/CPE flag */ -#define CHAN_ELEM_SET_TAG(x) (((x) & 0x0f) << 0) /* bits 3-0 = instance tag */ - -#define MAX_HUFF_BITS 20 -#define HUFFTAB_SPEC_OFFSET 1 - -/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */ -/* -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } -*/ -/* clip to [-2^n, 2^n-1], valid range of n = [1, 30] */ -/* -#define CLIP_2N(val, n) { \ - if ((val) >> 31 != (val) >> (n)) \ - (val) = ((val) >> 31) ^ ((1 << (n)) - 1); \ - } -*/ - - -#define SF_DQ_OFFSET 15 -#define FBITS_OUT_DQ 20 -#define FBITS_OUT_DQ_OFF (FBITS_OUT_DQ - SF_DQ_OFFSET) /* number of fraction bits out of dequant, including 2^15 bias */ - -#define FBITS_IN_IMDCT FBITS_OUT_DQ_OFF /* number of fraction bits into IMDCT */ -#define GBITS_IN_DCT4 4 /* min guard bits in for DCT4 */ - -#define FBITS_LOST_DCT4 1 /* number of fraction bits lost (>> out) in DCT-IV */ -#define FBITS_LOST_WND 1 /* number of fraction bits lost (>> out) in synthesis window (neg = gain frac bits) */ -#define FBITS_LOST_IMDCT (FBITS_LOST_DCT4 + FBITS_LOST_WND) -#define FBITS_OUT_IMDCT (FBITS_IN_IMDCT - FBITS_LOST_IMDCT) - -#define NUM_IMDCT_SIZES 2 - -/* additional external symbols to name-mangle for static linking */ -#define DecodeProgramConfigElement STATNAME(DecodeProgramConfigElement) -#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar) -#define DecodeSpectrumLong STATNAME(DecodeSpectrumLong) -#define DecodeSpectrumShort STATNAME(DecodeSpectrumShort) -#define DecodeICSInfo STATNAME(DecodeICSInfo) -#define DCT4 STATNAME(DCT4) -#define R4FFT STATNAME(R4FFT) - -#define DecWindowOverlapNoClip STATNAME(DecWindowOverlapNoClip) -#define DecWindowOverlapLongStartNoClip STATNAME(DecWindowOverlapLongStartNoClip) -#define DecWindowOverlapLongStopNoClip STATNAME(DecWindowOverlapLongStopNoClip) -#define DecWindowOverlapShortNoClip STATNAME(DecWindowOverlapShortNoClip) - -#define huffTabSpecInfo STATNAME(huffTabSpecInfo) -#define huffTabSpec STATNAME(huffTabSpec) -#define huffTabScaleFactInfo STATNAME(huffTabScaleFactInfo) -#define huffTabScaleFact STATNAME(huffTabScaleFact) -#define cos4sin4tab STATNAME(cos4sin4tab) -#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset) -#define cos1sin1tab STATNAME(cos1sin1tab) -#define sinWindow STATNAME(sinWindow) -#define sinWindowOffset STATNAME(sinWindowOffset) -#define kbdWindow STATNAME(kbdWindow) -#define kbdWindowOffset STATNAME(kbdWindowOffset) -#define bitrevtab STATNAME(bitrevtab) -#define bitrevtabOffset STATNAME(bitrevtabOffset) -#define uniqueIDTab STATNAME(uniqueIDTab) -#define twidTabEven STATNAME(twidTabEven) -#define twidTabOdd STATNAME(twidTabOdd) - -typedef struct _HuffInfo { - int maxBits; /* number of bits in longest codeword */ - unsigned /*char*/ int count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */ - int offset; /* offset into symbol table */ -} HuffInfo; - -typedef struct _PulseInfo { - unsigned char pulseDataPresent; - unsigned char numPulse; - unsigned char startSFB; - unsigned char offset[MAX_PULSES]; - unsigned char amp[MAX_PULSES]; -} PulseInfo; - -typedef struct _TNSInfo { - unsigned char tnsDataPresent; - unsigned char numFilt[MAX_TNS_FILTERS]; /* max 1 filter each for 8 short windows, or 3 filters for 1 long window */ - unsigned char coefRes[MAX_TNS_FILTERS]; - unsigned char length[MAX_TNS_FILTERS]; - unsigned char order[MAX_TNS_FILTERS]; - unsigned char dir[MAX_TNS_FILTERS]; - signed char coef[MAX_TNS_COEFS]; /* max 3 filters * 20 coefs for 1 long window, or 1 filter * 7 coefs for each of 8 short windows */ -} TNSInfo; - -typedef struct _GainControlInfo { - unsigned char gainControlDataPresent; - unsigned char maxBand; - unsigned char adjNum[MAX_GAIN_BANDS][MAX_GAIN_WIN]; - unsigned char alevCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST]; - unsigned char alocCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST]; -} GainControlInfo; - -typedef struct _ICSInfo { - unsigned char icsResBit; - unsigned char winSequence; - unsigned char winShape; - unsigned char maxSFB; - unsigned char sfGroup; - unsigned char predictorDataPresent; - unsigned char predictorReset; - unsigned char predictorResetGroupNum; - unsigned char predictionUsed[MAX_PRED_SFB]; - unsigned char numWinGroup; - unsigned char winGroupLen[MAX_WIN_GROUPS]; -} ICSInfo; - -typedef struct _ADTSHeader { - /* fixed */ - unsigned char id; /* MPEG bit - should be 1 */ - unsigned char layer; /* MPEG layer - should be 0 */ - unsigned char protectBit; /* 0 = CRC word follows, 1 = no CRC word */ - unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */ - unsigned char sampRateIdx; /* sample rate index range = [0, 11] */ - unsigned char privateBit; /* ignore */ - unsigned char channelConfig; /* 0 = implicit, >0 = use default table */ - unsigned char origCopy; /* 0 = copy, 1 = original */ - unsigned char home; /* ignore */ - - /* variable */ - unsigned char copyBit; /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */ - unsigned char copyStart; /* 1 = this bit starts the 72-bit ID, 0 = it does not */ - int frameLength; /* length of frame */ - int bufferFull; /* number of 32-bit words left in enc buffer, 0x7FF = VBR */ - unsigned char numRawDataBlocks; /* number of raw data blocks in frame */ - - /* CRC */ - int crcCheckWord; /* 16-bit CRC check word (present if protectBit == 0) */ -} ADTSHeader; - -typedef struct _ADIFHeader { - unsigned char copyBit; /* 0 = no copyright ID, 1 = 72-bit copyright ID follows immediately */ - unsigned char origCopy; /* 0 = copy, 1 = original */ - unsigned char home; /* ignore */ - unsigned char bsType; /* bitstream type: 0 = CBR, 1 = VBR */ - int bitRate; /* bitRate: CBR = bits/sec, VBR = peak bits/frame, 0 = unknown */ - unsigned char numPCE; /* number of program config elements (max = 16) */ - int bufferFull; /* bits left in bit reservoir */ - unsigned char copyID[ADIF_COPYID_SIZE]; /* optional 72-bit copyright ID */ -} ADIFHeader; - -/* sizeof(ProgConfigElement) = 82 bytes (if KEEP_PCE_COMMENTS not defined) */ -typedef struct _ProgConfigElement { - unsigned char elemInstTag; /* element instance tag */ - unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */ - unsigned char sampRateIdx; /* sample rate index range = [0, 11] */ - unsigned char numFCE; /* number of front channel elements (max = 15) */ - unsigned char numSCE; /* number of side channel elements (max = 15) */ - unsigned char numBCE; /* number of back channel elements (max = 15) */ - unsigned char numLCE; /* number of LFE channel elements (max = 3) */ - unsigned char numADE; /* number of associated data elements (max = 7) */ - unsigned char numCCE; /* number of valid channel coupling elements (max = 15) */ - unsigned char monoMixdown; /* mono mixdown: bit 4 = present flag, bits 3-0 = element number */ - unsigned char stereoMixdown; /* stereo mixdown: bit 4 = present flag, bits 3-0 = element number */ - unsigned char matrixMixdown; /* matrix mixdown: bit 4 = present flag, bit 3 = unused, - bits 2-1 = index, bit 0 = pseudo-surround enable */ - unsigned char fce[MAX_NUM_FCE]; /* front element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char sce[MAX_NUM_SCE]; /* side element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char bce[MAX_NUM_BCE]; /* back element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char lce[MAX_NUM_LCE]; /* instance tag for LFE elements */ - unsigned char ade[MAX_NUM_ADE]; /* instance tag for ADE elements */ - unsigned char cce[MAX_NUM_BCE]; /* channel coupling elements: bit 4 = switching flag, bits 3-0 = inst tag */ - -#ifdef KEEP_PCE_COMMENTS - /* make this optional - if not enabled, decoder will just skip comments */ - unsigned char commentBytes; - unsigned char commentField[MAX_COMMENT_BYTES]; -#endif - -} ProgConfigElement; - -/* state info struct for baseline (MPEG-4 LC) decoding */ -typedef struct _PSInfoBase { - /* header information */ - ADTSHeader fhADTS; - ADIFHeader fhADIF; - ProgConfigElement pce[MAX_NUM_PCE_ADIF]; - int dataCount; - unsigned char dataBuf[DATA_BUF_SIZE]; - int fillCount; - unsigned char fillBuf[FILL_BUF_SIZE]; - - /* state information which is the same throughout whole frame */ - int nChans; - int useImpChanMap; - int sampRateIdx; - - /* state information which can be overwritten by subsequent elements within frame */ - ICSInfo icsInfo[MAX_NCHANS_ELEM]; - - int commonWin; - short scaleFactors[MAX_NCHANS_ELEM][MAX_SF_BANDS]; - unsigned char sfbCodeBook[MAX_NCHANS_ELEM][MAX_SF_BANDS]; - - int msMaskPresent; - unsigned char msMaskBits[MAX_MS_MASK_BYTES]; - - int pnsUsed[MAX_NCHANS_ELEM]; - int pnsLastVal; - int intensityUsed[MAX_NCHANS_ELEM]; - - PulseInfo pulseInfo[MAX_NCHANS_ELEM]; - - TNSInfo tnsInfo[MAX_NCHANS_ELEM]; - int tnsLPCBuf[MAX_TNS_ORDER]; - int tnsWorkBuf[MAX_TNS_ORDER]; - - GainControlInfo gainControlInfo[MAX_NCHANS_ELEM]; - - int gbCurrent[MAX_NCHANS_ELEM]; - int coef[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS]; -#ifdef AAC_ENABLE_SBR - int sbrWorkBuf[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS]; -#endif - /* state information which must be saved for each element and used in next frame */ - int overlap[AAC_MAX_NCHANS][AAC_MAX_NSAMPS]; - int prevWinShape[AAC_MAX_NCHANS]; - -} PSInfoBase; - -/* private implementation-specific functions */ - -/* decelmnt.c */ -int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi); - -/* huffman.c */ -int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val); -void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch); -void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch); - -/* noiseless.c */ -void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx); - -/* dct4.c */ -void DCT4(int tabidx, int *coef, int gb); - -/* fft.c */ -void R4FFT(int tabidx, int *x); - -/* sbrimdct.c */ -void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); - -/* hufftabs.c */ -extern const HuffInfo huffTabSpecInfo[11]; -extern const signed short huffTabSpec[1241]; -extern const HuffInfo huffTabScaleFactInfo; -extern const signed short huffTabScaleFact[121]; - -/* trigtabs.c */ -extern const int cos4sin4tabOffset[NUM_IMDCT_SIZES]; -extern const int sinWindowOffset[NUM_IMDCT_SIZES]; -extern const int kbdWindowOffset[NUM_IMDCT_SIZES]; -extern const unsigned char bitrevtab[17 + 129]; -extern const int bitrevtabOffset[NUM_IMDCT_SIZES]; - -#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT -/* trigtabs_fltgen.c */ -extern int cos4sin4tab[128 + 1024]; -extern int cos1sin1tab[514]; -extern int sinWindow[128 + 1024]; -extern int kbdWindow[128 + 1024]; -extern int twidTabEven[4*6 + 16*6 + 64*6]; -extern int twidTabOdd[8*6 + 32*6 + 128*6]; -#else -/* trigtabs.c */ -extern const int cos4sin4tab[128 + 1024]; -extern const int cos1sin1tab[514]; -extern const int sinWindow[128 + 1024]; -extern const int kbdWindow[128 + 1024]; -extern const int twidTabEven[4*6 + 16*6 + 64*6]; -extern const int twidTabOdd[8*6 + 32*6 + 128*6]; -#endif - -#endif /* _CODER_H */ - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/dct4.c b/components/spotify/cspot/bell/external/libhelix-aac/dct4.c deleted file mode 100644 index 698f54b6..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/dct4.c +++ /dev/null @@ -1,337 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: dct4.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * dct4.c - optimized DCT-IV - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -static const int nmdctTab[NUM_IMDCT_SIZES] PROGMEM = {128, 1024}; -static const int postSkip[NUM_IMDCT_SIZES] PROGMEM = {15, 1}; - -/************************************************************************************** - * Function: PreMultiply - * - * Description: pre-twiddle stage of DCT4 - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 5 (short) or 8 (long) frac bits - * i.e. gains 2-7= -5 int bits (short) or 2-10 = -8 int bits (long) - * normalization by -1/N is rolled into tables here (see trigtabs.c) - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PreMultiply(int tabidx, int *zbuf1) -{ - int i, nmdct, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - zbuf2 = zbuf1 + nmdct - 1; - csptr = cos4sin4tab + cos4sin4tabOffset[tabidx]; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = nmdct >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0); - ai2 = *(zbuf1 + 1); - ai1 = *(zbuf2 + 0); - ar2 = *(zbuf2 - 1); - - /* gain 2 ints bit from MULSHIFT32 by Q30, but drop 7 or 10 int bits from table scaling of 1/M - * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */ - *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */ - *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */ - } -} - -/************************************************************************************** - * Function: PostMultiply - * - * Description: post-twiddle stage of DCT4 - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out - gains 2 int bits - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PostMultiply(int tabidx, int *fft1) -{ - int i, nmdct, ar1, ai1, ar2, ai2, skipFactor; - int t, cms2, cps2, sin2; - int *fft2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - csptr = cos1sin1tab; - skipFactor = postSkip[tabidx]; - fft2 = fft1 + nmdct - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) - */ - cps2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - cms2 = cps2 - 2*sin2; - - for (i = nmdct >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ar2 = *(fft2 - 1); - ai2 = *(fft2 + 0); - - /* gain 2 ints bit from MULSHIFT32 by Q30 - * max per-sample gain = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2, ar1 + ai1); - *fft2-- = t - MULSHIFT32(cps2, ai1); /* sin*ar1 - cos*ai1 */ - *fft1++ = t + MULSHIFT32(cms2, ar1); /* cos*ar1 + sin*ai1 */ - cps2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - *fft2-- = t - MULSHIFT32(cps2, ai2); /* sin*ar1 - cos*ai1 */ - cms2 = cps2 - 2*sin2; - *fft1++ = t + MULSHIFT32(cms2, ar2); /* cos*ar1 + sin*ai1 */ - } -} - -/************************************************************************************** - * Function: PreMultiplyRescale - * - * Description: pre-twiddle stage of DCT4, with rescaling for extra guard bits - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits to add to input before processing - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: see notes on PreMultiply(), above - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void PreMultiplyRescale(int tabidx, int *zbuf1, int es) -{ - int i, nmdct, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - zbuf2 = zbuf1 + nmdct - 1; - csptr = cos4sin4tab + cos4sin4tabOffset[tabidx]; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = nmdct >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0) >> es; - ai1 = *(zbuf2 + 0) >> es; - ai2 = *(zbuf1 + 1) >> es; - - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; - *zbuf1++ = z2; - - ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; - *zbuf2-- = z1; - - } -} - -/************************************************************************************** - * Function: PostMultiplyRescale - * - * Description: post-twiddle stage of DCT4, with rescaling for extra guard bits - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits to remove from output - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit - * see notes on PostMultiply(), above - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void PostMultiplyRescale(int tabidx, int *fft1, int es) -{ - int i, nmdct, ar1, ai1, ar2, ai2, skipFactor, z; - int t, cs2, sin2; - int *fft2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - csptr = cos1sin1tab; - skipFactor = postSkip[tabidx]; - fft2 = fft1 + nmdct - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) - */ - cs2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - for (i = nmdct >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ai2 = *(fft2 + 0); - - t = MULSHIFT32(sin2, ar1 + ai1); - z = t - MULSHIFT32(cs2, ai1); - CLIP_2N_SHIFT(z, es); - *fft2-- = z; - cs2 -= 2*sin2; - z = t + MULSHIFT32(cs2, ar1); - CLIP_2N_SHIFT(z, es); - *fft1++ = z; - - cs2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - ar2 = *fft2; - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - z = t - MULSHIFT32(cs2, ai2); - CLIP_2N_SHIFT(z, es); - *fft2-- = z; - cs2 -= 2*sin2; - z = t + MULSHIFT32(cs2, ar2); - CLIP_2N_SHIFT(z, es); - *fft1++ = z; - cs2 += 2*sin2; - } -} - -/************************************************************************************** - * Function: DCT4 - * - * Description: type-IV DCT - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits in the input buffer - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: operates in-place - * if number of guard bits in input is < GBITS_IN_DCT4, the input is - * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after - * the DCT4 (rare) - * the output has FBITS_LOST_DCT4 fewer fraction bits than the input - * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4) - * int bits gained per stage (PreMul + FFT + PostMul) - * short blocks = (-5 + 4 + 2) = 1 total - * long blocks = (-8 + 7 + 2) = 1 total - **************************************************************************************/ -void DCT4(int tabidx, int *coef, int gb) -{ - int es; - - /* fast in-place DCT-IV - adds guard bits if necessary */ - if (gb < GBITS_IN_DCT4) { - es = GBITS_IN_DCT4 - gb; - PreMultiplyRescale(tabidx, coef, es); - R4FFT(tabidx, coef); - PostMultiplyRescale(tabidx, coef, es); - } else { - PreMultiply(tabidx, coef); - R4FFT(tabidx, coef); - PostMultiply(tabidx, coef); - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/decelmnt.c b/components/spotify/cspot/bell/external/libhelix-aac/decelmnt.c deleted file mode 100644 index 8c319121..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/decelmnt.c +++ /dev/null @@ -1,425 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: decelmnt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * decelmnt.c - syntactic element decoding - **************************************************************************************/ - -#include "coder.h" - -/************************************************************************************** - * Function: DecodeSingleChannelElement - * - * Description: decode one SCE - * - * Inputs: BitStreamInfo struct pointing to start of SCE (14496-3, table 4.4.4) - * - * Outputs: updated element instance tag - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeSingleChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - return 0; -} - -/************************************************************************************** - * Function: DecodeChannelPairElement - * - * Description: decode one CPE - * - * Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5) - * - * Outputs: updated element instance tag - * updated commonWin - * updated ICS info, if commonWin == 1 - * updated mid-side stereo info, if commonWin == 1 - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - int sfb, gp, maskOffset; - unsigned char currBit, *maskPtr; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = psi->icsInfo; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - /* read common window flag and mid-side info (if present) - * store msMask bits in psi->msMaskBits[] as follows: - * long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0] - * short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7] - * msMaskPresent = 0 means no M/S coding - * = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding - * = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed) - */ - psi->commonWin = GetBits(bsi, 1); - if (psi->commonWin) { - DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx); - psi->msMaskPresent = GetBits(bsi, 2); - if (psi->msMaskPresent == 1) { - maskPtr = psi->msMaskBits; - *maskPtr = 0; - maskOffset = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - currBit = (unsigned char)GetBits(bsi, 1); - *maskPtr |= currBit << maskOffset; - if (++maskOffset == 8) { - maskPtr++; - *maskPtr = 0; - maskOffset = 0; - } - } - } - } - } - - return 0; -} - -/************************************************************************************** - * Function: DecodeLFEChannelElement - * - * Description: decode one LFE - * - * Inputs: BitStreamInfo struct pointing to start of LFE (14496-3, table 4.4.9) - * - * Outputs: updated element instance tag - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeLFEChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - return 0; -} - -/************************************************************************************** - * Function: DecodeDataStreamElement - * - * Description: decode one DSE - * - * Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10) - * - * Outputs: updated element instance tag - * filled in data stream buffer - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - unsigned int byteAlign, dataCount; - unsigned char *dataBuf; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - byteAlign = GetBits(bsi, 1); - dataCount = GetBits(bsi, 8); - if (dataCount == 255) - dataCount += GetBits(bsi, 8); - - if (byteAlign) - ByteAlignBitstream(bsi); - - psi->dataCount = dataCount; - dataBuf = psi->dataBuf; - while (dataCount--) - *dataBuf++ = GetBits(bsi, 8); - - return 0; -} - -/************************************************************************************** - * Function: DecodeProgramConfigElement - * - * Description: decode one PCE - * - * Inputs: BitStreamInfo struct pointing to start of PCE (14496-3, table 4.4.2) - * - * Outputs: filled-in ProgConfigElement struct - * updated BitStreamInfo struct - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: #define KEEP_PCE_COMMENTS to save the comment field of the PCE - * (otherwise we just skip it in the bitstream, to save memory) - **************************************************************************************/ -int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi) -{ - int i; - - pce->elemInstTag = GetBits(bsi, 4); - pce->profile = GetBits(bsi, 2); - pce->sampRateIdx = GetBits(bsi, 4); - pce->numFCE = GetBits(bsi, 4); - pce->numSCE = GetBits(bsi, 4); - pce->numBCE = GetBits(bsi, 4); - pce->numLCE = GetBits(bsi, 2); - pce->numADE = GetBits(bsi, 3); - pce->numCCE = GetBits(bsi, 4); - - pce->monoMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->monoMixdown) - pce->monoMixdown |= GetBits(bsi, 4); /* element number */ - - pce->stereoMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->stereoMixdown) - pce->stereoMixdown |= GetBits(bsi, 4); /* element number */ - - pce->matrixMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->matrixMixdown) { - pce->matrixMixdown |= GetBits(bsi, 2) << 1; /* index */ - pce->matrixMixdown |= GetBits(bsi, 1); /* pseudo-surround enable */ - } - - for (i = 0; i < pce->numFCE; i++) { - pce->fce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->fce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numSCE; i++) { - pce->sce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->sce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numBCE; i++) { - pce->bce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->bce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numLCE; i++) - pce->lce[i] = GetBits(bsi, 4); /* tag select */ - - for (i = 0; i < pce->numADE; i++) - pce->ade[i] = GetBits(bsi, 4); /* tag select */ - - for (i = 0; i < pce->numCCE; i++) { - pce->cce[i] = GetBits(bsi, 1) << 4; /* independent/dependent flag */ - pce->cce[i] |= GetBits(bsi, 4); /* tag select */ - } - - - ByteAlignBitstream(bsi); - -#ifdef KEEP_PCE_COMMENTS - pce->commentBytes = GetBits(bsi, 8); - for (i = 0; i < pce->commentBytes; i++) - pce->commentField[i] = GetBits(bsi, 8); -#else - /* eat comment bytes and throw away */ - i = GetBits(bsi, 8); - while (i--) - GetBits(bsi, 8); -#endif - - return 0; -} - -/************************************************************************************** - * Function: DecodeFillElement - * - * Description: decode one fill element - * - * Inputs: BitStreamInfo struct pointing to start of fill element - * (14496-3, table 4.4.11) - * - * Outputs: updated element instance tag - * unpacked extension payload - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - unsigned int fillCount; - unsigned char *fillBuf; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - fillCount = GetBits(bsi, 4); - if (fillCount == 15) - fillCount += (GetBits(bsi, 8) - 1); - - psi->fillCount = fillCount; - fillBuf = psi->fillBuf; - while (fillCount--) - *fillBuf++ = GetBits(bsi, 8); - - aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */ - aacDecInfo->fillExtType = 0; - -#ifdef AAC_ENABLE_SBR - /* check for SBR - * aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel - * need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and - * must upsample by 2 for LFE - */ - if (psi->fillCount > 0) { - aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f); - if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) - aacDecInfo->sbrEnabled = 1; - } -#endif - - aacDecInfo->fillBuf = psi->fillBuf; - aacDecInfo->fillCount = psi->fillCount; - - return 0; -} - -/************************************************************************************** - * Function: DecodeNextElement - * - * Description: decode next syntactic element in AAC frame - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer containing next element - * pointer to bit offset - * pointer to number of valid bits remaining in buf - * - * Outputs: type of element decoded (aacDecInfo->currBlockID) - * type of element decoded last time (aacDecInfo->prevBlockID) - * updated aacDecInfo state, depending on which element was decoded - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int err, bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* read element ID (save last ID for SBR purposes) */ - aacDecInfo->prevBlockID = aacDecInfo->currBlockID; - aacDecInfo->currBlockID = GetBits(&bsi, NUM_SYN_ID_BITS); - - /* set defaults (could be overwritten by DecodeXXXElement(), depending on currBlockID) */ - psi->commonWin = 0; - - err = 0; - switch (aacDecInfo->currBlockID) { - case AAC_ID_SCE: - err = DecodeSingleChannelElement(aacDecInfo, &bsi); - break; - case AAC_ID_CPE: - err = DecodeChannelPairElement(aacDecInfo, &bsi); - break; - case AAC_ID_CCE: - /* TODO - implement CCE decoding */ - break; - case AAC_ID_LFE: - err = DecodeLFEChannelElement(aacDecInfo, &bsi); - break; - case AAC_ID_DSE: - err = DecodeDataStreamElement(aacDecInfo, &bsi); - break; - case AAC_ID_PCE: - err = DecodeProgramConfigElement(psi->pce + 0, &bsi); - break; - case AAC_ID_FIL: - err = DecodeFillElement(aacDecInfo, &bsi); - break; - case AAC_ID_END: - break; - } - if (err) - return ERR_AAC_SYNTAX_ELEMENT; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed; - - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/dequant.c b/components/spotify/cspot/bell/external/libhelix-aac/dequant.c deleted file mode 100644 index 5f511664..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/dequant.c +++ /dev/null @@ -1,373 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: dequant.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * dequant.c - transform coefficient dequantization and short-block deinterleaving - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define SF_OFFSET 100 - -/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */ -static const int pow14[4] PROGMEM = { - 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 -}; - -/* pow(2, i/4.0) * pow(j, 4.0/3.0) for i = [0,1,2,3], j = [0,1,2,...,15] - * format = Q28 for j = [0-3], Q25 for j = [4-15] - */ -static const int pow43_14[4][16] PROGMEM = { - { - 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */ - 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, /* Q25 */ - 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, /* Q25 */ - 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, /* Q25 */ - }, - { - 0x00000000, 0x1306fe0a, 0x2ff221af, 0x52538f52, - 0x0f1a1bf4, 0x1455ccc2, 0x19ee62a8, 0x1fd92396, - 0x260dfc14, 0x2c8694d8, 0x333dcb29, 0x3a2f5c7a, - 0x4157aed5, 0x48b3aaa3, 0x50409f76, 0x57fc3010, - }, - { - 0x00000000, 0x16a09e66, 0x39047c0f, 0x61e734aa, - 0x11f59ac4, 0x182ec633, 0x1ed66a45, 0x25dfc55a, - 0x2d413ccd, 0x34f3462d, 0x3cefc603, 0x4531ab69, - 0x4db4adf8, 0x56752054, 0x5f6fcfcd, 0x68a1eca1, - }, - { - 0x00000000, 0x1ae89f99, 0x43ce3e4b, 0x746d57b2, - 0x155b8109, 0x1cc21cdc, 0x24ac1839, 0x2d0a479e, - 0x35d13f33, 0x3ef80748, 0x48775c93, 0x524938cd, - 0x5c68841d, 0x66d0df0a, 0x717e7bfe, 0x7c6e0305, - }, -}; - -/* pow(j, 4.0 / 3.0) for j = [16,17,18,...,63], format = Q23 */ -static const int pow43[48] PROGMEM = { - 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85, - 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a, - 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000, - 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99, - 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088, - 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72, - 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3, - 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c, - 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129, - 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b, - 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0, - 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09, -}; - -/* sqrt(0.5), format = Q31 */ -#define SQRTHALF 0x5a82799a - -/* Minimax polynomial approximation to pow(x, 4/3), over the range - * poly43lo: x = [0.5, 0.7071] - * poly43hi: x = [0.7071, 1.0] - * - * Relative error < 1E-7 - * Coefs are scaled by 4, 2, 1, 0.5, 0.25 - */ - -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" -static const int poly43lo[5] PROGMEM = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 }; -static const int poly43hi[5] PROGMEM = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 }; -#pragma GCC diagnostic pop - -/* pow2exp[i] = pow(2, i*4/3) exponent */ -static const int pow2exp[8] PROGMEM = { 14, 13, 11, 10, 9, 7, 6, 5 }; - -/* pow2exp[i] = pow(2, i*4/3) fraction */ -static const int pow2frac[8] PROGMEM = { - 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94, - 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6 -}; - -/************************************************************************************** - * Function: DequantBlock - * - * Description: dequantize one block of transform coefficients (in-place) - * - * Inputs: quantized transform coefficients, range = [0, 8191] - * number of samples to dequantize - * scalefactor for this block of data, range = [0, 256] - * - * Outputs: dequantized transform coefficients in Q(FBITS_OUT_DQ_OFF) - * - * Return: guard bit mask (OR of abs value of all dequantized coefs) - * - * Notes: applies dequant formula y = pow(x, 4.0/3.0) * pow(2, (scale - 100)/4.0) - * * pow(2, FBITS_OUT_DQ_OFF) - * clips outputs to Q(FBITS_OUT_DQ_OFF) - * output has no minimum number of guard bits - **************************************************************************************/ -static int DequantBlock(int *inbuf, int nSamps, int scale) -{ - int iSamp, scalef, scalei, x, y, gbMask, shift, tab4[4]; - const int *tab16, *coef; - - if (nSamps <= 0) - return 0; - - scale -= SF_OFFSET; /* new range = [-100, 156] */ - - /* with two's complement numbers, scalei/scalef factorization works for pos and neg values of scale: - * [+4...+7] >> 2 = +1, [ 0...+3] >> 2 = 0, [-4...-1] >> 2 = -1, [-8...-5] >> 2 = -2 ... - * (-1 & 0x3) = 3, (-2 & 0x3) = 2, (-3 & 0x3) = 1, (0 & 0x3) = 0 - * - * Example: 2^(-5/4) = 2^(-1) * 2^(-1/4) = 2^-2 * 2^(3/4) - */ - tab16 = pow43_14[scale & 0x3]; - scalef = pow14[scale & 0x3]; - scalei = (scale >> 2) + FBITS_OUT_DQ_OFF; - - /* cache first 4 values: - * tab16[j] = Q28 for j = [0,3] - * tab4[x] = x^(4.0/3.0) * 2^(0.25*scale), Q(FBITS_OUT_DQ_OFF) - */ - shift = 28 - scalei; - if (shift > 31) { - tab4[0] = tab4[1] = tab4[2] = tab4[3] = 0; - } else if (shift <= 0) { - shift = -shift; - if (shift > 31) - shift = 31; - for (x = 0; x < 4; x++) { - y = tab16[x]; - if (y > (0x7fffffff >> shift)) - y = 0x7fffffff; /* clip (rare) */ - else - y <<= shift; - tab4[x] = y; - } - } else { - tab4[0] = 0; - tab4[1] = tab16[1] >> shift; - tab4[2] = tab16[2] >> shift; - tab4[3] = tab16[3] >> shift; - } - - gbMask = 0; - do { - iSamp = *inbuf; - x = FASTABS(iSamp); - - if (x < 4) { - y = tab4[x]; - } else { - - if (x < 16) { - /* result: y = Q25 (tab16 = Q25) */ - y = tab16[x]; - shift = 25 - scalei; - } else if (x < 64) { - /* result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) */ - y = pow43[x-16]; - shift = 21 - scalei; - y = MULSHIFT32(y, scalef); - } else { - /* normalize to [0x40000000, 0x7fffffff] - * input x = [64, 8191] = [64, 2^13-1] - * ranges: - * shift = 7: 64 - 127 - * shift = 6: 128 - 255 - * shift = 5: 256 - 511 - * shift = 4: 512 - 1023 - * shift = 3: 1024 - 2047 - * shift = 2: 2048 - 4095 - * shift = 1: 4096 - 8191 - */ - x <<= 17; - shift = 0; - if (x < 0x08000000) - x <<= 4, shift += 4; - if (x < 0x20000000) - x <<= 2, shift += 2; - if (x < 0x40000000) - x <<= 1, shift += 1; - - coef = (x < SQRTHALF) ? poly43lo : poly43hi; - - /* polynomial */ - y = coef[0]; - y = MULSHIFT32(y, x) + coef[1]; - y = MULSHIFT32(y, x) + coef[2]; - y = MULSHIFT32(y, x) + coef[3]; - y = MULSHIFT32(y, x) + coef[4]; - y = MULSHIFT32(y, pow2frac[shift]) << 3; - - /* fractional scale - * result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) - */ - y = MULSHIFT32(y, scalef); /* now y is Q24 */ - shift = 24 - scalei - pow2exp[shift]; - } - - /* integer scale */ - if (shift <= 0) { - shift = -shift; - if (shift > 31) - shift = 31; - - if (y > (0x7fffffff >> shift)) - y = 0x7fffffff; /* clip (rare) */ - else - y <<= shift; - } else { - if (shift > 31) - shift = 31; - y >>= shift; - } - } - - /* sign and store (gbMask used to count GB's) */ - gbMask |= y; - - /* apply sign */ - iSamp >>= 31; - y ^= iSamp; - y -= iSamp; - - *inbuf++ = y; - } while (--nSamps); - - return gbMask; -} - -/************************************************************************************** - * Function: Dequantize - * - * Description: dequantize all transform coefficients for one channel - * - * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients) - * index of current channel - * - * Outputs: dequantized coefficients, including short-block deinterleaving - * flags indicating if intensity and/or PNS is active - * minimum guard bit count for dequantized coefficients - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int Dequantize(AACDecInfo *aacDecInfo, int ch) -{ - int gp, cb, sfb, win, width, nSamps, gbMask; - int *coef; - const int /*short*/ *sfbTab; - unsigned char *sfbCodeBook; - short *scaleFactors; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coef = psi->coef[ch]; - sfbCodeBook = psi->sfbCodeBook[ch]; - scaleFactors = psi->scaleFactors[ch]; - - psi->intensityUsed[ch] = 0; - psi->pnsUsed[ch] = 0; - gbMask = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - /* dequantize one scalefactor band (not necessary if codebook is intensity or PNS) - * for zero codebook, still run dequantizer in case non-zero pulse data was added - */ - cb = (int)(sfbCodeBook[sfb]); - width = sfbTab[sfb+1] - sfbTab[sfb]; - if (cb >= 0 && cb <= 11) - gbMask |= DequantBlock(coef, width, scaleFactors[sfb]); - else if (cb == 13) - psi->pnsUsed[ch] = 1; - else if (cb == 14 || cb == 15) - psi->intensityUsed[ch] = 1; /* should only happen if ch == 1 */ - coef += width; - } - coef += (nSamps - sfbTab[icsInfo->maxSFB]); - } - sfbCodeBook += icsInfo->maxSFB; - scaleFactors += icsInfo->maxSFB; - } - aacDecInfo->pnsUsed |= psi->pnsUsed[ch]; /* set flag if PNS used for any channel */ - - /* calculate number of guard bits in dequantized data */ - psi->gbCurrent[ch] = CLZ(gbMask) - 1; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: DeinterleaveShortBlocks - * - * Description: deinterleave transform coefficients in short blocks for one channel - * - * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients) - * index of current channel - * - * Outputs: deinterleaved coefficients (window groups into 8 separate windows) - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: only necessary if deinterleaving not part of Huffman decoding - **************************************************************************************/ -int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch) -{ - (void)aacDecInfo; - (void)ch; - /* not used for this implementation - short block deinterleaving performed during Huffman decoding */ - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/fft.c b/components/spotify/cspot/bell/external/libhelix-aac/fft.c deleted file mode 100644 index 0fc934ca..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/fft.c +++ /dev/null @@ -1,393 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: fft.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * fft.c - Ken's optimized radix-4 DIT FFT, optional radix-8 first pass for odd log2(N) - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define NUM_FFT_SIZES 2 -static const int nfftTab[NUM_FFT_SIZES] PROGMEM ={64, 512}; -static const int nfftlog2Tab[NUM_FFT_SIZES] PROGMEM = {6, 9}; - -#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */ - -#define swapcplx(p0,p1) \ - t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1 - -/************************************************************************************** - * Function: BitReverse - * - * Description: Ken's fast in-place bit reverse, using super-small table - * - * Inputs: buffer of samples - * table index (for transform size) - * - * Outputs: bit-reversed samples in same buffer - * - * Return: none - **************************************************************************************/ - /*__attribute__ ((section (".data"))) */ static void BitReverse(int *inout, int tabidx) -{ - int *part0, *part1; - int a,b, t,t1; - const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx]; - int nbits = nfftlog2Tab[tabidx]; - - part0 = inout; - part1 = inout + (1 << nbits); - - while ((a = pgm_read_byte(tab++)) != 0) { - b = pgm_read_byte(tab++); - - swapcplx(part0[4*a+0], part0[4*b+0]); /* 0xxx0 <-> 0yyy0 */ - swapcplx(part0[4*a+2], part1[4*b+0]); /* 0xxx1 <-> 1yyy0 */ - swapcplx(part1[4*a+0], part0[4*b+2]); /* 1xxx0 <-> 0yyy1 */ - swapcplx(part1[4*a+2], part1[4*b+2]); /* 1xxx1 <-> 1yyy1 */ - } - - do { - swapcplx(part0[4*a+2], part1[4*a+0]); /* 0xxx1 <-> 1xxx0 */ - } while ((a = pgm_read_byte(tab++)) != 0); - - -} - -/************************************************************************************** - * Function: R4FirstPass - * - * Description: radix-4 trivial pass for decimation-in-time FFT - * - * Inputs: buffer of (bit-reversed) samples - * number of R4 butterflies per group (i.e. nfft / 4) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 2 guard bits, gains no integer bits, - * guard bits out = guard bits in - 2 - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R4FirstPass(int *x, int bg) -{ - int ar, ai, br, bi, cr, ci, dr, di; - - for (; bg != 0; bg--) { - - ar = x[0] + x[2]; - br = x[0] - x[2]; - ai = x[1] + x[3]; - bi = x[1] - x[3]; - cr = x[4] + x[6]; - dr = x[4] - x[6]; - ci = x[5] + x[7]; - di = x[5] - x[7]; - - /* max per-sample gain = 4.0 (adding 4 inputs together) */ - x[0] = ar + cr; - x[4] = ar - cr; - x[1] = ai + ci; - x[5] = ai - ci; - x[2] = br + di; - x[6] = br - di; - x[3] = bi - dr; - x[7] = bi + dr; - - x += 8; - } -} - -/************************************************************************************** - * Function: R8FirstPass - * - * Description: radix-8 trivial pass for decimation-in-time FFT - * - * Inputs: buffer of (bit-reversed) samples - * number of R8 butterflies per group (i.e. nfft / 8) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits, gains 1 integer bit - * guard bits out = guard bits in - 3 (if inputs are full scale) - * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2) - * see scaling comments in code - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R8FirstPass(int *x, int bg) -{ - int ar, ai, br, bi, cr, ci, dr, di; - int sr, si, tr, ti, ur, ui, vr, vi; - int wr, wi, xr, xi, yr, yi, zr, zi; - - for (; bg != 0; bg--) { - - ar = x[0] + x[2]; - br = x[0] - x[2]; - ai = x[1] + x[3]; - bi = x[1] - x[3]; - cr = x[4] + x[6]; - dr = x[4] - x[6]; - ci = x[5] + x[7]; - di = x[5] - x[7]; - - sr = ar + cr; - ur = ar - cr; - si = ai + ci; - ui = ai - ci; - tr = br - di; - vr = br + di; - ti = bi + dr; - vi = bi - dr; - - ar = x[ 8] + x[10]; - br = x[ 8] - x[10]; - ai = x[ 9] + x[11]; - bi = x[ 9] - x[11]; - cr = x[12] + x[14]; - dr = x[12] - x[14]; - ci = x[13] + x[15]; - di = x[13] - x[15]; - - /* max gain of wr/wi/yr/yi vs input = 2 - * (sum of 4 samples >> 1) - */ - wr = (ar + cr) >> 1; - yr = (ar - cr) >> 1; - wi = (ai + ci) >> 1; - yi = (ai - ci) >> 1; - - /* max gain of output vs input = 4 - * (sum of 4 samples >> 1 + sum of 4 samples >> 1) - */ - x[ 0] = (sr >> 1) + wr; - x[ 8] = (sr >> 1) - wr; - x[ 1] = (si >> 1) + wi; - x[ 9] = (si >> 1) - wi; - x[ 4] = (ur >> 1) + yi; - x[12] = (ur >> 1) - yi; - x[ 5] = (ui >> 1) - yr; - x[13] = (ui >> 1) + yr; - - ar = br - di; - cr = br + di; - ai = bi + dr; - ci = bi - dr; - - /* max gain of xr/xi/zr/zi vs input = 4*sqrt(2)/2 = 2*sqrt(2) - * (sum of 8 samples, multiply by sqrt(2)/2, implicit >> 1 from Q31) - */ - xr = MULSHIFT32(SQRT1_2, ar - ai); - xi = MULSHIFT32(SQRT1_2, ar + ai); - zr = MULSHIFT32(SQRT1_2, cr - ci); - zi = MULSHIFT32(SQRT1_2, cr + ci); - - /* max gain of output vs input = (2 + 2*sqrt(2) ~= 4.83) - * (sum of 4 samples >> 1, plus xr/xi/zr/zi with gain of 2*sqrt(2)) - * in absolute terms, we have max gain of appx 9.656 (4 + 0.707*8) - * but we also gain 1 int bit (from MULSHIFT32 or from explicit >> 1) - */ - x[ 6] = (tr >> 1) - xr; - x[14] = (tr >> 1) + xr; - x[ 7] = (ti >> 1) - xi; - x[15] = (ti >> 1) + xi; - x[ 2] = (vr >> 1) + zi; - x[10] = (vr >> 1) - zi; - x[ 3] = (vi >> 1) - zr; - x[11] = (vi >> 1) + zr; - - x += 16; - } -} - -/************************************************************************************** - * Function: R4Core - * - * Description: radix-4 pass for decimation-in-time FFT - * - * Inputs: buffer of samples - * number of R4 butterflies per group - * number of R4 groups per pass - * pointer to twiddle factors tables - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: gain 2 integer bits per pass (see scaling comments in code) - * min 1 GB in - * gbOut = gbIn - 1 (short block) or gbIn - 2 (long block) - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R4Core(int *x, int bg, int gp, int *wtab) -{ - int ar, ai, br, bi, cr, ci, dr, di, tr, ti; - int wd, ws, wi; - int i, j, step; - int *xptr, *wptr; - - for (; bg != 0; gp <<= 2, bg >>= 2) { - - step = 2*gp; - xptr = x; - - /* max per-sample gain, per group < 1 + 3*sqrt(2) ~= 5.25 if inputs x are full-scale - * do 3 groups for long block, 2 groups for short block (gain 2 int bits per group) - * - * very conservative scaling: - * group 1: max gain = 5.25, int bits gained = 2, gb used = 1 (2^3 = 8) - * group 2: max gain = 5.25^2 = 27.6, int bits gained = 4, gb used = 1 (2^5 = 32) - * group 3: max gain = 5.25^3 = 144.7, int bits gained = 6, gb used = 2 (2^8 = 256) - */ - for (i = bg; i != 0; i--) { - - wptr = wtab; - - for (j = gp; j != 0; j--) { - - ar = xptr[0]; - ai = xptr[1]; - xptr += step; - - /* gain 2 int bits for br/bi, cr/ci, dr/di (MULSHIFT32 by Q30) - * gain 1 net GB - */ - ws = wptr[0]; - wi = wptr[1]; - br = xptr[0]; - bi = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, br + bi); - br = MULSHIFT32(wd, br) - tr; /* cos*br + sin*bi */ - bi = MULSHIFT32(ws, bi) + tr; /* cos*bi - sin*br */ - xptr += step; - - ws = wptr[2]; - wi = wptr[3]; - cr = xptr[0]; - ci = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, cr + ci); - cr = MULSHIFT32(wd, cr) - tr; - ci = MULSHIFT32(ws, ci) + tr; - xptr += step; - - ws = wptr[4]; - wi = wptr[5]; - dr = xptr[0]; - di = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, dr + di); - dr = MULSHIFT32(wd, dr) - tr; - di = MULSHIFT32(ws, di) + tr; - wptr += 6; - - tr = ar; - ti = ai; - ar = (tr >> 2) - br; - ai = (ti >> 2) - bi; - br = (tr >> 2) + br; - bi = (ti >> 2) + bi; - - tr = cr; - ti = ci; - cr = tr + dr; - ci = di - ti; - dr = tr - dr; - di = di + ti; - - xptr[0] = ar + ci; - xptr[1] = ai + dr; - xptr -= step; - xptr[0] = br - cr; - xptr[1] = bi - di; - xptr -= step; - xptr[0] = ar - ci; - xptr[1] = ai - dr; - xptr -= step; - xptr[0] = br + cr; - xptr[1] = bi + di; - xptr += 2; - } - xptr += 3*step; - } - wtab += 3*step; - } -} - - -/************************************************************************************** - * Function: R4FFT - * - * Description: Ken's very fast in-place radix-4 decimation-in-time FFT - * - * Inputs: table index (for transform size) - * buffer of samples (non bit-reversed) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 5 guard bits in for nfft <= 512 - * gbOut = gbIn - 4 (assuming input is from PreMultiply) - * gains log2(nfft) - 2 int bits total - * so gain 7 int bits (LONG), 4 int bits (SHORT) - **************************************************************************************/ -void R4FFT(int tabidx, int *x) -{ - int order = nfftlog2Tab[tabidx]; - int nfft = nfftTab[tabidx]; - - /* decimation in time */ - BitReverse(x, tabidx); - - if (order & 0x1) { - /* long block: order = 9, nfft = 512 */ - R8FirstPass(x, nfft >> 3); /* gain 1 int bit, lose 2 GB */ - R4Core(x, nfft >> 5, 8, (int *)twidTabOdd); /* gain 6 int bits, lose 2 GB */ - } else { - /* short block: order = 6, nfft = 64 */ - R4FirstPass(x, nfft >> 2); /* gain 0 int bits, lose 2 GB */ - R4Core(x, nfft >> 4, 4, (int *)twidTabEven); /* gain 4 int bits, lose 1 GB */ - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/filefmt.c b/components/spotify/cspot/bell/external/libhelix-aac/filefmt.c deleted file mode 100644 index ccfac596..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/filefmt.c +++ /dev/null @@ -1,496 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: filefmt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * filefmt.c - ADIF and ADTS header decoding, raw block handling - **************************************************************************************/ - -#include "coder.h" - - /************************************************************************************** - * Function: UnpackADTSHeader - * - * Description: parse the ADTS frame header and initialize decoder state - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer with complete ADTS frame header (byte aligned) - * header size = 7 bytes, plus 2 if CRC - * - * Outputs: filled in ADTS struct - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - * - * TODO: test CRC - * verify that fixed fields don't change between frames - **************************************************************************************/ -int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - ADTSHeader *fhADTS; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - fhADTS = &(psi->fhADTS); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* verify that first 12 bits of header are syncword */ - if (GetBits(&bsi, 12) != 0x0fff) { - return ERR_AAC_INVALID_ADTS_HEADER; - } - - /* fixed fields - should not change from frame to frame */ - fhADTS->id = GetBits(&bsi, 1); - fhADTS->layer = GetBits(&bsi, 2); - fhADTS->protectBit = GetBits(&bsi, 1); - fhADTS->profile = GetBits(&bsi, 2); - fhADTS->sampRateIdx = GetBits(&bsi, 4); - fhADTS->privateBit = GetBits(&bsi, 1); - fhADTS->channelConfig = GetBits(&bsi, 3); - fhADTS->origCopy = GetBits(&bsi, 1); - fhADTS->home = GetBits(&bsi, 1); - - /* variable fields - can change from frame to frame */ - fhADTS->copyBit = GetBits(&bsi, 1); - fhADTS->copyStart = GetBits(&bsi, 1); - fhADTS->frameLength = GetBits(&bsi, 13); - fhADTS->bufferFull = GetBits(&bsi, 11); - fhADTS->numRawDataBlocks = GetBits(&bsi, 2) + 1; - - /* note - MPEG4 spec, correction 1 changes how CRC is handled when protectBit == 0 and numRawDataBlocks > 1 */ - if (fhADTS->protectBit == 0) - fhADTS->crcCheckWord = GetBits(&bsi, 16); - - /* byte align */ - ByteAlignBitstream(&bsi); /* should always be aligned anyway */ - - /* check validity of header */ - if (fhADTS->layer != 0 || fhADTS->profile != AAC_PROFILE_LC || - fhADTS->sampRateIdx >= NUM_SAMPLE_RATES || fhADTS->channelConfig >= NUM_DEF_CHAN_MAPS) - return ERR_AAC_INVALID_ADTS_HEADER; - -#ifndef AAC_ENABLE_MPEG4 - if (fhADTS->id != 1) - return ERR_AAC_MPEG4_UNSUPPORTED; -#endif - - /* update codec info */ - psi->sampRateIdx = fhADTS->sampRateIdx; - if (!psi->useImpChanMap) - psi->nChans = channelMapTab[fhADTS->channelConfig]; - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data (TODO - calc bitrate, handle tricky channel config cases) */ - aacDecInfo->bitRate = 0; - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - aacDecInfo->profile = fhADTS->profile; - aacDecInfo->sbrEnabled = 0; - aacDecInfo->adtsBlocksLeft = fhADTS->numRawDataBlocks; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed ; - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: GetADTSChannelMapping - * - * Description: determine the number of channels from implicit mapping rules - * - * Inputs: valid AACDecInfo struct - * pointer to start of raw_data_block - * bit offset - * bits available - * - * Outputs: updated number of channels - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: calculates total number of channels using rules in 14496-3, 4.5.1.2.1 - * does not attempt to deduce speaker geometry - **************************************************************************************/ -int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail) -{ - int ch, nChans, elementChans, err; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - nChans = 0; - do { - /* parse next syntactic element */ - err = DecodeNextElement(aacDecInfo, &buf, &bitOffset, &bitsAvail); - if (err) - return err; - - elementChans = elementNumChans[aacDecInfo->currBlockID]; - nChans += elementChans; - - for (ch = 0; ch < elementChans; ch++) { - err = DecodeNoiselessData(aacDecInfo, &buf, &bitOffset, &bitsAvail, ch); - if (err) - return err; - } - } while (aacDecInfo->currBlockID != AAC_ID_END); - - if (nChans <= 0) - return ERR_AAC_CHANNEL_MAP; - - /* update number of channels in codec state and user-accessible info structs */ - psi->nChans = nChans; - aacDecInfo->nChans = psi->nChans; - psi->useImpChanMap = 1; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: GetNumChannelsADIF - * - * Description: get number of channels from program config elements in an ADIF file - * - * Inputs: array of filled-in program config element structures - * number of PCE's - * - * Outputs: none - * - * Return: total number of channels in file - * -1 if error (invalid number of PCE's or unsupported mode) - **************************************************************************************/ -static int GetNumChannelsADIF(ProgConfigElement *fhPCE, int nPCE) -{ - int i, j, nChans; - - if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) - return -1; - - nChans = 0; - for (i = 0; i < nPCE; i++) { - /* for now: only support LC, no channel coupling */ - if (fhPCE[i].profile != AAC_PROFILE_LC || fhPCE[i].numCCE > 0) - return -1; - - /* add up number of channels in all channel elements (assume all single-channel) */ - nChans += fhPCE[i].numFCE; - nChans += fhPCE[i].numSCE; - nChans += fhPCE[i].numBCE; - nChans += fhPCE[i].numLCE; - - /* add one more for every element which is a channel pair */ - for (j = 0; j < fhPCE[i].numFCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].fce[j])) - nChans++; - } - for (j = 0; j < fhPCE[i].numSCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].sce[j])) - nChans++; - } - for (j = 0; j < fhPCE[i].numBCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].bce[j])) - nChans++; - } - - } - - return nChans; -} - -/************************************************************************************** - * Function: GetSampleRateIdxADIF - * - * Description: get sampling rate index from program config elements in an ADIF file - * - * Inputs: array of filled-in program config element structures - * number of PCE's - * - * Outputs: none - * - * Return: sample rate of file - * -1 if error (invalid number of PCE's or sample rate mismatch) - **************************************************************************************/ -static int GetSampleRateIdxADIF(ProgConfigElement *fhPCE, int nPCE) -{ - int i, idx; - - if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) - return -1; - - /* make sure all PCE's have the same sample rate */ - idx = fhPCE[0].sampRateIdx; - for (i = 1; i < nPCE; i++) { - if (fhPCE[i].sampRateIdx != idx) - return -1; - } - - return idx; -} - -/************************************************************************************** - * Function: UnpackADIFHeader - * - * Description: parse the ADIF file header and initialize decoder state - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer with complete ADIF header - * (starting at 'A' in 'ADIF' tag) - * pointer to bit offset - * pointer to number of valid bits remaining in inbuf - * - * Outputs: filled-in ADIF struct - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int i, bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - ADIFHeader *fhADIF; - ProgConfigElement *pce; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* unpack ADIF file header */ - fhADIF = &(psi->fhADIF); - pce = psi->pce; - - /* verify that first 32 bits of header are "ADIF" */ - if (GetBits(&bsi, 8) != 'A' || GetBits(&bsi, 8) != 'D' || GetBits(&bsi, 8) != 'I' || GetBits(&bsi, 8) != 'F') - return ERR_AAC_INVALID_ADIF_HEADER; - - /* read ADIF header fields */ - fhADIF->copyBit = GetBits(&bsi, 1); - if (fhADIF->copyBit) { - for (i = 0; i < ADIF_COPYID_SIZE; i++) - fhADIF->copyID[i] = GetBits(&bsi, 8); - } - fhADIF->origCopy = GetBits(&bsi, 1); - fhADIF->home = GetBits(&bsi, 1); - fhADIF->bsType = GetBits(&bsi, 1); - fhADIF->bitRate = GetBits(&bsi, 23); - fhADIF->numPCE = GetBits(&bsi, 4) + 1; /* add 1 (so range = [1, 16]) */ - if (fhADIF->bsType == 0) - fhADIF->bufferFull = GetBits(&bsi, 20); - - /* parse all program config elements */ - for (i = 0; i < fhADIF->numPCE; i++) - DecodeProgramConfigElement(pce + i, &bsi); - - /* byte align */ - ByteAlignBitstream(&bsi); - - /* update codec info */ - psi->nChans = GetNumChannelsADIF(pce, fhADIF->numPCE); - psi->sampRateIdx = GetSampleRateIdxADIF(pce, fhADIF->numPCE); - - /* check validity of header */ - if (psi->nChans < 0 || psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) - return ERR_AAC_INVALID_ADIF_HEADER; - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data */ - aacDecInfo->bitRate = 0; - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - aacDecInfo->profile = pce[0].profile; - aacDecInfo->sbrEnabled = 0; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed ; - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: SetRawBlockParams - * - * Description: set internal state variables for decoding a stream of raw data blocks - * - * Inputs: valid AACDecInfo struct - * flag indicating source of parameters (from previous headers or passed - * explicitly by caller) - * number of channels - * sample rate - * profile ID - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: if copyLast == 1, then psi->nChans, psi->sampRateIdx, and - * aacDecInfo->profile are not changed (it's assumed that we already - * set them, such as by a previous call to UnpackADTSHeader()) - * if copyLast == 0, then the parameters we passed in are used instead - **************************************************************************************/ -int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile) -{ - int idx; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - if (!copyLast) { - aacDecInfo->profile = profile; - psi->nChans = nChans; - for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) { - if (sampRate == sampRateTab[idx]) { - psi->sampRateIdx = idx; - break; - } - } - if (idx == NUM_SAMPLE_RATES) - return ERR_AAC_INVALID_FRAME; - } - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - - /* check validity of header */ - if (psi->sampRateIdx >= NUM_SAMPLE_RATES || psi->sampRateIdx < 0 || aacDecInfo->profile != AAC_PROFILE_LC) - return ERR_AAC_RAWBLOCK_PARAMS; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: PrepareRawBlock - * - * Description: reset per-block state variables for raw blocks (no ADTS/ADIF headers) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int PrepareRawBlock(AACDecInfo *aacDecInfo) -{ -// PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; -// psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data */ - aacDecInfo->bitRate = 0; - aacDecInfo->sbrEnabled = 0; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: FlushCodec - * - * Description: flush internal codec state (after seeking, for example) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: only need to clear data which is persistent between frames - * (such as overlap buffer) - **************************************************************************************/ -int FlushCodec(AACDecInfo *aacDecInfo) -{ - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - ClearBuffer(psi->overlap, AAC_MAX_NCHANS * AAC_MAX_NSAMPS * sizeof(int)); - ClearBuffer(psi->prevWinShape, AAC_MAX_NCHANS * sizeof(int)); - - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/huffman.c b/components/spotify/cspot/bell/external/libhelix-aac/huffman.c deleted file mode 100644 index 57cc45c9..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/huffman.c +++ /dev/null @@ -1,415 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: huffman.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * huffman.c - Huffman decoding - **************************************************************************************/ - -#include "coder.h" - -/************************************************************************************** - * Function: DecodeHuffmanScalar - * - * Description: decode one Huffman symbol from bitstream - * - * Inputs: pointers to Huffman table and info struct - * left-aligned bit buffer with >= huffTabInfo->maxBits bits - * - * Outputs: decoded symbol in *val - * - * Return: number of bits in symbol - * - * Notes: assumes canonical Huffman codes: - * first CW always 0, we have "count" CW's of length "nBits" bits - * starting CW for codes of length nBits+1 = - * (startCW[nBits] + count[nBits]) << 1 - * if there are no codes at nBits, then we just keep << 1 each time - * (since count[nBits] = 0) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val) -{ - unsigned int count, start, shift, t; - const unsigned /*char*/ int *countPtr; - const signed short *map; - - map = huffTab + huffTabInfo->offset; - countPtr = huffTabInfo->count; - - start = 0; - count = 0; - shift = 32; - do { - start += count; - start <<= 1; - map += count; - count = *countPtr++; - shift--; - t = (bitBuf >> shift) - start; - } while (t >= count); - - *val = (signed int)pgm_read_word(&map[t]); - return (countPtr - huffTabInfo->count); -} - -#define APPLY_SIGN(v, s) {(v) ^= ((signed int)(s) >> 31); (v) -= ((signed int)(s) >> 31);} - -#define GET_QUAD_SIGNBITS(v) (((unsigned int)(v) << 17) >> 29) /* bits 14-12, unsigned */ -#define GET_QUAD_W(v) (((signed int)(v) << 20) >> 29) /* bits 11-9, sign-extend */ -#define GET_QUAD_X(v) (((signed int)(v) << 23) >> 29) /* bits 8-6, sign-extend */ -#define GET_QUAD_Y(v) (((signed int)(v) << 26) >> 29) /* bits 5-3, sign-extend */ -#define GET_QUAD_Z(v) (((signed int)(v) << 29) >> 29) /* bits 2-0, sign-extend */ - -#define GET_PAIR_SIGNBITS(v) (((unsigned int)(v) << 20) >> 30) /* bits 11-10, unsigned */ -#define GET_PAIR_Y(v) (((signed int)(v) << 22) >> 27) /* bits 9-5, sign-extend */ -#define GET_PAIR_Z(v) (((signed int)(v) << 27) >> 27) /* bits 4-0, sign-extend */ - -#define GET_ESC_SIGNBITS(v) (((unsigned int)(v) << 18) >> 30) /* bits 13-12, unsigned */ -#define GET_ESC_Y(v) (((signed int)(v) << 20) >> 26) /* bits 11-6, sign-extend */ -#define GET_ESC_Z(v) (((signed int)(v) << 26) >> 26) /* bits 5-0, sign-extend */ - -/************************************************************************************** - * Function: UnpackZeros - * - * Description: fill a section of coefficients with zeros - * - * Inputs: number of coefficients - * - * Outputs: nVals zeros, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -static void UnpackZeros(int nVals, int *coef) -{ - while (nVals > 0) { - *coef++ = 0; - *coef++ = 0; - *coef++ = 0; - *coef++ = 0; - nVals -= 4; - } -} - -/************************************************************************************** - * Function: UnpackQuads - * - * Description: decode a section of 4-way vector Huffman coded coefficients - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackQuads(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int w, x, y, z, maxBits, nCodeBits, nSignBits, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 4; - while (nVals > 0) { - /* decode quad */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - w = GET_QUAD_W(val); - x = GET_QUAD_X(val); - y = GET_QUAD_Y(val); - z = GET_QUAD_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = (int)GET_QUAD_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - if (nSignBits) { - if (w) {APPLY_SIGN(w, bitBuf); bitBuf <<= 1;} - if (x) {APPLY_SIGN(x, bitBuf); bitBuf <<= 1;} - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - *coef++ = w; *coef++ = x; *coef++ = y; *coef++ = z; - nVals -= 4; - } -} - -/************************************************************************************** - * Function: UnpackPairsNoEsc - * - * Description: decode a section of 2-way vector Huffman coded coefficients, - * using non-esc tables (5 through 10) - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook (must not be the escape codebook) - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackPairsNoEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int y, z, maxBits, nCodeBits, nSignBits, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2; - while (nVals > 0) { - /* decode pair */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb-HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - y = GET_PAIR_Y(val); - z = GET_PAIR_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = GET_PAIR_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - if (nSignBits) { - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - *coef++ = y; *coef++ = z; - nVals -= 2; - } -} - -/************************************************************************************** - * Function: UnpackPairsEsc - * - * Description: decode a section of 2-way vector Huffman coded coefficients, - * using esc table (11) - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook (must be the escape codebook) - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackPairsEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int y, z, maxBits, nCodeBits, nSignBits, n, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2; - while (nVals > 0) { - /* decode pair with escape value */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb-HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - y = GET_ESC_Y(val); - z = GET_ESC_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = GET_ESC_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - - if (y == 16) { - n = 4; - while (GetBits(bsi, 1) == 1) - n++; - y = (1 << n) + GetBits(bsi, n); - } - if (z == 16) { - n = 4; - while (GetBits(bsi, 1) == 1) - n++; - z = (1 << n) + GetBits(bsi, n); - } - - if (nSignBits) { - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - - *coef++ = y; *coef++ = z; - nVals -= 2; - } -} - -/************************************************************************************** - * Function: DecodeSpectrumLong - * - * Description: decode transform coefficients for frame with one long block - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of spectral data - * (14496-3, table 4.4.29) - * index of current channel - * - * Outputs: decoded, quantized coefficients for this channel - * - * Return: none - * - * Notes: adds in pulse data if present - * fills coefficient buffer with zeros in any region not coded with - * codebook in range [1, 11] (including sfb's above sfbMax) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int i, sfb, cb, nVals, offset; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - int *coef; - ICSInfo *icsInfo; - PulseInfo *pi; - - coef = psi->coef[ch]; - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - /* decode long block */ - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - sfbCodeBook = psi->sfbCodeBook[ch]; - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - cb = *sfbCodeBook++; - nVals = sfbTab[sfb+1] - sfbTab[sfb]; - - if (cb == 0) - UnpackZeros(nVals, coef); - else if (cb <= 4) - UnpackQuads(bsi, cb, nVals, coef); - else if (cb <= 10) - UnpackPairsNoEsc(bsi, cb, nVals, coef); - else if (cb == 11) - UnpackPairsEsc(bsi, cb, nVals, coef); - else - UnpackZeros(nVals, coef); - - coef += nVals; - } - - /* fill with zeros above maxSFB */ - nVals = NSAMPS_LONG - sfbTab[sfb]; - UnpackZeros(nVals, coef); - - /* add pulse data, if present */ - pi = &psi->pulseInfo[ch]; - if (pi->pulseDataPresent) { - coef = psi->coef[ch]; - offset = sfbTab[pi->startSFB]; - for (i = 0; i < pi->numPulse; i++) { - offset += pi->offset[i]; - if (coef[offset] > 0) - coef[offset] += pi->amp[i]; - else - coef[offset] -= pi->amp[i]; - } - ASSERT(offset < NSAMPS_LONG); - } -} - -/************************************************************************************** - * Function: DecodeSpectrumShort - * - * Description: decode transform coefficients for frame with eight short blocks - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of spectral data - * (14496-3, table 4.4.29) - * index of current channel - * - * Outputs: decoded, quantized coefficients for this channel - * - * Return: none - * - * Notes: fills coefficient buffer with zeros in any region not coded with - * codebook in range [1, 11] (including sfb's above sfbMax) - * deinterleaves window groups into 8 windows - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int gp, cb, nVals=0, win, offset, sfb; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - int *coef; - ICSInfo *icsInfo; - - coef = psi->coef[ch]; - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - /* decode short blocks, deinterleaving in-place */ - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - sfbCodeBook = psi->sfbCodeBook[ch]; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - nVals = sfbTab[sfb+1] - sfbTab[sfb]; - cb = *sfbCodeBook++; - - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - offset = win*NSAMPS_SHORT; - if (cb == 0) - UnpackZeros(nVals, coef + offset); - else if (cb <= 4) - UnpackQuads(bsi, cb, nVals, coef + offset); - else if (cb <= 10) - UnpackPairsNoEsc(bsi, cb, nVals, coef + offset); - else if (cb == 11) - UnpackPairsEsc(bsi, cb, nVals, coef + offset); - else - UnpackZeros(nVals, coef + offset); - } - coef += nVals; - } - - /* fill with zeros above maxSFB */ - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - offset = win*NSAMPS_SHORT; - nVals = NSAMPS_SHORT - sfbTab[sfb]; - UnpackZeros(nVals, coef + offset); - } - coef += nVals; - coef += (icsInfo->winGroupLen[gp] - 1)*NSAMPS_SHORT; - } - - ASSERT(coef == psi->coef[ch] + NSAMPS_LONG); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/hufftabs.c b/components/spotify/cspot/bell/external/libhelix-aac/hufftabs.c deleted file mode 100644 index 91cc50ce..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/hufftabs.c +++ /dev/null @@ -1,177 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: hufftabs.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * hufftabs.c - Huffman symbol tables - **************************************************************************************/ - -#include "coder.h" - -const HuffInfo huffTabSpecInfo[11] PROGMEM = { - /* table 0 not used */ - {11, { 1, 0, 0, 0, 8, 0, 24, 0, 24, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0}, - { 9, { 0, 0, 1, 1, 7, 24, 15, 19, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 81}, - {16, { 1, 0, 0, 4, 2, 6, 3, 5, 15, 15, 8, 9, 3, 3, 5, 2, 0, 0, 0, 0}, 162}, - {12, { 0, 0, 0, 10, 6, 0, 9, 21, 8, 14, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 243}, - {13, { 1, 0, 0, 4, 4, 0, 4, 12, 12, 12, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0}, 324}, - {11, { 0, 0, 0, 9, 0, 16, 13, 8, 23, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 405}, - {12, { 1, 0, 2, 1, 0, 4, 5, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 486}, - {10, { 0, 0, 1, 5, 7, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 550}, - {15, { 1, 0, 2, 1, 0, 4, 3, 8, 11, 20, 31, 38, 32, 14, 4, 0, 0, 0, 0, 0}, 614}, - {12, { 0, 0, 0, 3, 8, 14, 17, 25, 31, 41, 22, 8, 0, 0, 0, 0, 0, 0, 0, 0}, 783}, - {12, { 0, 0, 0, 2, 6, 7, 16, 59, 55, 95, 43, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 952}, -}; - -const signed short huffTabSpec[1241] PROGMEM = { - /* spectrum table 1 [81] (signed) */ - 0x0000, 0x0200, 0x0e00, 0x0007, 0x0040, 0x0001, 0x0038, 0x0008, 0x01c0, 0x03c0, 0x0e40, 0x0039, 0x0078, 0x01c8, 0x000f, 0x0240, - 0x003f, 0x0fc0, 0x01f8, 0x0238, 0x0047, 0x0e08, 0x0009, 0x0208, 0x01c1, 0x0048, 0x0041, 0x0e38, 0x0201, 0x0e07, 0x0207, 0x0e01, - 0x01c7, 0x0278, 0x0e78, 0x03c8, 0x004f, 0x0079, 0x01c9, 0x01cf, 0x03f8, 0x0239, 0x007f, 0x0e48, 0x0e0f, 0x0fc8, 0x01f9, 0x03c1, - 0x03c7, 0x0e47, 0x0ff8, 0x01ff, 0x0049, 0x020f, 0x0241, 0x0e41, 0x0248, 0x0fc1, 0x0e3f, 0x0247, 0x023f, 0x0e39, 0x0fc7, 0x0e09, - 0x0209, 0x03cf, 0x0e79, 0x0e4f, 0x03f9, 0x0249, 0x0fc9, 0x027f, 0x0fcf, 0x0fff, 0x0279, 0x03c9, 0x0e49, 0x0e7f, 0x0ff9, 0x03ff, - 0x024f, - /* spectrum table 2 [81] (signed) */ - 0x0000, 0x0200, 0x0e00, 0x0001, 0x0038, 0x0007, 0x01c0, 0x0008, 0x0040, 0x01c8, 0x0e40, 0x0078, 0x000f, 0x0047, 0x0039, 0x0e07, - 0x03c0, 0x0238, 0x0fc0, 0x003f, 0x0208, 0x0201, 0x01c1, 0x0e08, 0x0041, 0x01f8, 0x0e01, 0x01c7, 0x0e38, 0x0240, 0x0048, 0x0009, - 0x0207, 0x0079, 0x0239, 0x0e78, 0x01cf, 0x03c8, 0x0247, 0x0209, 0x0e48, 0x01f9, 0x0248, 0x0e0f, 0x0ff8, 0x0e39, 0x03f8, 0x0278, - 0x03c1, 0x0e47, 0x0fc8, 0x0e09, 0x0fc1, 0x0fc7, 0x01ff, 0x020f, 0x023f, 0x007f, 0x0049, 0x0e41, 0x0e3f, 0x004f, 0x03c7, 0x01c9, - 0x0241, 0x03cf, 0x0e79, 0x03f9, 0x0fff, 0x0e4f, 0x0e49, 0x0249, 0x0fcf, 0x03c9, 0x0e7f, 0x0fc9, 0x027f, 0x03ff, 0x0ff9, 0x0279, - 0x024f, - /* spectrum table 3 [81] (unsigned) */ - 0x0000, 0x1200, 0x1001, 0x1040, 0x1008, 0x2240, 0x2009, 0x2048, 0x2041, 0x2208, 0x3049, 0x2201, 0x3248, 0x4249, 0x3209, 0x3241, - 0x1400, 0x1002, 0x200a, 0x2440, 0x3288, 0x2011, 0x3051, 0x2280, 0x304a, 0x3448, 0x1010, 0x2088, 0x2050, 0x1080, 0x2042, 0x2408, - 0x4289, 0x3089, 0x3250, 0x4251, 0x3281, 0x2210, 0x3211, 0x2081, 0x4449, 0x424a, 0x3441, 0x320a, 0x2012, 0x3052, 0x3488, 0x3290, - 0x2202, 0x2401, 0x3091, 0x2480, 0x4291, 0x3242, 0x3409, 0x4252, 0x4489, 0x2090, 0x308a, 0x3212, 0x3481, 0x3450, 0x3490, 0x3092, - 0x4491, 0x4451, 0x428a, 0x4292, 0x2082, 0x2410, 0x3282, 0x3411, 0x444a, 0x3442, 0x4492, 0x448a, 0x4452, 0x340a, 0x2402, 0x3482, - 0x3412, - /* spectrum table 4 [81] (unsigned) */ - 0x4249, 0x3049, 0x3241, 0x3248, 0x3209, 0x1200, 0x2240, 0x0000, 0x2009, 0x2208, 0x2201, 0x2048, 0x1001, 0x2041, 0x1008, 0x1040, - 0x4449, 0x4251, 0x4289, 0x424a, 0x3448, 0x3441, 0x3288, 0x3409, 0x3051, 0x304a, 0x3250, 0x3089, 0x320a, 0x3281, 0x3242, 0x3211, - 0x2440, 0x2408, 0x2280, 0x2401, 0x2042, 0x2088, 0x200a, 0x2050, 0x2081, 0x2202, 0x2011, 0x2210, 0x1400, 0x1002, 0x1080, 0x1010, - 0x4291, 0x4489, 0x4451, 0x4252, 0x428a, 0x444a, 0x3290, 0x3488, 0x3450, 0x3091, 0x3052, 0x3481, 0x308a, 0x3411, 0x3212, 0x4491, - 0x3282, 0x340a, 0x3442, 0x4292, 0x4452, 0x448a, 0x2090, 0x2480, 0x2012, 0x2410, 0x2082, 0x2402, 0x4492, 0x3092, 0x3490, 0x3482, - 0x3412, - /* spectrum table 5 [81] (signed) */ - 0x0000, 0x03e0, 0x0020, 0x0001, 0x001f, 0x003f, 0x03e1, 0x03ff, 0x0021, 0x03c0, 0x0002, 0x0040, 0x001e, 0x03df, 0x0041, 0x03fe, - 0x0022, 0x03c1, 0x005f, 0x03e2, 0x003e, 0x03a0, 0x0060, 0x001d, 0x0003, 0x03bf, 0x0023, 0x0061, 0x03fd, 0x03a1, 0x007f, 0x003d, - 0x03e3, 0x03c2, 0x0042, 0x03de, 0x005e, 0x03be, 0x007e, 0x03c3, 0x005d, 0x0062, 0x0043, 0x03a2, 0x03dd, 0x001c, 0x0380, 0x0081, - 0x0080, 0x039f, 0x0004, 0x009f, 0x03fc, 0x0024, 0x03e4, 0x0381, 0x003c, 0x007d, 0x03bd, 0x03a3, 0x03c4, 0x039e, 0x0082, 0x005c, - 0x0044, 0x0063, 0x0382, 0x03dc, 0x009e, 0x007c, 0x039d, 0x0383, 0x0064, 0x03a4, 0x0083, 0x009d, 0x03bc, 0x009c, 0x0384, 0x0084, - 0x039c, - /* spectrum table 6 [81] (signed) */ - 0x0000, 0x0020, 0x001f, 0x0001, 0x03e0, 0x0021, 0x03e1, 0x003f, 0x03ff, 0x005f, 0x0041, 0x03c1, 0x03df, 0x03c0, 0x03e2, 0x0040, - 0x003e, 0x0022, 0x001e, 0x03fe, 0x0002, 0x005e, 0x03c2, 0x03de, 0x0042, 0x03a1, 0x0061, 0x007f, 0x03e3, 0x03bf, 0x0023, 0x003d, - 0x03fd, 0x0060, 0x03a0, 0x001d, 0x0003, 0x0062, 0x03be, 0x03c3, 0x0043, 0x007e, 0x005d, 0x03dd, 0x03a2, 0x0063, 0x007d, 0x03bd, - 0x03a3, 0x003c, 0x03fc, 0x0081, 0x0381, 0x039f, 0x0024, 0x009f, 0x03e4, 0x001c, 0x0382, 0x039e, 0x0044, 0x03dc, 0x0380, 0x0082, - 0x009e, 0x03c4, 0x0080, 0x005c, 0x0004, 0x03bc, 0x03a4, 0x007c, 0x009d, 0x0064, 0x0083, 0x0383, 0x039d, 0x0084, 0x0384, 0x039c, - 0x009c, - /* spectrum table 7 [64] (unsigned) */ - 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0823, 0x0842, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824, - 0x0881, 0x0825, 0x08a1, 0x0863, 0x0844, 0x0404, 0x0480, 0x0882, 0x0845, 0x08a2, 0x0405, 0x08c1, 0x04a0, 0x0826, 0x0883, 0x0865, - 0x0864, 0x08a3, 0x0846, 0x08c2, 0x0827, 0x0866, 0x0406, 0x04c0, 0x0884, 0x08e1, 0x0885, 0x08e2, 0x08a4, 0x08c3, 0x0847, 0x08e3, - 0x08c4, 0x08a5, 0x0886, 0x0867, 0x04e0, 0x0407, 0x08c5, 0x08a6, 0x08e4, 0x0887, 0x08a7, 0x08e5, 0x08e6, 0x08c6, 0x08c7, 0x08e7, - /* spectrum table 8 [64] (unsigned) */ - 0x0821, 0x0841, 0x0420, 0x0822, 0x0401, 0x0842, 0x0000, 0x0440, 0x0402, 0x0861, 0x0823, 0x0862, 0x0843, 0x0863, 0x0881, 0x0824, - 0x0882, 0x0844, 0x0460, 0x0403, 0x0883, 0x0864, 0x08a2, 0x08a1, 0x0845, 0x0825, 0x08a3, 0x0865, 0x0884, 0x08a4, 0x0404, 0x0885, - 0x0480, 0x0846, 0x08c2, 0x08c1, 0x0826, 0x0866, 0x08c3, 0x08a5, 0x04a0, 0x08c4, 0x0405, 0x0886, 0x08e1, 0x08e2, 0x0847, 0x08c5, - 0x08e3, 0x0827, 0x08a6, 0x0867, 0x08c6, 0x08e4, 0x04c0, 0x0887, 0x0406, 0x08e5, 0x08e6, 0x08c7, 0x08a7, 0x04e0, 0x0407, 0x08e7, - /* spectrum table 9 [169] (unsigned) */ - 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0842, 0x0823, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824, - 0x0881, 0x0844, 0x0825, 0x0882, 0x0863, 0x0404, 0x0480, 0x08a1, 0x0845, 0x0826, 0x0864, 0x08a2, 0x08c1, 0x0883, 0x0405, 0x0846, - 0x04a0, 0x0827, 0x0865, 0x0828, 0x0901, 0x0884, 0x08a3, 0x08c2, 0x08e1, 0x0406, 0x0902, 0x0848, 0x0866, 0x0847, 0x0885, 0x0921, - 0x0829, 0x08e2, 0x04c0, 0x08a4, 0x08c3, 0x0903, 0x0407, 0x0922, 0x0868, 0x0886, 0x0867, 0x0408, 0x0941, 0x08c4, 0x0849, 0x08a5, - 0x0500, 0x04e0, 0x08e3, 0x0942, 0x0923, 0x0904, 0x082a, 0x08e4, 0x08c5, 0x08a6, 0x0888, 0x0887, 0x0869, 0x0961, 0x08a8, 0x0520, - 0x0905, 0x0943, 0x084a, 0x0409, 0x0962, 0x0924, 0x08c6, 0x0981, 0x0889, 0x0906, 0x082b, 0x0925, 0x0944, 0x08a7, 0x08e5, 0x084b, - 0x082c, 0x0982, 0x0963, 0x086a, 0x08a9, 0x08c7, 0x0907, 0x0964, 0x040a, 0x08e6, 0x0983, 0x0540, 0x0945, 0x088a, 0x08c8, 0x084c, - 0x0926, 0x0927, 0x088b, 0x0560, 0x08c9, 0x086b, 0x08aa, 0x0908, 0x08e8, 0x0985, 0x086c, 0x0965, 0x08e7, 0x0984, 0x0966, 0x0946, - 0x088c, 0x08e9, 0x08ab, 0x040b, 0x0986, 0x08ca, 0x0580, 0x0947, 0x08ac, 0x08ea, 0x0928, 0x040c, 0x0967, 0x0909, 0x0929, 0x0948, - 0x08eb, 0x0987, 0x08cb, 0x090b, 0x0968, 0x08ec, 0x08cc, 0x090a, 0x0949, 0x090c, 0x092a, 0x092b, 0x092c, 0x094b, 0x0989, 0x094a, - 0x0969, 0x0988, 0x096a, 0x098a, 0x098b, 0x094c, 0x096b, 0x096c, 0x098c, - /* spectrum table 10 [169] (unsigned) */ - 0x0821, 0x0822, 0x0841, 0x0842, 0x0420, 0x0401, 0x0823, 0x0862, 0x0861, 0x0843, 0x0863, 0x0440, 0x0402, 0x0844, 0x0882, 0x0824, - 0x0881, 0x0000, 0x0883, 0x0864, 0x0460, 0x0403, 0x0884, 0x0845, 0x08a2, 0x0825, 0x08a1, 0x08a3, 0x0865, 0x08a4, 0x0885, 0x08c2, - 0x0846, 0x08c3, 0x0480, 0x08c1, 0x0404, 0x0826, 0x0866, 0x08a5, 0x08c4, 0x0886, 0x08c5, 0x08e2, 0x0867, 0x0847, 0x08a6, 0x0902, - 0x08e3, 0x04a0, 0x08e1, 0x0405, 0x0901, 0x0827, 0x0903, 0x08e4, 0x0887, 0x0848, 0x08c6, 0x08e5, 0x0828, 0x0868, 0x0904, 0x0888, - 0x08a7, 0x0905, 0x08a8, 0x08e6, 0x08c7, 0x0922, 0x04c0, 0x08c8, 0x0923, 0x0869, 0x0921, 0x0849, 0x0406, 0x0906, 0x0924, 0x0889, - 0x0942, 0x0829, 0x08e7, 0x0907, 0x0925, 0x08e8, 0x0943, 0x08a9, 0x0944, 0x084a, 0x0941, 0x086a, 0x0926, 0x08c9, 0x0500, 0x088a, - 0x04e0, 0x0962, 0x08e9, 0x0963, 0x0946, 0x082a, 0x0961, 0x0927, 0x0407, 0x0908, 0x0945, 0x086b, 0x08aa, 0x0909, 0x0965, 0x0408, - 0x0964, 0x084b, 0x08ea, 0x08ca, 0x0947, 0x088b, 0x082b, 0x0982, 0x0928, 0x0983, 0x0966, 0x08ab, 0x0984, 0x0967, 0x0985, 0x086c, - 0x08cb, 0x0520, 0x0948, 0x0540, 0x0981, 0x0409, 0x088c, 0x0929, 0x0986, 0x084c, 0x090a, 0x092a, 0x082c, 0x0968, 0x0987, 0x08eb, - 0x08ac, 0x08cc, 0x0949, 0x090b, 0x0988, 0x040a, 0x08ec, 0x0560, 0x094a, 0x0969, 0x096a, 0x040b, 0x096b, 0x092b, 0x094b, 0x0580, - 0x090c, 0x0989, 0x094c, 0x092c, 0x096c, 0x098b, 0x040c, 0x098a, 0x098c, - /* spectrum table 11 [289] (unsigned) */ - 0x0000, 0x2041, 0x2410, 0x1040, 0x1001, 0x2081, 0x2042, 0x2082, 0x2043, 0x20c1, 0x20c2, 0x1080, 0x2083, 0x1002, 0x20c3, 0x2101, - 0x2044, 0x2102, 0x2084, 0x2103, 0x20c4, 0x10c0, 0x1003, 0x2141, 0x2142, 0x2085, 0x2104, 0x2045, 0x2143, 0x20c5, 0x2144, 0x2105, - 0x2182, 0x2086, 0x2181, 0x2183, 0x20c6, 0x2046, 0x2110, 0x20d0, 0x2405, 0x2403, 0x2404, 0x2184, 0x2406, 0x1100, 0x2106, 0x1004, - 0x2090, 0x2145, 0x2150, 0x2407, 0x2402, 0x2408, 0x2087, 0x21c2, 0x20c7, 0x2185, 0x2146, 0x2190, 0x240a, 0x21c3, 0x21c1, 0x2409, - 0x21d0, 0x2050, 0x2047, 0x2107, 0x240b, 0x21c4, 0x240c, 0x2210, 0x2401, 0x2186, 0x2250, 0x2088, 0x2147, 0x2290, 0x240d, 0x2203, - 0x2202, 0x20c8, 0x1140, 0x240e, 0x22d0, 0x21c5, 0x2108, 0x2187, 0x21c6, 0x1005, 0x2204, 0x240f, 0x2310, 0x2048, 0x2201, 0x2390, - 0x2148, 0x2350, 0x20c9, 0x2205, 0x21c7, 0x2089, 0x2206, 0x2242, 0x2243, 0x23d0, 0x2109, 0x2188, 0x1180, 0x2244, 0x2149, 0x2207, - 0x21c8, 0x2049, 0x2283, 0x1006, 0x2282, 0x2241, 0x2245, 0x210a, 0x208a, 0x2246, 0x20ca, 0x2189, 0x2284, 0x2208, 0x2285, 0x2247, - 0x22c3, 0x204a, 0x11c0, 0x2286, 0x21c9, 0x20cb, 0x214a, 0x2281, 0x210b, 0x22c2, 0x2342, 0x218a, 0x2343, 0x208b, 0x1400, 0x214b, - 0x22c5, 0x22c4, 0x2248, 0x21ca, 0x2209, 0x1010, 0x210d, 0x1007, 0x20cd, 0x22c6, 0x2341, 0x2344, 0x2303, 0x208d, 0x2345, 0x220a, - 0x218b, 0x2288, 0x2287, 0x2382, 0x2304, 0x204b, 0x210c, 0x22c1, 0x20cc, 0x204d, 0x2302, 0x21cb, 0x20ce, 0x214c, 0x214d, 0x2384, - 0x210e, 0x22c7, 0x2383, 0x2305, 0x2346, 0x2306, 0x1200, 0x22c8, 0x208c, 0x2249, 0x2385, 0x218d, 0x228a, 0x23c2, 0x220b, 0x224a, - 0x2386, 0x2289, 0x214e, 0x22c9, 0x2381, 0x208e, 0x218c, 0x204c, 0x2348, 0x1008, 0x2347, 0x21cc, 0x2307, 0x21cd, 0x23c3, 0x2301, - 0x218e, 0x208f, 0x23c5, 0x23c4, 0x204e, 0x224b, 0x210f, 0x2387, 0x220d, 0x2349, 0x220c, 0x214f, 0x20cf, 0x228b, 0x22ca, 0x2308, - 0x23c6, 0x23c7, 0x220e, 0x23c1, 0x21ce, 0x1240, 0x1009, 0x224d, 0x224c, 0x2309, 0x2388, 0x228d, 0x2389, 0x230a, 0x218f, 0x21cf, - 0x224e, 0x23c8, 0x22cb, 0x22ce, 0x204f, 0x228c, 0x228e, 0x234b, 0x234a, 0x22cd, 0x22cc, 0x220f, 0x238b, 0x234c, 0x230d, 0x23c9, - 0x238a, 0x1280, 0x230b, 0x224f, 0x100a, 0x230c, 0x12c0, 0x230e, 0x228f, 0x234d, 0x100d, 0x238c, 0x23ca, 0x23cb, 0x22cf, 0x238d, - 0x1340, 0x100b, 0x234e, 0x23cc, 0x23cd, 0x230f, 0x1380, 0x238e, 0x234f, 0x1300, 0x238f, 0x100e, 0x100c, 0x23ce, 0x13c0, 0x100f, - 0x23cf, -}; - -const HuffInfo huffTabScaleFactInfo PROGMEM = - {19, { 1, 0, 1, 3, 2, 4, 3, 5, 4, 6, 6, 6, 5, 8, 4, 7, 3, 7, 46, 0}, 0}; - -/* note - includes offset of -60 (4.6.2.3 in spec) */ -const signed short huffTabScaleFact[121] PROGMEM = { - /* scale factor table [121] */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, 6, -6, 7, -7, 8, - -8, 9, -9, 10, -10, -11, 11, 12, -12, 13, -13, 14, -14, 16, 15, 17, - 18, -15, -17, -16, 19, -18, -19, 20, -20, 21, -21, 22, -22, 23, -23, -25, - 25, -27, -24, -26, 24, -28, 27, 29, -30, -29, 26, -31, -34, -33, -32, -36, - 28, -35, -38, -37, 30, -39, -41, -57, -59, -58, -60, 38, 39, 40, 41, 42, - 57, 37, 31, 32, 33, 34, 35, 36, 44, 51, 52, 53, 54, 55, 56, 50, - 45, 46, 47, 48, 49, 58, -54, -52, -51, -50, -55, 43, 60, 59, -56, -53, - -45, -44, -42, -40, -43, -49, -48, -46, -47, -}; - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/imdct.c b/components/spotify/cspot/bell/external/libhelix-aac/imdct.c deleted file mode 100644 index 1ff9e4ab..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/imdct.c +++ /dev/null @@ -1,589 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: imdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * imdct.c - inverse MDCT - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define RND_VAL (1 << (FBITS_OUT_IMDCT-1)) - -#ifndef AAC_ENABLE_SBR - -/************************************************************************************** - * Function: DecWindowOverlap - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-LONG - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ -/*__attribute__ ((section (".data")))*/ static void DecWindowOverlap(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - if (winTypeCurr == winTypePrev) { - /* cut window loads in half since current and overlap sections use same symmetric window */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } else { - /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */ - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStart - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-START - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data")))*/ static void DecWindowOverlapLongStart(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - in = *buf1--; - - *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */ - *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */ - } while (--i); - - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */ - w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */ - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */ - *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */ - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStop - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-STOP - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data")))*/ static void DecWindowOverlapLongStop(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - /* Wn = 0 for n = (0, 1, ... 447) */ - /* Wn = 1 for n = (576, 577, ... 1023) */ - in = *buf0++; - f1 = in >> 1; /* scale since skipping multiply by Q31 */ - - in = *over0; - *pcm0 = CLIPTOSHORT( (in + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (--i); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapShort - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence EIGHT-SHORT (does all 8 short blocks) - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data"))) */ static void DecWindowOverlapShort(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* pcm[0-447] = 0 + overlap[0-447] */ - i = 448; - do { - f0 = *over0++; - f1 = *over0++; - *pcm0 = CLIPTOSHORT( (f0 + RND_VAL) >> FBITS_OUT_IMDCT ); pcm0 += nChans; - *pcm0 = CLIPTOSHORT( (f1 + RND_VAL) >> FBITS_OUT_IMDCT ); pcm0 += nChans; - i -= 2; - } while (i); - - /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */ - pcm1 = pcm0 + (128 - 1) * nChans; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - /* save over0/over1 for next short block, in the slots just vacated */ - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - - /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703] - * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831] - * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959] - */ - for (i = 0; i < 3; i++) { - pcm0 += 64 * nChans; - pcm1 = pcm0 + (128 - 1) * nChans; - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 - 128); /* from last short block */ - in += *(over0 + 0); /* from last full frame */ - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *(over1 - 128); /* from last short block */ - in += *(over1 + 0); /* from last full frame */ - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - /* save over0/over1 for next short block, in the slots just vacated */ - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023] - * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127] - */ - pcm0 += 64 * nChans; - over0 -= 832; /* points at overlap[64] */ - over1 = over0 + 128 - 1; /* points at overlap[191] */ - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 + 768); /* from last short block */ - in += *(over0 + 896); /* from last full frame */ - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *(over1 + 768); /* from last short block */ - *(over1 - 128) = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */ - *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */ - } while (over0 < over1); - - /* over0 now points at overlap[128] */ - - /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127] - * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127] - * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127] - * over[448-576] = Wc[128-255] * block7[128-255] - */ - for (i = 0; i < 3; i++) { - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - /* from last short block */ - *(over0 - 128) -= f0; - *(over1 - 128)+= f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* over[576-1024] = 0 */ - i = 448; - over0 += 64; - do { - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - i -= 4; - } while (i); -} - -#endif /* !AAC_ENABLE_SBR */ - -/************************************************************************************** - * Function: IMDCT - * - * Description: inverse transform and convert to 16-bit PCM - * - * Inputs: valid AACDecInfo struct - * index of current channel (0 for SCE/LFE, 0 or 1 for CPE) - * output channel (range = [0, nChans-1]) - * - * Outputs: complete frame of decoded PCM, after inverse transform - * - * Return: 0 if successful, -1 if error - * - * Notes: If AAC_ENABLE_SBR is defined at compile time then window + overlap - * does NOT clip to 16-bit PCM and does NOT interleave channels - * If AAC_ENABLE_SBR is NOT defined at compile time, then window + overlap - * does clip to 16-bit PCM and interleaves channels - * If SBR is enabled at compile time, but we don't know whether it is - * actually used for this frame (e.g. the first frame of a stream), - * we need to produce both clipped 16-bit PCM in outbuf AND - * unclipped 32-bit PCM in the SBR input buffer. In this case we make - * a separate pass over the 32-bit PCM to produce 16-bit PCM output. - * This inflicts a slight performance hit when decoding non-SBR files. - **************************************************************************************/ -int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf) -{ - int i; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - outbuf += chOut; - - /* optimized type-IV DCT (operates inplace) */ - if (icsInfo->winSequence == 2) { - /* 8 short blocks */ - for (i = 0; i < 8; i++) - DCT4(0, psi->coef[ch] + i*128, psi->gbCurrent[ch]); - } else { - /* 1 long block */ - DCT4(1, psi->coef[ch], psi->gbCurrent[ch]); - } - -#ifdef AAC_ENABLE_SBR - /* window, overlap-add, don't clip to short (send to SBR decoder) - * store the decoded 32-bit samples in top half (second AAC_MAX_NSAMPS samples) of coef buffer - */ - if (icsInfo->winSequence == 0) - DecWindowOverlapNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 1) - DecWindowOverlapLongStartNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 2) - DecWindowOverlapShortNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 3) - DecWindowOverlapLongStopNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - - if (!aacDecInfo->sbrEnabled) { - for (i = 0; i < AAC_MAX_NSAMPS; i++) { - *outbuf = CLIPTOSHORT((psi->sbrWorkBuf[ch][i] + RND_VAL) >> FBITS_OUT_IMDCT); - outbuf += aacDecInfo->nChans; - } - } - - aacDecInfo->rawSampleBuf[ch] = psi->sbrWorkBuf[ch]; - aacDecInfo->rawSampleBytes = sizeof(int); - aacDecInfo->rawSampleFBits = FBITS_OUT_IMDCT; -#else - /* window, overlap-add, round to PCM - optimized for each window sequence */ - if (icsInfo->winSequence == 0) - DecWindowOverlap(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 1) - DecWindowOverlapLongStart(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 2) - DecWindowOverlapShort(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 3) - DecWindowOverlapLongStop(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - - aacDecInfo->rawSampleBuf[ch] = 0; - aacDecInfo->rawSampleBytes = 0; - aacDecInfo->rawSampleFBits = 0; -#endif - - psi->prevWinShape[chOut] = icsInfo->winShape; - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aaccommon.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aaccommon.h deleted file mode 100644 index 9d862fab..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aaccommon.h +++ /dev/null @@ -1,213 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * aaccommon.h - implementation-independent API's, datatypes, and definitions - **************************************************************************************/ - -#ifndef _AACCOMMON_H -#define _AACCOMMON_H - -#ifdef ESP8266 -# include "pgmspace.h" -#elif defined(ESP_PLATFORM) && __has_include() -# include -#else -# define PROGMEM -# define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -# define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif -// Can't fit in ESP8266 RAM -#ifndef ESP8266 - #define AAC_ENABLE_SBR 1 -#endif - -#pragma GCC optimize ("O3") - -#include "aacdec.h" -#include "statname.h" - -/* 12-bit syncword */ -#define SYNCWORDH 0xff -#define SYNCWORDL 0xf0 - -#define MAX_NCHANS_ELEM 2 /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */ - -#define ADTS_HEADER_BYTES 7 -#define NUM_SAMPLE_RATES 12 -#define NUM_DEF_CHAN_MAPS 8 -#define NUM_ELEMENTS 8 -#define MAX_NUM_PCE_ADIF 16 - -#define MAX_WIN_GROUPS 8 -#define MAX_SFB_SHORT 15 -#define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */ -#define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3) -#define MAX_PRED_SFB 41 -#define MAX_TNS_FILTERS 8 -#define MAX_TNS_COEFS 60 -#define MAX_TNS_ORDER 20 -#define MAX_PULSES 4 -#define MAX_GAIN_BANDS 3 -#define MAX_GAIN_WIN 8 -#define MAX_GAIN_ADJUST 7 - -#define NSAMPS_LONG 1024 -#define NSAMPS_SHORT 128 - -#define NUM_SYN_ID_BITS 3 -#define NUM_INST_TAG_BITS 4 - -#define EXT_SBR_DATA 0x0d -#define EXT_SBR_DATA_CRC 0x0e - -#define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F') -#define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS))) - -/* AAC file format */ -enum { - AAC_FF_Unknown = 0, /* should be 0 on init */ - - AAC_FF_ADTS = 1, - AAC_FF_ADIF = 2, - AAC_FF_RAW = 3 - -}; - -/* syntactic element type */ -enum { - AAC_ID_INVALID = -1, - - AAC_ID_SCE = 0, - AAC_ID_CPE = 1, - AAC_ID_CCE = 2, - AAC_ID_LFE = 3, - AAC_ID_DSE = 4, - AAC_ID_PCE = 5, - AAC_ID_FIL = 6, - AAC_ID_END = 7 -}; - -typedef struct _AACDecInfo { - /* pointers to platform-specific state information */ - void *psInfoBase; /* baseline MPEG-4 LC decoding */ - void *psInfoSBR; /* MPEG-4 SBR decoding */ - - /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */ - void *rawSampleBuf[AAC_MAX_NCHANS]; - int rawSampleBytes; - int rawSampleFBits; - - /* fill data (can be used for processing SBR or other extensions) */ - unsigned char *fillBuf; - int fillCount; - int fillExtType; - - /* block information */ - int prevBlockID; - int currBlockID; - int currInstTag; - int sbDeinterleaveReqd[MAX_NCHANS_ELEM]; - int adtsBlocksLeft; - - /* user-accessible info */ - int bitRate; - int nChans; - int sampRate; - int profile; - int format; - int sbrEnabled; - int tnsUsed; - int pnsUsed; - int frameCount; - -} AACDecInfo; - -/* decoder functions which must be implemented for each platform */ -AACDecInfo *AllocateBuffers(void); -AACDecInfo *AllocateBuffersPre(void **space, int *len); -void FreeBuffers(AACDecInfo *aacDecInfo); -void ClearBuffer(void *buf, int nBytes); - -int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail); -int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile); -int PrepareRawBlock(AACDecInfo *aacDecInfo); -int FlushCodec(AACDecInfo *aacDecInfo); - -int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail); -int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch); - -int Dequantize(AACDecInfo *aacDecInfo, int ch); -int StereoProcess(AACDecInfo *aacDecInfo); -int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch); -int PNS(AACDecInfo *aacDecInfo, int ch); -int TNSFilter(AACDecInfo *aacDecInfo, int ch); -int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf); - -/* SBR specific functions */ -int InitSBR(AACDecInfo *aacDecInfo); -int InitSBRPre(AACDecInfo *aacDecInfo, void **ptr, int *sz); -void FreeSBR(AACDecInfo *aacDecInfo); -int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase); -int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf); -int FlushCodecSBR(AACDecInfo *aacDecInfo); - -/* aactabs.c - global ROM tables */ -extern const int sampRateTab[NUM_SAMPLE_RATES]; -extern const int predSFBMax[NUM_SAMPLE_RATES]; -extern const int channelMapTab[NUM_DEF_CHAN_MAPS]; -extern const int elementNumChans[NUM_ELEMENTS]; -extern const unsigned /*char*/ int sfBandTotalShort[NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int sfBandTotalLong[NUM_SAMPLE_RATES]; -extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES]; -extern const /*short*/ int sfBandTabShort[76]; -extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES]; -extern const /*short*/ int sfBandTabLong[325]; -extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES]; -extern const unsigned /*char*/ int tnsMaxBandsShort[2*NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int tnsMaxOrderShort[AAC_NUM_PROFILES]; -extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES]; -extern const unsigned /*char*/ int tnsMaxBandsLong[2*NUM_SAMPLE_RATES]; -extern const unsigned /*char*/ int tnsMaxOrderLong[AAC_NUM_PROFILES]; - -#endif /* _AACCOMMON_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.c deleted file mode 100644 index cb0e5041..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.c +++ /dev/null @@ -1,476 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aacdec.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * aacdec.c - platform-independent top level decoder API - **************************************************************************************/ - -#include "aaccommon.h" - -//#include "profile.h" - -#define PROFILE_START(x) -#define PROFILE_END() - -/************************************************************************************** - * Function: AACInitDecoder - * - * Description: allocate memory for platform-specific data - * clear all the user-accessible fields - * initialize SBR decoder if enabled - * - * Inputs: none - * - * Outputs: none - * - * Return: handle to AAC decoder instance, 0 if malloc fails - **************************************************************************************/ -HAACDecoder AACInitDecoder(void) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = AllocateBuffers(); - if (!aacDecInfo) - return 0; - -#ifdef AAC_ENABLE_SBR - if (InitSBR(aacDecInfo)) { - AACFreeDecoder(aacDecInfo); - return 0; - } -#endif - - return (HAACDecoder)aacDecInfo; -} - -HAACDecoder AACInitDecoderPre(void *ptr, int sz) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = AllocateBuffersPre(&ptr, &sz); - if (!aacDecInfo) - return 0; - -#ifdef AAC_ENABLE_SBR - if (InitSBRPre(aacDecInfo, &ptr, &sz)) { - return 0; - } -#endif - - return (HAACDecoder)aacDecInfo; -} - -/************************************************************************************** - * Function: AACFreeDecoder - * - * Description: free platform-specific data allocated by AACInitDecoder - * free SBR decoder if enabled - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * - * Outputs: none - * - * Return: none - **************************************************************************************/ -void AACFreeDecoder(HAACDecoder hAACDecoder) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return; - -#ifdef AAC_ENABLE_SBR - FreeSBR(aacDecInfo); -#endif - FreeBuffers(aacDecInfo); -} - -/************************************************************************************** - * Function: AACFindSyncWord - * - * Description: locate the next byte-alinged sync word in the raw AAC stream - * - * Inputs: buffer to search for sync word - * max number of bytes to search in buffer - * - * Outputs: none - * - * Return: offset to first sync word (bytes from start of buf) - * -1 if sync not found after searching nBytes - **************************************************************************************/ -int AACFindSyncWord(unsigned char *buf, int nBytes) -{ - int i; - - /* find byte-aligned syncword (12 bits = 0xFFF) */ - for (i = 0; i < nBytes - 1; i++) { - if ( (buf[i+0] & SYNCWORDH) == SYNCWORDH && (buf[i+1] & SYNCWORDL) == SYNCWORDL ) - return i; - } - - return -1; -} - -/************************************************************************************** - * Function: AACGetLastFrameInfo - * - * Description: get info about last AAC frame decoded (number of samples decoded, - * sample rate, bit rate, etc.) - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * pointer to AACFrameInfo struct - * - * Outputs: filled-in AACFrameInfo struct - * - * Return: none - * - * Notes: call this right after calling AACDecode() - **************************************************************************************/ -void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) { - aacFrameInfo->bitRate = 0; - aacFrameInfo->nChans = 0; - aacFrameInfo->sampRateCore = 0; - aacFrameInfo->sampRateOut = 0; - aacFrameInfo->bitsPerSample = 0; - aacFrameInfo->outputSamps = 0; - aacFrameInfo->profile = 0; - aacFrameInfo->tnsUsed = 0; - aacFrameInfo->pnsUsed = 0; - } else { - aacFrameInfo->bitRate = aacDecInfo->bitRate; - aacFrameInfo->nChans = aacDecInfo->nChans; - aacFrameInfo->sampRateCore = aacDecInfo->sampRate; - aacFrameInfo->sampRateOut = aacDecInfo->sampRate * (aacDecInfo->sbrEnabled ? 2 : 1); - aacFrameInfo->bitsPerSample = 16; - aacFrameInfo->outputSamps = aacDecInfo->nChans * AAC_MAX_NSAMPS * (aacDecInfo->sbrEnabled ? 2 : 1); - aacFrameInfo->profile = aacDecInfo->profile; - aacFrameInfo->tnsUsed = aacDecInfo->tnsUsed; - aacFrameInfo->pnsUsed = aacDecInfo->pnsUsed; - } -} - -/************************************************************************************** - * Function: AACSetRawBlockParams - * - * Description: set internal state variables for decoding a stream of raw data blocks - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * flag indicating source of parameters - * AACFrameInfo struct, with the members nChans, sampRate, and profile - * optionally filled-in - * - * Outputs: updated codec state - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: if copyLast == 1, then the codec sets up its internal state (for - * decoding raw blocks) based on previously-decoded ADTS header info - * if copyLast == 0, then the codec uses the values passed in - * aacFrameInfo to configure its internal state (useful when the - * source is MP4 format, for example) - **************************************************************************************/ -int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo) -{ - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - aacDecInfo->format = AAC_FF_RAW; - if (copyLast) - return SetRawBlockParams(aacDecInfo, 1, 0, 0, 0); - else - return SetRawBlockParams(aacDecInfo, 0, aacFrameInfo->nChans, aacFrameInfo->sampRateCore, aacFrameInfo->profile); -} - -/************************************************************************************** - * Function: AACFlushCodec - * - * Description: flush internal codec state (after seeking, for example) - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int AACFlushCodec(HAACDecoder hAACDecoder) -{ - int ch; - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* reset common state variables which change per-frame - * don't touch state variables which are (usually) constant for entire clip - * (nChans, sampRate, profile, format, sbrEnabled) - */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - for (ch = 0; ch < MAX_NCHANS_ELEM; ch++) - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - aacDecInfo->adtsBlocksLeft = 0; - aacDecInfo->tnsUsed = 0; - aacDecInfo->pnsUsed = 0; - - /* reset internal codec state (flush overlap buffers, etc.) */ - FlushCodec(aacDecInfo); -#ifdef AAC_ENABLE_SBR - FlushCodecSBR(aacDecInfo); -#endif - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: AACDecode - * - * Description: decode AAC frame - * - * Inputs: valid AAC decoder instance pointer (HAACDecoder) - * double pointer to buffer of AAC data - * pointer to number of valid bytes remaining in inbuf - * pointer to outbuf, big enough to hold one frame of decoded PCM samples - * (outbuf must be double-sized if SBR enabled) - * - * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo - * number of output samples = 1024 per channel (2048 if SBR enabled) - * updated inbuf pointer - * updated bytesLeft - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: inbuf pointer and bytesLeft are not updated until whole frame is - * successfully decoded, so if ERR_AAC_INDATA_UNDERFLOW is returned - * just call AACDecode again with more data in inbuf - **************************************************************************************/ -int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf) -{ - int err, offset, bitOffset, bitsAvail; - int ch, baseChan, elementChans; - unsigned char *inptr; - AACDecInfo *aacDecInfo = (AACDecInfo *)hAACDecoder; -#ifdef AAC_ENABLE_SBR - int baseChanSBR, elementChansSBR; -#endif - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* make local copies (see "Notes" above) */ - inptr = *inbuf; - bitOffset = 0; - bitsAvail = (*bytesLeft) << 3; - - /* first time through figure out what the file format is */ - if (aacDecInfo->format == AAC_FF_Unknown) { - if (bitsAvail < 32) - return ERR_AAC_INDATA_UNDERFLOW; - - if (IS_ADIF(inptr)) { - /* unpack ADIF header */ - aacDecInfo->format = AAC_FF_ADIF; - err = UnpackADIFHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - } else { - /* assume ADTS by default */ - aacDecInfo->format = AAC_FF_ADTS; - } - } - - - - /* if ADTS, search for start of next frame */ - if (aacDecInfo->format == AAC_FF_ADTS) { - /* can have 1-4 raw data blocks per ADTS frame (header only present for first one) */ - if (aacDecInfo->adtsBlocksLeft == 0) { - offset = AACFindSyncWord(inptr, bitsAvail >> 3); - if (offset < 0) - return ERR_AAC_INDATA_UNDERFLOW; - inptr += offset; - bitsAvail -= (offset << 3); - - err = UnpackADTSHeader(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - - if (aacDecInfo->nChans == -1) { - /* figure out implicit channel mapping if necessary */ - err = GetADTSChannelMapping(aacDecInfo, inptr, bitOffset, bitsAvail); - if (err) - return err; - } - } - aacDecInfo->adtsBlocksLeft--; - } else if (aacDecInfo->format == AAC_FF_RAW) { - err = PrepareRawBlock(aacDecInfo); - if (err) - return err; - } - - - - /* check for valid number of channels */ - if (aacDecInfo->nChans > AAC_MAX_NCHANS || aacDecInfo->nChans <= 0) - return ERR_AAC_NCHANS_TOO_HIGH; - - /* will be set later if active in this frame */ - aacDecInfo->tnsUsed = 0; - aacDecInfo->pnsUsed = 0; - - bitOffset = 0; - baseChan = 0; -#ifdef AAC_ENABLE_SBR - baseChanSBR = 0; -#endif - do { - - - - /* parse next syntactic element */ - err = DecodeNextElement(aacDecInfo, &inptr, &bitOffset, &bitsAvail); - if (err) - return err; - - elementChans = elementNumChans[aacDecInfo->currBlockID]; - if (baseChan + elementChans > AAC_MAX_NCHANS) - return ERR_AAC_NCHANS_TOO_HIGH; - - /* noiseless decoder and dequantizer */ - for (ch = 0; ch < elementChans; ch++) { - PROFILE_START("noiseless decoder"); - err = DecodeNoiselessData(aacDecInfo, &inptr, &bitOffset, &bitsAvail, ch); - PROFILE_END(); - - if (err) - return err; - - PROFILE_START("dequant"); - if (Dequantize(aacDecInfo, ch)) - return ERR_AAC_DEQUANT; - PROFILE_END(); - } - - PROFILE_START("mid-side and intensity stereo"); - /* mid-side and intensity stereo */ - if (aacDecInfo->currBlockID == AAC_ID_CPE) { - if (StereoProcess(aacDecInfo)) - return ERR_AAC_STEREO_PROCESS; - } - PROFILE_END(); - - - /* PNS, TNS, inverse transform */ - for (ch = 0; ch < elementChans; ch++) { - PROFILE_START("PNS"); - if (PNS(aacDecInfo, ch)) - return ERR_AAC_PNS; - PROFILE_END(); - - if (aacDecInfo->sbDeinterleaveReqd[ch]) { - /* deinterleave short blocks, if required */ - if (DeinterleaveShortBlocks(aacDecInfo, ch)) - return ERR_AAC_SHORT_BLOCK_DEINT; - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - } - - PROFILE_START("TNS"); - if (TNSFilter(aacDecInfo, ch)) - return ERR_AAC_TNS; - PROFILE_END(); - - PROFILE_START("IMDCT"); - if (IMDCT(aacDecInfo, ch, baseChan + ch, outbuf)) - return ERR_AAC_IMDCT; - PROFILE_END(); - } - -#ifdef AAC_ENABLE_SBR - if (aacDecInfo->sbrEnabled && (aacDecInfo->currBlockID == AAC_ID_FIL || aacDecInfo->currBlockID == AAC_ID_LFE)) { - if (aacDecInfo->currBlockID == AAC_ID_LFE) - elementChansSBR = elementNumChans[AAC_ID_LFE]; - else if (aacDecInfo->currBlockID == AAC_ID_FIL && (aacDecInfo->prevBlockID == AAC_ID_SCE || aacDecInfo->prevBlockID == AAC_ID_CPE)) - elementChansSBR = elementNumChans[aacDecInfo->prevBlockID]; - else - elementChansSBR = 0; - - if (baseChanSBR + elementChansSBR > AAC_MAX_NCHANS) - return ERR_AAC_SBR_NCHANS_TOO_HIGH; - - /* parse SBR extension data if present (contained in a fill element) */ - if (DecodeSBRBitstream(aacDecInfo, baseChanSBR)) - return ERR_AAC_SBR_BITSTREAM; - - /* apply SBR */ - if (DecodeSBRData(aacDecInfo, baseChanSBR, outbuf)) - return ERR_AAC_SBR_DATA; - - baseChanSBR += elementChansSBR; - } -#endif - - baseChan += elementChans; - } while (aacDecInfo->currBlockID != AAC_ID_END); - - /* byte align after each raw_data_block */ - if (bitOffset) { - inptr++; - bitsAvail -= (8-bitOffset); - bitOffset = 0; - if (bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - } - - /* update pointers */ - aacDecInfo->frameCount++; - *bytesLeft -= (inptr - *inbuf); - *inbuf = inptr; - - return ERR_AAC_NONE; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.h deleted file mode 100644 index 9cc738e7..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aacdec.h +++ /dev/null @@ -1,175 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * aacdec.h - public C API for AAC decoder - **************************************************************************************/ - -#ifndef _AACDEC_H -#define _AACDEC_H - -#if defined(_WIN32) && !defined(_WIN32_WCE) -# -#elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM) -# -#elif defined(_WIN32) && defined(WINCE_EMULATOR) -# -#elif defined (__arm) && defined (__ARMCC_VERSION) -# -#elif defined(_SYMBIAN) && defined(__WINS__) -# -#elif defined(__GNUC__) && defined(__arm__) -# -#elif defined(__GNUC__) && defined(__i386__) -# -#elif defined(__APPLE__) -# -#elif defined(__GNUC__) && defined(__amd64__) -# -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) -# -#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR) -# -#elif defined(_SOLARIS) && !defined(__GNUC__) -# -#elif defined(ESP_PLATFORM) -# -#else -#error No platform defined. See valid options in aacdec.h -#endif - -#ifndef USE_DEFAULT_STDLIB -#define USE_DEFAULT_STDLIB -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3) - * max size of input buffer = - * 6144 bits = 768 bytes per SCE or CCE-I - * 12288 bits = 1536 bytes per CPE - * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to) - */ -#ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */ -#define AAC_MAX_NCHANS 2 /* set to default max number of channels */ -#endif -#define AAC_MAX_NSAMPS 1024 -#define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS) - -#define AAC_NUM_PROFILES 3 -#define AAC_PROFILE_MP 0 -#define AAC_PROFILE_LC 1 -#define AAC_PROFILE_SSR 2 - -/* define these to enable decoder features */ -#if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR) -#define AAC_ENABLE_SBR -#endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR. -#define AAC_ENABLE_MPEG4 - -enum { - ERR_AAC_NONE = 0, - ERR_AAC_INDATA_UNDERFLOW = -1, - ERR_AAC_NULL_POINTER = -2, - ERR_AAC_INVALID_ADTS_HEADER = -3, - ERR_AAC_INVALID_ADIF_HEADER = -4, - ERR_AAC_INVALID_FRAME = -5, - ERR_AAC_MPEG4_UNSUPPORTED = -6, - ERR_AAC_CHANNEL_MAP = -7, - ERR_AAC_SYNTAX_ELEMENT = -8, - - ERR_AAC_DEQUANT = -9, - ERR_AAC_STEREO_PROCESS = -10, - ERR_AAC_PNS = -11, - ERR_AAC_SHORT_BLOCK_DEINT = -12, - ERR_AAC_TNS = -13, - ERR_AAC_IMDCT = -14, - ERR_AAC_NCHANS_TOO_HIGH = -15, - - ERR_AAC_SBR_INIT = -16, - ERR_AAC_SBR_BITSTREAM = -17, - ERR_AAC_SBR_DATA = -18, - ERR_AAC_SBR_PCM_FORMAT = -19, - ERR_AAC_SBR_NCHANS_TOO_HIGH = -20, - ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21, - - ERR_AAC_RAWBLOCK_PARAMS = -22, - - ERR_AAC_UNKNOWN = -9999 -}; - -typedef struct _AACFrameInfo { - int bitRate; - int nChans; - int sampRateCore; - int sampRateOut; - int bitsPerSample; - int outputSamps; - int profile; - int tnsUsed; - int pnsUsed; -} AACFrameInfo; - -typedef void *HAACDecoder; - -/* public C API */ -HAACDecoder AACInitDecoder(void); -HAACDecoder AACInitDecoderPre(void *ptr, int sz); -void AACFreeDecoder(HAACDecoder hAACDecoder); -int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf); - -int AACFindSyncWord(unsigned char *buf, int nBytes); -void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo); -int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo); -int AACFlushCodec(HAACDecoder hAACDecoder); - -#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT -int AACInitTrigtabsFloat(void); -void AACFreeTrigtabsFloat(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _AACDEC_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aactabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aactabs.c deleted file mode 100644 index 1efa20ca..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/aactabs.c +++ /dev/null @@ -1,157 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: aactabs.c,v 1.1 2005/02/26 01:47:31 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * aactabs.c - platform-independent tables for AAC decoder (global, read-only) - **************************************************************************************/ - -#include "aaccommon.h" - -/* sample rates (table 4.5.1) */ -const int sampRateTab[NUM_SAMPLE_RATES] PROGMEM = { - 96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000 -}; - -/* max scalefactor band for prediction (main profile only) */ -const int predSFBMax[NUM_SAMPLE_RATES] PROGMEM = { - 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34 -}; - -/* channel mapping (table 1.6.3.4) (-1 = unknown, so need to determine mapping based on rules in 8.5.1) */ -const int channelMapTab[NUM_DEF_CHAN_MAPS] PROGMEM = { - -1, 1, 2, 3, 4, 5, 6, 8 -}; - -/* number of channels in each element (SCE, CPE, etc.) - * see AACElementID in aaccommon.h - */ -const int elementNumChans[NUM_ELEMENTS] PROGMEM = { - 1, 2, 0, 1, 0, 0, 0, 0 -}; - -/* total number of scale factor bands in one window */ -const unsigned int /*char*/ sfBandTotalShort[NUM_SAMPLE_RATES] PROGMEM = { - 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15 -}; - -const unsigned int /*char*/ sfBandTotalLong[NUM_SAMPLE_RATES] PROGMEM = { - 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40 -}; - -/* scale factor band tables */ -const int sfBandTabShortOffset[NUM_SAMPLE_RATES] PROGMEM = {0, 0, 0, 13, 13, 13, 28, 28, 44, 44, 44, 60}; - -const /*short*/ int sfBandTabShort[76] PROGMEM = { - /* short block 64, 88, 96 kHz [13] (tables 4.5.24, 4.5.26) */ - 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128, - - /* short block 32, 44, 48 kHz [15] (table 4.5.15) */ - 0, 4, 8, 12, 16, 20, 28, 36, 44, 56, 68, 80, 96, 112, 128, - - /* short block 22, 24 kHz [16] (table 4.5.22) */ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 64, 76, 92, 108, 128, - - /* short block 11, 12, 16 kHz [16] (table 4.5.20) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 60, 72, 88, 108, 128, - - /* short block 8 kHz [16] (table 4.5.18) */ - 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 128 -}; - -const int sfBandTabLongOffset[NUM_SAMPLE_RATES] PROGMEM = {0, 0, 42, 90, 90, 140, 192, 192, 240, 240, 240, 284}; - -const /*short*/ int sfBandTabLong[325] PROGMEM = { - /* long block 88, 96 kHz [42] (table 4.5.25) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, - 56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 156, 172, 188, 212, - 240, 276, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, - - /* long block 64 kHz [48] (table 4.5.13) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 64, - 72, 80, 88, 100, 112, 124, 140, 156, 172, 192, 216, 240, 268, 304, 344, 384, - 424, 464, 504, 544, 584, 624, 664, 704, 744, 784, 824, 864, 904, 944, 984, 1024, - - /* long block 44, 48 kHz [50] (table 4.5.14) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 88, - 96, 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, 384, 416, 448, - 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 1024, - - /* long block 32 kHz [52] (table 4.5.16) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72, 80, 88, 96, - 108, 120, 132, 144, 160, 176, 196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, - 544, 576, 608, 640, 672, 704, 736, 768, 800, 832, 864, 896, 928, 960, 992, 1024, - - /* long block 22, 24 kHz [48] (table 4.5.21) */ - 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 52, 60, 68, 76, - 84, 92, 100, 108, 116, 124, 136, 148, 160, 172, 188, 204, 220, 240, 260, 284, - 308, 336, 364, 396, 432, 468, 508, 552, 600, 652, 704, 768, 832, 896, 960, 1024, - - /* long block 11, 12, 16 kHz [44] (table 4.5.19) */ - 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 100, 112, 124, - 136, 148, 160, 172, 184, 196, 212, 228, 244, 260, 280, 300, 320, 344, 368, - 396, 424, 456, 492, 532, 572, 616, 664, 716, 772, 832, 896, 960, 1024, - - /* long block 8 kHz [41] (table 4.5.17) */ - 0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, - 172, 188, 204, 220, 236, 252, 268, 288, 308, 328, 348, 372, 396, 420, - 448, 476, 508, 544, 580, 620, 664, 712, 764, 820, 880, 944, 1024 -}; - - -/* TNS max bands (table 4.139) and max order (table 4.138) */ -const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES] PROGMEM = {0, 0, 12}; - -const unsigned /*char*/ int tnsMaxBandsShort[2*NUM_SAMPLE_RATES] PROGMEM = { - 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, /* short block, Main/LC */ - 7, 7, 7, 6, 6, 6, 7, 7, 8, 8, 8, 7 /* short block, SSR */ -}; - -const unsigned /*char*/ int tnsMaxOrderShort[AAC_NUM_PROFILES] PROGMEM = {7, 7, 7}; - -const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES] PROGMEM = {0, 0, 12}; - -const unsigned int /*char*/ tnsMaxBandsLong[2*NUM_SAMPLE_RATES] PROGMEM = { - 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, /* long block, Main/LC */ - 28, 28, 27, 26, 26, 26, 29, 29, 23, 23, 23, 19, /* long block, SSR */ -}; - -const unsigned /*char*/ int tnsMaxOrderLong[AAC_NUM_PROFILES] PROGMEM = {20, 12, 12}; diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/assembly.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/assembly.h deleted file mode 100644 index 4a45236d..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/assembly.h +++ /dev/null @@ -1,728 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: assembly.h,v 1.7 2005/11/10 00:04:40 margotm Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * assembly.h - inline assembly language functions and prototypes - * - * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), - * returns top 32-bits of 64-bit result - * CLIPTOSHORT(x) convert 32-bit integer to 16-bit short, - * clipping to [-32768, 32767] - * FASTABS(x) branchless absolute value of signed integer x - * CLZ(x) count leading zeros on signed integer x - * MADD64(sum64, x, y) 64-bit multiply accumulate: sum64 += (x*y) - **************************************************************************************/ - -#ifndef _ASSEMBLY_H -#define _ASSEMBLY_H - -/* toolchain: MSFT Visual C++ - * target architecture: x86 - */ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) || (defined (__WINS__) && defined (_SYMBIAN)) || (defined (WINCE_EMULATOR)) || (defined (_OPENWAVE_SIMULATOR)) - -#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */ - -static __inline int MULSHIFT32(int x, int y) -{ - __asm { - mov eax, x - imul y - mov eax, edx - } -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -#ifdef __CW32__ -typedef long long Word64; -#else -typedef __int64 Word64; -#endif - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -/* returns 64-bit value in [edx:eax] */ -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ -#if (defined (_SYMBIAN_61_) || defined (_SYMBIAN_70_)) && defined (__WINS__) && !defined (__CW32__) -/* Workaround for the Symbian emulator because of non existing longlong.lib and - * hence __allmul not defined. */ - __asm { - mov eax, x - imul y - add dword ptr sum64, eax - adc dword ptr sum64 + 4, edx - } -#else - sum64 += (Word64)x * (Word64)y; -#endif - - return sum64; -} - -/* toolchain: MSFT Embedded Visual C++ - * target architecture: ARM v.4 and above (require 'M' type processor for 32x32->64 multiplier) - */ -#elif defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM) - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -/* implemented in asmfunc.s */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef __int64 Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* ARM WinCE = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -/* manual name mangling for just this platform (must match labels in .s file) */ -#define MULSHIFT32 raac_MULSHIFT32 -#define MADD64 raac_MADD64 - -int MULSHIFT32(int x, int y); -Word64 MADD64(Word64 sum64, int x, int y); - -#ifdef __cplusplus -} -#endif - -/* toolchain: ARM ADS or RealView - * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier) - */ -#elif defined (XXX__arm) && defined (__ARMCC_VERSION) - -static __inline int MULSHIFT32(int x, int y) -{ - /* rules for smull RdLo, RdHi, Rm, Rs: - * RdHi != Rm - * RdLo != Rm - * RdHi != RdLo - */ - int zlow; - __asm { - smull zlow,y,x,y - } - - return y; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; - -/* ARM code would look like this, but do NOT use inline asm in ADS for this, - because you can't safely use the status register flags intermixed with C code - - __asm { - mov numZeros, #1 - tst x, 0xffff0000 - addeq numZeros, numZeros, #16 - moveq x, x, lsl #16 - tst x, 0xff000000 - addeq numZeros, numZeros, #8 - moveq x, x, lsl #8 - tst x, 0xf0000000 - addeq numZeros, numZeros, #4 - moveq x, x, lsl #4 - tst x, 0xc0000000 - addeq numZeros, numZeros, #2 - moveq x, x, lsl #2 - sub numZeros, numZeros, x, lsr #31 - } -*/ -/* reference: - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } -*/ -} - -typedef __int64 Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* ARM ADS = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - U64 u; - u.w64 = sum64; - - __asm { - smlal u.r.lo32, u.r.hi32, x, y - } - - return u.w64; -} - -/* toolchain: ARM gcc - * target architecture: ARM v.4 and above (requires 'M' type processor for 32x32->64 multiplier) - */ -#elif defined(__GNUC__) && defined(XXXX__arm__) - -static inline int MULSHIFT32(int x, int y) -{ - int zlow; - asm ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y) : "cc"); - return y; -} -/* -static inline short CLIPTOSHORT(int x) -{ - int sign; - - // clip to [-32768, 32767] // - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} -*/ -static inline short CLIPTOSHORT(int x) -{ - asm ("ssat %0, #16, %1" : "=r" (x) : "r" (x)); - return x; -} - -/* From coder.h, ORIGINAL: -clip to [-2^n, 2^n-1], valid range of n = [1, 30] -//TODO (FB) Is there a better way ? -*/ -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} - -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } - - - -#define FASTABS(x) abs(x) //FB -#define CLZ(x) __builtin_clz(x) //FB - -//Reverse byte order (16 bit) //FB -static inline unsigned int REV16( unsigned int value) -{ - asm ("rev16 %0, %1" : "=r" (value) : "r" (value) ); - return(value); -} - -//Reverse byte order (32 bit) //FB -static inline unsigned int REV32( unsigned int value) -{ - asm ("rev %0, %1" : "=r" (value) : "r" (value) ); - return(value); -} - - -typedef long long Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static inline Word64 MADD64(Word64 sum64, int x, int y) -{ - U64 u; - u.w64 = sum64; - asm ("smlal %0,%1,%2,%3" : "+&r" (u.r.lo32), "+&r" (u.r.hi32) : "r" (x), "r" (y) : "cc"); - return u.w64; -} - -/* toolchain: x86 gcc - * target architecture: x86 - */ -#elif defined(__APPLE__) || defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) || (defined (_SOLARIS) && !defined (__GNUC__) && defined(_SOLARISX86)) - -typedef long long Word64; - -static __inline__ int MULSHIFT32(int x, int y) -{ - int z; - - z = (Word64)x * (Word64)y >> 32; - - return z; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} -#elif defined(__arm__) - -typedef long long Word64; - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - - -#if defined(ARM7DI) - -static __inline int MULSHIFT32(int x, int y) { - return x * y; -} - -#else - -static __inline int MULSHIFT32(int x, int y) -{ - /* important rules for smull RdLo, RdHi, Rm, Rs: - * RdHi and Rm can't be the same register - * RdLo and Rm can't be the same register - * RdHi and RdLo can't be the same register - * Note: Rs determines early termination (leading sign bits) so if you want to specify - * which operand is Rs, put it in the SECOND argument (y) - * For inline assembly, x and y are not assumed to be R0, R1 so it shouldn't matter - * which one is returned. (If this were a function call, returning y (R1) would - * require an extra "mov r0, r1") - */ - int zlow; - __asm__ volatile ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y)) ; - - return y; -} - -#endif - -static __inline int FASTABS(int x) -{ - int t=0; /*Really is not necessary to initialiaze only to avoid warning*/ - - __asm__ volatile ( - "eor %0,%2,%2, asr #31;" - "sub %0,%1,%2, asr #31;" - : "=&r" (t) - : "0" (t), "r" (x) - ); - - return t; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -#elif defined(ESP_PLATFORM) || defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) || (defined (_SOLARIS) && !defined (__GNUC__) && !defined (_SOLARISX86)) - -typedef long long Word64; - -static __inline__ int MULSHIFT32(int x, int y) -{ - int z; - - z = (Word64)x * (Word64)y >> 32; - - return z; -} - -static __inline short CLIPTOSHORT(int x) -{ - int sign; - - /* clip to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return 32; - - /* count leading zeros with binary search (function should be 17 ARM instructions total) */ - numZeros = 1; - if (!((unsigned int)x >> 16)) { numZeros += 16; x <<= 16; } - if (!((unsigned int)x >> 24)) { numZeros += 8; x <<= 8; } - if (!((unsigned int)x >> 28)) { numZeros += 4; x <<= 4; } - if (!((unsigned int)x >> 30)) { numZeros += 2; x <<= 2; } - - numZeros -= ((unsigned int)x >> 31); - - return numZeros; -} - -typedef union _U64 { - Word64 w64; - struct { -#ifdef __XTENSA__ - unsigned int lo32; - signed int hi32; -#else - /* PowerPC = big endian */ - signed int hi32; - unsigned int lo32; -#endif - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} - -/* From coder.h, ORIGINAL: -clip to [-2^n, 2^n-1], valid range of n = [1, 30] -//TODO (FB) Is there a better way ? -*/ -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} - -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } - - - -//#define FASTABS(x) abs(x) //FB -//#define CLZ(x) __builtin_clz(x) //FB - -#else - -#error Unsupported platform in assembly.h - -#endif /* platforms */ - -#ifndef CLIP_2N -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} -#endif - -#ifndef CLIP_2N_SHIFT -/* From coder.h, ORIGINAL: - do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) -*/ -//TODO (FB) Is there a better way ? -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } -#endif - -#endif /* _ASSEMBLY_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.c deleted file mode 100644 index 09cb3f65..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.c +++ /dev/null @@ -1,261 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: bitstream.c,v 1.2 2005/09/27 20:31:11 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * bitstream.c - bitstream parsing functions - **************************************************************************************/ - -#include "bitstream.h" - -/************************************************************************************** - * Function: SetBitstreamPointer - * - * Description: initialize bitstream reader - * - * Inputs: pointer to BitStreamInfo struct - * number of bytes in bitstream - * pointer to byte-aligned buffer of data to read from - * - * Outputs: initialized bitstream info struct - * - * Return: none - **************************************************************************************/ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf) -{ - /* init bitstream */ - bsi->bytePtr = buf; - bsi->iCache = 0; /* 4-byte unsigned int */ - bsi->cachedBits = 0; /* i.e. zero bits in cache */ - bsi->nBytes = nBytes; -} - -/************************************************************************************** - * Function: RefillBitstreamCache - * - * Description: read new data from bitstream buffer into 32-bit cache - * - * Inputs: pointer to initialized BitStreamInfo struct - * - * Outputs: updated bitstream info struct - * - * Return: none - * - * Notes: only call when iCache is completely drained (resets bitOffset to 0) - * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer) - * stores data as big-endian in cache, regardless of machine endian-ness - **************************************************************************************/ -//Optimized for REV16, REV32 (FB) -static __inline void RefillBitstreamCache(BitStreamInfo *bsi) -{ - int nBytes = bsi->nBytes; - if (nBytes >= 4) { - /* optimize for common case, independent of machine endian-ness */ - bsi->iCache = (*bsi->bytePtr++) << 24; - bsi->iCache |= (*bsi->bytePtr++) << 16; - bsi->iCache |= (*bsi->bytePtr++) << 8; - bsi->iCache |= (*bsi->bytePtr++); - - bsi->cachedBits = 32; - bsi->nBytes -= 4; - } else { - bsi->iCache = 0; - while (nBytes--) { - bsi->iCache |= (*bsi->bytePtr++); - bsi->iCache <<= 8; - } - bsi->iCache <<= ((3 - bsi->nBytes)*8); - bsi->cachedBits = 8*bsi->nBytes; - bsi->nBytes = 0; - } -} - -/************************************************************************************** - * Function: GetBits - * - * Description: get bits from bitstream, advance bitstream pointer - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to get from bitstream - * - * Outputs: updated bitstream info struct - * - * Return: the next nBits bits of data from bitstream buffer - * - * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f - * for speed, does not indicate error if you overrun bit buffer - * if nBits == 0, returns 0 - **************************************************************************************/ -unsigned int GetBits(BitStreamInfo *bsi, int nBits) -{ - unsigned int data, lowBits; - - nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */ - data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */ - data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */ - bsi->iCache <<= nBits; /* left-justify cache */ - bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */ - - /* if we cross an int boundary, refill the cache */ - if (bsi->cachedBits < 0) { - lowBits = -bsi->cachedBits; - RefillBitstreamCache(bsi); - data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */ - - bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */ - bsi->iCache <<= lowBits; /* left-justify cache */ - } - - return data; -} - -/************************************************************************************** - * Function: GetBitsNoAdvance - * - * Description: get bits from bitstream, do not advance bitstream pointer - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to get from bitstream - * - * Outputs: none (state of BitStreamInfo struct left unchanged) - * - * Return: the next nBits bits of data from bitstream buffer - * - * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f - * for speed, does not indicate error if you overrun bit buffer - * if nBits == 0, returns 0 - **************************************************************************************/ -unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits) -{ - unsigned char *buf; - unsigned int data, iCache; - signed int lowBits; - - nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */ - data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */ - data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */ - lowBits = nBits - bsi->cachedBits; /* how many bits do we have left to read */ - - /* if we cross an int boundary, read next bytes in buffer */ - if (lowBits > 0) { - iCache = 0; - buf = bsi->bytePtr; - while (lowBits > 0) { - iCache <<= 8; - if (buf < bsi->bytePtr + bsi->nBytes) - iCache |= (unsigned int)*buf++; - lowBits -= 8; - } - lowBits = -lowBits; - data |= iCache >> lowBits; - } - - return data; -} - -/************************************************************************************** - * Function: AdvanceBitstream - * - * Description: move bitstream pointer ahead - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to advance bitstream - * - * Outputs: updated bitstream info struct - * - * Return: none - * - * Notes: generally used following GetBitsNoAdvance(bsi, maxBits) - **************************************************************************************/ -void AdvanceBitstream(BitStreamInfo *bsi, int nBits) -{ - nBits &= 0x1f; - if (nBits > bsi->cachedBits) { - nBits -= bsi->cachedBits; - RefillBitstreamCache(bsi); - } - bsi->iCache <<= nBits; - bsi->cachedBits -= nBits; -} - -/************************************************************************************** - * Function: CalcBitsUsed - * - * Description: calculate how many bits have been read from bitstream - * - * Inputs: pointer to initialized BitStreamInfo struct - * pointer to start of bitstream buffer - * bit offset into first byte of startBuf (0-7) - * - * Outputs: none - * - * Return: number of bits read from bitstream, as offset from startBuf:startOffset - **************************************************************************************/ -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset) -{ - int bitsUsed; - - bitsUsed = (bsi->bytePtr - startBuf) * 8; - bitsUsed -= bsi->cachedBits; - bitsUsed -= startOffset; - - return bitsUsed; -} - -/************************************************************************************** - * Function: ByteAlignBitstream - * - * Description: bump bitstream pointer to start of next byte - * - * Inputs: pointer to initialized BitStreamInfo struct - * - * Outputs: byte-aligned bitstream BitStreamInfo struct - * - * Return: none - * - * Notes: if bitstream is already byte-aligned, do nothing - **************************************************************************************/ -void ByteAlignBitstream(BitStreamInfo *bsi) -{ - int offset; - - offset = bsi->cachedBits & 0x07; - AdvanceBitstream(bsi, offset); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.h deleted file mode 100644 index de68a989..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/bitstream.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: bitstream.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * bitstream.h - definitions of bitstream handling functions - **************************************************************************************/ - -#ifndef _BITSTREAM_H -#define _BITSTREAM_H - -#include "aaccommon.h" - -/* additional external symbols to name-mangle for static linking */ -#define SetBitstreamPointer STATNAME(SetBitstreamPointer) -#define GetBits STATNAME(GetBits) -#define GetBitsNoAdvance STATNAME(GetBitsNoAdvance) -#define AdvanceBitstream STATNAME(AdvanceBitstream) -#define CalcBitsUsed STATNAME(CalcBitsUsed) -#define ByteAlignBitstream STATNAME(ByteAlignBitstream) - -typedef struct _BitStreamInfo { - unsigned char *bytePtr; - unsigned int iCache; - int cachedBits; - int nBytes; -} BitStreamInfo; - -/* bitstream.c */ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf); -unsigned int GetBits(BitStreamInfo *bsi, int nBits); -unsigned int GetBitsNoAdvance(BitStreamInfo *bsi, int nBits); -void AdvanceBitstream(BitStreamInfo *bsi, int nBits); -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset); -void ByteAlignBitstream(BitStreamInfo *bsi); - -#endif /* _BITSTREAM_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/buffers.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/buffers.c deleted file mode 100644 index 9ed39119..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/buffers.c +++ /dev/null @@ -1,165 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: buffers.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * buffers.c - allocation and deallocation of internal AAC decoder buffers - **************************************************************************************/ - -#if defined(USE_DEFAULT_STDLIB) || defined(ESP_PLATFORM) -#include -#else -#include "hlxclib/stdlib.h" -#endif - -#include "coder.h" - -/************************************************************************************** - * Function: ClearBuffer - * - * Description: fill buffer with 0's - * - * Inputs: pointer to buffer - * number of bytes to fill with 0 - * - * Outputs: cleared buffer - * - * Return: none - * - * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes) - **************************************************************************************/ -#include - void ClearBuffer(void *buf, int nBytes) -{ -/* int i; - unsigned char *cbuf = (unsigned char *)buf; - - for (i = 0; i < nBytes; i++) - cbuf[i] = 0; - - return; - */ - memset(buf, 0, nBytes); -} - -/************************************************************************************** - * Function: AllocateBuffers - * - * Description: allocate all the memory needed for the AAC decoder - * - * Inputs: none - * - * Outputs: none - * - * Return: pointer to AACDecInfo structure, cleared to all 0's (except for - * pointer to platform-specific data structure) - * - * Notes: if one or more mallocs fail, function frees any buffers already - * allocated before returning - **************************************************************************************/ -AACDecInfo *AllocateBuffers(void) -{ - AACDecInfo *aacDecInfo; - - aacDecInfo = (AACDecInfo *)malloc(sizeof(AACDecInfo)); - if (!aacDecInfo) - return 0; - ClearBuffer(aacDecInfo, sizeof(AACDecInfo)); - - aacDecInfo->psInfoBase = malloc(sizeof(PSInfoBase)); - if (!aacDecInfo->psInfoBase) { - FreeBuffers(aacDecInfo); - return 0; - } - ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase)); - - return aacDecInfo; -} - -AACDecInfo *AllocateBuffersPre(void **ptr, int *sz) -{ - AACDecInfo *aacDecInfo; - - char *p = (char*)*ptr; - aacDecInfo = (AACDecInfo *)p; - p += (sizeof(AACDecInfo) +7 ) & ~7; - *sz -= (sizeof(AACDecInfo) +7 ) & ~7; - if (*sz < 0) - return 0; - ClearBuffer(aacDecInfo, sizeof(AACDecInfo)); - - aacDecInfo->psInfoBase = (PSInfoBase*)p; - p += (sizeof(PSInfoBase) + 7) & ~7; - *sz -= (sizeof(PSInfoBase) + 7) & ~7; - if (*sz <0) { - return 0; - } - ClearBuffer(aacDecInfo->psInfoBase, sizeof(PSInfoBase)); - - *ptr = p; - - return aacDecInfo; -} - -#ifndef SAFE_FREE -#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */ -#endif - -/************************************************************************************** - * Function: FreeBuffers - * - * Description: frees all the memory used by the AAC decoder - * - * Inputs: pointer to initialized AACDecInfo structure - * - * Outputs: none - * - * Return: none - * - * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE) - **************************************************************************************/ -void FreeBuffers(AACDecInfo *aacDecInfo) -{ - if (!aacDecInfo) - return; - - SAFE_FREE(aacDecInfo->psInfoBase); - SAFE_FREE(aacDecInfo); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/coder.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/coder.h deleted file mode 100644 index 9609e393..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/coder.h +++ /dev/null @@ -1,373 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: coder.h,v 1.2 2005/06/27 21:06:00 gwright Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * coder.h - definitions of platform-specific data structures, functions, and tables - **************************************************************************************/ - -#ifndef _CODER_H -#define _CODER_H - -#include "aaccommon.h" -#include "bitstream.h" - -#ifndef ASSERT -#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS)) -#define ASSERT(x) if (!(x)) __asm int 3; -#else -#define ASSERT(x) /* do nothing */ -#endif -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define NWINDOWS_LONG 1 -#define NWINDOWS_SHORT 8 - -#define DATA_BUF_SIZE 510 /* max count = 255 + 255 */ -#define FILL_BUF_SIZE 269 /* max count = 15 + 255 - 1*/ -#define ADIF_COPYID_SIZE 9 -#define MAX_COMMENT_BYTES 255 - -#define MAX_NUM_FCE 15 -#define MAX_NUM_SCE 15 -#define MAX_NUM_BCE 15 -#define MAX_NUM_LCE 3 -#define MAX_NUM_ADE 7 -#define MAX_NUM_CCE 15 - -#define CHAN_ELEM_IS_CPE(x) (((x) & 0x10) >> 4) /* bit 4 = SCE/CPE flag */ -#define CHAN_ELEM_GET_TAG(x) (((x) & 0x0f) >> 0) /* bits 3-0 = instance tag */ - -#define CHAN_ELEM_SET_CPE(x) (((x) & 0x01) << 4) /* bit 4 = SCE/CPE flag */ -#define CHAN_ELEM_SET_TAG(x) (((x) & 0x0f) << 0) /* bits 3-0 = instance tag */ - -#define MAX_HUFF_BITS 20 -#define HUFFTAB_SPEC_OFFSET 1 - -/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */ -/* -#define CLIP_2N_SHIFT(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ - } -*/ -/* clip to [-2^n, 2^n-1], valid range of n = [1, 30] */ -/* -#define CLIP_2N(val, n) { \ - if ((val) >> 31 != (val) >> (n)) \ - (val) = ((val) >> 31) ^ ((1 << (n)) - 1); \ - } -*/ - - -#define SF_DQ_OFFSET 15 -#define FBITS_OUT_DQ 20 -#define FBITS_OUT_DQ_OFF (FBITS_OUT_DQ - SF_DQ_OFFSET) /* number of fraction bits out of dequant, including 2^15 bias */ - -#define FBITS_IN_IMDCT FBITS_OUT_DQ_OFF /* number of fraction bits into IMDCT */ -#define GBITS_IN_DCT4 4 /* min guard bits in for DCT4 */ - -#define FBITS_LOST_DCT4 1 /* number of fraction bits lost (>> out) in DCT-IV */ -#define FBITS_LOST_WND 1 /* number of fraction bits lost (>> out) in synthesis window (neg = gain frac bits) */ -#define FBITS_LOST_IMDCT (FBITS_LOST_DCT4 + FBITS_LOST_WND) -#define FBITS_OUT_IMDCT (FBITS_IN_IMDCT - FBITS_LOST_IMDCT) - -#define NUM_IMDCT_SIZES 2 - -/* additional external symbols to name-mangle for static linking */ -#define DecodeProgramConfigElement STATNAME(DecodeProgramConfigElement) -#define DecodeHuffmanScalar STATNAME(DecodeHuffmanScalar) -#define DecodeSpectrumLong STATNAME(DecodeSpectrumLong) -#define DecodeSpectrumShort STATNAME(DecodeSpectrumShort) -#define DecodeICSInfo STATNAME(DecodeICSInfo) -#define DCT4 STATNAME(DCT4) -#define R4FFT STATNAME(R4FFT) - -#define DecWindowOverlapNoClip STATNAME(DecWindowOverlapNoClip) -#define DecWindowOverlapLongStartNoClip STATNAME(DecWindowOverlapLongStartNoClip) -#define DecWindowOverlapLongStopNoClip STATNAME(DecWindowOverlapLongStopNoClip) -#define DecWindowOverlapShortNoClip STATNAME(DecWindowOverlapShortNoClip) - -#define huffTabSpecInfo STATNAME(huffTabSpecInfo) -#define huffTabSpec STATNAME(huffTabSpec) -#define huffTabScaleFactInfo STATNAME(huffTabScaleFactInfo) -#define huffTabScaleFact STATNAME(huffTabScaleFact) -#define cos4sin4tab STATNAME(cos4sin4tab) -#define cos4sin4tabOffset STATNAME(cos4sin4tabOffset) -#define cos1sin1tab STATNAME(cos1sin1tab) -#define sinWindow STATNAME(sinWindow) -#define sinWindowOffset STATNAME(sinWindowOffset) -#define kbdWindow STATNAME(kbdWindow) -#define kbdWindowOffset STATNAME(kbdWindowOffset) -#define bitrevtab STATNAME(bitrevtab) -#define bitrevtabOffset STATNAME(bitrevtabOffset) -#define uniqueIDTab STATNAME(uniqueIDTab) -#define twidTabEven STATNAME(twidTabEven) -#define twidTabOdd STATNAME(twidTabOdd) - -typedef struct _HuffInfo { - int maxBits; /* number of bits in longest codeword */ - unsigned /*char*/ int count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */ - int offset; /* offset into symbol table */ -} HuffInfo; - -typedef struct _PulseInfo { - unsigned char pulseDataPresent; - unsigned char numPulse; - unsigned char startSFB; - unsigned char offset[MAX_PULSES]; - unsigned char amp[MAX_PULSES]; -} PulseInfo; - -typedef struct _TNSInfo { - unsigned char tnsDataPresent; - unsigned char numFilt[MAX_TNS_FILTERS]; /* max 1 filter each for 8 short windows, or 3 filters for 1 long window */ - unsigned char coefRes[MAX_TNS_FILTERS]; - unsigned char length[MAX_TNS_FILTERS]; - unsigned char order[MAX_TNS_FILTERS]; - unsigned char dir[MAX_TNS_FILTERS]; - signed char coef[MAX_TNS_COEFS]; /* max 3 filters * 20 coefs for 1 long window, or 1 filter * 7 coefs for each of 8 short windows */ -} TNSInfo; - -typedef struct _GainControlInfo { - unsigned char gainControlDataPresent; - unsigned char maxBand; - unsigned char adjNum[MAX_GAIN_BANDS][MAX_GAIN_WIN]; - unsigned char alevCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST]; - unsigned char alocCode[MAX_GAIN_BANDS][MAX_GAIN_WIN][MAX_GAIN_ADJUST]; -} GainControlInfo; - -typedef struct _ICSInfo { - unsigned char icsResBit; - unsigned char winSequence; - unsigned char winShape; - unsigned char maxSFB; - unsigned char sfGroup; - unsigned char predictorDataPresent; - unsigned char predictorReset; - unsigned char predictorResetGroupNum; - unsigned char predictionUsed[MAX_PRED_SFB]; - unsigned char numWinGroup; - unsigned char winGroupLen[MAX_WIN_GROUPS]; -} ICSInfo; - -typedef struct _ADTSHeader { - /* fixed */ - unsigned char id; /* MPEG bit - should be 1 */ - unsigned char layer; /* MPEG layer - should be 0 */ - unsigned char protectBit; /* 0 = CRC word follows, 1 = no CRC word */ - unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */ - unsigned char sampRateIdx; /* sample rate index range = [0, 11] */ - unsigned char privateBit; /* ignore */ - unsigned char channelConfig; /* 0 = implicit, >0 = use default table */ - unsigned char origCopy; /* 0 = copy, 1 = original */ - unsigned char home; /* ignore */ - - /* variable */ - unsigned char copyBit; /* 1 bit of the 72-bit copyright ID (transmitted as 1 bit per frame) */ - unsigned char copyStart; /* 1 = this bit starts the 72-bit ID, 0 = it does not */ - int frameLength; /* length of frame */ - int bufferFull; /* number of 32-bit words left in enc buffer, 0x7FF = VBR */ - unsigned char numRawDataBlocks; /* number of raw data blocks in frame */ - - /* CRC */ - int crcCheckWord; /* 16-bit CRC check word (present if protectBit == 0) */ -} ADTSHeader; - -typedef struct _ADIFHeader { - unsigned char copyBit; /* 0 = no copyright ID, 1 = 72-bit copyright ID follows immediately */ - unsigned char origCopy; /* 0 = copy, 1 = original */ - unsigned char home; /* ignore */ - unsigned char bsType; /* bitstream type: 0 = CBR, 1 = VBR */ - int bitRate; /* bitRate: CBR = bits/sec, VBR = peak bits/frame, 0 = unknown */ - unsigned char numPCE; /* number of program config elements (max = 16) */ - int bufferFull; /* bits left in bit reservoir */ - unsigned char copyID[ADIF_COPYID_SIZE]; /* optional 72-bit copyright ID */ -} ADIFHeader; - -/* sizeof(ProgConfigElement) = 82 bytes (if KEEP_PCE_COMMENTS not defined) */ -typedef struct _ProgConfigElement { - unsigned char elemInstTag; /* element instance tag */ - unsigned char profile; /* 0 = main, 1 = LC, 2 = SSR, 3 = reserved */ - unsigned char sampRateIdx; /* sample rate index range = [0, 11] */ - unsigned char numFCE; /* number of front channel elements (max = 15) */ - unsigned char numSCE; /* number of side channel elements (max = 15) */ - unsigned char numBCE; /* number of back channel elements (max = 15) */ - unsigned char numLCE; /* number of LFE channel elements (max = 3) */ - unsigned char numADE; /* number of associated data elements (max = 7) */ - unsigned char numCCE; /* number of valid channel coupling elements (max = 15) */ - unsigned char monoMixdown; /* mono mixdown: bit 4 = present flag, bits 3-0 = element number */ - unsigned char stereoMixdown; /* stereo mixdown: bit 4 = present flag, bits 3-0 = element number */ - unsigned char matrixMixdown; /* matrix mixdown: bit 4 = present flag, bit 3 = unused, - bits 2-1 = index, bit 0 = pseudo-surround enable */ - unsigned char fce[MAX_NUM_FCE]; /* front element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char sce[MAX_NUM_SCE]; /* side element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char bce[MAX_NUM_BCE]; /* back element channel pair: bit 4 = SCE/CPE flag, bits 3-0 = inst tag */ - unsigned char lce[MAX_NUM_LCE]; /* instance tag for LFE elements */ - unsigned char ade[MAX_NUM_ADE]; /* instance tag for ADE elements */ - unsigned char cce[MAX_NUM_BCE]; /* channel coupling elements: bit 4 = switching flag, bits 3-0 = inst tag */ - -#ifdef KEEP_PCE_COMMENTS - /* make this optional - if not enabled, decoder will just skip comments */ - unsigned char commentBytes; - unsigned char commentField[MAX_COMMENT_BYTES]; -#endif - -} ProgConfigElement; - -/* state info struct for baseline (MPEG-4 LC) decoding */ -typedef struct _PSInfoBase { - /* header information */ - ADTSHeader fhADTS; - ADIFHeader fhADIF; - ProgConfigElement pce[MAX_NUM_PCE_ADIF]; - int dataCount; - unsigned char dataBuf[DATA_BUF_SIZE]; - int fillCount; - unsigned char fillBuf[FILL_BUF_SIZE]; - - /* state information which is the same throughout whole frame */ - int nChans; - int useImpChanMap; - int sampRateIdx; - - /* state information which can be overwritten by subsequent elements within frame */ - ICSInfo icsInfo[MAX_NCHANS_ELEM]; - - int commonWin; - short scaleFactors[MAX_NCHANS_ELEM][MAX_SF_BANDS]; - unsigned char sfbCodeBook[MAX_NCHANS_ELEM][MAX_SF_BANDS]; - - int msMaskPresent; - unsigned char msMaskBits[MAX_MS_MASK_BYTES]; - - int pnsUsed[MAX_NCHANS_ELEM]; - int pnsLastVal; - int intensityUsed[MAX_NCHANS_ELEM]; - - PulseInfo pulseInfo[MAX_NCHANS_ELEM]; - - TNSInfo tnsInfo[MAX_NCHANS_ELEM]; - int tnsLPCBuf[MAX_TNS_ORDER]; - int tnsWorkBuf[MAX_TNS_ORDER]; - - GainControlInfo gainControlInfo[MAX_NCHANS_ELEM]; - - int gbCurrent[MAX_NCHANS_ELEM]; - int coef[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS]; -#ifdef AAC_ENABLE_SBR - int sbrWorkBuf[MAX_NCHANS_ELEM][AAC_MAX_NSAMPS]; -#endif - /* state information which must be saved for each element and used in next frame */ - int overlap[AAC_MAX_NCHANS][AAC_MAX_NSAMPS]; - int prevWinShape[AAC_MAX_NCHANS]; - -} PSInfoBase; - -/* private implementation-specific functions */ - -/* decelmnt.c */ -int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi); - -/* huffman.c */ -int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val); -void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch); -void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch); - -/* noiseless.c */ -void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx); - -/* dct4.c */ -void DCT4(int tabidx, int *coef, int gb); - -/* fft.c */ -void R4FFT(int tabidx, int *x); - -/* sbrimdct.c */ -void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); -void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev); - -/* hufftabs.c */ -extern const HuffInfo huffTabSpecInfo[11]; -extern const signed short huffTabSpec[1241]; -extern const HuffInfo huffTabScaleFactInfo; -extern const signed short huffTabScaleFact[121]; - -/* trigtabs.c */ -extern const int cos4sin4tabOffset[NUM_IMDCT_SIZES]; -extern const int sinWindowOffset[NUM_IMDCT_SIZES]; -extern const int kbdWindowOffset[NUM_IMDCT_SIZES]; -extern const unsigned char bitrevtab[17 + 129]; -extern const int bitrevtabOffset[NUM_IMDCT_SIZES]; - -#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT -/* trigtabs_fltgen.c */ -extern int cos4sin4tab[128 + 1024]; -extern int cos1sin1tab[514]; -extern int sinWindow[128 + 1024]; -extern int kbdWindow[128 + 1024]; -extern int twidTabEven[4*6 + 16*6 + 64*6]; -extern int twidTabOdd[8*6 + 32*6 + 128*6]; -#else -/* trigtabs.c */ -extern const int cos4sin4tab[128 + 1024]; -extern const int cos1sin1tab[514]; -extern const int sinWindow[128 + 1024]; -extern const int kbdWindow[128 + 1024]; -extern const int twidTabEven[4*6 + 16*6 + 64*6]; -extern const int twidTabOdd[8*6 + 32*6 + 128*6]; -#endif - -#endif /* _CODER_H */ - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dct4.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dct4.c deleted file mode 100644 index 698f54b6..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dct4.c +++ /dev/null @@ -1,337 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: dct4.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * dct4.c - optimized DCT-IV - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -static const int nmdctTab[NUM_IMDCT_SIZES] PROGMEM = {128, 1024}; -static const int postSkip[NUM_IMDCT_SIZES] PROGMEM = {15, 1}; - -/************************************************************************************** - * Function: PreMultiply - * - * Description: pre-twiddle stage of DCT4 - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 5 (short) or 8 (long) frac bits - * i.e. gains 2-7= -5 int bits (short) or 2-10 = -8 int bits (long) - * normalization by -1/N is rolled into tables here (see trigtabs.c) - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PreMultiply(int tabidx, int *zbuf1) -{ - int i, nmdct, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - zbuf2 = zbuf1 + nmdct - 1; - csptr = cos4sin4tab + cos4sin4tabOffset[tabidx]; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = nmdct >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0); - ai2 = *(zbuf1 + 1); - ai1 = *(zbuf2 + 0); - ar2 = *(zbuf2 - 1); - - /* gain 2 ints bit from MULSHIFT32 by Q30, but drop 7 or 10 int bits from table scaling of 1/M - * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */ - *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */ - *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */ - } -} - -/************************************************************************************** - * Function: PostMultiply - * - * Description: post-twiddle stage of DCT4 - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out - gains 2 int bits - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PostMultiply(int tabidx, int *fft1) -{ - int i, nmdct, ar1, ai1, ar2, ai2, skipFactor; - int t, cms2, cps2, sin2; - int *fft2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - csptr = cos1sin1tab; - skipFactor = postSkip[tabidx]; - fft2 = fft1 + nmdct - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) - */ - cps2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - cms2 = cps2 - 2*sin2; - - for (i = nmdct >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ar2 = *(fft2 - 1); - ai2 = *(fft2 + 0); - - /* gain 2 ints bit from MULSHIFT32 by Q30 - * max per-sample gain = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2, ar1 + ai1); - *fft2-- = t - MULSHIFT32(cps2, ai1); /* sin*ar1 - cos*ai1 */ - *fft1++ = t + MULSHIFT32(cms2, ar1); /* cos*ar1 + sin*ai1 */ - cps2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - *fft2-- = t - MULSHIFT32(cps2, ai2); /* sin*ar1 - cos*ai1 */ - cms2 = cps2 - 2*sin2; - *fft1++ = t + MULSHIFT32(cms2, ar2); /* cos*ar1 + sin*ai1 */ - } -} - -/************************************************************************************** - * Function: PreMultiplyRescale - * - * Description: pre-twiddle stage of DCT4, with rescaling for extra guard bits - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits to add to input before processing - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: see notes on PreMultiply(), above - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void PreMultiplyRescale(int tabidx, int *zbuf1, int es) -{ - int i, nmdct, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - zbuf2 = zbuf1 + nmdct - 1; - csptr = cos4sin4tab + cos4sin4tabOffset[tabidx]; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = nmdct >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0) >> es; - ai1 = *(zbuf2 + 0) >> es; - ai2 = *(zbuf1 + 1) >> es; - - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; - *zbuf1++ = z2; - - ar2 = *(zbuf2 - 1) >> es; /* do here to free up register used for es */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; - *zbuf2-- = z1; - - } -} - -/************************************************************************************** - * Function: PostMultiplyRescale - * - * Description: post-twiddle stage of DCT4, with rescaling for extra guard bits - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits to remove from output - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: clips output to [-2^30, 2^30 - 1], guaranteeing at least 1 guard bit - * see notes on PostMultiply(), above - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void PostMultiplyRescale(int tabidx, int *fft1, int es) -{ - int i, nmdct, ar1, ai1, ar2, ai2, skipFactor, z; - int t, cs2, sin2; - int *fft2; - const int *csptr; - - nmdct = nmdctTab[tabidx]; - csptr = cos1sin1tab; - skipFactor = postSkip[tabidx]; - fft2 = fft1 + nmdct - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) - */ - cs2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - for (i = nmdct >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ai2 = *(fft2 + 0); - - t = MULSHIFT32(sin2, ar1 + ai1); - z = t - MULSHIFT32(cs2, ai1); - CLIP_2N_SHIFT(z, es); - *fft2-- = z; - cs2 -= 2*sin2; - z = t + MULSHIFT32(cs2, ar1); - CLIP_2N_SHIFT(z, es); - *fft1++ = z; - - cs2 = *csptr++; - sin2 = *csptr; - csptr += skipFactor; - - ar2 = *fft2; - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - z = t - MULSHIFT32(cs2, ai2); - CLIP_2N_SHIFT(z, es); - *fft2-- = z; - cs2 -= 2*sin2; - z = t + MULSHIFT32(cs2, ar2); - CLIP_2N_SHIFT(z, es); - *fft1++ = z; - cs2 += 2*sin2; - } -} - -/************************************************************************************** - * Function: DCT4 - * - * Description: type-IV DCT - * - * Inputs: table index (for transform size) - * buffer of nmdct samples - * number of guard bits in the input buffer - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: operates in-place - * if number of guard bits in input is < GBITS_IN_DCT4, the input is - * scaled (>>) before the DCT4 and rescaled (<<, with clipping) after - * the DCT4 (rare) - * the output has FBITS_LOST_DCT4 fewer fraction bits than the input - * the output will always have at least 1 guard bit (GBITS_IN_DCT4 >= 4) - * int bits gained per stage (PreMul + FFT + PostMul) - * short blocks = (-5 + 4 + 2) = 1 total - * long blocks = (-8 + 7 + 2) = 1 total - **************************************************************************************/ -void DCT4(int tabidx, int *coef, int gb) -{ - int es; - - /* fast in-place DCT-IV - adds guard bits if necessary */ - if (gb < GBITS_IN_DCT4) { - es = GBITS_IN_DCT4 - gb; - PreMultiplyRescale(tabidx, coef, es); - R4FFT(tabidx, coef); - PostMultiplyRescale(tabidx, coef, es); - } else { - PreMultiply(tabidx, coef); - R4FFT(tabidx, coef); - PostMultiply(tabidx, coef); - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/decelmnt.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/decelmnt.c deleted file mode 100644 index 8c319121..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/decelmnt.c +++ /dev/null @@ -1,425 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: decelmnt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * decelmnt.c - syntactic element decoding - **************************************************************************************/ - -#include "coder.h" - -/************************************************************************************** - * Function: DecodeSingleChannelElement - * - * Description: decode one SCE - * - * Inputs: BitStreamInfo struct pointing to start of SCE (14496-3, table 4.4.4) - * - * Outputs: updated element instance tag - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeSingleChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - return 0; -} - -/************************************************************************************** - * Function: DecodeChannelPairElement - * - * Description: decode one CPE - * - * Inputs: BitStreamInfo struct pointing to start of CPE (14496-3, table 4.4.5) - * - * Outputs: updated element instance tag - * updated commonWin - * updated ICS info, if commonWin == 1 - * updated mid-side stereo info, if commonWin == 1 - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeChannelPairElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - int sfb, gp, maskOffset; - unsigned char currBit, *maskPtr; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = psi->icsInfo; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - /* read common window flag and mid-side info (if present) - * store msMask bits in psi->msMaskBits[] as follows: - * long blocks - pack bits for each SFB in range [0, maxSFB) starting with lsb of msMaskBits[0] - * short blocks - pack bits for each SFB in range [0, maxSFB), for each group [0, 7] - * msMaskPresent = 0 means no M/S coding - * = 1 means psi->msMaskBits contains 1 bit per SFB to toggle M/S coding - * = 2 means all SFB's are M/S coded (so psi->msMaskBits is not needed) - */ - psi->commonWin = GetBits(bsi, 1); - if (psi->commonWin) { - DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx); - psi->msMaskPresent = GetBits(bsi, 2); - if (psi->msMaskPresent == 1) { - maskPtr = psi->msMaskBits; - *maskPtr = 0; - maskOffset = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - currBit = (unsigned char)GetBits(bsi, 1); - *maskPtr |= currBit << maskOffset; - if (++maskOffset == 8) { - maskPtr++; - *maskPtr = 0; - maskOffset = 0; - } - } - } - } - } - - return 0; -} - -/************************************************************************************** - * Function: DecodeLFEChannelElement - * - * Description: decode one LFE - * - * Inputs: BitStreamInfo struct pointing to start of LFE (14496-3, table 4.4.9) - * - * Outputs: updated element instance tag - * - * Return: 0 if successful, -1 if error - * - * Notes: doesn't decode individual channel stream (part of DecodeNoiselessData) - **************************************************************************************/ -static int DecodeLFEChannelElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - - /* read instance tag */ - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - - return 0; -} - -/************************************************************************************** - * Function: DecodeDataStreamElement - * - * Description: decode one DSE - * - * Inputs: BitStreamInfo struct pointing to start of DSE (14496-3, table 4.4.10) - * - * Outputs: updated element instance tag - * filled in data stream buffer - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -static int DecodeDataStreamElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - unsigned int byteAlign, dataCount; - unsigned char *dataBuf; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - aacDecInfo->currInstTag = GetBits(bsi, NUM_INST_TAG_BITS); - byteAlign = GetBits(bsi, 1); - dataCount = GetBits(bsi, 8); - if (dataCount == 255) - dataCount += GetBits(bsi, 8); - - if (byteAlign) - ByteAlignBitstream(bsi); - - psi->dataCount = dataCount; - dataBuf = psi->dataBuf; - while (dataCount--) - *dataBuf++ = GetBits(bsi, 8); - - return 0; -} - -/************************************************************************************** - * Function: DecodeProgramConfigElement - * - * Description: decode one PCE - * - * Inputs: BitStreamInfo struct pointing to start of PCE (14496-3, table 4.4.2) - * - * Outputs: filled-in ProgConfigElement struct - * updated BitStreamInfo struct - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: #define KEEP_PCE_COMMENTS to save the comment field of the PCE - * (otherwise we just skip it in the bitstream, to save memory) - **************************************************************************************/ -int DecodeProgramConfigElement(ProgConfigElement *pce, BitStreamInfo *bsi) -{ - int i; - - pce->elemInstTag = GetBits(bsi, 4); - pce->profile = GetBits(bsi, 2); - pce->sampRateIdx = GetBits(bsi, 4); - pce->numFCE = GetBits(bsi, 4); - pce->numSCE = GetBits(bsi, 4); - pce->numBCE = GetBits(bsi, 4); - pce->numLCE = GetBits(bsi, 2); - pce->numADE = GetBits(bsi, 3); - pce->numCCE = GetBits(bsi, 4); - - pce->monoMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->monoMixdown) - pce->monoMixdown |= GetBits(bsi, 4); /* element number */ - - pce->stereoMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->stereoMixdown) - pce->stereoMixdown |= GetBits(bsi, 4); /* element number */ - - pce->matrixMixdown = GetBits(bsi, 1) << 4; /* present flag */ - if (pce->matrixMixdown) { - pce->matrixMixdown |= GetBits(bsi, 2) << 1; /* index */ - pce->matrixMixdown |= GetBits(bsi, 1); /* pseudo-surround enable */ - } - - for (i = 0; i < pce->numFCE; i++) { - pce->fce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->fce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numSCE; i++) { - pce->sce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->sce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numBCE; i++) { - pce->bce[i] = GetBits(bsi, 1) << 4; /* is_cpe flag */ - pce->bce[i] |= GetBits(bsi, 4); /* tag select */ - } - - for (i = 0; i < pce->numLCE; i++) - pce->lce[i] = GetBits(bsi, 4); /* tag select */ - - for (i = 0; i < pce->numADE; i++) - pce->ade[i] = GetBits(bsi, 4); /* tag select */ - - for (i = 0; i < pce->numCCE; i++) { - pce->cce[i] = GetBits(bsi, 1) << 4; /* independent/dependent flag */ - pce->cce[i] |= GetBits(bsi, 4); /* tag select */ - } - - - ByteAlignBitstream(bsi); - -#ifdef KEEP_PCE_COMMENTS - pce->commentBytes = GetBits(bsi, 8); - for (i = 0; i < pce->commentBytes; i++) - pce->commentField[i] = GetBits(bsi, 8); -#else - /* eat comment bytes and throw away */ - i = GetBits(bsi, 8); - while (i--) - GetBits(bsi, 8); -#endif - - return 0; -} - -/************************************************************************************** - * Function: DecodeFillElement - * - * Description: decode one fill element - * - * Inputs: BitStreamInfo struct pointing to start of fill element - * (14496-3, table 4.4.11) - * - * Outputs: updated element instance tag - * unpacked extension payload - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -static int DecodeFillElement(AACDecInfo *aacDecInfo, BitStreamInfo *bsi) -{ - unsigned int fillCount; - unsigned char *fillBuf; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - fillCount = GetBits(bsi, 4); - if (fillCount == 15) - fillCount += (GetBits(bsi, 8) - 1); - - psi->fillCount = fillCount; - fillBuf = psi->fillBuf; - while (fillCount--) - *fillBuf++ = GetBits(bsi, 8); - - aacDecInfo->currInstTag = -1; /* fill elements don't have instance tag */ - aacDecInfo->fillExtType = 0; - -#ifdef AAC_ENABLE_SBR - /* check for SBR - * aacDecInfo->sbrEnabled is sticky (reset each raw_data_block), so for multichannel - * need to verify that all SCE/CPE/ICCE have valid SBR fill element following, and - * must upsample by 2 for LFE - */ - if (psi->fillCount > 0) { - aacDecInfo->fillExtType = (int)((psi->fillBuf[0] >> 4) & 0x0f); - if (aacDecInfo->fillExtType == EXT_SBR_DATA || aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) - aacDecInfo->sbrEnabled = 1; - } -#endif - - aacDecInfo->fillBuf = psi->fillBuf; - aacDecInfo->fillCount = psi->fillCount; - - return 0; -} - -/************************************************************************************** - * Function: DecodeNextElement - * - * Description: decode next syntactic element in AAC frame - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer containing next element - * pointer to bit offset - * pointer to number of valid bits remaining in buf - * - * Outputs: type of element decoded (aacDecInfo->currBlockID) - * type of element decoded last time (aacDecInfo->prevBlockID) - * updated aacDecInfo state, depending on which element was decoded - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int err, bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* read element ID (save last ID for SBR purposes) */ - aacDecInfo->prevBlockID = aacDecInfo->currBlockID; - aacDecInfo->currBlockID = GetBits(&bsi, NUM_SYN_ID_BITS); - - /* set defaults (could be overwritten by DecodeXXXElement(), depending on currBlockID) */ - psi->commonWin = 0; - - err = 0; - switch (aacDecInfo->currBlockID) { - case AAC_ID_SCE: - err = DecodeSingleChannelElement(aacDecInfo, &bsi); - break; - case AAC_ID_CPE: - err = DecodeChannelPairElement(aacDecInfo, &bsi); - break; - case AAC_ID_CCE: - /* TODO - implement CCE decoding */ - break; - case AAC_ID_LFE: - err = DecodeLFEChannelElement(aacDecInfo, &bsi); - break; - case AAC_ID_DSE: - err = DecodeDataStreamElement(aacDecInfo, &bsi); - break; - case AAC_ID_PCE: - err = DecodeProgramConfigElement(psi->pce + 0, &bsi); - break; - case AAC_ID_FIL: - err = DecodeFillElement(aacDecInfo, &bsi); - break; - case AAC_ID_END: - break; - } - if (err) - return ERR_AAC_SYNTAX_ELEMENT; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed; - - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dequant.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dequant.c deleted file mode 100644 index 5f511664..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/dequant.c +++ /dev/null @@ -1,373 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: dequant.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * dequant.c - transform coefficient dequantization and short-block deinterleaving - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define SF_OFFSET 100 - -/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */ -static const int pow14[4] PROGMEM = { - 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 -}; - -/* pow(2, i/4.0) * pow(j, 4.0/3.0) for i = [0,1,2,3], j = [0,1,2,...,15] - * format = Q28 for j = [0-3], Q25 for j = [4-15] - */ -static const int pow43_14[4][16] PROGMEM = { - { - 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */ - 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, /* Q25 */ - 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, /* Q25 */ - 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, /* Q25 */ - }, - { - 0x00000000, 0x1306fe0a, 0x2ff221af, 0x52538f52, - 0x0f1a1bf4, 0x1455ccc2, 0x19ee62a8, 0x1fd92396, - 0x260dfc14, 0x2c8694d8, 0x333dcb29, 0x3a2f5c7a, - 0x4157aed5, 0x48b3aaa3, 0x50409f76, 0x57fc3010, - }, - { - 0x00000000, 0x16a09e66, 0x39047c0f, 0x61e734aa, - 0x11f59ac4, 0x182ec633, 0x1ed66a45, 0x25dfc55a, - 0x2d413ccd, 0x34f3462d, 0x3cefc603, 0x4531ab69, - 0x4db4adf8, 0x56752054, 0x5f6fcfcd, 0x68a1eca1, - }, - { - 0x00000000, 0x1ae89f99, 0x43ce3e4b, 0x746d57b2, - 0x155b8109, 0x1cc21cdc, 0x24ac1839, 0x2d0a479e, - 0x35d13f33, 0x3ef80748, 0x48775c93, 0x524938cd, - 0x5c68841d, 0x66d0df0a, 0x717e7bfe, 0x7c6e0305, - }, -}; - -/* pow(j, 4.0 / 3.0) for j = [16,17,18,...,63], format = Q23 */ -static const int pow43[48] PROGMEM = { - 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85, - 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a, - 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000, - 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99, - 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088, - 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72, - 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3, - 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c, - 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129, - 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b, - 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0, - 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09, -}; - -/* sqrt(0.5), format = Q31 */ -#define SQRTHALF 0x5a82799a - -/* Minimax polynomial approximation to pow(x, 4/3), over the range - * poly43lo: x = [0.5, 0.7071] - * poly43hi: x = [0.7071, 1.0] - * - * Relative error < 1E-7 - * Coefs are scaled by 4, 2, 1, 0.5, 0.25 - */ - -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" -static const int poly43lo[5] PROGMEM = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 }; -static const int poly43hi[5] PROGMEM = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 }; -#pragma GCC diagnostic pop - -/* pow2exp[i] = pow(2, i*4/3) exponent */ -static const int pow2exp[8] PROGMEM = { 14, 13, 11, 10, 9, 7, 6, 5 }; - -/* pow2exp[i] = pow(2, i*4/3) fraction */ -static const int pow2frac[8] PROGMEM = { - 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94, - 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6 -}; - -/************************************************************************************** - * Function: DequantBlock - * - * Description: dequantize one block of transform coefficients (in-place) - * - * Inputs: quantized transform coefficients, range = [0, 8191] - * number of samples to dequantize - * scalefactor for this block of data, range = [0, 256] - * - * Outputs: dequantized transform coefficients in Q(FBITS_OUT_DQ_OFF) - * - * Return: guard bit mask (OR of abs value of all dequantized coefs) - * - * Notes: applies dequant formula y = pow(x, 4.0/3.0) * pow(2, (scale - 100)/4.0) - * * pow(2, FBITS_OUT_DQ_OFF) - * clips outputs to Q(FBITS_OUT_DQ_OFF) - * output has no minimum number of guard bits - **************************************************************************************/ -static int DequantBlock(int *inbuf, int nSamps, int scale) -{ - int iSamp, scalef, scalei, x, y, gbMask, shift, tab4[4]; - const int *tab16, *coef; - - if (nSamps <= 0) - return 0; - - scale -= SF_OFFSET; /* new range = [-100, 156] */ - - /* with two's complement numbers, scalei/scalef factorization works for pos and neg values of scale: - * [+4...+7] >> 2 = +1, [ 0...+3] >> 2 = 0, [-4...-1] >> 2 = -1, [-8...-5] >> 2 = -2 ... - * (-1 & 0x3) = 3, (-2 & 0x3) = 2, (-3 & 0x3) = 1, (0 & 0x3) = 0 - * - * Example: 2^(-5/4) = 2^(-1) * 2^(-1/4) = 2^-2 * 2^(3/4) - */ - tab16 = pow43_14[scale & 0x3]; - scalef = pow14[scale & 0x3]; - scalei = (scale >> 2) + FBITS_OUT_DQ_OFF; - - /* cache first 4 values: - * tab16[j] = Q28 for j = [0,3] - * tab4[x] = x^(4.0/3.0) * 2^(0.25*scale), Q(FBITS_OUT_DQ_OFF) - */ - shift = 28 - scalei; - if (shift > 31) { - tab4[0] = tab4[1] = tab4[2] = tab4[3] = 0; - } else if (shift <= 0) { - shift = -shift; - if (shift > 31) - shift = 31; - for (x = 0; x < 4; x++) { - y = tab16[x]; - if (y > (0x7fffffff >> shift)) - y = 0x7fffffff; /* clip (rare) */ - else - y <<= shift; - tab4[x] = y; - } - } else { - tab4[0] = 0; - tab4[1] = tab16[1] >> shift; - tab4[2] = tab16[2] >> shift; - tab4[3] = tab16[3] >> shift; - } - - gbMask = 0; - do { - iSamp = *inbuf; - x = FASTABS(iSamp); - - if (x < 4) { - y = tab4[x]; - } else { - - if (x < 16) { - /* result: y = Q25 (tab16 = Q25) */ - y = tab16[x]; - shift = 25 - scalei; - } else if (x < 64) { - /* result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) */ - y = pow43[x-16]; - shift = 21 - scalei; - y = MULSHIFT32(y, scalef); - } else { - /* normalize to [0x40000000, 0x7fffffff] - * input x = [64, 8191] = [64, 2^13-1] - * ranges: - * shift = 7: 64 - 127 - * shift = 6: 128 - 255 - * shift = 5: 256 - 511 - * shift = 4: 512 - 1023 - * shift = 3: 1024 - 2047 - * shift = 2: 2048 - 4095 - * shift = 1: 4096 - 8191 - */ - x <<= 17; - shift = 0; - if (x < 0x08000000) - x <<= 4, shift += 4; - if (x < 0x20000000) - x <<= 2, shift += 2; - if (x < 0x40000000) - x <<= 1, shift += 1; - - coef = (x < SQRTHALF) ? poly43lo : poly43hi; - - /* polynomial */ - y = coef[0]; - y = MULSHIFT32(y, x) + coef[1]; - y = MULSHIFT32(y, x) + coef[2]; - y = MULSHIFT32(y, x) + coef[3]; - y = MULSHIFT32(y, x) + coef[4]; - y = MULSHIFT32(y, pow2frac[shift]) << 3; - - /* fractional scale - * result: y = Q21 (pow43tab[j] = Q23, scalef = Q30) - */ - y = MULSHIFT32(y, scalef); /* now y is Q24 */ - shift = 24 - scalei - pow2exp[shift]; - } - - /* integer scale */ - if (shift <= 0) { - shift = -shift; - if (shift > 31) - shift = 31; - - if (y > (0x7fffffff >> shift)) - y = 0x7fffffff; /* clip (rare) */ - else - y <<= shift; - } else { - if (shift > 31) - shift = 31; - y >>= shift; - } - } - - /* sign and store (gbMask used to count GB's) */ - gbMask |= y; - - /* apply sign */ - iSamp >>= 31; - y ^= iSamp; - y -= iSamp; - - *inbuf++ = y; - } while (--nSamps); - - return gbMask; -} - -/************************************************************************************** - * Function: Dequantize - * - * Description: dequantize all transform coefficients for one channel - * - * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients) - * index of current channel - * - * Outputs: dequantized coefficients, including short-block deinterleaving - * flags indicating if intensity and/or PNS is active - * minimum guard bit count for dequantized coefficients - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int Dequantize(AACDecInfo *aacDecInfo, int ch) -{ - int gp, cb, sfb, win, width, nSamps, gbMask; - int *coef; - const int /*short*/ *sfbTab; - unsigned char *sfbCodeBook; - short *scaleFactors; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coef = psi->coef[ch]; - sfbCodeBook = psi->sfbCodeBook[ch]; - scaleFactors = psi->scaleFactors[ch]; - - psi->intensityUsed[ch] = 0; - psi->pnsUsed[ch] = 0; - gbMask = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - /* dequantize one scalefactor band (not necessary if codebook is intensity or PNS) - * for zero codebook, still run dequantizer in case non-zero pulse data was added - */ - cb = (int)(sfbCodeBook[sfb]); - width = sfbTab[sfb+1] - sfbTab[sfb]; - if (cb >= 0 && cb <= 11) - gbMask |= DequantBlock(coef, width, scaleFactors[sfb]); - else if (cb == 13) - psi->pnsUsed[ch] = 1; - else if (cb == 14 || cb == 15) - psi->intensityUsed[ch] = 1; /* should only happen if ch == 1 */ - coef += width; - } - coef += (nSamps - sfbTab[icsInfo->maxSFB]); - } - sfbCodeBook += icsInfo->maxSFB; - scaleFactors += icsInfo->maxSFB; - } - aacDecInfo->pnsUsed |= psi->pnsUsed[ch]; /* set flag if PNS used for any channel */ - - /* calculate number of guard bits in dequantized data */ - psi->gbCurrent[ch] = CLZ(gbMask) - 1; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: DeinterleaveShortBlocks - * - * Description: deinterleave transform coefficients in short blocks for one channel - * - * Inputs: valid AACDecInfo struct (including unpacked, quantized coefficients) - * index of current channel - * - * Outputs: deinterleaved coefficients (window groups into 8 separate windows) - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: only necessary if deinterleaving not part of Huffman decoding - **************************************************************************************/ -int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch) -{ - (void)aacDecInfo; - (void)ch; - /* not used for this implementation - short block deinterleaving performed during Huffman decoding */ - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/fft.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/fft.c deleted file mode 100644 index 0fc934ca..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/fft.c +++ /dev/null @@ -1,393 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: fft.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * fft.c - Ken's optimized radix-4 DIT FFT, optional radix-8 first pass for odd log2(N) - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define NUM_FFT_SIZES 2 -static const int nfftTab[NUM_FFT_SIZES] PROGMEM ={64, 512}; -static const int nfftlog2Tab[NUM_FFT_SIZES] PROGMEM = {6, 9}; - -#define SQRT1_2 0x5a82799a /* sqrt(1/2) in Q31 */ - -#define swapcplx(p0,p1) \ - t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1 - -/************************************************************************************** - * Function: BitReverse - * - * Description: Ken's fast in-place bit reverse, using super-small table - * - * Inputs: buffer of samples - * table index (for transform size) - * - * Outputs: bit-reversed samples in same buffer - * - * Return: none - **************************************************************************************/ - /*__attribute__ ((section (".data"))) */ static void BitReverse(int *inout, int tabidx) -{ - int *part0, *part1; - int a,b, t,t1; - const unsigned char* tab = bitrevtab + bitrevtabOffset[tabidx]; - int nbits = nfftlog2Tab[tabidx]; - - part0 = inout; - part1 = inout + (1 << nbits); - - while ((a = pgm_read_byte(tab++)) != 0) { - b = pgm_read_byte(tab++); - - swapcplx(part0[4*a+0], part0[4*b+0]); /* 0xxx0 <-> 0yyy0 */ - swapcplx(part0[4*a+2], part1[4*b+0]); /* 0xxx1 <-> 1yyy0 */ - swapcplx(part1[4*a+0], part0[4*b+2]); /* 1xxx0 <-> 0yyy1 */ - swapcplx(part1[4*a+2], part1[4*b+2]); /* 1xxx1 <-> 1yyy1 */ - } - - do { - swapcplx(part0[4*a+2], part1[4*a+0]); /* 0xxx1 <-> 1xxx0 */ - } while ((a = pgm_read_byte(tab++)) != 0); - - -} - -/************************************************************************************** - * Function: R4FirstPass - * - * Description: radix-4 trivial pass for decimation-in-time FFT - * - * Inputs: buffer of (bit-reversed) samples - * number of R4 butterflies per group (i.e. nfft / 4) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 2 guard bits, gains no integer bits, - * guard bits out = guard bits in - 2 - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R4FirstPass(int *x, int bg) -{ - int ar, ai, br, bi, cr, ci, dr, di; - - for (; bg != 0; bg--) { - - ar = x[0] + x[2]; - br = x[0] - x[2]; - ai = x[1] + x[3]; - bi = x[1] - x[3]; - cr = x[4] + x[6]; - dr = x[4] - x[6]; - ci = x[5] + x[7]; - di = x[5] - x[7]; - - /* max per-sample gain = 4.0 (adding 4 inputs together) */ - x[0] = ar + cr; - x[4] = ar - cr; - x[1] = ai + ci; - x[5] = ai - ci; - x[2] = br + di; - x[6] = br - di; - x[3] = bi - dr; - x[7] = bi + dr; - - x += 8; - } -} - -/************************************************************************************** - * Function: R8FirstPass - * - * Description: radix-8 trivial pass for decimation-in-time FFT - * - * Inputs: buffer of (bit-reversed) samples - * number of R8 butterflies per group (i.e. nfft / 8) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits, gains 1 integer bit - * guard bits out = guard bits in - 3 (if inputs are full scale) - * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2) - * see scaling comments in code - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R8FirstPass(int *x, int bg) -{ - int ar, ai, br, bi, cr, ci, dr, di; - int sr, si, tr, ti, ur, ui, vr, vi; - int wr, wi, xr, xi, yr, yi, zr, zi; - - for (; bg != 0; bg--) { - - ar = x[0] + x[2]; - br = x[0] - x[2]; - ai = x[1] + x[3]; - bi = x[1] - x[3]; - cr = x[4] + x[6]; - dr = x[4] - x[6]; - ci = x[5] + x[7]; - di = x[5] - x[7]; - - sr = ar + cr; - ur = ar - cr; - si = ai + ci; - ui = ai - ci; - tr = br - di; - vr = br + di; - ti = bi + dr; - vi = bi - dr; - - ar = x[ 8] + x[10]; - br = x[ 8] - x[10]; - ai = x[ 9] + x[11]; - bi = x[ 9] - x[11]; - cr = x[12] + x[14]; - dr = x[12] - x[14]; - ci = x[13] + x[15]; - di = x[13] - x[15]; - - /* max gain of wr/wi/yr/yi vs input = 2 - * (sum of 4 samples >> 1) - */ - wr = (ar + cr) >> 1; - yr = (ar - cr) >> 1; - wi = (ai + ci) >> 1; - yi = (ai - ci) >> 1; - - /* max gain of output vs input = 4 - * (sum of 4 samples >> 1 + sum of 4 samples >> 1) - */ - x[ 0] = (sr >> 1) + wr; - x[ 8] = (sr >> 1) - wr; - x[ 1] = (si >> 1) + wi; - x[ 9] = (si >> 1) - wi; - x[ 4] = (ur >> 1) + yi; - x[12] = (ur >> 1) - yi; - x[ 5] = (ui >> 1) - yr; - x[13] = (ui >> 1) + yr; - - ar = br - di; - cr = br + di; - ai = bi + dr; - ci = bi - dr; - - /* max gain of xr/xi/zr/zi vs input = 4*sqrt(2)/2 = 2*sqrt(2) - * (sum of 8 samples, multiply by sqrt(2)/2, implicit >> 1 from Q31) - */ - xr = MULSHIFT32(SQRT1_2, ar - ai); - xi = MULSHIFT32(SQRT1_2, ar + ai); - zr = MULSHIFT32(SQRT1_2, cr - ci); - zi = MULSHIFT32(SQRT1_2, cr + ci); - - /* max gain of output vs input = (2 + 2*sqrt(2) ~= 4.83) - * (sum of 4 samples >> 1, plus xr/xi/zr/zi with gain of 2*sqrt(2)) - * in absolute terms, we have max gain of appx 9.656 (4 + 0.707*8) - * but we also gain 1 int bit (from MULSHIFT32 or from explicit >> 1) - */ - x[ 6] = (tr >> 1) - xr; - x[14] = (tr >> 1) + xr; - x[ 7] = (ti >> 1) - xi; - x[15] = (ti >> 1) + xi; - x[ 2] = (vr >> 1) + zi; - x[10] = (vr >> 1) - zi; - x[ 3] = (vi >> 1) - zr; - x[11] = (vi >> 1) + zr; - - x += 16; - } -} - -/************************************************************************************** - * Function: R4Core - * - * Description: radix-4 pass for decimation-in-time FFT - * - * Inputs: buffer of samples - * number of R4 butterflies per group - * number of R4 groups per pass - * pointer to twiddle factors tables - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: gain 2 integer bits per pass (see scaling comments in code) - * min 1 GB in - * gbOut = gbIn - 1 (short block) or gbIn - 2 (long block) - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ - /* __attribute__ ((section (".data"))) */ static void R4Core(int *x, int bg, int gp, int *wtab) -{ - int ar, ai, br, bi, cr, ci, dr, di, tr, ti; - int wd, ws, wi; - int i, j, step; - int *xptr, *wptr; - - for (; bg != 0; gp <<= 2, bg >>= 2) { - - step = 2*gp; - xptr = x; - - /* max per-sample gain, per group < 1 + 3*sqrt(2) ~= 5.25 if inputs x are full-scale - * do 3 groups for long block, 2 groups for short block (gain 2 int bits per group) - * - * very conservative scaling: - * group 1: max gain = 5.25, int bits gained = 2, gb used = 1 (2^3 = 8) - * group 2: max gain = 5.25^2 = 27.6, int bits gained = 4, gb used = 1 (2^5 = 32) - * group 3: max gain = 5.25^3 = 144.7, int bits gained = 6, gb used = 2 (2^8 = 256) - */ - for (i = bg; i != 0; i--) { - - wptr = wtab; - - for (j = gp; j != 0; j--) { - - ar = xptr[0]; - ai = xptr[1]; - xptr += step; - - /* gain 2 int bits for br/bi, cr/ci, dr/di (MULSHIFT32 by Q30) - * gain 1 net GB - */ - ws = wptr[0]; - wi = wptr[1]; - br = xptr[0]; - bi = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, br + bi); - br = MULSHIFT32(wd, br) - tr; /* cos*br + sin*bi */ - bi = MULSHIFT32(ws, bi) + tr; /* cos*bi - sin*br */ - xptr += step; - - ws = wptr[2]; - wi = wptr[3]; - cr = xptr[0]; - ci = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, cr + ci); - cr = MULSHIFT32(wd, cr) - tr; - ci = MULSHIFT32(ws, ci) + tr; - xptr += step; - - ws = wptr[4]; - wi = wptr[5]; - dr = xptr[0]; - di = xptr[1]; - wd = ws + 2*wi; - tr = MULSHIFT32(wi, dr + di); - dr = MULSHIFT32(wd, dr) - tr; - di = MULSHIFT32(ws, di) + tr; - wptr += 6; - - tr = ar; - ti = ai; - ar = (tr >> 2) - br; - ai = (ti >> 2) - bi; - br = (tr >> 2) + br; - bi = (ti >> 2) + bi; - - tr = cr; - ti = ci; - cr = tr + dr; - ci = di - ti; - dr = tr - dr; - di = di + ti; - - xptr[0] = ar + ci; - xptr[1] = ai + dr; - xptr -= step; - xptr[0] = br - cr; - xptr[1] = bi - di; - xptr -= step; - xptr[0] = ar - ci; - xptr[1] = ai - dr; - xptr -= step; - xptr[0] = br + cr; - xptr[1] = bi + di; - xptr += 2; - } - xptr += 3*step; - } - wtab += 3*step; - } -} - - -/************************************************************************************** - * Function: R4FFT - * - * Description: Ken's very fast in-place radix-4 decimation-in-time FFT - * - * Inputs: table index (for transform size) - * buffer of samples (non bit-reversed) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 5 guard bits in for nfft <= 512 - * gbOut = gbIn - 4 (assuming input is from PreMultiply) - * gains log2(nfft) - 2 int bits total - * so gain 7 int bits (LONG), 4 int bits (SHORT) - **************************************************************************************/ -void R4FFT(int tabidx, int *x) -{ - int order = nfftlog2Tab[tabidx]; - int nfft = nfftTab[tabidx]; - - /* decimation in time */ - BitReverse(x, tabidx); - - if (order & 0x1) { - /* long block: order = 9, nfft = 512 */ - R8FirstPass(x, nfft >> 3); /* gain 1 int bit, lose 2 GB */ - R4Core(x, nfft >> 5, 8, (int *)twidTabOdd); /* gain 6 int bits, lose 2 GB */ - } else { - /* short block: order = 6, nfft = 64 */ - R4FirstPass(x, nfft >> 2); /* gain 0 int bits, lose 2 GB */ - R4Core(x, nfft >> 4, 4, (int *)twidTabEven); /* gain 4 int bits, lose 1 GB */ - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/filefmt.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/filefmt.c deleted file mode 100644 index ccfac596..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/filefmt.c +++ /dev/null @@ -1,496 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: filefmt.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * filefmt.c - ADIF and ADTS header decoding, raw block handling - **************************************************************************************/ - -#include "coder.h" - - /************************************************************************************** - * Function: UnpackADTSHeader - * - * Description: parse the ADTS frame header and initialize decoder state - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer with complete ADTS frame header (byte aligned) - * header size = 7 bytes, plus 2 if CRC - * - * Outputs: filled in ADTS struct - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - * - * TODO: test CRC - * verify that fixed fields don't change between frames - **************************************************************************************/ -int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - ADTSHeader *fhADTS; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - fhADTS = &(psi->fhADTS); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* verify that first 12 bits of header are syncword */ - if (GetBits(&bsi, 12) != 0x0fff) { - return ERR_AAC_INVALID_ADTS_HEADER; - } - - /* fixed fields - should not change from frame to frame */ - fhADTS->id = GetBits(&bsi, 1); - fhADTS->layer = GetBits(&bsi, 2); - fhADTS->protectBit = GetBits(&bsi, 1); - fhADTS->profile = GetBits(&bsi, 2); - fhADTS->sampRateIdx = GetBits(&bsi, 4); - fhADTS->privateBit = GetBits(&bsi, 1); - fhADTS->channelConfig = GetBits(&bsi, 3); - fhADTS->origCopy = GetBits(&bsi, 1); - fhADTS->home = GetBits(&bsi, 1); - - /* variable fields - can change from frame to frame */ - fhADTS->copyBit = GetBits(&bsi, 1); - fhADTS->copyStart = GetBits(&bsi, 1); - fhADTS->frameLength = GetBits(&bsi, 13); - fhADTS->bufferFull = GetBits(&bsi, 11); - fhADTS->numRawDataBlocks = GetBits(&bsi, 2) + 1; - - /* note - MPEG4 spec, correction 1 changes how CRC is handled when protectBit == 0 and numRawDataBlocks > 1 */ - if (fhADTS->protectBit == 0) - fhADTS->crcCheckWord = GetBits(&bsi, 16); - - /* byte align */ - ByteAlignBitstream(&bsi); /* should always be aligned anyway */ - - /* check validity of header */ - if (fhADTS->layer != 0 || fhADTS->profile != AAC_PROFILE_LC || - fhADTS->sampRateIdx >= NUM_SAMPLE_RATES || fhADTS->channelConfig >= NUM_DEF_CHAN_MAPS) - return ERR_AAC_INVALID_ADTS_HEADER; - -#ifndef AAC_ENABLE_MPEG4 - if (fhADTS->id != 1) - return ERR_AAC_MPEG4_UNSUPPORTED; -#endif - - /* update codec info */ - psi->sampRateIdx = fhADTS->sampRateIdx; - if (!psi->useImpChanMap) - psi->nChans = channelMapTab[fhADTS->channelConfig]; - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data (TODO - calc bitrate, handle tricky channel config cases) */ - aacDecInfo->bitRate = 0; - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - aacDecInfo->profile = fhADTS->profile; - aacDecInfo->sbrEnabled = 0; - aacDecInfo->adtsBlocksLeft = fhADTS->numRawDataBlocks; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed ; - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: GetADTSChannelMapping - * - * Description: determine the number of channels from implicit mapping rules - * - * Inputs: valid AACDecInfo struct - * pointer to start of raw_data_block - * bit offset - * bits available - * - * Outputs: updated number of channels - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: calculates total number of channels using rules in 14496-3, 4.5.1.2.1 - * does not attempt to deduce speaker geometry - **************************************************************************************/ -int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail) -{ - int ch, nChans, elementChans, err; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - nChans = 0; - do { - /* parse next syntactic element */ - err = DecodeNextElement(aacDecInfo, &buf, &bitOffset, &bitsAvail); - if (err) - return err; - - elementChans = elementNumChans[aacDecInfo->currBlockID]; - nChans += elementChans; - - for (ch = 0; ch < elementChans; ch++) { - err = DecodeNoiselessData(aacDecInfo, &buf, &bitOffset, &bitsAvail, ch); - if (err) - return err; - } - } while (aacDecInfo->currBlockID != AAC_ID_END); - - if (nChans <= 0) - return ERR_AAC_CHANNEL_MAP; - - /* update number of channels in codec state and user-accessible info structs */ - psi->nChans = nChans; - aacDecInfo->nChans = psi->nChans; - psi->useImpChanMap = 1; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: GetNumChannelsADIF - * - * Description: get number of channels from program config elements in an ADIF file - * - * Inputs: array of filled-in program config element structures - * number of PCE's - * - * Outputs: none - * - * Return: total number of channels in file - * -1 if error (invalid number of PCE's or unsupported mode) - **************************************************************************************/ -static int GetNumChannelsADIF(ProgConfigElement *fhPCE, int nPCE) -{ - int i, j, nChans; - - if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) - return -1; - - nChans = 0; - for (i = 0; i < nPCE; i++) { - /* for now: only support LC, no channel coupling */ - if (fhPCE[i].profile != AAC_PROFILE_LC || fhPCE[i].numCCE > 0) - return -1; - - /* add up number of channels in all channel elements (assume all single-channel) */ - nChans += fhPCE[i].numFCE; - nChans += fhPCE[i].numSCE; - nChans += fhPCE[i].numBCE; - nChans += fhPCE[i].numLCE; - - /* add one more for every element which is a channel pair */ - for (j = 0; j < fhPCE[i].numFCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].fce[j])) - nChans++; - } - for (j = 0; j < fhPCE[i].numSCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].sce[j])) - nChans++; - } - for (j = 0; j < fhPCE[i].numBCE; j++) { - if (CHAN_ELEM_IS_CPE(fhPCE[i].bce[j])) - nChans++; - } - - } - - return nChans; -} - -/************************************************************************************** - * Function: GetSampleRateIdxADIF - * - * Description: get sampling rate index from program config elements in an ADIF file - * - * Inputs: array of filled-in program config element structures - * number of PCE's - * - * Outputs: none - * - * Return: sample rate of file - * -1 if error (invalid number of PCE's or sample rate mismatch) - **************************************************************************************/ -static int GetSampleRateIdxADIF(ProgConfigElement *fhPCE, int nPCE) -{ - int i, idx; - - if (nPCE < 1 || nPCE > MAX_NUM_PCE_ADIF) - return -1; - - /* make sure all PCE's have the same sample rate */ - idx = fhPCE[0].sampRateIdx; - for (i = 1; i < nPCE; i++) { - if (fhPCE[i].sampRateIdx != idx) - return -1; - } - - return idx; -} - -/************************************************************************************** - * Function: UnpackADIFHeader - * - * Description: parse the ADIF file header and initialize decoder state - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer with complete ADIF header - * (starting at 'A' in 'ADIF' tag) - * pointer to bit offset - * pointer to number of valid bits remaining in inbuf - * - * Outputs: filled-in ADIF struct - * updated buffer pointer - * updated bit offset - * updated number of available bits - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail) -{ - int i, bitsUsed; - PSInfoBase *psi; - BitStreamInfo bsi; - ADIFHeader *fhADIF; - ProgConfigElement *pce; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* init bitstream reader */ - SetBitstreamPointer(&bsi, (*bitsAvail + 7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - /* unpack ADIF file header */ - fhADIF = &(psi->fhADIF); - pce = psi->pce; - - /* verify that first 32 bits of header are "ADIF" */ - if (GetBits(&bsi, 8) != 'A' || GetBits(&bsi, 8) != 'D' || GetBits(&bsi, 8) != 'I' || GetBits(&bsi, 8) != 'F') - return ERR_AAC_INVALID_ADIF_HEADER; - - /* read ADIF header fields */ - fhADIF->copyBit = GetBits(&bsi, 1); - if (fhADIF->copyBit) { - for (i = 0; i < ADIF_COPYID_SIZE; i++) - fhADIF->copyID[i] = GetBits(&bsi, 8); - } - fhADIF->origCopy = GetBits(&bsi, 1); - fhADIF->home = GetBits(&bsi, 1); - fhADIF->bsType = GetBits(&bsi, 1); - fhADIF->bitRate = GetBits(&bsi, 23); - fhADIF->numPCE = GetBits(&bsi, 4) + 1; /* add 1 (so range = [1, 16]) */ - if (fhADIF->bsType == 0) - fhADIF->bufferFull = GetBits(&bsi, 20); - - /* parse all program config elements */ - for (i = 0; i < fhADIF->numPCE; i++) - DecodeProgramConfigElement(pce + i, &bsi); - - /* byte align */ - ByteAlignBitstream(&bsi); - - /* update codec info */ - psi->nChans = GetNumChannelsADIF(pce, fhADIF->numPCE); - psi->sampRateIdx = GetSampleRateIdxADIF(pce, fhADIF->numPCE); - - /* check validity of header */ - if (psi->nChans < 0 || psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) - return ERR_AAC_INVALID_ADIF_HEADER; - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data */ - aacDecInfo->bitRate = 0; - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - aacDecInfo->profile = pce[0].profile; - aacDecInfo->sbrEnabled = 0; - - /* update bitstream reader */ - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - *bitsAvail -= bitsUsed ; - if (*bitsAvail < 0) - return ERR_AAC_INDATA_UNDERFLOW; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: SetRawBlockParams - * - * Description: set internal state variables for decoding a stream of raw data blocks - * - * Inputs: valid AACDecInfo struct - * flag indicating source of parameters (from previous headers or passed - * explicitly by caller) - * number of channels - * sample rate - * profile ID - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: if copyLast == 1, then psi->nChans, psi->sampRateIdx, and - * aacDecInfo->profile are not changed (it's assumed that we already - * set them, such as by a previous call to UnpackADTSHeader()) - * if copyLast == 0, then the parameters we passed in are used instead - **************************************************************************************/ -int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile) -{ - int idx; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - if (!copyLast) { - aacDecInfo->profile = profile; - psi->nChans = nChans; - for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) { - if (sampRate == sampRateTab[idx]) { - psi->sampRateIdx = idx; - break; - } - } - if (idx == NUM_SAMPLE_RATES) - return ERR_AAC_INVALID_FRAME; - } - aacDecInfo->nChans = psi->nChans; - aacDecInfo->sampRate = sampRateTab[psi->sampRateIdx]; - - /* check validity of header */ - if (psi->sampRateIdx >= NUM_SAMPLE_RATES || psi->sampRateIdx < 0 || aacDecInfo->profile != AAC_PROFILE_LC) - return ERR_AAC_RAWBLOCK_PARAMS; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: PrepareRawBlock - * - * Description: reset per-block state variables for raw blocks (no ADTS/ADIF headers) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int PrepareRawBlock(AACDecInfo *aacDecInfo) -{ -// PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; -// psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* syntactic element fields will be read from bitstream for each element */ - aacDecInfo->prevBlockID = AAC_ID_INVALID; - aacDecInfo->currBlockID = AAC_ID_INVALID; - aacDecInfo->currInstTag = -1; - - /* fill in user-accessible data */ - aacDecInfo->bitRate = 0; - aacDecInfo->sbrEnabled = 0; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: FlushCodec - * - * Description: flush internal codec state (after seeking, for example) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables in aacDecInfo - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: only need to clear data which is persistent between frames - * (such as overlap buffer) - **************************************************************************************/ -int FlushCodec(AACDecInfo *aacDecInfo) -{ - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - ClearBuffer(psi->overlap, AAC_MAX_NCHANS * AAC_MAX_NSAMPS * sizeof(int)); - ClearBuffer(psi->prevWinShape, AAC_MAX_NCHANS * sizeof(int)); - - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/huffman.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/huffman.c deleted file mode 100644 index 57cc45c9..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/huffman.c +++ /dev/null @@ -1,415 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: huffman.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * huffman.c - Huffman decoding - **************************************************************************************/ - -#include "coder.h" - -/************************************************************************************** - * Function: DecodeHuffmanScalar - * - * Description: decode one Huffman symbol from bitstream - * - * Inputs: pointers to Huffman table and info struct - * left-aligned bit buffer with >= huffTabInfo->maxBits bits - * - * Outputs: decoded symbol in *val - * - * Return: number of bits in symbol - * - * Notes: assumes canonical Huffman codes: - * first CW always 0, we have "count" CW's of length "nBits" bits - * starting CW for codes of length nBits+1 = - * (startCW[nBits] + count[nBits]) << 1 - * if there are no codes at nBits, then we just keep << 1 each time - * (since count[nBits] = 0) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ int DecodeHuffmanScalar(const signed short *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val) -{ - unsigned int count, start, shift, t; - const unsigned /*char*/ int *countPtr; - const signed short *map; - - map = huffTab + huffTabInfo->offset; - countPtr = huffTabInfo->count; - - start = 0; - count = 0; - shift = 32; - do { - start += count; - start <<= 1; - map += count; - count = *countPtr++; - shift--; - t = (bitBuf >> shift) - start; - } while (t >= count); - - *val = (signed int)pgm_read_word(&map[t]); - return (countPtr - huffTabInfo->count); -} - -#define APPLY_SIGN(v, s) {(v) ^= ((signed int)(s) >> 31); (v) -= ((signed int)(s) >> 31);} - -#define GET_QUAD_SIGNBITS(v) (((unsigned int)(v) << 17) >> 29) /* bits 14-12, unsigned */ -#define GET_QUAD_W(v) (((signed int)(v) << 20) >> 29) /* bits 11-9, sign-extend */ -#define GET_QUAD_X(v) (((signed int)(v) << 23) >> 29) /* bits 8-6, sign-extend */ -#define GET_QUAD_Y(v) (((signed int)(v) << 26) >> 29) /* bits 5-3, sign-extend */ -#define GET_QUAD_Z(v) (((signed int)(v) << 29) >> 29) /* bits 2-0, sign-extend */ - -#define GET_PAIR_SIGNBITS(v) (((unsigned int)(v) << 20) >> 30) /* bits 11-10, unsigned */ -#define GET_PAIR_Y(v) (((signed int)(v) << 22) >> 27) /* bits 9-5, sign-extend */ -#define GET_PAIR_Z(v) (((signed int)(v) << 27) >> 27) /* bits 4-0, sign-extend */ - -#define GET_ESC_SIGNBITS(v) (((unsigned int)(v) << 18) >> 30) /* bits 13-12, unsigned */ -#define GET_ESC_Y(v) (((signed int)(v) << 20) >> 26) /* bits 11-6, sign-extend */ -#define GET_ESC_Z(v) (((signed int)(v) << 26) >> 26) /* bits 5-0, sign-extend */ - -/************************************************************************************** - * Function: UnpackZeros - * - * Description: fill a section of coefficients with zeros - * - * Inputs: number of coefficients - * - * Outputs: nVals zeros, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -static void UnpackZeros(int nVals, int *coef) -{ - while (nVals > 0) { - *coef++ = 0; - *coef++ = 0; - *coef++ = 0; - *coef++ = 0; - nVals -= 4; - } -} - -/************************************************************************************** - * Function: UnpackQuads - * - * Description: decode a section of 4-way vector Huffman coded coefficients - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 4 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackQuads(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int w, x, y, z, maxBits, nCodeBits, nSignBits, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 4; - while (nVals > 0) { - /* decode quad */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - w = GET_QUAD_W(val); - x = GET_QUAD_X(val); - y = GET_QUAD_Y(val); - z = GET_QUAD_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = (int)GET_QUAD_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - if (nSignBits) { - if (w) {APPLY_SIGN(w, bitBuf); bitBuf <<= 1;} - if (x) {APPLY_SIGN(x, bitBuf); bitBuf <<= 1;} - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - *coef++ = w; *coef++ = x; *coef++ = y; *coef++ = z; - nVals -= 4; - } -} - -/************************************************************************************** - * Function: UnpackPairsNoEsc - * - * Description: decode a section of 2-way vector Huffman coded coefficients, - * using non-esc tables (5 through 10) - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook (must not be the escape codebook) - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackPairsNoEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int y, z, maxBits, nCodeBits, nSignBits, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2; - while (nVals > 0) { - /* decode pair */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb-HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - y = GET_PAIR_Y(val); - z = GET_PAIR_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = GET_PAIR_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - if (nSignBits) { - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - *coef++ = y; *coef++ = z; - nVals -= 2; - } -} - -/************************************************************************************** - * Function: UnpackPairsEsc - * - * Description: decode a section of 2-way vector Huffman coded coefficients, - * using esc table (11) - * - * Inputs BitStreamInfo struct pointing to start of codewords for this section - * index of Huffman codebook (must be the escape codebook) - * number of coefficients - * - * Outputs: nVals coefficients, starting at coef - * - * Return: none - * - * Notes: assumes nVals is always a multiple of 2 because all scalefactor bands - * are a multiple of 4 coefficients long - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void UnpackPairsEsc(BitStreamInfo *bsi, int cb, int nVals, int *coef) -{ - int y, z, maxBits, nCodeBits, nSignBits, n, val; - unsigned int bitBuf; - - maxBits = huffTabSpecInfo[cb - HUFFTAB_SPEC_OFFSET].maxBits + 2; - while (nVals > 0) { - /* decode pair with escape value */ - bitBuf = GetBitsNoAdvance(bsi, maxBits) << (32 - maxBits); - nCodeBits = DecodeHuffmanScalar(huffTabSpec, &huffTabSpecInfo[cb-HUFFTAB_SPEC_OFFSET], bitBuf, &val); - - y = GET_ESC_Y(val); - z = GET_ESC_Z(val); - - bitBuf <<= nCodeBits; - nSignBits = GET_ESC_SIGNBITS(val); - AdvanceBitstream(bsi, nCodeBits + nSignBits); - - if (y == 16) { - n = 4; - while (GetBits(bsi, 1) == 1) - n++; - y = (1 << n) + GetBits(bsi, n); - } - if (z == 16) { - n = 4; - while (GetBits(bsi, 1) == 1) - n++; - z = (1 << n) + GetBits(bsi, n); - } - - if (nSignBits) { - if (y) {APPLY_SIGN(y, bitBuf); bitBuf <<= 1;} - if (z) {APPLY_SIGN(z, bitBuf); bitBuf <<= 1;} - } - - *coef++ = y; *coef++ = z; - nVals -= 2; - } -} - -/************************************************************************************** - * Function: DecodeSpectrumLong - * - * Description: decode transform coefficients for frame with one long block - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of spectral data - * (14496-3, table 4.4.29) - * index of current channel - * - * Outputs: decoded, quantized coefficients for this channel - * - * Return: none - * - * Notes: adds in pulse data if present - * fills coefficient buffer with zeros in any region not coded with - * codebook in range [1, 11] (including sfb's above sfbMax) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ void DecodeSpectrumLong(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int i, sfb, cb, nVals, offset; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - int *coef; - ICSInfo *icsInfo; - PulseInfo *pi; - - coef = psi->coef[ch]; - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - /* decode long block */ - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - sfbCodeBook = psi->sfbCodeBook[ch]; - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - cb = *sfbCodeBook++; - nVals = sfbTab[sfb+1] - sfbTab[sfb]; - - if (cb == 0) - UnpackZeros(nVals, coef); - else if (cb <= 4) - UnpackQuads(bsi, cb, nVals, coef); - else if (cb <= 10) - UnpackPairsNoEsc(bsi, cb, nVals, coef); - else if (cb == 11) - UnpackPairsEsc(bsi, cb, nVals, coef); - else - UnpackZeros(nVals, coef); - - coef += nVals; - } - - /* fill with zeros above maxSFB */ - nVals = NSAMPS_LONG - sfbTab[sfb]; - UnpackZeros(nVals, coef); - - /* add pulse data, if present */ - pi = &psi->pulseInfo[ch]; - if (pi->pulseDataPresent) { - coef = psi->coef[ch]; - offset = sfbTab[pi->startSFB]; - for (i = 0; i < pi->numPulse; i++) { - offset += pi->offset[i]; - if (coef[offset] > 0) - coef[offset] += pi->amp[i]; - else - coef[offset] -= pi->amp[i]; - } - ASSERT(offset < NSAMPS_LONG); - } -} - -/************************************************************************************** - * Function: DecodeSpectrumShort - * - * Description: decode transform coefficients for frame with eight short blocks - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of spectral data - * (14496-3, table 4.4.29) - * index of current channel - * - * Outputs: decoded, quantized coefficients for this channel - * - * Return: none - * - * Notes: fills coefficient buffer with zeros in any region not coded with - * codebook in range [1, 11] (including sfb's above sfbMax) - * deinterleaves window groups into 8 windows - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ void DecodeSpectrumShort(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int gp, cb, nVals=0, win, offset, sfb; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - int *coef; - ICSInfo *icsInfo; - - coef = psi->coef[ch]; - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - /* decode short blocks, deinterleaving in-place */ - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - sfbCodeBook = psi->sfbCodeBook[ch]; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - nVals = sfbTab[sfb+1] - sfbTab[sfb]; - cb = *sfbCodeBook++; - - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - offset = win*NSAMPS_SHORT; - if (cb == 0) - UnpackZeros(nVals, coef + offset); - else if (cb <= 4) - UnpackQuads(bsi, cb, nVals, coef + offset); - else if (cb <= 10) - UnpackPairsNoEsc(bsi, cb, nVals, coef + offset); - else if (cb == 11) - UnpackPairsEsc(bsi, cb, nVals, coef + offset); - else - UnpackZeros(nVals, coef + offset); - } - coef += nVals; - } - - /* fill with zeros above maxSFB */ - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - offset = win*NSAMPS_SHORT; - nVals = NSAMPS_SHORT - sfbTab[sfb]; - UnpackZeros(nVals, coef + offset); - } - coef += nVals; - coef += (icsInfo->winGroupLen[gp] - 1)*NSAMPS_SHORT; - } - - ASSERT(coef == psi->coef[ch] + NSAMPS_LONG); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/hufftabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/hufftabs.c deleted file mode 100644 index 91cc50ce..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/hufftabs.c +++ /dev/null @@ -1,177 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: hufftabs.c,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * hufftabs.c - Huffman symbol tables - **************************************************************************************/ - -#include "coder.h" - -const HuffInfo huffTabSpecInfo[11] PROGMEM = { - /* table 0 not used */ - {11, { 1, 0, 0, 0, 8, 0, 24, 0, 24, 8, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0}, - { 9, { 0, 0, 1, 1, 7, 24, 15, 19, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 81}, - {16, { 1, 0, 0, 4, 2, 6, 3, 5, 15, 15, 8, 9, 3, 3, 5, 2, 0, 0, 0, 0}, 162}, - {12, { 0, 0, 0, 10, 6, 0, 9, 21, 8, 14, 11, 2, 0, 0, 0, 0, 0, 0, 0, 0}, 243}, - {13, { 1, 0, 0, 4, 4, 0, 4, 12, 12, 12, 18, 10, 4, 0, 0, 0, 0, 0, 0, 0}, 324}, - {11, { 0, 0, 0, 9, 0, 16, 13, 8, 23, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 405}, - {12, { 1, 0, 2, 1, 0, 4, 5, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0}, 486}, - {10, { 0, 0, 1, 5, 7, 10, 14, 15, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 550}, - {15, { 1, 0, 2, 1, 0, 4, 3, 8, 11, 20, 31, 38, 32, 14, 4, 0, 0, 0, 0, 0}, 614}, - {12, { 0, 0, 0, 3, 8, 14, 17, 25, 31, 41, 22, 8, 0, 0, 0, 0, 0, 0, 0, 0}, 783}, - {12, { 0, 0, 0, 2, 6, 7, 16, 59, 55, 95, 43, 6, 0, 0, 0, 0, 0, 0, 0, 0}, 952}, -}; - -const signed short huffTabSpec[1241] PROGMEM = { - /* spectrum table 1 [81] (signed) */ - 0x0000, 0x0200, 0x0e00, 0x0007, 0x0040, 0x0001, 0x0038, 0x0008, 0x01c0, 0x03c0, 0x0e40, 0x0039, 0x0078, 0x01c8, 0x000f, 0x0240, - 0x003f, 0x0fc0, 0x01f8, 0x0238, 0x0047, 0x0e08, 0x0009, 0x0208, 0x01c1, 0x0048, 0x0041, 0x0e38, 0x0201, 0x0e07, 0x0207, 0x0e01, - 0x01c7, 0x0278, 0x0e78, 0x03c8, 0x004f, 0x0079, 0x01c9, 0x01cf, 0x03f8, 0x0239, 0x007f, 0x0e48, 0x0e0f, 0x0fc8, 0x01f9, 0x03c1, - 0x03c7, 0x0e47, 0x0ff8, 0x01ff, 0x0049, 0x020f, 0x0241, 0x0e41, 0x0248, 0x0fc1, 0x0e3f, 0x0247, 0x023f, 0x0e39, 0x0fc7, 0x0e09, - 0x0209, 0x03cf, 0x0e79, 0x0e4f, 0x03f9, 0x0249, 0x0fc9, 0x027f, 0x0fcf, 0x0fff, 0x0279, 0x03c9, 0x0e49, 0x0e7f, 0x0ff9, 0x03ff, - 0x024f, - /* spectrum table 2 [81] (signed) */ - 0x0000, 0x0200, 0x0e00, 0x0001, 0x0038, 0x0007, 0x01c0, 0x0008, 0x0040, 0x01c8, 0x0e40, 0x0078, 0x000f, 0x0047, 0x0039, 0x0e07, - 0x03c0, 0x0238, 0x0fc0, 0x003f, 0x0208, 0x0201, 0x01c1, 0x0e08, 0x0041, 0x01f8, 0x0e01, 0x01c7, 0x0e38, 0x0240, 0x0048, 0x0009, - 0x0207, 0x0079, 0x0239, 0x0e78, 0x01cf, 0x03c8, 0x0247, 0x0209, 0x0e48, 0x01f9, 0x0248, 0x0e0f, 0x0ff8, 0x0e39, 0x03f8, 0x0278, - 0x03c1, 0x0e47, 0x0fc8, 0x0e09, 0x0fc1, 0x0fc7, 0x01ff, 0x020f, 0x023f, 0x007f, 0x0049, 0x0e41, 0x0e3f, 0x004f, 0x03c7, 0x01c9, - 0x0241, 0x03cf, 0x0e79, 0x03f9, 0x0fff, 0x0e4f, 0x0e49, 0x0249, 0x0fcf, 0x03c9, 0x0e7f, 0x0fc9, 0x027f, 0x03ff, 0x0ff9, 0x0279, - 0x024f, - /* spectrum table 3 [81] (unsigned) */ - 0x0000, 0x1200, 0x1001, 0x1040, 0x1008, 0x2240, 0x2009, 0x2048, 0x2041, 0x2208, 0x3049, 0x2201, 0x3248, 0x4249, 0x3209, 0x3241, - 0x1400, 0x1002, 0x200a, 0x2440, 0x3288, 0x2011, 0x3051, 0x2280, 0x304a, 0x3448, 0x1010, 0x2088, 0x2050, 0x1080, 0x2042, 0x2408, - 0x4289, 0x3089, 0x3250, 0x4251, 0x3281, 0x2210, 0x3211, 0x2081, 0x4449, 0x424a, 0x3441, 0x320a, 0x2012, 0x3052, 0x3488, 0x3290, - 0x2202, 0x2401, 0x3091, 0x2480, 0x4291, 0x3242, 0x3409, 0x4252, 0x4489, 0x2090, 0x308a, 0x3212, 0x3481, 0x3450, 0x3490, 0x3092, - 0x4491, 0x4451, 0x428a, 0x4292, 0x2082, 0x2410, 0x3282, 0x3411, 0x444a, 0x3442, 0x4492, 0x448a, 0x4452, 0x340a, 0x2402, 0x3482, - 0x3412, - /* spectrum table 4 [81] (unsigned) */ - 0x4249, 0x3049, 0x3241, 0x3248, 0x3209, 0x1200, 0x2240, 0x0000, 0x2009, 0x2208, 0x2201, 0x2048, 0x1001, 0x2041, 0x1008, 0x1040, - 0x4449, 0x4251, 0x4289, 0x424a, 0x3448, 0x3441, 0x3288, 0x3409, 0x3051, 0x304a, 0x3250, 0x3089, 0x320a, 0x3281, 0x3242, 0x3211, - 0x2440, 0x2408, 0x2280, 0x2401, 0x2042, 0x2088, 0x200a, 0x2050, 0x2081, 0x2202, 0x2011, 0x2210, 0x1400, 0x1002, 0x1080, 0x1010, - 0x4291, 0x4489, 0x4451, 0x4252, 0x428a, 0x444a, 0x3290, 0x3488, 0x3450, 0x3091, 0x3052, 0x3481, 0x308a, 0x3411, 0x3212, 0x4491, - 0x3282, 0x340a, 0x3442, 0x4292, 0x4452, 0x448a, 0x2090, 0x2480, 0x2012, 0x2410, 0x2082, 0x2402, 0x4492, 0x3092, 0x3490, 0x3482, - 0x3412, - /* spectrum table 5 [81] (signed) */ - 0x0000, 0x03e0, 0x0020, 0x0001, 0x001f, 0x003f, 0x03e1, 0x03ff, 0x0021, 0x03c0, 0x0002, 0x0040, 0x001e, 0x03df, 0x0041, 0x03fe, - 0x0022, 0x03c1, 0x005f, 0x03e2, 0x003e, 0x03a0, 0x0060, 0x001d, 0x0003, 0x03bf, 0x0023, 0x0061, 0x03fd, 0x03a1, 0x007f, 0x003d, - 0x03e3, 0x03c2, 0x0042, 0x03de, 0x005e, 0x03be, 0x007e, 0x03c3, 0x005d, 0x0062, 0x0043, 0x03a2, 0x03dd, 0x001c, 0x0380, 0x0081, - 0x0080, 0x039f, 0x0004, 0x009f, 0x03fc, 0x0024, 0x03e4, 0x0381, 0x003c, 0x007d, 0x03bd, 0x03a3, 0x03c4, 0x039e, 0x0082, 0x005c, - 0x0044, 0x0063, 0x0382, 0x03dc, 0x009e, 0x007c, 0x039d, 0x0383, 0x0064, 0x03a4, 0x0083, 0x009d, 0x03bc, 0x009c, 0x0384, 0x0084, - 0x039c, - /* spectrum table 6 [81] (signed) */ - 0x0000, 0x0020, 0x001f, 0x0001, 0x03e0, 0x0021, 0x03e1, 0x003f, 0x03ff, 0x005f, 0x0041, 0x03c1, 0x03df, 0x03c0, 0x03e2, 0x0040, - 0x003e, 0x0022, 0x001e, 0x03fe, 0x0002, 0x005e, 0x03c2, 0x03de, 0x0042, 0x03a1, 0x0061, 0x007f, 0x03e3, 0x03bf, 0x0023, 0x003d, - 0x03fd, 0x0060, 0x03a0, 0x001d, 0x0003, 0x0062, 0x03be, 0x03c3, 0x0043, 0x007e, 0x005d, 0x03dd, 0x03a2, 0x0063, 0x007d, 0x03bd, - 0x03a3, 0x003c, 0x03fc, 0x0081, 0x0381, 0x039f, 0x0024, 0x009f, 0x03e4, 0x001c, 0x0382, 0x039e, 0x0044, 0x03dc, 0x0380, 0x0082, - 0x009e, 0x03c4, 0x0080, 0x005c, 0x0004, 0x03bc, 0x03a4, 0x007c, 0x009d, 0x0064, 0x0083, 0x0383, 0x039d, 0x0084, 0x0384, 0x039c, - 0x009c, - /* spectrum table 7 [64] (unsigned) */ - 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0823, 0x0842, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824, - 0x0881, 0x0825, 0x08a1, 0x0863, 0x0844, 0x0404, 0x0480, 0x0882, 0x0845, 0x08a2, 0x0405, 0x08c1, 0x04a0, 0x0826, 0x0883, 0x0865, - 0x0864, 0x08a3, 0x0846, 0x08c2, 0x0827, 0x0866, 0x0406, 0x04c0, 0x0884, 0x08e1, 0x0885, 0x08e2, 0x08a4, 0x08c3, 0x0847, 0x08e3, - 0x08c4, 0x08a5, 0x0886, 0x0867, 0x04e0, 0x0407, 0x08c5, 0x08a6, 0x08e4, 0x0887, 0x08a7, 0x08e5, 0x08e6, 0x08c6, 0x08c7, 0x08e7, - /* spectrum table 8 [64] (unsigned) */ - 0x0821, 0x0841, 0x0420, 0x0822, 0x0401, 0x0842, 0x0000, 0x0440, 0x0402, 0x0861, 0x0823, 0x0862, 0x0843, 0x0863, 0x0881, 0x0824, - 0x0882, 0x0844, 0x0460, 0x0403, 0x0883, 0x0864, 0x08a2, 0x08a1, 0x0845, 0x0825, 0x08a3, 0x0865, 0x0884, 0x08a4, 0x0404, 0x0885, - 0x0480, 0x0846, 0x08c2, 0x08c1, 0x0826, 0x0866, 0x08c3, 0x08a5, 0x04a0, 0x08c4, 0x0405, 0x0886, 0x08e1, 0x08e2, 0x0847, 0x08c5, - 0x08e3, 0x0827, 0x08a6, 0x0867, 0x08c6, 0x08e4, 0x04c0, 0x0887, 0x0406, 0x08e5, 0x08e6, 0x08c7, 0x08a7, 0x04e0, 0x0407, 0x08e7, - /* spectrum table 9 [169] (unsigned) */ - 0x0000, 0x0420, 0x0401, 0x0821, 0x0841, 0x0822, 0x0440, 0x0402, 0x0861, 0x0842, 0x0823, 0x0460, 0x0403, 0x0843, 0x0862, 0x0824, - 0x0881, 0x0844, 0x0825, 0x0882, 0x0863, 0x0404, 0x0480, 0x08a1, 0x0845, 0x0826, 0x0864, 0x08a2, 0x08c1, 0x0883, 0x0405, 0x0846, - 0x04a0, 0x0827, 0x0865, 0x0828, 0x0901, 0x0884, 0x08a3, 0x08c2, 0x08e1, 0x0406, 0x0902, 0x0848, 0x0866, 0x0847, 0x0885, 0x0921, - 0x0829, 0x08e2, 0x04c0, 0x08a4, 0x08c3, 0x0903, 0x0407, 0x0922, 0x0868, 0x0886, 0x0867, 0x0408, 0x0941, 0x08c4, 0x0849, 0x08a5, - 0x0500, 0x04e0, 0x08e3, 0x0942, 0x0923, 0x0904, 0x082a, 0x08e4, 0x08c5, 0x08a6, 0x0888, 0x0887, 0x0869, 0x0961, 0x08a8, 0x0520, - 0x0905, 0x0943, 0x084a, 0x0409, 0x0962, 0x0924, 0x08c6, 0x0981, 0x0889, 0x0906, 0x082b, 0x0925, 0x0944, 0x08a7, 0x08e5, 0x084b, - 0x082c, 0x0982, 0x0963, 0x086a, 0x08a9, 0x08c7, 0x0907, 0x0964, 0x040a, 0x08e6, 0x0983, 0x0540, 0x0945, 0x088a, 0x08c8, 0x084c, - 0x0926, 0x0927, 0x088b, 0x0560, 0x08c9, 0x086b, 0x08aa, 0x0908, 0x08e8, 0x0985, 0x086c, 0x0965, 0x08e7, 0x0984, 0x0966, 0x0946, - 0x088c, 0x08e9, 0x08ab, 0x040b, 0x0986, 0x08ca, 0x0580, 0x0947, 0x08ac, 0x08ea, 0x0928, 0x040c, 0x0967, 0x0909, 0x0929, 0x0948, - 0x08eb, 0x0987, 0x08cb, 0x090b, 0x0968, 0x08ec, 0x08cc, 0x090a, 0x0949, 0x090c, 0x092a, 0x092b, 0x092c, 0x094b, 0x0989, 0x094a, - 0x0969, 0x0988, 0x096a, 0x098a, 0x098b, 0x094c, 0x096b, 0x096c, 0x098c, - /* spectrum table 10 [169] (unsigned) */ - 0x0821, 0x0822, 0x0841, 0x0842, 0x0420, 0x0401, 0x0823, 0x0862, 0x0861, 0x0843, 0x0863, 0x0440, 0x0402, 0x0844, 0x0882, 0x0824, - 0x0881, 0x0000, 0x0883, 0x0864, 0x0460, 0x0403, 0x0884, 0x0845, 0x08a2, 0x0825, 0x08a1, 0x08a3, 0x0865, 0x08a4, 0x0885, 0x08c2, - 0x0846, 0x08c3, 0x0480, 0x08c1, 0x0404, 0x0826, 0x0866, 0x08a5, 0x08c4, 0x0886, 0x08c5, 0x08e2, 0x0867, 0x0847, 0x08a6, 0x0902, - 0x08e3, 0x04a0, 0x08e1, 0x0405, 0x0901, 0x0827, 0x0903, 0x08e4, 0x0887, 0x0848, 0x08c6, 0x08e5, 0x0828, 0x0868, 0x0904, 0x0888, - 0x08a7, 0x0905, 0x08a8, 0x08e6, 0x08c7, 0x0922, 0x04c0, 0x08c8, 0x0923, 0x0869, 0x0921, 0x0849, 0x0406, 0x0906, 0x0924, 0x0889, - 0x0942, 0x0829, 0x08e7, 0x0907, 0x0925, 0x08e8, 0x0943, 0x08a9, 0x0944, 0x084a, 0x0941, 0x086a, 0x0926, 0x08c9, 0x0500, 0x088a, - 0x04e0, 0x0962, 0x08e9, 0x0963, 0x0946, 0x082a, 0x0961, 0x0927, 0x0407, 0x0908, 0x0945, 0x086b, 0x08aa, 0x0909, 0x0965, 0x0408, - 0x0964, 0x084b, 0x08ea, 0x08ca, 0x0947, 0x088b, 0x082b, 0x0982, 0x0928, 0x0983, 0x0966, 0x08ab, 0x0984, 0x0967, 0x0985, 0x086c, - 0x08cb, 0x0520, 0x0948, 0x0540, 0x0981, 0x0409, 0x088c, 0x0929, 0x0986, 0x084c, 0x090a, 0x092a, 0x082c, 0x0968, 0x0987, 0x08eb, - 0x08ac, 0x08cc, 0x0949, 0x090b, 0x0988, 0x040a, 0x08ec, 0x0560, 0x094a, 0x0969, 0x096a, 0x040b, 0x096b, 0x092b, 0x094b, 0x0580, - 0x090c, 0x0989, 0x094c, 0x092c, 0x096c, 0x098b, 0x040c, 0x098a, 0x098c, - /* spectrum table 11 [289] (unsigned) */ - 0x0000, 0x2041, 0x2410, 0x1040, 0x1001, 0x2081, 0x2042, 0x2082, 0x2043, 0x20c1, 0x20c2, 0x1080, 0x2083, 0x1002, 0x20c3, 0x2101, - 0x2044, 0x2102, 0x2084, 0x2103, 0x20c4, 0x10c0, 0x1003, 0x2141, 0x2142, 0x2085, 0x2104, 0x2045, 0x2143, 0x20c5, 0x2144, 0x2105, - 0x2182, 0x2086, 0x2181, 0x2183, 0x20c6, 0x2046, 0x2110, 0x20d0, 0x2405, 0x2403, 0x2404, 0x2184, 0x2406, 0x1100, 0x2106, 0x1004, - 0x2090, 0x2145, 0x2150, 0x2407, 0x2402, 0x2408, 0x2087, 0x21c2, 0x20c7, 0x2185, 0x2146, 0x2190, 0x240a, 0x21c3, 0x21c1, 0x2409, - 0x21d0, 0x2050, 0x2047, 0x2107, 0x240b, 0x21c4, 0x240c, 0x2210, 0x2401, 0x2186, 0x2250, 0x2088, 0x2147, 0x2290, 0x240d, 0x2203, - 0x2202, 0x20c8, 0x1140, 0x240e, 0x22d0, 0x21c5, 0x2108, 0x2187, 0x21c6, 0x1005, 0x2204, 0x240f, 0x2310, 0x2048, 0x2201, 0x2390, - 0x2148, 0x2350, 0x20c9, 0x2205, 0x21c7, 0x2089, 0x2206, 0x2242, 0x2243, 0x23d0, 0x2109, 0x2188, 0x1180, 0x2244, 0x2149, 0x2207, - 0x21c8, 0x2049, 0x2283, 0x1006, 0x2282, 0x2241, 0x2245, 0x210a, 0x208a, 0x2246, 0x20ca, 0x2189, 0x2284, 0x2208, 0x2285, 0x2247, - 0x22c3, 0x204a, 0x11c0, 0x2286, 0x21c9, 0x20cb, 0x214a, 0x2281, 0x210b, 0x22c2, 0x2342, 0x218a, 0x2343, 0x208b, 0x1400, 0x214b, - 0x22c5, 0x22c4, 0x2248, 0x21ca, 0x2209, 0x1010, 0x210d, 0x1007, 0x20cd, 0x22c6, 0x2341, 0x2344, 0x2303, 0x208d, 0x2345, 0x220a, - 0x218b, 0x2288, 0x2287, 0x2382, 0x2304, 0x204b, 0x210c, 0x22c1, 0x20cc, 0x204d, 0x2302, 0x21cb, 0x20ce, 0x214c, 0x214d, 0x2384, - 0x210e, 0x22c7, 0x2383, 0x2305, 0x2346, 0x2306, 0x1200, 0x22c8, 0x208c, 0x2249, 0x2385, 0x218d, 0x228a, 0x23c2, 0x220b, 0x224a, - 0x2386, 0x2289, 0x214e, 0x22c9, 0x2381, 0x208e, 0x218c, 0x204c, 0x2348, 0x1008, 0x2347, 0x21cc, 0x2307, 0x21cd, 0x23c3, 0x2301, - 0x218e, 0x208f, 0x23c5, 0x23c4, 0x204e, 0x224b, 0x210f, 0x2387, 0x220d, 0x2349, 0x220c, 0x214f, 0x20cf, 0x228b, 0x22ca, 0x2308, - 0x23c6, 0x23c7, 0x220e, 0x23c1, 0x21ce, 0x1240, 0x1009, 0x224d, 0x224c, 0x2309, 0x2388, 0x228d, 0x2389, 0x230a, 0x218f, 0x21cf, - 0x224e, 0x23c8, 0x22cb, 0x22ce, 0x204f, 0x228c, 0x228e, 0x234b, 0x234a, 0x22cd, 0x22cc, 0x220f, 0x238b, 0x234c, 0x230d, 0x23c9, - 0x238a, 0x1280, 0x230b, 0x224f, 0x100a, 0x230c, 0x12c0, 0x230e, 0x228f, 0x234d, 0x100d, 0x238c, 0x23ca, 0x23cb, 0x22cf, 0x238d, - 0x1340, 0x100b, 0x234e, 0x23cc, 0x23cd, 0x230f, 0x1380, 0x238e, 0x234f, 0x1300, 0x238f, 0x100e, 0x100c, 0x23ce, 0x13c0, 0x100f, - 0x23cf, -}; - -const HuffInfo huffTabScaleFactInfo PROGMEM = - {19, { 1, 0, 1, 3, 2, 4, 3, 5, 4, 6, 6, 6, 5, 8, 4, 7, 3, 7, 46, 0}, 0}; - -/* note - includes offset of -60 (4.6.2.3 in spec) */ -const signed short huffTabScaleFact[121] PROGMEM = { - /* scale factor table [121] */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, 6, -6, 7, -7, 8, - -8, 9, -9, 10, -10, -11, 11, 12, -12, 13, -13, 14, -14, 16, 15, 17, - 18, -15, -17, -16, 19, -18, -19, 20, -20, 21, -21, 22, -22, 23, -23, -25, - 25, -27, -24, -26, 24, -28, 27, 29, -30, -29, 26, -31, -34, -33, -32, -36, - 28, -35, -38, -37, 30, -39, -41, -57, -59, -58, -60, 38, 39, 40, 41, 42, - 57, 37, 31, 32, 33, 34, 35, 36, 44, 51, 52, 53, 54, 55, 56, 50, - 45, 46, 47, 48, 49, 58, -54, -52, -51, -50, -55, 43, 60, 59, -56, -53, - -45, -44, -42, -40, -43, -49, -48, -46, -47, -}; - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/imdct.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/imdct.c deleted file mode 100644 index 1ff9e4ab..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/imdct.c +++ /dev/null @@ -1,589 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: imdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * imdct.c - inverse MDCT - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define RND_VAL (1 << (FBITS_OUT_IMDCT-1)) - -#ifndef AAC_ENABLE_SBR - -/************************************************************************************** - * Function: DecWindowOverlap - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-LONG - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ -/*__attribute__ ((section (".data")))*/ static void DecWindowOverlap(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - if (winTypeCurr == winTypePrev) { - /* cut window loads in half since current and overlap sections use same symmetric window */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } else { - /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */ - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStart - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-START - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data")))*/ static void DecWindowOverlapLongStart(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - in = *buf1--; - - *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */ - *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */ - } while (--i); - - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */ - w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */ - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */ - *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */ - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStop - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence LONG-STOP - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data")))*/ static void DecWindowOverlapLongStop(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - pcm1 = pcm0 + (1024 - 1) * nChans; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - /* Wn = 0 for n = (0, 1, ... 447) */ - /* Wn = 1 for n = (576, 577, ... 1023) */ - in = *buf0++; - f1 = in >> 1; /* scale since skipping multiply by Q31 */ - - in = *over0; - *pcm0 = CLIPTOSHORT( (in + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (--i); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapShort - * - * Description: apply synthesis window, do overlap-add, clip to 16-bit PCM, - * for winSequence EIGHT-SHORT (does all 8 short blocks) - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * number of channels - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 16-bit PCM, interleaved by nChans - * - * Return: none - * - * Notes: this processes one channel at a time, but skips every other sample in - * the output buffer (pcm) for stereo interleaving - * this should fit in registers on ARM - * - * TODO: ARM5E version with saturating overlap/add (QADD) - * asm code with free pointer updates, better load scheduling - **************************************************************************************/ - /*__attribute__ ((section (".data"))) */ static void DecWindowOverlapShort(int *buf0, int *over0, short *pcm0, int nChans, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1; - short *pcm1; - const int *wndPrev, *wndCurr; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* pcm[0-447] = 0 + overlap[0-447] */ - i = 448; - do { - f0 = *over0++; - f1 = *over0++; - *pcm0 = CLIPTOSHORT( (f0 + RND_VAL) >> FBITS_OUT_IMDCT ); pcm0 += nChans; - *pcm0 = CLIPTOSHORT( (f1 + RND_VAL) >> FBITS_OUT_IMDCT ); pcm0 += nChans; - i -= 2; - } while (i); - - /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */ - pcm1 = pcm0 + (128 - 1) * nChans; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *over1; - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - /* save over0/over1 for next short block, in the slots just vacated */ - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - - /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703] - * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831] - * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959] - */ - for (i = 0; i < 3; i++) { - pcm0 += 64 * nChans; - pcm1 = pcm0 + (128 - 1) * nChans; - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 - 128); /* from last short block */ - in += *(over0 + 0); /* from last full frame */ - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *(over1 - 128); /* from last short block */ - in += *(over1 + 0); /* from last full frame */ - *pcm1 = CLIPTOSHORT( (in + f1 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm1 -= nChans; - - /* save over0/over1 for next short block, in the slots just vacated */ - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023] - * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127] - */ - pcm0 += 64 * nChans; - over0 -= 832; /* points at overlap[64] */ - over1 = over0 + 128 - 1; /* points at overlap[191] */ - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 + 768); /* from last short block */ - in += *(over0 + 896); /* from last full frame */ - *pcm0 = CLIPTOSHORT( (in - f0 + RND_VAL) >> FBITS_OUT_IMDCT ); - pcm0 += nChans; - - in = *(over1 + 768); /* from last short block */ - *(over1 - 128) = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */ - *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */ - } while (over0 < over1); - - /* over0 now points at overlap[128] */ - - /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127] - * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127] - * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127] - * over[448-576] = Wc[128-255] * block7[128-255] - */ - for (i = 0; i < 3; i++) { - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - /* from last short block */ - *(over0 - 128) -= f0; - *(over1 - 128)+= f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* over[576-1024] = 0 */ - i = 448; - over0 += 64; - do { - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - i -= 4; - } while (i); -} - -#endif /* !AAC_ENABLE_SBR */ - -/************************************************************************************** - * Function: IMDCT - * - * Description: inverse transform and convert to 16-bit PCM - * - * Inputs: valid AACDecInfo struct - * index of current channel (0 for SCE/LFE, 0 or 1 for CPE) - * output channel (range = [0, nChans-1]) - * - * Outputs: complete frame of decoded PCM, after inverse transform - * - * Return: 0 if successful, -1 if error - * - * Notes: If AAC_ENABLE_SBR is defined at compile time then window + overlap - * does NOT clip to 16-bit PCM and does NOT interleave channels - * If AAC_ENABLE_SBR is NOT defined at compile time, then window + overlap - * does clip to 16-bit PCM and interleaves channels - * If SBR is enabled at compile time, but we don't know whether it is - * actually used for this frame (e.g. the first frame of a stream), - * we need to produce both clipped 16-bit PCM in outbuf AND - * unclipped 32-bit PCM in the SBR input buffer. In this case we make - * a separate pass over the 32-bit PCM to produce 16-bit PCM output. - * This inflicts a slight performance hit when decoding non-SBR files. - **************************************************************************************/ -int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf) -{ - int i; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - outbuf += chOut; - - /* optimized type-IV DCT (operates inplace) */ - if (icsInfo->winSequence == 2) { - /* 8 short blocks */ - for (i = 0; i < 8; i++) - DCT4(0, psi->coef[ch] + i*128, psi->gbCurrent[ch]); - } else { - /* 1 long block */ - DCT4(1, psi->coef[ch], psi->gbCurrent[ch]); - } - -#ifdef AAC_ENABLE_SBR - /* window, overlap-add, don't clip to short (send to SBR decoder) - * store the decoded 32-bit samples in top half (second AAC_MAX_NSAMPS samples) of coef buffer - */ - if (icsInfo->winSequence == 0) - DecWindowOverlapNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 1) - DecWindowOverlapLongStartNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 2) - DecWindowOverlapShortNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 3) - DecWindowOverlapLongStopNoClip(psi->coef[ch], psi->overlap[chOut], psi->sbrWorkBuf[ch], icsInfo->winShape, psi->prevWinShape[chOut]); - - if (!aacDecInfo->sbrEnabled) { - for (i = 0; i < AAC_MAX_NSAMPS; i++) { - *outbuf = CLIPTOSHORT((psi->sbrWorkBuf[ch][i] + RND_VAL) >> FBITS_OUT_IMDCT); - outbuf += aacDecInfo->nChans; - } - } - - aacDecInfo->rawSampleBuf[ch] = psi->sbrWorkBuf[ch]; - aacDecInfo->rawSampleBytes = sizeof(int); - aacDecInfo->rawSampleFBits = FBITS_OUT_IMDCT; -#else - /* window, overlap-add, round to PCM - optimized for each window sequence */ - if (icsInfo->winSequence == 0) - DecWindowOverlap(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 1) - DecWindowOverlapLongStart(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 2) - DecWindowOverlapShort(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - else if (icsInfo->winSequence == 3) - DecWindowOverlapLongStop(psi->coef[ch], psi->overlap[chOut], outbuf, aacDecInfo->nChans, icsInfo->winShape, psi->prevWinShape[chOut]); - - aacDecInfo->rawSampleBuf[ch] = 0; - aacDecInfo->rawSampleBytes = 0; - aacDecInfo->rawSampleFBits = 0; -#endif - - psi->prevWinShape[chOut] = icsInfo->winShape; - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/noiseless.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/noiseless.c deleted file mode 100644 index 5d3a65df..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/noiseless.c +++ /dev/null @@ -1,484 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: noiseless.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * noiseless.c - decode channel info, scalefactors, quantized coefficients, - * scalefactor band codebook, and TNS coefficients from bitstream - **************************************************************************************/ - -#include "coder.h" - -//#include "profile.h" - -//#define PROFILE_START(x) -//#define PROFILE_END() - -/************************************************************************************** - * Function: DecodeICSInfo - * - * Description: decode individual channel stream info - * - * Inputs: BitStreamInfo struct pointing to start of ICS info - * (14496-3, table 4.4.6) - * sample rate index - * - * Outputs: updated icsInfo struct - * - * Return: none - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ void DecodeICSInfo(BitStreamInfo *bsi, ICSInfo *icsInfo, int sampRateIdx) -{ - int sfb, g, mask; - - icsInfo->icsResBit = GetBits(bsi, 1); - icsInfo->winSequence = GetBits(bsi, 2); - icsInfo->winShape = GetBits(bsi, 1); - if (icsInfo->winSequence == 2) { - /* short block */ - icsInfo->maxSFB = GetBits(bsi, 4); - icsInfo->sfGroup = GetBits(bsi, 7); - icsInfo->numWinGroup = 1; - icsInfo->winGroupLen[0] = 1; - mask = 0x40; /* start with bit 6 */ - for (g = 0; g < 7; g++) { - if (icsInfo->sfGroup & mask) { - icsInfo->winGroupLen[icsInfo->numWinGroup - 1]++; - } else { - icsInfo->numWinGroup++; - icsInfo->winGroupLen[icsInfo->numWinGroup - 1] = 1; - } - mask >>= 1; - } - } else { - /* long block */ - icsInfo->maxSFB = GetBits(bsi, 6); - icsInfo->predictorDataPresent = GetBits(bsi, 1); - if (icsInfo->predictorDataPresent) { - icsInfo->predictorReset = GetBits(bsi, 1); - if (icsInfo->predictorReset) - icsInfo->predictorResetGroupNum = GetBits(bsi, 5); - for (sfb = 0; sfb < MIN(icsInfo->maxSFB, predSFBMax[sampRateIdx]); sfb++) - icsInfo->predictionUsed[sfb] = GetBits(bsi, 1); - } - icsInfo->numWinGroup = 1; - icsInfo->winGroupLen[0] = 1; - } -} - -/************************************************************************************** - * Function: DecodeSectionData - * - * Description: decode section data (scale factor band groupings and - * associated Huffman codebooks) - * - * Inputs: BitStreamInfo struct pointing to start of ICS info - * (14496-3, table 4.4.25) - * window sequence (short or long blocks) - * number of window groups (1 for long blocks, 1-8 for short blocks) - * max coded scalefactor band - * - * Outputs: index of Huffman codebook for each scalefactor band in each section - * - * Return: none - * - * Notes: sectCB, sectEnd, sfbCodeBook, ordered by window groups for short blocks - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodeSectionData(BitStreamInfo *bsi, int winSequence, int numWinGrp, int maxSFB, unsigned char *sfbCodeBook) -{ - int g, cb, sfb; - int sectLen, sectLenBits, sectLenIncr, sectEscapeVal; - - sectLenBits = (winSequence == 2 ? 3 : 5); - sectEscapeVal = (1 << sectLenBits) - 1; - - for (g = 0; g < numWinGrp; g++) { - sfb = 0; - while (sfb < maxSFB) { - cb = GetBits(bsi, 4); /* next section codebook */ - sectLen = 0; - do { - sectLenIncr = GetBits(bsi, sectLenBits); - sectLen += sectLenIncr; - } while (sectLenIncr == sectEscapeVal); - - sfb += sectLen; - while (sectLen--) - *sfbCodeBook++ = (unsigned char)cb; - } - ASSERT(sfb == maxSFB); - } -} - -/************************************************************************************** - * Function: DecodeOneScaleFactor - * - * Description: decode one scalefactor using scalefactor Huffman codebook - * - * Inputs: BitStreamInfo struct pointing to start of next coded scalefactor - * - * Outputs: updated BitstreamInfo struct - * - * Return: one decoded scalefactor, including index_offset of -60 - **************************************************************************************/ -static int DecodeOneScaleFactor(BitStreamInfo *bsi) -{ - int nBits, val; - unsigned int bitBuf; - - /* decode next scalefactor from bitstream */ - bitBuf = GetBitsNoAdvance(bsi, huffTabScaleFactInfo.maxBits) << (32 - huffTabScaleFactInfo.maxBits); - //PROFILE_START("DecodeHuffmanScalar"); - nBits = DecodeHuffmanScalar(huffTabScaleFact, &huffTabScaleFactInfo, bitBuf, &val); - AdvanceBitstream(bsi, nBits); - //PROFILE_END(); - return val; -} - -/************************************************************************************** - * Function: DecodeScaleFactors - * - * Description: decode scalefactors, PNS energy, and intensity stereo weights - * - * Inputs: BitStreamInfo struct pointing to start of ICS info - * (14496-3, table 4.4.26) - * number of window groups (1 for long blocks, 1-8 for short blocks) - * max coded scalefactor band - * global gain (starting value for differential scalefactor coding) - * index of Huffman codebook for each scalefactor band in each section - * - * Outputs: decoded scalefactor for each section - * - * Return: none - * - * Notes: sfbCodeBook, scaleFactors ordered by window groups for short blocks - * for section with codebook 13, scaleFactors buffer has decoded PNS - * energy instead of regular scalefactor - * for section with codebook 14 or 15, scaleFactors buffer has intensity - * stereo weight instead of regular scalefactor - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodeScaleFactors(BitStreamInfo *bsi, int numWinGrp, int maxSFB, int globalGain, - unsigned char *sfbCodeBook, short *scaleFactors) -{ - int g, sfbCB, nrg, npf, val, sf, is; - - /* starting values for differential coding */ - sf = globalGain; - is = 0; - nrg = globalGain - 90 - 256; - npf = 1; - - for (g = 0; g < numWinGrp * maxSFB; g++) { - sfbCB = *sfbCodeBook++; - - if (sfbCB == 14 || sfbCB == 15) { - /* intensity stereo - differential coding */ - val = DecodeOneScaleFactor(bsi); - is += val; - *scaleFactors++ = (short)is; - } else if (sfbCB == 13) { - /* PNS - first energy is directly coded, rest are Huffman coded (npf = noise_pcm_flag) */ - if (npf) { - val = GetBits(bsi, 9); - npf = 0; - } else { - val = DecodeOneScaleFactor(bsi); - } - nrg += val; - *scaleFactors++ = (short)nrg; - } else if (sfbCB >= 1 && sfbCB <= 11) { - /* regular (non-zero) region - differential coding */ - val = DecodeOneScaleFactor(bsi); - sf += val; - *scaleFactors++ = (short)sf; - } else { - /* inactive scalefactor band if codebook 0 */ - *scaleFactors++ = 0; - } - } -} - -/************************************************************************************** - * Function: DecodePulseInfo - * - * Description: decode pulse information - * - * Inputs: BitStreamInfo struct pointing to start of pulse info - * (14496-3, table 4.4.7) - * - * Outputs: updated PulseInfo struct - * - * Return: none - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodePulseInfo(BitStreamInfo *bsi, PulseInfo *pi) -{ - int i; - - pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */ - pi->startSFB = GetBits(bsi, 6); - for (i = 0; i < pi->numPulse; i++) { - pi->offset[i] = GetBits(bsi, 5); - pi->amp[i] = GetBits(bsi, 4); - } -} - -/************************************************************************************** - * Function: DecodeTNSInfo - * - * Description: decode TNS filter information - * - * Inputs: BitStreamInfo struct pointing to start of TNS info - * (14496-3, table 4.4.27) - * window sequence (short or long blocks) - * - * Outputs: updated TNSInfo struct - * buffer of decoded (signed) TNS filter coefficients - * - * Return: none - **************************************************************************************/ -static const signed char sgnMask[3] = {0x02, 0x04, 0x08}; -static const signed char negMask[3] = {~0x03, ~0x07, ~0x0f}; - -static void DecodeTNSInfo(BitStreamInfo *bsi, int winSequence, TNSInfo *ti, signed char *tnsCoef) -{ - int i, w, f, coefBits, compress; - signed char c, s, n; - - unsigned char *filtLength, *filtOrder, *filtDir; - - filtLength = ti->length; - filtOrder = ti->order; - filtDir = ti->dir; - - if (winSequence == 2) { - /* short blocks */ - for (w = 0; w < NWINDOWS_SHORT; w++) { - ti->numFilt[w] = GetBits(bsi, 1); - if (ti->numFilt[w]) { - ti->coefRes[w] = GetBits(bsi, 1) + 3; - *filtLength = GetBits(bsi, 4); - *filtOrder = GetBits(bsi, 3); - if (*filtOrder) { - *filtDir++ = GetBits(bsi, 1); - compress = GetBits(bsi, 1); - coefBits = (int)ti->coefRes[w] - compress; /* 2, 3, or 4 */ - s = sgnMask[coefBits - 2]; - n = negMask[coefBits - 2]; - for (i = 0; i < *filtOrder; i++) { - c = GetBits(bsi, coefBits); - if (c & s) c |= n; - *tnsCoef++ = c; - } - } - filtLength++; - filtOrder++; - } - } - } else { - /* long blocks */ - ti->numFilt[0] = GetBits(bsi, 2); - if (ti->numFilt[0]) - ti->coefRes[0] = GetBits(bsi, 1) + 3; - for (f = 0; f < ti->numFilt[0]; f++) { - *filtLength = GetBits(bsi, 6); - *filtOrder = GetBits(bsi, 5); - if (*filtOrder) { - *filtDir++ = GetBits(bsi, 1); - compress = GetBits(bsi, 1); - coefBits = (int)ti->coefRes[0] - compress; /* 2, 3, or 4 */ - s = sgnMask[coefBits - 2]; - n = negMask[coefBits - 2]; - for (i = 0; i < *filtOrder; i++) { - c = GetBits(bsi, coefBits); - if (c & s) c |= n; - *tnsCoef++ = c; - } - } - filtLength++; - filtOrder++; - } - } -} - -/* bitstream field lengths for gain control data: - * gainBits[winSequence][0] = maxWindow (how many gain windows there are) - * gainBits[winSequence][1] = locBitsZero (bits for alocCode if window == 0) - * gainBits[winSequence][2] = locBits (bits for alocCode if window != 0) - */ -static const unsigned char gainBits[4][3] = { - {1, 5, 5}, /* long */ - {2, 4, 2}, /* start */ - {8, 2, 2}, /* short */ - {2, 4, 5}, /* stop */ -}; - -/************************************************************************************** - * Function: DecodeGainControlInfo - * - * Description: decode gain control information (SSR profile only) - * - * Inputs: BitStreamInfo struct pointing to start of gain control info - * (14496-3, table 4.4.12) - * window sequence (short or long blocks) - * - * Outputs: updated GainControlInfo struct - * - * Return: none - **************************************************************************************/ -static void DecodeGainControlInfo(BitStreamInfo *bsi, int winSequence, GainControlInfo *gi) -{ - int bd, wd, ad; - int locBits, locBitsZero, maxWin; - - gi->maxBand = GetBits(bsi, 2); - maxWin = (int)gainBits[winSequence][0]; - locBitsZero = (int)gainBits[winSequence][1]; - locBits = (int)gainBits[winSequence][2]; - - for (bd = 1; bd <= gi->maxBand; bd++) { - for (wd = 0; wd < maxWin; wd++) { - gi->adjNum[bd][wd] = GetBits(bsi, 3); - for (ad = 0; ad < gi->adjNum[bd][wd]; ad++) { - gi->alevCode[bd][wd][ad] = GetBits(bsi, 4); - gi->alocCode[bd][wd][ad] = GetBits(bsi, (wd == 0 ? locBitsZero : locBits)); - } - } - } -} - -/************************************************************************************** - * Function: DecodeICS - * - * Description: decode individual channel stream - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of individual channel stream - * (14496-3, table 4.4.24) - * index of current channel - * - * Outputs: updated section data, scale factor data, pulse data, TNS data, - * and gain control data - * - * Return: none - **************************************************************************************/ -static void DecodeICS(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int globalGain; - ICSInfo *icsInfo; - PulseInfo *pi; - TNSInfo *ti; - GainControlInfo *gi; - - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - globalGain = GetBits(bsi, 8); - if (!psi->commonWin) - DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx); - - DecodeSectionData(bsi, icsInfo->winSequence, icsInfo->numWinGroup, icsInfo->maxSFB, psi->sfbCodeBook[ch]); - - DecodeScaleFactors(bsi, icsInfo->numWinGroup, icsInfo->maxSFB, globalGain, psi->sfbCodeBook[ch], psi->scaleFactors[ch]); - - pi = &psi->pulseInfo[ch]; - pi->pulseDataPresent = GetBits(bsi, 1); - if (pi->pulseDataPresent) - DecodePulseInfo(bsi, pi); - - ti = &psi->tnsInfo[ch]; - ti->tnsDataPresent = GetBits(bsi, 1); - if (ti->tnsDataPresent) - DecodeTNSInfo(bsi, icsInfo->winSequence, ti, ti->coef); - - gi = &psi->gainControlInfo[ch]; - gi->gainControlDataPresent = GetBits(bsi, 1); - if (gi->gainControlDataPresent) - DecodeGainControlInfo(bsi, icsInfo->winSequence, gi); -} - -/************************************************************************************** - * Function: DecodeNoiselessData - * - * Description: decode noiseless data (side info and transform coefficients) - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer pointing to start of individual channel stream - * (14496-3, table 4.4.24) - * pointer to bit offset - * pointer to number of valid bits remaining in buf - * index of current channel - * - * Outputs: updated global gain, section data, scale factor data, pulse data, - * TNS data, gain control data, and spectral data - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch) -{ - int bitsUsed; - BitStreamInfo bsi; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - SetBitstreamPointer(&bsi, (*bitsAvail+7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - DecodeICS(psi, &bsi, ch); - - if (icsInfo->winSequence == 2) - DecodeSpectrumShort(psi, &bsi, ch); - else - DecodeSpectrumLong(psi, &bsi, ch); - - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += ((bitsUsed + *bitOffset) >> 3); - *bitOffset = ((bitsUsed + *bitOffset) & 0x07); - *bitsAvail -= bitsUsed; - - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - aacDecInfo->tnsUsed |= psi->tnsInfo[ch].tnsDataPresent; /* set flag if TNS used for any channel */ - - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/pns.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/pns.c deleted file mode 100644 index 3594c76d..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/pns.c +++ /dev/null @@ -1,357 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: pns.c,v 1.2 2005/03/10 17:01:56 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * pns.c - perceptual noise substitution - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: Get32BitVal - * - * Description: generate 32-bit unsigned random number - * - * Inputs: last number calculated (seed, first time through) - * - * Outputs: new number, saved in *last - * - * Return: 32-bit number, uniformly distributed between [0, 2^32) - * - * Notes: uses simple linear congruential generator - **************************************************************************************/ -static unsigned int Get32BitVal(unsigned int *last) -{ - unsigned int r = *last; - - /* use same coefs as MPEG reference code (classic LCG) - * use unsigned multiply to force reliable wraparound behavior in C (mod 2^32) - */ - r = (1664525U * r) + 1013904223U; - *last = r; - - return r; -} - - -#define NUM_ITER_INVSQRT 4 - -#define X0_COEF_2 0xc0000000 /* Q29: -2.0 */ -#define X0_OFF_2 0x60000000 /* Q29: 3.0 */ -#define Q26_3 0x0c000000 /* Q26: 3.0 */ - -/************************************************************************************** - * Function: InvRootR - * - * Description: use Newton's method to solve for x = 1/sqrt(r) - * - * Inputs: r in Q30 format, range = [0.25, 1] (normalize inputs to this range) - * - * Outputs: none - * - * Return: x = Q29, range = (1, 2) - * - * Notes: guaranteed to converge and not overflow for any r in this range - * - * xn+1 = xn - f(xn)/f'(xn) - * f(x) = 1/sqrt(r) - x = 0 (find root) - * = 1/x^2 - r - * f'(x) = -2/x^3 - * - * so xn+1 = xn/2 * (3 - r*xn^2) - * - * NUM_ITER_INVSQRT = 3, maxDiff = 1.3747e-02 - * NUM_ITER_INVSQRT = 4, maxDiff = 3.9832e-04 - **************************************************************************************/ -static int InvRootR(int r) -{ - int i, xn, t; - - /* use linear equation for initial guess - * x0 = -2*r + 3 (so x0 always >= correct answer in range [0.25, 1)) - * xn = Q29 (at every step) - */ - xn = (MULSHIFT32(r, X0_COEF_2) << 2) + X0_OFF_2; - - for (i = 0; i < NUM_ITER_INVSQRT; i++) { - t = MULSHIFT32(xn, xn); /* Q26 = Q29*Q29 */ - t = Q26_3 - (MULSHIFT32(r, t) << 2); /* Q26 = Q26 - (Q31*Q26 << 1) */ - xn = MULSHIFT32(xn, t) << (6 - 1); /* Q29 = (Q29*Q26 << 6), and -1 for division by 2 */ - } - - /* clip to range (1.0, 2.0) - * (because of rounding, this can converge to xn slightly > 2.0 when r is near 0.25) - */ - if (xn >> 30) - xn = (1 << 30) - 1; - - return xn; -} - -/************************************************************************************** - * Function: ScaleNoiseVector - * - * Description: apply scaling to vector of noise coefficients for one scalefactor band - * - * Inputs: unscaled coefficients - * number of coefficients in vector (one scalefactor band of coefs) - * scalefactor for this band (i.e. noise energy) - * - * Outputs: nVals coefficients in Q(FBITS_OUT_DQ_OFF) - * - * Return: guard bit mask (OR of abs value of all noise coefs) - **************************************************************************************/ -static int ScaleNoiseVector(int *coef, int nVals, int sf) -{ - -/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */ -static const int pow14[4] PROGMEM = { - 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 -}; - - int i, c, spec, energy, sq, scalef, scalei, invSqrtEnergy, z, gbMask; - - energy = 0; - for (i = 0; i < nVals; i++) { - spec = coef[i]; - - /* max nVals = max SFB width = 96, so energy can gain < 2^7 bits in accumulation */ - sq = (spec * spec) >> 8; /* spec*spec range = (-2^30, 2^30) */ - energy += sq; - } - - /* unless nVals == 1 (or the number generator is broken...), this should not happen */ - if (energy == 0) - return 0; /* coef[i] must = 0 for i = [0, nVals-1], so gbMask = 0 */ - - /* pow(2, sf/4) * pow(2, FBITS_OUT_DQ_OFF) */ - scalef = pow14[sf & 0x3]; - scalei = (sf >> 2) + FBITS_OUT_DQ_OFF; - - /* energy has implied factor of 2^-8 since we shifted the accumulator - * normalize energy to range [0.25, 1.0), calculate 1/sqrt(1), and denormalize - * i.e. divide input by 2^(30-z) and convert to Q30 - * output of 1/sqrt(i) now has extra factor of 2^((30-z)/2) - * for energy > 0, z is an even number between 0 and 28 - * final scaling of invSqrtEnergy: - * 2^(15 - z/2) to compensate for implicit 2^(30-z) factor in input - * +4 to compensate for implicit 2^-8 factor in input - */ - z = CLZ(energy) - 2; /* energy has at least 2 leading zeros (see acc loop) */ - z &= 0xfffffffe; /* force even */ - invSqrtEnergy = InvRootR(energy << z); /* energy << z must be in range [0x10000000, 0x40000000] */ - scalei -= (15 - z/2 + 4); /* nInt = 1/sqrt(energy) in Q29 */ - - /* normalize for final scaling */ - z = CLZ(invSqrtEnergy) - 1; - invSqrtEnergy <<= z; - scalei -= (z - 3 - 2); /* -2 for scalef, z-3 for invSqrtEnergy */ - scalef = MULSHIFT32(scalef, invSqrtEnergy); /* scalef (input) = Q30, invSqrtEnergy = Q29 * 2^z */ - gbMask = 0; - - if (scalei < 0) { - scalei = -scalei; - if (scalei > 31) - scalei = 31; - for (i = 0; i < nVals; i++) { - c = MULSHIFT32(coef[i], scalef) >> scalei; - gbMask |= FASTABS(c); - coef[i] = c; - } - } else { - /* for scalei <= 16, no clipping possible (coef[i] is < 2^15 before scaling) - * for scalei > 16, just saturate exponent (rare) - * scalef is close to full-scale (since we normalized invSqrtEnergy) - * remember, we are just producing noise here - */ - if (scalei > 16) - scalei = 16; - for (i = 0; i < nVals; i++) { - c = MULSHIFT32(coef[i] << scalei, scalef); - coef[i] = c; - gbMask |= FASTABS(c); - } - } - - return gbMask; -} - -/************************************************************************************** - * Function: GenerateNoiseVector - * - * Description: create vector of noise coefficients for one scalefactor band - * - * Inputs: seed for number generator - * number of coefficients to generate - * - * Outputs: buffer of nVals coefficients, range = [-2^15, 2^15) - * updated seed for number generator - * - * Return: none - **************************************************************************************/ -static void GenerateNoiseVector(int *coef, int *last, int nVals) -{ - int i; - - for (i = 0; i < nVals; i++) - coef[i] = ((signed int)Get32BitVal((unsigned int *)last)) >> 16; -} - -/************************************************************************************** - * Function: CopyNoiseVector - * - * Description: copy vector of noise coefficients for one scalefactor band from L to R - * - * Inputs: buffer of left coefficients - * number of coefficients to copy - * - * Outputs: buffer of right coefficients - * - * Return: none - **************************************************************************************/ -static void CopyNoiseVector(int *coefL, int *coefR, int nVals) -{ - int i; - - for (i = 0; i < nVals; i++) - coefR[i] = coefL[i]; -} - -/************************************************************************************** - * Function: PNS - * - * Description: apply perceptual noise substitution, if enabled (MPEG-4 only) - * - * Inputs: valid AACDecInfo struct - * index of current channel - * - * Outputs: shaped noise in scalefactor bands where PNS is active - * updated minimum guard bit count for this channel - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int PNS(AACDecInfo *aacDecInfo, int ch) -{ - int gp, sfb, win, width, nSamps, gb, gbMask; - int *coef; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - short *scaleFactors; - int msMaskOffset, checkCorr, genNew; - unsigned char msMask; - unsigned char *msMaskPtr; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - if (!psi->pnsUsed[ch]) - return 0; - - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coef = psi->coef[ch]; - sfbCodeBook = psi->sfbCodeBook[ch]; - scaleFactors = psi->scaleFactors[ch]; - checkCorr = (aacDecInfo->currBlockID == AAC_ID_CPE && psi->commonWin == 1 ? 1 : 0); - - gbMask = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - msMaskPtr = psi->msMaskBits + ((gp*icsInfo->maxSFB) >> 3); - msMaskOffset = ((gp*icsInfo->maxSFB) & 0x07); - msMask = (*msMaskPtr++) >> msMaskOffset; - - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - width = sfbTab[sfb+1] - sfbTab[sfb]; - if (sfbCodeBook[sfb] == 13) { - if (ch == 0) { - /* generate new vector, copy into ch 1 if it's possible that the channels will be correlated - * if ch 1 has PNS enabled for this SFB but it's uncorrelated (i.e. ms_used == 0), - * the copied values will be overwritten when we process ch 1 - */ - GenerateNoiseVector(coef, &psi->pnsLastVal, width); - if (checkCorr && psi->sfbCodeBook[1][gp*icsInfo->maxSFB + sfb] == 13) - CopyNoiseVector(coef, psi->coef[1] + (coef - psi->coef[0]), width); - } else { - /* generate new vector if no correlation between channels */ - genNew = 1; - if (checkCorr && psi->sfbCodeBook[0][gp*icsInfo->maxSFB + sfb] == 13) { - if ( (psi->msMaskPresent == 1 && (msMask & 0x01)) || psi->msMaskPresent == 2 ) - genNew = 0; - } - if (genNew) - GenerateNoiseVector(coef, &psi->pnsLastVal, width); - } - gbMask |= ScaleNoiseVector(coef, width, psi->scaleFactors[ch][gp*icsInfo->maxSFB + sfb]); - } - coef += width; - - /* get next mask bit (should be branchless on ARM) */ - msMask >>= 1; - if (++msMaskOffset == 8) { - msMask = *msMaskPtr++; - msMaskOffset = 0; - } - } - coef += (nSamps - sfbTab[icsInfo->maxSFB]); - } - sfbCodeBook += icsInfo->maxSFB; - scaleFactors += icsInfo->maxSFB; - } - - /* update guard bit count if necessary */ - gb = CLZ(gbMask) - 1; - if (psi->gbCurrent[ch] > gb) - psi->gbCurrent[ch] = gb; - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/readme.txt b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/readme.txt deleted file mode 100644 index de4ca0ee..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/readme.txt +++ /dev/null @@ -1,127 +0,0 @@ -Fixed-point HE-AAC decoder -Developed by RealNetworks, 2005 -=============================== - -Overview --------- -This module contains a high-performance HE-AAC decoder for 32-bit fixed-point -processors. The following is a summary of what is and is not supported: - -Supported: - - MPEG2, MPEG4 low complexity decoding (intensity stereo, M-S, TNS, PNS) - - spectral band replication (SBR), high-quality mode - - mono, stereo, and multichannel modes - - ADTS, ADIF, and raw data block file formats - -Not currently supported: - - main or SSR profile, LTP - - coupling channel elements (CCE) - - 960/1920-sample frame size - - low-power mode SBR - - downsampled (single-rate) SBR - - parametric stereo - -Highlights ----------- - - highly optimized for ARM processors (details in docs/ subdirectory) - - reference x86 implementation - - C and assembly code only (C++ not required for codec library) - - reentrant, statically linkable - - low memory (details in docs/ subdirectory) - - option to use Intel Integrated Performance Primitives (details below) - -Supported platforms and toolchains ----------------------------------- -This codec should run on any 32-bit fixed-point processor which can perform a full 32x32-bit -multiply (providing a 64-bit result). The following processors and toolchains are supported: - - x86, Microsoft Visual C++ - - x86, GNU toolchain (gcc) - - ARM, ARM Developer Suite (ADS) - - ARM, Microsoft Embedded Visual C++ - - ARM, GNU toolchain (gcc) - -ARM refers to any processor supporting ARM architecture v.4 or above. Thumb is not required. - -Generally ADS produces the fastest code. EVC 3 does not support inline assembly code for -ARM targets, so calls to MULSHIFT32 (smull on ARM) are left as function calls. This incurs -a significant performance penalty. For the fastest code on targets which do not normally use -ADS consider compiling with ADS, using the -S option to output assembly code, and -feeding this assembly code to the assembler of your choice. This might require some -syntax changes in the .S file. - -Adding support for a new processor is fairly simple. Simply add a new block to the file -real/assembly.h which implements the required inline assembly functions for your processor. -Something like - -... -#elif defined NEW_PROCESSOR - -/* you implement MULSHIFT32() and so forth */ - -#else -#error Unsupported platform in assembly.h -#endif - -Optionally you can rewrite or add assembly language files optimized for your platform. Note -that many of the algorithms are designed for an ARM-type processor, so performance of the -unmodified C code might be noticeably worse on other architectures. - -Adding support for a new toolchain is straightforward. Use the sample projects or the -Helix makefiles as a template for which source files to include. - -Multichannel ------------- -For multichannel, just set AAC_MAX_NCHANS in pub/aacdec.h to the desired max number -of channels (default = 2) and recompile. This increases RAM usage since more memory -is required to save state for multiple channels. See docs/memory.xls for details. - -Directory structure -------------------- -fixpt/ platform-independent code and tables, public API -fixpt/docs memory and CPU usage figures, callgraphs -fixpt/hxwrap Helix wrapper code and makefiles -fixpt/ipp source code which uses IPP for decoding (see the "IPP" section below) -fixpt/pub public header files -fixpt/real source code for RealNetworks' AAC decoder -fixpt/testwrap sample code to build a command-line test application - -Code organization ------------------ -fixpt/ - aacdec.c main decode functions, exports C-only API - aactabs.c common tables used by all implementations -fixpt/pub/ - aaccommon.h low-level codec API which aacdec.c calls - aacdec.h high-level codec API which applications call - statname.h symbols which get name-mangled by C preprocessor to allow static linking -fixpt/ipp source code for wrapper files which link in IPP libraries -fixpt/real full source code for RealNetworks AAC decoder, including SBR -fixpt/real/asm optimized assembly code files for certain platforms - -To build an AAC decoder library, you'll need to compile the top-level files and EITHER -real/*.c OR ipp/*.c and the appropriate IPP library. - -Decoder using Real code: aacdec.c + aactabs.c + real/*.c + real/asm/[platform]/*.s (if necessary) -Decoder using IPP code: aacdec.c + aactabs.c + ipp/*.c + ippac*.lib - -IPP ---- -For certain platforms Intel® has created highly-optimized object code libraries of DSP -routines. These are called the Intel® Integrated Performance Primitives (IPP). If IPP -libraries are available for a platform, this AAC decoder can link them in and use them -instead of the RealNetworks source code. To use IPP, you still need to build the top-level -files (aacdec.c, aactabs.c). You also build the files in ipp/*.c. These are just thin -wrappers which provide the glue logic between the top-level decode functions in -aacdec.c and the optimized DSP primitives in the IPP libraries. IPP libraries are not -included in this module. You must obtain them WITH A LICENSE directly from Intel. -Further info on the latest versions of IPP (as of the date of this readme) is available -from the URL below: - -http://www.intel.com/software/products/ipp/ - -This site explains how to obtain IPP and the terms under which IPP libraries may be used. -The code in this module is merely wrapper code which calls IPP functions. You are fully -responsible for adhering to the license agreement under which you obtain the IPP -libraries from Intel. - -readme.txt last updated 02/25/05 diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.c deleted file mode 100644 index 691694d0..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.c +++ /dev/null @@ -1,431 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbr.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbr.c - top level functions for SBR - **************************************************************************************/ - -#if defined(USE_DEFAULT_STDLIB) || defined(ESP_PLATFORM) -#include -#include -#else -#include "hlxclib/stdlib.h" -#endif - -#include "sbr.h" - -/************************************************************************************** - * Function: InitSBRState - * - * Description: initialize PSInfoSBR struct at start of stream or after flush - * - * Inputs: valid AACDecInfo struct - * - * Outputs: PSInfoSBR struct with proper initial state - * - * Return: none - **************************************************************************************/ -static void InitSBRState(PSInfoSBR *psi) -{ - int i, ch; - unsigned char *c; - - if (!psi) - return; - - /* clear SBR state structure */ - c = (unsigned char *)psi; - for (i = 0; i < (int)sizeof(PSInfoSBR); i++) - *c++ = 0; - - /* initialize non-zero state variables */ - for (ch = 0; ch < AAC_MAX_NCHANS; ch++) { - psi->sbrChan[ch].reset = 1; - psi->sbrChan[ch].laPrev = -1; - } -} - -/************************************************************************************** - * Function: InitSBR - * - * Description: initialize SBR decoder - * - * Inputs: valid AACDecInfo struct - * - * Outputs: PSInfoSBR struct to hold SBR state information - * - * Return: 0 if successful, error code (< 0) if error - * - * Note: memory allocation for SBR is only done here - **************************************************************************************/ -int InitSBR(AACDecInfo *aacDecInfo) -{ - PSInfoSBR *psi; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* allocate SBR state structure */ - psi = (PSInfoSBR *)malloc(sizeof(PSInfoSBR)); - if (!psi) { - printf("OOM in SBR, can't allocate %d bytes\n", sizeof(PSInfoSBR)); - return ERR_AAC_SBR_INIT; - } - InitSBRState(psi); - - aacDecInfo->psInfoSBR = psi; - return ERR_AAC_NONE; -} - -int InitSBRPre(AACDecInfo *aacDecInfo, void **ptr, int *sz) -{ - PSInfoSBR *psi; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* allocate SBR state structure */ - psi = (PSInfoSBR *)*ptr; - *sz -= sizeof(PSInfoSBR); - if (*sz < 0) { - printf("OOM in SBR, can't allocate %d bytes\n", sizeof(PSInfoSBR)); - return ERR_AAC_SBR_INIT; - } - InitSBRState(psi); - - *ptr = (void*)((char*)(*ptr) + sizeof(PSInfoSBR)); - aacDecInfo->psInfoSBR = psi; - return ERR_AAC_NONE; -} - - - -/************************************************************************************** - * Function: FreeSBR - * - * Description: free SBR decoder - * - * Inputs: valid AACDecInfo struct - * - * Outputs: none - * - * Return: none - * - * Note: memory deallocation for SBR is only done here - **************************************************************************************/ -void FreeSBR(AACDecInfo *aacDecInfo) -{ - if (aacDecInfo && aacDecInfo->psInfoSBR) - free(aacDecInfo->psInfoSBR); - - return; -} - -/************************************************************************************** - * Function: DecodeSBRBitstream - * - * Description: decode sideband information for SBR - * - * Inputs: valid AACDecInfo struct - * fill buffer with SBR extension block - * number of bytes in fill buffer - * base output channel (range = [0, nChans-1]) - * - * Outputs: initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan) - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: SBR payload should be in aacDecInfo->fillBuf - * returns with no error if fill buffer is not an SBR extension block, - * or if current block is not a fill block (e.g. for LFE upsampling) - **************************************************************************************/ -int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase) -{ - int headerFlag; - BitStreamInfo bsi; - PSInfoSBR *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - if (aacDecInfo->currBlockID != AAC_ID_FIL || (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC)) - return ERR_AAC_NONE; - - SetBitstreamPointer(&bsi, aacDecInfo->fillCount, aacDecInfo->fillBuf); - if (GetBits(&bsi, 4) != (unsigned int)aacDecInfo->fillExtType) - return ERR_AAC_SBR_BITSTREAM; - - if (aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) - psi->crcCheckWord = GetBits(&bsi, 10); - - headerFlag = GetBits(&bsi, 1); - if (headerFlag) { - /* get sample rate index for output sample rate (2x base rate) */ - psi->sampRateIdx = GetSampRateIdx(2 * aacDecInfo->sampRate); - if (psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) - return ERR_AAC_SBR_BITSTREAM; - else if (psi->sampRateIdx >= NUM_SAMPLE_RATES_SBR) - return ERR_AAC_SBR_SINGLERATE_UNSUPPORTED; - - /* reset flag = 1 if header values changed */ - if (UnpackSBRHeader(&bsi, &(psi->sbrHdr[chBase]))) - psi->sbrChan[chBase].reset = 1; - - /* first valid SBR header should always trigger CalcFreqTables(), since psi->reset was set in InitSBR() */ - if (psi->sbrChan[chBase].reset) - CalcFreqTables(&(psi->sbrHdr[chBase+0]), &(psi->sbrFreq[chBase]), psi->sampRateIdx); - - /* copy and reset state to right channel for CPE */ - if (aacDecInfo->prevBlockID == AAC_ID_CPE) - psi->sbrChan[chBase+1].reset = psi->sbrChan[chBase+0].reset; - } - - - /* if no header has been received, upsample only */ - if (psi->sbrHdr[chBase].count == 0) - return ERR_AAC_NONE; - - if (aacDecInfo->prevBlockID == AAC_ID_SCE) { - UnpackSBRSingleChannel(&bsi, psi, chBase); - } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) { - UnpackSBRChannelPair(&bsi, psi, chBase); - } else { - return ERR_AAC_SBR_BITSTREAM; - } - - ByteAlignBitstream(&bsi); - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: DecodeSBRData - * - * Description: apply SBR to one frame of PCM data - * - * Inputs: 1024 samples of decoded 32-bit PCM, before SBR - * size of input PCM samples (must be 4 bytes) - * number of fraction bits in input PCM samples - * base output channel (range = [0, nChans-1]) - * initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan) - * - * Outputs: 2048 samples of decoded 16-bit PCM, after SBR - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf) -{ - int k, l, ch, chBlock, qmfaBands, qmfsBands; - int upsampleOnly, gbIdx, gbMask; - int *inbuf; - short *outptr; - PSInfoSBR *psi; - SBRHeader *sbrHdr; - SBRGrid *sbrGrid; - SBRFreq *sbrFreq; - SBRChan *sbrChan; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - /* same header and freq tables for both channels in CPE */ - sbrHdr = &(psi->sbrHdr[chBase]); - sbrFreq = &(psi->sbrFreq[chBase]); - - /* upsample only if we haven't received an SBR header yet or if we have an LFE block */ - if (aacDecInfo->currBlockID == AAC_ID_LFE) { - chBlock = 1; - upsampleOnly = 1; - } else if (aacDecInfo->currBlockID == AAC_ID_FIL) { - if (aacDecInfo->prevBlockID == AAC_ID_SCE) - chBlock = 1; - else if (aacDecInfo->prevBlockID == AAC_ID_CPE) - chBlock = 2; - else - return ERR_AAC_NONE; - - upsampleOnly = (sbrHdr->count == 0 ? 1 : 0); - if (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC) - return ERR_AAC_NONE; - } else { - /* ignore non-SBR blocks */ - return ERR_AAC_NONE; - } - - if (upsampleOnly) { - sbrFreq->kStart = 32; - sbrFreq->numQMFBands = 0; - } - - for (ch = 0; ch < chBlock; ch++) { - sbrGrid = &(psi->sbrGrid[chBase + ch]); - sbrChan = &(psi->sbrChan[chBase + ch]); - - if (aacDecInfo->rawSampleBuf[ch] == 0 || aacDecInfo->rawSampleBytes != 4) - return ERR_AAC_SBR_PCM_FORMAT; - inbuf = (int *)aacDecInfo->rawSampleBuf[ch]; - outptr = outbuf + chBase + ch; - - /* restore delay buffers (could use ring buffer or keep in temp buffer for nChans == 1) */ - for (l = 0; l < HF_GEN; l++) { - for (k = 0; k < 64; k++) { - psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0]; - psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1]; - } - } - - /* step 1 - analysis QMF */ - qmfaBands = sbrFreq->kStart; - for (l = 0; l < 32; l++) { - gbMask = QMFAnalysis(inbuf + l*32, psi->delayQMFA[chBase + ch], psi->XBuf[l + HF_GEN][0], - aacDecInfo->rawSampleFBits, &(psi->delayIdxQMFA[chBase + ch]), qmfaBands); - - gbIdx = ((l + HF_GEN) >> 5) & 0x01; - sbrChan->gbMask[gbIdx] |= gbMask; /* gbIdx = (0 if i < 32), (1 if i >= 32) */ - } - - if (upsampleOnly) { - /* no SBR - just run synthesis QMF to upsample by 2x */ - qmfsBands = 32; - for (l = 0; l < 32; l++) { - /* step 4 - synthesis QMF */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - } else { - /* if previous frame had lower SBR starting freq than current, zero out the synthesized QMF - * bands so they aren't used as sources for patching - * after patch generation, restore from delay buffer - * can only happen after header reset - */ - for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) { - for (l = 0; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) { - psi->XBuf[l][k][0] = 0; - psi->XBuf[l][k][1] = 0; - } - } - - /* step 2 - HF generation */ - GenerateHighFreq(psi, sbrGrid, sbrFreq, sbrChan, ch); - - /* restore SBR bands that were cleared before patch generation (time slots 0, 1 no longer needed) */ - for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) { - for (l = HF_ADJ; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) { - psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0]; - psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1]; - } - } - - /* step 3 - HF adjustment */ - AdjustHighFreq(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch); - - /* step 4 - synthesis QMF */ - qmfsBands = sbrFreq->kStartPrev + sbrFreq->numQMFBandsPrev; - for (l = 0; l < sbrGrid->envTimeBorder[0]; l++) { - /* if new envelope starts mid-frame, use old settings until start of first envelope in this frame */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - - qmfsBands = sbrFreq->kStart + sbrFreq->numQMFBands; - for ( ; l < 32; l++) { - /* use new settings for rest of frame (usually the entire frame, unless the first envelope starts mid-frame) */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - } - - /* save delay */ - for (l = 0; l < HF_GEN; l++) { - for (k = 0; k < 64; k++) { - psi->XBufDelay[chBase + ch][l][k][0] = psi->XBuf[l+32][k][0]; - psi->XBufDelay[chBase + ch][l][k][1] = psi->XBuf[l+32][k][1]; - } - } - sbrChan->gbMask[0] = sbrChan->gbMask[1]; - sbrChan->gbMask[1] = 0; - - if (sbrHdr->count > 0) - sbrChan->reset = 0; - } - sbrFreq->kStartPrev = sbrFreq->kStart; - sbrFreq->numQMFBandsPrev = sbrFreq->numQMFBands; - - if (aacDecInfo->nChans > 0 && (chBase + ch) == aacDecInfo->nChans) - psi->frameCount++; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: FlushCodecSBR - * - * Description: flush internal SBR codec state (after seeking, for example) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables for SBR - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: SBR is heavily dependent on state from previous frames - * (e.g. delta coded scalefactors, previous envelope boundaries, etc.) - * On flush, we reset everything as if SBR had just been initialized - * for the first time. This triggers "upsample-only" mode until - * the first valid SBR header is received. Then SBR starts as usual. - **************************************************************************************/ -int FlushCodecSBR(AACDecInfo *aacDecInfo) -{ - PSInfoSBR *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - InitSBRState(psi); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.h deleted file mode 100644 index 6c898a13..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbr.h +++ /dev/null @@ -1,383 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbr.h,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbr.h - definitions of platform-specific SBR data structures, functions, and tables - **************************************************************************************/ - -#ifndef _SBR_H -#define _SBR_H - -#include "aaccommon.h" -#include "bitstream.h" - -#ifndef ASSERT -#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS)) -#define ASSERT(x) if (!(x)) __asm int 3; -#else -#define ASSERT(x) /* do nothing */ -#endif -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define NUM_TIME_SLOTS 16 -#define SAMPLES_PER_SLOT 2 /* RATE in spec */ -#define NUM_SAMPLE_RATES_SBR 9 /* downsampled (single-rate) mode unsupported, so only use Fs_sbr >= 16 kHz */ - -#define MAX_NUM_ENV 5 -#define MAX_NUM_NOISE_FLOORS 2 -#define MAX_NUM_NOISE_FLOOR_BANDS 5 /* max Nq, see 4.6.18.3.6 */ -#define MAX_NUM_PATCHES 5 -#define MAX_NUM_SMOOTH_COEFS 5 - -#define HF_GEN 8 -#define HF_ADJ 2 - -#define MAX_QMF_BANDS 48 /* max QMF subbands covered by SBR (4.6.18.3.6) */ - -#define FBITS_IN_QMFA 14 -#define FBITS_LOST_QMFA (1 + 2 + 3 + 2 + 1) /* 1 from cTab, 2 in premul, 3 in FFT, 2 in postmul, 1 for implicit scaling by 2.0 */ -#define FBITS_OUT_QMFA (FBITS_IN_QMFA - FBITS_LOST_QMFA) - -#define MIN_GBITS_IN_QMFS 2 -#define FBITS_IN_QMFS FBITS_OUT_QMFA -#define FBITS_LOST_DCT4_64 (2 + 3 + 2) /* 2 in premul, 3 in FFT, 2 in postmul */ - -#define FBITS_OUT_DQ_ENV 29 /* dequantized env scalefactors are Q(29 - envDataDequantScale) */ -#define FBITS_OUT_DQ_NOISE 24 /* range of Q_orig = [2^-24, 2^6] */ -#define NOISE_FLOOR_OFFSET 6 - -/* see comments in ApplyBoost() */ -#define FBITS_GLIM_BOOST 24 -#define FBITS_QLIM_BOOST 14 - -#define MAX_HUFF_BITS 20 -#define NUM_QMF_DELAY_BUFS 10 -#define DELAY_SAMPS_QMFA (NUM_QMF_DELAY_BUFS * 32) -#define DELAY_SAMPS_QMFS (NUM_QMF_DELAY_BUFS * 128) - -/* additional external symbols to name-mangle for static linking */ -#define FFT32C STATNAME(FFT32C) -#define CalcFreqTables STATNAME(CalcFreqTables) -#define AdjustHighFreq STATNAME(AdjustHighFreq) -#define GenerateHighFreq STATNAME(GenerateHighFreq) -#define DecodeSBREnvelope STATNAME(DecodeSBREnvelope) -#define DecodeSBRNoise STATNAME(DecodeSBRNoise) -#define UncoupleSBREnvelope STATNAME(UncoupleSBREnvelope) -#define UncoupleSBRNoise STATNAME(UncoupleSBRNoise) -#define InvRNormalized STATNAME(InvRNormalized) -#define RatioPowInv STATNAME(RatioPowInv) -#define SqrtFix STATNAME(SqrtFix) -#define QMFAnalysis STATNAME(QMFAnalysis) -#define QMFSynthesis STATNAME(QMFSynthesis) -#define GetSampRateIdx STATNAME(GetSampRateIdx) -#define UnpackSBRHeader STATNAME(UnpackSBRHeader) -#define UnpackSBRSingleChannel STATNAME(UnpackSBRSingleChannel) -#define UnpackSBRChannelPair STATNAME(UnpackSBRChannelPair) - -/* asm functions */ -#define CVKernel1 STATNAME(CVKernel1) -#define CVKernel2 STATNAME(CVKernel2) -#define QMFAnalysisConv STATNAME(QMFAnalysisConv) -#define QMFSynthesisConv STATNAME(QMFSynthesisConv) - -#define k0Tab STATNAME(k0Tab) -#define k2Tab STATNAME(k2Tab) -#define goalSBTab STATNAME(goalSBTab) -#define huffTabSBR STATNAME(huffTabSBR) -#define huffTabSBRInfo STATNAME(huffTabSBRInfo) -#define log2Tab STATNAME(log2Tab) -#define noiseTab STATNAME(noiseTab) -#define cTabA STATNAME(cTabA) -#define cTabS STATNAME(cTabS) - -/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */ -#define CLIP_2N_SHIFT30(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ -} - -/* -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != ((y) >> (n))) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} -*/ - -enum { - SBR_GRID_FIXFIX = 0, - SBR_GRID_FIXVAR = 1, - SBR_GRID_VARFIX = 2, - SBR_GRID_VARVAR = 3 -}; - -enum { - HuffTabSBR_tEnv15 = 0, - HuffTabSBR_fEnv15 = 1, - HuffTabSBR_tEnv15b = 2, - HuffTabSBR_fEnv15b = 3, - HuffTabSBR_tEnv30 = 4, - HuffTabSBR_fEnv30 = 5, - HuffTabSBR_tEnv30b = 6, - HuffTabSBR_fEnv30b = 7, - HuffTabSBR_tNoise30 = 8, - HuffTabSBR_fNoise30 = 5, - HuffTabSBR_tNoise30b = 9, - HuffTabSBR_fNoise30b = 7 -}; - -typedef struct _HuffInfo { - int maxBits; /* number of bits in longest codeword */ - unsigned /*char*/ int count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */ - int offset; /* offset into symbol table */ -} HuffInfo; - -/* need one SBRHeader per element (SCE/CPE), updated only on new header */ -typedef struct _SBRHeader { - int count; - - unsigned char ampRes; - unsigned char startFreq; - unsigned char stopFreq; - unsigned char crossOverBand; - unsigned char resBitsHdr; - unsigned char hdrExtra1; - unsigned char hdrExtra2; - - unsigned char freqScale; - unsigned char alterScale; - unsigned char noiseBands; - - unsigned char limiterBands; - unsigned char limiterGains; - unsigned char interpFreq; - unsigned char smoothMode; -} SBRHeader; - -/* need one SBRGrid per channel, updated every frame */ -typedef struct _SBRGrid { - unsigned char frameClass; - unsigned char ampResFrame; - unsigned char pointer; - - unsigned char numEnv; /* L_E */ - unsigned char envTimeBorder[MAX_NUM_ENV+1]; /* t_E */ - unsigned char freqRes[MAX_NUM_ENV]; /* r */ - - unsigned char numNoiseFloors; /* L_Q */ - unsigned char noiseTimeBorder[MAX_NUM_NOISE_FLOORS+1]; /* t_Q */ - - unsigned char numEnvPrev; - unsigned char numNoiseFloorsPrev; - unsigned char freqResPrev; -} SBRGrid; - -/* need one SBRFreq per element (SCE/CPE/LFE), updated only on header reset */ -typedef struct _SBRFreq { - int kStart; /* k_x */ - int nMaster; - int nHigh; - int nLow; - int nLimiter; /* N_l */ - int numQMFBands; /* M */ - int numNoiseFloorBands; /* Nq */ - - int kStartPrev; - int numQMFBandsPrev; - - unsigned char freqMaster[MAX_QMF_BANDS + 1]; /* not necessary to save this after derived tables are generated */ - unsigned char freqHigh[MAX_QMF_BANDS + 1]; - unsigned char freqLow[MAX_QMF_BANDS / 2 + 1]; /* nLow = nHigh - (nHigh >> 1) */ - unsigned char freqNoise[MAX_NUM_NOISE_FLOOR_BANDS+1]; - unsigned char freqLimiter[MAX_QMF_BANDS / 2 + MAX_NUM_PATCHES]; /* max (intermediate) size = nLow + numPatches - 1 */ - - unsigned char numPatches; - unsigned char patchNumSubbands[MAX_NUM_PATCHES + 1]; - unsigned char patchStartSubband[MAX_NUM_PATCHES + 1]; -} SBRFreq; - -typedef struct _SBRChan { - int reset; - unsigned char deltaFlagEnv[MAX_NUM_ENV]; - unsigned char deltaFlagNoise[MAX_NUM_NOISE_FLOORS]; - - signed char envDataQuant[MAX_NUM_ENV][MAX_QMF_BANDS]; /* range = [0, 127] */ - signed char noiseDataQuant[MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS]; - - unsigned char invfMode[2][MAX_NUM_NOISE_FLOOR_BANDS]; /* invfMode[0/1][band] = prev/curr */ - int chirpFact[MAX_NUM_NOISE_FLOOR_BANDS]; /* bwArray */ - unsigned char addHarmonicFlag[2]; /* addHarmonicFlag[0/1] = prev/curr */ - unsigned char addHarmonic[2][64]; /* addHarmonic[0/1][band] = prev/curr */ - - int gbMask[2]; /* gbMask[0/1] = XBuf[0-31]/XBuf[32-39] */ - signed char laPrev; - - int noiseTabIndex; - int sinIndex; - int gainNoiseIndex; - int gTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS]; - int qTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS]; - -} SBRChan; - -typedef struct _PSInfoSBR { - /* save for entire file */ - int frameCount; - int sampRateIdx; - - /* state info that must be saved for each channel */ - SBRHeader sbrHdr[AAC_MAX_NCHANS]; - SBRGrid sbrGrid[AAC_MAX_NCHANS]; - SBRFreq sbrFreq[AAC_MAX_NCHANS]; - SBRChan sbrChan[AAC_MAX_NCHANS]; - - /* temp variables, no need to save between blocks */ - unsigned char dataExtra; - unsigned char resBitsData; - unsigned char extendedDataPresent; - int extendedDataSize; - - signed char envDataDequantScale[MAX_NCHANS_ELEM][MAX_NUM_ENV]; - int envDataDequant[MAX_NCHANS_ELEM][MAX_NUM_ENV][MAX_QMF_BANDS]; - int noiseDataDequant[MAX_NCHANS_ELEM][MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS]; - - int eCurr[MAX_QMF_BANDS]; - unsigned char eCurrExp[MAX_QMF_BANDS]; - unsigned char eCurrExpMax; - signed char la; - - int crcCheckWord; - int couplingFlag; - int envBand; - int eOMGainMax; - int gainMax; - int gainMaxFBits; - int noiseFloorBand; - int qp1Inv; - int qqp1Inv; - int sMapped; - int sBand; - int highBand; - - int sumEOrigMapped; - int sumECurrGLim; - int sumSM; - int sumQM; - int gLimBoost[MAX_QMF_BANDS]; - int qmLimBoost[MAX_QMF_BANDS]; - int smBoost[MAX_QMF_BANDS]; - - int smBuf[MAX_QMF_BANDS]; - int qmLimBuf[MAX_QMF_BANDS]; - int gLimBuf[MAX_QMF_BANDS]; - int gLimFbits[MAX_QMF_BANDS]; - - int gFiltLast[MAX_QMF_BANDS]; - int qFiltLast[MAX_QMF_BANDS]; - - /* large buffers */ - int delayIdxQMFA[AAC_MAX_NCHANS]; - int delayQMFA[AAC_MAX_NCHANS][DELAY_SAMPS_QMFA]; - int delayIdxQMFS[AAC_MAX_NCHANS]; - int delayQMFS[AAC_MAX_NCHANS][DELAY_SAMPS_QMFS]; - int XBufDelay[AAC_MAX_NCHANS][HF_GEN][64][2]; - int XBuf[32+8][64][2]; - -} PSInfoSBR; - -/* sbrfft.c */ -void FFT32C(int *x); - -/* sbrfreq.c */ -int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx); - -/* sbrhfadj.c */ -void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); - -/* sbrhfgen.c */ -void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); - -/* sbrhuff.c */ -void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); -void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); -void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR); -void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR); - -/* sbrmath.c */ -int InvRNormalized(int r); -int RatioPowInv(int a, int b, int c); -int SqrtFix(int x, int fBitsIn, int *fBitsOut); - -/* sbrqmf.c */ -int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands); -void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans); - -/* sbrside.c */ -int GetSampRateIdx(int sampRate); -int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr); -void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut); -void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut); - -/* sbrtabs.c */ -extern const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16]; -extern const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14]; -extern const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR]; -extern const HuffInfo huffTabSBRInfo[10]; -extern const signed int /*short*/ huffTabSBR[604]; -extern const int log2Tab[65]; -extern const int noiseTab[512*2]; -extern const int cTabA[165]; -extern const int cTabS[640]; - -#endif /* _SBR_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfft.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfft.c deleted file mode 100644 index 23b36ac3..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfft.c +++ /dev/null @@ -1,368 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * sbrfft.c - optimized FFT for SBR QMF filters - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define SQRT1_2 0x5a82799a - -/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */ -#define swapcplx(p0,p1) \ - t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1 - -/* nfft = 32, hard coded since small, fixed size FFT -static const unsigned char bitrevtab32[9] = { - 0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00, -}; -*/ - -/* twiddle table for radix 4 pass, format = Q31 */ -static const int twidTabOdd32[8*6] = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59, - 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, - 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862, - 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, - 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, -}; - -/************************************************************************************** - * Function: BitReverse32 - * - * Description: Ken's fast in-place bit reverse - * - * Inputs: buffer of 32 complex samples - * - * Outputs: bit-reversed samples in same buffer - * - * Return: none -**************************************************************************************/ -static void BitReverse32(int *inout) -{ - int t, t1; - - swapcplx(inout[2], inout[32]); - swapcplx(inout[4], inout[16]); - swapcplx(inout[6], inout[48]); - swapcplx(inout[10], inout[40]); - swapcplx(inout[12], inout[24]); - swapcplx(inout[14], inout[56]); - swapcplx(inout[18], inout[36]); - swapcplx(inout[22], inout[52]); - swapcplx(inout[26], inout[44]); - swapcplx(inout[30], inout[60]); - swapcplx(inout[38], inout[50]); - swapcplx(inout[46], inout[58]); -} - -/************************************************************************************** - * Function: R8FirstPass32 - * - * Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5) - * - * Inputs: buffer of (bit-reversed) samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits, gains 1 integer bit - * guard bits out = guard bits in - 3 (if inputs are full scale) - * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2) - * see scaling comments in fft.c for base AAC - * should compile with no stack spills on ARM (verify compiled output) - * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU - **************************************************************************************/ -static void R8FirstPass32(int *r0) -{ - int r1, r2, r3, r4, r5, r6, r7; - int r8, r9, r10, r11, r12, r14; - - /* number of passes = fft size / 8 = 32 / 8 = 4 */ - r1 = (32 >> 3); - do { - - r2 = r0[8]; - r3 = r0[9]; - r4 = r0[10]; - r5 = r0[11]; - r6 = r0[12]; - r7 = r0[13]; - r8 = r0[14]; - r9 = r0[15]; - - r10 = r2 + r4; - r11 = r3 + r5; - r12 = r6 + r8; - r14 = r7 + r9; - - r2 -= r4; - r3 -= r5; - r6 -= r8; - r7 -= r9; - - r4 = r2 - r7; - r5 = r2 + r7; - r8 = r3 - r6; - r9 = r3 + r6; - - r2 = r4 - r9; - r3 = r4 + r9; - r6 = r5 - r8; - r7 = r5 + r8; - - r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */ - r3 = MULSHIFT32(SQRT1_2, r3); - r6 = MULSHIFT32(SQRT1_2, r6); - r7 = MULSHIFT32(SQRT1_2, r7); - - r4 = r10 + r12; - r5 = r10 - r12; - r8 = r11 + r14; - r9 = r11 - r14; - - r10 = r0[0]; - r11 = r0[2]; - r12 = r0[4]; - r14 = r0[6]; - - r10 += r11; - r12 += r14; - - r4 >>= 1; - r10 += r12; - r4 += (r10 >> 1); - r0[ 0] = r4; - r4 -= (r10 >> 1); - r4 = (r10 >> 1) - r4; - r0[ 8] = r4; - - r9 >>= 1; - r10 -= 2*r12; - r4 = (r10 >> 1) + r9; - r0[ 4] = r4; - r4 = (r10 >> 1) - r9; - r0[12] = r4; - r10 += r12; - - r10 -= 2*r11; - r12 -= 2*r14; - - r4 = r0[1]; - r9 = r0[3]; - r11 = r0[5]; - r14 = r0[7]; - - r4 += r9; - r11 += r14; - - r8 >>= 1; - r4 += r11; - r8 += (r4 >> 1); - r0[ 1] = r8; - r8 -= (r4 >> 1); - r8 = (r4 >> 1) - r8; - r0[ 9] = r8; - - r5 >>= 1; - r4 -= 2*r11; - r8 = (r4 >> 1) - r5; - r0[ 5] = r8; - r8 = (r4 >> 1) + r5; - r0[13] = r8; - r4 += r11; - - r4 -= 2*r9; - r11 -= 2*r14; - - r9 = r10 - r11; - r10 += r11; - r14 = r4 + r12; - r4 -= r12; - - r5 = (r10 >> 1) + r7; - r8 = (r4 >> 1) - r6; - r0[ 2] = r5; - r0[ 3] = r8; - - r5 = (r9 >> 1) - r2; - r8 = (r14 >> 1) - r3; - r0[ 6] = r5; - r0[ 7] = r8; - - r5 = (r10 >> 1) - r7; - r8 = (r4 >> 1) + r6; - r0[10] = r5; - r0[11] = r8; - - r5 = (r9 >> 1) + r2; - r8 = (r14 >> 1) + r3; - r0[14] = r5; - r0[15] = r8; - - r0 += 16; - r1--; - } while (r1 != 0); -} - -/************************************************************************************** - * Function: R4Core32 - * - * Description: radix-4 pass for 32-point decimation-in-time FFT - * - * Inputs: buffer of samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: gain 2 integer bits - * guard bits out = guard bits in - 1 (if inputs are full scale) - * see scaling comments in fft.c for base AAC - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - * should compile with no stack spills on ARM (verify compiled output) - * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU - **************************************************************************************/ -static void R4Core32(int *r0) -{ - int r2, r3, r4, r5, r6, r7; - int r8, r9, r10, r12, r14; - int *r1; - - r1 = (int *)twidTabOdd32; - r10 = 8; - do { - /* can use r14 for lo32 scratch register in all MULSHIFT32 */ - r2 = r1[0]; - r3 = r1[1]; - r4 = r0[16]; - r5 = r0[17]; - r12 = r4 + r5; - r12 = MULSHIFT32(r3, r12); - r5 = MULSHIFT32(r2, r5) + r12; - r2 += 2*r3; - r4 = MULSHIFT32(r2, r4) - r12; - - r2 = r1[2]; - r3 = r1[3]; - r6 = r0[32]; - r7 = r0[33]; - r12 = r6 + r7; - r12 = MULSHIFT32(r3, r12); - r7 = MULSHIFT32(r2, r7) + r12; - r2 += 2*r3; - r6 = MULSHIFT32(r2, r6) - r12; - - r2 = r1[4]; - r3 = r1[5]; - r8 = r0[48]; - r9 = r0[49]; - r12 = r8 + r9; - r12 = MULSHIFT32(r3, r12); - r9 = MULSHIFT32(r2, r9) + r12; - r2 += 2*r3; - r8 = MULSHIFT32(r2, r8) - r12; - - r2 = r0[0]; - r3 = r0[1]; - - r12 = r6 + r8; - r8 = r6 - r8; - r14 = r9 - r7; - r9 = r9 + r7; - - r6 = (r2 >> 2) - r4; - r7 = (r3 >> 2) - r5; - r4 += (r2 >> 2); - r5 += (r3 >> 2); - - r2 = r4 + r12; - r3 = r5 + r9; - r0[0] = r2; - r0[1] = r3; - r2 = r6 - r14; - r3 = r7 - r8; - r0[16] = r2; - r0[17] = r3; - r2 = r4 - r12; - r3 = r5 - r9; - r0[32] = r2; - r0[33] = r3; - r2 = r6 + r14; - r3 = r7 + r8; - r0[48] = r2; - r0[49] = r3; - - r0 += 2; - r1 += 6; - r10--; - } while (r10 != 0); -} - -/************************************************************************************** - * Function: FFT32C - * - * Description: Ken's very fast in-place radix-4 decimation-in-time FFT - * - * Inputs: buffer of 32 complex samples (before bit-reversal) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits in, gains 3 integer bits - * guard bits out = guard bits in - 2 - * (guard bit analysis includes assumptions about steps immediately - * before and after, i.e. PreMul and PostMul for DCT) - **************************************************************************************/ -void FFT32C(int *x) -{ - /* decimation in time */ - BitReverse32(x); - - /* 32-point complex FFT */ - R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */ - R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */ -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfreq.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfreq.c deleted file mode 100644 index 26a76063..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrfreq.c +++ /dev/null @@ -1,641 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrfreq.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrfreq.c - frequency band table calculation for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/************************************************************************************** - * Function: BubbleSort - * - * Description: in-place sort of unsigned chars - * - * Inputs: buffer of elements to sort - * number of elements to sort - * - * Outputs: sorted buffer - * - * Return: none - **************************************************************************************/ -static void BubbleSort(unsigned char *v, int nItems) -{ - int i; - unsigned char t; - - while (nItems >= 2) { - for (i = 0; i < nItems-1; i++) { - if (v[i+1] < v[i]) { - t = v[i+1]; - v[i+1] = v[i]; - v[i] = t; - } - } - nItems--; - } -} - -/************************************************************************************** - * Function: VMin - * - * Description: find smallest element in a buffer of unsigned chars - * - * Inputs: buffer of elements to search - * number of elements to search - * - * Outputs: none - * - * Return: smallest element in buffer - **************************************************************************************/ -static unsigned char VMin(unsigned char *v, int nItems) -{ - int i; - unsigned char vMin; - - vMin = v[0]; - for (i = 1; i < nItems; i++) { - if (v[i] < vMin) - vMin = v[i]; - } - return vMin; -} - -/************************************************************************************** - * Function: VMax - * - * Description: find largest element in a buffer of unsigned chars - * - * Inputs: buffer of elements to search - * number of elements to search - * - * Outputs: none - * - * Return: largest element in buffer - **************************************************************************************/ -static unsigned char VMax(unsigned char *v, int nItems) -{ - int i; - unsigned char vMax; - - vMax = v[0]; - for (i = 1; i < nItems; i++) { - if (v[i] > vMax) - vMax = v[i]; - } - return vMax; -} - -/************************************************************************************** - * Function: CalcFreqMasterScaleZero - * - * Description: calculate master frequency table when freqScale == 0 - * (4.6.18.3.2.1, figure 4.39) - * - * Inputs: alterScale flag - * index of first QMF subband in master freq table (k0) - * index of last QMF subband (k2) - * - * Outputs: master frequency table - * - * Return: number of bands in master frequency table - * - * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6) - **************************************************************************************/ -static int CalcFreqMasterScaleZero(unsigned char *freqMaster, int alterScale, int k0, int k2) -{ - int nMaster, k, nBands, k2Achieved, dk, vDk[64], k2Diff; - - if (alterScale) { - dk = 2; - nBands = 2 * ((k2 - k0 + 2) >> 2); - } else { - dk = 1; - nBands = 2 * ((k2 - k0) >> 1); - } - - if (nBands <= 0) - return 0; - - k2Achieved = k0 + nBands * dk; - k2Diff = k2 - k2Achieved; - for (k = 0; k < nBands; k++) - vDk[k] = dk; - - if (k2Diff > 0) { - k = nBands - 1; - while (k2Diff) { - vDk[k]++; - k--; - k2Diff--; - } - } else if (k2Diff < 0) { - k = 0; - while (k2Diff) { - vDk[k]--; - k++; - k2Diff++; - } - } - - nMaster = nBands; - freqMaster[0] = k0; - for (k = 1; k <= nBands; k++) - freqMaster[k] = freqMaster[k-1] + vDk[k-1]; - - return nMaster; -} - -/* mBandTab[i] = temp1[i] / 2 */ -static const int mBandTab[3] PROGMEM = {6, 5, 4}; - -/* invWarpTab[i] = 1.0 / temp2[i], Q30 (see 4.6.18.3.2.1) */ -static const int invWarpTab[2] PROGMEM = {0x40000000, 0x313b13b1}; - -/************************************************************************************** - * Function: CalcFreqMasterScale - * - * Description: calculate master frequency table when freqScale > 0 - * (4.6.18.3.2.1, figure 4.39) - * - * Inputs: alterScale flag - * freqScale flag - * index of first QMF subband in master freq table (k0) - * index of last QMF subband (k2) - * - * Outputs: master frequency table - * - * Return: number of bands in master frequency table - * - * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6) - **************************************************************************************/ -static int CalcFreqMaster(unsigned char *freqMaster, int freqScale, int alterScale, int k0, int k2) -{ - int bands, twoRegions, k, k1, t, vLast, vCurr, pCurr; - int invWarp, nBands0, nBands1, change; - unsigned char vDk1Min, vDk0Max; - unsigned char *vDelta; - - if (freqScale < 1 || freqScale > 3) - return -1; - - bands = mBandTab[freqScale - 1]; - invWarp = invWarpTab[alterScale]; - - /* tested for all k0 = [5, 64], k2 = [k0, 64] */ - if (k2*10000 > 22449*k0) { - twoRegions = 1; - k1 = 2*k0; - } else { - twoRegions = 0; - k1 = k2; - } - - /* tested for all k0 = [5, 64], k1 = [k0, 64], freqScale = [1,3] */ - t = (log2Tab[k1] - log2Tab[k0]) >> 3; /* log2(k1/k0), Q28 to Q25 */ - nBands0 = 2 * (((bands * t) + (1 << 24)) >> 25); /* multiply by bands/2, round to nearest int (mBandTab has factor of 1/2 rolled in) */ - - /* tested for all valid combinations of k0, k1, nBands (from sampRate, freqScale, alterScale) - * roundoff error can be a problem with fixpt (e.g. pCurr = 12.499999 instead of 12.50003) - * because successive multiplication always undershoots a little bit, but this - * doesn't occur in any of the ratios we encounter from the valid k0/k1 bands in the spec - */ - t = RatioPowInv(k1, k0, nBands0); - pCurr = k0 << 24; - vLast = k0; - vDelta = freqMaster + 1; /* operate in-place */ - for (k = 0; k < nBands0; k++) { - pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */ - vCurr = (pCurr + (1 << 23)) >> 24; - vDelta[k] = (vCurr - vLast); - vLast = vCurr; - } - - /* sort the deltas and find max delta for first region */ - BubbleSort(vDelta, nBands0); - vDk0Max = VMax(vDelta, nBands0); - - /* fill master frequency table with bands from first region */ - freqMaster[0] = k0; - for (k = 1; k <= nBands0; k++) - freqMaster[k] += freqMaster[k-1]; - - /* if only one region, then the table is complete */ - if (!twoRegions) - return nBands0; - - /* tested for all k1 = [10, 64], k2 = [k0, 64], freqScale = [1,3] */ - t = (log2Tab[k2] - log2Tab[k1]) >> 3; /* log2(k1/k0), Q28 to Q25 */ - t = MULSHIFT32(bands * t, invWarp) << 2; /* multiply by bands/2, divide by warp factor, keep Q25 */ - nBands1 = 2 * ((t + (1 << 24)) >> 25); /* round to nearest int */ - - /* see comments above for calculations in first region */ - t = RatioPowInv(k2, k1, nBands1); - pCurr = k1 << 24; - vLast = k1; - vDelta = freqMaster + nBands0 + 1; /* operate in-place */ - for (k = 0; k < nBands1; k++) { - pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */ - vCurr = (pCurr + (1 << 23)) >> 24; - vDelta[k] = (vCurr - vLast); - vLast = vCurr; - } - - /* sort the deltas, adjusting first and last if the second region has smaller deltas than the first */ - vDk1Min = VMin(vDelta, nBands1); - if (vDk1Min < vDk0Max) { - BubbleSort(vDelta, nBands1); - change = vDk0Max - vDelta[0]; - if (change > ((vDelta[nBands1 - 1] - vDelta[0]) >> 1)) - change = ((vDelta[nBands1 - 1] - vDelta[0]) >> 1); - vDelta[0] += change; - vDelta[nBands1-1] -= change; - } - BubbleSort(vDelta, nBands1); - - /* fill master frequency table with bands from second region - * Note: freqMaster[nBands0] = k1 - */ - for (k = 1; k <= nBands1; k++) - freqMaster[k + nBands0] += freqMaster[k + nBands0 - 1]; - - return (nBands0 + nBands1); -} - -/************************************************************************************** - * Function: CalcFreqHigh - * - * Description: calculate high resolution frequency table (4.6.18.3.2.2) - * - * Inputs: master frequency table - * number of bands in master frequency table - * crossover band from header - * - * Outputs: high resolution frequency table - * - * Return: number of bands in high resolution frequency table - **************************************************************************************/ -static int CalcFreqHigh(unsigned char *freqHigh, unsigned char *freqMaster, int nMaster, int crossOverBand) -{ - int k, nHigh; - - nHigh = nMaster - crossOverBand; - - for (k = 0; k <= nHigh; k++) - freqHigh[k] = freqMaster[k + crossOverBand]; - - return nHigh; -} - -/************************************************************************************** - * Function: CalcFreqLow - * - * Description: calculate low resolution frequency table (4.6.18.3.2.2) - * - * Inputs: high resolution frequency table - * number of bands in high resolution frequency table - * - * Outputs: low resolution frequency table - * - * Return: number of bands in low resolution frequency table - **************************************************************************************/ -static int CalcFreqLow(unsigned char *freqLow, unsigned char *freqHigh, int nHigh) -{ - int k, nLow, oddFlag; - - nLow = nHigh - (nHigh >> 1); - freqLow[0] = freqHigh[0]; - oddFlag = nHigh & 0x01; - - for (k = 1; k <= nLow; k++) - freqLow[k] = freqHigh[2*k - oddFlag]; - - return nLow; -} - -/************************************************************************************** - * Function: CalcFreqNoise - * - * Description: calculate noise floor frequency table (4.6.18.3.2.2) - * - * Inputs: low resolution frequency table - * number of bands in low resolution frequency table - * index of starting QMF subband for SBR (kStart) - * index of last QMF subband (k2) - * number of noise bands - * - * Outputs: noise floor frequency table - * - * Return: number of bands in noise floor frequency table - **************************************************************************************/ -static int CalcFreqNoise(unsigned char *freqNoise, unsigned char *freqLow, int nLow, int kStart, int k2, int noiseBands) -{ - int i, iLast, k, nQ, lTop, lBottom; - - lTop = log2Tab[k2]; - lBottom = log2Tab[kStart]; - nQ = noiseBands*((lTop - lBottom) >> 2); /* Q28 to Q26, noiseBands = [0,3] */ - nQ = (nQ + (1 << 25)) >> 26; - if (nQ < 1) - nQ = 1; - - ASSERT(nQ <= MAX_NUM_NOISE_FLOOR_BANDS); /* required from 4.6.18.3.6 */ - - iLast = 0; - freqNoise[0] = freqLow[0]; - for (k = 1; k <= nQ; k++) { - i = iLast + (nLow - iLast) / (nQ + 1 - k); /* truncating division */ - freqNoise[k] = freqLow[i]; - iLast = i; - } - - return nQ; -} - -/************************************************************************************** - * Function: BuildPatches - * - * Description: build high frequency patches (4.6.18.6.3) - * - * Inputs: master frequency table - * number of bands in low resolution frequency table - * index of first QMF subband in master freq table (k0) - * index of starting QMF subband for SBR (kStart) - * number of QMF bands in high resolution frequency table - * sample rate index - * - * Outputs: starting subband for each patch - * number of subbands in each patch - * - * Return: number of patches - **************************************************************************************/ -static int BuildPatches(unsigned char *patchNumSubbands, unsigned char *patchStartSubband, unsigned char *freqMaster, - int nMaster, int k0, int kStart, int numQMFBands, int sampRateIdx) -{ - int i, j, k; - int msb, sb, usb, numPatches, goalSB, oddFlag; - - msb = k0; - usb = kStart; - numPatches = 0; - goalSB = goalSBTab[sampRateIdx]; - - if (nMaster == 0) { - patchNumSubbands[0] = 0; - patchStartSubband[0] = 0; - return 0; - } - - if (goalSB < kStart + numQMFBands) { - k = 0; - for (i = 0; freqMaster[i] < goalSB; i++) - k = i+1; - } else { - k = nMaster; - } - - do { - j = k+1; - do { - j--; - sb = freqMaster[j]; - oddFlag = (sb - 2 + k0) & 0x01; - } while (sb > k0 - 1 + msb - oddFlag); - - patchNumSubbands[numPatches] = MAX(sb - usb, 0); - patchStartSubband[numPatches] = k0 - oddFlag - patchNumSubbands[numPatches]; - - /* from MPEG reference code - slightly different from spec */ - if ((patchNumSubbands[numPatches] < 3) && (numPatches > 0)) - break; - - if (patchNumSubbands[numPatches] > 0) { - usb = sb; - msb = sb; - numPatches++; - } else { - msb = kStart; - } - - if (freqMaster[k] - sb < 3) - k = nMaster; - - } while (sb != (kStart + numQMFBands) && numPatches <= MAX_NUM_PATCHES); - - return numPatches; -} - -/************************************************************************************** - * Function: FindFreq - * - * Description: search buffer of unsigned chars for a specific value - * - * Inputs: buffer of elements to search - * number of elements to search - * value to search for - * - * Outputs: none - * - * Return: non-zero if the value is found anywhere in the buffer, zero otherwise - **************************************************************************************/ -static int FindFreq(unsigned char *freq, int nFreq, unsigned char val) -{ - int k; - - for (k = 0; k < nFreq; k++) { - if (freq[k] == val) - return 1; - } - - return 0; -} - -/************************************************************************************** - * Function: RemoveFreq - * - * Description: remove one element from a buffer of unsigned chars - * - * Inputs: buffer of elements - * number of elements - * index of element to remove - * - * Outputs: new buffer of length nFreq-1 - * - * Return: none - **************************************************************************************/ -static void RemoveFreq(unsigned char *freq, int nFreq, int removeIdx) -{ - int k; - - if (removeIdx >= nFreq) - return; - - for (k = removeIdx; k < nFreq - 1; k++) - freq[k] = freq[k+1]; -} - -/************************************************************************************** - * Function: CalcFreqLimiter - * - * Description: calculate limiter frequency table (4.6.18.3.2.3) - * - * Inputs: number of subbands in each patch - * low resolution frequency table - * number of bands in low resolution frequency table - * index of starting QMF subband for SBR (kStart) - * number of limiter bands - * number of patches - * - * Outputs: limiter frequency table - * - * Return: number of bands in limiter frequency table - **************************************************************************************/ -static int CalcFreqLimiter(unsigned char *freqLimiter, unsigned char *patchNumSubbands, unsigned char *freqLow, - int nLow, int kStart, int limiterBands, int numPatches) -{ - int k, bands, nLimiter, nOctaves; - int limBandsPerOctave[3] = {120, 200, 300}; /* [1.2, 2.0, 3.0] * 100 */ - unsigned char patchBorders[MAX_NUM_PATCHES + 1]; - - /* simple case */ - if (limiterBands == 0) { - freqLimiter[0] = freqLow[0] - kStart; - freqLimiter[1] = freqLow[nLow] - kStart; - return 1; - } - - bands = limBandsPerOctave[limiterBands - 1]; - patchBorders[0] = kStart; - - /* from MPEG reference code - slightly different from spec (top border) */ - for (k = 1; k < numPatches; k++) - patchBorders[k] = patchBorders[k-1] + patchNumSubbands[k-1]; - patchBorders[k] = freqLow[nLow]; - - for (k = 0; k <= nLow; k++) - freqLimiter[k] = freqLow[k]; - - for (k = 1; k < numPatches; k++) - freqLimiter[k+nLow] = patchBorders[k]; - - k = 1; - nLimiter = nLow + numPatches - 1; - BubbleSort(freqLimiter, nLimiter + 1); - - while (k <= nLimiter) { - nOctaves = log2Tab[freqLimiter[k]] - log2Tab[freqLimiter[k-1]]; /* Q28 */ - nOctaves = (nOctaves >> 9) * bands; /* Q19, max bands = 300 < 2^9 */ - if (nOctaves < (49 << 19)) { /* compare with 0.49*100, in Q19 */ - if (freqLimiter[k] == freqLimiter[k-1] || FindFreq(patchBorders, numPatches + 1, freqLimiter[k]) == 0) { - RemoveFreq(freqLimiter, nLimiter + 1, k); - nLimiter--; - } else if (FindFreq(patchBorders, numPatches + 1, freqLimiter[k-1]) == 0) { - RemoveFreq(freqLimiter, nLimiter + 1, k-1); - nLimiter--; - } else { - k++; - } - } else { - k++; - } - } - - /* store limiter boundaries as offsets from kStart */ - for (k = 0; k <= nLimiter; k++) - freqLimiter[k] -= kStart; - - return nLimiter; -} - -/************************************************************************************** - * Function: CalcFreqTables - * - * Description: calulate master and derived frequency tables, and patches - * - * Inputs: initialized SBRHeader struct for this SCE/CPE block - * initialized SBRFreq struct for this SCE/CPE block - * sample rate index of output sample rate (after SBR) - * - * Outputs: master and derived frequency tables, and patches - * - * Return: non-zero if error, zero otherwise - **************************************************************************************/ -int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx) -{ - int k0, k2; - - k0 = k0Tab[sampRateIdx][sbrHdr->startFreq]; - - if (sbrHdr->stopFreq == 14) - k2 = 2*k0; - else if (sbrHdr->stopFreq == 15) - k2 = 3*k0; - else - k2 = k2Tab[sampRateIdx][sbrHdr->stopFreq]; - if (k2 > 64) - k2 = 64; - - /* calculate master frequency table */ - if (sbrHdr->freqScale == 0) - sbrFreq->nMaster = CalcFreqMasterScaleZero(sbrFreq->freqMaster, sbrHdr->alterScale, k0, k2); - else - sbrFreq->nMaster = CalcFreqMaster(sbrFreq->freqMaster, sbrHdr->freqScale, sbrHdr->alterScale, k0, k2); - - /* calculate high frequency table and related parameters */ - sbrFreq->nHigh = CalcFreqHigh(sbrFreq->freqHigh, sbrFreq->freqMaster, sbrFreq->nMaster, sbrHdr->crossOverBand); - sbrFreq->numQMFBands = sbrFreq->freqHigh[sbrFreq->nHigh] - sbrFreq->freqHigh[0]; - sbrFreq->kStart = sbrFreq->freqHigh[0]; - - /* calculate low frequency table */ - sbrFreq->nLow = CalcFreqLow(sbrFreq->freqLow, sbrFreq->freqHigh, sbrFreq->nHigh); - - /* calculate noise floor frequency table */ - sbrFreq->numNoiseFloorBands = CalcFreqNoise(sbrFreq->freqNoise, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, k2, sbrHdr->noiseBands); - - /* calculate limiter table */ - sbrFreq->numPatches = BuildPatches(sbrFreq->patchNumSubbands, sbrFreq->patchStartSubband, sbrFreq->freqMaster, - sbrFreq->nMaster, k0, sbrFreq->kStart, sbrFreq->numQMFBands, sampRateIdx); - sbrFreq->nLimiter = CalcFreqLimiter(sbrFreq->freqLimiter, sbrFreq->patchNumSubbands, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, - sbrHdr->limiterBands, sbrFreq->numPatches); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfadj.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfadj.c deleted file mode 100644 index f16cb07b..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfadj.c +++ /dev/null @@ -1,853 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhfadj.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhfadj.c - high frequency adjustment for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/* invBandTab[i] = 1.0 / (i + 1), Q31 */ -static const int invBandTab[64] PROGMEM = { - 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555555, 0x12492492, 0x10000000, - 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba, 0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000, - 0x07878788, 0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216, 0x05555555, - 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58, 0x04444444, 0x04210842, 0x04000000, - 0x03e0f83e, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333, - 0x031f3832, 0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105, 0x02aaaaab, - 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f, 0x025ed098, 0x0253c825, 0x02492492, - 0x023ee090, 0x0234f72c, 0x022b63cc, 0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000, -}; - -/************************************************************************************** - * Function: EstimateEnvelope - * - * Description: estimate power of generated HF QMF bands in one time-domain envelope - * (4.6.18.7.3) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * index of current envelope - * - * Outputs: power of each QMF subband, stored as integer (Q0) * 2^N, N >= 0 - * - * Return: none - **************************************************************************************/ -static void EstimateEnvelope(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int env) -{ - int i, m, iStart, iEnd, xre, xim, nScale, expMax; - int p, n, mStart, mEnd, invFact, t; - int *XBuf; - U64 eCurr; - unsigned char *freqBandTab; - - /* estimate current envelope */ - iStart = sbrGrid->envTimeBorder[env] + HF_ADJ; - iEnd = sbrGrid->envTimeBorder[env+1] + HF_ADJ; - if (sbrGrid->freqRes[env]) { - n = sbrFreq->nHigh; - freqBandTab = sbrFreq->freqHigh; - } else { - n = sbrFreq->nLow; - freqBandTab = sbrFreq->freqLow; - } - - /* ADS should inline MADD64 (smlal) properly, but check to make sure */ - expMax = 0; - if (sbrHdr->interpFreq) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - eCurr.w64 = 0; - XBuf = psi->XBuf[iStart][sbrFreq->kStart + m]; - for (i = iStart; i < iEnd; i++) { - /* scale to int before calculating power (precision not critical, and avoids overflow) */ - xre = (*XBuf) >> FBITS_OUT_QMFA; XBuf += 1; - xim = (*XBuf) >> FBITS_OUT_QMFA; XBuf += (2*64 - 1); - eCurr.w64 = MADD64(eCurr.w64, xre, xre); - eCurr.w64 = MADD64(eCurr.w64, xim, xim); - } - - /* eCurr.w64 is now Q(64 - 2*FBITS_OUT_QMFA) (64-bit word) - * if energy is too big to fit in 32-bit word (> 2^31) scale down by power of 2 - */ - nScale = 0; - if (eCurr.r.hi32) { - nScale = (32 - CLZ(eCurr.r.hi32)) + 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - t |= eCurr.r.hi32 << (32 - nScale); - } else if (eCurr.r.lo32 >> 31) { - nScale = 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - } else { - t = (int)eCurr.r.lo32; - } - - invFact = invBandTab[(iEnd - iStart)-1]; - psi->eCurr[m] = MULSHIFT32(t, invFact); - psi->eCurrExp[m] = nScale + 1; /* +1 for invFact = Q31 */ - if (psi->eCurrExp[m] > expMax) - expMax = psi->eCurrExp[m]; - } - } else { - for (p = 0; p < n; p++) { - mStart = freqBandTab[p]; - mEnd = freqBandTab[p+1]; - eCurr.w64 = 0; - for (i = iStart; i < iEnd; i++) { - XBuf = psi->XBuf[i][mStart]; - for (m = mStart; m < mEnd; m++) { - xre = (*XBuf++) >> FBITS_OUT_QMFA; - xim = (*XBuf++) >> FBITS_OUT_QMFA; - eCurr.w64 = MADD64(eCurr.w64, xre, xre); - eCurr.w64 = MADD64(eCurr.w64, xim, xim); - } - } - - nScale = 0; - if (eCurr.r.hi32) { - nScale = (32 - CLZ(eCurr.r.hi32)) + 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - t |= eCurr.r.hi32 << (32 - nScale); - } else if (eCurr.r.lo32 >> 31) { - nScale = 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - } else { - t = (int)eCurr.r.lo32; - } - - invFact = invBandTab[(iEnd - iStart)-1]; - invFact = MULSHIFT32(invBandTab[(mEnd - mStart)-1], invFact) << 1; - t = MULSHIFT32(t, invFact); - - for (m = mStart; m < mEnd; m++) { - psi->eCurr[m - sbrFreq->kStart] = t; - psi->eCurrExp[m - sbrFreq->kStart] = nScale + 1; /* +1 for invFact = Q31 */ - } - if (psi->eCurrExp[mStart - sbrFreq->kStart] > expMax) - expMax = psi->eCurrExp[mStart - sbrFreq->kStart]; - } - } - psi->eCurrExpMax = expMax; -} - -/************************************************************************************** - * Function: GetSMapped - * - * Description: calculate SMapped (4.6.18.7.2) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current envelope - * index of current QMF band - * la flag for this envelope - * - * Outputs: none - * - * Return: 1 if a sinusoid is present in this band, 0 if not - **************************************************************************************/ -static int GetSMapped(SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int band, int la) -{ - int bandStart, bandEnd, oddFlag, r; - - if (sbrGrid->freqRes[env]) { - /* high resolution */ - bandStart = band; - bandEnd = band+1; - } else { - /* low resolution (see CalcFreqLow() for mapping) */ - oddFlag = sbrFreq->nHigh & 0x01; - bandStart = (band > 0 ? 2*band - oddFlag : 0); /* starting index for freqLow[band] */ - bandEnd = 2*(band+1) - oddFlag; /* ending index for freqLow[band+1] */ - } - - /* sMapped = 1 if sIndexMapped == 1 for any frequency in this band */ - for (band = bandStart; band < bandEnd; band++) { - if (sbrChan->addHarmonic[1][band]) { - r = ((sbrFreq->freqHigh[band+1] + sbrFreq->freqHigh[band]) >> 1); - if (env >= la || sbrChan->addHarmonic[0][r] == 1) - return 1; - } - } - return 0; -} - -#define GBOOST_MAX 0x2830afd3 /* Q28, 1.584893192 squared */ -#define ACC_SCALE 6 - -/* squared version of table in 4.6.18.7.5 */ -static const int limGainTab[4] PROGMEM = {0x20138ca7, 0x40000000, 0x7fb27dce, 0x80000000}; /* Q30 (0x80000000 = sentinel for GMAX) */ - -/************************************************************************************** - * Function: CalcMaxGain - * - * Description: calculate max gain in one limiter band (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * index of current limiter band - * number of fraction bits in dequantized envelope - * (max = Q(FBITS_OUT_DQ_ENV - 6) = Q23, can go negative) - * - * Outputs: updated gainMax, gainMaxFBits, and sumEOrigMapped in PSInfoSBR struct - * - * Return: none - **************************************************************************************/ -static void CalcMaxGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int ch, int env, int lim, int fbitsDQ) -{ - int m, mStart, mEnd, q, z, r; - int sumEOrigMapped, sumECurr, gainMax, eOMGainMax, envBand; - unsigned char eCurrExpMax; - unsigned char *freqBandTab; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow); - - /* calculate max gain to apply to signal in this limiter band */ - sumECurr = 0; - sumEOrigMapped = 0; - eCurrExpMax = psi->eCurrExpMax; - eOMGainMax = psi->eOMGainMax; - envBand = psi->envBand; - for (m = mStart; m < mEnd; m++) { - /* map current QMF band to appropriate envelope band */ - if (m == freqBandTab[envBand + 1] - sbrFreq->kStart) { - envBand++; - eOMGainMax = psi->envDataDequant[ch][env][envBand] >> ACC_SCALE; /* summing max 48 bands */ - } - sumEOrigMapped += eOMGainMax; - - /* easy test for overflow on ARM */ - sumECurr += (psi->eCurr[m] >> (eCurrExpMax - psi->eCurrExp[m])); - if (sumECurr >> 30) { - sumECurr >>= 1; - eCurrExpMax++; - } - } - psi->eOMGainMax = eOMGainMax; - psi->envBand = envBand; - - psi->gainMaxFBits = 30; /* Q30 tables */ - if (sumECurr == 0) { - /* any non-zero numerator * 1/EPS_0 is > G_MAX */ - gainMax = (sumEOrigMapped == 0 ? (int)limGainTab[sbrHdr->limiterGains] : (int)0x80000000); - } else if (sumEOrigMapped == 0) { - /* 1/(any non-zero denominator) * EPS_0 * limGainTab[x] is appx. 0 */ - gainMax = 0; - } else { - /* sumEOrigMapped = Q(fbitsDQ - ACC_SCALE), sumECurr = Q(-eCurrExpMax) */ - gainMax = limGainTab[sbrHdr->limiterGains]; - if (sbrHdr->limiterGains != 3) { - q = MULSHIFT32(sumEOrigMapped, gainMax); /* Q(fbitsDQ - ACC_SCALE - 2), gainMax = Q30 */ - z = CLZ(sumECurr) - 1; - r = InvRNormalized(sumECurr << z); /* in = Q(z - eCurrExpMax), out = Q(29 + 31 - z + eCurrExpMax) */ - gainMax = MULSHIFT32(q, r); /* Q(29 + 31 - z + eCurrExpMax + fbitsDQ - ACC_SCALE - 2 - 32) */ - psi->gainMaxFBits = 26 - z + eCurrExpMax + fbitsDQ - ACC_SCALE; - } - } - psi->sumEOrigMapped = sumEOrigMapped; - psi->gainMax = gainMax; -} - -/************************************************************************************** - * Function: CalcNoiseDivFactors - * - * Description: calculate 1/(1+Q) and Q/(1+Q) (4.6.18.7.4; 4.6.18.7.5) - * - * Inputs: dequantized noise floor scalefactor - * - * Outputs: 1/(1+Q) and Q/(1+Q), format = Q31 - * - * Return: none - **************************************************************************************/ -static void CalcNoiseDivFactors(int q, int *qp1Inv, int *qqp1Inv) -{ - int z, qp1, t, s; - - /* 1 + Q_orig */ - qp1 = (q >> 1); - qp1 += (1 << (FBITS_OUT_DQ_NOISE - 1)); /* >> 1 to avoid overflow when adding 1.0 */ - z = CLZ(qp1) - 1; /* z <= 31 - FBITS_OUT_DQ_NOISE */ - qp1 <<= z; /* Q(FBITS_OUT_DQ_NOISE + z) = Q31 * 2^-(31 - (FBITS_OUT_DQ_NOISE + z)) */ - t = InvRNormalized(qp1) << 1; /* Q30 * 2^(31 - (FBITS_OUT_DQ_NOISE + z)), guaranteed not to overflow */ - - /* normalize to Q31 */ - s = (31 - (FBITS_OUT_DQ_NOISE - 1) - z - 1); /* clearly z >= 0, z <= (30 - (FBITS_OUT_DQ_NOISE - 1)) */ - *qp1Inv = (t >> s); /* s = [0, 31 - FBITS_OUT_DQ_NOISE] */ - *qqp1Inv = MULSHIFT32(t, q) << (32 - FBITS_OUT_DQ_NOISE - s); -} - -/************************************************************************************** - * Function: CalcComponentGains - * - * Description: calculate gain of envelope, sinusoids, and noise in one limiter band - * (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * index of current limiter band - * number of fraction bits in dequantized envelope - * - * Outputs: gains for envelope, sinusoids and noise - * number of fraction bits for envelope gain - * sum of the total gain for each component in this band - * other updated state variables - * - * Return: none - **************************************************************************************/ -static void CalcComponentGains(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env, int lim, int fbitsDQ) -{ - int d, m, mStart, mEnd, q, qm, noiseFloor, sIndexMapped; - int shift, eCurr, maxFlag, gainMax, gainMaxFBits; - int gain, sm, z, r, fbitsGain, gainScale; - unsigned char *freqBandTab; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - - gainMax = psi->gainMax; - gainMaxFBits = psi->gainMaxFBits; - - d = (env == psi->la || env == sbrChan->laPrev ? 0 : 1); - freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow); - - /* figure out which noise floor this envelope is in (only 1 or 2 noise floors allowed) */ - noiseFloor = 0; - if (sbrGrid->numNoiseFloors == 2 && sbrGrid->noiseTimeBorder[1] <= sbrGrid->envTimeBorder[env]) - noiseFloor++; - - psi->sumECurrGLim = 0; - psi->sumSM = 0; - psi->sumQM = 0; - /* calculate energy of noise to add in this limiter band */ - for (m = mStart; m < mEnd; m++) { - if (m == sbrFreq->freqNoise[psi->noiseFloorBand + 1] - sbrFreq->kStart) { - /* map current QMF band to appropriate noise floor band (NOTE: freqLimiter[0] == freqLow[0] = freqHigh[0]) */ - psi->noiseFloorBand++; - CalcNoiseDivFactors(psi->noiseDataDequant[ch][noiseFloor][psi->noiseFloorBand], &(psi->qp1Inv), &(psi->qqp1Inv)); - } - if (m == sbrFreq->freqHigh[psi->highBand + 1] - sbrFreq->kStart) - psi->highBand++; - if (m == freqBandTab[psi->sBand + 1] - sbrFreq->kStart) { - psi->sBand++; - psi->sMapped = GetSMapped(sbrGrid, sbrFreq, sbrChan, env, psi->sBand, psi->la); - } - - /* get sIndexMapped for this QMF subband */ - sIndexMapped = 0; - r = ((sbrFreq->freqHigh[psi->highBand+1] + sbrFreq->freqHigh[psi->highBand]) >> 1); - if (m + sbrFreq->kStart == r) { - /* r = center frequency, deltaStep = (env >= la || sIndexMapped'(r, numEnv'-1) == 1) */ - if (env >= psi->la || sbrChan->addHarmonic[0][r] == 1) - sIndexMapped = sbrChan->addHarmonic[1][psi->highBand]; - } - - /* save sine flags from last envelope in this frame: - * addHarmonic[0][0...63] = saved sine present flag from previous frame, for each QMF subband - * addHarmonic[1][0...nHigh-1] = addHarmonic bit from current frame, for each high-res frequency band - * from MPEG reference code - slightly different from spec - * (sIndexMapped'(m,LE'-1) can still be 0 when numEnv == psi->la) - */ - if (env == sbrGrid->numEnv - 1) { - if (m + sbrFreq->kStart == r) - sbrChan->addHarmonic[0][m + sbrFreq->kStart] = sbrChan->addHarmonic[1][psi->highBand]; - else - sbrChan->addHarmonic[0][m + sbrFreq->kStart] = 0; - } - - gain = psi->envDataDequant[ch][env][psi->sBand]; - qm = MULSHIFT32(gain, psi->qqp1Inv) << 1; - sm = (sIndexMapped ? MULSHIFT32(gain, psi->qp1Inv) << 1 : 0); - - /* three cases: (sMapped == 0 && delta == 1), (sMapped == 0 && delta == 0), (sMapped == 1) */ - if (d == 1 && psi->sMapped == 0) - gain = MULSHIFT32(psi->qp1Inv, gain) << 1; - else if (psi->sMapped != 0) - gain = MULSHIFT32(psi->qqp1Inv, gain) << 1; - - /* gain, qm, sm = Q(fbitsDQ), gainMax = Q(fbitsGainMax) */ - eCurr = psi->eCurr[m]; - if (eCurr) { - z = CLZ(eCurr) - 1; - r = InvRNormalized(eCurr << z); /* in = Q(z - eCurrExp), out = Q(29 + 31 - z + eCurrExp) */ - gainScale = MULSHIFT32(gain, r); /* out = Q(29 + 31 - z + eCurrExp + fbitsDQ - 32) */ - fbitsGain = 29 + 31 - z + psi->eCurrExp[m] + fbitsDQ - 32; - } else { - /* if eCurr == 0, then gain is unchanged (divide by EPS = 1) */ - gainScale = gain; - fbitsGain = fbitsDQ; - } - - /* see if gain for this band exceeds max gain */ - maxFlag = 0; - if (gainMax != (int)0x80000000) { - if (fbitsGain >= gainMaxFBits) { - shift = MIN(fbitsGain - gainMaxFBits, 31); - maxFlag = ((gainScale >> shift) > gainMax ? 1 : 0); - } else { - shift = MIN(gainMaxFBits - fbitsGain, 31); - maxFlag = (gainScale > (gainMax >> shift) ? 1 : 0); - } - } - - if (maxFlag) { - /* gainScale > gainMax, calculate ratio with 32/16 division */ - q = 0; - r = gainScale; /* guaranteed > 0, else maxFlag could not have been set */ - z = CLZ(r); - if (z < 16) { - q = 16 - z; - r >>= q; /* out = Q(fbitsGain - q) */ - } - - z = CLZ(gainMax) - 1; - r = (gainMax << z) / r; /* out = Q((fbitsGainMax + z) - (fbitsGain - q)) */ - q = (gainMaxFBits + z) - (fbitsGain - q); /* r = Q(q) */ - if (q > 30) { - r >>= MIN(q - 30, 31); - } else { - z = MIN(30 - q, 30); - CLIP_2N_SHIFT30(r, z); /* let r = Q30 since range = [0.0, 1.0) (clip to 0x3fffffff = 0.99999) */ - } - - qm = MULSHIFT32(qm, r) << 2; - gain = MULSHIFT32(gain, r) << 2; - psi->gLimBuf[m] = gainMax; - psi->gLimFbits[m] = gainMaxFBits; - } else { - psi->gLimBuf[m] = gainScale; - psi->gLimFbits[m] = fbitsGain; - } - - /* sumSM, sumQM, sumECurrGLim = Q(fbitsDQ - ACC_SCALE) */ - psi->smBuf[m] = sm; - psi->sumSM += (sm >> ACC_SCALE); - - psi->qmLimBuf[m] = qm; - if (env != psi->la && env != sbrChan->laPrev && sm == 0) - psi->sumQM += (qm >> ACC_SCALE); - - /* eCurr * gain^2 same as gain^2, before division by eCurr - * (but note that gain != 0 even if eCurr == 0, since it's divided by eps) - */ - if (eCurr) - psi->sumECurrGLim += (gain >> ACC_SCALE); - } -} - -/************************************************************************************** - * Function: ApplyBoost - * - * Description: calculate and apply boost factor for envelope, sinusoids, and noise - * in this limiter band (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRFreq struct for this SCE/CPE block - * index of current limiter band - * number of fraction bits in dequantized envelope - * - * Outputs: envelope gain, sinusoids and noise after scaling by gBoost - * format = Q(FBITS_GLIM_BOOST) for envelope gain, - * = Q(FBITS_QLIM_BOOST) for noise - * = Q(FBITS_OUT_QMFA) for sinusoids - * - * Return: none - * - * Notes: after scaling, each component has at least 1 GB - **************************************************************************************/ -static void ApplyBoost(PSInfoSBR *psi, SBRFreq *sbrFreq, int lim, int fbitsDQ) -{ - int m, mStart, mEnd, q, z, r; - int sumEOrigMapped, gBoost; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - - sumEOrigMapped = psi->sumEOrigMapped >> 1; - r = (psi->sumECurrGLim >> 1) + (psi->sumSM >> 1) + (psi->sumQM >> 1); /* 1 GB fine (sm and qm are mutually exclusive in acc) */ - if (r < (1 << (31-28))) { - /* any non-zero numerator * 1/EPS_0 is > GBOOST_MAX - * round very small r to zero to avoid scaling problems - */ - gBoost = (sumEOrigMapped == 0 ? (1 << 28) : GBOOST_MAX); - z = 0; - } else if (sumEOrigMapped == 0) { - /* 1/(any non-zero denominator) * EPS_0 is appx. 0 */ - gBoost = 0; - z = 0; - } else { - /* numerator (sumEOrigMapped) and denominator (r) have same Q format (before << z) */ - z = CLZ(r) - 1; /* z = [0, 27] */ - r = InvRNormalized(r << z); - gBoost = MULSHIFT32(sumEOrigMapped, r); - } - - /* gBoost = Q(28 - z) */ - if (gBoost > (GBOOST_MAX >> z)) { - gBoost = GBOOST_MAX; - z = 0; - } - gBoost <<= z; /* gBoost = Q28, minimum 1 GB */ - - /* convert gain, noise, sinusoids to fixed Q format, clipping if necessary - * (rare, usually only happens at very low bitrates, introduces slight - * distortion into final HF mapping, but should be inaudible) - */ - for (m = mStart; m < mEnd; m++) { - /* let gLimBoost = Q24, since in practice the max values are usually 16 to 20 - * unless limiterGains == 3 (limiter off) and eCurr ~= 0 (i.e. huge gain, but only - * because the envelope has 0 power anyway) - */ - q = MULSHIFT32(psi->gLimBuf[m], gBoost) << 2; /* Q(gLimFbits) * Q(28) --> Q(gLimFbits[m]-2) */ - r = SqrtFix(q, psi->gLimFbits[m] - 2, &z); - z -= FBITS_GLIM_BOOST; - if (z >= 0) { - psi->gLimBoost[m] = r >> MIN(z, 31); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->gLimBoost[m] = r; - } - - q = MULSHIFT32(psi->qmLimBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */ - r = SqrtFix(q, fbitsDQ - 2, &z); - z -= FBITS_QLIM_BOOST; /* << by 14, since integer sqrt of x < 2^16, and we want to leave 1 GB */ - if (z >= 0) { - psi->qmLimBoost[m] = r >> MIN(31, z); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->qmLimBoost[m] = r; - } - - q = MULSHIFT32(psi->smBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */ - r = SqrtFix(q, fbitsDQ - 2, &z); - z -= FBITS_OUT_QMFA; /* justify for adding to signal (xBuf) later */ - if (z >= 0) { - psi->smBoost[m] = r >> MIN(31, z); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->smBoost[m] = r; - } - } -} - -/************************************************************************************** - * Function: CalcGain - * - * Description: calculate and apply proper gain to HF components in one envelope - * (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * - * Outputs: envelope gain, sinusoids and noise after scaling - * - * Return: none - **************************************************************************************/ -static void CalcGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env) -{ - int lim, fbitsDQ; - - /* initialize to -1 so that mapping limiter bands to env/noise bands works right on first pass */ - psi->envBand = -1; - psi->noiseFloorBand = -1; - psi->sBand = -1; - psi->highBand = -1; - - fbitsDQ = (FBITS_OUT_DQ_ENV - psi->envDataDequantScale[ch][env]); /* Q(29 - optional scalefactor) */ - for (lim = 0; lim < sbrFreq->nLimiter; lim++) { - /* the QMF bands are divided into lim regions (consecutive, non-overlapping) */ - CalcMaxGain(psi, sbrHdr, sbrGrid, sbrFreq, ch, env, lim, fbitsDQ); - CalcComponentGains(psi, sbrGrid, sbrFreq, sbrChan, ch, env, lim, fbitsDQ); - ApplyBoost(psi, sbrFreq, lim, fbitsDQ); - } -} - -/* hSmooth table from 4.7.18.7.6, format = Q31 */ -static const int hSmoothCoef[MAX_NUM_SMOOTH_COEFS] PROGMEM = { - 0x2aaaaaab, 0x2697a512, 0x1becfa68, 0x0ebdb043, 0x04130598, -}; - -/************************************************************************************** - * Function: MapHF - * - * Description: map HF components to proper QMF bands, with optional gain smoothing - * filter (4.6.18.7.6) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current envelope - * reset flag (can be non-zero for first envelope only) - * - * Outputs: complete reconstructed subband QMF samples for this envelope - * - * Return: none - * - * Notes: ensures that output has >= MIN_GBITS_IN_QMFS guard bits, - * so it's not necessary to check anything in the synth QMF - **************************************************************************************/ -static void MapHF(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int hfReset) -{ - int noiseTabIndex, sinIndex, gainNoiseIndex, hSL; - int i, iStart, iEnd, m, idx, j, s, n, smre, smim; - int gFilt, qFilt, xre, xim, gbMask, gbIdx; - int *XBuf; - - noiseTabIndex = sbrChan->noiseTabIndex; - sinIndex = sbrChan->sinIndex; - gainNoiseIndex = sbrChan->gainNoiseIndex; /* oldest entries in filter delay buffer */ - - if (hfReset) - noiseTabIndex = 2; /* starts at 1, double since complex */ - hSL = (sbrHdr->smoothMode ? 0 : 4); - - if (hfReset) { - for (i = 0; i < hSL; i++) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m]; - sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m]; - } - gainNoiseIndex++; - if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) - gainNoiseIndex = 0; - } - ASSERT(env == 0); /* should only be reset when env == 0 */ - } - - iStart = sbrGrid->envTimeBorder[env]; - iEnd = sbrGrid->envTimeBorder[env+1]; - for (i = iStart; i < iEnd; i++) { - /* save new values in temp buffers (delay) - * we only store MAX_NUM_SMOOTH_COEFS most recent values, - * so don't keep storing the same value over and over - */ - if (i - iStart < MAX_NUM_SMOOTH_COEFS) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m]; - sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m]; - } - } - - /* see 4.6.18.7.6 */ - XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart]; - gbMask = 0; - for (m = 0; m < sbrFreq->numQMFBands; m++) { - if (env == psi->la || env == sbrChan->laPrev) { - /* no smoothing filter for gain, and qFilt = 0 (only need to do once) */ - if (i == iStart) { - psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m]; - psi->qFiltLast[m] = 0; - } - } else if (hSL == 0) { - /* no smoothing filter for gain, (only need to do once) */ - if (i == iStart) { - psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m]; - psi->qFiltLast[m] = sbrChan->qTemp[gainNoiseIndex][m]; - } - } else { - /* apply smoothing filter to gain and noise (after MAX_NUM_SMOOTH_COEFS, it's always the same) */ - if (i - iStart < MAX_NUM_SMOOTH_COEFS) { - gFilt = 0; - qFilt = 0; - idx = gainNoiseIndex; - for (j = 0; j < MAX_NUM_SMOOTH_COEFS; j++) { - /* sum(abs(hSmoothCoef[j])) for all j < 1.0 */ - gFilt += MULSHIFT32(sbrChan->gTemp[idx][m], hSmoothCoef[j]); - qFilt += MULSHIFT32(sbrChan->qTemp[idx][m], hSmoothCoef[j]); - idx--; - if (idx < 0) - idx += MAX_NUM_SMOOTH_COEFS; - } - psi->gFiltLast[m] = gFilt << 1; /* restore to Q(FBITS_GLIM_BOOST) (gain of filter < 1.0, so no overflow) */ - psi->qFiltLast[m] = qFilt << 1; /* restore to Q(FBITS_QLIM_BOOST) */ - } - } - - if (psi->smBoost[m] != 0) { - /* add scaled signal and sinusoid, don't add noise (qFilt = 0) */ - smre = psi->smBoost[m]; - smim = smre; - - /* sinIndex: [0] xre += sm [1] xim += sm*s [2] xre -= sm [3] xim -= sm*s */ - s = (sinIndex >> 1); /* if 2 or 3, flip sign to subtract sm */ - s <<= 31; - smre ^= (s >> 31); - smre -= (s >> 31); - s ^= ((m + sbrFreq->kStart) << 31); - smim ^= (s >> 31); - smim -= (s >> 31); - - /* if sinIndex == 0 or 2, smim = 0; if sinIndex == 1 or 3, smre = 0 */ - s = sinIndex << 31; - smim &= (s >> 31); - s ^= 0x80000000; - smre &= (s >> 31); - - noiseTabIndex += 2; /* noise filtered by 0, but still need to bump index */ - } else { - /* add scaled signal and scaled noise */ - qFilt = psi->qFiltLast[m]; - n = noiseTab[noiseTabIndex++]; - smre = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA); - - n = noiseTab[noiseTabIndex++]; - smim = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA); - } - noiseTabIndex &= 1023; /* 512 complex numbers */ - - gFilt = psi->gFiltLast[m]; - xre = MULSHIFT32(gFilt, XBuf[0]); - xim = MULSHIFT32(gFilt, XBuf[1]); - CLIP_2N_SHIFT30(xre, 32 - FBITS_GLIM_BOOST); - CLIP_2N_SHIFT30(xim, 32 - FBITS_GLIM_BOOST); - - xre += smre; *XBuf++ = xre; - xim += smim; *XBuf++ = xim; - - gbMask |= FASTABS(xre); - gbMask |= FASTABS(xim); - } - /* update circular buffer index */ - gainNoiseIndex++; - if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) - gainNoiseIndex = 0; - - sinIndex++; - sinIndex &= 3; - - /* ensure MIN_GBITS_IN_QMFS guard bits in output - * almost never occurs in practice, but checking here makes synth QMF logic very simple - */ - if (gbMask >> (31 - MIN_GBITS_IN_QMFS)) { - XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart]; - for (m = 0; m < sbrFreq->numQMFBands; m++) { - xre = XBuf[0]; xim = XBuf[1]; - CLIP_2N(xre, (31 - MIN_GBITS_IN_QMFS)); - CLIP_2N(xim, (31 - MIN_GBITS_IN_QMFS)); - *XBuf++ = xre; *XBuf++ = xim; - } - CLIP_2N(gbMask, (31 - MIN_GBITS_IN_QMFS)); - } - gbIdx = ((i + HF_ADJ) >> 5) & 0x01; - sbrChan->gbMask[gbIdx] |= gbMask; - } - sbrChan->noiseTabIndex = noiseTabIndex; - sbrChan->sinIndex = sinIndex; - sbrChan->gainNoiseIndex = gainNoiseIndex; -} - -/************************************************************************************** - * Function: AdjustHighFreq - * - * Description: adjust high frequencies and add noise and sinusoids (4.6.18.7) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: complete reconstructed subband QMF samples for this channel - * - * Return: none - **************************************************************************************/ -void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int i, env, hfReset; - unsigned char frameClass, pointer; - - frameClass = sbrGrid->frameClass; - pointer = sbrGrid->pointer; - - /* derive la from table 4.159 */ - if ((frameClass == SBR_GRID_FIXVAR || frameClass == SBR_GRID_VARVAR) && pointer > 0) - psi->la = sbrGrid->numEnv + 1 - pointer; - else if (frameClass == SBR_GRID_VARFIX && pointer > 1) - psi->la = pointer - 1; - else - psi->la = -1; - - /* for each envelope, estimate gain and adjust SBR QMF bands */ - hfReset = sbrChan->reset; - for (env = 0; env < sbrGrid->numEnv; env++) { - EstimateEnvelope(psi, sbrHdr, sbrGrid, sbrFreq, env); - CalcGain(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch, env); - MapHF(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, env, hfReset); - hfReset = 0; /* only set for first envelope after header reset */ - } - - /* set saved sine flags to 0 for QMF bands outside of current frequency range */ - for (i = 0; i < sbrFreq->freqLimiter[0] + sbrFreq->kStart; i++) - sbrChan->addHarmonic[0][i] = 0; - for (i = sbrFreq->freqLimiter[sbrFreq->nLimiter] + sbrFreq->kStart; i < 64; i++) - sbrChan->addHarmonic[0][i] = 0; - sbrChan->addHarmonicFlag[0] = sbrChan->addHarmonicFlag[1]; - - /* save la for next frame */ - if (psi->la == sbrGrid->numEnv) - sbrChan->laPrev = 0; - else - sbrChan->laPrev = -1; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfgen.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfgen.c deleted file mode 100644 index e5f27eb6..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhfgen.c +++ /dev/null @@ -1,616 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhfgen.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhfgen.c - high frequency generation for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define FBITS_LPCOEFS 29 /* Q29 for range of (-4, 4) */ -#define MAG_16 (16 * (1 << (32 - (2*(32-FBITS_LPCOEFS))))) /* i.e. 16 in Q26 format */ -#define RELAX_COEF 0x7ffff79c /* 1.0 / (1.0 + 1e-6), Q31 */ - -/* newBWTab[prev invfMode][curr invfMode], format = Q31 (table 4.158) - * sample file which uses all of these: al_sbr_sr_64_2_fsaac32.aac - */ -static const int newBWTab[4][4] PROGMEM = { - {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7}, - {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7}, - {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, - {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, -}; - -/************************************************************************************** - * Function: CVKernel1 - * - * Description: kernel of covariance matrix calculation for p01, p11, p12, p22 - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: 64-bit accumulators for p01re, p01im, p12re, p12im, p11re, p22re - * stored in accBuf - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrcov.s when building for ARM! - **************************************************************************************/ -#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__)) -#ifdef __cplusplus -extern "C" -#endif -void CVKernel1(int *XBuf, int *accBuf); -#else -void CVKernel1(int *XBuf, int *accBuf) -{ - U64 p01re, p01im, p12re, p12im, p11re, p22re; - int n, x0re, x0im, x1re, x1im; - - x0re = XBuf[0]; - x0im = XBuf[1]; - XBuf += (2*64); - x1re = XBuf[0]; - x1im = XBuf[1]; - XBuf += (2*64); - - p01re.w64 = p01im.w64 = 0; - p12re.w64 = p12im.w64 = 0; - p11re.w64 = 0; - p22re.w64 = 0; - - p12re.w64 = MADD64(p12re.w64, x1re, x0re); - p12re.w64 = MADD64(p12re.w64, x1im, x0im); - p12im.w64 = MADD64(p12im.w64, x0re, x1im); - p12im.w64 = MADD64(p12im.w64, -x0im, x1re); - p22re.w64 = MADD64(p22re.w64, x0re, x0re); - p22re.w64 = MADD64(p22re.w64, x0im, x0im); - for (n = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6); n != 0; n--) { - /* 4 input, 3*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */ - x0re = x1re; - x0im = x1im; - x1re = XBuf[0]; - x1im = XBuf[1]; - - p01re.w64 = MADD64(p01re.w64, x1re, x0re); - p01re.w64 = MADD64(p01re.w64, x1im, x0im); - p01im.w64 = MADD64(p01im.w64, x0re, x1im); - p01im.w64 = MADD64(p01im.w64, -x0im, x1re); - p11re.w64 = MADD64(p11re.w64, x0re, x0re); - p11re.w64 = MADD64(p11re.w64, x0im, x0im); - - XBuf += (2*64); - } - /* these can be derived by slight changes to account for boundary conditions */ - p12re.w64 += p01re.w64; - p12re.w64 = MADD64(p12re.w64, x1re, -x0re); - p12re.w64 = MADD64(p12re.w64, x1im, -x0im); - p12im.w64 += p01im.w64; - p12im.w64 = MADD64(p12im.w64, x0re, -x1im); - p12im.w64 = MADD64(p12im.w64, x0im, x1re); - p22re.w64 += p11re.w64; - p22re.w64 = MADD64(p22re.w64, x0re, -x0re); - p22re.w64 = MADD64(p22re.w64, x0im, -x0im); - - accBuf[0] = p01re.r.lo32; accBuf[1] = p01re.r.hi32; - accBuf[2] = p01im.r.lo32; accBuf[3] = p01im.r.hi32; - accBuf[4] = p11re.r.lo32; accBuf[5] = p11re.r.hi32; - accBuf[6] = p12re.r.lo32; accBuf[7] = p12re.r.hi32; - accBuf[8] = p12im.r.lo32; accBuf[9] = p12im.r.hi32; - accBuf[10] = p22re.r.lo32; accBuf[11] = p22re.r.hi32; -} -#endif - -/************************************************************************************** - * Function: CalcCovariance1 - * - * Description: calculate covariance matrix for p01, p12, p11, p22 (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index 0, - * freq index = patch subband - * - * Outputs: complex covariance elements p01re, p01im, p12re, p12im, p11re, p22re - * (p11im = p22im = 0) - * format = integer (Q0) * 2^N, with scalefactor N >= 0 - * - * Return: scalefactor N - * - * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits) - **************************************************************************************/ -static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int *p12imN, int *p11reN, int *p22reN) -{ - int accBuf[2*6]; - int n, z, s, loShift, hiShift, gbMask; - U64 p01re, p01im, p12re, p12im, p11re, p22re; - - CVKernel1(XBuf, accBuf); - p01re.r.lo32 = accBuf[0]; p01re.r.hi32 = accBuf[1]; - p01im.r.lo32 = accBuf[2]; p01im.r.hi32 = accBuf[3]; - p11re.r.lo32 = accBuf[4]; p11re.r.hi32 = accBuf[5]; - p12re.r.lo32 = accBuf[6]; p12re.r.hi32 = accBuf[7]; - p12im.r.lo32 = accBuf[8]; p12im.r.hi32 = accBuf[9]; - p22re.r.lo32 = accBuf[10]; p22re.r.hi32 = accBuf[11]; - - /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits - * want to scale them down to integers (32-bit signed, Q0) - * with scale factor of 2^n, n >= 0 - * leave 2 GB's for calculating determinant, so take top 30 non-zero bits - */ - gbMask = ((p01re.r.hi32) ^ (p01re.r.hi32 >> 31)) | ((p01im.r.hi32) ^ (p01im.r.hi32 >> 31)); - gbMask |= ((p12re.r.hi32) ^ (p12re.r.hi32 >> 31)) | ((p12im.r.hi32) ^ (p12im.r.hi32 >> 31)); - gbMask |= ((p11re.r.hi32) ^ (p11re.r.hi32 >> 31)) | ((p22re.r.hi32) ^ (p22re.r.hi32 >> 31)); - if (gbMask == 0) { - s = p01re.r.hi32 >> 31; gbMask = (p01re.r.lo32 ^ s) - s; - s = p01im.r.hi32 >> 31; gbMask |= (p01im.r.lo32 ^ s) - s; - s = p12re.r.hi32 >> 31; gbMask |= (p12re.r.lo32 ^ s) - s; - s = p12im.r.hi32 >> 31; gbMask |= (p12im.r.lo32 ^ s) - s; - s = p11re.r.hi32 >> 31; gbMask |= (p11re.r.lo32 ^ s) - s; - s = p22re.r.hi32 >> 31; gbMask |= (p22re.r.lo32 ^ s) - s; - z = 32 + CLZ(gbMask); - } else { - gbMask = FASTABS(p01re.r.hi32) | FASTABS(p01im.r.hi32); - gbMask |= FASTABS(p12re.r.hi32) | FASTABS(p12im.r.hi32); - gbMask |= FASTABS(p11re.r.hi32) | FASTABS(p22re.r.hi32); - z = CLZ(gbMask); - } - - n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */ - if (n <= 30) { - loShift = (30 - n); - *p01reN = p01re.r.lo32 << loShift; *p01imN = p01im.r.lo32 << loShift; - *p12reN = p12re.r.lo32 << loShift; *p12imN = p12im.r.lo32 << loShift; - *p11reN = p11re.r.lo32 << loShift; *p22reN = p22re.r.lo32 << loShift; - return -(loShift + 2*FBITS_OUT_QMFA); - } else if (n < 32 + 30) { - loShift = (n - 30); - hiShift = 32 - loShift; - *p01reN = (p01re.r.hi32 << hiShift) | (p01re.r.lo32 >> loShift); - *p01imN = (p01im.r.hi32 << hiShift) | (p01im.r.lo32 >> loShift); - *p12reN = (p12re.r.hi32 << hiShift) | (p12re.r.lo32 >> loShift); - *p12imN = (p12im.r.hi32 << hiShift) | (p12im.r.lo32 >> loShift); - *p11reN = (p11re.r.hi32 << hiShift) | (p11re.r.lo32 >> loShift); - *p22reN = (p22re.r.hi32 << hiShift) | (p22re.r.lo32 >> loShift); - return (loShift - 2*FBITS_OUT_QMFA); - } else { - hiShift = n - (32 + 30); - *p01reN = p01re.r.hi32 >> hiShift; *p01imN = p01im.r.hi32 >> hiShift; - *p12reN = p12re.r.hi32 >> hiShift; *p12imN = p12im.r.hi32 >> hiShift; - *p11reN = p11re.r.hi32 >> hiShift; *p22reN = p22re.r.hi32 >> hiShift; - return (32 - 2*FBITS_OUT_QMFA - hiShift); - } - - return 0; -} - -/************************************************************************************** - * Function: CVKernel2 - * - * Description: kernel of covariance matrix calculation for p02 - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: 64-bit accumulators for p02re, p02im stored in accBuf - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrcov.s when building for ARM! - **************************************************************************************/ -#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__)) -#ifdef __cplusplus -extern "C" -#endif -void CVKernel2(int *XBuf, int *accBuf); -#else -void CVKernel2(int *XBuf, int *accBuf) -{ - U64 p02re, p02im; - int n, x0re, x0im, x1re, x1im, x2re, x2im; - - p02re.w64 = p02im.w64 = 0; - - x0re = XBuf[0]; - x0im = XBuf[1]; - XBuf += (2*64); - x1re = XBuf[0]; - x1im = XBuf[1]; - XBuf += (2*64); - - for (n = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6); n != 0; n--) { - /* 6 input, 2*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */ - x2re = XBuf[0]; - x2im = XBuf[1]; - - p02re.w64 = MADD64(p02re.w64, x2re, x0re); - p02re.w64 = MADD64(p02re.w64, x2im, x0im); - p02im.w64 = MADD64(p02im.w64, x0re, x2im); - p02im.w64 = MADD64(p02im.w64, -x0im, x2re); - - x0re = x1re; - x0im = x1im; - x1re = x2re; - x1im = x2im; - XBuf += (2*64); - } - - accBuf[0] = p02re.r.lo32; - accBuf[1] = p02re.r.hi32; - accBuf[2] = p02im.r.lo32; - accBuf[3] = p02im.r.hi32; -} -#endif - -/************************************************************************************** - * Function: CalcCovariance2 - * - * Description: calculate covariance matrix for p02 (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: complex covariance element p02re, p02im - * format = integer (Q0) * 2^N, with scalefactor N >= 0 - * - * Return: scalefactor N - * - * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits) - **************************************************************************************/ -static int CalcCovariance2(int *XBuf, int *p02reN, int *p02imN) -{ - U64 p02re, p02im; - int n, z, s, loShift, hiShift, gbMask; - int accBuf[2*2]; - - CVKernel2(XBuf, accBuf); - p02re.r.lo32 = accBuf[0]; - p02re.r.hi32 = accBuf[1]; - p02im.r.lo32 = accBuf[2]; - p02im.r.hi32 = accBuf[3]; - - /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits - * want to scale them down to integers (32-bit signed, Q0) - * with scale factor of 2^n, n >= 0 - * leave 1 GB for calculating determinant, so take top 30 non-zero bits - */ - gbMask = ((p02re.r.hi32) ^ (p02re.r.hi32 >> 31)) | ((p02im.r.hi32) ^ (p02im.r.hi32 >> 31)); - if (gbMask == 0) { - s = p02re.r.hi32 >> 31; gbMask = (p02re.r.lo32 ^ s) - s; - s = p02im.r.hi32 >> 31; gbMask |= (p02im.r.lo32 ^ s) - s; - z = 32 + CLZ(gbMask); - } else { - gbMask = FASTABS(p02re.r.hi32) | FASTABS(p02im.r.hi32); - z = CLZ(gbMask); - } - n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */ - - if (n <= 30) { - loShift = (30 - n); - *p02reN = p02re.r.lo32 << loShift; - *p02imN = p02im.r.lo32 << loShift; - return -(loShift + 2*FBITS_OUT_QMFA); - } else if (n < 32 + 30) { - loShift = (n - 30); - hiShift = 32 - loShift; - *p02reN = (p02re.r.hi32 << hiShift) | (p02re.r.lo32 >> loShift); - *p02imN = (p02im.r.hi32 << hiShift) | (p02im.r.lo32 >> loShift); - return (loShift - 2*FBITS_OUT_QMFA); - } else { - hiShift = n - (32 + 30); - *p02reN = p02re.r.hi32 >> hiShift; - *p02imN = p02im.r.hi32 >> hiShift; - return (32 - 2*FBITS_OUT_QMFA - hiShift); - } - - return 0; -} - -/************************************************************************************** - * Function: CalcLPCoefs - * - * Description: calculate linear prediction coefficients for one subband (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * number of guard bits in input sample buffer - * - * Outputs: complex LP coefficients a0re, a0im, a1re, a1im, format = Q29 - * - * Return: none - * - * Notes: output coefficients (a0re, a0im, a1re, a1im) clipped to range (-4, 4) - * if the comples coefficients have magnitude >= 4.0, they are all - * set to 0 (see spec) - **************************************************************************************/ -static void CalcLPCoefs(int *XBuf, int *a0re, int *a0im, int *a1re, int *a1im, int gb) -{ - int zFlag, n1, n2, nd, d, dInv, tre, tim; - int p01re, p01im, p02re, p02im, p12re, p12im, p11re, p22re; - - /* pre-scale to avoid overflow - probably never happens in practice (see QMFA) - * max bit growth per accumulator = 38*2 = 76 mul-adds (X * X) - * using 64-bit MADD, so if X has n guard bits, X*X has 2n+1 guard bits - * gain 1 extra sign bit per multiply, so ensure ceil(log2(76/2) / 2) = 3 guard bits on inputs - */ - if (gb < 3) { - nd = 3 - gb; - for (n1 = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) { - XBuf[0] >>= nd; XBuf[1] >>= nd; - XBuf += (2*64); - } - XBuf -= (2*64*(NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2)); - } - - /* calculate covariance elements */ - n1 = CalcCovariance1(XBuf, &p01re, &p01im, &p12re, &p12im, &p11re, &p22re); - n2 = CalcCovariance2(XBuf, &p02re, &p02im); - - /* normalize everything to larger power of 2 scalefactor, call it n1 */ - if (n1 < n2) { - nd = MIN(n2 - n1, 31); - p01re >>= nd; p01im >>= nd; - p12re >>= nd; p12im >>= nd; - p11re >>= nd; p22re >>= nd; - n1 = n2; - } else if (n1 > n2) { - nd = MIN(n1 - n2, 31); - p02re >>= nd; p02im >>= nd; - } - - /* calculate determinant of covariance matrix (at least 1 GB in pXX) */ - d = MULSHIFT32(p12re, p12re) + MULSHIFT32(p12im, p12im); - d = MULSHIFT32(d, RELAX_COEF) << 1; - d = MULSHIFT32(p11re, p22re) - d; - ASSERT(d >= 0); /* should never be < 0 */ - - zFlag = 0; - *a0re = *a0im = 0; - *a1re = *a1im = 0; - if (d > 0) { - /* input = Q31 d = Q(-2*n1 - 32 + nd) = Q31 * 2^(31 + 2*n1 + 32 - nd) - * inverse = Q29 dInv = Q29 * 2^(-31 - 2*n1 - 32 + nd) = Q(29 + 31 + 2*n1 + 32 - nd) - * - * numerator has same Q format as d, since it's sum of normalized squares - * so num * inverse = Q(-2*n1 - 32) * Q(29 + 31 + 2*n1 + 32 - nd) - * = Q(29 + 31 - nd), drop low 32 in MULSHIFT32 - * = Q(29 + 31 - 32 - nd) = Q(28 - nd) - */ - nd = CLZ(d) - 1; - d <<= nd; - dInv = InvRNormalized(d); - - /* 1 GB in pXX */ - tre = MULSHIFT32(p01re, p12re) - MULSHIFT32(p01im, p12im) - MULSHIFT32(p02re, p11re); - tre = MULSHIFT32(tre, dInv); - tim = MULSHIFT32(p01re, p12im) + MULSHIFT32(p01im, p12re) - MULSHIFT32(p02im, p11re); - tim = MULSHIFT32(tim, dInv); - - /* if d is extremely small, just set coefs to 0 (would have poor precision anyway) */ - if (nd > 28 || (FASTABS(tre) >> (28 - nd)) >= 4 || (FASTABS(tim) >> (28 - nd)) >= 4) { - zFlag = 1; - } else { - *a1re = tre << (FBITS_LPCOEFS - 28 + nd); /* i.e. convert Q(28 - nd) to Q(29) */ - *a1im = tim << (FBITS_LPCOEFS - 28 + nd); - } - } - - if (p11re) { - /* input = Q31 p11re = Q(-n1 + nd) = Q31 * 2^(31 + n1 - nd) - * inverse = Q29 dInv = Q29 * 2^(-31 - n1 + nd) = Q(29 + 31 + n1 - nd) - * - * numerator is Q(-n1 - 3) - * so num * inverse = Q(-n1 - 3) * Q(29 + 31 + n1 - nd) - * = Q(29 + 31 - 3 - nd), drop low 32 in MULSHIFT32 - * = Q(29 + 31 - 3 - 32 - nd) = Q(25 - nd) - */ - nd = CLZ(p11re) - 1; /* assume positive */ - p11re <<= nd; - dInv = InvRNormalized(p11re); - - /* a1re, a1im = Q29, so scaled by (n1 + 3) */ - tre = (p01re >> 3) + MULSHIFT32(p12re, *a1re) + MULSHIFT32(p12im, *a1im); - tre = -MULSHIFT32(tre, dInv); - tim = (p01im >> 3) - MULSHIFT32(p12im, *a1re) + MULSHIFT32(p12re, *a1im); - tim = -MULSHIFT32(tim, dInv); - - if (nd > 25 || (FASTABS(tre) >> (25 - nd)) >= 4 || (FASTABS(tim) >> (25 - nd)) >= 4) { - zFlag = 1; - } else { - *a0re = tre << (FBITS_LPCOEFS - 25 + nd); /* i.e. convert Q(25 - nd) to Q(29) */ - *a0im = tim << (FBITS_LPCOEFS - 25 + nd); - } - } - - /* see 4.6.18.6.2 - if magnitude of a0 or a1 >= 4 then a0 = a1 = 0 - * i.e. a0re < 4, a0im < 4, a1re < 4, a1im < 4 - * Q29*Q29 = Q26 - */ - if (zFlag || MULSHIFT32(*a0re, *a0re) + MULSHIFT32(*a0im, *a0im) >= MAG_16 || MULSHIFT32(*a1re, *a1re) + MULSHIFT32(*a1im, *a1im) >= MAG_16) { - *a0re = *a0im = 0; - *a1re = *a1im = 0; - } - - /* no need to clip - we never changed the XBuf data, just used it to calculate a0 and a1 */ - if (gb < 3) { - nd = 3 - gb; - for (n1 = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) { - XBuf[0] <<= nd; XBuf[1] <<= nd; - XBuf += (2*64); - } - } -} - -/************************************************************************************** - * Function: GenerateHighFreq - * - * Description: generate high frequencies with SBR (4.6.18.6) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: new high frequency samples starting at frequency kStart - * - * Return: none - **************************************************************************************/ -void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int band, newBW, c, t, gb, gbMask, gbIdx; - int currPatch, p, x, k, g, i, iStart, iEnd, bw, bwsq; - int a0re, a0im, a1re, a1im; - int x1re, x1im, x2re, x2im; - int ACCre, ACCim; - int *XBufLo, *XBufHi; - (void) ch; - - /* calculate array of chirp factors */ - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - c = sbrChan->chirpFact[band]; /* previous (bwArray') */ - newBW = newBWTab[sbrChan->invfMode[0][band]][sbrChan->invfMode[1][band]]; - - /* weighted average of new and old (can't overflow - total gain = 1.0) */ - if (newBW < c) - t = MULSHIFT32(newBW, 0x60000000) + MULSHIFT32(0x20000000, c); /* new is smaller: 0.75*new + 0.25*old */ - else - t = MULSHIFT32(newBW, 0x74000000) + MULSHIFT32(0x0c000000, c); /* new is larger: 0.90625*new + 0.09375*old */ - t <<= 1; - - if (t < 0x02000000) /* below 0.015625, clip to 0 */ - t = 0; - if (t > 0x7f800000) /* clip to 0.99609375 */ - t = 0x7f800000; - - /* save curr as prev for next time */ - sbrChan->chirpFact[band] = t; - sbrChan->invfMode[0][band] = sbrChan->invfMode[1][band]; - } - - iStart = sbrGrid->envTimeBorder[0] + HF_ADJ; - iEnd = sbrGrid->envTimeBorder[sbrGrid->numEnv] + HF_ADJ; - - /* generate new high freqs from low freqs, patches, and chirp factors */ - k = sbrFreq->kStart; - g = 0; - bw = sbrChan->chirpFact[g]; - bwsq = MULSHIFT32(bw, bw) << 1; - - gbMask = (sbrChan->gbMask[0] | sbrChan->gbMask[1]); /* older 32 | newer 8 */ - gb = CLZ(gbMask) - 1; - - for (currPatch = 0; currPatch < sbrFreq->numPatches; currPatch++) { - for (x = 0; x < sbrFreq->patchNumSubbands[currPatch]; x++) { - /* map k to corresponding noise floor band */ - if (k >= sbrFreq->freqNoise[g+1]) { - g++; - bw = sbrChan->chirpFact[g]; /* Q31 */ - bwsq = MULSHIFT32(bw, bw) << 1; /* Q31 */ - } - - p = sbrFreq->patchStartSubband[currPatch] + x; /* low QMF band */ - XBufHi = psi->XBuf[iStart][k]; - if (bw) { - CalcLPCoefs(psi->XBuf[0][p], &a0re, &a0im, &a1re, &a1im, gb); - - a0re = MULSHIFT32(bw, a0re); /* Q31 * Q29 = Q28 */ - a0im = MULSHIFT32(bw, a0im); - a1re = MULSHIFT32(bwsq, a1re); - a1im = MULSHIFT32(bwsq, a1im); - - XBufLo = psi->XBuf[iStart-2][p]; - - x2re = XBufLo[0]; /* RE{XBuf[n-2]} */ - x2im = XBufLo[1]; /* IM{XBuf[n-2]} */ - XBufLo += (64*2); - - x1re = XBufLo[0]; /* RE{XBuf[n-1]} */ - x1im = XBufLo[1]; /* IM{XBuf[n-1]} */ - XBufLo += (64*2); - - for (i = iStart; i < iEnd; i++) { - /* a0re/im, a1re/im are Q28 with at least 1 GB, - * so the summing for AACre/im is fine (1 GB in, plus 1 from MULSHIFT32) - */ - ACCre = MULSHIFT32(x2re, a1re) - MULSHIFT32(x2im, a1im); - ACCim = MULSHIFT32(x2re, a1im) + MULSHIFT32(x2im, a1re); - x2re = x1re; - x2im = x1im; - - ACCre += MULSHIFT32(x1re, a0re) - MULSHIFT32(x1im, a0im); - ACCim += MULSHIFT32(x1re, a0im) + MULSHIFT32(x1im, a0re); - x1re = XBufLo[0]; /* RE{XBuf[n]} */ - x1im = XBufLo[1]; /* IM{XBuf[n]} */ - XBufLo += (64*2); - - /* lost 4 fbits when scaling by a0re/im, a1re/im (Q28) */ - CLIP_2N_SHIFT30(ACCre, 4); - ACCre += x1re; - CLIP_2N_SHIFT30(ACCim, 4); - ACCim += x1im; - - XBufHi[0] = ACCre; - XBufHi[1] = ACCim; - XBufHi += (64*2); - - /* update guard bit masks */ - gbMask = FASTABS(ACCre); - gbMask |= FASTABS(ACCim); - gbIdx = (i >> 5) & 0x01; /* 0 if i < 32, 1 if i >= 32 */ - sbrChan->gbMask[gbIdx] |= gbMask; - } - } else { - XBufLo = (int *)psi->XBuf[iStart][p]; - for (i = iStart; i < iEnd; i++) { - XBufHi[0] = XBufLo[0]; - XBufHi[1] = XBufLo[1]; - XBufLo += (64*2); - XBufHi += (64*2); - } - } - k++; /* high QMF band */ - } - } -} - - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhuff.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhuff.c deleted file mode 100644 index a174e1e8..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrhuff.c +++ /dev/null @@ -1,476 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhuff.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhuff.c - functions for unpacking Huffman-coded envelope and noise data - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/************************************************************************************** - * Function: DecodeHuffmanScalar - * - * Description: decode one Huffman symbol from bitstream - * - * Inputs: pointers to Huffman table and info struct - * left-aligned bit buffer with >= huffTabInfo->maxBits bits - * - * Outputs: decoded symbol in *val - * - * Return: number of bits in symbol - * - * Notes: assumes canonical Huffman codes: - * first CW always 0, we have "count" CW's of length "nBits" bits - * starting CW for codes of length nBits+1 = - * (startCW[nBits] + count[nBits]) << 1 - * if there are no codes at nBits, then we just keep << 1 each time - * (since count[nBits] = 0) - **************************************************************************************/ -static int DecodeHuffmanScalar(const signed /*short*/ int *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val) -{ - unsigned int count, start, shift, t; - const unsigned int /*char*/ *countPtr; - const signed int /*short*/ *map; - - map = huffTab + huffTabInfo->offset; - countPtr = huffTabInfo->count; - - start = 0; - count = 0; - shift = 32; - do { - start += count; - start <<= 1; - map += count; - count = *countPtr++; - shift--; - t = (bitBuf >> shift) - start; - } while (t >= count); - - *val = (signed int)map[t]; - return (countPtr - huffTabInfo->count); -} - -/************************************************************************************** - * Function: DecodeOneSymbol - * - * Description: dequantize one Huffman symbol from bitstream, - * using table huffTabSBR[huffTabIndex] - * - * Inputs: BitStreamInfo struct pointing to start of next Huffman codeword - * index of Huffman table - * - * Outputs: bitstream advanced by number of bits in codeword - * - * Return: one decoded symbol - **************************************************************************************/ -static int DecodeOneSymbol(BitStreamInfo *bsi, int huffTabIndex) -{ - int nBits, val; - unsigned int bitBuf; - const HuffInfo *hi; - - hi = &(huffTabSBRInfo[huffTabIndex]); - - bitBuf = GetBitsNoAdvance(bsi, hi->maxBits) << (32 - hi->maxBits); - nBits = DecodeHuffmanScalar(huffTabSBR, hi, bitBuf, &val); - AdvanceBitstream(bsi, nBits); - - return val; -} - -/* [1.0, sqrt(2)], format = Q29 (one guard bit for decoupling) */ -static const int envDQTab[2] PROGMEM = {0x20000000, 0x2d413ccc}; - -/************************************************************************************** - * Function: DequantizeEnvelope - * - * Description: dequantize envelope scalefactors - * - * Inputs: number of scalefactors to process - * amplitude resolution flag for this frame (0 or 1) - * quantized envelope scalefactors - * - * Outputs: dequantized envelope scalefactors - * - * Return: extra int bits in output (6 + expMax) - * in other words, output format = Q(FBITS_OUT_DQ_ENV - (6 + expMax)) - * - * Notes: dequantized scalefactors have at least 2 GB - **************************************************************************************/ -static int DequantizeEnvelope(int nBands, int ampRes, signed char *envQuant, int *envDequant) -{ - int exp, expMax, i, scalei; - - if (nBands <= 0) - return 0; - - /* scan for largest dequant value (do separately from envelope decoding to keep code cleaner) */ - expMax = 0; - for (i = 0; i < nBands; i++) { - if (envQuant[i] > expMax) - expMax = envQuant[i]; - } - - /* dequantized envelope gains - * envDequant = 64*2^(envQuant / alpha) = 2^(6 + envQuant / alpha) - * if ampRes == 0, alpha = 2 and range of envQuant = [0, 127] - * if ampRes == 1, alpha = 1 and range of envQuant = [0, 63] - * also if coupling is on, envDequant is scaled by something in range [0, 2] - * so range of envDequant = [2^6, 2^69] (no coupling), [2^6, 2^70] (with coupling) - * - * typical range (from observation) of envQuant/alpha = [0, 27] --> largest envQuant ~= 2^33 - * output: Q(29 - (6 + expMax)) - * - * reference: 14496-3:2001(E)/4.6.18.3.5 and 14496-4:200X/FPDAM8/5.6.5.1.2.1.5 - */ - if (ampRes) { - do { - exp = *envQuant++; - scalei = MIN(expMax - exp, 31); - *envDequant++ = envDQTab[0] >> scalei; - } while (--nBands); - - return (6 + expMax); - } else { - expMax >>= 1; - do { - exp = *envQuant++; - scalei = MIN(expMax - (exp >> 1), 31); - *envDequant++ = envDQTab[exp & 0x01] >> scalei; - } while (--nBands); - - return (6 + expMax); - } - -} - -/************************************************************************************** - * Function: DequantizeNoise - * - * Description: dequantize noise scalefactors - * - * Inputs: number of scalefactors to process - * quantized noise scalefactors - * - * Outputs: dequantized noise scalefactors, format = Q(FBITS_OUT_DQ_NOISE) - * - * Return: none - * - * Notes: dequantized scalefactors have at least 2 GB - **************************************************************************************/ -static void DequantizeNoise(int nBands, signed char *noiseQuant, int *noiseDequant) -{ - int exp, scalei; - - if (nBands <= 0) - return; - - /* dequantize noise floor gains (4.6.18.3.5): - * noiseDequant = 2^(NOISE_FLOOR_OFFSET - noiseQuant) - * - * range of noiseQuant = [0, 30] (see 4.6.18.3.6), NOISE_FLOOR_OFFSET = 6 - * so range of noiseDequant = [2^-24, 2^6] - */ - do { - exp = *noiseQuant++; - scalei = NOISE_FLOOR_OFFSET - exp + FBITS_OUT_DQ_NOISE; /* 6 + 24 - exp, exp = [0,30] */ - - if (scalei < 0) - *noiseDequant++ = 0; - else if (scalei < 30) - *noiseDequant++ = 1 << scalei; - else - *noiseDequant++ = 0x3fffffff; /* leave 2 GB */ - - } while (--nBands); -} - -/************************************************************************************** - * Function: DecodeSBREnvelope - * - * Description: decode delta Huffman coded envelope scalefactors from bitstream - * - * Inputs: BitStreamInfo struct pointing to start of env data - * initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: dequantized env scalefactors for left channel (before decoupling) - * dequantized env scalefactors for right channel (if coupling off) - * or raw decoded env scalefactors for right channel (if coupling on) - * - * Return: none - **************************************************************************************/ -void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int huffIndexTime, huffIndexFreq, env, envStartBits, band, nBands, sf, lastEnv; - int freqRes, freqResPrev, dShift, i; - - if (psi->couplingFlag && ch) { - dShift = 1; - if (sbrGrid->ampResFrame) { - huffIndexTime = HuffTabSBR_tEnv30b; - huffIndexFreq = HuffTabSBR_fEnv30b; - envStartBits = 5; - } else { - huffIndexTime = HuffTabSBR_tEnv15b; - huffIndexFreq = HuffTabSBR_fEnv15b; - envStartBits = 6; - } - } else { - dShift = 0; - if (sbrGrid->ampResFrame) { - huffIndexTime = HuffTabSBR_tEnv30; - huffIndexFreq = HuffTabSBR_fEnv30; - envStartBits = 6; - } else { - huffIndexTime = HuffTabSBR_tEnv15; - huffIndexFreq = HuffTabSBR_fEnv15; - envStartBits = 7; - } - } - - /* range of envDataQuant[] = [0, 127] (see comments in DequantizeEnvelope() for reference) */ - for (env = 0; env < sbrGrid->numEnv; env++) { - nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow); - freqRes = (sbrGrid->freqRes[env]); - freqResPrev = (env == 0 ? sbrGrid->freqResPrev : sbrGrid->freqRes[env-1]); - lastEnv = (env == 0 ? sbrGrid->numEnvPrev-1 : env-1); - if (lastEnv < 0) - lastEnv = 0; /* first frame */ - - ASSERT(nBands <= MAX_QMF_BANDS); - - if (sbrChan->deltaFlagEnv[env] == 0) { - /* delta coding in freq */ - sf = GetBits(bsi, envStartBits) << dShift; - sbrChan->envDataQuant[env][0] = sf; - for (band = 1; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift; - sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[env][band-1]; - } - } else if (freqRes == freqResPrev) { - /* delta coding in time - same freq resolution for both frames */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[lastEnv][band]; - } - } else if (freqRes == 0 && freqResPrev == 1) { - /* delta coding in time - low freq resolution for new frame, high freq resolution for old frame */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf; - for (i = 0; i < sbrFreq->nHigh; i++) { - if (sbrFreq->freqHigh[i] == sbrFreq->freqLow[band]) { - sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i]; - break; - } - } - } - } else if (freqRes == 1 && freqResPrev == 0) { - /* delta coding in time - high freq resolution for new frame, low freq resolution for old frame */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf; - for (i = 0; i < sbrFreq->nLow; i++) { - if (sbrFreq->freqLow[i] <= sbrFreq->freqHigh[band] && sbrFreq->freqHigh[band] < sbrFreq->freqLow[i+1] ) { - sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i]; - break; - } - } - } - } - - /* skip coupling channel */ - if (ch != 1 || psi->couplingFlag != 1) - psi->envDataDequantScale[ch][env] = DequantizeEnvelope(nBands, sbrGrid->ampResFrame, sbrChan->envDataQuant[env], psi->envDataDequant[ch][env]); - } - sbrGrid->numEnvPrev = sbrGrid->numEnv; - sbrGrid->freqResPrev = sbrGrid->freqRes[sbrGrid->numEnv-1]; -} - -/************************************************************************************** - * Function: DecodeSBRNoise - * - * Description: decode delta Huffman coded noise scalefactors from bitstream - * - * Inputs: BitStreamInfo struct pointing to start of noise data - * initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: dequantized noise scalefactors for left channel (before decoupling) - * dequantized noise scalefactors for right channel (if coupling off) - * or raw decoded noise scalefactors for right channel (if coupling on) - * - * Return: none - **************************************************************************************/ -void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int huffIndexTime, huffIndexFreq, noiseFloor, band, dShift, sf, lastNoiseFloor; - - if (psi->couplingFlag && ch) { - dShift = 1; - huffIndexTime = HuffTabSBR_tNoise30b; - huffIndexFreq = HuffTabSBR_fNoise30b; - } else { - dShift = 0; - huffIndexTime = HuffTabSBR_tNoise30; - huffIndexFreq = HuffTabSBR_fNoise30; - } - - for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) { - lastNoiseFloor = (noiseFloor == 0 ? sbrGrid->numNoiseFloorsPrev-1 : noiseFloor-1); - if (lastNoiseFloor < 0) - lastNoiseFloor = 0; /* first frame */ - - ASSERT(sbrFreq->numNoiseFloorBands <= MAX_QMF_BANDS); - - if (sbrChan->deltaFlagNoise[noiseFloor] == 0) { - /* delta coding in freq */ - sbrChan->noiseDataQuant[noiseFloor][0] = GetBits(bsi, 5) << dShift; - for (band = 1; band < sbrFreq->numNoiseFloorBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift; - sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[noiseFloor][band-1]; - } - } else { - /* delta coding in time */ - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[lastNoiseFloor][band]; - } - } - - /* skip coupling channel */ - if (ch != 1 || psi->couplingFlag != 1) - DequantizeNoise(sbrFreq->numNoiseFloorBands, sbrChan->noiseDataQuant[noiseFloor], psi->noiseDataDequant[ch][noiseFloor]); - } - sbrGrid->numNoiseFloorsPrev = sbrGrid->numNoiseFloors; -} - -/* dqTabCouple[i] = 2 / (1 + 2^(12 - i)), format = Q30 */ -static const int dqTabCouple[25] PROGMEM = { - 0x0007ff80, 0x000ffe00, 0x001ff802, 0x003fe010, 0x007f8080, 0x00fe03f8, 0x01f81f82, 0x03e0f83e, - 0x07878788, 0x0e38e38e, 0x1999999a, 0x2aaaaaab, 0x40000000, 0x55555555, 0x66666666, 0x71c71c72, - 0x78787878, 0x7c1f07c2, 0x7e07e07e, 0x7f01fc08, 0x7f807f80, 0x7fc01ff0, 0x7fe007fe, 0x7ff00200, - 0x7ff80080, -}; - -/************************************************************************************** - * Function: UncoupleSBREnvelope - * - * Description: scale dequantized envelope scalefactors according to channel - * coupling rules - * - * Inputs: initialized PSInfoSBR struct including - * dequantized envelope data for left channel - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for right channel including - * quantized envelope scalefactors - * - * Outputs: dequantized envelope data for left channel (after decoupling) - * dequantized envelope data for right channel (after decoupling) - * - * Return: none - **************************************************************************************/ -void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR) -{ - int env, band, nBands, scalei, E_1; - - scalei = (sbrGrid->ampResFrame ? 0 : 1); - for (env = 0; env < sbrGrid->numEnv; env++) { - nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow); - psi->envDataDequantScale[1][env] = psi->envDataDequantScale[0][env]; /* same scalefactor for L and R */ - for (band = 0; band < nBands; band++) { - /* clip E_1 to [0, 24] (scalefactors approach 0 or 2) */ - E_1 = sbrChanR->envDataQuant[env][band] >> scalei; - if (E_1 < 0) E_1 = 0; - if (E_1 > 24) E_1 = 24; - - /* envDataDequant[0] has 1 GB, so << by 2 is okay */ - psi->envDataDequant[1][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[24 - E_1]) << 2; - psi->envDataDequant[0][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[E_1]) << 2; - } - } -} - -/************************************************************************************** - * Function: UncoupleSBRNoise - * - * Description: scale dequantized noise floor scalefactors according to channel - * coupling rules - * - * Inputs: initialized PSInfoSBR struct including - * dequantized noise data for left channel - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel including - * quantized noise scalefactors - * - * Outputs: dequantized noise data for left channel (after decoupling) - * dequantized noise data for right channel (after decoupling) - * - * Return: none - **************************************************************************************/ -void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR) -{ - int noiseFloor, band, Q_1; - - for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) { - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - /* Q_1 should be in range [0, 24] according to 4.6.18.3.6, but check to make sure */ - Q_1 = sbrChanR->noiseDataQuant[noiseFloor][band]; - if (Q_1 < 0) Q_1 = 0; - if (Q_1 > 24) Q_1 = 24; - - /* noiseDataDequant[0] has 1 GB, so << by 2 is okay */ - psi->noiseDataDequant[1][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[24 - Q_1]) << 2; - psi->noiseDataDequant[0][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[Q_1]) << 2; - } - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrimdct.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrimdct.c deleted file mode 100644 index 365ff02a..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrimdct.c +++ /dev/null @@ -1,447 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrimdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrimdct.c - inverse MDCT without clipping or interleaving, for input to SBR - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: DecWindowOverlapNoClip - * - * Description: apply synthesis window, do overlap-add without clipping, - * for winSequence LONG-LONG - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - if (winTypeCurr == winTypePrev) { - /* cut window loads in half since current and overlap sections use same symmetric window */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } else { - /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */ - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStart - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence LONG-START - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - in = *buf1--; - - *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */ - *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */ - } while (--i); - - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */ - w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */ - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */ - *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */ - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStop - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence LONG-STOP - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - /* Wn = 0 for n = (0, 1, ... 447) */ - /* Wn = 1 for n = (576, 577, ... 1023) */ - in = *buf0++; - f1 = in >> 1; /* scale since skipping multiply by Q31 */ - - in = *over0; - *out0++ = in; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (--i); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapShort - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence EIGHT-SHORT (does all 8 short blocks) - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* pcm[0-447] = 0 + overlap[0-447] */ - i = 448; - do { - f0 = *over0++; - f1 = *over0++; - *out0++ = f0; - *out0++ = f1; - i -= 2; - } while (i); - - /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */ - out1 = out0 + (128 - 1); - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - /* save over0/over1 for next short block, in the slots just vacated */ - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - - /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703] - * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831] - * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959] - */ - for (i = 0; i < 3; i++) { - out0 += 64; - out1 = out0 + 128 - 1; - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 - 128); /* from last short block */ - in += *(over0 + 0); /* from last full frame */ - *out0++ = in - f0; - - in = *(over1 - 128); /* from last short block */ - in += *(over1 + 0); /* from last full frame */ - *out1-- = in + f1; - - /* save over0/over1 for next short block, in the slots just vacated */ - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023] - * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127] - */ - out0 += 64; - over0 -= 832; /* points at overlap[64] */ - over1 = over0 + 128 - 1; /* points at overlap[191] */ - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 + 768); /* from last short block */ - in += *(over0 + 896); /* from last full frame */ - *out0++ = in - f0; - - in = *(over1 + 768); /* from last short block */ - *(over1 - 128) = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */ - *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */ - } while (over0 < over1); - - /* over0 now points at overlap[128] */ - - /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127] - * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127] - * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127] - * over[448-576] = Wc[128-255] * block7[128-255] - */ - for (i = 0; i < 3; i++) { - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - /* from last short block */ - *(over0 - 128) -= f0; - *(over1 - 128)+= f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* over[576-1024] = 0 */ - i = 448; - over0 += 64; - do { - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - i -= 4; - } while (i); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrmath.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrmath.c deleted file mode 100644 index 930889d8..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrmath.c +++ /dev/null @@ -1,195 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrmath.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrmath.c - fixed-point math functions for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define Q28_2 0x20000000 /* Q28: 2.0 */ -#define Q28_15 0x30000000 /* Q28: 1.5 */ - -#define NUM_ITER_IRN 5 - -/************************************************************************************** - * Function: InvRNormalized - * - * Description: use Newton's method to solve for x = 1/r - * - * Inputs: r = Q31, range = [0.5, 1) (normalize your inputs to this range) - * - * Outputs: none - * - * Return: x = Q29, range ~= [1.0, 2.0] - * - * Notes: guaranteed to converge and not overflow for any r in [0.5, 1) - * - * xn+1 = xn - f(xn)/f'(xn) - * f(x) = 1/r - x = 0 (find root) - * = 1/x - r - * f'(x) = -1/x^2 - * - * so xn+1 = xn - (1/xn - r) / (-1/xn^2) - * = xn * (2 - r*xn) - * - * NUM_ITER_IRN = 2, maxDiff = 6.2500e-02 (precision of about 4 bits) - * NUM_ITER_IRN = 3, maxDiff = 3.9063e-03 (precision of about 8 bits) - * NUM_ITER_IRN = 4, maxDiff = 1.5288e-05 (precision of about 16 bits) - * NUM_ITER_IRN = 5, maxDiff = 3.0034e-08 (precision of about 24 bits) - **************************************************************************************/ -int InvRNormalized(int r) -{ - int i, xn, t; - - /* r = [0.5, 1.0) - * 1/r = (1.0, 2.0] - * so use 1.5 as initial guess - */ - xn = Q28_15; - - /* xn = xn*(2.0 - r*xn) */ - for (i = NUM_ITER_IRN; i != 0; i--) { - t = MULSHIFT32(r, xn); /* Q31*Q29 = Q28 */ - t = Q28_2 - t; /* Q28 */ - xn = MULSHIFT32(xn, t) << 4; /* Q29*Q28 << 4 = Q29 */ - } - - return xn; -} - -#define NUM_TERMS_RPI 5 -#define LOG2_EXP_INV 0x58b90bfc /* 1/log2(e), Q31 */ - -/* invTab[x] = 1/(x+1), format = Q30 */ -static const int invTab[NUM_TERMS_RPI] PROGMEM = {0x40000000, 0x20000000, 0x15555555, 0x10000000, 0x0ccccccd}; - -/************************************************************************************** - * Function: RatioPowInv - * - * Description: use Taylor (MacLaurin) series expansion to calculate (a/b) ^ (1/c) - * - * Inputs: a = [1, 64], b = [1, 64], c = [1, 64], a >= b - * - * Outputs: none - * - * Return: y = Q24, range ~= [0.015625, 64] - **************************************************************************************/ -int RatioPowInv(int a, int b, int c) -{ - int lna, lnb, i, p, t, y; - - if (a < 1 || b < 1 || c < 1 || a > 64 || b > 64 || c > 64 || a < b) - return 0; - - lna = MULSHIFT32(log2Tab[a], LOG2_EXP_INV) << 1; /* ln(a), Q28 */ - lnb = MULSHIFT32(log2Tab[b], LOG2_EXP_INV) << 1; /* ln(b), Q28 */ - p = (lna - lnb) / c; /* Q28 */ - - /* sum in Q24 */ - y = (1 << 24); - t = p >> 4; /* t = p^1 * 1/1! (Q24)*/ - y += t; - - for (i = 2; i <= NUM_TERMS_RPI; i++) { - t = MULSHIFT32(invTab[i-1], t) << 2; - t = MULSHIFT32(p, t) << 4; /* t = p^i * 1/i! (Q24) */ - y += t; - } - - return y; -} - -/************************************************************************************** - * Function: SqrtFix - * - * Description: use binary search to calculate sqrt(q) - * - * Inputs: q = Q30 - * number of fraction bits in input - * - * Outputs: number of fraction bits in output - * - * Return: lo = Q(fBitsOut) - * - * Notes: absolute precision varies depending on fBitsIn - * normalizes input to range [0x200000000, 0x7fffffff] and takes - * floor(sqrt(input)), and sets fBitsOut appropriately - **************************************************************************************/ -int SqrtFix(int q, int fBitsIn, int *fBitsOut) -{ - int z, lo, hi, mid; - - if (q <= 0) { - *fBitsOut = fBitsIn; - return 0; - } - - /* force even fBitsIn */ - z = fBitsIn & 0x01; - q >>= z; - fBitsIn -= z; - - /* for max precision, normalize to [0x20000000, 0x7fffffff] */ - z = (CLZ(q) - 1); - z >>= 1; - q <<= (2*z); - - /* choose initial bounds */ - lo = 1; - if (q >= 0x10000000) - lo = 16384; /* (int)sqrt(0x10000000) */ - hi = 46340; /* (int)sqrt(0x7fffffff) */ - - /* do binary search with 32x32->32 multiply test */ - do { - mid = (lo + hi) >> 1; - if (mid*mid > q) - hi = mid - 1; - else - lo = mid + 1; - } while (hi >= lo); - lo--; - - *fBitsOut = ((fBitsIn + 2*z) >> 1); - return lo; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrqmf.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrqmf.c deleted file mode 100644 index 45fc8629..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrqmf.c +++ /dev/null @@ -1,527 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrqmf.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrqmf.c - analysis and synthesis QMF filters for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/* PreMultiply64() table - * format = Q30 - * reordered for sequential access - * - * for (i = 0; i < 64/4; i++) { - * angle = (i + 0.25) * M_PI / nmdct; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * - * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -static const int cos4sin4tab64[64] PROGMEM = { - 0x40c7d2bd, 0x00c90e90, 0x424ff28f, 0x3ff4e5e0, 0x43cdd89a, 0x03ecadcf, 0x454149fc, 0x3fc395f9, - 0x46aa0d6d, 0x070de172, 0x4807eb4b, 0x3f6af2e3, 0x495aada2, 0x0a2abb59, 0x4aa22036, 0x3eeb3347, - 0x4bde1089, 0x0d415013, 0x4d0e4de2, 0x3e44a5ef, 0x4e32a956, 0x104fb80e, 0x4f4af5d1, 0x3d77b192, - 0x50570819, 0x135410c3, 0x5156b6d9, 0x3c84d496, 0x5249daa2, 0x164c7ddd, 0x53304df6, 0x3b6ca4c4, - 0x5409ed4b, 0x19372a64, 0x54d69714, 0x3a2fcee8, 0x55962bc0, 0x1c1249d8, 0x56488dc5, 0x38cf1669, - 0x56eda1a0, 0x1edc1953, 0x57854ddd, 0x374b54ce, 0x580f7b19, 0x2192e09b, 0x588c1404, 0x35a5793c, - 0x58fb0568, 0x2434f332, 0x595c3e2a, 0x33de87de, 0x59afaf4c, 0x26c0b162, 0x59f54bee, 0x31f79948, - 0x5a2d0957, 0x29348937, 0x5a56deec, 0x2ff1d9c7, 0x5a72c63b, 0x2b8ef77d, 0x5a80baf6, 0x2dce88aa, -}; - -/* PostMultiply64() table - * format = Q30 - * reordered for sequential access - * - * for (i = 0; i <= (32/2); i++) { - * angle = i * M_PI / 64; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -static const int cos1sin1tab64[34] PROGMEM = { - 0x40000000, 0x00000000, 0x43103085, 0x0323ecbe, 0x45f704f7, 0x0645e9af, 0x48b2b335, 0x09640837, - 0x4b418bbe, 0x0c7c5c1e, 0x4da1fab5, 0x0f8cfcbe, 0x4fd288dc, 0x1294062f, 0x51d1dc80, 0x158f9a76, - 0x539eba45, 0x187de2a7, 0x553805f2, 0x1b5d100a, 0x569cc31b, 0x1e2b5d38, 0x57cc15bc, 0x20e70f32, - 0x58c542c5, 0x238e7673, 0x5987b08a, 0x261feffa, 0x5a12e720, 0x2899e64a, 0x5a6690ae, 0x2afad269, - 0x5a82799a, 0x2d413ccd, -}; - -/************************************************************************************** - * Function: PreMultiply64 - * - * Description: pre-twiddle stage of 64-point DCT-IV - * - * Inputs: buffer of 64 samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits - * gbOut = gbIn + 1 - * output is limited to sqrt(2)/2 plus GB in full GB - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PreMultiply64(int *zbuf1) -{ - int i, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - zbuf2 = zbuf1 + 64 - 1; - csptr = cos4sin4tab64; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = 64 >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0); - ai2 = *(zbuf1 + 1); - ai1 = *(zbuf2 + 0); - ar2 = *(zbuf2 - 1); - - /* gain 2 ints bit from MULSHIFT32 by Q30 - * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */ - *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */ - *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */ - } -} - -/************************************************************************************** - * Function: PostMultiply64 - * - * Description: post-twiddle stage of 64-point type-IV DCT - * - * Inputs: buffer of 64 samples - * number of output samples to calculate - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits - * gbOut = gbIn + 1 - * output is limited to sqrt(2)/2 plus GB in full GB - * nSampsOut is rounded up to next multiple of 4, since we calculate - * 4 samples per loop - **************************************************************************************/ -static void PostMultiply64(int *fft1, int nSampsOut) -{ - int i, ar1, ai1, ar2, ai2; - int t, cms2, cps2, sin2; - int *fft2; - const int *csptr; - - csptr = cos1sin1tab64; - fft2 = fft1 + 64 - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2 - */ - cps2 = *csptr++; - sin2 = *csptr++; - cms2 = cps2 - 2*sin2; - - for (i = (nSampsOut + 3) >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ar2 = *(fft2 - 1); - ai2 = *(fft2 + 0); - - /* gain 2 int bits (multiplying by Q30), max gain = sqrt(2) */ - t = MULSHIFT32(sin2, ar1 + ai1); - *fft2-- = t - MULSHIFT32(cps2, ai1); - *fft1++ = t + MULSHIFT32(cms2, ar1); - - cps2 = *csptr++; - sin2 = *csptr++; - - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - *fft2-- = t - MULSHIFT32(cps2, ai2); - cms2 = cps2 - 2*sin2; - *fft1++ = t + MULSHIFT32(cms2, ar2); - } -} - -/************************************************************************************** - * Function: QMFAnalysisConv - * - * Description: convolution kernel for analysis QMF - * - * Inputs: pointer to coefficient table, reordered for sequential access - * delay buffer of size 32*10 = 320 real-valued PCM samples - * index for delay ring buffer (range = [0, 9]) - * - * Outputs: 64 consecutive 32-bit samples - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrqmfak.s when building for ARM! - **************************************************************************************/ -#if (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) -#ifdef __cplusplus -extern "C" -#endif -void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf); -#else -void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf) -{ - int k, dOff; - int *cPtr0, *cPtr1; - U64 u64lo, u64hi; - - dOff = dIdx*32 + 31; - cPtr0 = cTab; - cPtr1 = cTab + 33*5 - 1; - - /* special first pass since we need to flip sign to create cTab[384], cTab[512] */ - u64lo.w64 = 0; - u64hi.w64 = 0; - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - - uBuf[0] = u64lo.r.hi32; - uBuf[32] = u64hi.r.hi32; - uBuf++; - dOff--; - - /* max gain for any sample in uBuf, after scaling by cTab, ~= 0.99 - * so we can just sum the uBuf values with no overflow problems - */ - for (k = 1; k <= 31; k++) { - u64lo.w64 = 0; - u64hi.w64 = 0; - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - - uBuf[0] = u64lo.r.hi32; - uBuf[32] = u64hi.r.hi32; - uBuf++; - dOff--; - } -} -#endif - -/************************************************************************************** - * Function: QMFAnalysis - * - * Description: 32-subband analysis QMF (4.6.18.4.1) - * - * Inputs: 32 consecutive samples of decoded 32-bit PCM, format = Q(fBitsIn) - * delay buffer of size 32*10 = 320 PCM samples - * number of fraction bits in input PCM - * index for delay ring buffer (range = [0, 9]) - * number of subbands to calculate (range = [0, 32]) - * - * Outputs: qmfaBands complex subband samples, format = Q(FBITS_OUT_QMFA) - * updated delay buffer - * updated delay index - * - * Return: guard bit mask - * - * Notes: output stored as RE{X0}, IM{X0}, RE{X1}, IM{X1}, ... RE{X31}, IM{X31} - * output stored in int buffer of size 64*2 = 128 - * (zero-filled from XBuf[2*qmfaBands] to XBuf[127]) - **************************************************************************************/ -int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands) -{ - int n, y, shift, gbMask; - int *delayPtr, *uBuf, *tBuf; - - /* use XBuf[128] as temp buffer for reordering */ - uBuf = XBuf; /* first 64 samples */ - tBuf = XBuf + 64; /* second 64 samples */ - - /* overwrite oldest PCM with new PCM - * delay[n] has 1 GB after shifting (either << or >>) - */ - delayPtr = delay + (*delayIdx * 32); - if (fBitsIn > FBITS_IN_QMFA) { - shift = MIN(fBitsIn - FBITS_IN_QMFA, 31); - for (n = 32; n != 0; n--) { - y = (*inbuf) >> shift; - inbuf++; - *delayPtr++ = y; - } - } else { - shift = MIN(FBITS_IN_QMFA - fBitsIn, 30); - for (n = 32; n != 0; n--) { - y = *inbuf++; - CLIP_2N_SHIFT30(y, shift); - *delayPtr++ = y; - } - } - - QMFAnalysisConv((int *)cTabA, delay, *delayIdx, uBuf); - - /* uBuf has at least 2 GB right now (1 from clipping to Q(FBITS_IN_QMFA), one from - * the scaling by cTab (MULSHIFT32(*delayPtr--, *cPtr++), with net gain of < 1.0) - * TODO - fuse with QMFAnalysisConv to avoid separate reordering - */ - tBuf[2*0 + 0] = uBuf[0]; - tBuf[2*0 + 1] = uBuf[1]; - for (n = 1; n < 31; n++) { - tBuf[2*n + 0] = -uBuf[64-n]; - tBuf[2*n + 1] = uBuf[n+1]; - } - tBuf[2*31 + 1] = uBuf[32]; - tBuf[2*31 + 0] = -uBuf[33]; - - /* fast in-place DCT-IV - only need 2*qmfaBands output samples */ - PreMultiply64(tBuf); /* 2 GB in, 3 GB out */ - FFT32C(tBuf); /* 3 GB in, 1 GB out */ - PostMultiply64(tBuf, qmfaBands*2); /* 1 GB in, 2 GB out */ - - /* TODO - roll into PostMultiply (if enough registers) */ - gbMask = 0; - for (n = 0; n < qmfaBands; n++) { - XBuf[2*n+0] = tBuf[ n + 0]; /* implicit scaling of 2 in our output Q format */ - gbMask |= FASTABS(XBuf[2*n+0]); - XBuf[2*n+1] = -tBuf[63 - n]; - gbMask |= FASTABS(XBuf[2*n+1]); - } - - /* fill top section with zeros for HF generation */ - for ( ; n < 64; n++) { - XBuf[2*n+0] = 0; - XBuf[2*n+1] = 0; - } - - *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1); - - /* minimum of 2 GB in output */ - return gbMask; -} - -/* lose FBITS_LOST_DCT4_64 in DCT4, gain 6 for implicit scaling by 1/64, lose 1 for cTab multiply (Q31) */ -#define FBITS_OUT_QMFS (FBITS_IN_QMFS - FBITS_LOST_DCT4_64 + 6 - 1) -#define RND_VAL (1 << (FBITS_OUT_QMFS-1)) - -/************************************************************************************** - * Function: QMFSynthesisConv - * - * Description: final convolution kernel for synthesis QMF - * - * Inputs: pointer to coefficient table, reordered for sequential access - * delay buffer of size 64*10 = 640 complex samples (1280 ints) - * index for delay ring buffer (range = [0, 9]) - * number of QMF subbands to process (range = [0, 64]) - * number of channels - * - * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrqmfsk.s when building for ARM! - **************************************************************************************/ -#if (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) -#ifdef __cplusplus -extern "C" -#endif -void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans); -#else -void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans) -{ - int k, dOff0, dOff1; - U64 sum64; - - dOff0 = (dIdx)*128; - dOff1 = dOff0 - 1; - if (dOff1 < 0) - dOff1 += 1280; - - /* scaling note: total gain of coefs (cPtr[0]-cPtr[9] for any k) is < 2.0, so 1 GB in delay values is adequate */ - for (k = 0; k <= 63; k++) { - sum64.w64 = 0; - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - - dOff0++; - dOff1--; - *outbuf = CLIPTOSHORT((sum64.r.hi32 + RND_VAL) >> FBITS_OUT_QMFS); - outbuf += nChans; - } -} -#endif - -/************************************************************************************** - * Function: QMFSynthesis - * - * Description: 64-subband synthesis QMF (4.6.18.4.2) - * - * Inputs: 64 consecutive complex subband QMF samples, format = Q(FBITS_IN_QMFS) - * delay buffer of size 64*10 = 640 complex samples (1280 ints) - * index for delay ring buffer (range = [0, 9]) - * number of QMF subbands to process (range = [0, 64]) - * number of channels - * - * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans - * updated delay buffer - * updated delay index - * - * Return: none - * - * Notes: assumes MIN_GBITS_IN_QMFS guard bits in input, either from - * QMFAnalysis (if upsampling only) or from MapHF (if SBR on) - **************************************************************************************/ -void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans) -{ - int n, a0, a1, b0, b1, dOff0, dOff1, dIdx; - int *tBufLo, *tBufHi; - - dIdx = *delayIdx; - tBufLo = delay + dIdx*128 + 0; - tBufHi = delay + dIdx*128 + 127; - - /* reorder inputs to DCT-IV, only use first qmfsBands (complex) samples - * TODO - fuse with PreMultiply64 to avoid separate reordering steps - */ - for (n = 0; n < qmfsBands >> 1; n++) { - a0 = *inbuf++; - b0 = *inbuf++; - a1 = *inbuf++; - b1 = *inbuf++; - *tBufLo++ = a0; - *tBufLo++ = a1; - *tBufHi-- = b0; - *tBufHi-- = b1; - } - if (qmfsBands & 0x01) { - a0 = *inbuf++; - b0 = *inbuf++; - *tBufLo++ = a0; - *tBufHi-- = b0; - *tBufLo++ = 0; - *tBufHi-- = 0; - n++; - } - for ( ; n < 32; n++) { - *tBufLo++ = 0; - *tBufHi-- = 0; - *tBufLo++ = 0; - *tBufHi-- = 0; - } - - tBufLo = delay + dIdx*128 + 0; - tBufHi = delay + dIdx*128 + 64; - - /* 2 GB in, 3 GB out */ - PreMultiply64(tBufLo); - PreMultiply64(tBufHi); - - /* 3 GB in, 1 GB out */ - FFT32C(tBufLo); - FFT32C(tBufHi); - - /* 1 GB in, 2 GB out */ - PostMultiply64(tBufLo, 64); - PostMultiply64(tBufHi, 64); - - /* could fuse with PostMultiply64 to avoid separate pass */ - dOff0 = dIdx*128; - dOff1 = dIdx*128 + 64; - for (n = 32; n != 0; n--) { - a0 = (*tBufLo++); - a1 = (*tBufLo++); - b0 = (*tBufHi++); - b1 = -(*tBufHi++); - - delay[dOff0++] = (b0 - a0); - delay[dOff0++] = (b1 - a1); - delay[dOff1++] = (b0 + a0); - delay[dOff1++] = (b1 + a1); - } - - QMFSynthesisConv((int *)cTabS, delay, dIdx, outbuf, nChans); - - *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrside.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrside.c deleted file mode 100644 index 6bb49f31..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrside.c +++ /dev/null @@ -1,575 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrside.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrside.c - functions for unpacking side info from SBR bitstream - **************************************************************************************/ - -#include "sbr.h" - -/************************************************************************************** - * Function: GetSampRateIdx - * - * Description: get index of given sample rate - * - * Inputs: sample rate (in Hz) - * - * Outputs: none - * - * Return: index of sample rate (table 1.15 in 14496-3:2001(E)) - * -1 if sample rate not found in table - **************************************************************************************/ -int GetSampRateIdx(int sampRate) -{ - int idx; - - for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) { - if (sampRate == sampRateTab[idx]) - return idx; - } - - return -1; -} - -/************************************************************************************** - * Function: UnpackSBRHeader - * - * Description: unpack SBR header (table 4.56) - * - * Inputs: BitStreamInfo struct pointing to start of SBR header - * - * Outputs: initialized SBRHeader struct for this SCE/CPE block - * - * Return: non-zero if frame reset is triggered, zero otherwise - **************************************************************************************/ -int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr) -{ - SBRHeader sbrHdrPrev; - - /* save previous values so we know whether to reset decoder */ - sbrHdrPrev.startFreq = sbrHdr->startFreq; - sbrHdrPrev.stopFreq = sbrHdr->stopFreq; - sbrHdrPrev.freqScale = sbrHdr->freqScale; - sbrHdrPrev.alterScale = sbrHdr->alterScale; - sbrHdrPrev.crossOverBand = sbrHdr->crossOverBand; - sbrHdrPrev.noiseBands = sbrHdr->noiseBands; - - sbrHdr->ampRes = GetBits(bsi, 1); - sbrHdr->startFreq = GetBits(bsi, 4); - sbrHdr->stopFreq = GetBits(bsi, 4); - sbrHdr->crossOverBand = GetBits(bsi, 3); - sbrHdr->resBitsHdr = GetBits(bsi, 2); - sbrHdr->hdrExtra1 = GetBits(bsi, 1); - sbrHdr->hdrExtra2 = GetBits(bsi, 1); - - if (sbrHdr->hdrExtra1) { - sbrHdr->freqScale = GetBits(bsi, 2); - sbrHdr->alterScale = GetBits(bsi, 1); - sbrHdr->noiseBands = GetBits(bsi, 2); - } else { - /* defaults */ - sbrHdr->freqScale = 2; - sbrHdr->alterScale = 1; - sbrHdr->noiseBands = 2; - } - - if (sbrHdr->hdrExtra2) { - sbrHdr->limiterBands = GetBits(bsi, 2); - sbrHdr->limiterGains = GetBits(bsi, 2); - sbrHdr->interpFreq = GetBits(bsi, 1); - sbrHdr->smoothMode = GetBits(bsi, 1); - } else { - /* defaults */ - sbrHdr->limiterBands = 2; - sbrHdr->limiterGains = 2; - sbrHdr->interpFreq = 1; - sbrHdr->smoothMode = 1; - } - sbrHdr->count++; - - /* if any of these have changed from previous frame, reset the SBR module */ - if (sbrHdr->startFreq != sbrHdrPrev.startFreq || sbrHdr->stopFreq != sbrHdrPrev.stopFreq || - sbrHdr->freqScale != sbrHdrPrev.freqScale || sbrHdr->alterScale != sbrHdrPrev.alterScale || - sbrHdr->crossOverBand != sbrHdrPrev.crossOverBand || sbrHdr->noiseBands != sbrHdrPrev.noiseBands - ) - return -1; - else - return 0; -} - -/* cLog2[i] = ceil(log2(i)) (disregard i == 0) */ -static const unsigned char cLog2[9] = {0, 0, 1, 2, 2, 3, 3, 3, 3}; - -/************************************************************************************** - * Function: UnpackSBRGrid - * - * Description: unpack SBR grid (table 4.62) - * - * Inputs: BitStreamInfo struct pointing to start of SBR grid - * initialized SBRHeader struct for this SCE/CPE block - * - * Outputs: initialized SBRGrid struct for this channel - * - * Return: none - **************************************************************************************/ -static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGrid) -{ - int numEnvRaw, env, rel, pBits, border, middleBorder=0; - unsigned char relBordLead[MAX_NUM_ENV], relBordTrail[MAX_NUM_ENV]; - unsigned char relBorder0[3], relBorder1[3], relBorder[3]; - unsigned char numRelBorder0, numRelBorder1, numRelBorder, numRelLead=0, numRelTrail; - unsigned char absBordLead=0, absBordTrail=0, absBorder; - - sbrGrid->ampResFrame = sbrHdr->ampRes; - sbrGrid->frameClass = GetBits(bsi, 2); - switch (sbrGrid->frameClass) { - - case SBR_GRID_FIXFIX: - numEnvRaw = GetBits(bsi, 2); - sbrGrid->numEnv = (1 << numEnvRaw); - if (sbrGrid->numEnv == 1) - sbrGrid->ampResFrame = 0; - - ASSERT(sbrGrid->numEnv == 1 || sbrGrid->numEnv == 2 || sbrGrid->numEnv == 4); - - sbrGrid->freqRes[0] = GetBits(bsi, 1); - for (env = 1; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = sbrGrid->freqRes[0]; - - absBordLead = 0; - absBordTrail = NUM_TIME_SLOTS; - numRelLead = sbrGrid->numEnv - 1; - numRelTrail = 0; - - /* numEnv = 1, 2, or 4 */ - if (sbrGrid->numEnv == 1) border = NUM_TIME_SLOTS / 1; - else if (sbrGrid->numEnv == 2) border = NUM_TIME_SLOTS / 2; - else border = NUM_TIME_SLOTS / 4; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = border; - - middleBorder = (sbrGrid->numEnv >> 1); - - break; - - case SBR_GRID_FIXVAR: - absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS; - numRelBorder = GetBits(bsi, 2); - sbrGrid->numEnv = numRelBorder + 1; - for (rel = 0; rel < numRelBorder; rel++) - relBorder[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[sbrGrid->numEnv + 1]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = sbrGrid->numEnv - 1; env >= 0; env--) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - absBordLead = 0; - absBordTrail = absBorder; - numRelLead = 0; - numRelTrail = numRelBorder; - - for (rel = 0; rel < numRelTrail; rel++) - relBordTrail[rel] = relBorder[rel]; - - if (sbrGrid->pointer > 1) middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer; - else middleBorder = sbrGrid->numEnv - 1; - - break; - - case SBR_GRID_VARFIX: - absBorder = GetBits(bsi, 2); - numRelBorder = GetBits(bsi, 2); - sbrGrid->numEnv = numRelBorder + 1; - for (rel = 0; rel < numRelBorder; rel++) - relBorder[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[sbrGrid->numEnv + 1]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = 0; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - absBordLead = absBorder; - absBordTrail = NUM_TIME_SLOTS; - numRelLead = numRelBorder; - numRelTrail = 0; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = relBorder[rel]; - - if (sbrGrid->pointer == 0) middleBorder = 1; - else if (sbrGrid->pointer == 1) middleBorder = sbrGrid->numEnv - 1; - else middleBorder = sbrGrid->pointer - 1; - - break; - - case SBR_GRID_VARVAR: - absBordLead = GetBits(bsi, 2); /* absBorder0 */ - absBordTrail = GetBits(bsi, 2) + NUM_TIME_SLOTS; /* absBorder1 */ - numRelBorder0 = GetBits(bsi, 2); - numRelBorder1 = GetBits(bsi, 2); - - sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1; - ASSERT(sbrGrid->numEnv <= 5); - - for (rel = 0; rel < numRelBorder0; rel++) - relBorder0[rel] = 2*GetBits(bsi, 2) + 2; - - for (rel = 0; rel < numRelBorder1; rel++) - relBorder1[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[numRelBorder0 + numRelBorder1 + 2]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = 0; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - numRelLead = numRelBorder0; - numRelTrail = numRelBorder1; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = relBorder0[rel]; - - for (rel = 0; rel < numRelTrail; rel++) - relBordTrail[rel] = relBorder1[rel]; - - if (sbrGrid->pointer > 1) middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer; - else middleBorder = sbrGrid->numEnv - 1; - - break; - } - - /* build time border vector */ - sbrGrid->envTimeBorder[0] = absBordLead * SAMPLES_PER_SLOT; - - rel = 0; - border = absBordLead; - for (env = 1; env <= numRelLead; env++) { - border += relBordLead[rel++]; - sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT; - } - - rel = 0; - border = absBordTrail; - for (env = sbrGrid->numEnv - 1; env > numRelLead; env--) { - border -= relBordTrail[rel++]; - sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT; - } - - sbrGrid->envTimeBorder[sbrGrid->numEnv] = absBordTrail * SAMPLES_PER_SLOT; - - if (sbrGrid->numEnv > 1) { - sbrGrid->numNoiseFloors = 2; - sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0]; - sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[middleBorder]; - sbrGrid->noiseTimeBorder[2] = sbrGrid->envTimeBorder[sbrGrid->numEnv]; - } else { - sbrGrid->numNoiseFloors = 1; - sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0]; - sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[1]; - } -} - -/************************************************************************************** - * Function: UnpackDeltaTimeFreq - * - * Description: unpack time/freq flags for delta coding of SBR envelopes (table 4.63) - * - * Inputs: BitStreamInfo struct pointing to start of dt/df flags - * number of envelopes - * number of noise floors - * - * Outputs: delta flags for envelope and noise floors - * - * Return: none - **************************************************************************************/ -static void UnpackDeltaTimeFreq(BitStreamInfo *bsi, int numEnv, unsigned char *deltaFlagEnv, - int numNoiseFloors, unsigned char *deltaFlagNoise) -{ - int env, noiseFloor; - - for (env = 0; env < numEnv; env++) - deltaFlagEnv[env] = GetBits(bsi, 1); - - for (noiseFloor = 0; noiseFloor < numNoiseFloors; noiseFloor++) - deltaFlagNoise[noiseFloor] = GetBits(bsi, 1); -} - -/************************************************************************************** - * Function: UnpackInverseFilterMode - * - * Description: unpack invf flags for chirp factor calculation (table 4.64) - * - * Inputs: BitStreamInfo struct pointing to start of invf flags - * number of noise floor bands - * - * Outputs: invf flags for noise floor bands - * - * Return: none - **************************************************************************************/ -static void UnpackInverseFilterMode(BitStreamInfo *bsi, int numNoiseFloorBands, unsigned char *mode) -{ - int n; - - for (n = 0; n < numNoiseFloorBands; n++) - mode[n] = GetBits(bsi, 2); -} - -/************************************************************************************** - * Function: UnpackSinusoids - * - * Description: unpack sinusoid (harmonic) flags for each SBR subband (table 4.67) - * - * Inputs: BitStreamInfo struct pointing to start of sinusoid flags - * number of high resolution SBR subbands (nHigh) - * - * Outputs: sinusoid flags for each SBR subband, zero-filled above nHigh - * - * Return: none - **************************************************************************************/ -static void UnpackSinusoids(BitStreamInfo *bsi, int nHigh, int addHarmonicFlag, unsigned char *addHarmonic) -{ - int n; - - n = 0; - if (addHarmonicFlag) { - for ( ; n < nHigh; n++) - addHarmonic[n] = GetBits(bsi, 1); - } - - /* zero out unused bands */ - for ( ; n < MAX_QMF_BANDS; n++) - addHarmonic[n] = 0; -} - -/************************************************************************************** - * Function: CopyCouplingGrid - * - * Description: copy grid parameters from left to right for channel coupling - * - * Inputs: initialized SBRGrid struct for left channel - * - * Outputs: initialized SBRGrid struct for right channel - * - * Return: none - **************************************************************************************/ -static void CopyCouplingGrid(SBRGrid *sbrGridLeft, SBRGrid *sbrGridRight) -{ - int env, noiseFloor; - - sbrGridRight->frameClass = sbrGridLeft->frameClass; - sbrGridRight->ampResFrame = sbrGridLeft->ampResFrame; - sbrGridRight->pointer = sbrGridLeft->pointer; - - sbrGridRight->numEnv = sbrGridLeft->numEnv; - for (env = 0; env < sbrGridLeft->numEnv; env++) { - sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; - sbrGridRight->freqRes[env] = sbrGridLeft->freqRes[env]; - } - sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; /* borders are [0, numEnv] inclusive */ - - sbrGridRight->numNoiseFloors = sbrGridLeft->numNoiseFloors; - for (noiseFloor = 0; noiseFloor <= sbrGridLeft->numNoiseFloors; noiseFloor++) - sbrGridRight->noiseTimeBorder[noiseFloor] = sbrGridLeft->noiseTimeBorder[noiseFloor]; - - /* numEnvPrev, numNoiseFloorsPrev, freqResPrev are updated in DecodeSBREnvelope() and DecodeSBRNoise() */ -} - -/************************************************************************************** - * Function: CopyCouplingInverseFilterMode - * - * Description: copy invf flags from left to right for channel coupling - * - * Inputs: invf flags for left channel - * number of noise floor bands - * - * Outputs: invf flags for right channel - * - * Return: none - **************************************************************************************/ -static void CopyCouplingInverseFilterMode(int numNoiseFloorBands, unsigned char *modeLeft, unsigned char *modeRight) -{ - int band; - - for (band = 0; band < numNoiseFloorBands; band++) - modeRight[band] = modeLeft[band]; -} - -/************************************************************************************** - * Function: UnpackSBRSingleChannel - * - * Description: unpack sideband info (grid, delta flags, invf flags, envelope and - * noise floor configuration, sinusoids) for a single channel - * - * Inputs: BitStreamInfo struct pointing to start of sideband info - * initialized PSInfoSBR struct (after parsing SBR header and building - * frequency tables) - * base output channel (range = [0, nChans-1]) - * - * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan) - * - * Return: none - **************************************************************************************/ -void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase) -{ - int bitsLeft; - SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]); - SBRGrid *sbrGridL = &(psi->sbrGrid[chBase+0]); - SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]); - SBRChan *sbrChanL = &(psi->sbrChan[chBase+0]); - - psi->dataExtra = GetBits(bsi, 1); - if (psi->dataExtra) - psi->resBitsData = GetBits(bsi, 4); - - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - - sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]); - - psi->extendedDataPresent = GetBits(bsi, 1); - if (psi->extendedDataPresent) { - psi->extendedDataSize = GetBits(bsi, 4); - if (psi->extendedDataSize == 15) - psi->extendedDataSize += GetBits(bsi, 8); - - bitsLeft = 8 * psi->extendedDataSize; - - /* get ID, unpack extension info, do whatever is necessary with it... */ - while (bitsLeft > 0) { - GetBits(bsi, 8); - bitsLeft -= 8; - } - } -} - -/************************************************************************************** - * Function: UnpackSBRChannelPair - * - * Description: unpack sideband info (grid, delta flags, invf flags, envelope and - * noise floor configuration, sinusoids) for a channel pair - * - * Inputs: BitStreamInfo struct pointing to start of sideband info - * initialized PSInfoSBR struct (after parsing SBR header and building - * frequency tables) - * base output channel (range = [0, nChans-1]) - * - * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan for both channels) - * - * Return: none - **************************************************************************************/ -void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase) -{ - int bitsLeft; - SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]); - SBRGrid *sbrGridL = &(psi->sbrGrid[chBase+0]), *sbrGridR = &(psi->sbrGrid[chBase+1]); - SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]); - SBRChan *sbrChanL = &(psi->sbrChan[chBase+0]), *sbrChanR = &(psi->sbrChan[chBase+1]); - - psi->dataExtra = GetBits(bsi, 1); - if (psi->dataExtra) { - psi->resBitsData = GetBits(bsi, 4); - psi->resBitsData = GetBits(bsi, 4); - } - - psi->couplingFlag = GetBits(bsi, 1); - if (psi->couplingFlag) { - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - CopyCouplingGrid(sbrGridL, sbrGridR); - - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise); - - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - CopyCouplingInverseFilterMode(sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1], sbrChanR->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - - /* pass RIGHT sbrChan struct */ - UncoupleSBREnvelope(psi, sbrGridL, sbrFreq, sbrChanR); - UncoupleSBRNoise(psi, sbrGridL, sbrFreq, sbrChanR); - - } else { - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - UnpackSBRGrid(bsi, sbrHdr, sbrGridR); - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanR->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - } - - sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]); - - sbrChanR->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanR->addHarmonicFlag[1], sbrChanR->addHarmonic[1]); - - psi->extendedDataPresent = GetBits(bsi, 1); - if (psi->extendedDataPresent) { - psi->extendedDataSize = GetBits(bsi, 4); - if (psi->extendedDataSize == 15) - psi->extendedDataSize += GetBits(bsi, 8); - - bitsLeft = 8 * psi->extendedDataSize; - - /* get ID, unpack extension info, do whatever is necessary with it... */ - while (bitsLeft > 0) { - GetBits(bsi, 8); - bitsLeft -= 8; - } - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrtabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrtabs.c deleted file mode 100644 index 01da8617..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/sbrtabs.c +++ /dev/null @@ -1,400 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrtabs.c - platform-independent tables for SBR (global, read-only) - **************************************************************************************/ - -#include "sbr.h" - -/* k0Tab[sampRateIdx][k] = k0 = startMin + offset(bs_start_freq) for given sample rate (4.6.18.3.2.1) - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16] = { - { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 96 kHz */ - { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 88 kHz */ - { 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 30 }, /* 64 kHz */ - { 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 27, 31 }, /* 48 kHz */ - { 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, 28, 32 }, /* 44 kHz */ - { 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 32 kHz */ - { 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 24 kHz */ - { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30 }, /* 22 kHz */ - { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, /* 16 kHz */ -}; - -/* k2Tab[sampRateIdx][k] = stopVector(bs_stop_freq) for given sample rate, bs_stop_freq = [0, 13] (4.6.18.3.2.1) - * generated with Matlab script calc_stopvec.m - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14] = { - { 13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64 }, /* 96 kHz */ - { 15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64 }, /* 88 kHz */ - { 20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64 }, /* 64 kHz */ - { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59, 64 }, /* 48 kHz */ - { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64 }, /* 44 kHz */ - { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 32 kHz */ - { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 24 kHz */ - { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64 }, /* 22 kHz */ - { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64 }, /* 16 kHz */ -}; - -/* NINT(2.048E6 / Fs) (figure 4.47) - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR] = { - 21, 23, 32, 43, 46, 64, 85, 93, 128 -}; - -const HuffInfo huffTabSBRInfo[10] PROGMEM = { - {19, { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 7, 4, 8, 72, 0}, 0}, - {20, { 0, 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, 4, 4, 3, 2, 5, 6, 13, 15, 46}, 121}, - {17, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 1, 25, 10, 0, 0, 0}, 242}, - {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 0, 1, 1, 2, 1, 29, 2, 0}, 291}, - {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 5, 1, 4, 2, 3, 34, 0}, 340}, - {20, { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 1, 2, 3, 4, 4, 7, 10, 16}, 403}, - {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 2, 0, 0, 0, 0, 0, 0}, 466}, - {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 6, 8, 0, 0, 0, 0, 0, 0}, 491}, - {14, { 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 51, 2, 0, 0, 0, 0, 0, 0}, 516}, - { 8, { 1, 1, 1, 0, 1, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 579}, -}; - -/* Huffman tables from appendix 4.A.6.1, includes offset of -LAV[i] for table i */ -const signed int /*short*/ huffTabSBR[604] PROGMEM = { - /* SBR table sbr_tenv15 [121] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, - -9, 8, -10, 9, -11, 10, -12, -13, 11, -14, 12, -15, -16, 13, -19, -18, - -17, 14, -24, -20, 16, -26, -21, 15, -23, -25, -22, -60, -59, -58, -57, -56, - -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, - -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, - /* SBR table sbr_fenv15 [121] (signed) */ - 0, -1, 1, -2, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7, - -9, 8, -10, 9, -11, 10, 11, -12, 12, -13, 13, 14, -14, -15, 15, 16, - 17, -16, -17, -18, -19, 18, 19, -20, -21, 20, 21, -24, -23, -22, -26, -28, - 22, 23, 25, -41, -25, 26, 27, -30, -27, 24, 28, 44, -51, -46, -44, -43, - -37, -33, -31, -29, 30, 37, 42, 47, 48, -60, -59, -58, -57, -56, -55, -54, - -53, -52, -50, -49, -48, -47, -45, -42, -40, -39, -38, -36, -35, -34, -32, 29, - 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 45, 46, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, - /* SBR table sbr_tenv15b [49] (signed) */ - 0, 1, -1, 2, -2, 3, -3, 4, -4, -5, 5, -6, 6, 7, -7, 8, - -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, - -8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, - /* SBR table sbr_fenv15b [49] (signed) */ - 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, -6, 6, -7, 7, 8, - -9, -8, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, - -10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, - /* SBR table sbr_tenv30 [63] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, -7, 6, -8, 7, - -9, -10, 8, 9, 10, -13, -11, -12, -14, 11, 12, -31, -30, -29, -28, -27, - -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_fenv30 [63] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, - 8, 9, -9, -10, 10, 11, -11, -12, 12, 13, -13, -15, 14, 15, -14, 18, - -18, -24, -19, 16, 17, -22, -21, -16, 20, 21, 22, 25, -23, -20, 24, -31, - -30, -29, -28, -27, -26, -25, -17, 19, 23, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_tenv30b [25] (signed) */ - 0, 1, -1, -2, 2, 3, -3, -4, 4, -5, -12, -11, -10, -9, -8, -7, - -6, 5, 6, 7, 8, 9, 10, 11, 12, - /* SBR table sbr_fenv30b [25] (signed) */ - 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, 6, -12, -11, -10, -9, - -8, -7, -6, 7, 8, 9, 10, 11, 12, - /* SBR table sbr_tnoise30 [63] (signed) */ - 0, 1, -1, -2, 2, -3, 3, -4, 4, -5, 5, 11, -31, -30, -29, -28, - -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, - -11, -10, -9, -8, -7, -6, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_tnoise30b [25] (signed) */ - 0, -1, 1, -2, 2, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, -}; - -/* log2Tab[x] = floor(log2(x)), format = Q28 */ -const int log2Tab[65] PROGMEM = { - 0x00000000, 0x00000000, 0x10000000, 0x195c01a3, 0x20000000, 0x25269e12, 0x295c01a3, 0x2ceaecfe, - 0x30000000, 0x32b80347, 0x35269e12, 0x3759d4f8, 0x395c01a3, 0x3b350047, 0x3ceaecfe, 0x3e829fb6, - 0x40000000, 0x41663f6f, 0x42b80347, 0x43f782d7, 0x45269e12, 0x4646eea2, 0x4759d4f8, 0x48608280, - 0x495c01a3, 0x4a4d3c25, 0x4b350047, 0x4c1404ea, 0x4ceaecfe, 0x4dba4a47, 0x4e829fb6, 0x4f446359, - 0x50000000, 0x50b5d69b, 0x51663f6f, 0x52118b11, 0x52b80347, 0x5359ebc5, 0x53f782d7, 0x549101ea, - 0x55269e12, 0x55b88873, 0x5646eea2, 0x56d1fafd, 0x5759d4f8, 0x57dea15a, 0x58608280, 0x58df988f, - 0x595c01a3, 0x59d5d9fd, 0x5a4d3c25, 0x5ac24113, 0x5b350047, 0x5ba58feb, 0x5c1404ea, 0x5c80730b, - 0x5ceaecfe, 0x5d53847a, 0x5dba4a47, 0x5e1f4e51, 0x5e829fb6, 0x5ee44cd5, 0x5f446359, 0x5fa2f045, - 0x60000000 -}; - -/* coefficient table 4.A.87, format = Q31 - * reordered as: - * cTab[0], cTab[64], cTab[128], cTab[192], cTab[256], - * cTab[2], cTab[66], cTab[130], cTab[194], cTab[258], - * ... - * cTab[64], cTab[128], cTab[192], cTab[256], cTab[320] - * - * NOTE: cTab[1, 2, ... , 318, 319] = cTab[639, 638, ... 322, 321] - * except cTab[384] = -cTab[256], cTab[512] = -cTab[128] - */ -const int cTabA[165] PROGMEM = { - 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, - 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, - 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, - 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, - 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, - 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, - 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, - 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, - 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, - 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, - 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, - 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, - 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, - 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, - 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, - 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, - 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, -}; - -/* coefficient table 4.A.87, format = Q31 - * reordered as cTab[0], cTab[64], cTab[128], ... cTab[576], cTab[1], cTab[65], cTab[129], ... cTab[639] - * keeping full table (not using symmetry) to allow sequential access in synth filter inner loop - * format = Q31 - */ -const int cTabS[640] PROGMEM = { - 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, 0xd1c58ace, 0x09015651, 0xfe4d1be3, 0x0055dba1, - 0xffede50e, 0x005b5371, 0x01d78bfc, 0x08d3e41b, 0x2faa221c, 0x6d41d963, 0xd3337b3d, 0x09299ead, 0xfe70b8d1, 0x0050b177, - 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, 0x6d32730f, 0xd49fd55f, 0x094d7ec2, 0xfe933dc0, 0x004b6c46, - 0xffefc9b9, 0x0065fde5, 0x02244a24, 0x086b1eeb, 0x328cc6f0, 0x6d18520e, 0xd60a46e5, 0x096d0e21, 0xfeb48d0d, 0x00465348, - 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0x6cf4073e, 0xd7722f04, 0x09881dc5, 0xfed4bec3, 0x004103f4, - 0xffeff6ca, 0x0070c8a5, 0x0274ba43, 0x07ee507c, 0x3572ec70, 0x6cc59bab, 0xd8d7f21f, 0x099ec3dc, 0xfef3f6ab, 0x003c1fa4, - 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, 0x6c8c4c7a, 0xda3b176a, 0x09b18a1d, 0xff120d70, 0x003745f9, - 0xffeedfa4, 0x007b3875, 0x02c89901, 0x075ca90c, 0x385a49c4, 0x6c492217, 0xdb9b5b12, 0x09c018ce, 0xff2ef725, 0x00329ab6, - 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0x6bfbdd98, 0xdcf898fb, 0x09caeb0f, 0xff4aabc8, 0x002d8e42, - 0xffed651d, 0x0085c217, 0x03201116, 0x06b559c3, 0x3b415115, 0x6ba4629f, 0xde529086, 0x09d1fa23, 0xff6542d1, 0x00293718, - 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, 0x6b42a864, 0xdfa93ab5, 0x09d5560b, 0xff7ee3f1, 0x0024dd50, - 0xffebe77b, 0x008f4bfc, 0x037ad438, 0x05f7fb90, 0x3e25b17e, 0x6ad73e8d, 0xe0fc421e, 0x09d52709, 0xff975c01, 0x002064f8, - 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0x6a619c5e, 0xe24b8f66, 0x09d19ca9, 0xffaea5d6, 0x001c3549, - 0xffea9192, 0x0098b855, 0x03d8afe6, 0x05237f9d, 0x41058bc6, 0x69e29784, 0xe396a45d, 0x09cab9f2, 0xffc4e365, 0x0018703f, - 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, 0x6959709d, 0xe4de0cb0, 0x09c0e59f, 0xffda17f2, 0x001471f8, - 0xffe940f4, 0x00a1039c, 0x043889c6, 0x0437fb0a, 0x43de620a, 0x68c7269b, 0xe620c476, 0x09b3d77f, 0xffee183b, 0x0010bc63, - 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0x682b39a4, 0xe75f8bb8, 0x09a3e163, 0x0000e790, 0x000d31b5, - 0xffe83a07, 0x00a8739d, 0x049aa82f, 0x03343533, 0x46aea856, 0x6785c24d, 0xe89971b7, 0x099140a7, 0x00131c75, 0x0009aa3f, - 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, 0x66d76725, 0xe9cea84a, 0x097c1ee8, 0x0023b989, 0x0006b1cf, - 0xffe7746e, 0x00af374c, 0x04fe20be, 0x02186a91, 0x4973fef1, 0x661fd6b8, 0xeafee7f1, 0x0963ed46, 0x0033b927, 0x00039609, - 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0x655f63f2, 0xec2a3f5f, 0x0949eaac, 0x00426f36, 0x00007134, - 0xffe6afee, 0x00b3d15c, 0x05626209, 0x00e42fa2, 0x4c2ca3df, 0x64964063, 0xed50a31d, 0x092d7970, 0x00504f41, 0xfffdfa25, - 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, 0x63c45243, 0xee71b2fe, 0x090ec1fc, 0x005d36df, 0xfffb42b0, - 0xffe681c6, 0x00b74c37, 0x05c76fed, 0xff96db90, 0x4ed62be3, 0x62ea6474, 0xef8d4d7b, 0x08edfeaa, 0x006928a0, 0xfff91fca, - 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0x6207f220, 0xf0a3959f, 0x08cb4e23, 0x007400b8, 0xfff681d6, - 0xffe66fac, 0x00b8fe0d, 0x062bf5ec, 0xfe310657, 0x516eefb9, 0x611d58a3, 0xf1b461ab, 0x08a75da4, 0x007e0393, 0xfff48700, - 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, 0x602b0c7f, 0xf2bf6ea4, 0x0880ffdd, 0x00872c63, 0xfff294c3, - 0xffe6fed4, 0x00b85f70, 0x068f8b44, 0xfcb1d740, 0x53f495aa, 0x5f30ff5f, 0xf3c4e887, 0x08594887, 0x008f87aa, 0xfff0e7ef, - 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0x5e2f6367, 0xf4c473c6, 0x08303897, 0x0096dcc2, 0xffef2395, - 0xffe80414, 0x00b58c8c, 0x06f1825d, 0xfb19b7bd, 0x56654bdd, 0x5d26be9b, 0xf5be0fa9, 0x08061671, 0x009da526, 0xffedc418, - 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, 0x5c16d0ae, 0xf6b1f3c3, 0x07da2b7f, 0x00a3508f, 0xffec8409, - 0xffe954d0, 0x00b06b68, 0x075112a2, 0xf96916f5, 0x58befacd, 0x5b001db8, 0xf79fa13a, 0x07ad8c26, 0x00a85e94, 0xffeb3849, - 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0x59e2f69e, 0xf887507c, 0x077fedb3, 0x00acbd2f, 0xffea353a, - 0xffeb3849, 0x00a85e94, 0x07ad8c26, 0xf79fa13a, 0x5b001db8, 0x58befacd, 0xf96916f5, 0x075112a2, 0x00b06b68, 0xffe954d0, - 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, 0x579505f5, 0xfa44a069, 0x0721bf22, 0x00b36acd, 0xffe85b4b, - 0xffedc418, 0x009da526, 0x08061671, 0xf5be0fa9, 0x5d26be9b, 0x56654bdd, 0xfb19b7bd, 0x06f1825d, 0x00b58c8c, 0xffe80414, - 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0x552f8ff7, 0xfbe8f5bd, 0x06c0f0c0, 0x00b73ab0, 0xffe75361, - 0xfff0e7ef, 0x008f87aa, 0x08594887, 0xf3c4e887, 0x5f30ff5f, 0x53f495aa, 0xfcb1d740, 0x068f8b44, 0x00b85f70, 0xffe6fed4, - 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, 0x52b449de, 0xfd7475d8, 0x065dd56a, 0x00b8c6b0, 0xffe69423, - 0xfff48700, 0x007e0393, 0x08a75da4, 0xf1b461ab, 0x611d58a3, 0x516eefb9, 0xfe310657, 0x062bf5ec, 0x00b8fe0d, 0xffe66fac, - 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0x5024d70e, 0xfee723c6, 0x05f9c051, 0x00b8394b, 0xffe66dd0, - 0xfff91fca, 0x006928a0, 0x08edfeaa, 0xef8d4d7b, 0x62ea6474, 0x4ed62be3, 0xff96db90, 0x05c76fed, 0x00b74c37, 0xffe681c6, - 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, 0x4d83976c, 0x0040c496, 0x05950122, 0x00b5c867, 0xffe65416, - 0xfffdfa25, 0x00504f41, 0x092d7970, 0xed50a31d, 0x64964063, 0x4c2ca3df, 0x00e42fa2, 0x05626209, 0x00b3d15c, 0xffe6afee, - 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x4ad237a2, 0x01816e06, 0x05303f87, 0x00b1978d, 0xffe6d466, - 0x00039609, 0x0033b927, 0x0963ed46, 0xeafee7f1, 0x661fd6b8, 0x4973fef1, 0x02186a91, 0x04fe20be, 0x00af374c, 0xffe7746e, - 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, 0x4812f848, 0x02a99097, 0x04cc2fcf, 0x00abe79e, 0xffe79e16, - 0x0009aa3f, 0x00131c75, 0x099140a7, 0xe89971b7, 0x6785c24d, 0x46aea856, 0x03343533, 0x049aa82f, 0x00a8739d, 0xffe83a07, - 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x4547daea, 0x03b8f8dc, 0x04694101, 0x00a520bb, 0xffe88ba8, - 0x0010bc63, 0xffee183b, 0x09b3d77f, 0xe620c476, 0x68c7269b, 0x43de620a, 0x0437fb0a, 0x043889c6, 0x00a1039c, 0xffe940f4, - 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, 0x4272a385, 0x04b0adcb, 0x04083fec, 0x009d10bf, 0xffe9ca76, - 0x0018703f, 0xffc4e365, 0x09cab9f2, 0xe396a45d, 0x69e29784, 0x41058bc6, 0x05237f9d, 0x03d8afe6, 0x0098b855, 0xffea9192, - 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x3f962fb8, 0x0590a67d, 0x03a966bb, 0x009424c6, 0xffeb50b2, - 0x002064f8, 0xff975c01, 0x09d52709, 0xe0fc421e, 0x6ad73e8d, 0x3e25b17e, 0x05f7fb90, 0x037ad438, 0x008f4bfc, 0xffebe77b, - 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, 0x3cb41219, 0x06593912, 0x034d01f0, 0x008a7dd7, 0xffecc31b, - 0x00293718, 0xff6542d1, 0x09d1fa23, 0xde529086, 0x6ba4629f, 0x3b415115, 0x06b559c3, 0x03201116, 0x0085c217, 0xffed651d, - 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x39ce0477, 0x070bbf58, 0x02f3e48d, 0x00807994, 0xffee1650, - 0x00329ab6, 0xff2ef725, 0x09c018ce, 0xdb9b5b12, 0x6c492217, 0x385a49c4, 0x075ca90c, 0x02c89901, 0x007b3875, 0xffeedfa4, - 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, 0x36e69691, 0x07a8127d, 0x029e35b4, 0x0075fded, 0xffef7b8b, - 0x003c1fa4, 0xfef3f6ab, 0x099ec3dc, 0xd8d7f21f, 0x6cc59bab, 0x3572ec70, 0x07ee507c, 0x0274ba43, 0x0070c8a5, 0xffeff6ca, - 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x33ff670e, 0x082f552e, 0x024bf7a1, 0x006b47fa, 0xfff0065d, - 0x00465348, 0xfeb48d0d, 0x096d0e21, 0xd60a46e5, 0x6d18520e, 0x328cc6f0, 0x086b1eeb, 0x02244a24, 0x0065fde5, 0xffefc9b9, - 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, 0x311af3a4, 0x08a24899, 0x01fd3ba0, 0x006090c4, 0xffed978a, - 0x0050b177, 0xfe70b8d1, 0x09299ead, 0xd3337b3d, 0x6d41d963, 0x2faa221c, 0x08d3e41b, 0x01d78bfc, 0x005b5371, 0xffede50f, -}; - -/* noise table 4.A.88, format = Q31 */ -const int noiseTab[512*2] PROGMEM = { - 0x8010fd38, 0xb3dc7948, 0x7c4e2301, 0xa9904192, 0x121622a7, 0x86489625, 0xc3d53d25, 0xd0343fa9, - 0x674d6f70, 0x25f4e9fd, 0xce1a8c8b, 0x72a726c5, 0xfea6efc6, 0xaa4adb1a, 0x8b2dd628, 0xf14029e4, - 0x46321c1a, 0x604889a0, 0x33363b63, 0x815ed069, 0x802b4315, 0x8f2bf7f3, 0x85b86073, 0x745cfb46, - 0xc57886b3, 0xb76731f0, 0xa2a66772, 0x828ca631, 0x60cc145e, 0x1ad1010f, 0x090c83d4, 0x9bd7ba87, - 0x5f5aeea2, 0x8b4dbd99, 0x848e7b1e, 0x86bb9fa2, 0x26f18ae5, 0xc0b81194, 0x553407bf, 0x52c17953, - 0x755f468d, 0x166b04f8, 0xa5687981, 0x4343248b, 0xa6558d5e, 0xc5f6fab7, 0x80a4fb8c, 0x8cb53cb7, - 0x7da68a54, 0x9cd8df8a, 0xba05376c, 0xfcb58ee2, 0xfdd657a4, 0x005e35ca, 0x91c75c55, 0x367651e6, - 0x816abf85, 0x8f831c4f, 0x423f9c9c, 0x55aa919e, 0x80779834, 0xb59f4244, 0x800a095c, 0x7de9e0cc, - 0x46bda5cb, 0x4c184464, 0x2c438f71, 0x797216b5, 0x5035cee6, 0xa0c3a26e, 0x9d3f95fa, 0xd4a100c0, - 0x8ac30dac, 0x04b87397, 0x9e5ac516, 0x8b0b442e, 0x66210ad6, 0x88ba7598, 0x45b9bd33, 0xf0be5087, - 0x9261b85e, 0x364f6a31, 0x891c4b50, 0x23ad08ce, 0xf10366a6, 0x80414276, 0x1b562e06, 0x8be21591, - 0x9e798195, 0x7fb4045c, 0x7d9506cf, 0x854e691f, 0x9207f092, 0x7a94c9d5, 0x88911536, 0x3f45cc61, - 0x27059279, 0xa5b57109, 0x6d2bb67b, 0x3bdc5379, 0x74e662d8, 0x80348f8c, 0xf875e638, 0x5a8caea1, - 0x2459ae75, 0x2c54b939, 0x79ee3203, 0xb9bc8683, 0x9b6f630c, 0x9f45b351, 0x8563b2b9, 0xe5dbba41, - 0x697c7d0d, 0x7bb7c90e, 0xac900866, 0x8e6b5177, 0x8822dd37, 0x7fd5a91e, 0x7506da05, 0x82302aca, - 0xa5e4be04, 0x4b4288eb, 0x00b8bc9f, 0x4f1033e4, 0x7200d612, 0x43900c8c, 0xa815b900, 0x676ed1d4, - 0x5c5f23b2, 0xa758ee11, 0xaf73abfa, 0x11714ec0, 0x265239e0, 0xc50de679, 0x8a84e341, 0xa1438354, - 0x7f1a341f, 0x343ec96b, 0x696e71b0, 0xa13bde39, 0x81e75094, 0x80091111, 0x853a73bf, 0x80f9c1ee, - 0xe4980086, 0x886a8e28, 0xa7e89426, 0xdd93edd7, 0x7592100d, 0x0bfa8123, 0x850a26d4, 0x2e34f395, - 0x421b6c00, 0xa4a462e4, 0x4e3f5090, 0x3c189f4c, 0x3c971a56, 0xdd0376d2, 0x747a5367, 0x7bcbc9d7, - 0x3966be6a, 0x7efda616, 0x55445e15, 0x7ba2ab3f, 0x5fe684f2, 0x8cf42af9, 0x808c61c3, 0x4390c27b, - 0x7cac62ff, 0xea6cab22, 0x5d0902ad, 0xc27b7208, 0x7a27389d, 0x5820a357, 0xa29bbe59, 0x9df0f1fd, - 0x92bd67e5, 0x7195b587, 0x97cac65b, 0x8339807e, 0x8f72d832, 0x5fad8685, 0xa462d9d3, 0x81d46214, - 0x6ae93e1d, 0x6b23a5b9, 0xc2732874, 0x81795268, 0x7c568cb6, 0x668513ea, 0x428d024e, 0x66b78b3a, - 0xfee9ef03, 0x9ddcbb82, 0xa605f07e, 0x46dc55e0, 0x85415054, 0xc89ec271, 0x7c42edfb, 0x0befe59b, - 0x89b8f607, 0x6d732a1a, 0xa7081ebd, 0x7e403258, 0x21feeb7b, 0x5dd7a1e7, 0x23e3a31a, 0x129bc896, - 0xa11a6b54, 0x7f1e031c, 0xfdc1a4d1, 0x96402e53, 0xb9700f1a, 0x8168ecd6, 0x7d63d3cc, 0x87a70d65, - 0x81075a7a, 0x55c8caa7, 0xa95d00b5, 0x102b1652, 0x0bb30215, 0xe5b63237, 0xa446ca44, 0x82d4c333, - 0x67b2e094, 0x44c3d661, 0x33fd6036, 0xde1ea2a1, 0xa95e8e47, 0x78f66eb9, 0x6f2aef1e, 0xe8887247, - 0x80a3b70e, 0xfca0d9d3, 0x6bf0fd20, 0x0d5226de, 0xf4341c87, 0x5902df05, 0x7ff1a38d, 0xf02e5a5b, - 0x99f129af, 0x8ac63d01, 0x7b53f599, 0x7bb32532, 0x99ac59b0, 0x5255a80f, 0xf1320a41, 0x2497aa5c, - 0xcce60bd8, 0x787c634b, 0x7ed58c5b, 0x8a28eb3a, 0x24a5e647, 0x8b79a2c1, 0x955f5ce5, 0xa9d12bc4, - 0x7a1e20c6, 0x3eeda7ac, 0xf7be823a, 0x042924ce, 0x808b3f03, 0x364248da, 0xac2895e5, 0x69a8b5fa, - 0x97fe8b63, 0xbdeac9aa, 0x8073e0ad, 0x6c25dba7, 0x005e51d2, 0x52e74389, 0x59d3988c, 0xe5d1f39c, - 0x7b57dc91, 0x341adbe7, 0xa7d42b8d, 0x74e9f335, 0xd35bf7d8, 0x5b7c0a4b, 0x75bc0874, 0x552129bf, - 0x8144b70d, 0x6de93bbb, 0x5825f14b, 0x473ec5ca, 0x80a8f37c, 0xe6552d69, 0x7898360b, 0x806379b0, - 0xa9b59339, 0x3f6bf60c, 0xc367d731, 0x920ade99, 0x125592f7, 0x877e5ed1, 0xda895d95, 0x075f2ece, - 0x380e5f5e, 0x9b006b62, 0xd17a6dd2, 0x530a0e13, 0xf4cc9a14, 0x7d0a0ed4, 0x847c6e3f, 0xbaee4975, - 0x47131163, 0x64fb2cac, 0x5e2100a6, 0x7b756a42, 0xd87609f4, 0x98bfe48c, 0x0493745e, 0x836c5784, - 0x7e5ccb40, 0x3df6b476, 0x97700d28, 0x8bbd93fd, 0x56de9cdb, 0x680b4e65, 0xebc3d90e, 0x6d286793, - 0x6753712e, 0xe05c98a7, 0x3d2b6b85, 0xc4b18ddb, 0x7b59b869, 0x31435688, 0x811888e9, 0xe011ee7a, - 0x6a5844f9, 0x86ae35ea, 0xb4cbc10b, 0x01a6f5d6, 0x7a49ed64, 0x927caa49, 0x847ddaed, 0xae0d9bb6, - 0x836bdb04, 0x0fd810a6, 0x74fe126b, 0x4a346b5f, 0x80184d36, 0x5afd153c, 0x90cc8102, 0xe606d0e6, - 0xde69aa58, 0xa89f1222, 0xe06df715, 0x8fd16144, 0x0317c3e8, 0x22ce92fc, 0x690c3eca, 0x93166f02, - 0x71573414, 0x8d43cffb, 0xe8bd0bb6, 0xde86770f, 0x0bf99a41, 0x4633a661, 0xba064108, 0x7adafae3, - 0x2f6cde5d, 0xb350a52c, 0xa5ebfb0b, 0x74c57b46, 0xd3b603b5, 0x80b70892, 0xa7f7fa53, 0xd94b566c, - 0xdda3fd86, 0x6a635793, 0x3ed005ca, 0xc5f087d8, 0x31e3a746, 0x7a4278f9, 0x82def1f9, 0x06caa2b2, - 0xe9d2c349, 0x8940e7f7, 0x7feef8dd, 0x4a9b01f0, 0xacde69f8, 0x57ddc280, 0xf09e4ba4, 0xb6d9f729, - 0xb48c18f2, 0xd3654aa9, 0xca7a03c8, 0x14d57545, 0x7fda87a5, 0x0e411366, 0xb77d0df0, 0x8c2aa467, - 0x787f2590, 0x2d292db1, 0x9f12682c, 0x44ac364d, 0x1a4b31a6, 0x871f7ded, 0x7ff99167, 0x6630a1d5, - 0x25385eb9, 0x2d4dd549, 0xaf8a7004, 0x319ebe0f, 0x379ab730, 0x81dc56a4, 0x822d8523, 0x1ae8554c, - 0x18fa0786, 0x875f7de4, 0x85ca350f, 0x7de818dc, 0x7786a38f, 0xa5456355, 0x92e60f88, 0xf5526122, - 0x916039bc, 0xc561e2de, 0x31c42042, 0x7c82e290, 0x75d158b2, 0xb015bda1, 0x7220c750, 0x46565441, - 0xd0da1fdd, 0x7b777481, 0x782e73c6, 0x8cd72b7b, 0x7f1006aa, 0xfb30e51e, 0x87994818, 0x34e7c7db, - 0x7faae06b, 0xea74fbc0, 0xd20c7af4, 0xc44f396b, 0x06b4234e, 0xdf2e2a93, 0x2efb07c8, 0xce861911, - 0x7550ea05, 0xd8d90bbb, 0x58522eec, 0x746b3520, 0xce844ce9, 0x7f5cacc3, 0xda8f17e0, 0x2fedf9cb, - 0xb2f77ec4, 0x6f13f4c0, 0x834de085, 0x7b7ace4b, 0x713b16ac, 0x499c5ab0, 0x06a7961d, 0x1b39a48a, - 0xbb853e6e, 0x7c781cc1, 0xc0baebf5, 0x7dace394, 0x815ceebc, 0xcc7b27d4, 0x8274b181, 0xa2be40a2, - 0xdd01d5dc, 0x7fefeb14, 0x0813ec78, 0xba3077cc, 0xe5cf1e1c, 0xedcfacae, 0x54c43a9b, 0x5cd62a42, - 0x93806b55, 0x03095c5b, 0x8e076ae3, 0x71bfcd2a, 0x7ac1989b, 0x623bc71a, 0x5e15d4d2, 0xfb341dd1, - 0xd75dfbca, 0xd0da32be, 0xd4569063, 0x337869da, 0x3d30606a, 0xcd89cca2, 0x7dd2ae36, 0x028c03cd, - 0xd85e052c, 0xe8dc9ec5, 0x7ffd9241, 0xde5bf4c6, 0x88c4b235, 0x8228be2e, 0x7fe6ec64, 0x996abe6a, - 0xdeb0666d, 0x9eb86611, 0xd249b922, 0x18b3e26b, 0x80211168, 0x5f8bb99c, 0x6ecb0dd2, 0x4728ff8d, - 0x2ac325b8, 0x6e5169d2, 0x7ebbd68d, 0x05e41d17, 0xaaa19f28, 0x8ab238a6, 0x51f105be, 0x140809cc, - 0x7f7345d9, 0x3aae5a9d, 0xaecec6e4, 0x1afb3473, 0xf6229ed1, 0x8d55f467, 0x7e32003a, 0x70f30c14, - 0x6686f33f, 0xd0d45ed8, 0x644fab57, 0x3a3fbbd3, 0x0b255fc4, 0x679a1701, 0x90e17b6e, 0x325d537b, - 0xcd7b9b87, 0xaa7be2a2, 0x7d47c966, 0xa33dbce5, 0x8659c3bb, 0x72a41367, 0x15c446e0, 0x45fe8b0a, - 0x9d8ddf26, 0x84d47643, 0x7fabe0da, 0x36a70122, 0x7a28ebfe, 0x7c29b8b8, 0x7f760406, 0xbabe4672, - 0x23ea216e, 0x92bcc50a, 0x6d20dba2, 0xad5a7c7e, 0xbf3897f5, 0xabb793e1, 0x8391fc7e, 0xe270291c, - 0x7a248d58, 0x80f8fd15, 0x83ef19f3, 0x5e6ece7d, 0x278430c1, 0x35239f4d, 0xe09c073b, 0x50e78cb5, - 0xd4b811bd, 0xce834ee0, 0xf88aaa34, 0xf71da5a9, 0xe2b0a1d5, 0x7c3aef31, 0xe84eabca, 0x3ce25964, - 0xf29336d3, 0x8fa78b2c, 0xa3fc3415, 0x63e1313d, 0x7fbc74e0, 0x7340bc93, 0x49ae583b, 0x8b79de4b, - 0x25011ce9, 0x7b462279, 0x36007db0, 0x3da1599c, 0x77780772, 0xc845c9bb, 0x83ba68be, 0x6ee507d1, - 0x2f0159b8, 0x5392c4ed, 0x98336ff6, 0x0b3c7f11, 0xde697aac, 0x893fc8d0, 0x6b83f8f3, 0x47799a0d, - 0x801d9dfc, 0x8516a83e, 0x5f8d22ec, 0x0f8ba384, 0xa049dc4b, 0xdd920b05, 0x7a99bc9f, 0x9ad19344, - 0x7a345dba, 0xf501a13f, 0x3e58bf19, 0x7fffaf9a, 0x3b4e1511, 0x0e08b991, 0x9e157620, 0x7230a326, - 0x4977f9ff, 0x2d2bbae1, 0x607aa7fc, 0x7bc85d5f, 0xb441bbbe, 0x8d8fa5f2, 0x601cce26, 0xda1884f2, - 0x81c82d64, 0x200b709c, 0xcbd36abe, 0x8cbdddd3, 0x55ab61d3, 0x7e3ee993, 0x833f18aa, 0xffc1aaea, - 0x7362e16a, 0x7fb85db2, 0x904ee04c, 0x7f04dca6, 0x8ad7a046, 0xebe7d8f7, 0xfbc4c687, 0xd0609458, - 0x093ed977, 0x8e546085, 0x7f5b8236, 0x7c47e118, 0xa01f2641, 0x7ffb3e48, 0x05de7cda, 0x7fc281b9, - 0x8e0278fc, 0xd74e6d07, 0x94c24450, 0x7cf9e641, 0x2ad27871, 0x919fa815, 0x805fd205, 0x7758397f, - 0xe2c7e02c, 0x1828e194, 0x5613d6fe, 0xfb55359f, 0xf9699516, 0x8978ee26, 0x7feebad9, 0x77d71d82, - 0x55b28b60, 0x7e997600, 0x80821a6b, 0xc6d78af1, 0x691822ab, 0x7f6982a0, 0x7ef56f99, 0x5c307f40, - 0xac6f8b76, 0x42cc8ba4, 0x782c61d9, 0xa0224dd0, 0x7bd234d1, 0x74576e3b, 0xe38cfe9a, 0x491e66ef, - 0xc78291c5, 0x895bb87f, 0x924f7889, 0x71b89394, 0x757b779d, 0xc4a9c604, 0x5cdf7829, 0x8020e9df, - 0x805e8245, 0x4a82c398, 0x6360bd62, 0x78bb60fc, 0x09e0d014, 0x4b0ea180, 0xb841978b, 0x69a0e864, - 0x7df35977, 0x3284b0dd, 0x3cdc2efd, 0x57d31f5e, 0x541069cc, 0x1776e92e, 0x04309ea3, 0xa015eb2d, - 0xce7bfabc, 0x41b638f8, 0x8365932e, 0x846ab44c, 0xbbcc80cb, 0x8afa6cac, 0x7fc422ea, 0x4e403fc0, - 0xbfac9aee, 0x8e4c6709, 0x028e01fb, 0x6d160a9b, 0x7fe93004, 0x790f9cdc, 0x6a1f37a0, 0xf7e7ef30, - 0xb4ea0f04, 0x7bf4c8e6, 0xe981701f, 0xc258a9d3, 0x6acbbfba, 0xef5479c7, 0x079c8bd8, 0x1a410f56, - 0x6853b799, 0x86cd4f01, 0xc66e23b6, 0x34585565, 0x8d1fe00d, 0x7fcdba1a, 0x32c9717b, 0xa02f9f48, - 0xf64940db, 0x5ed7d8f1, 0x61b823b2, 0x356f8918, 0xa0a7151e, 0x793fc969, 0x530beaeb, 0x34e93270, - 0x4fc4ddb5, 0x88d58b6c, 0x36094774, 0xf620ac80, 0x03763a72, 0xf910c9a6, 0x6666fb2d, 0x752c8be8, - 0x9a6dfdd8, 0xd1a7117d, 0x51c1b1d4, 0x0a67773d, 0x43b32a79, 0x4cdcd085, 0x5f067d30, 0x05bfe92a, - 0x7ed7d203, 0xe71a3c85, 0x99127ce2, 0x8eb3cac4, 0xad4bbcea, 0x5c6a0fd0, 0x0eec04af, 0x94e95cd4, - 0x8654f921, 0x83eabb5d, 0xb058d7ca, 0x69f12d3c, 0x03d881b2, 0x80558ef7, 0x82938cb3, 0x2ec0e1d6, - 0x80044422, 0xd1e47051, 0x720fc6ff, 0x82b20316, 0x0d527b02, 0x63049a15, 0x7ad5b9ad, 0xd2a4641d, - 0x41144f86, 0x7b04917a, 0x15c4a2c0, 0x9da07916, 0x211df54a, 0x7fdd09af, 0xfe924f3f, 0x7e132cfe, - 0x9a1d18d6, 0x7c56508b, 0x80f0f0af, 0x8095ced6, 0x8037d0d7, 0x026719d1, 0xa55fec43, 0x2b1c7cb7, - 0xa5cd5ac1, 0x77639fad, 0x7fcd8b62, 0x81a18c27, 0xaee4912e, 0xeae9eebe, 0xeb3081de, 0x8532aada, - 0xc822362e, 0x86a649a9, 0x8031a71d, 0x7b319dc6, 0xea8022e6, 0x814bc5a9, 0x8f62f7a1, 0xa430ea17, - 0x388deafb, 0x883b5185, 0x776fe13c, 0x801c683f, 0x87c11b98, 0xb7cbc644, 0x8e9ad3e8, 0x3cf5a10c, - 0x7ff6a634, 0x949ef096, 0x9f84aa7c, 0x010af13f, 0x782d1de8, 0xf18e492a, 0x6cf63b01, 0x4301cd81, - 0x32d15c9e, 0x68ad8cef, 0xd09bd2d6, 0x908c5c15, 0xd1e36260, 0x2c5bfdd0, 0x88765a99, 0x93deba1e, - 0xac6ae342, 0xe865b84c, 0x0f4f2847, 0x7fdf0499, 0x78b1c9b3, 0x6a73261e, 0x601a96f6, 0xd2847933, - 0x489aa888, 0xe12e8093, 0x3bfa5a5f, 0xd96ba5f7, 0x7c8f4c8d, 0x80940c6f, 0xcef9dd1a, 0x7e1a055f, - 0x3483558b, 0x02b59cc4, 0x0c56333e, 0x05a5b813, 0x92d66287, 0x7516b679, 0x71bfe03f, 0x8056bf68, - 0xc24d0724, 0x8416bcf3, 0x234afbdb, 0x4b0d6f9c, 0xaba97333, 0x4b4f42b6, 0x7e8343ab, 0x7ffe2603, - 0xe590f73c, 0x45e10c76, 0xb07a6a78, 0xb35609d3, 0x1a027dfd, 0x90cb6e20, 0x82d3fe38, 0x7b409257, - 0x0e395afa, 0x1b802093, 0xcb0c6c59, 0x241e17e7, 0x1ee3ea0a, 0x41a82302, 0xab04350a, 0xf570beb7, - 0xbb444b9b, 0x83021459, 0x838d65dc, 0x1c439c84, 0x6fdcc454, 0xef9ef325, 0x18626c1c, 0x020d251f, - 0xc4aae786, 0x8614cb48, 0xf6f53ca6, 0x8710dbab, 0x89abec0d, 0xf29d41c1, 0x94b50336, 0xfdd49178, - 0x604658d1, 0x800e85be, 0xca1bb079, 0x7fa48eeb, 0xa3b7fafe, 0xd330436b, 0x64eb604c, 0x43a658ae, - 0x7caa1337, 0xddd445e6, 0x7efbf955, 0xb706ec71, 0x624a6b53, 0x9e0e231f, 0x97097248, 0xa1e1a17a, - 0x68dd2e44, 0x7f9d2e14, 0xddcc7074, 0x58324197, 0xc88fc426, 0x6d3640ae, 0x7ef83600, 0x759a0270, - 0x98b6d854, 0xd63c9b84, 0x372474a2, 0xe3f18cfd, 0x56ab0bdb, 0x85c9be7e, 0x47dfcfeb, 0xa5830d41, - 0x0ddd6283, 0xf4f480ad, 0x74c60e38, 0xab8943c3, 0xc1508fe7, 0x480cdc39, 0x8e097362, 0xa44793be, - 0x538b7e18, 0x545f5b41, 0x56529175, 0x9771a97e, 0xc2da7421, 0xea8265f2, 0x805d1163, 0x883c5d28, - 0x8ba94c48, 0x4f676e65, 0xf78735b3, 0xe1853671, 0x7f454f53, 0x18147f85, 0x7d09e15d, 0xdb4f3494, - 0x795c8973, 0x83310632, 0x85d8061c, 0x9a1a0ebf, 0xc125583c, 0x2a1b1a95, 0x7fd9103f, 0x71e98c72, - 0x40932ed7, 0x91ed227a, 0x3c5e560e, 0xe816dee9, 0xb0891b80, 0x600038ba, 0xc7d9a80d, 0x7fff5e09, - 0x7e3f4351, 0xbb6b4424, 0xb14448d4, 0x8d6bb7e1, 0xfb153626, 0xa68ad537, 0xd9782006, 0xf62f6991, - 0x359ba8c1, 0x02ccff0b, 0x91bf2256, 0x7ea71c4d, 0x560ce5df, 0xeeba289b, 0xa574c4e7, 0x9e04f6ee, - 0x7860a5ec, 0x0b8db4a2, 0x968ba3d7, 0x0b6c77df, 0xd6f3157d, 0x402eff1a, 0x49b820b3, 0x8152aebb, - 0xd180b0b6, 0x098604d4, 0x7ff92224, 0xede9c996, 0x89c58061, 0x829624c4, 0xc6e71ea7, 0xba94d915, - 0x389c3cf6, 0x5b4c5a06, 0x04b335e6, 0x516a8aab, 0x42c8d7d9, 0x92b12af6, 0x86c8549f, 0xfda98acf, - 0x819673b6, 0x69545dac, 0x6feaa230, 0x726e6d3f, 0x886ebdfe, 0x34f5730a, 0x7af63ba2, 0x77307bbf, - 0x7cd80630, 0x6e45efe0, 0x7f8ad7eb, 0x59d7df99, 0x86c70946, 0xda233629, 0x753f6cbf, 0x825eeb40, -}; diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/statname.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/statname.h deleted file mode 100644 index a27f04d5..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/statname.h +++ /dev/null @@ -1,115 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: statname.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * statname.h - name mangling macros for static linking - **************************************************************************************/ - -#ifndef _STATNAME_H -#define _STATNAME_H - -/* define STAT_PREFIX to a unique name for static linking - * all the C functions and global variables will be mangled by the preprocessor - * e.g. void DCT4(...) becomes void raac_DCT4(...) - */ -#define STAT_PREFIX raac - -#define STATCC1(x,y,z) STATCC2(x,y,z) -#define STATCC2(x,y,z) x##y##z - -#ifdef STAT_PREFIX -#define STATNAME(func) STATCC1(STAT_PREFIX, _, func) -#else -#define STATNAME(func) func -#endif - -/* these symbols are common to all implementations */ -#define AllocateBuffers STATNAME(AllocateBuffers) -#define FreeBuffers STATNAME(FreeBuffers) -#define ClearBuffer STATNAME(ClearBuffer) - -#define SetRawBlockParams STATNAME(SetRawBlockParams) -#define PrepareRawBlock STATNAME(PrepareRawBlock) -#define FlushCodec STATNAME(FlushCodec) - -#define UnpackADTSHeader STATNAME(UnpackADTSHeader) -#define GetADTSChannelMapping STATNAME(GetADTSChannelMapping) -#define UnpackADIFHeader STATNAME(UnpackADIFHeader) -#define DecodeNextElement STATNAME(DecodeNextElement) -#define DecodeNoiselessData STATNAME(DecodeNoiselessData) -#define Dequantize STATNAME(Dequantize) -#define StereoProcess STATNAME(StereoProcess) -#define DeinterleaveShortBlocks STATNAME(DeinterleaveShortBlocks) -#define PNS STATNAME(PNS) -#define TNSFilter STATNAME(TNSFilter) -#define IMDCT STATNAME(IMDCT) - -#define InitSBR STATNAME(InitSBR) -#define DecodeSBRBitstream STATNAME(DecodeSBRBitstream) -#define DecodeSBRData STATNAME(DecodeSBRData) -#define FreeSBR STATNAME(FreeSBR) -#define FlushCodecSBR STATNAME(FlushCodecSBR) - -/* global ROM tables */ -#define sampRateTab STATNAME(sampRateTab) -#define predSFBMax STATNAME(predSFBMax) -#define channelMapTab STATNAME(channelMapTab) -#define elementNumChans STATNAME(elementNumChans) -#define sfBandTotalShort STATNAME(sfBandTotalShort) -#define sfBandTotalLong STATNAME(sfBandTotalLong) -#define sfBandTabShortOffset STATNAME(sfBandTabShortOffset) -#define sfBandTabShort STATNAME(sfBandTabShort) -#define sfBandTabLongOffset STATNAME(sfBandTabLongOffset) -#define sfBandTabLong STATNAME(sfBandTabLong) -#define tnsMaxBandsShortOffset STATNAME(tnsMaxBandsShortOffset) -#define tnsMaxBandsShort STATNAME(tnsMaxBandsShort) -#define tnsMaxOrderShort STATNAME(tnsMaxOrderShort) -#define tnsMaxBandsLongOffset STATNAME(tnsMaxBandsLongOffset) -#define tnsMaxBandsLong STATNAME(tnsMaxBandsLong) -#define tnsMaxOrderLong STATNAME(tnsMaxOrderLong) - -/* in your implementation's top-level include file (e.g. real\coder.h) you should - * add new #define sym STATNAME(sym) lines for all the - * additional global functions or variables which your - * implementation uses - */ - -#endif /* _STATNAME_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/stproc.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/stproc.c deleted file mode 100644 index 93854e45..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/stproc.c +++ /dev/null @@ -1,246 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: stproc.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * stproc.c - mid-side and intensity stereo processing - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/* pow14[0][i] = -pow(2, i/4.0) - * pow14[1][i] = +pow(2, i/4.0) - * - * i = [0,1,2,3] - * format = Q30 - */ - - -/************************************************************************************** - * Function: StereoProcessGroup - * - * Description: apply mid-side and intensity stereo to group of transform coefficients - * - * Inputs: dequantized transform coefficients for both channels - * pointer to appropriate scalefactor band table - * mid-side mask enabled flag - * buffer with mid-side mask (one bit for each scalefactor band) - * bit offset into mid-side mask buffer - * max coded scalefactor band - * buffer of codebook indices for right channel - * buffer of scalefactors for right channel, range = [0, 256] - * - * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF) - * updated minimum guard bit count for both channels - * - * Return: none - * - * Notes: assume no guard bits in input - * gains 0 int bits - **************************************************************************************/ -static void StereoProcessGroup(int *coefL, int *coefR, const /*short*/ int *sfbTab, - int msMaskPres, unsigned char *msMaskPtr, int msMaskOffset, int maxSFB, - unsigned char *cbRight, short *sfRight, int *gbCurrent) -{ -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" -static const int pow14[2][4] PROGMEM = { - { 0xc0000000, 0xb3e407d7, 0xa57d8666, 0x945d819b }, - { 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 } -}; -#pragma GCC diagnostic pop - - int sfb, width, cbIdx, sf, cl, cr, scalef, scalei; - int gbMaskL, gbMaskR; - unsigned char msMask; - - msMask = (*msMaskPtr++) >> msMaskOffset; - gbMaskL = 0; - gbMaskR = 0; - - for (sfb = 0; sfb < maxSFB; sfb++) { - width = sfbTab[sfb+1] - sfbTab[sfb]; /* assume >= 0 (see sfBandTabLong/sfBandTabShort) */ - cbIdx = cbRight[sfb]; - - if (cbIdx == 14 || cbIdx == 15) { - /* intensity stereo */ - if (msMaskPres == 1 && (msMask & 0x01)) - cbIdx ^= 0x01; /* invert_intensity(): 14 becomes 15, or 15 becomes 14 */ - sf = -sfRight[sfb]; /* negative since we use identity 0.5^(x) = 2^(-x) (see spec) */ - cbIdx &= 0x01; /* choose - or + scale factor */ - scalef = pow14[cbIdx][sf & 0x03]; - scalei = (sf >> 2) + 2; /* +2 to compensate for scalef = Q30 */ - - if (scalei > 0) { - if (scalei > 30) - scalei = 30; - do { - cr = MULSHIFT32(*coefL++, scalef); - CLIP_2N(cr, 31-scalei); - cr <<= scalei; - gbMaskR |= FASTABS(cr); - *coefR++ = cr; - } while (--width); - } else { - scalei = -scalei; - if (scalei > 31) - scalei = 31; - do { - cr = MULSHIFT32(*coefL++, scalef) >> scalei; - gbMaskR |= FASTABS(cr); - *coefR++ = cr; - } while (--width); - } - } else if ( cbIdx != 13 && ((msMaskPres == 1 && (msMask & 0x01)) || msMaskPres == 2) ) { - /* mid-side stereo (assumes no GB in inputs) */ - do { - cl = *coefL; - cr = *coefR; - - if ( (FASTABS(cl) | FASTABS(cr)) >> 30 ) { - /* avoid overflow (rare) */ - cl >>= 1; - sf = cl + (cr >> 1); CLIP_2N(sf, 30); sf <<= 1; - cl = cl - (cr >> 1); CLIP_2N(cl, 30); cl <<= 1; - } else { - /* usual case */ - sf = cl + cr; - cl -= cr; - } - - *coefL++ = sf; - gbMaskL |= FASTABS(sf); - *coefR++ = cl; - gbMaskR |= FASTABS(cl); - } while (--width); - - } else { - /* nothing to do */ - coefL += width; - coefR += width; - } - - /* get next mask bit (should be branchless on ARM) */ - msMask >>= 1; - if (++msMaskOffset == 8) { - msMask = *msMaskPtr++; - msMaskOffset = 0; - } - } - - cl = CLZ(gbMaskL) - 1; - if (gbCurrent[0] > cl) - gbCurrent[0] = cl; - - cr = CLZ(gbMaskR) - 1; - if (gbCurrent[1] > cr) - gbCurrent[1] = cr; - - return; -} - -/************************************************************************************** - * Function: StereoProcess - * - * Description: apply mid-side and intensity stereo, if enabled - * - * Inputs: valid AACDecInfo struct (including dequantized transform coefficients) - * - * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF) - * updated minimum guard bit count for both channels - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int StereoProcess(AACDecInfo *aacDecInfo) -{ - PSInfoBase *psi; - ICSInfo *icsInfo; - int gp, win, nSamps, msMaskOffset; - int *coefL, *coefR; - unsigned char *msMaskPtr; - const /*short*/ int *sfbTab; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* mid-side and intensity stereo require common_window == 1 (see MPEG4 spec, Correction 2, 2004) */ - if (psi->commonWin != 1 || aacDecInfo->currBlockID != AAC_ID_CPE) - return 0; - - /* nothing to do */ - if (!psi->msMaskPresent && !psi->intensityUsed[1]) - return 0; - - icsInfo = &(psi->icsInfo[0]); - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coefL = psi->coef[0]; - coefR = psi->coef[1]; - - /* do fused mid-side/intensity processing for each block (one long or eight short) */ - msMaskOffset = 0; - msMaskPtr = psi->msMaskBits; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - StereoProcessGroup(coefL, coefR, sfbTab, psi->msMaskPresent, - msMaskPtr, msMaskOffset, icsInfo->maxSFB, psi->sfbCodeBook[1] + gp*icsInfo->maxSFB, - psi->scaleFactors[1] + gp*icsInfo->maxSFB, psi->gbCurrent); - coefL += nSamps; - coefR += nSamps; - } - /* we use one bit per sfb, so there are maxSFB bits for each window group */ - msMaskPtr += (msMaskOffset + icsInfo->maxSFB) >> 3; - msMaskOffset = (msMaskOffset + icsInfo->maxSFB) & 0x07; - } - - ASSERT(coefL == psi->coef[0] + 1024); - ASSERT(coefR == psi->coef[1] + 1024); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/tns.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/tns.c deleted file mode 100644 index 87726067..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/tns.c +++ /dev/null @@ -1,300 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: tns.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * tns.c - apply TNS to spectrum - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define FBITS_LPC_COEFS 20 - -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" - -/* inverse quantization tables for TNS filter coefficients, format = Q31 - * see bottom of file for table generation - * negative (vs. spec) since we use MADD for filter kernel - */ -static const int invQuant3[16] PROGMEM = { - 0x00000000, 0xc8767f65, 0x9becf22c, 0x83358feb, 0x83358feb, 0x9becf22c, 0xc8767f65, 0x00000000, - 0x2bc750e9, 0x5246dd49, 0x6ed9eba1, 0x7e0e2e32, 0x7e0e2e32, 0x6ed9eba1, 0x5246dd49, 0x2bc750e9, -}; - -static const int invQuant4[16] PROGMEM = { - 0x00000000, 0xe5632654, 0xcbf00dbe, 0xb4c373ee, 0xa0e0a15f, 0x9126145f, 0x8643c7b3, 0x80b381ac, - 0x7f7437ad, 0x7b1d1a49, 0x7294b5f2, 0x66256db2, 0x563ba8aa, 0x4362210e, 0x2e3d2abb, 0x17851aad, -}; - -#pragma GCC diagnostic pop - -/************************************************************************************** - * Function: DecodeLPCCoefs - * - * Description: decode LPC coefficients for TNS - * - * Inputs: order of TNS filter - * resolution of coefficients (3 or 4 bits) - * coefficients unpacked from bitstream - * scratch buffer (b) of size >= order - * - * Outputs: LPC coefficients in Q(FBITS_LPC_COEFS), in 'a' - * - * Return: none - * - * Notes: assumes no guard bits in input transform coefficients - * a[i] = Q(FBITS_LPC_COEFS), don't store a0 = 1.0 - * (so a[0] = first delay tap, etc.) - * max abs(a[i]) < log2(order), so for max order = 20 a[i] < 4.4 - * (up to 3 bits of gain) so a[i] has at least 31 - FBITS_LPC_COEFS - 3 - * guard bits - * to ensure no intermediate overflow in all-pole filter, set - * FBITS_LPC_COEFS such that number of guard bits >= log2(max order) - **************************************************************************************/ -static void DecodeLPCCoefs(int order, int res, signed char *filtCoef, int *a, int *b) -{ - int i, m, t; - const int *invQuantTab; - - if (res == 3) invQuantTab = invQuant3; - else if (res == 4) invQuantTab = invQuant4; - else return; - - for (m = 0; m < order; m++) { - t = invQuantTab[filtCoef[m] & 0x0f]; /* t = Q31 */ - for (i = 0; i < m; i++) - b[i] = a[i] - (MULSHIFT32(t, a[m-i-1]) << 1); - for (i = 0; i < m; i++) - a[i] = b[i]; - a[m] = t >> (31 - FBITS_LPC_COEFS); - } -} - -/************************************************************************************** - * Function: FilterRegion - * - * Description: apply LPC filter to one region of coefficients - * - * Inputs: number of transform coefficients in this region - * direction flag (forward = 1, backward = -1) - * order of filter - * 'size' transform coefficients - * 'order' LPC coefficients in Q(FBITS_LPC_COEFS) - * scratch buffer for history (must be >= order samples long) - * - * Outputs: filtered transform coefficients - * - * Return: guard bit mask (OR of abs value of all filtered transform coefs) - * - * Notes: assumes no guard bits in input transform coefficients - * gains 0 int bits - * history buffer does not need to be preserved between regions - **************************************************************************************/ -static int FilterRegion(int size, int dir, int order, int *audioCoef, int *a, int *hist) -{ - int i, j, y, hi32, inc, gbMask; - U64 sum64; - - /* init history to 0 every time */ - for (i = 0; i < order; i++) - hist[i] = 0; - - sum64.w64 = 0; /* avoid warning */ - gbMask = 0; - inc = (dir ? -1 : 1); - do { - /* sum64 = a0*y[n] = 1.0*y[n] */ - y = *audioCoef; - sum64.r.hi32 = y >> (32 - FBITS_LPC_COEFS); - sum64.r.lo32 = y << FBITS_LPC_COEFS; - - /* sum64 += (a1*y[n-1] + a2*y[n-2] + ... + a[order-1]*y[n-(order-1)]) */ - for (j = order - 1; j > 0; j--) { - sum64.w64 = MADD64(sum64.w64, hist[j], a[j]); - hist[j] = hist[j-1]; - } - sum64.w64 = MADD64(sum64.w64, hist[0], a[0]); - y = (sum64.r.hi32 << (32 - FBITS_LPC_COEFS)) | (sum64.r.lo32 >> FBITS_LPC_COEFS); - - /* clip output (rare) */ - hi32 = sum64.r.hi32; - if ((hi32 >> 31) != (hi32 >> (FBITS_LPC_COEFS-1))) - y = (hi32 >> 31) ^ 0x7fffffff; - - hist[0] = y; - *audioCoef = y; - audioCoef += inc; - gbMask |= FASTABS(y); - } while (--size); - - return gbMask; -} - -/************************************************************************************** - * Function: TNSFilter - * - * Description: apply temporal noise shaping, if enabled - * - * Inputs: valid AACDecInfo struct - * index of current channel - * - * Outputs: updated transform coefficients - * updated minimum guard bit count for this channel - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int TNSFilter(AACDecInfo *aacDecInfo, int ch) -{ - int win, winLen, nWindows, nSFB, filt, bottom, top, order, maxOrder, dir; - int start, end, size, tnsMaxBand, numFilt, gbMask; - int *audioCoef; - unsigned char *filtLength, *filtOrder, *filtRes, *filtDir; - signed char *filtCoef; - const unsigned /*char*/ int *tnsMaxBandTab; - const /*short*/ int *sfbTab; - ICSInfo *icsInfo; - TNSInfo *ti; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - ti = &psi->tnsInfo[ch]; - - if (!ti->tnsDataPresent) - return 0; - - if (icsInfo->winSequence == 2) { - nWindows = NWINDOWS_SHORT; - winLen = NSAMPS_SHORT; - nSFB = sfBandTotalShort[psi->sampRateIdx]; - maxOrder = tnsMaxOrderShort[aacDecInfo->profile]; - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - tnsMaxBandTab = tnsMaxBandsShort + tnsMaxBandsShortOffset[aacDecInfo->profile]; - tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx]; - } else { - nWindows = NWINDOWS_LONG; - winLen = NSAMPS_LONG; - nSFB = sfBandTotalLong[psi->sampRateIdx]; - maxOrder = tnsMaxOrderLong[aacDecInfo->profile]; - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - tnsMaxBandTab = tnsMaxBandsLong + tnsMaxBandsLongOffset[aacDecInfo->profile]; - tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx]; - } - - if (tnsMaxBand > icsInfo->maxSFB) - tnsMaxBand = icsInfo->maxSFB; - - filtRes = ti->coefRes; - filtLength = ti->length; - filtOrder = ti->order; - filtDir = ti->dir; - filtCoef = ti->coef; - - gbMask = 0; - audioCoef = psi->coef[ch]; - for (win = 0; win < nWindows; win++) { - bottom = nSFB; - numFilt = ti->numFilt[win]; - for (filt = 0; filt < numFilt; filt++) { - top = bottom; - bottom = top - *filtLength++; - bottom = MAX(bottom, 0); - order = *filtOrder++; - order = MIN(order, maxOrder); - - if (order) { - start = sfbTab[MIN(bottom, tnsMaxBand)]; - end = sfbTab[MIN(top, tnsMaxBand)]; - size = end - start; - if (size > 0) { - dir = *filtDir++; - if (dir) - start = end - 1; - - DecodeLPCCoefs(order, filtRes[win], filtCoef, psi->tnsLPCBuf, psi->tnsWorkBuf); - gbMask |= FilterRegion(size, dir, order, audioCoef + start, psi->tnsLPCBuf, psi->tnsWorkBuf); - } - filtCoef += order; - } - } - audioCoef += winLen; - } - - /* update guard bit count if necessary */ - size = CLZ(gbMask) - 1; - if (psi->gbCurrent[ch] > size) - psi->gbCurrent[ch] = size; - - return 0; -} - -/* Code to generate invQuantXXX[] tables - * { - * int res, i, t; - * double powScale, iqfac, iqfac_m, d; - * - * powScale = pow(2.0, 31) * -1.0; / ** make coefficients negative for using MADD in kernel ** / - * for (res = 3; res <= 4; res++) { - * iqfac = ( ((1 << (res-1)) - 0.5) * (2.0 / M_PI) ); - * iqfac_m = ( ((1 << (res-1)) + 0.5) * (2.0 / M_PI) ); - * printf("static const int invQuant%d[16] = {\n", res); - * for (i = 0; i < 16; i++) { - * / ** extend bottom 4 bits into signed, 2's complement number ** / - * t = (i << 28) >> 28; - * - * if (t >= 0) d = sin(t / iqfac); - * else d = sin(t / iqfac_m); - * - * d *= powScale; - * printf("0x%08x, ", (int)(d > 0 ? d + 0.5 : d - 0.5)); - * if ((i & 0x07) == 0x07) - * printf("\n"); - * } - * printf("};\n\n"); - * } - * } - */ - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/trigtabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/trigtabs.c deleted file mode 100644 index 43012904..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-aac/trigtabs.c +++ /dev/null @@ -1,1004 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: trigtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * trigtabs.c - tables of sin, cos, etc. for IMDCT - **************************************************************************************/ - -#include "coder.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" - -const int cos4sin4tabOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* PreMultiply() tables - * format = Q30 * 2^[-7, -10] for nmdct = [128, 1024] - * reordered for sequential access - * - * invM = -1.0 / nmdct; - * for (i = 0; i < nmdct/4; i++) { - * angle = (i + 0.25) * M_PI / nmdct; - * x = invM * (cos(angle) + sin(angle)); - * x = invM * sin(angle); - * - * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct; - * x = invM * (cos(angle) + sin(angle)); - * x = invM * sin(angle); - * } - */ -const int cos4sin4tab[128 + 1024] PROGMEM = { -/* 128 - format = Q30 * 2^-7 */ -0xbf9bc731, 0xff9b783c, 0xbed5332c, 0xc002c697, 0xbe112251, 0xfe096c8d, 0xbd4f9c30, 0xc00f1c4a, -0xbc90a83f, 0xfc77ae5e, 0xbbd44dd9, 0xc0254e27, 0xbb1a9443, 0xfae67ba2, 0xba6382a6, 0xc04558c0, -0xb9af200f, 0xf9561237, 0xb8fd7373, 0xc06f3726, 0xb84e83ac, 0xf7c6afdc, 0xb7a25779, 0xc0a2e2e3, -0xb6f8f57c, 0xf6389228, 0xb652643e, 0xc0e05401, 0xb5aeaa2a, 0xf4abf67e, 0xb50dcd90, 0xc1278104, -0xb46fd4a4, 0xf3211a07, 0xb3d4c57c, 0xc1785ef4, 0xb33ca614, 0xf19839a6, 0xb2a77c49, 0xc1d2e158, -0xb2154dda, 0xf01191f3, 0xb186206b, 0xc236fa3b, 0xb0f9f981, 0xee8d5f29, 0xb070de82, 0xc2a49a2e, -0xafead4b9, 0xed0bdd25, 0xaf67e14f, 0xc31bb049, 0xaee80952, 0xeb8d475b, 0xae6b51ae, 0xc39c2a2f, -0xadf1bf34, 0xea11d8c8, 0xad7b5692, 0xc425f410, 0xad081c5a, 0xe899cbf1, 0xac9814fd, 0xc4b8f8ad, -0xac2b44cc, 0xe7255ad1, 0xabc1aff9, 0xc555215a, 0xab5b5a96, 0xe5b4bed8, 0xaaf84896, 0xc5fa5603, -0xaa987dca, 0xe44830dd, 0xaa3bfde3, 0xc6a87d2d, 0xa9e2cc73, 0xe2dfe917, 0xa98cece9, 0xc75f7bfe, -0xa93a6296, 0xe17c1f15, 0xa8eb30a7, 0xc81f363d, 0xa89f5a2b, 0xe01d09b4, 0xa856e20e, 0xc8e78e5b, -0xa811cb1b, 0xdec2df18, 0xa7d017fc, 0xc9b86572, 0xa791cb39, 0xdd6dd4a2, 0xa756e73a, 0xca919b4e, -0xa71f6e43, 0xdc1e1ee9, 0xa6eb6279, 0xcb730e70, 0xa6bac5dc, 0xdad3f1b1, 0xa68d9a4c, 0xcc5c9c14, -0xa663e188, 0xd98f7fe6, 0xa63d9d2b, 0xcd4e2037, 0xa61aceaf, 0xd850fb8e, 0xa5fb776b, 0xce47759a, -0xa5df9894, 0xd71895c9, 0xa5c7333e, 0xcf4875ca, 0xa5b2485a, 0xd5e67ec1, 0xa5a0d8b5, 0xd050f926, -0xa592e4fd, 0xd4bae5ab, 0xa5886dba, 0xd160d6e5, 0xa5817354, 0xd395f8ba, 0xa57df60f, 0xd277e518, -/* 1024 - format = Q30 * 2^-10 */ -0xbff3703e, 0xfff36f02, 0xbfda5824, 0xc0000b1a, 0xbfc149ed, 0xffc12b16, 0xbfa845a0, 0xc0003c74, -0xbf8f4b3e, 0xff8ee750, 0xbf765acc, 0xc0009547, 0xbf5d744e, 0xff5ca3d0, 0xbf4497c8, 0xc0011594, -0xbf2bc53d, 0xff2a60b4, 0xbf12fcb2, 0xc001bd5c, 0xbefa3e2a, 0xfef81e1d, 0xbee189a8, 0xc0028c9c, -0xbec8df32, 0xfec5dc28, 0xbeb03eca, 0xc0038356, 0xbe97a875, 0xfe939af5, 0xbe7f1c36, 0xc004a188, -0xbe669a10, 0xfe615aa3, 0xbe4e2209, 0xc005e731, 0xbe35b423, 0xfe2f1b50, 0xbe1d5062, 0xc0075452, -0xbe04f6cb, 0xfdfcdd1d, 0xbdeca760, 0xc008e8e8, 0xbdd46225, 0xfdcaa027, 0xbdbc2720, 0xc00aa4f3, -0xbda3f652, 0xfd98648d, 0xbd8bcfbf, 0xc00c8872, 0xbd73b36d, 0xfd662a70, 0xbd5ba15d, 0xc00e9364, -0xbd439995, 0xfd33f1ed, 0xbd2b9c17, 0xc010c5c7, 0xbd13a8e7, 0xfd01bb24, 0xbcfbc00a, 0xc0131f9b, -0xbce3e182, 0xfccf8634, 0xbccc0d53, 0xc015a0dd, 0xbcb44382, 0xfc9d533b, 0xbc9c8411, 0xc018498c, -0xbc84cf05, 0xfc6b2259, 0xbc6d2461, 0xc01b19a7, 0xbc558428, 0xfc38f3ac, 0xbc3dee5f, 0xc01e112b, -0xbc266309, 0xfc06c754, 0xbc0ee22a, 0xc0213018, 0xbbf76bc4, 0xfbd49d70, 0xbbdfffdd, 0xc024766a, -0xbbc89e77, 0xfba2761e, 0xbbb14796, 0xc027e421, 0xbb99fb3e, 0xfb70517d, 0xbb82b972, 0xc02b7939, -0xbb6b8235, 0xfb3e2fac, 0xbb54558d, 0xc02f35b1, 0xbb3d337b, 0xfb0c10cb, 0xbb261c04, 0xc0331986, -0xbb0f0f2b, 0xfad9f4f8, 0xbaf80cf4, 0xc03724b6, 0xbae11561, 0xfaa7dc52, 0xbaca2878, 0xc03b573f, -0xbab3463b, 0xfa75c6f8, 0xba9c6eae, 0xc03fb11d, 0xba85a1d4, 0xfa43b508, 0xba6edfb1, 0xc044324f, -0xba582849, 0xfa11a6a3, 0xba417b9e, 0xc048dad1, 0xba2ad9b5, 0xf9df9be6, 0xba144291, 0xc04daaa1, -0xb9fdb635, 0xf9ad94f0, 0xb9e734a4, 0xc052a1bb, 0xb9d0bde4, 0xf97b91e1, 0xb9ba51f6, 0xc057c01d, -0xb9a3f0de, 0xf94992d7, 0xb98d9aa0, 0xc05d05c3, 0xb9774f3f, 0xf91797f0, 0xb9610ebe, 0xc06272aa, -0xb94ad922, 0xf8e5a14d, 0xb934ae6d, 0xc06806ce, 0xb91e8ea3, 0xf8b3af0c, 0xb90879c7, 0xc06dc22e, -0xb8f26fdc, 0xf881c14b, 0xb8dc70e7, 0xc073a4c3, 0xb8c67cea, 0xf84fd829, 0xb8b093ea, 0xc079ae8c, -0xb89ab5e8, 0xf81df3c5, 0xb884e2e9, 0xc07fdf85, 0xb86f1af0, 0xf7ec143e, 0xb8595e00, 0xc08637a9, -0xb843ac1d, 0xf7ba39b3, 0xb82e0549, 0xc08cb6f5, 0xb818698a, 0xf7886442, 0xb802d8e0, 0xc0935d64, -0xb7ed5351, 0xf756940a, 0xb7d7d8df, 0xc09a2af3, 0xb7c2698e, 0xf724c92a, 0xb7ad0561, 0xc0a11f9d, -0xb797ac5b, 0xf6f303c0, 0xb7825e80, 0xc0a83b5e, 0xb76d1bd2, 0xf6c143ec, 0xb757e455, 0xc0af7e33, -0xb742b80d, 0xf68f89cb, 0xb72d96fd, 0xc0b6e815, 0xb7188127, 0xf65dd57d, 0xb7037690, 0xc0be7901, -0xb6ee773a, 0xf62c2721, 0xb6d98328, 0xc0c630f2, 0xb6c49a5e, 0xf5fa7ed4, 0xb6afbce0, 0xc0ce0fe3, -0xb69aeab0, 0xf5c8dcb6, 0xb68623d1, 0xc0d615cf, 0xb6716847, 0xf59740e5, 0xb65cb815, 0xc0de42b2, -0xb648133e, 0xf565ab80, 0xb63379c5, 0xc0e69686, 0xb61eebae, 0xf5341ca5, 0xb60a68fb, 0xc0ef1147, -0xb5f5f1b1, 0xf5029473, 0xb5e185d1, 0xc0f7b2ee, 0xb5cd255f, 0xf4d11308, 0xb5b8d05f, 0xc1007b77, -0xb5a486d2, 0xf49f9884, 0xb59048be, 0xc1096add, 0xb57c1624, 0xf46e2504, 0xb567ef08, 0xc1128119, -0xb553d36c, 0xf43cb8a7, 0xb53fc355, 0xc11bbe26, 0xb52bbec4, 0xf40b538b, 0xb517c5be, 0xc12521ff, -0xb503d845, 0xf3d9f5cf, 0xb4eff65c, 0xc12eac9d, 0xb4dc2007, 0xf3a89f92, 0xb4c85548, 0xc1385dfb, -0xb4b49622, 0xf37750f2, 0xb4a0e299, 0xc1423613, 0xb48d3ab0, 0xf3460a0d, 0xb4799e69, 0xc14c34df, -0xb4660dc8, 0xf314cb02, 0xb45288cf, 0xc1565a58, 0xb43f0f82, 0xf2e393ef, 0xb42ba1e4, 0xc160a678, -0xb4183ff7, 0xf2b264f2, 0xb404e9bf, 0xc16b193a, 0xb3f19f3e, 0xf2813e2a, 0xb3de6078, 0xc175b296, -0xb3cb2d70, 0xf2501fb5, 0xb3b80628, 0xc1807285, 0xb3a4eaa4, 0xf21f09b1, 0xb391dae6, 0xc18b5903, -0xb37ed6f1, 0xf1edfc3d, 0xb36bdec9, 0xc1966606, 0xb358f26f, 0xf1bcf777, 0xb34611e8, 0xc1a1998a, -0xb3333d36, 0xf18bfb7d, 0xb320745c, 0xc1acf386, 0xb30db75d, 0xf15b086d, 0xb2fb063b, 0xc1b873f5, -0xb2e860fa, 0xf12a1e66, 0xb2d5c79d, 0xc1c41ace, 0xb2c33a26, 0xf0f93d86, 0xb2b0b898, 0xc1cfe80a, -0xb29e42f6, 0xf0c865ea, 0xb28bd943, 0xc1dbdba3, 0xb2797b82, 0xf09797b2, 0xb26729b5, 0xc1e7f591, -0xb254e3e0, 0xf066d2fa, 0xb242aa05, 0xc1f435cc, 0xb2307c27, 0xf03617e2, 0xb21e5a49, 0xc2009c4e, -0xb20c446d, 0xf0056687, 0xb1fa3a97, 0xc20d290d, 0xb1e83cc9, 0xefd4bf08, 0xb1d64b06, 0xc219dc03, -0xb1c46551, 0xefa42181, 0xb1b28bad, 0xc226b528, 0xb1a0be1b, 0xef738e12, 0xb18efca0, 0xc233b473, -0xb17d473d, 0xef4304d8, 0xb16b9df6, 0xc240d9de, 0xb15a00cd, 0xef1285f2, 0xb1486fc5, 0xc24e255e, -0xb136eae1, 0xeee2117c, 0xb1257223, 0xc25b96ee, 0xb114058e, 0xeeb1a796, 0xb102a524, 0xc2692e83, -0xb0f150e9, 0xee81485c, 0xb0e008e0, 0xc276ec16, 0xb0cecd09, 0xee50f3ed, 0xb0bd9d6a, 0xc284cf9f, -0xb0ac7a03, 0xee20aa67, 0xb09b62d8, 0xc292d914, 0xb08a57eb, 0xedf06be6, 0xb079593f, 0xc2a1086d, -0xb06866d7, 0xedc0388a, 0xb05780b5, 0xc2af5da2, 0xb046a6db, 0xed901070, 0xb035d94e, 0xc2bdd8a9, -0xb025180e, 0xed5ff3b5, 0xb014631e, 0xc2cc7979, 0xb003ba82, 0xed2fe277, 0xaff31e3b, 0xc2db400a, -0xafe28e4d, 0xecffdcd4, 0xafd20ab9, 0xc2ea2c53, 0xafc19383, 0xeccfe2ea, 0xafb128ad, 0xc2f93e4a, -0xafa0ca39, 0xec9ff4d6, 0xaf90782a, 0xc30875e5, 0xaf803283, 0xec7012b5, 0xaf6ff945, 0xc317d31c, -0xaf5fcc74, 0xec403ca5, 0xaf4fac12, 0xc32755e5, 0xaf3f9822, 0xec1072c4, 0xaf2f90a5, 0xc336fe37, -0xaf1f959f, 0xebe0b52f, 0xaf0fa712, 0xc346cc07, 0xaeffc500, 0xebb10404, 0xaeefef6c, 0xc356bf4d, -0xaee02658, 0xeb815f60, 0xaed069c7, 0xc366d7fd, 0xaec0b9bb, 0xeb51c760, 0xaeb11636, 0xc377160f, -0xaea17f3b, 0xeb223c22, 0xae91f4cd, 0xc3877978, 0xae8276ed, 0xeaf2bdc3, 0xae73059f, 0xc398022f, -0xae63a0e3, 0xeac34c60, 0xae5448be, 0xc3a8b028, 0xae44fd31, 0xea93e817, 0xae35be3f, 0xc3b9835a, -0xae268be9, 0xea649105, 0xae176633, 0xc3ca7bba, 0xae084d1f, 0xea354746, 0xadf940ae, 0xc3db993e, -0xadea40e4, 0xea060af9, 0xaddb4dc2, 0xc3ecdbdc, 0xadcc674b, 0xe9d6dc3b, 0xadbd8d82, 0xc3fe4388, -0xadaec067, 0xe9a7bb28, 0xad9fffff, 0xc40fd037, 0xad914c4b, 0xe978a7dd, 0xad82a54c, 0xc42181e0, -0xad740b07, 0xe949a278, 0xad657d7c, 0xc4335877, 0xad56fcaf, 0xe91aab16, 0xad4888a0, 0xc44553f2, -0xad3a2153, 0xe8ebc1d3, 0xad2bc6ca, 0xc4577444, 0xad1d7907, 0xe8bce6cd, 0xad0f380c, 0xc469b963, -0xad0103db, 0xe88e1a20, 0xacf2dc77, 0xc47c2344, 0xace4c1e2, 0xe85f5be9, 0xacd6b41e, 0xc48eb1db, -0xacc8b32c, 0xe830ac45, 0xacbabf10, 0xc4a1651c, 0xacacd7cb, 0xe8020b52, 0xac9efd60, 0xc4b43cfd, -0xac912fd1, 0xe7d3792b, 0xac836f1f, 0xc4c73972, 0xac75bb4d, 0xe7a4f5ed, 0xac68145d, 0xc4da5a6f, -0xac5a7a52, 0xe77681b6, 0xac4ced2c, 0xc4ed9fe7, 0xac3f6cef, 0xe7481ca1, 0xac31f99d, 0xc50109d0, -0xac249336, 0xe719c6cb, 0xac1739bf, 0xc514981d, 0xac09ed38, 0xe6eb8052, 0xabfcada3, 0xc5284ac3, -0xabef7b04, 0xe6bd4951, 0xabe2555b, 0xc53c21b4, 0xabd53caa, 0xe68f21e5, 0xabc830f5, 0xc5501ce5, -0xabbb323c, 0xe6610a2a, 0xabae4082, 0xc5643c4a, 0xaba15bc9, 0xe633023e, 0xab948413, 0xc5787fd6, -0xab87b962, 0xe6050a3b, 0xab7afbb7, 0xc58ce77c, 0xab6e4b15, 0xe5d72240, 0xab61a77d, 0xc5a17330, -0xab5510f3, 0xe5a94a67, 0xab488776, 0xc5b622e6, 0xab3c0b0b, 0xe57b82cd, 0xab2f9bb1, 0xc5caf690, -0xab23396c, 0xe54dcb8f, 0xab16e43d, 0xc5dfee22, 0xab0a9c27, 0xe52024c9, 0xaafe612a, 0xc5f5098f, -0xaaf23349, 0xe4f28e96, 0xaae61286, 0xc60a48c9, 0xaad9fee3, 0xe4c50914, 0xaacdf861, 0xc61fabc4, -0xaac1ff03, 0xe497945d, 0xaab612ca, 0xc6353273, 0xaaaa33b8, 0xe46a308f, 0xaa9e61cf, 0xc64adcc7, -0xaa929d10, 0xe43cddc4, 0xaa86e57e, 0xc660aab5, 0xaa7b3b1b, 0xe40f9c1a, 0xaa6f9de7, 0xc6769c2e, -0xaa640de6, 0xe3e26bac, 0xaa588b18, 0xc68cb124, 0xaa4d157f, 0xe3b54c95, 0xaa41ad1e, 0xc6a2e98b, -0xaa3651f6, 0xe3883ef2, 0xaa2b0409, 0xc6b94554, 0xaa1fc358, 0xe35b42df, 0xaa148fe6, 0xc6cfc472, -0xaa0969b3, 0xe32e5876, 0xa9fe50c2, 0xc6e666d7, 0xa9f34515, 0xe3017fd5, 0xa9e846ad, 0xc6fd2c75, -0xa9dd558b, 0xe2d4b916, 0xa9d271b2, 0xc714153e, 0xa9c79b23, 0xe2a80456, 0xa9bcd1e0, 0xc72b2123, -0xa9b215ea, 0xe27b61af, 0xa9a76744, 0xc7425016, 0xa99cc5ee, 0xe24ed13d, 0xa99231eb, 0xc759a20a, -0xa987ab3c, 0xe222531c, 0xa97d31e3, 0xc77116f0, 0xa972c5e1, 0xe1f5e768, 0xa9686738, 0xc788aeb9, -0xa95e15e9, 0xe1c98e3b, 0xa953d1f7, 0xc7a06957, 0xa9499b62, 0xe19d47b1, 0xa93f722c, 0xc7b846ba, -0xa9355658, 0xe17113e5, 0xa92b47e5, 0xc7d046d6, 0xa92146d7, 0xe144f2f3, 0xa917532e, 0xc7e8699a, -0xa90d6cec, 0xe118e4f6, 0xa9039413, 0xc800aef7, 0xa8f9c8a4, 0xe0ecea09, 0xa8f00aa0, 0xc81916df, -0xa8e65a0a, 0xe0c10247, 0xa8dcb6e2, 0xc831a143, 0xa8d3212a, 0xe0952dcb, 0xa8c998e3, 0xc84a4e14, -0xa8c01e10, 0xe0696cb0, 0xa8b6b0b1, 0xc8631d42, 0xa8ad50c8, 0xe03dbf11, 0xa8a3fe57, 0xc87c0ebd, -0xa89ab95e, 0xe012250a, 0xa89181df, 0xc8952278, 0xa88857dc, 0xdfe69eb4, 0xa87f3b57, 0xc8ae5862, -0xa8762c4f, 0xdfbb2c2c, 0xa86d2ac8, 0xc8c7b06b, 0xa86436c2, 0xdf8fcd8b, 0xa85b503e, 0xc8e12a84, -0xa852773f, 0xdf6482ed, 0xa849abc4, 0xc8fac69e, 0xa840edd1, 0xdf394c6b, 0xa8383d66, 0xc91484a8, -0xa82f9a84, 0xdf0e2a22, 0xa827052d, 0xc92e6492, 0xa81e7d62, 0xdee31c2b, 0xa8160324, 0xc948664d, -0xa80d9675, 0xdeb822a1, 0xa8053756, 0xc96289c9, 0xa7fce5c9, 0xde8d3d9e, 0xa7f4a1ce, 0xc97ccef5, -0xa7ec6b66, 0xde626d3e, 0xa7e44294, 0xc99735c2, 0xa7dc2759, 0xde37b199, 0xa7d419b4, 0xc9b1be1e, -0xa7cc19a9, 0xde0d0acc, 0xa7c42738, 0xc9cc67fa, 0xa7bc4262, 0xdde278ef, 0xa7b46b29, 0xc9e73346, -0xa7aca18e, 0xddb7fc1e, 0xa7a4e591, 0xca021fef, 0xa79d3735, 0xdd8d9472, 0xa795967a, 0xca1d2de7, -0xa78e0361, 0xdd634206, 0xa7867dec, 0xca385d1d, 0xa77f061c, 0xdd3904f4, 0xa7779bf2, 0xca53ad7e, -0xa7703f70, 0xdd0edd55, 0xa768f095, 0xca6f1efc, 0xa761af64, 0xdce4cb44, 0xa75a7bdd, 0xca8ab184, -0xa7535602, 0xdcbacedb, 0xa74c3dd4, 0xcaa66506, 0xa7453353, 0xdc90e834, 0xa73e3681, 0xcac23971, -0xa7374760, 0xdc671768, 0xa73065ef, 0xcade2eb3, 0xa7299231, 0xdc3d5c91, 0xa722cc25, 0xcafa44bc, -0xa71c13ce, 0xdc13b7c9, 0xa715692c, 0xcb167b79, 0xa70ecc41, 0xdbea292b, 0xa7083d0d, 0xcb32d2da, -0xa701bb91, 0xdbc0b0ce, 0xa6fb47ce, 0xcb4f4acd, 0xa6f4e1c6, 0xdb974ece, 0xa6ee8979, 0xcb6be341, -0xa6e83ee8, 0xdb6e0342, 0xa6e20214, 0xcb889c23, 0xa6dbd2ff, 0xdb44ce46, 0xa6d5b1a9, 0xcba57563, -0xa6cf9e13, 0xdb1baff2, 0xa6c9983e, 0xcbc26eee, 0xa6c3a02b, 0xdaf2a860, 0xa6bdb5da, 0xcbdf88b3, -0xa6b7d94e, 0xdac9b7a9, 0xa6b20a86, 0xcbfcc29f, 0xa6ac4984, 0xdaa0dde7, 0xa6a69649, 0xcc1a1ca0, -0xa6a0f0d5, 0xda781b31, 0xa69b5929, 0xcc3796a5, 0xa695cf46, 0xda4f6fa3, 0xa690532d, 0xcc55309b, -0xa68ae4df, 0xda26db54, 0xa685845c, 0xcc72ea70, 0xa68031a6, 0xd9fe5e5e, 0xa67aecbd, 0xcc90c412, -0xa675b5a3, 0xd9d5f8d9, 0xa6708c57, 0xccaebd6e, 0xa66b70db, 0xd9adaadf, 0xa6666330, 0xccccd671, -0xa6616355, 0xd9857489, 0xa65c714d, 0xcceb0f0a, 0xa6578d18, 0xd95d55ef, 0xa652b6b6, 0xcd096725, -0xa64dee28, 0xd9354f2a, 0xa6493370, 0xcd27deb0, 0xa644868d, 0xd90d6053, 0xa63fe781, 0xcd467599, -0xa63b564c, 0xd8e58982, 0xa636d2ee, 0xcd652bcb, 0xa6325d6a, 0xd8bdcad0, 0xa62df5bf, 0xcd840134, -0xa6299bed, 0xd8962456, 0xa6254ff7, 0xcda2f5c2, 0xa62111db, 0xd86e962b, 0xa61ce19c, 0xcdc20960, -0xa618bf39, 0xd8472069, 0xa614aab3, 0xcde13bfd, 0xa610a40c, 0xd81fc328, 0xa60cab43, 0xce008d84, -0xa608c058, 0xd7f87e7f, 0xa604e34e, 0xce1ffde2, 0xa6011424, 0xd7d15288, 0xa5fd52db, 0xce3f8d05, -0xa5f99f73, 0xd7aa3f5a, 0xa5f5f9ed, 0xce5f3ad8, 0xa5f2624a, 0xd783450d, 0xa5eed88a, 0xce7f0748, -0xa5eb5cae, 0xd75c63ba, 0xa5e7eeb6, 0xce9ef241, 0xa5e48ea3, 0xd7359b78, 0xa5e13c75, 0xcebefbb0, -0xa5ddf82d, 0xd70eec60, 0xa5dac1cb, 0xcedf2380, 0xa5d79950, 0xd6e85689, 0xa5d47ebc, 0xceff699f, -0xa5d17210, 0xd6c1da0b, 0xa5ce734d, 0xcf1fcdf8, 0xa5cb8272, 0xd69b76fe, 0xa5c89f80, 0xcf405077, -0xa5c5ca77, 0xd6752d79, 0xa5c30359, 0xcf60f108, 0xa5c04a25, 0xd64efd94, 0xa5bd9edc, 0xcf81af97, -0xa5bb017f, 0xd628e767, 0xa5b8720d, 0xcfa28c10, 0xa5b5f087, 0xd602eb0a, 0xa5b37cee, 0xcfc3865e, -0xa5b11741, 0xd5dd0892, 0xa5aebf82, 0xcfe49e6d, 0xa5ac75b0, 0xd5b74019, 0xa5aa39cd, 0xd005d42a, -0xa5a80bd7, 0xd59191b5, 0xa5a5ebd0, 0xd027277e, 0xa5a3d9b8, 0xd56bfd7d, 0xa5a1d590, 0xd0489856, -0xa59fdf57, 0xd5468389, 0xa59df70e, 0xd06a269d, 0xa59c1cb5, 0xd52123f0, 0xa59a504c, 0xd08bd23f, -0xa59891d4, 0xd4fbdec9, 0xa596e14e, 0xd0ad9b26, 0xa5953eb8, 0xd4d6b42b, 0xa593aa14, 0xd0cf813e, -0xa5922362, 0xd4b1a42c, 0xa590aaa2, 0xd0f18472, 0xa58f3fd4, 0xd48caee4, 0xa58de2f8, 0xd113a4ad, -0xa58c940f, 0xd467d469, 0xa58b5319, 0xd135e1d9, 0xa58a2016, 0xd44314d3, 0xa588fb06, 0xd1583be2, -0xa587e3ea, 0xd41e7037, 0xa586dac1, 0xd17ab2b3, 0xa585df8c, 0xd3f9e6ad, 0xa584f24b, 0xd19d4636, -0xa58412fe, 0xd3d5784a, 0xa58341a5, 0xd1bff656, 0xa5827e40, 0xd3b12526, 0xa581c8d0, 0xd1e2c2fd, -0xa5812154, 0xd38ced57, 0xa58087cd, 0xd205ac17, 0xa57ffc3b, 0xd368d0f3, 0xa57f7e9d, 0xd228b18d, -0xa57f0ef5, 0xd344d011, 0xa57ead41, 0xd24bd34a, 0xa57e5982, 0xd320eac6, 0xa57e13b8, 0xd26f1138, -0xa57ddbe4, 0xd2fd2129, 0xa57db204, 0xd2926b41, 0xa57d961a, 0xd2d97350, 0xa57d8825, 0xd2b5e151, -}; - -/* PostMultiply() tables - * format = Q30 - * reordered for sequential access - * decimate (skip by 16 instead of 2) for small transform (128) - * - * for (i = 0; i <= (512/2); i++) { - * angle = i * M_PI / 1024; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -const int cos1sin1tab[514] PROGMEM = { -/* format = Q30 */ -0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58, -0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2, -0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb, -0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755, -0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df, -0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d, -0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3, -0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5, -0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb, -0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff, -0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de, -0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7, -0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac, -0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043, -0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7, -0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94, -0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e, -0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a, -0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7, -0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3, -0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807, -0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e, -0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc, -0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699, -0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6, -0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9, -0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1, -0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013, -0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d, -0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864, -0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6, -0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab, -0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82, -0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44, -0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4, -0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e, -0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518, -0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4, -0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c, -0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67, -0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696, -0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6, -0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190, -0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8, -0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f, -0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492, -0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca, -0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e, -0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543, -0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699, -0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1, -0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497, -0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6, -0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8, -0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5, -0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6, -0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661, -0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db, -0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a, -0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3, -0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d, -0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c, -0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87, -0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5, -0x5a82799a, 0x2d413ccd, -}; - -const int sinWindowOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* Synthesis window - SIN - * format = Q31 for nmdct = [128, 1024] - * reordered for sequential access - * - * for (i = 0; i < nmdct/2; i++) { - * angle = (i + 0.5) * M_PI / (2.0 * nmdct); - * x = sin(angle); - * - * angle = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct); - * x = sin(angle); - * } - */ -const int sinWindow[128 + 1024] PROGMEM = { -/* 128 - format = Q31 * 2^0 */ -0x00c90f88, 0x7fff6216, 0x025b26d7, 0x7ffa72d1, 0x03ed26e6, 0x7ff09478, 0x057f0035, 0x7fe1c76b, -0x0710a345, 0x7fce0c3e, 0x08a2009a, 0x7fb563b3, 0x0a3308bd, 0x7f97cebd, 0x0bc3ac35, 0x7f754e80, -0x0d53db92, 0x7f4de451, 0x0ee38766, 0x7f2191b4, 0x1072a048, 0x7ef05860, 0x120116d5, 0x7eba3a39, -0x138edbb1, 0x7e7f3957, 0x151bdf86, 0x7e3f57ff, 0x16a81305, 0x7dfa98a8, 0x183366e9, 0x7db0fdf8, -0x19bdcbf3, 0x7d628ac6, 0x1b4732ef, 0x7d0f4218, 0x1ccf8cb3, 0x7cb72724, 0x1e56ca1e, 0x7c5a3d50, -0x1fdcdc1b, 0x7bf88830, 0x2161b3a0, 0x7b920b89, 0x22e541af, 0x7b26cb4f, 0x24677758, 0x7ab6cba4, -0x25e845b6, 0x7a4210d8, 0x27679df4, 0x79c89f6e, 0x28e5714b, 0x794a7c12, 0x2a61b101, 0x78c7aba2, -0x2bdc4e6f, 0x78403329, 0x2d553afc, 0x77b417df, 0x2ecc681e, 0x77235f2d, 0x3041c761, 0x768e0ea6, -0x31b54a5e, 0x75f42c0b, 0x3326e2c3, 0x7555bd4c, 0x34968250, 0x74b2c884, 0x36041ad9, 0x740b53fb, -0x376f9e46, 0x735f6626, 0x38d8fe93, 0x72af05a7, 0x3a402dd2, 0x71fa3949, 0x3ba51e29, 0x71410805, -0x3d07c1d6, 0x708378ff, 0x3e680b2c, 0x6fc19385, 0x3fc5ec98, 0x6efb5f12, 0x4121589b, 0x6e30e34a, -0x427a41d0, 0x6d6227fa, 0x43d09aed, 0x6c8f351c, 0x452456bd, 0x6bb812d1, 0x46756828, 0x6adcc964, -0x47c3c22f, 0x69fd614a, 0x490f57ee, 0x6919e320, 0x4a581c9e, 0x683257ab, 0x4b9e0390, 0x6746c7d8, -0x4ce10034, 0x66573cbb, 0x4e210617, 0x6563bf92, 0x4f5e08e3, 0x646c59bf, 0x5097fc5e, 0x637114cc, -0x51ced46e, 0x6271fa69, 0x53028518, 0x616f146c, 0x5433027d, 0x60686ccf, 0x556040e2, 0x5f5e0db3, -0x568a34a9, 0x5e50015d, 0x57b0d256, 0x5d3e5237, 0x58d40e8c, 0x5c290acc, 0x59f3de12, 0x5b1035cf, -/* 1024 - format = Q31 * 2^0 */ -0x001921fb, 0x7ffffd88, 0x004b65ee, 0x7fffe9cb, 0x007da9d4, 0x7fffc251, 0x00afeda8, 0x7fff8719, -0x00e23160, 0x7fff3824, 0x011474f6, 0x7ffed572, 0x0146b860, 0x7ffe5f03, 0x0178fb99, 0x7ffdd4d7, -0x01ab3e97, 0x7ffd36ee, 0x01dd8154, 0x7ffc8549, 0x020fc3c6, 0x7ffbbfe6, 0x024205e8, 0x7ffae6c7, -0x027447b0, 0x7ff9f9ec, 0x02a68917, 0x7ff8f954, 0x02d8ca16, 0x7ff7e500, 0x030b0aa4, 0x7ff6bcf0, -0x033d4abb, 0x7ff58125, 0x036f8a51, 0x7ff4319d, 0x03a1c960, 0x7ff2ce5b, 0x03d407df, 0x7ff1575d, -0x040645c7, 0x7fefcca4, 0x04388310, 0x7fee2e30, 0x046abfb3, 0x7fec7c02, 0x049cfba7, 0x7feab61a, -0x04cf36e5, 0x7fe8dc78, 0x05017165, 0x7fe6ef1c, 0x0533ab20, 0x7fe4ee06, 0x0565e40d, 0x7fe2d938, -0x05981c26, 0x7fe0b0b1, 0x05ca5361, 0x7fde7471, 0x05fc89b8, 0x7fdc247a, 0x062ebf22, 0x7fd9c0ca, -0x0660f398, 0x7fd74964, 0x06932713, 0x7fd4be46, 0x06c5598a, 0x7fd21f72, 0x06f78af6, 0x7fcf6ce8, -0x0729bb4e, 0x7fcca6a7, 0x075bea8c, 0x7fc9ccb2, 0x078e18a7, 0x7fc6df08, 0x07c04598, 0x7fc3dda9, -0x07f27157, 0x7fc0c896, 0x08249bdd, 0x7fbd9fd0, 0x0856c520, 0x7fba6357, 0x0888ed1b, 0x7fb7132b, -0x08bb13c5, 0x7fb3af4e, 0x08ed3916, 0x7fb037bf, 0x091f5d06, 0x7facac7f, 0x09517f8f, 0x7fa90d8e, -0x0983a0a7, 0x7fa55aee, 0x09b5c048, 0x7fa1949e, 0x09e7de6a, 0x7f9dbaa0, 0x0a19fb04, 0x7f99ccf4, -0x0a4c1610, 0x7f95cb9a, 0x0a7e2f85, 0x7f91b694, 0x0ab0475c, 0x7f8d8de1, 0x0ae25d8d, 0x7f895182, -0x0b147211, 0x7f850179, 0x0b4684df, 0x7f809dc5, 0x0b7895f0, 0x7f7c2668, 0x0baaa53b, 0x7f779b62, -0x0bdcb2bb, 0x7f72fcb4, 0x0c0ebe66, 0x7f6e4a5e, 0x0c40c835, 0x7f698461, 0x0c72d020, 0x7f64aabf, -0x0ca4d620, 0x7f5fbd77, 0x0cd6da2d, 0x7f5abc8a, 0x0d08dc3f, 0x7f55a7fa, 0x0d3adc4e, 0x7f507fc7, -0x0d6cda53, 0x7f4b43f2, 0x0d9ed646, 0x7f45f47b, 0x0dd0d01f, 0x7f409164, 0x0e02c7d7, 0x7f3b1aad, -0x0e34bd66, 0x7f359057, 0x0e66b0c3, 0x7f2ff263, 0x0e98a1e9, 0x7f2a40d2, 0x0eca90ce, 0x7f247ba5, -0x0efc7d6b, 0x7f1ea2dc, 0x0f2e67b8, 0x7f18b679, 0x0f604faf, 0x7f12b67c, 0x0f923546, 0x7f0ca2e7, -0x0fc41876, 0x7f067bba, 0x0ff5f938, 0x7f0040f6, 0x1027d784, 0x7ef9f29d, 0x1059b352, 0x7ef390ae, -0x108b8c9b, 0x7eed1b2c, 0x10bd6356, 0x7ee69217, 0x10ef377d, 0x7edff570, 0x11210907, 0x7ed94538, -0x1152d7ed, 0x7ed28171, 0x1184a427, 0x7ecbaa1a, 0x11b66dad, 0x7ec4bf36, 0x11e83478, 0x7ebdc0c6, -0x1219f880, 0x7eb6aeca, 0x124bb9be, 0x7eaf8943, 0x127d7829, 0x7ea85033, 0x12af33ba, 0x7ea1039b, -0x12e0ec6a, 0x7e99a37c, 0x1312a230, 0x7e922fd6, 0x13445505, 0x7e8aa8ac, 0x137604e2, 0x7e830dff, -0x13a7b1bf, 0x7e7b5fce, 0x13d95b93, 0x7e739e1d, 0x140b0258, 0x7e6bc8eb, 0x143ca605, 0x7e63e03b, -0x146e4694, 0x7e5be40c, 0x149fe3fc, 0x7e53d462, 0x14d17e36, 0x7e4bb13c, 0x1503153a, 0x7e437a9c, -0x1534a901, 0x7e3b3083, 0x15663982, 0x7e32d2f4, 0x1597c6b7, 0x7e2a61ed, 0x15c95097, 0x7e21dd73, -0x15fad71b, 0x7e194584, 0x162c5a3b, 0x7e109a24, 0x165dd9f0, 0x7e07db52, 0x168f5632, 0x7dff0911, -0x16c0cef9, 0x7df62362, 0x16f2443e, 0x7ded2a47, 0x1723b5f9, 0x7de41dc0, 0x17552422, 0x7ddafdce, -0x17868eb3, 0x7dd1ca75, 0x17b7f5a3, 0x7dc883b4, 0x17e958ea, 0x7dbf298d, 0x181ab881, 0x7db5bc02, -0x184c1461, 0x7dac3b15, 0x187d6c82, 0x7da2a6c6, 0x18aec0db, 0x7d98ff17, 0x18e01167, 0x7d8f4409, -0x19115e1c, 0x7d85759f, 0x1942a6f3, 0x7d7b93da, 0x1973ebe6, 0x7d719eba, 0x19a52ceb, 0x7d679642, -0x19d669fc, 0x7d5d7a74, 0x1a07a311, 0x7d534b50, 0x1a38d823, 0x7d4908d9, 0x1a6a0929, 0x7d3eb30f, -0x1a9b361d, 0x7d3449f5, 0x1acc5ef6, 0x7d29cd8c, 0x1afd83ad, 0x7d1f3dd6, 0x1b2ea43a, 0x7d149ad5, -0x1b5fc097, 0x7d09e489, 0x1b90d8bb, 0x7cff1af5, 0x1bc1ec9e, 0x7cf43e1a, 0x1bf2fc3a, 0x7ce94dfb, -0x1c240786, 0x7cde4a98, 0x1c550e7c, 0x7cd333f3, 0x1c861113, 0x7cc80a0f, 0x1cb70f43, 0x7cbcccec, -0x1ce80906, 0x7cb17c8d, 0x1d18fe54, 0x7ca618f3, 0x1d49ef26, 0x7c9aa221, 0x1d7adb73, 0x7c8f1817, -0x1dabc334, 0x7c837ad8, 0x1ddca662, 0x7c77ca65, 0x1e0d84f5, 0x7c6c06c0, 0x1e3e5ee5, 0x7c602fec, -0x1e6f342c, 0x7c5445e9, 0x1ea004c1, 0x7c4848ba, 0x1ed0d09d, 0x7c3c3860, 0x1f0197b8, 0x7c3014de, -0x1f325a0b, 0x7c23de35, 0x1f63178f, 0x7c179467, 0x1f93d03c, 0x7c0b3777, 0x1fc4840a, 0x7bfec765, -0x1ff532f2, 0x7bf24434, 0x2025dcec, 0x7be5ade6, 0x205681f1, 0x7bd9047c, 0x208721f9, 0x7bcc47fa, -0x20b7bcfe, 0x7bbf7860, 0x20e852f6, 0x7bb295b0, 0x2118e3dc, 0x7ba59fee, 0x21496fa7, 0x7b989719, -0x2179f64f, 0x7b8b7b36, 0x21aa77cf, 0x7b7e4c45, 0x21daf41d, 0x7b710a49, 0x220b6b32, 0x7b63b543, -0x223bdd08, 0x7b564d36, 0x226c4996, 0x7b48d225, 0x229cb0d5, 0x7b3b4410, 0x22cd12bd, 0x7b2da2fa, -0x22fd6f48, 0x7b1feee5, 0x232dc66d, 0x7b1227d3, 0x235e1826, 0x7b044dc7, 0x238e646a, 0x7af660c2, -0x23beab33, 0x7ae860c7, 0x23eeec78, 0x7ada4dd8, 0x241f2833, 0x7acc27f7, 0x244f5e5c, 0x7abdef25, -0x247f8eec, 0x7aafa367, 0x24afb9da, 0x7aa144bc, 0x24dfdf20, 0x7a92d329, 0x250ffeb7, 0x7a844eae, -0x25401896, 0x7a75b74f, 0x25702cb7, 0x7a670d0d, 0x25a03b11, 0x7a584feb, 0x25d0439f, 0x7a497feb, -0x26004657, 0x7a3a9d0f, 0x26304333, 0x7a2ba75a, 0x26603a2c, 0x7a1c9ece, 0x26902b39, 0x7a0d836d, -0x26c01655, 0x79fe5539, 0x26effb76, 0x79ef1436, 0x271fda96, 0x79dfc064, 0x274fb3ae, 0x79d059c8, -0x277f86b5, 0x79c0e062, 0x27af53a6, 0x79b15435, 0x27df1a77, 0x79a1b545, 0x280edb23, 0x79920392, -0x283e95a1, 0x79823f20, 0x286e49ea, 0x797267f2, 0x289df7f8, 0x79627e08, 0x28cd9fc1, 0x79528167, -0x28fd4140, 0x79427210, 0x292cdc6d, 0x79325006, 0x295c7140, 0x79221b4b, 0x298bffb2, 0x7911d3e2, -0x29bb87bc, 0x790179cd, 0x29eb0957, 0x78f10d0f, 0x2a1a847b, 0x78e08dab, 0x2a49f920, 0x78cffba3, -0x2a796740, 0x78bf56f9, 0x2aa8ced3, 0x78ae9fb0, 0x2ad82fd2, 0x789dd5cb, 0x2b078a36, 0x788cf94c, -0x2b36ddf7, 0x787c0a36, 0x2b662b0e, 0x786b088c, 0x2b957173, 0x7859f44f, 0x2bc4b120, 0x7848cd83, -0x2bf3ea0d, 0x7837942b, 0x2c231c33, 0x78264849, 0x2c52478a, 0x7814e9df, 0x2c816c0c, 0x780378f1, -0x2cb089b1, 0x77f1f581, 0x2cdfa071, 0x77e05f91, 0x2d0eb046, 0x77ceb725, 0x2d3db928, 0x77bcfc3f, -0x2d6cbb10, 0x77ab2ee2, 0x2d9bb5f6, 0x77994f11, 0x2dcaa9d5, 0x77875cce, 0x2df996a3, 0x7775581d, -0x2e287c5a, 0x776340ff, 0x2e575af3, 0x77511778, 0x2e863267, 0x773edb8b, 0x2eb502ae, 0x772c8d3a, -0x2ee3cbc1, 0x771a2c88, 0x2f128d99, 0x7707b979, 0x2f41482e, 0x76f5340e, 0x2f6ffb7a, 0x76e29c4b, -0x2f9ea775, 0x76cff232, 0x2fcd4c19, 0x76bd35c7, 0x2ffbe95d, 0x76aa670d, 0x302a7f3a, 0x76978605, -0x30590dab, 0x768492b4, 0x308794a6, 0x76718d1c, 0x30b61426, 0x765e7540, 0x30e48c22, 0x764b4b23, -0x3112fc95, 0x76380ec8, 0x31416576, 0x7624c031, 0x316fc6be, 0x76115f63, 0x319e2067, 0x75fdec60, -0x31cc7269, 0x75ea672a, 0x31fabcbd, 0x75d6cfc5, 0x3228ff5c, 0x75c32634, 0x32573a3f, 0x75af6a7b, -0x32856d5e, 0x759b9c9b, 0x32b398b3, 0x7587bc98, 0x32e1bc36, 0x7573ca75, 0x330fd7e1, 0x755fc635, -0x333debab, 0x754bafdc, 0x336bf78f, 0x7537876c, 0x3399fb85, 0x75234ce8, 0x33c7f785, 0x750f0054, -0x33f5eb89, 0x74faa1b3, 0x3423d78a, 0x74e63108, 0x3451bb81, 0x74d1ae55, 0x347f9766, 0x74bd199f, -0x34ad6b32, 0x74a872e8, 0x34db36df, 0x7493ba34, 0x3508fa66, 0x747eef85, 0x3536b5be, 0x746a12df, -0x356468e2, 0x74552446, 0x359213c9, 0x744023bc, 0x35bfb66e, 0x742b1144, 0x35ed50c9, 0x7415ece2, -0x361ae2d3, 0x7400b69a, 0x36486c86, 0x73eb6e6e, 0x3675edd9, 0x73d61461, 0x36a366c6, 0x73c0a878, -0x36d0d746, 0x73ab2ab4, 0x36fe3f52, 0x73959b1b, 0x372b9ee3, 0x737ff9ae, 0x3758f5f2, 0x736a4671, -0x37864477, 0x73548168, 0x37b38a6d, 0x733eaa96, 0x37e0c7cc, 0x7328c1ff, 0x380dfc8d, 0x7312c7a5, -0x383b28a9, 0x72fcbb8c, 0x38684c19, 0x72e69db7, 0x389566d6, 0x72d06e2b, 0x38c278d9, 0x72ba2cea, -0x38ef821c, 0x72a3d9f7, 0x391c8297, 0x728d7557, 0x39497a43, 0x7276ff0d, 0x39766919, 0x7260771b, -0x39a34f13, 0x7249dd86, 0x39d02c2a, 0x72333251, 0x39fd0056, 0x721c7580, 0x3a29cb91, 0x7205a716, -0x3a568dd4, 0x71eec716, 0x3a834717, 0x71d7d585, 0x3aaff755, 0x71c0d265, 0x3adc9e86, 0x71a9bdba, -0x3b093ca3, 0x71929789, 0x3b35d1a5, 0x717b5fd3, 0x3b625d86, 0x7164169d, 0x3b8ee03e, 0x714cbbeb, -0x3bbb59c7, 0x71354fc0, 0x3be7ca1a, 0x711dd220, 0x3c143130, 0x7106430e, 0x3c408f03, 0x70eea28e, -0x3c6ce38a, 0x70d6f0a4, 0x3c992ec0, 0x70bf2d53, 0x3cc5709e, 0x70a7589f, 0x3cf1a91c, 0x708f728b, -0x3d1dd835, 0x70777b1c, 0x3d49fde1, 0x705f7255, 0x3d761a19, 0x70475839, 0x3da22cd7, 0x702f2ccd, -0x3dce3614, 0x7016f014, 0x3dfa35c8, 0x6ffea212, 0x3e262bee, 0x6fe642ca, 0x3e52187f, 0x6fcdd241, -0x3e7dfb73, 0x6fb5507a, 0x3ea9d4c3, 0x6f9cbd79, 0x3ed5a46b, 0x6f841942, 0x3f016a61, 0x6f6b63d8, -0x3f2d26a0, 0x6f529d40, 0x3f58d921, 0x6f39c57d, 0x3f8481dd, 0x6f20dc92, 0x3fb020ce, 0x6f07e285, -0x3fdbb5ec, 0x6eeed758, 0x40074132, 0x6ed5bb10, 0x4032c297, 0x6ebc8db0, 0x405e3a16, 0x6ea34f3d, -0x4089a7a8, 0x6e89ffb9, 0x40b50b46, 0x6e709f2a, 0x40e064ea, 0x6e572d93, 0x410bb48c, 0x6e3daaf8, -0x4136fa27, 0x6e24175c, 0x416235b2, 0x6e0a72c5, 0x418d6729, 0x6df0bd35, 0x41b88e84, 0x6dd6f6b1, -0x41e3abbc, 0x6dbd1f3c, 0x420ebecb, 0x6da336dc, 0x4239c7aa, 0x6d893d93, 0x4264c653, 0x6d6f3365, -0x428fbabe, 0x6d551858, 0x42baa4e6, 0x6d3aec6e, 0x42e584c3, 0x6d20afac, 0x43105a50, 0x6d066215, -0x433b2585, 0x6cec03af, 0x4365e65b, 0x6cd1947c, 0x43909ccd, 0x6cb71482, 0x43bb48d4, 0x6c9c83c3, -0x43e5ea68, 0x6c81e245, 0x44108184, 0x6c67300b, 0x443b0e21, 0x6c4c6d1a, 0x44659039, 0x6c319975, -0x449007c4, 0x6c16b521, 0x44ba74bd, 0x6bfbc021, 0x44e4d71c, 0x6be0ba7b, 0x450f2edb, 0x6bc5a431, -0x45397bf4, 0x6baa7d49, 0x4563be60, 0x6b8f45c7, 0x458df619, 0x6b73fdae, 0x45b82318, 0x6b58a503, -0x45e24556, 0x6b3d3bcb, 0x460c5cce, 0x6b21c208, 0x46366978, 0x6b0637c1, 0x46606b4e, 0x6aea9cf8, -0x468a624a, 0x6acef1b2, 0x46b44e65, 0x6ab335f4, 0x46de2f99, 0x6a9769c1, 0x470805df, 0x6a7b8d1e, -0x4731d131, 0x6a5fa010, 0x475b9188, 0x6a43a29a, 0x478546de, 0x6a2794c1, 0x47aef12c, 0x6a0b7689, -0x47d8906d, 0x69ef47f6, 0x48022499, 0x69d3090e, 0x482badab, 0x69b6b9d3, 0x48552b9b, 0x699a5a4c, -0x487e9e64, 0x697dea7b, 0x48a805ff, 0x69616a65, 0x48d16265, 0x6944da10, 0x48fab391, 0x6928397e, -0x4923f97b, 0x690b88b5, 0x494d341e, 0x68eec7b9, 0x49766373, 0x68d1f68f, 0x499f8774, 0x68b5153a, -0x49c8a01b, 0x689823bf, 0x49f1ad61, 0x687b2224, 0x4a1aaf3f, 0x685e106c, 0x4a43a5b0, 0x6840ee9b, -0x4a6c90ad, 0x6823bcb7, 0x4a957030, 0x68067ac3, 0x4abe4433, 0x67e928c5, 0x4ae70caf, 0x67cbc6c0, -0x4b0fc99d, 0x67ae54ba, 0x4b387af9, 0x6790d2b6, 0x4b6120bb, 0x677340ba, 0x4b89badd, 0x67559eca, -0x4bb24958, 0x6737ecea, 0x4bdacc28, 0x671a2b20, 0x4c034345, 0x66fc596f, 0x4c2baea9, 0x66de77dc, -0x4c540e4e, 0x66c0866d, 0x4c7c622d, 0x66a28524, 0x4ca4aa41, 0x66847408, 0x4ccce684, 0x6666531d, -0x4cf516ee, 0x66482267, 0x4d1d3b7a, 0x6629e1ec, 0x4d455422, 0x660b91af, 0x4d6d60df, 0x65ed31b5, -0x4d9561ac, 0x65cec204, 0x4dbd5682, 0x65b0429f, 0x4de53f5a, 0x6591b38c, 0x4e0d1c30, 0x657314cf, -0x4e34ecfc, 0x6554666d, 0x4e5cb1b9, 0x6535a86b, 0x4e846a60, 0x6516dacd, 0x4eac16eb, 0x64f7fd98, -0x4ed3b755, 0x64d910d1, 0x4efb4b96, 0x64ba147d, 0x4f22d3aa, 0x649b08a0, 0x4f4a4f89, 0x647bed3f, -0x4f71bf2e, 0x645cc260, 0x4f992293, 0x643d8806, 0x4fc079b1, 0x641e3e38, 0x4fe7c483, 0x63fee4f8, -0x500f0302, 0x63df7c4d, 0x50363529, 0x63c0043b, 0x505d5af1, 0x63a07cc7, 0x50847454, 0x6380e5f6, -0x50ab814d, 0x63613fcd, 0x50d281d5, 0x63418a50, 0x50f975e6, 0x6321c585, 0x51205d7b, 0x6301f171, -0x5147388c, 0x62e20e17, 0x516e0715, 0x62c21b7e, 0x5194c910, 0x62a219aa, 0x51bb7e75, 0x628208a1, -0x51e22740, 0x6261e866, 0x5208c36a, 0x6241b8ff, 0x522f52ee, 0x62217a72, 0x5255d5c5, 0x62012cc2, -0x527c4bea, 0x61e0cff5, 0x52a2b556, 0x61c06410, 0x52c91204, 0x619fe918, 0x52ef61ee, 0x617f5f12, -0x5315a50e, 0x615ec603, 0x533bdb5d, 0x613e1df0, 0x536204d7, 0x611d66de, 0x53882175, 0x60fca0d2, -0x53ae3131, 0x60dbcbd1, 0x53d43406, 0x60bae7e1, 0x53fa29ed, 0x6099f505, 0x542012e1, 0x6078f344, -0x5445eedb, 0x6057e2a2, 0x546bbdd7, 0x6036c325, 0x54917fce, 0x601594d1, 0x54b734ba, 0x5ff457ad, -0x54dcdc96, 0x5fd30bbc, 0x5502775c, 0x5fb1b104, 0x55280505, 0x5f90478a, 0x554d858d, 0x5f6ecf53, -0x5572f8ed, 0x5f4d4865, 0x55985f20, 0x5f2bb2c5, 0x55bdb81f, 0x5f0a0e77, 0x55e303e6, 0x5ee85b82, -0x5608426e, 0x5ec699e9, 0x562d73b2, 0x5ea4c9b3, 0x565297ab, 0x5e82eae5, 0x5677ae54, 0x5e60fd84, -0x569cb7a8, 0x5e3f0194, 0x56c1b3a1, 0x5e1cf71c, 0x56e6a239, 0x5dfade20, 0x570b8369, 0x5dd8b6a7, -0x5730572e, 0x5db680b4, 0x57551d80, 0x5d943c4e, 0x5779d65b, 0x5d71e979, 0x579e81b8, 0x5d4f883b, -0x57c31f92, 0x5d2d189a, 0x57e7afe4, 0x5d0a9a9a, 0x580c32a7, 0x5ce80e41, 0x5830a7d6, 0x5cc57394, -0x58550f6c, 0x5ca2ca99, 0x58796962, 0x5c801354, 0x589db5b3, 0x5c5d4dcc, 0x58c1f45b, 0x5c3a7a05, -0x58e62552, 0x5c179806, 0x590a4893, 0x5bf4a7d2, 0x592e5e19, 0x5bd1a971, 0x595265df, 0x5bae9ce7, -0x59765fde, 0x5b8b8239, 0x599a4c12, 0x5b68596d, 0x59be2a74, 0x5b452288, 0x59e1faff, 0x5b21dd90, -0x5a05bdae, 0x5afe8a8b, 0x5a29727b, 0x5adb297d, 0x5a4d1960, 0x5ab7ba6c, 0x5a70b258, 0x5a943d5e, -}; - -const int kbdWindowOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* Synthesis window - KBD - * format = Q31 for nmdct = [128, 1024] - * reordered for sequential access - * - * aacScaleFact = -sqrt(1.0 / (2.0 * nmdct)); - * for (i = 0; i < nmdct/2; i++) { - * x = kbdWindowRef[i] * aacScaleFact; - * x = kbdWindowRef[nmdct - 1 - i] * aacScaleFact; - * } - * Note: see below for code to generate kbdWindowRef[] - */ -const int kbdWindow[128 + 1024] PROGMEM = { -/* 128 - format = Q31 * 2^0 */ -0x00016f63, 0x7ffffffe, 0x0003e382, 0x7ffffff1, 0x00078f64, 0x7fffffc7, 0x000cc323, 0x7fffff5d, -0x0013d9ed, 0x7ffffe76, 0x001d3a9d, 0x7ffffcaa, 0x0029581f, 0x7ffff953, 0x0038b1bd, 0x7ffff372, -0x004bd34d, 0x7fffe98b, 0x00635538, 0x7fffd975, 0x007fdc64, 0x7fffc024, 0x00a219f1, 0x7fff995b, -0x00cacad0, 0x7fff5f5b, 0x00fab72d, 0x7fff0a75, 0x0132b1af, 0x7ffe9091, 0x01739689, 0x7ffde49e, -0x01be4a63, 0x7ffcf5ef, 0x0213b910, 0x7ffbaf84, 0x0274d41e, 0x7ff9f73a, 0x02e2913a, 0x7ff7acf1, -0x035de86c, 0x7ff4a99a, 0x03e7d233, 0x7ff0be3d, 0x0481457c, 0x7febb2f1, 0x052b357c, 0x7fe545d4, -0x05e68f77, 0x7fdd2a02, 0x06b4386f, 0x7fd30695, 0x07950acb, 0x7fc675b4, 0x0889d3ef, 0x7fb703be, -0x099351e0, 0x7fa42e89, 0x0ab230e0, 0x7f8d64d8, 0x0be70923, 0x7f7205f8, 0x0d325c93, 0x7f516195, -0x0e9494ae, 0x7f2ab7d0, 0x100e0085, 0x7efd3997, 0x119ed2ef, 0x7ec8094a, 0x134720d8, 0x7e8a3ba7, -0x1506dfdc, 0x7e42d906, 0x16dde50b, 0x7df0dee4, 0x18cbe3f7, 0x7d9341b4, 0x1ad06e07, 0x7d28ef02, -0x1ceaf215, 0x7cb0cfcc, 0x1f1abc4f, 0x7c29cb20, 0x215ef677, 0x7b92c8eb, 0x23b6a867, 0x7aeab4ec, -0x2620b8ec, 0x7a3081d0, 0x289beef5, 0x79632c5a, 0x2b26f30b, 0x7881be95, 0x2dc0511f, 0x778b5304, -0x30667aa2, 0x767f17c0, 0x3317c8dd, 0x755c5178, 0x35d27f98, 0x74225e50, 0x3894cff3, 0x72d0b887, -0x3b5cdb7b, 0x7166f8e7, 0x3e28b770, 0x6fe4d8e8, 0x40f6702a, 0x6e4a3491, 0x43c40caa, 0x6c970bfc, -0x468f9231, 0x6acb8483, 0x495707f5, 0x68e7e994, 0x4c187ac7, 0x66ecad1c, 0x4ed200c5, 0x64da6797, -0x5181bcea, 0x62b1d7b7, 0x5425e28e, 0x6073e1ae, 0x56bcb8c2, 0x5e218e16, 0x59449d76, 0x5bbc0875, -/* 1024 - format = Q31 * 2^0 */ -0x0009962f, 0x7fffffa4, 0x000e16fb, 0x7fffff39, 0x0011ea65, 0x7ffffebf, 0x0015750e, 0x7ffffe34, -0x0018dc74, 0x7ffffd96, 0x001c332e, 0x7ffffce5, 0x001f83f5, 0x7ffffc1f, 0x0022d59a, 0x7ffffb43, -0x00262cc2, 0x7ffffa4f, 0x00298cc4, 0x7ffff942, 0x002cf81f, 0x7ffff81a, 0x003070c4, 0x7ffff6d6, -0x0033f840, 0x7ffff573, 0x00378fd9, 0x7ffff3f1, 0x003b38a1, 0x7ffff24d, 0x003ef381, 0x7ffff085, -0x0042c147, 0x7fffee98, 0x0046a2a8, 0x7fffec83, 0x004a9847, 0x7fffea44, 0x004ea2b7, 0x7fffe7d8, -0x0052c283, 0x7fffe53f, 0x0056f829, 0x7fffe274, 0x005b4422, 0x7fffdf76, 0x005fa6dd, 0x7fffdc43, -0x006420c8, 0x7fffd8d6, 0x0068b249, 0x7fffd52f, 0x006d5bc4, 0x7fffd149, 0x00721d9a, 0x7fffcd22, -0x0076f828, 0x7fffc8b6, 0x007bebca, 0x7fffc404, 0x0080f8d9, 0x7fffbf06, 0x00861fae, 0x7fffb9bb, -0x008b609e, 0x7fffb41e, 0x0090bbff, 0x7fffae2c, 0x00963224, 0x7fffa7e1, 0x009bc362, 0x7fffa13a, -0x00a17009, 0x7fff9a32, 0x00a7386c, 0x7fff92c5, 0x00ad1cdc, 0x7fff8af0, 0x00b31da8, 0x7fff82ad, -0x00b93b21, 0x7fff79f9, 0x00bf7596, 0x7fff70cf, 0x00c5cd57, 0x7fff672a, 0x00cc42b1, 0x7fff5d05, -0x00d2d5f3, 0x7fff525c, 0x00d9876c, 0x7fff4729, 0x00e05769, 0x7fff3b66, 0x00e74638, 0x7fff2f10, -0x00ee5426, 0x7fff221f, 0x00f58182, 0x7fff148e, 0x00fcce97, 0x7fff0658, 0x01043bb3, 0x7ffef776, -0x010bc923, 0x7ffee7e2, 0x01137733, 0x7ffed795, 0x011b4631, 0x7ffec68a, 0x01233669, 0x7ffeb4ba, -0x012b4827, 0x7ffea21d, 0x01337bb8, 0x7ffe8eac, 0x013bd167, 0x7ffe7a61, 0x01444982, 0x7ffe6533, -0x014ce454, 0x7ffe4f1c, 0x0155a229, 0x7ffe3813, 0x015e834d, 0x7ffe2011, 0x0167880c, 0x7ffe070d, -0x0170b0b2, 0x7ffdecff, 0x0179fd8b, 0x7ffdd1df, 0x01836ee1, 0x7ffdb5a2, 0x018d0500, 0x7ffd9842, -0x0196c035, 0x7ffd79b3, 0x01a0a0ca, 0x7ffd59ee, 0x01aaa70a, 0x7ffd38e8, 0x01b4d341, 0x7ffd1697, -0x01bf25b9, 0x7ffcf2f2, 0x01c99ebd, 0x7ffccdee, 0x01d43e99, 0x7ffca780, 0x01df0597, 0x7ffc7f9e, -0x01e9f401, 0x7ffc563d, 0x01f50a22, 0x7ffc2b51, 0x02004844, 0x7ffbfecf, 0x020baeb1, 0x7ffbd0ab, -0x02173db4, 0x7ffba0da, 0x0222f596, 0x7ffb6f4f, 0x022ed6a1, 0x7ffb3bfd, 0x023ae11f, 0x7ffb06d8, -0x02471558, 0x7ffacfd3, 0x02537397, 0x7ffa96e0, 0x025ffc25, 0x7ffa5bf2, 0x026caf4a, 0x7ffa1efc, -0x02798d4f, 0x7ff9dfee, 0x0286967c, 0x7ff99ebb, 0x0293cb1b, 0x7ff95b55, 0x02a12b72, 0x7ff915ab, -0x02aeb7cb, 0x7ff8cdaf, 0x02bc706d, 0x7ff88351, 0x02ca559f, 0x7ff83682, 0x02d867a9, 0x7ff7e731, -0x02e6a6d2, 0x7ff7954e, 0x02f51361, 0x7ff740c8, 0x0303ad9c, 0x7ff6e98e, 0x031275ca, 0x7ff68f8f, -0x03216c30, 0x7ff632ba, 0x03309116, 0x7ff5d2fb, 0x033fe4bf, 0x7ff57042, 0x034f6773, 0x7ff50a7a, -0x035f1975, 0x7ff4a192, 0x036efb0a, 0x7ff43576, 0x037f0c78, 0x7ff3c612, 0x038f4e02, 0x7ff35353, -0x039fbfeb, 0x7ff2dd24, 0x03b06279, 0x7ff26370, 0x03c135ed, 0x7ff1e623, 0x03d23a8b, 0x7ff16527, -0x03e37095, 0x7ff0e067, 0x03f4d84e, 0x7ff057cc, 0x040671f7, 0x7fefcb40, 0x04183dd3, 0x7fef3aad, -0x042a3c22, 0x7feea5fa, 0x043c6d25, 0x7fee0d11, 0x044ed11d, 0x7fed6fda, 0x04616849, 0x7fecce3d, -0x047432eb, 0x7fec2821, 0x04873140, 0x7feb7d6c, 0x049a6388, 0x7feace07, 0x04adca01, 0x7fea19d6, -0x04c164ea, 0x7fe960c0, 0x04d53481, 0x7fe8a2aa, 0x04e93902, 0x7fe7df79, 0x04fd72aa, 0x7fe71712, -0x0511e1b6, 0x7fe6495a, 0x05268663, 0x7fe57634, 0x053b60eb, 0x7fe49d83, 0x05507189, 0x7fe3bf2b, -0x0565b879, 0x7fe2db0f, 0x057b35f4, 0x7fe1f110, 0x0590ea35, 0x7fe10111, 0x05a6d574, 0x7fe00af3, -0x05bcf7ea, 0x7fdf0e97, 0x05d351cf, 0x7fde0bdd, 0x05e9e35c, 0x7fdd02a6, 0x0600acc8, 0x7fdbf2d2, -0x0617ae48, 0x7fdadc40, 0x062ee814, 0x7fd9becf, 0x06465a62, 0x7fd89a5e, 0x065e0565, 0x7fd76eca, -0x0675e954, 0x7fd63bf1, 0x068e0662, 0x7fd501b0, 0x06a65cc3, 0x7fd3bfe4, 0x06beecaa, 0x7fd2766a, -0x06d7b648, 0x7fd1251e, 0x06f0b9d1, 0x7fcfcbda, 0x0709f775, 0x7fce6a7a, 0x07236f65, 0x7fcd00d8, -0x073d21d2, 0x7fcb8ecf, 0x07570eea, 0x7fca1439, 0x077136dd, 0x7fc890ed, 0x078b99da, 0x7fc704c7, -0x07a6380d, 0x7fc56f9d, 0x07c111a4, 0x7fc3d147, 0x07dc26cc, 0x7fc2299e, 0x07f777b1, 0x7fc07878, -0x0813047d, 0x7fbebdac, 0x082ecd5b, 0x7fbcf90f, 0x084ad276, 0x7fbb2a78, 0x086713f7, 0x7fb951bc, -0x08839206, 0x7fb76eaf, 0x08a04ccb, 0x7fb58126, 0x08bd446e, 0x7fb388f4, 0x08da7915, 0x7fb185ee, -0x08f7eae7, 0x7faf77e5, 0x09159a09, 0x7fad5ead, 0x0933869f, 0x7fab3a17, 0x0951b0cd, 0x7fa909f6, -0x097018b7, 0x7fa6ce1a, 0x098ebe7f, 0x7fa48653, 0x09ada248, 0x7fa23273, 0x09ccc431, 0x7f9fd249, -0x09ec245b, 0x7f9d65a4, 0x0a0bc2e7, 0x7f9aec53, 0x0a2b9ff3, 0x7f986625, 0x0a4bbb9e, 0x7f95d2e7, -0x0a6c1604, 0x7f933267, 0x0a8caf43, 0x7f908472, 0x0aad8776, 0x7f8dc8d5, 0x0ace9eb9, 0x7f8aff5c, -0x0aeff526, 0x7f8827d3, 0x0b118ad8, 0x7f854204, 0x0b335fe6, 0x7f824dbb, 0x0b557469, 0x7f7f4ac3, -0x0b77c879, 0x7f7c38e4, 0x0b9a5c2b, 0x7f7917e9, 0x0bbd2f97, 0x7f75e79b, 0x0be042d0, 0x7f72a7c3, -0x0c0395ec, 0x7f6f5828, 0x0c2728fd, 0x7f6bf892, 0x0c4afc16, 0x7f6888c9, 0x0c6f0f4a, 0x7f650894, -0x0c9362a8, 0x7f6177b9, 0x0cb7f642, 0x7f5dd5ff, 0x0cdcca26, 0x7f5a232a, 0x0d01de63, 0x7f565f00, -0x0d273307, 0x7f528947, 0x0d4cc81f, 0x7f4ea1c2, 0x0d729db7, 0x7f4aa835, 0x0d98b3da, 0x7f469c65, -0x0dbf0a92, 0x7f427e13, 0x0de5a1e9, 0x7f3e4d04, 0x0e0c79e7, 0x7f3a08f9, 0x0e339295, 0x7f35b1b4, -0x0e5aebfa, 0x7f3146f8, 0x0e82861a, 0x7f2cc884, 0x0eaa60fd, 0x7f28361b, 0x0ed27ca5, 0x7f238f7c, -0x0efad917, 0x7f1ed467, 0x0f237656, 0x7f1a049d, 0x0f4c5462, 0x7f151fdc, 0x0f75733d, 0x7f1025e3, -0x0f9ed2e6, 0x7f0b1672, 0x0fc8735e, 0x7f05f146, 0x0ff254a1, 0x7f00b61d, 0x101c76ae, 0x7efb64b4, -0x1046d981, 0x7ef5fcca, 0x10717d15, 0x7ef07e19, 0x109c6165, 0x7eeae860, 0x10c7866a, 0x7ee53b5b, -0x10f2ec1e, 0x7edf76c4, 0x111e9279, 0x7ed99a58, 0x114a7971, 0x7ed3a5d1, 0x1176a0fc, 0x7ecd98eb, -0x11a30910, 0x7ec77360, 0x11cfb1a1, 0x7ec134eb, 0x11fc9aa2, 0x7ebadd44, 0x1229c406, 0x7eb46c27, -0x12572dbf, 0x7eade14c, 0x1284d7bc, 0x7ea73c6c, 0x12b2c1ed, 0x7ea07d41, 0x12e0ec42, 0x7e99a382, -0x130f56a8, 0x7e92aee7, 0x133e010b, 0x7e8b9f2a, 0x136ceb59, 0x7e847402, 0x139c157b, 0x7e7d2d25, -0x13cb7f5d, 0x7e75ca4c, 0x13fb28e6, 0x7e6e4b2d, 0x142b1200, 0x7e66af7f, 0x145b3a92, 0x7e5ef6f8, -0x148ba281, 0x7e572150, 0x14bc49b4, 0x7e4f2e3b, 0x14ed300f, 0x7e471d70, 0x151e5575, 0x7e3eeea5, -0x154fb9c9, 0x7e36a18e, 0x15815ced, 0x7e2e35e2, 0x15b33ec1, 0x7e25ab56, 0x15e55f25, 0x7e1d019e, -0x1617bdf9, 0x7e14386e, 0x164a5b19, 0x7e0b4f7d, 0x167d3662, 0x7e02467e, 0x16b04fb2, 0x7df91d25, -0x16e3a6e2, 0x7defd327, 0x17173bce, 0x7de66837, 0x174b0e4d, 0x7ddcdc0a, 0x177f1e39, 0x7dd32e53, -0x17b36b69, 0x7dc95ec6, 0x17e7f5b3, 0x7dbf6d17, 0x181cbcec, 0x7db558f9, 0x1851c0e9, 0x7dab221f, -0x1887017d, 0x7da0c83c, 0x18bc7e7c, 0x7d964b05, 0x18f237b6, 0x7d8baa2b, 0x19282cfd, 0x7d80e563, -0x195e5e20, 0x7d75fc5e, 0x1994caee, 0x7d6aeed0, 0x19cb7335, 0x7d5fbc6d, 0x1a0256c2, 0x7d5464e6, -0x1a397561, 0x7d48e7ef, 0x1a70cede, 0x7d3d453b, 0x1aa86301, 0x7d317c7c, 0x1ae03195, 0x7d258d65, -0x1b183a63, 0x7d1977aa, 0x1b507d30, 0x7d0d3afc, 0x1b88f9c5, 0x7d00d710, 0x1bc1afe6, 0x7cf44b97, -0x1bfa9f58, 0x7ce79846, 0x1c33c7e0, 0x7cdabcce, 0x1c6d293f, 0x7ccdb8e4, 0x1ca6c337, 0x7cc08c39, -0x1ce0958a, 0x7cb33682, 0x1d1a9ff8, 0x7ca5b772, 0x1d54e240, 0x7c980ebd, 0x1d8f5c21, 0x7c8a3c14, -0x1dca0d56, 0x7c7c3f2e, 0x1e04f59f, 0x7c6e17bc, 0x1e4014b4, 0x7c5fc573, 0x1e7b6a53, 0x7c514807, -0x1eb6f633, 0x7c429f2c, 0x1ef2b80f, 0x7c33ca96, 0x1f2eaf9e, 0x7c24c9fa, 0x1f6adc98, 0x7c159d0d, -0x1fa73eb2, 0x7c064383, 0x1fe3d5a3, 0x7bf6bd11, 0x2020a11e, 0x7be7096c, 0x205da0d8, 0x7bd7284a, -0x209ad483, 0x7bc71960, 0x20d83bd1, 0x7bb6dc65, 0x2115d674, 0x7ba6710d, 0x2153a41b, 0x7b95d710, -0x2191a476, 0x7b850e24, 0x21cfd734, 0x7b7415ff, 0x220e3c02, 0x7b62ee59, 0x224cd28d, 0x7b5196e9, -0x228b9a82, 0x7b400f67, 0x22ca938a, 0x7b2e578a, 0x2309bd52, 0x7b1c6f0b, 0x23491783, 0x7b0a55a1, -0x2388a1c4, 0x7af80b07, 0x23c85bbf, 0x7ae58ef5, 0x2408451a, 0x7ad2e124, 0x24485d7c, 0x7ac0014e, -0x2488a48a, 0x7aacef2e, 0x24c919e9, 0x7a99aa7e, 0x2509bd3d, 0x7a8632f8, 0x254a8e29, 0x7a728858, -0x258b8c50, 0x7a5eaa5a, 0x25ccb753, 0x7a4a98b9, 0x260e0ed3, 0x7a365333, 0x264f9271, 0x7a21d983, -0x269141cb, 0x7a0d2b68, 0x26d31c80, 0x79f8489e, 0x2715222f, 0x79e330e4, 0x27575273, 0x79cde3f8, -0x2799acea, 0x79b8619a, 0x27dc3130, 0x79a2a989, 0x281ededf, 0x798cbb85, 0x2861b591, 0x7976974e, -0x28a4b4e0, 0x79603ca5, 0x28e7dc65, 0x7949ab4c, 0x292b2bb8, 0x7932e304, 0x296ea270, 0x791be390, -0x29b24024, 0x7904acb3, 0x29f6046b, 0x78ed3e30, 0x2a39eed8, 0x78d597cc, 0x2a7dff02, 0x78bdb94a, -0x2ac2347c, 0x78a5a270, 0x2b068eda, 0x788d5304, 0x2b4b0dae, 0x7874cacb, 0x2b8fb08a, 0x785c098d, -0x2bd47700, 0x78430f11, 0x2c1960a1, 0x7829db1f, 0x2c5e6cfd, 0x78106d7f, 0x2ca39ba3, 0x77f6c5fb, -0x2ce8ec23, 0x77dce45c, 0x2d2e5e0b, 0x77c2c86e, 0x2d73f0e8, 0x77a871fa, 0x2db9a449, 0x778de0cd, -0x2dff77b8, 0x777314b2, 0x2e456ac4, 0x77580d78, 0x2e8b7cf6, 0x773ccaeb, 0x2ed1addb, 0x77214cdb, -0x2f17fcfb, 0x77059315, 0x2f5e69e2, 0x76e99d69, 0x2fa4f419, 0x76cd6ba9, 0x2feb9b27, 0x76b0fda4, -0x30325e96, 0x7694532e, 0x30793dee, 0x76776c17, 0x30c038b5, 0x765a4834, 0x31074e72, 0x763ce759, -0x314e7eab, 0x761f4959, 0x3195c8e6, 0x76016e0b, 0x31dd2ca9, 0x75e35545, 0x3224a979, 0x75c4fedc, -0x326c3ed8, 0x75a66aab, 0x32b3ec4d, 0x75879887, 0x32fbb159, 0x7568884b, 0x33438d81, 0x754939d1, -0x338b8045, 0x7529acf4, 0x33d3892a, 0x7509e18e, 0x341ba7b1, 0x74e9d77d, 0x3463db5a, 0x74c98e9e, -0x34ac23a7, 0x74a906cd, 0x34f48019, 0x74883fec, 0x353cf02f, 0x746739d8, 0x3585736a, 0x7445f472, -0x35ce0949, 0x74246f9c, 0x3616b14c, 0x7402ab37, 0x365f6af0, 0x73e0a727, 0x36a835b5, 0x73be6350, -0x36f11118, 0x739bdf95, 0x3739fc98, 0x73791bdd, 0x3782f7b2, 0x7356180e, 0x37cc01e3, 0x7332d410, -0x38151aa8, 0x730f4fc9, 0x385e417e, 0x72eb8b24, 0x38a775e1, 0x72c7860a, 0x38f0b74d, 0x72a34066, -0x393a053e, 0x727eba24, 0x39835f30, 0x7259f331, 0x39ccc49e, 0x7234eb79, 0x3a163503, 0x720fa2eb, -0x3a5fafda, 0x71ea1977, 0x3aa9349e, 0x71c44f0c, 0x3af2c2ca, 0x719e439d, 0x3b3c59d7, 0x7177f71a, -0x3b85f940, 0x71516978, 0x3bcfa07e, 0x712a9aaa, 0x3c194f0d, 0x71038aa4, 0x3c630464, 0x70dc395e, -0x3cacbfff, 0x70b4a6cd, 0x3cf68155, 0x708cd2e9, 0x3d4047e1, 0x7064bdab, 0x3d8a131c, 0x703c670d, -0x3dd3e27e, 0x7013cf0a, 0x3e1db580, 0x6feaf59c, 0x3e678b9b, 0x6fc1dac1, 0x3eb16449, 0x6f987e76, -0x3efb3f01, 0x6f6ee0b9, 0x3f451b3d, 0x6f45018b, 0x3f8ef874, 0x6f1ae0eb, 0x3fd8d620, 0x6ef07edb, -0x4022b3b9, 0x6ec5db5d, 0x406c90b7, 0x6e9af675, 0x40b66c93, 0x6e6fd027, 0x410046c5, 0x6e446879, -0x414a1ec6, 0x6e18bf71, 0x4193f40d, 0x6decd517, 0x41ddc615, 0x6dc0a972, 0x42279455, 0x6d943c8d, -0x42715e45, 0x6d678e71, 0x42bb235f, 0x6d3a9f2a, 0x4304e31a, 0x6d0d6ec5, 0x434e9cf1, 0x6cdffd4f, -0x4398505b, 0x6cb24ad6, 0x43e1fcd1, 0x6c84576b, 0x442ba1cd, 0x6c56231c, 0x44753ec7, 0x6c27adfd, -0x44bed33a, 0x6bf8f81e, 0x45085e9d, 0x6bca0195, 0x4551e06b, 0x6b9aca75, 0x459b581e, 0x6b6b52d5, -0x45e4c52f, 0x6b3b9ac9, 0x462e2717, 0x6b0ba26b, 0x46777d52, 0x6adb69d3, 0x46c0c75a, 0x6aaaf11b, -0x470a04a9, 0x6a7a385c, 0x475334b9, 0x6a493fb3, 0x479c5707, 0x6a18073d, 0x47e56b0c, 0x69e68f17, -0x482e7045, 0x69b4d761, 0x4877662c, 0x6982e039, 0x48c04c3f, 0x6950a9c0, 0x490921f8, 0x691e341a, -0x4951e6d5, 0x68eb7f67, 0x499a9a51, 0x68b88bcd, 0x49e33beb, 0x68855970, 0x4a2bcb1f, 0x6851e875, -0x4a74476b, 0x681e3905, 0x4abcb04c, 0x67ea4b47, 0x4b050541, 0x67b61f63, 0x4b4d45c9, 0x6781b585, -0x4b957162, 0x674d0dd6, 0x4bdd878c, 0x67182883, 0x4c2587c6, 0x66e305b8, 0x4c6d7190, 0x66ada5a5, -0x4cb5446a, 0x66780878, 0x4cfcffd5, 0x66422e60, 0x4d44a353, 0x660c1790, 0x4d8c2e64, 0x65d5c439, -0x4dd3a08c, 0x659f348e, 0x4e1af94b, 0x656868c3, 0x4e623825, 0x6531610d, 0x4ea95c9d, 0x64fa1da3, -0x4ef06637, 0x64c29ebb, 0x4f375477, 0x648ae48d, 0x4f7e26e1, 0x6452ef53, 0x4fc4dcfb, 0x641abf46, -0x500b7649, 0x63e254a2, 0x5051f253, 0x63a9afa2, 0x5098509f, 0x6370d083, 0x50de90b3, 0x6337b784, -0x5124b218, 0x62fe64e3, 0x516ab455, 0x62c4d8e0, 0x51b096f3, 0x628b13bc, 0x51f6597b, 0x625115b8, -0x523bfb78, 0x6216df18, 0x52817c72, 0x61dc701f, 0x52c6dbf5, 0x61a1c912, 0x530c198d, 0x6166ea36, -0x535134c5, 0x612bd3d2, 0x53962d2a, 0x60f0862d, 0x53db024a, 0x60b50190, 0x541fb3b1, 0x60794644, -0x546440ef, 0x603d5494, 0x54a8a992, 0x60012cca, 0x54eced2b, 0x5fc4cf33, 0x55310b48, 0x5f883c1c, -0x5575037c, 0x5f4b73d2, 0x55b8d558, 0x5f0e76a5, 0x55fc806f, 0x5ed144e5, 0x56400452, 0x5e93dee1, -0x56836096, 0x5e5644ec, 0x56c694cf, 0x5e187757, 0x5709a092, 0x5dda7677, 0x574c8374, 0x5d9c429f, -0x578f3d0d, 0x5d5ddc24, 0x57d1ccf2, 0x5d1f435d, 0x581432bd, 0x5ce078a0, 0x58566e04, 0x5ca17c45, -0x58987e63, 0x5c624ea4, 0x58da6372, 0x5c22f016, 0x591c1ccc, 0x5be360f6, 0x595daa0d, 0x5ba3a19f, -0x599f0ad1, 0x5b63b26c, 0x59e03eb6, 0x5b2393ba, 0x5a214558, 0x5ae345e7, 0x5a621e56, 0x5aa2c951, -}; - - - -/* bit reverse tables for FFT */ - -const int bitrevtabOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 17}; - -const unsigned char bitrevtab[17 + 129] PROGMEM = { -/* nfft = 64 */ -0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f, -0x00, - -/* nfft = 512 */ -0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48, -0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24, -0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c, -0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a, -0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76, -0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69, -0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b, -0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f, -0x00, - -}; - -const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f}; - -/* Twiddle tables for FFT - * format = Q30 - * - * for (k = 4; k <= N/4; k <<= 1) { - * for (j = 0; j < k; j++) { - * double wr1, wi1, wr2, wi2, wr3, wi3; - * - * wr1 = cos(1.0 * M_PI * j / (2*k)); - * wi1 = sin(1.0 * M_PI * j / (2*k)); - * wr1 = (wr1 + wi1); - * wi1 = -wi1; - * - * wr2 = cos(2.0 * M_PI * j / (2*k)); - * wi2 = sin(2.0 * M_PI * j / (2*k)); - * wr2 = (wr2 + wi2); - * wi2 = -wi2; - * - * wr3 = cos(3.0 * M_PI * j / (2*k)); - * wi3 = sin(3.0 * M_PI * j / (2*k)); - * wr3 = (wr3 + wi3); - * wi3 = -wi3; - * - * if (k & 0xaaaaaaaa) { - * w_odd[iodd++] = (float)wr2; - * w_odd[iodd++] = (float)wi2; - * w_odd[iodd++] = (float)wr1; - * w_odd[iodd++] = (float)wi1; - * w_odd[iodd++] = (float)wr3; - * w_odd[iodd++] = (float)wi3; - * } else { - * w_even[ieven++] = (float)wr2; - * w_even[ieven++] = (float)wi2; - * w_even[ieven++] = (float)wr1; - * w_even[ieven++] = (float)wi1; - * w_even[ieven++] = (float)wr3; - * w_even[ieven++] = (float)wi3; - * } - * } - * } - */ -const int twidTabOdd[8*6 + 32*6 + 128*6] PROGMEM = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59, - 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, - 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862, - 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, - 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651, - 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, - 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8, - 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, - 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a, - 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, - 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52, - 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, - 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8, - 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, - 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d, - 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, - 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6, - 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, - 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1, - 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, - 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1, - 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1, - 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e, - 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a, - 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, - 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2, - 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb, - 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a, - 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c, - 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c, - 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, - 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc, - 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb, - 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9, - 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24, - 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, - 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639, - 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566, - 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c, - 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4, - 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88, - 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, - 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90, - 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc, - 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e, - 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d, - 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, - 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d, - 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50, - 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24, - 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3, - 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be, - 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, - 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892, - 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566, - 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9, - 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31, - 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, - 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18, - 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b, - 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88, - 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca, - 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6, - 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, - 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f, - 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90, - 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59, - 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e, - 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, - 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1, - 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7, - 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d, - 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf, - 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27, - 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, - 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d, - 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50, - 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd, - 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7, - 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, - 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf, - 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf, - 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be, - 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013, - 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8, - 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, - 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156, - 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892, - 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953, - 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae, - 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, - 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162, - 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958, - 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31, - 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa, - 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167, - 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, - 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf, - 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b, - 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669, - 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d, - 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, - 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496, - 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de, - 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6, - 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347, - 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db, - 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, - 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0, -}; - -const int twidTabEven[4*6 + 16*6 + 64*6] PROGMEM = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333, - 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, - 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2, - 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, - 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae, - 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, - 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060, - 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, - 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d, - 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, - 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342, - 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, - 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb, - 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342, - 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, - 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6, - 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, - 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90, - 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006, - 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, - 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb, - 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, - 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b, - 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976, - 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, - 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6, - 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, - 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d, - 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502, - 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, - 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39, - 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, - 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958, - 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209, - 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, - 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18, - 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, - 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f, - 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70, - 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, - 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97, - 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, - 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a, - 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce, - 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, - 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a, - 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, - 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e, - 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9, - 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, - 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a, -}; - -/* for reference, here's the code to generate the bitreverse tables - short blocks: nbits = 4 (nfft = 64) - long blocks: nbits = 7 (nfft = 512) - -static int bitrev(int n, int nbits) -{ - int r, i; - - r = 0; - for (i = 0; i < nbits; i++) { - r <<= 1; - r |= (n & 1); - n >>= 1; - } - - return r; -} - -static void InitBitrevTable(unsigned char *out, int nbits) -{ - int i, t; - - for (i = 0; i < (1< KBD_THRESH); - - return i0; -} - -static double CalcW(double nRef, double n, double a) -{ - double i0Base, i0Curr, nTemp; - - i0Base = CalcI0(M_PI * a); - - nTemp = (n - nRef/4) / (nRef/4); - i0Curr = CalcI0( M_PI * a * sqrt(1.0 - nTemp*nTemp) ); - - return i0Curr / i0Base; -} - -void InitKBDWindow(int nmdct) -{ - int n, nRef; - double a, wBase, wCurr; - - nRef = nmdct * 2; - - / *** kbd window *** / - if (nmdct == 128) - a = 6.0; - else - a = 4.0; - - wBase = 0; - for (n = 0; n <= nRef/2; n++) - wBase += CalcW(nRef, n, a); - - / *** left *** / - wCurr = 0; - for (n = 0; n < nRef/2; n++) { - wCurr += CalcW(nRef, n, a); - kbdWindowRef[n] = sqrt(wCurr / wBase); - } - - / *** - * symmetry: - * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1] - * - * wCurr = 0; - * for (n = N_REF-1; n >= N_REF/2; n--) { - * wCurr += CalcW(N_REF-n-1, a); - * kbdWindowRef[n] = sqrt(wCurr / wBase); - * } - * - *** / - return; -} -*/ -#pragma GCC diagnostic pop diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/LICENSE.txt b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/LICENSE.txt deleted file mode 100644 index 12e5372a..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/LICENSE.txt +++ /dev/null @@ -1,30 +0,0 @@ - Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. - - The contents of this directory, and (except where otherwise - indicated) the directories included within this directory, are - subject to the current version of the RealNetworks Public Source - License (the "RPSL") available at RPSL.txt in this directory, unless - you have licensed the directory under the current version of the - RealNetworks Community Source License (the "RCSL") available at - RCSL.txt in this directory, in which case the RCSL will apply. You - may also obtain the license terms directly from RealNetworks. You - may not use the files in this directory except in compliance with the - RPSL or, if you have a valid RCSL with RealNetworks applicable to - this directory, the RCSL. Please see the applicable RPSL or RCSL for - the rights, obligations and limitations governing use of the contents - of the directory. - - This directory is part of the Helix DNA Technology. RealNetworks is - the developer of the Original Code and owns the copyrights in the - portions it created. - - This directory, and the directories included with this directory, are - distributed and made available on an 'AS IS' basis, WITHOUT WARRANTY - OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY - DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY - WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, - QUIET ENJOYMENT OR NON-INFRINGEMENT. - - Technology Compatibility Kit Test Suite(s) Location: - http://www.helixcommunity.org/content/tck - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RCSL.txt b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RCSL.txt deleted file mode 100644 index a809759a..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RCSL.txt +++ /dev/null @@ -1,948 +0,0 @@ -The RCSL is made up of a base agreement and a few Attachments. - -For Research and Development use, you agree to the terms of the -RCSL R&D License (base RCSL and Attachments A, B, and C) - -For Commercial Use (either distribution or internal commercial -deployment) of the Helix DNA with or without support for RealNetworks' -RealAudio and RealVideo Add-on Technology, you agree to the -terms of the same RCSL R&D license -and execute one or more additional Commercial Use License attachments -. - ------------------------------------------------------------------------- - - - REALNETWORKS COMMUNITY SOURCE LICENSE - -Version 1.2 (Rev. Date: January 22, 2003). - - - RECITALS - -Original Contributor has developed Specifications, Source Code -implementations and Executables of certain Technology; and - -Original Contributor desires to license the Technology to a large -community to facilitate research, innovation and product development -while maintaining compatibility of such products with the Technology as -delivered by Original Contributor; and - -Original Contributor desires to license certain Trademarks for the -purpose of branding products that are compatible with the relevant -Technology delivered by Original Contributor; and - -You desire to license the Technology and possibly certain Trademarks -from Original Contributor on the terms and conditions specified in this -License. - -In consideration for the mutual covenants contained herein, You and -Original Contributor agree as follows: - - - AGREEMENT - -*1. Introduction.* - -The RealNetworks Community Source License ("RCSL") and effective -attachments ("License") may include five distinct licenses: - -i) Research Use license -- License plus Attachments A, B and C only. - -ii) Commercial Use and Trademark License, which may be for Internal -Deployment Use or external distribution, or both -- License plus -Attachments A, B, C, and D. - -iii) Technology Compatibility Kit (TCK) license -- Attachment C. - -iv) Add-On Technology License (Executable) Commercial Use License --Attachment F. - -v) Add-On Technology Source Code Porting and Optimization -License-Attachment G. - -The Research Use license is effective when You click and accept this -License. The TCK is effective when You click and accept this License, -unless otherwise specified in the TCK attachments. The Commercial Use -and Trademark, Add-On Technology License, and the Add-On Technology -Source Code Porting and Optimization licenses must each be signed by You -and Original Contributor to become effective. Once effective, these -licenses and the associated requirements and responsibilities are -cumulative. Capitalized terms used in this License are defined in the -Glossary. - -*2. License Grants.* - -2.1 Original Contributor Grant. - -Subject to Your compliance with Sections 3, 8.10 and Attachment A of -this License, Original Contributor grants to You a worldwide, -royalty-free, non-exclusive license, to the extent of Original -Contributor's Intellectual Property Rights covering the Original Code, -Upgraded Code and Specifications, to do the following: - -(a) Research Use License: - -(i) use, reproduce and modify the Original Code, Upgraded Code and -Specifications to create Modifications and Reformatted Specifications -for Research Use by You; - -(ii) publish and display Original Code, Upgraded Code and Specifications -with, or as part of Modifications, as permitted under Section 3.1(b) below; - -(iii) reproduce and distribute copies of Original Code and Upgraded Code -to Licensees and students for Research Use by You; - -(iv) compile, reproduce and distribute Original Code and Upgraded Code -in Executable form, and Reformatted Specifications to anyone for -Research Use by You. - -(b) Other than the licenses expressly granted in this License, Original -Contributor retains all right, title, and interest in Original Code and -Upgraded Code and Specifications. - -2.2 Your Grants. - -(a) To Other Licensees. You hereby grant to each Licensee a license to -Your Error Corrections and Shared Modifications, of the same scope and -extent as Original Contributor's licenses under Section 2.1 a) above -relative to Research Use and Attachment D relative to Commercial Use. - -(b) To Original Contributor. You hereby grant to Original Contributor a -worldwide, royalty-free, non-exclusive, perpetual and irrevocable -license, to the extent of Your Intellectual Property Rights covering -Your Error Corrections, Shared Modifications and Reformatted -Specifications, to use, reproduce, modify, display and distribute Your -Error Corrections, Shared Modifications and Reformatted Specifications, -in any form, including the right to sublicense such rights through -multiple tiers of distribution. - -(c) Other than the licenses expressly granted in Sections 2.2(a) and (b) -above, and the restrictions set forth in Section 3.1(d)(iv) below, You -retain all right, title, and interest in Your Error Corrections, Shared -Modifications and Reformatted Specifications. - -2.3 Contributor Modifications. - -You may use, reproduce, modify, display and distribute Contributor Error -Corrections, Shared Modifications and Reformatted Specifications, -obtained by You under this License, to the same scope and extent as with -Original Code, Upgraded Code and Specifications. - -2.4 Subcontracting. - -You may deliver the Source Code of Covered Code to other Licensees -having at least a Research Use license, for the sole purpose of -furnishing development services to You in connection with Your rights -granted in this License. All such Licensees must execute appropriate -documents with respect to such work consistent with the terms of this -License, and acknowledging their work-made-for-hire status or assigning -exclusive right to the work product and associated Intellectual Property -Rights to You. - -*3. Requirements and Responsibilities*. - -3.1 Research Use License. - -As a condition of exercising the rights granted under Section 2.1(a) -above, You agree to comply with the following: - -(a) Your Contribution to the Community. All Error Corrections and Shared -Modifications which You create or contribute to are automatically -subject to the licenses granted under Section 2.2 above. You are -encouraged to license all of Your other Modifications under Section 2.2 -as Shared Modifications, but are not required to do so. You agree to -notify Original Contributor of any errors in the Specification. - -(b) Source Code Availability. You agree to provide all Your Error -Corrections to Original Contributor as soon as reasonably practicable -and, in any event, prior to Internal Deployment Use or Commercial Use, -if applicable. Original Contributor may, at its discretion, post Source -Code for Your Error Corrections and Shared Modifications on the -Community Webserver. You may also post Error Corrections and Shared -Modifications on a web-server of Your choice; provided, that You must -take reasonable precautions to ensure that only Licensees have access to -such Error Corrections and Shared Modifications. Such precautions shall -include, without limitation, a password protection scheme limited to -Licensees and a click-on, download certification of Licensee status -required of those attempting to download from the server. An example of -an acceptable certification is attached as Attachment A-2. - -(c) Notices. All Error Corrections and Shared Modifications You create -or contribute to must include a file documenting the additions and -changes You made and the date of such additions and changes. You must -also include the notice set forth in Attachment A-1 in the file header. -If it is not possible to put the notice in a particular Source Code file -due to its structure, then You must include the notice in a location -(such as a relevant directory file), where a recipient would be most -likely to look for such a notice. - -(d) Redistribution. - -(i) Source. Covered Code may be distributed in Source Code form only to -another Licensee (except for students as provided below). You may not -offer or impose any terms on any Covered Code that alter the rights, -requirements, or responsibilities of such Licensee. You may distribute -Covered Code to students for use in connection with their course work -and research projects undertaken at accredited educational institutions. -Such students need not be Licensees, but must be given a copy of the -notice set forth in Attachment A-3 and such notice must also be included -in a file header or prominent location in the Source Code made available -to such students. - -(ii) Executable. You may distribute Executable version(s) of Covered -Code to Licensees and other third parties only for the purpose of -evaluation and comment in connection with Research Use by You and under -a license of Your choice, but which limits use of such Executable -version(s) of Covered Code only to that purpose. - -(iii) Modified Class, Interface and Package Naming. In connection with -Research Use by You only, You may use Original Contributor's class, -Interface and package names only to accurately reference or invoke the -Source Code files You modify. Original Contributor grants to You a -limited license to the extent necessary for such purposes. - -(iv) You expressly agree that any distribution, in whole or in part, of -Modifications developed by You shall only be done pursuant to the terms -and conditions of this License. - -(e) Extensions. - -(i) Covered Code. You may not include any Source Code of Community Code -in any Extensions. You may include the compiled Header Files of -Community Code in an Extension provided that Your use of the Covered -Code, including Heading Files, complies with the Commercial Use License, -the TCK and all other terms of this License. - -(ii) Publication. No later than the date on which You first distribute -such Extension for Commercial Use, You must publish to the industry, on -a non-confidential basis and free of all copyright restrictions with -respect to reproduction and use, an accurate and current specification -for any Extension. In addition, You must make available an appropriate -test suite, pursuant to the same rights as the specification, -sufficiently detailed to allow any third party reasonably skilled in the -technology to produce implementations of the Extension compatible with -the specification. Such test suites must be made available as soon as -reasonably practicable but, in no event, later than ninety (90) days -after Your first Commercial Use of the Extension. You must use -reasonable efforts to promptly clarify and correct the specification and -the test suite upon written request by Original Contributor. - -(iii) Open. You agree to refrain from enforcing any Intellectual -Property Rights You may have covering any interface(s) of Your -Extension, which would prevent the implementation of such interface(s) -by Original Contributor or any Licensee. This obligation does not -prevent You from enforcing any Intellectual Property Right You have that -would otherwise be infringed by an implementation of Your Extension. - -(iv) Interface Modifications and Naming. You may not modify or add to -the GUID space * * "xxxxxxxx-0901-11d1-8B06-00A024406D59" or any other -GUID space designated by Original Contributor. You may not modify any -Interface prefix provided with the Covered Code or any other prefix -designated by Original Contributor.* * - -* * - -(f) You agree that any Specifications provided to You by Original -Contributor are confidential and proprietary information of Original -Contributor. You must maintain the confidentiality of the Specifications -and may not disclose them to any third party without Original -Contributor's prior written consent. You may only use the Specifications -under the terms of this License and only for the purpose of implementing -the terms of this License with respect to Covered Code. You agree not -use, copy or distribute any such Specifications except as provided in -writing by Original Contributor. - -3.2 Commercial Use License. - -You may not make Commercial Use of any Covered Code unless You and -Original Contributor have executed a copy of the Commercial Use and -Trademark License attached as Attachment D. - -*4. Versions of the License.* - -4.1 License Versions. - -Original Contributor may publish revised versions of the License from -time to time. Each version will be given a distinguishing version number. - -4.2 Effect. - -Once a particular version of Covered Code has been provided under a -version of the License, You may always continue to use such Covered Code -under the terms of that version of the License. You may also choose to -use such Covered Code under the terms of any subsequent version of the -License. No one other than Original Contributor has the right to -promulgate License versions. - -4.3 Multiple-Licensed Code. - -Original Contributor may designate portions of the Covered Code as -"Multiple-Licensed." "Multiple-Licensed" means that the Original -Contributor permits You to utilize those designated portions of the -Covered Code under Your choice of this License or the alternative -license(s), if any, specified by the Original Contributor in an -Attachment to this License. - -*5. Disclaimer of Warranty.* - -5.1 COVERED CODE PROVIDED AS IS. - -COVERED CODE IS PROVIDED UNDER THIS LICENSE "AS IS," WITHOUT WARRANTY OF -ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, -WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT -FOR A PARTICULAR PURPOSE OR NON-INFRINGING. YOU AGREE TO BEAR THE ENTIRE -RISK IN CONNECTION WITH YOUR USE AND DISTRIBUTION OF COVERED CODE UNDER -THIS LICENSE. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART -OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER -EXCEPT SUBJECT TO THIS DISCLAIMER. - -5.2 Not Designed for High Risk Activities. - -You acknowledge that Original Code, Upgraded Code and Specifications are -not designed or intended for use in high risk activities including, but -not limited to: (i) on-line control of aircraft, air traffic, aircraft -navigation or aircraft communications; or (ii) in the design, -construction, operation or maintenance of any nuclear facility. Original -Contributor disclaims any express or implied warranty of fitness for -such uses. - -*6. Termination.* - -6.1 By You. - -You may terminate this Research Use license at anytime by providing -written notice to Original Contributor. - -6.2 By Original Contributor. - -This License and the rights granted hereunder will terminate: - -(i) automatically if You fail to comply with the terms of this License -and fail to cure such breach within 30 days of receipt of written notice -of the breach; - -(ii) immediately in the event of circumstances specified in Sections 7.1 -and 8.4; or - -(iii) at Original Contributor's discretion upon any action initiated by -You (including by cross-claim or counter claim) alleging that use or -distribution by Original Contributor or any Licensee, of Original Code, -Upgraded Code, Error Corrections, Shared Modifications or Specifications -infringe a patent owned or controlled by You. - -6.3 Effective of Termination. - -Upon termination, You agree to discontinue use of and destroy all copies -of Covered Code in Your possession. All sublicenses to the Covered Code -which You have properly granted shall survive any termination of this -License. Provisions that, by their nature, should remain in effect -beyond the termination of this License shall survive including, without -limitation, Sections 2.2, 3, 5, 7 and 8. - -6.4 No Compensation. - -Each party waives and releases the other from any claim to compensation -or indemnity for permitted or lawful termination of the business -relationship established by this License. - -*7. Liability.* - -7.1 Infringement. Should any of the Original Code, Upgraded Code, TCK or -Specifications ("Materials") become the subject of a claim of -infringement, Original Contributor may, at its sole option, (i) attempt -to procure the rights necessary for You to continue using the Materials, -(ii) modify the Materials so that they are no longer infringing, or -(iii) terminate Your right to use the Materials, immediately upon -written notice, and refund to You the amount, if any, having then -actually been paid by You to Original Contributor for the Original Code, -Upgraded Code and TCK, depreciated on a straight line, five year basis. - -7.2 LIMITATION OF LIABILITY. TO THE FULL EXTENT ALLOWED BY APPLICABLE -LAW, ORIGINAL CONTRIBUTOR'S LIABILITY TO YOU FOR CLAIMS RELATING TO THIS -LICENSE, WHETHER FOR BREACH OR IN TORT, SHALL BE LIMITED TO ONE HUNDRED -PERCENT (100%) OF THE AMOUNT HAVING THEN ACTUALLY BEEN PAID BY YOU TO -ORIGINAL CONTRIBUTOR FOR ALL COPIES LICENSED HEREUNDER OF THE PARTICULAR -ITEMS GIVING RISE TO SUCH CLAIM, IF ANY, DURING THE TWELVE MONTHS -PRECEDING THE CLAIMED BREACH. IN NO EVENT WILL YOU (RELATIVE TO YOUR -SHARED MODIFICATIONS OR ERROR CORRECTIONS) OR ORIGINAL CONTRIBUTOR BE -LIABLE FOR ANY INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL OR CONSEQUENTIAL -DAMAGES IN CONNECTION WITH OR RISING OUT OF THIS LICENSE (INCLUDING, -WITHOUT LIMITATION, LOSS OF PROFITS, USE, DATA, OR OTHER ECONOMIC -ADVANTAGE), HOWEVER IT ARISES AND ON ANY THEORY OF LIABILITY, WHETHER IN -AN ACTION FOR CONTRACT, STRICT LIABILITY OR TORT (INCLUDING NEGLIGENCE) -OR OTHERWISE, WHETHER OR NOT YOU OR ORIGINAL CONTRIBUTOR HAS BEEN -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE AND NOTWITHSTANDING THE -FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. - -*8. Miscellaneous.* - -8.1 Trademark. - -You shall not use any Trademark unless You and Original Contributor -execute a copy of the Commercial Use and Trademark License Agreement -attached hereto as Attachment D. Except as expressly provided in the -License, You are granted no right, title or license to, or interest in, -any Trademarks. Whether or not You and Original Contributor enter into -the Trademark License, You agree not to (i) challenge Original -Contributor's ownership or use of Trademarks; (ii) attempt to register -any Trademarks, or any mark or logo substantially similar thereto; or -(iii) incorporate any Trademarks into Your own trademarks, product -names, service marks, company names, or domain names. - -8.2 Integration. - -This License represents the complete agreement concerning the subject -matter hereof. - -8.3 Assignment. - -Original Contributor may assign this License, and its rights and -obligations hereunder, in its sole discretion. You may assign the -Research Use portions of this License and the TCK license to a third -party upon prior written notice to Original Contributor (which may be -provided electronically via the Community Web-Server). You may not -assign the Commercial Use and Trademark license, the Add-On Technology -License, or the Add-On Technology Source Code Porting License, including -by way of merger (regardless of whether You are the surviving entity) or -acquisition, without Original Contributor's prior written consent. - -8.4 Severability. - -If any provision of this License is held to be unenforceable, such -provision shall be reformed only to the extent necessary to make it -enforceable. Notwithstanding the foregoing, if You are prohibited by law -from fully and specifically complying with Sections 2.2 or 3, this -License will immediately terminate and You must immediately discontinue -any use of Covered Code. - -8.5 Governing Law. - -This License shall be governed by the laws of the United States and the -State of Washington, as applied to contracts entered into and to be -performed in Washington between Washington residents. The application of -the United Nations Convention on Contracts for the International Sale of -Goods is expressly excluded. You agree that the state and federal courts -located in Seattle, Washington have exclusive jurisdiction over any -claim relating to the License, including contract and tort claims. - -8.6 Dispute Resolution. - -a) Arbitration. Any dispute arising out of or relating to this License -shall be finally settled by arbitration as set out herein, except that -either party may bring any action, in a court of competent jurisdiction -(which jurisdiction shall be exclusive), with respect to any dispute -relating to such party's Intellectual Property Rights or with respect to -Your compliance with the TCK license. Arbitration shall be administered: -(i) by the American Arbitration Association (AAA), (ii) in accordance -with the rules of the United Nations Commission on International Trade -Law (UNCITRAL) (the "Rules") in effect at the time of arbitration as -modified herein; and (iii) the arbitrator will apply the substantive -laws of Washington and the United States. Judgment upon the award -rendered by the arbitrator may be entered in any court having -jurisdiction to enforce such award. - -b) Arbitration language, venue and damages. All arbitration proceedings -shall be conducted in English by a single arbitrator selected in -accordance with the Rules, who must be fluent in English and be either a -retired judge or practicing attorney having at least ten (10) years -litigation experience and be reasonably familiar with the technology -matters relative to the dispute. Unless otherwise agreed, arbitration -venue shall be in Seattle, Washington. The arbitrator may award monetary -damages only and nothing shall preclude either party from seeking -provisional or emergency relief from a court of competent jurisdiction. -The arbitrator shall have no authority to award damages in excess of -those permitted in this License and any such award in excess is void. -All awards will be payable in U.S. dollars and may include, for the -prevailing party (i) pre-judgment award interest, (ii) reasonable -attorneys' fees incurred in connection with the arbitration, and (iii) -reasonable costs and expenses incurred in enforcing the award. The -arbitrator will order each party to produce identified documents and -respond to no more than twenty-five single question interrogatories. - -8.7 Construction. - -Any law or regulation, which provides that the language of a contract -shall be construed against the drafter, shall not apply to this License. - -8.8 U.S. Government End Users. - -The Covered Code is a "commercial item," as that term is defined in 48 -C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" -and "commercial computer software documentation," as such terms are used -in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and -48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government -End Users acquire Covered Code with only those rights set forth herein. -You agree to pass this notice to our licensees. - -8.9 Marketing Activities. - -Licensee hereby grants Original Contributor a non-exclusive, -non-transferable, limited license to use the Licensee's company name and -logo ("Licensee Marks") in any presentations, press releases, or -marketing materials solely for the purpose of identifying Licensee as a -member of the Helix Community. Licensee shall provide samples of -Licensee Marks to Original Contributor upon request by Original -Contributor. Original Contributor acknowledges that the Licensee Marks -are the trademarks of Licensee. Original Contributor shall not use the -Licensee Marks in a way that may imply that Original Contributor is an -agency or branch of Licensee. Original Contributor understands and -agrees that the use of any Licensee Marks in connection with this -Agreement shall not create any right, title or interest, in, or to the -Licensee Marks or any Licensee trademarks and that all such use and -goodwill associated with any such trademarks will inure to the benefit -of Licensee. Further the Original Contributor will stop usage of the -Licensee Marks upon Licensee's request. - -8.10 Press Announcements. - -You may make press announcements or other public statements regarding -this License without the prior written consent of the Original -Contributor, if Your statement is limited to announcing the licensing of -the Covered Code or the availability of Your Product and its -compatibility with the Covered Code. All other public announcements -regarding this license require the prior written consent of the Original -Contributor. Consent requests are welcome at press@helixcommunity.org. - -8.11 International Use. - -a) Export/Import laws. Covered Code is subject to U.S. export control -laws and may be subject to export or import regulations in other -countries. Each party agrees to comply strictly with all such laws and -regulations and acknowledges their responsibility to obtain such -licenses to export, re-export, or import as may be required. You agree -to pass these obligations to Your licensees. - -b) Intellectual Property Protection. Due to limited intellectual -property protection and enforcement in certain countries, You agree not -to redistribute the Original Code, Upgraded Code, TCK and Specifications -to any country on the list of restricted countries on the Community Web -Server. - -8.12 Language. - -This License is in the English language only, which language shall be -controlling in all respects, and all versions of this License in any -other language shall be for accommodation only and shall not be binding -on the parties to this License. All communications and notices made or -given pursuant to this License, and all documentation and support to be -provided, unless otherwise noted, shall be in the English language. - -PLEASE READ THE TERMS OF THIS LICENSE CAREFULLY. BY CLICKING ON THE -"ACCEPT" BUTTON BELOW YOU ARE ACCEPTING AND AGREEING TO THE TERMS AND -CONDITIONS OF THIS LICENSE WITH REALNETWORKS, INC. IF YOU ARE AGREEING -TO THIS LICENSE ON BEHALF OF A COMPANY, YOU REPRESENT THAT YOU ARE -AUTHORIZED TO BIND THE COMPANY TO SUCH A LICENSE. WHETHER YOU ARE ACTING -ON YOUR OWN BEHALF, OR REPRESENTING A COMPANY, YOU MUST BE OF MAJORITY -AGE AND BE OTHERWISE COMPETENT TO ENTER INTO CONTRACTS. IF YOU DO NOT -MEET THIS CRITERIA OR YOU DO NOT AGREE TO ANY OF THE TERMS AND -CONDITIONS OF THIS LICENSE, CLICK ON THE REJECT BUTTON TO EXIT. - - - GLOSSARY - -1. *"Added Value"* means code which: - -(i) has a principal purpose which is substantially different from that -of the stand-alone Technology; - -(ii) represents a significant functional and value enhancement to the -Technology; - -(iii) operates in conjunction with the Technology; and - -(iv) is not marketed as a technology which replaces or substitutes for -the Technology - -2. "*Applicable Patent Rights*" mean: (a) in the case where Original -Contributor is the grantor of rights, claims of patents that (i) are now -or hereafter acquired, owned by or assigned to Original Contributor and -(ii) are necessarily infringed by using or making the Original Code or -Upgraded Code, including Modifications provided by Original Contributor, -alone and not in combination with other software or hardware; and (b) in -the case where Licensee is the grantor of rights, claims of patents that -(i) are now or hereafter acquired, owned by or assigned to Licensee and -(ii) are infringed (directly or indirectly) by using or making -Licensee's Modifications or Error Corrections, taken alone or in -combination with Covered Code. - -3. "*Application Programming Interfaces (APIs)"* means the interfaces, -associated header files, service provider interfaces, and protocols that -enable a device, application, Operating System, or other program to -obtain services from or make requests of (or provide services in -response to requests from) other programs, and to use, benefit from, or -rely on the resources, facilities, and capabilities of the relevant -programs using the APIs. APIs includes the technical documentation -describing the APIs, the Source Code constituting the API, and any -Header Files used with the APIs. - -4. "*Commercial Use*" means any use (internal or external), copying, -sublicensing or distribution (internal or external), directly or -indirectly of Covered Code by You other than Your Research Use of -Covered Code within Your business or organization or in conjunction with -other Licensees with equivalent Research Use rights. Commercial Use -includes any use of the Covered Code for direct or indirect commercial -or strategic gain, advantage or other business purpose. Any Commercial -Use requires execution of Attachment D by You and Original Contributor. - -5. "*Community Code*" means the Original Code, Upgraded Code, Error -Corrections, Shared Modifications, or any combination thereof. - -6. "*Community Webserver(s)"* means the webservers designated by -Original Contributor for access to the Original Code, Upgraded Code, TCK -and Specifications and for posting Error Corrections and Shared -Modifications. - -7. "*Compliant Covered Code*" means Covered Code that complies with the -requirements of the TCK. - -8. "*Contributor*" means each Licensee that creates or contributes to -the creation of any Error Correction or Shared Modification. - -9. "*Covered Code*" means the Original Code, Upgraded Code, -Modifications, or any combination thereof. - -10. "*Error Correction*" means any change made to Community Code which -conforms to the Specification and corrects the adverse effect of a -failure of Community Code to perform any function set forth in or -required by the Specifications. - -11. "*Executable*" means Covered Code that has been converted from -Source Code to the preferred form for execution by a computer or digital -processor (e.g. binary form). - -12. "*Extension(s)"* means any additional Interfaces developed by or for -You which: (i) are designed for use with the Technology; (ii) constitute -an API for a library of computing functions or services; and (iii) are -disclosed or otherwise made available to third party software developers -for the purpose of developing software which invokes such additional -Interfaces. The foregoing shall not apply to software developed by Your -subcontractors to be exclusively used by You. - -13. "*Header File(s)"* means that portion of the Source Code that -provides the names and types of member functions, data members, class -definitions, and interface definitions necessary to implement the APIs -for the Covered Code. Header Files include, files specifically -designated by Original Contributor as Header Files. Header Files do not -include the code necessary to implement the functionality underlying the -Interface. - -14. *"Helix DNA Server Technology"* means the program(s) that implement -the Helix Universal Server streaming engine for the Technology as -defined in the Specification. - -15. *"Helix DNA Client Technology"* means the Covered Code that -implements the RealOne Player engine as defined in the Specification. - -16. *"Helix DNA Producer Technology"* means the Covered Code that -implements the Helix Producer engine as defined in the Specification. - -17. *"Helix DNA Technology"* means the Helix DNA Server Technology, the -Helix DNA Client Technology, the Helix DNA Producer Technology and other -Helix technologies designated by Original Contributor. - -18. "*Intellectual Property Rights*" means worldwide statutory and -common law rights associated solely with (i) Applicable Patent Rights; -(ii) works of authorship including copyrights, copyright applications, -copyright registrations and "moral rights"; (iii) the protection of -trade and industrial secrets and confidential information; and (iv) -divisions, continuations, renewals, and re-issuances of the foregoing -now existing or acquired in the future. - -19. *"Interface*" means interfaces, functions, properties, class -definitions, APIs, Header Files, GUIDs, V-Tables, and/or protocols -allowing one piece of software, firmware or hardware to communicate or -interoperate with another piece of software, firmware or hardware. - -20. "*Internal Deployment Use*" means use of Compliant Covered Code -(excluding Research Use) within Your business or organization only by -Your employees and/or agents on behalf of Your business or organization, -but not to provide services, including content distribution, to third -parties, subject to execution of Attachment D by You and Original -Contributor, if required. - -21. "*Licensee*" means any party that has entered into and has in effect -a version of this License with Original Contributor. - -22. "*MIME type*" means a description of what type of media or other -content is in a file, including by way of example but not limited to -'audio/x-pn-realaudio-plugin.' - -23. "*Modification(s)"* means (i) any addition to, deletion from and/or -change to the substance and/or structure of the Covered Code, including -Interfaces; (ii) the combination of any Covered Code and any previous -Modifications; (iii) any new file or other representation of computer -program statements that contains any portion of Covered Code; and/or -(iv) any new Source Code implementing any portion of the Specifications. - -24. "*MP3 Patents*" means any patents necessary to make, use or sell -technology implementing any portion of the specification developed by -the Moving Picture Experts Group known as MPEG-1 Audio Layer-3 or MP3, -including but not limited to all past and future versions, profiles, -extensions, parts and amendments relating to the MP3 specification. - -25. "*MPEG-4 Patents*" means any patents necessary to make, use or sell -technology implementing any portion of the specification developed by -the Moving Pictures Experts Group known as MPEG-4, including but not -limited to all past and future versions, profiles, extensions, parts and -amendments relating to the MPEG-4 specification. - -26. "*Original Code*" means the initial Source Code for the Technology -as described on the Community Web Server. - -27. "*Original Contributor*" means RealNetworks, Inc., its affiliates -and its successors and assigns. - -28. "*Original Contributor MIME Type*" means the MIME registry, browser -preferences, or local file/protocol associations invoking any Helix DNA -Client-based application, including the RealOne Player, for playback of -RealAudio, RealVideo, other RealMedia MIME types or datatypes (e.g., -.ram, .rnx, .rpm, .ra, .rm, .rp, .rt, .rf, .prx, .mpe, .rmp, .rmj, .rav, -.rjs, .rmx, .rjt, .rms), and any other Original Contributor-specific or -proprietary MIME types that Original Contributor may introduce in the -future. - -29. "*Personal Use*" means use of Covered Code by an individual solely -for his or her personal, private and non-commercial purposes. An -individual's use of Covered Code in his or her capacity as an officer, -employee, member, independent contractor or agent of a corporation, -business or organization (commercial or non-commercial) does not qualify -as Personal Use. - -30. "*RealMedia File Format*" means the file format designed and -developed by RealNetworks for storing multimedia data and used to store -RealAudio and RealVideo encoded streams. Valid RealMedia File Format -extensions include: .rm, .rmj, .rmc, .rmvb, .rms. - -31. "*RCSL Webpage*" means the RealNetworks Community Source License -webpage located at https://www.helixcommunity.org/content/rcsl or such -other URL that Original Contributor may designate from time to time. - -32. "*Reformatted Specifications*" means any revision to the -Specifications which translates or reformats the Specifications (as for -example in connection with Your documentation) but which does not alter, -subset or superset * *the functional or operational aspects of the -Specifications. - -33. "*Research Use*" means use and distribution of Covered Code only for -Your Personal Use, research or development use and expressly excludes -Internal Deployment Use and Commercial Use. Research Use also includes -use of Covered Code to teach individuals how to use Covered Code. - -34. "*Shared Modifications*" means Modifications that You distribute or -use for a Commercial Use, in addition to any Modifications provided by -You, at Your option, pursuant to Section 2.2, or received by You from a -Contributor pursuant to Section 2.3. - -35. "*Source Code*" means the preferred form of the Covered Code for -making modifications to it, including all modules it contains, plus any -associated interface definition files, scripts used to control -compilation and installation of an Executable, or source code -differential comparisons against either the Original Code or another -well known, available Covered Code of the Contributor's choice. The -Source Code can be in a compressed or archival form, provided the -appropriate decompression or de-archiving software is widely available -for no charge. - -36. "*Specifications*" means the specifications for the Technology and -other documentation, as designated on the Community Web Server, as may -be revised by Original Contributor from time to time. - -37. "*Trademarks*" means Original Contributor's trademarks and logos, -including, but not limited to, RealNetworks, RealAudio, RealVideo, -RealOne, RealSystem, SureStream, Helix, Helix DNA and other trademarks -whether now used or adopted in the future. - -38. "*Technology*" means the technology described in Attachment B, and -Upgrades. - -39. "*Technology Compatibility Kit"* or *"TCK*" means the test programs, -procedures, acceptance criteria and/or other requirements, designated by -Original Contributor for use in verifying compliance of Covered Code -with the Specifications, in conjunction with the Original Code and -Upgraded Code. Original Contributor may, in its sole discretion and from -time to time, revise a TCK to correct errors and/or omissions and in -connection with Upgrades. - -40. "*Upgrade(s)"* means new versions of Technology designated -exclusively by Original Contributor as an "Upgrade" and released by -Original Contributor from time to time under the terms of the License. - -41. "*Upgraded Code*" means the Source Code and/or Executables for -Upgrades, possibly including Modifications made by Contributors. - -42. *"User's Guide"* means the users guide for the TCK which Original -Contributor makes available to You to provide direction in how to run -the TCK and properly interpret the results, as may be revised by -Original Contributor from time to time. - -43. "*You(r)*" means an individual, or a legal entity acting by and -through an individual or individuals, exercising rights either under -this License or under a future version of this License issued pursuant -to Section 4.1. For legal entities, "You(r)" includes any entity that by -majority voting interest controls, is controlled by, or is under common -control with You. - -44. "*Your Products*" means any (i) hardware products You distribute -integrating the Covered Code; (ii) any software products You distribute -with the Covered Code that utilize the APIs of the Covered Code; or -(iii) any services You provide using the Covered Code. - - - ATTACHMENT A - -REQUIRED NOTICES - - - ATTACHMENT A-1 - -REQUIRED IN ALL CASES - -Notice to be included in header file of all Error Corrections and Shared -Modifications: - -Portions Copyright 1994-2003 © RealNetworks, Inc. All rights reserved. - -The contents of this file, and the files included with this file, are -subject to the current version of RealNetworks Community Source License -Version 1.1 (the "License"). You may not use this file except in -compliance with the License executed by both You and RealNetworks. You -may obtain a copy of the License at * -https://www.helixcommunity.org/content/rcsl.* You may also obtain a copy -of the License by contacting RealNetworks directly. Please see the -License for the rights, obligations and limitations governing use of the -contents of the file. - -This file is part of the Helix DNA technology. RealNetworks, Inc., is -the developer of the Original code and owns the copyrights in the -portions it created. - -This file, and the files included with this file, are distributed on an -'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, -AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT -LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - -Contributor(s): - -_______________________________________________ - -Technology Compatibility Kit Test Suite(s) Location: - -________________________________ - - - ATTACHMENT A-2 - -SAMPLE LICENSEE CERTIFICATION - -"By clicking the `Agree' button below, You certify that You are a -Licensee in good standing under the RealNetworks Community Source -License, ("License") and that Your access, use and distribution of code -and information You may obtain at this site is subject to the License. -If You are not a Licensee under the RealNetworks Community Source -License You agree not to download, copy or use the Helix DNA technology. - - - ATTACHMENT A-3 - -REQUIRED STUDENT NOTIFICATION - -"This software and related documentation has been obtained by Your -educational institution subject to the RealNetworks Community Source -License. You have been provided access to the software and related -documentation for use only in connection with your course work and -research activities as a matriculated student of Your educational -institution. Any other use is expressly prohibited. - -THIS SOFTWARE AND RELATED DOCUMENTATION CONTAINS PROPRIETARY MATERIAL OF -REALNETWORKS, INC, WHICH ARE PROTECTED BY VARIOUS INTELLECTUAL PROPERTY -RIGHTS. - -You may not use this file except in compliance with the License. You may -obtain a copy of the License on the web at -https://www.helixcommunity.org/content/rcsl. - -* -* - - - ATTACHMENT B - -Description of Technology - -Helix DNA, which consists of Helix DNA Client, Helix DNA Server and -Helix DNA Producer. - -Description of "Technology" - -Helix DNA Technology v1.0 as described on the Community Web Server. - - - ATTACHMENT C - -TECHNOLOGY COMPATIBILITY KIT LICENSE - -The following license is effective for the *Helix DNA* Technology -Compatibility Kit - as described on the Community Web Server. The -Technology Compatibility Kit(s) for the Technology specified in -Attachment B may be accessed at the Community Web Server. - -1. TCK License. - -1.1 Grants to use TCK - -Subject to the terms and restrictions set forth below and the -RealNetworks Community Source License, and the Research Use license, -Original Contributor grants to You a worldwide, non-exclusive, -non-transferable license, to the extent of Original Contributor's -Intellectual Property Rights in the TCK (without the right to -sublicense), to use the TCK to develop and test Covered Code. - -1.2 TCK Use Restrictions. - -You are not authorized to create derivative works of the TCK or use the -TCK to test any implementation of the Specification that is not Covered -Code. You may not publish Your test results or make claims of -comparative compatibility with respect to other implementations of the -Specification. In consideration for the license grant in Section 1.1 -above You agree not to develop Your own tests that are intended to -validate conformation with the Specification. - -2. Test Results. - -You agree to provide to Original Contributor or the third party test -facility if applicable, Your test results that demonstrate that Covered -Code is Compliant Covered Code and that Original Contributor may publish -or otherwise distribute such test results. - -PLEASE READ THE TERMS OF THIS LICENSE CAREFULLY. BY CLICKING ON THE -"ACCEPT" BUTTON BELOW YOU ARE ACCEPTING AND AGREEING TO THE TERMS AND -CONDITIONS OF THIS LICENSE WITH THE ORIGINAL CONTRIBUTOR, REALNETWORKS, -INC. IF YOU ARE AGREEING TO THIS LICENSE ON BEHALF OF A COMPANY, YOU -REPRESENT THAT YOU ARE AUTHORIZED TO BIND THE COMPANY TO SUCH A LICENSE. -WHETHER YOU ARE ACTING ON YOUR OWN BEHALF, OR REPRESENTING A COMPANY, -YOU MUST BE OF MAJORITY AGE AND BE OTHERWISE COMPETENT TO ENTER INTO -CONTRACTS. IF YOU DO NOT MEET THIS CRITERIA OR YOU DO NOT AGREE TO ANY -OF THE TERMS AND CONDITIONS OF THIS LICENSE, CLICK ON THE REJECT BUTTON -TO EXIT. - -*ACCEPT / REJECT -* - -* -* - -*To agree to the R&D/academic terms of this license, please register - on the site -- -you will then be given a chance to agree to the clickwrap RCSL - -R&D License - -and gain access to the RCSL-licensed source code. To build or deploy -commercial applications based on the RCSL, you will need to agree to the -Commercial Use license attachments -* - - - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RPSL.txt b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RPSL.txt deleted file mode 100644 index d040a452..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/RPSL.txt +++ /dev/null @@ -1,518 +0,0 @@ -RealNetworks Public Source License Version 1.0 -(Rev. Date October 28, 2002) - -1. General Definitions. This License applies to any program or other work which -RealNetworks, Inc., or any other entity that elects to use this license, -("Licensor") makes publicly available and which contains a notice placed by -Licensor identifying such program or work as "Original Code" and stating that it -is subject to the terms of this RealNetworks Public Source License version 1.0 -(or subsequent version thereof) ("License"). You are not required to accept this -License. However, nothing else grants You permission to use, copy, modify or -distribute the software or its derivative works. These actions are prohibited by -law if You do not accept this License. Therefore, by modifying, copying or -distributing the software (or any work based on the software), You indicate your -acceptance of this License to do so, and all its terms and conditions. In -addition, you agree to the terms of this License by clicking the Accept button -or downloading the software. As used in this License: - -1.1 "Applicable Patent Rights" mean: (a) in the case where Licensor is the -grantor of rights, claims of patents that (i) are now or hereafter acquired, -owned by or assigned to Licensor and (ii) are necessarily infringed by using or -making the Original Code alone and not in combination with other software or -hardware; and (b) in the case where You are the grantor of rights, claims of -patents that (i) are now or hereafter acquired, owned by or assigned to You and -(ii) are infringed (directly or indirectly) by using or making Your -Modifications, taken alone or in combination with Original Code. - -1.2 "Compatible Source License" means any one of the licenses listed on Exhibit -B or at https://www.helixcommunity.org/content/complicense or other licenses -specifically identified by Licensor in writing. Notwithstanding any term to the -contrary in any Compatible Source License, any code covered by any Compatible -Source License that is used with Covered Code must be made readily available in -Source Code format for royalty-free use under the terms of the Compatible Source -License or this License. - -1.3 "Contributor" means any person or entity that creates or contributes to the -creation of Modifications. - -1.4 "Covered Code" means the Original Code, Modifications, the combination of -Original Code and any Modifications, and/or any respective portions thereof. - -1.5 "Deploy" means to use, sublicense or distribute Covered Code other than for -Your internal research and development (R&D) and/or Personal Use, and includes -without limitation, any and all internal use or distribution of Covered Code -within Your business or organization except for R&D use and/or Personal Use, as -well as direct or indirect sublicensing or distribution of Covered Code by You -to any third party in any form or manner. - -1.6 "Derivative Work" means either the Covered Code or any derivative work under -United States copyright law, and including any work containing or including any -portion of the Covered Code or Modifications, either verbatim or with -modifications and/or translated into another language. Derivative Work also -includes any work which combines any portion of Covered Code or Modifications -with code not otherwise governed by the terms of this License. - -1.7 "Externally Deploy" means to Deploy the Covered Code in any way that may be -accessed or used by anyone other than You, used to provide any services to -anyone other than You, or used in any way to deliver any content to anyone other -than You, whether the Covered Code is distributed to those parties, made -available as an application intended for use over a computer network, or used to -provide services or otherwise deliver content to anyone other than You. - -1.8. "Interface" means interfaces, functions, properties, class definitions, -APIs, header files, GUIDs, V-Tables, and/or protocols allowing one piece of -software, firmware or hardware to communicate or interoperate with another piece -of software, firmware or hardware. - -1.9 "Modifications" mean any addition to, deletion from, and/or change to, the -substance and/or structure of the Original Code, any previous Modifications, the -combination of Original Code and any previous Modifications, and/or any -respective portions thereof. When code is released as a series of files, a -Modification is: (a) any addition to or deletion from the contents of a file -containing Covered Code; and/or (b) any new file or other representation of -computer program statements that contains any part of Covered Code. - -1.10 "Original Code" means (a) the Source Code of a program or other work as -originally made available by Licensor under this License, including the Source -Code of any updates or upgrades to such programs or works made available by -Licensor under this License, and that has been expressly identified by Licensor -as such in the header file(s) of such work; and (b) the object code compiled -from such Source Code and originally made available by Licensor under this -License. - -1.11 "Personal Use" means use of Covered Code by an individual solely for his or -her personal, private and non-commercial purposes. An individual's use of -Covered Code in his or her capacity as an officer, employee, member, independent -contractor or agent of a corporation, business or organization (commercial or -non-commercial) does not qualify as Personal Use. - -1.12 "Source Code" means the human readable form of a program or other work that -is suitable for making modifications to it, including all modules it contains, -plus any associated interface definition files, scripts used to control -compilation and installation of an executable (object code). - -1.13 "You" or "Your" means an individual or a legal entity exercising rights -under this License. For legal entities, "You" or "Your" includes any entity -which controls, is controlled by, or is under common control with, You, where -"control" means (a) the power, direct or indirect, to cause the direction or -management of such entity, whether by contract or otherwise, or (b) ownership of -fifty percent (50%) or more of the outstanding shares or beneficial ownership of -such entity. - -2. Permitted Uses; Conditions & Restrictions. Subject to the terms and -conditions of this License, Licensor hereby grants You, effective on the date -You accept this License (via downloading or using Covered Code or otherwise -indicating your acceptance of this License), a worldwide, royalty-free, -non-exclusive copyright license, to the extent of Licensor's copyrights cover -the Original Code, to do the following: - -2.1 You may reproduce, display, perform, modify and Deploy Covered Code, -provided that in each instance: - -(a) You must retain and reproduce in all copies of Original Code the copyright -and other proprietary notices and disclaimers of Licensor as they appear in the -Original Code, and keep intact all notices in the Original Code that refer to -this License; - -(b) You must include a copy of this License with every copy of Source Code of -Covered Code and documentation You distribute, and You may not offer or impose -any terms on such Source Code that alter or restrict this License or the -recipients' rights hereunder, except as permitted under Section 6; - -(c) You must duplicate, to the extent it does not already exist, the notice in -Exhibit A in each file of the Source Code of all Your Modifications, and cause -the modified files to carry prominent notices stating that You changed the files -and the date of any change; - -(d) You must make Source Code of all Your Externally Deployed Modifications -publicly available under the terms of this License, including the license grants -set forth in Section 3 below, for as long as you Deploy the Covered Code or -twelve (12) months from the date of initial Deployment, whichever is longer. You -should preferably distribute the Source Code of Your Deployed Modifications -electronically (e.g. download from a web site); and - -(e) if You Deploy Covered Code in object code, executable form only, You must -include a prominent notice, in the code itself as well as in related -documentation, stating that Source Code of the Covered Code is available under -the terms of this License with information on how and where to obtain such -Source Code. You must also include the Object Code Notice set forth in Exhibit A -in the "about" box or other appropriate place where other copyright notices are -placed, including any packaging materials. - -2.2 You expressly acknowledge and agree that although Licensor and each -Contributor grants the licenses to their respective portions of the Covered Code -set forth herein, no assurances are provided by Licensor or any Contributor that -the Covered Code does not infringe the patent or other intellectual property -rights of any other entity. Licensor and each Contributor disclaim any liability -to You for claims brought by any other entity based on infringement of -intellectual property rights or otherwise. As a condition to exercising the -rights and licenses granted hereunder, You hereby assume sole responsibility to -secure any other intellectual property rights needed, if any. For example, if a -third party patent license is required to allow You to make, use, sell, import -or offer for sale the Covered Code, it is Your responsibility to acquire such -license(s). - -2.3 Subject to the terms and conditions of this License, Licensor hereby grants -You, effective on the date You accept this License (via downloading or using -Covered Code or otherwise indicating your acceptance of this License), a -worldwide, royalty-free, perpetual, non-exclusive patent license under -Licensor's Applicable Patent Rights to make, use, sell, offer for sale and -import the Covered Code, provided that in each instance you comply with the -terms of this License. - -3. Your Grants. In consideration of, and as a condition to, the licenses granted -to You under this License: - -(a) You grant to Licensor and all third parties a non-exclusive, perpetual, -irrevocable, royalty free license under Your Applicable Patent Rights and other -intellectual property rights owned or controlled by You, to make, sell, offer -for sale, use, import, reproduce, display, perform, modify, distribute and -Deploy Your Modifications of the same scope and extent as Licensor's licenses -under Sections 2.1 and 2.2; and - -(b) You grant to Licensor and its subsidiaries a non-exclusive, worldwide, -royalty-free, perpetual and irrevocable license, under Your Applicable Patent -Rights and other intellectual property rights owned or controlled by You, to -make, use, sell, offer for sale, import, reproduce, display, perform, -distribute, modify or have modified (for Licensor and/or its subsidiaries), -sublicense and distribute Your Modifications, in any form and for any purpose, -through multiple tiers of distribution. - -(c) You agree not use any information derived from Your use and review of the -Covered Code, including but not limited to any algorithms or inventions that may -be contained in the Covered Code, for the purpose of asserting any of Your -patent rights, or assisting a third party to assert any of its patent rights, -against Licensor or any Contributor. - -4. Derivative Works. You may create a Derivative Work by combining Covered Code -with other code not otherwise governed by the terms of this License and -distribute the Derivative Work as an integrated product. In each such instance, -You must make sure the requirements of this License are fulfilled for the -Covered Code or any portion thereof, including all Modifications. - -4.1 You must cause any Derivative Work that you distribute, publish or -Externally Deploy, that in whole or in part contains or is derived from the -Covered Code or any part thereof, to be licensed as a whole at no charge to all -third parties under the terms of this License and no other license except as -provided in Section 4.2. You also must make Source Code available for the -Derivative Work under the same terms as Modifications, described in Sections 2 -and 3, above. - -4.2 Compatible Source Licenses. Software modules that have been independently -developed without any use of Covered Code and which contain no portion of the -Covered Code, Modifications or other Derivative Works, but are used or combined -in any way wtih the Covered Code or any Derivative Work to form a larger -Derivative Work, are exempt from the conditions described in Section 4.1 but -only to the extent that: the software module, including any software that is -linked to, integrated with, or part of the same applications as, the software -module by any method must be wholly subject to one of the Compatible Source -Licenses. Notwithstanding the foregoing, all Covered Code must be subject to the -terms of this License. Thus, the entire Derivative Work must be licensed under a -combination of the RPSL (for Covered Code) and a Compatible Source License for -any independently developed software modules within the Derivative Work. The -foregoing requirement applies even if the Compatible Source License would -ordinarily allow the software module to link with, or form larger works with, -other software that is not subject to the Compatible Source License. For -example, although the Mozilla Public License v1.1 allows Mozilla code to be -combined with proprietary software that is not subject to the MPL, if -MPL-licensed code is used with Covered Code the MPL-licensed code could not be -combined or linked with any code not governed by the MPL. The general intent of -this section 4.2 is to enable use of Covered Code with applications that are -wholly subject to an acceptable open source license. You are responsible for -determining whether your use of software with Covered Code is allowed under Your -license to such software. - -4.3 Mere aggregation of another work not based on the Covered Code with the -Covered Code (or with a work based on the Covered Code) on a volume of a storage -or distribution medium does not bring the other work under the scope of this -License. If You deliver the Covered Code for combination and/or integration with -an application previously provided by You (for example, via automatic updating -technology), such combination and/or integration constitutes a Derivative Work -subject to the terms of this License. - -5. Exclusions From License Grant. Nothing in this License shall be deemed to -grant any rights to trademarks, copyrights, patents, trade secrets or any other -intellectual property of Licensor or any Contributor except as expressly stated -herein. No right is granted to the trademarks of Licensor or any Contributor -even if such marks are included in the Covered Code. Nothing in this License -shall be interpreted to prohibit Licensor from licensing under different terms -from this License any code that Licensor otherwise would have a right to -license. Modifications, Derivative Works and/or any use or combination of -Covered Code with other technology provided by Licensor or third parties may -require additional patent licenses from Licensor which Licensor may grant in its -sole discretion. No patent license is granted separate from the Original Code or -combinations of the Original Code with other software or hardware. - -5.1. Trademarks. This License does not grant any rights to use the trademarks or -trade names owned by Licensor ("Licensor Marks" defined in Exhibit C) or to any -trademark or trade name belonging to any Contributor. No Licensor Marks may be -used to endorse or promote products derived from the Original Code other than as -permitted by the Licensor Trademark Policy defined in Exhibit C. - -6. Additional Terms. You may choose to offer, and to charge a fee for, warranty, -support, indemnity or liability obligations and/or other rights consistent with -the scope of the license granted herein ("Additional Terms") to one or more -recipients of Covered Code. However, You may do so only on Your own behalf and -as Your sole responsibility, and not on behalf of Licensor or any Contributor. -You must obtain the recipient's agreement that any such Additional Terms are -offered by You alone, and You hereby agree to indemnify, defend and hold -Licensor and every Contributor harmless for any liability incurred by or claims -asserted against Licensor or such Contributor by reason of any such Additional -Terms. - -7. Versions of the License. Licensor may publish revised and/or new versions of -this License from time to time. Each version will be given a distinguishing -version number. Once Original Code has been published under a particular version -of this License, You may continue to use it under the terms of that version. You -may also choose to use such Original Code under the terms of any subsequent -version of this License published by Licensor. No one other than Licensor has -the right to modify the terms applicable to Covered Code created under this -License. - -8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in part -pre-release, untested, or not fully tested works. The Covered Code may contain -errors that could cause failures or loss of data, and may be incomplete or -contain inaccuracies. You expressly acknowledge and agree that use of the -Covered Code, or any portion thereof, is at Your sole and entire risk. THE -COVERED CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR SUPPORT OF -ANY KIND AND LICENSOR AND LICENSOR'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS -"LICENSOR" FOR THE PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY -DISCLAIM ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT -NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF MERCHANTABILITY, OF -SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF ACCURACY, OF QUIET -ENJOYMENT, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. LICENSOR AND EACH -CONTRIBUTOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE -COVERED CODE, THAT THE FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR -REQUIREMENTS, THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR -ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO ORAL OR -WRITTEN DOCUMENTATION, INFORMATION OR ADVICE GIVEN BY LICENSOR, A LICENSOR -AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. You -acknowledge that the Covered Code is not intended for use in high risk -activities, including, but not limited to, the design, construction, operation -or maintenance of nuclear facilities, aircraft navigation, aircraft -communication systems, or air traffic control machines in which case the failure -of the Covered Code could lead to death, personal injury, or severe physical or -environmental damage. Licensor disclaims any express or implied warranty of -fitness for such uses. - -9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT -SHALL LICENSOR OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL, -INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING TO THIS LICENSE OR -YOUR USE OR INABILITY TO USE THE COVERED CODE, OR ANY PORTION THEREOF, WHETHER -UNDER A THEORY OF CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE OR STRICT -LIABILITY), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF LICENSOR OR SUCH -CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND -NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. SOME -JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU. In no event -shall Licensor's total liability to You for all damages (other than as may be -required by applicable law) under this License exceed the amount of ten dollars -($10.00). - -10. Ownership. Subject to the licenses granted under this License, each -Contributor retains all rights, title and interest in and to any Modifications -made by such Contributor. Licensor retains all rights, title and interest in and -to the Original Code and any Modifications made by or on behalf of Licensor -("Licensor Modifications"), and such Licensor Modifications will not be -automatically subject to this License. Licensor may, at its sole discretion, -choose to license such Licensor Modifications under this License, or on -different terms from those contained in this License or may choose not to -license them at all. - -11. Termination. - -11.1 Term and Termination. The term of this License is perpetual unless -terminated as provided below. This License and the rights granted hereunder will -terminate: - -(a) automatically without notice from Licensor if You fail to comply with any -term(s) of this License and fail to cure such breach within 30 days of becoming -aware of such breach; - -(b) immediately in the event of the circumstances described in Section 12.5(b); -or - -(c) automatically without notice from Licensor if You, at any time during the -term of this License, commence an action for patent infringement against -Licensor (including by cross-claim or counter claim in a lawsuit); - -(d) upon written notice from Licensor if You, at any time during the term of -this License, commence an action for patent infringement against any third party -alleging that the Covered Code itself (excluding combinations with other -software or hardware) infringes any patent (including by cross-claim or counter -claim in a lawsuit). - -11.2 Effect of Termination. Upon termination, You agree to immediately stop any -further use, reproduction, modification, sublicensing and distribution of the -Covered Code and to destroy all copies of the Covered Code that are in your -possession or control. All sublicenses to the Covered Code which have been -properly granted prior to termination shall survive any termination of this -License. Provisions which, by their nature, should remain in effect beyond the -termination of this License shall survive, including but not limited to Sections -3, 5, 8, 9, 10, 11, 12.2 and 13. No party will be liable to any other for -compensation, indemnity or damages of any sort solely as a result of terminating -this License in accordance with its terms, and termination of this License will -be without prejudice to any other right or remedy of any party. - -12. Miscellaneous. - -12.1 Government End Users. The Covered Code is a "commercial item" as defined in -FAR 2.101. Government software and technical data rights in the Covered Code -include only those rights customarily provided to the public as defined in this -License. This customary commercial license in technical data and software is -provided in accordance with FAR 12.211 (Technical Data) and 12.212 (Computer -Software) and, for Department of Defense purchases, DFAR 252.227-7015 (Technical -Data -- Commercial Items) and 227.7202-3 (Rights in Commercial Computer Software -or Computer Software Documentation). Accordingly, all U.S. Government End Users -acquire Covered Code with only those rights set forth herein. - -12.2 Relationship of Parties. This License will not be construed as creating an -agency, partnership, joint venture or any other form of legal association -between or among You, Licensor or any Contributor, and You will not represent to -the contrary, whether expressly, by implication, appearance or otherwise. - -12.3 Independent Development. Nothing in this License will impair Licensor's -right to acquire, license, develop, have others develop for it, market and/or -distribute technology or products that perform the same or similar functions as, -or otherwise compete with, Modifications, Derivative Works, technology or -products that You may develop, produce, market or distribute. - -12.4 Waiver; Construction. Failure by Licensor or any Contributor to enforce any -provision of this License will not be deemed a waiver of future enforcement of -that or any other provision. Any law or regulation which provides that the -language of a contract shall be construed against the drafter will not apply to -this License. - -12.5 Severability. (a) If for any reason a court of competent jurisdiction finds -any provision of this License, or portion thereof, to be unenforceable, that -provision of the License will be enforced to the maximum extent permissible so -as to effect the economic benefits and intent of the parties, and the remainder -of this License will continue in full force and effect. (b) Notwithstanding the -foregoing, if applicable law prohibits or restricts You from fully and/or -specifically complying with Sections 2 and/or 3 or prevents the enforceability -of either of those Sections, this License will immediately terminate and You -must immediately discontinue any use of the Covered Code and destroy all copies -of it that are in your possession or control. - -12.6 Dispute Resolution. Any litigation or other dispute resolution between You -and Licensor relating to this License shall take place in the Seattle, -Washington, and You and Licensor hereby consent to the personal jurisdiction of, -and venue in, the state and federal courts within that District with respect to -this License. The application of the United Nations Convention on Contracts for -the International Sale of Goods is expressly excluded. - -12.7 Export/Import Laws. This software is subject to all export and import laws -and restrictions and regulations of the country in which you receive the Covered -Code and You are solely responsible for ensuring that You do not export, -re-export or import the Covered Code or any direct product thereof in violation -of any such restrictions, laws or regulations, or without all necessary -authorizations. - -12.8 Entire Agreement; Governing Law. This License constitutes the entire -agreement between the parties with respect to the subject matter hereof. This -License shall be governed by the laws of the United States and the State of -Washington. - -Where You are located in the province of Quebec, Canada, the following clause -applies: The parties hereby confirm that they have requested that this License -and all related documents be drafted in English. Les parties ont exigé -que le présent contrat et tous les documents connexes soient -rédigés en anglais. - - EXHIBIT A. - -"Copyright © 1995-2002 -RealNetworks, Inc. and/or its licensors. All Rights Reserved. - -The contents of this file, and the files included with this file, are subject to -the current version of the RealNetworks Public Source License Version 1.0 (the -"RPSL") available at https://www.helixcommunity.org/content/rpsl unless you have -licensed the file under the RealNetworks Community Source License Version 1.0 -(the "RCSL") available at https://www.helixcommunity.org/content/rcsl, in which -case the RCSL will apply. You may also obtain the license terms directly from -RealNetworks. You may not use this file except in compliance with the RPSL or, -if you have a valid RCSL with RealNetworks applicable to this file, the RCSL. -Please see the applicable RPSL or RCSL for the rights, obligations and -limitations governing use of the contents of the file. - -This file is part of the Helix DNA Technology. RealNetworks is the developer of -the Original code and owns the copyrights in the portions it created. - -This file, and the files included with this file, is distributed and made -available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR -IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING -WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - -Contributor(s): ____________________________________ - -Technology Compatibility Kit Test -Suite(s) Location (if licensed under the RCSL): ______________________________ - -Object Code Notice: Helix DNA Client technology included. Copyright (c) -RealNetworks, Inc., 1995-2002. All rights reserved. - - - EXHIBIT B - -Compatible Source Licenses for the RealNetworks Public Source License. The -following list applies to the most recent version of the license as of October -25, 2002, unless otherwise indicated. - -* Academic Free License -* Apache Software License -* Apple Public Source License -* Artistic license -* Attribution Assurance Licenses -* BSD license -* Common Public License (1) -* Eiffel Forum License -* GNU General Public License (GPL) (1) -* GNU Library or "Lesser" General Public License (LGPL) (1) -* IBM Public License -* Intel Open Source License -* Jabber Open Source License -* MIT license -* MITRE Collaborative Virtual Workspace License (CVW License) -* Motosoto License -* Mozilla Public License 1.0 (MPL) -* Mozilla Public License 1.1 (MPL) -* Nokia Open Source License -* Open Group Test Suite License -* Python Software Foundation License -* Ricoh Source Code Public License -* Sun Industry Standards Source License (SISSL) -* Sun Public License -* University of Illinois/NCSA Open Source License -* Vovida Software License v. 1.0 -* W3C License -* X.Net License -* Zope Public License -* zlib/libpng license - -(1) Note: because this license contains certain reciprocal licensing terms that -purport to extend to independently developed code, You may be prohibited under -the terms of this otherwise compatible license from using code licensed under -its terms with Covered Code because Covered Code may only be licensed under the -RealNetworks Public Source License. Any attempt to apply non RPSL license terms, -including without limitation the GPL, to Covered Code is expressly forbidden. -You are responsible for ensuring that Your use of Compatible Source Licensed -code does not violate either the RPSL or the Compatible Source License. - -The latest version of this list can be found at: -https://www.helixcommunity.org/content/complicense - - EXHIBIT C - -RealNetworks' Trademark policy. - -RealNetworks defines the following trademarks collectively as "Licensor -Trademarks": "RealNetworks", "RealPlayer", "RealJukebox", "RealSystem", -"RealAudio", "RealVideo", "RealOne Player", "RealMedia", "Helix" or any other -trademarks or trade names belonging to RealNetworks. - -RealNetworks "Licensor Trademark Policy" forbids any use of Licensor Trademarks -except as permitted by and in strict compliance at all times with RealNetworks' -third party trademark usage guidelines which are posted at -http://www.realnetworks.com/info/helixlogo.html. - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/assembly.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/assembly.h deleted file mode 100644 index 1faa2c75..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/assembly.h +++ /dev/null @@ -1,458 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * assembly.h - assembly language functions and prototypes for supported platforms - * - * - inline rountines with access to 64-bit multiply results - * - x86 (_WIN32) and ARM (ARM_ADS, _WIN32_WCE) versions included - * - some inline functions are mix of asm and C for speed - * - some functions are in native asm files, so only the prototype is given here - * - * MULSHIFT32(x, y) signed multiply of two 32-bit integers (x and y), returns top 32 bits of 64-bit result - * FASTABS(x) branchless absolute value of signed integer x - * CLZ(x) count leading zeros in x - * MADD64(sum, x, y) (Windows only) sum [64-bit] += x [32-bit] * y [32-bit] - * SHL64(sum, x, y) (Windows only) 64-bit left shift using __int64 - * SAR64(sum, x, y) (Windows only) 64-bit right shift using __int64 - */ - -#ifndef _ASSEMBLY_H -#define _ASSEMBLY_H - -#if (defined _WIN32 && !defined _WIN32_WCE) || (defined __WINS__ && defined _SYMBIAN) || defined(_OPENWAVE_SIMULATOR) || defined(WINCE_EMULATOR) /* Symbian emulator for Ix86 */ - -#pragma warning( disable : 4035 ) /* complains about inline asm not returning a value */ - -static __inline int MULSHIFT32(int x, int y) -{ - __asm { - mov eax, x - imul y - mov eax, edx - } -} - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -/* MADD64, SHL64, SAR64: - * write in assembly to avoid dependency on run-time lib for 64-bit shifts, muls - * (sometimes compiler thunks to function calls instead of code generating) - * required for Symbian emulator - */ -#ifdef __CW32__ -typedef long long Word64; -#else -typedef __int64 Word64; -#endif - -static __inline Word64 MADD64(Word64 sum, int x, int y) -{ - unsigned int sumLo = ((unsigned int *)&sum)[0]; - int sumHi = ((int *)&sum)[1]; - - __asm { - mov eax, x - imul y - add eax, sumLo - adc edx, sumHi - } - - /* equivalent to return (sum + ((__int64)x * y)); */ -} - -static __inline Word64 SHL64(Word64 x, int n) -{ - unsigned int xLo = ((unsigned int *)&x)[0]; - int xHi = ((int *)&x)[1]; - unsigned char nb = (unsigned char)n; - - if (n < 32) { - __asm { - mov edx, xHi - mov eax, xLo - mov cl, nb - shld edx, eax, cl - shl eax, cl - } - } else if (n < 64) { - /* shl masks cl to 0x1f */ - __asm { - mov edx, xLo - mov cl, nb - xor eax, eax - shl edx, cl - } - } else { - __asm { - xor edx, edx - xor eax, eax - } - } -} - -static __inline Word64 SAR64(Word64 x, int n) -{ - unsigned int xLo = ((unsigned int *)&x)[0]; - int xHi = ((int *)&x)[1]; - unsigned char nb = (unsigned char)n; - - if (n < 32) { - __asm { - mov edx, xHi - mov eax, xLo - mov cl, nb - shrd eax, edx, cl - sar edx, cl - } - } else if (n < 64) { - /* sar masks cl to 0x1f */ - __asm { - mov edx, xHi - mov eax, xHi - mov cl, nb - sar edx, 31 - sar eax, cl - } - } else { - __asm { - sar xHi, 31 - mov eax, xHi - mov edx, xHi - } - } -} - -#elif (defined _WIN32) && (defined _WIN32_WCE) - -/* use asm function for now (EVC++ 3.0 does horrible job compiling __int64 version) */ -#define MULSHIFT32 xmp3_MULSHIFT32 -int MULSHIFT32(int x, int y); - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -#elif defined XXXARM_ADS - -static __inline int MULSHIFT32(int x, int y) -{ - /* important rules for smull RdLo, RdHi, Rm, Rs: - * RdHi and Rm can't be the same register - * RdLo and Rm can't be the same register - * RdHi and RdLo can't be the same register - * Note: Rs determines early termination (leading sign bits) so if you want to specify - * which operand is Rs, put it in the SECOND argument (y) - * For inline assembly, x and y are not assumed to be R0, R1 so it shouldn't matter - * which one is returned. (If this were a function call, returning y (R1) would - * require an extra "mov r0, r1") - */ - int zlow; - __asm { - smull zlow,y,x,y - } - - return y; -} - -static __inline int FASTABS(int x) -{ - int t=0; /*Really is not necessary to initialiaze only to avoid warning*/ - - __asm { - eor t, x, x, asr #31 - sub t, t, x, asr #31 - } - - return t; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -#elif defined(__GNUC__) && defined(XXXX__thumb__) - - -static __inline int MULSHIFT32(int x, int y) -{ - // important rules for smull RdLo, RdHi, Rm, Rs: - // RdHi and Rm can't be the same register - // RdLo and Rm can't be the same register - // RdHi and RdLo can't be the same register - // Note: Rs determines early termination (leading sign bits) so if you want to specify - // which operand is Rs, put it in the SECOND argument (y) - // For inline assembly, x and y are not assumed to be R0, R1 so it shouldn't matter - // which one is returned. (If this were a function call, returning y (R1) would - // require an extra "mov r0, r1") - - int zlow; - __asm__ volatile ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y)) ; - return y; -} - -//fb -#include -static __inline int FASTABS(int x) -{ - return abs(x); -} - -static __inline int CLZ(int x) -{ - return __builtin_clz(x); -} -//fb -//mw -//TODO: Check Compiler output on these.. (fb) -static __inline Word64 xMADD64(Word64 sum, int x, int y) -{ - return (sum + ((int64_t)x * y)); -} -static __inline Word64 xHL64(Word64 x, int n) -{ - return x << n; -} - -static __inline Word64 xSAR64(Word64 x, int n) -{ - return x >> n; -} -//mw - -#elif defined(__arm__) - -#if defined(ARM7DI) - -typedef long long Word64; - -static __inline int MULSHIFT32(int x, int y) { - return x * y; -} - -#else - -static __inline Word64 SAR64(Word64 x, int n) { - return x >>= n; -} - - -typedef union _U64 { - Word64 w64; - struct { - /* x86 = little endian */ - unsigned int lo32; - signed int hi32; - } r; -} U64; - -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - - return sum64; -} - -static __inline int MULSHIFT32(int x, int y) -{ - /* important rules for smull RdLo, RdHi, Rm, Rs: - * RdHi and Rm can't be the same register - * RdLo and Rm can't be the same register - * RdHi and RdLo can't be the same register - * Note: Rs determines early termination (leading sign bits) so if you want to specify - * which operand is Rs, put it in the SECOND argument (y) - * For inline assembly, x and y are not assumed to be R0, R1 so it shouldn't matter - * which one is returned. (If this were a function call, returning y (R1) would - * require an extra "mov r0, r1") - */ - int zlow; - __asm__ volatile ("smull %0,%1,%2,%3" : "=&r" (zlow), "=r" (y) : "r" (x), "1" (y)) ; - - return y; -} - -#endif - -static __inline int FASTABS(int x) -{ - int t=0; /*Really is not necessary to initialiaze only to avoid warning*/ - - __asm__ volatile ( - "eor %0,%2,%2, asr #31;" - "sub %0,%1,%2, asr #31;" - : "=&r" (t) - : "0" (t), "r" (x) - ); - - return t; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -#elif defined(__APPLE__) || defined(ESP_PLATFORM) || defined(__amd64__) - -static __inline int FASTABS(int x) -{ - int sign; - - sign = x >> (sizeof(int) * 8 - 1); - x ^= sign; - x -= sign; - - return x; -} - -static __inline int CLZ(int x) -{ - int numZeros; - - if (!x) - return (sizeof(int) * 8); - - numZeros = 0; - while (!(x & 0x80000000)) { - numZeros++; - x <<= 1; - } - - return numZeros; -} - -/* returns 64-bit value in [edx:eax] */ -static __inline Word64 MADD64(Word64 sum64, int x, int y) -{ - sum64 += (Word64)x * (Word64)y; - return sum64; -} - -static __inline__ int MULSHIFT32(int x, int y) -{ - int z; - - z = (Word64)x * (Word64)y >> 32; - - return z; -} - -static __inline Word64 SAR64(Word64 x, int n) -{ - return x >> n; -} - -#else - -#error Unsupported platform in assembly.h - -#endif /* platforms */ - -#endif /* _ASSEMBLY_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/bitstream.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/bitstream.c deleted file mode 100644 index 608c39cc..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/bitstream.c +++ /dev/null @@ -1,389 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * bitstream.c - bitstream unpacking, frame header parsing, side info parsing - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: SetBitstreamPointer - * - * Description: initialize bitstream reader - * - * Inputs: pointer to BitStreamInfo struct - * number of bytes in bitstream - * pointer to byte-aligned buffer of data to read from - * - * Outputs: filled bitstream info struct - * - * Return: none - **************************************************************************************/ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf) -{ - /* init bitstream */ - bsi->bytePtr = buf; - bsi->iCache = 0; /* 4-byte unsigned int */ - bsi->cachedBits = 0; /* i.e. zero bits in cache */ - bsi->nBytes = nBytes; -} - -/************************************************************************************** - * Function: RefillBitstreamCache - * - * Description: read new data from bitstream buffer into bsi cache - * - * Inputs: pointer to initialized BitStreamInfo struct - * - * Outputs: updated bitstream info struct - * - * Return: none - * - * Notes: only call when iCache is completely drained (resets bitOffset to 0) - * always loads 4 new bytes except when bsi->nBytes < 4 (end of buffer) - * stores data as big-endian in cache, regardless of machine endian-ness - * - * TODO: optimize for ARM - * possibly add little/big-endian modes for doing 32-bit loads - **************************************************************************************/ -static __inline void RefillBitstreamCache(BitStreamInfo *bsi) -{ - int nBytes = bsi->nBytes; - - /* optimize for common case, independent of machine endian-ness */ - if (nBytes >= 4) { - bsi->iCache = (*bsi->bytePtr++) << 24; - bsi->iCache |= (*bsi->bytePtr++) << 16; - bsi->iCache |= (*bsi->bytePtr++) << 8; - bsi->iCache |= (*bsi->bytePtr++); - bsi->cachedBits = 32; - bsi->nBytes -= 4; - } else { - bsi->iCache = 0; - while (nBytes--) { - bsi->iCache |= (*bsi->bytePtr++); - bsi->iCache <<= 8; - } - bsi->iCache <<= ((3 - bsi->nBytes)*8); - bsi->cachedBits = 8*bsi->nBytes; - bsi->nBytes = 0; - } -} - -/************************************************************************************** - * Function: GetBits - * - * Description: get bits from bitstream, advance bitstream pointer - * - * Inputs: pointer to initialized BitStreamInfo struct - * number of bits to get from bitstream - * - * Outputs: updated bitstream info struct - * - * Return: the next nBits bits of data from bitstream buffer - * - * Notes: nBits must be in range [0, 31], nBits outside this range masked by 0x1f - * for speed, does not indicate error if you overrun bit buffer - * if nBits = 0, returns 0 (useful for scalefactor unpacking) - * - * TODO: optimize for ARM - **************************************************************************************/ -unsigned int GetBits(BitStreamInfo *bsi, int nBits) -{ - unsigned int data, lowBits; - - nBits &= 0x1f; /* nBits mod 32 to avoid unpredictable results like >> by negative amount */ - data = bsi->iCache >> (31 - nBits); /* unsigned >> so zero-extend */ - data >>= 1; /* do as >> 31, >> 1 so that nBits = 0 works okay (returns 0) */ - bsi->iCache <<= nBits; /* left-justify cache */ - bsi->cachedBits -= nBits; /* how many bits have we drawn from the cache so far */ - - /* if we cross an int boundary, refill the cache */ - if (bsi->cachedBits < 0) { - lowBits = -bsi->cachedBits; - RefillBitstreamCache(bsi); - data |= bsi->iCache >> (32 - lowBits); /* get the low-order bits */ - - bsi->cachedBits -= lowBits; /* how many bits have we drawn from the cache so far */ - bsi->iCache <<= lowBits; /* left-justify cache */ - } - - return data; -} - -/************************************************************************************** - * Function: CalcBitsUsed - * - * Description: calculate how many bits have been read from bitstream - * - * Inputs: pointer to initialized BitStreamInfo struct - * pointer to start of bitstream buffer - * bit offset into first byte of startBuf (0-7) - * - * Outputs: none - * - * Return: number of bits read from bitstream, as offset from startBuf:startOffset - **************************************************************************************/ -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset) -{ - int bitsUsed; - - bitsUsed = (bsi->bytePtr - startBuf) * 8; - bitsUsed -= bsi->cachedBits; - bitsUsed -= startOffset; - - return bitsUsed; -} - -/************************************************************************************** - * Function: CheckPadBit - * - * Description: check whether padding byte is present in an MP3 frame - * - * Inputs: MP3DecInfo struct with valid FrameHeader struct - * (filled by UnpackFrameHeader()) - * - * Outputs: none - * - * Return: 1 if pad bit is set, 0 if not, -1 if null input pointer - **************************************************************************************/ -int CheckPadBit(MP3DecInfo *mp3DecInfo) -{ - FrameHeader *fh; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS) - return -1; - - fh = ((FrameHeader *)(mp3DecInfo->FrameHeaderPS)); - - return (fh->paddingBit ? 1 : 0); -} - -/************************************************************************************** - * Function: UnpackFrameHeader - * - * Description: parse the fields of the MP3 frame header - * - * Inputs: buffer pointing to a complete MP3 frame header (4 bytes, plus 2 if CRC) - * - * Outputs: filled frame header info in the MP3DecInfo structure - * updated platform-specific FrameHeader struct - * - * Return: length (in bytes) of frame header (for caller to calculate offset to - * first byte following frame header) - * -1 if null frameHeader or invalid header - * - * TODO: check for valid modes, depending on capabilities of decoder - * test CRC on actual stream (verify no endian problems) - **************************************************************************************/ -int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf) -{ - - int verIdx; - FrameHeader *fh; - - /* validate pointers and sync word */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || (buf[0] & SYNCWORDH) != SYNCWORDH || (buf[1] & SYNCWORDL) != SYNCWORDL) - return -1; - - fh = ((FrameHeader *)(mp3DecInfo->FrameHeaderPS)); - - /* read header fields - use bitmasks instead of GetBits() for speed, since format never varies */ - verIdx = (buf[1] >> 3) & 0x03; - fh->ver = (MPEGVersion)( verIdx == 0 ? MPEG25 : ((verIdx & 0x01) ? MPEG1 : MPEG2) ); - fh->layer = 4 - ((buf[1] >> 1) & 0x03); /* easy mapping of index to layer number, 4 = error */ - fh->crc = 1 - ((buf[1] >> 0) & 0x01); - fh->brIdx = (buf[2] >> 4) & 0x0f; - fh->srIdx = (buf[2] >> 2) & 0x03; - fh->paddingBit = (buf[2] >> 1) & 0x01; - fh->privateBit = (buf[2] >> 0) & 0x01; - fh->sMode = (StereoMode)((buf[3] >> 6) & 0x03); /* maps to correct enum (see definition) */ - fh->modeExt = (buf[3] >> 4) & 0x03; - fh->copyFlag = (buf[3] >> 3) & 0x01; - fh->origFlag = (buf[3] >> 2) & 0x01; - fh->emphasis = (buf[3] >> 0) & 0x03; - - /* check parameters to avoid indexing tables with bad values */ - if (fh->srIdx == 3 || fh->layer == 4 || fh->brIdx == 15) - return -1; - - fh->sfBand = &sfBandTable[fh->ver][fh->srIdx]; /* for readability (we reference sfBandTable many times in decoder) */ - if (fh->sMode != Joint) /* just to be safe (dequant, stproc check fh->modeExt) */ - fh->modeExt = 0; - - /* init user-accessible data */ - mp3DecInfo->nChans = (fh->sMode == Mono ? 1 : 2); - mp3DecInfo->samprate = samplerateTab[fh->ver][fh->srIdx]; - mp3DecInfo->nGrans = (fh->ver == MPEG1 ? NGRANS_MPEG1 : NGRANS_MPEG2); - mp3DecInfo->nGranSamps = ((int)samplesPerFrameTab[fh->ver][fh->layer - 1]) / mp3DecInfo->nGrans; - mp3DecInfo->layer = fh->layer; - mp3DecInfo->version = fh->ver; - - /* get bitrate and nSlots from table, unless brIdx == 0 (free mode) in which case caller must figure it out himself - * question - do we want to overwrite mp3DecInfo->bitrate with 0 each time if it's free mode, and - * copy the pre-calculated actual free bitrate into it in mp3dec.c (according to the spec, - * this shouldn't be necessary, since it should be either all frames free or none free) - */ - if (fh->brIdx) { - mp3DecInfo->bitrate = ((int)bitrateTab[fh->ver][fh->layer - 1][fh->brIdx]) * 1000; - - /* nSlots = total frame bytes (from table) - sideInfo bytes - header - CRC (if present) + pad (if present) */ - mp3DecInfo->nSlots = (int)slotTab[fh->ver][fh->srIdx][fh->brIdx] - - (int)sideBytesTab[fh->ver][(fh->sMode == Mono ? 0 : 1)] - - 4 - (fh->crc ? 2 : 0) + (fh->paddingBit ? 1 : 0); - } - - /* load crc word, if enabled, and return length of frame header (in bytes) */ - if (fh->crc) { - fh->CRCWord = ((int)buf[4] << 8 | (int)buf[5] << 0); - return 6; - } else { - fh->CRCWord = 0; - return 4; - } -} - -/************************************************************************************** - * Function: UnpackSideInfo - * - * Description: parse the fields of the MP3 side info header - * - * Inputs: MP3DecInfo structure filled by UnpackFrameHeader() - * buffer pointing to the MP3 side info data - * - * Outputs: updated mainDataBegin in MP3DecInfo struct - * updated private (platform-specific) SideInfo struct - * - * Return: length (in bytes) of side info data - * -1 if null input pointers - **************************************************************************************/ -int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf) -{ - int gr, ch, bd, nBytes; - BitStreamInfo bitStreamInfo, *bsi; - FrameHeader *fh; - SideInfo *si; - SideInfoSub *sis; - - /* validate pointers and sync word */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS) - return -1; - - fh = ((FrameHeader *)(mp3DecInfo->FrameHeaderPS)); - si = ((SideInfo *)(mp3DecInfo->SideInfoPS)); - - bsi = &bitStreamInfo; - if (fh->ver == MPEG1) { - /* MPEG 1 */ - nBytes = (fh->sMode == Mono ? SIBYTES_MPEG1_MONO : SIBYTES_MPEG1_STEREO); - SetBitstreamPointer(bsi, nBytes, buf); - si->mainDataBegin = GetBits(bsi, 9); - si->privateBits = GetBits(bsi, (fh->sMode == Mono ? 5 : 3)); - - for (ch = 0; ch < mp3DecInfo->nChans; ch++) - for (bd = 0; bd < MAX_SCFBD; bd++) - si->scfsi[ch][bd] = GetBits(bsi, 1); - } else { - /* MPEG 2, MPEG 2.5 */ - nBytes = (fh->sMode == Mono ? SIBYTES_MPEG2_MONO : SIBYTES_MPEG2_STEREO); - SetBitstreamPointer(bsi, nBytes, buf); - si->mainDataBegin = GetBits(bsi, 8); - si->privateBits = GetBits(bsi, (fh->sMode == Mono ? 1 : 2)); - } - - for(gr =0; gr < mp3DecInfo->nGrans; gr++) { - for (ch = 0; ch < mp3DecInfo->nChans; ch++) { - sis = &si->sis[gr][ch]; /* side info subblock for this granule, channel */ - - sis->part23Length = GetBits(bsi, 12); - sis->nBigvals = GetBits(bsi, 9); - sis->globalGain = GetBits(bsi, 8); - sis->sfCompress = GetBits(bsi, (fh->ver == MPEG1 ? 4 : 9)); - sis->winSwitchFlag = GetBits(bsi, 1); - - if(sis->winSwitchFlag) { - /* this is a start, stop, short, or mixed block */ - sis->blockType = GetBits(bsi, 2); /* 0 = normal, 1 = start, 2 = short, 3 = stop */ - sis->mixedBlock = GetBits(bsi, 1); /* 0 = not mixed, 1 = mixed */ - sis->tableSelect[0] = GetBits(bsi, 5); - sis->tableSelect[1] = GetBits(bsi, 5); - sis->tableSelect[2] = 0; /* unused */ - sis->subBlockGain[0] = GetBits(bsi, 3); - sis->subBlockGain[1] = GetBits(bsi, 3); - sis->subBlockGain[2] = GetBits(bsi, 3); - - /* TODO - check logic */ - if (sis->blockType == 0) { - /* this should not be allowed, according to spec */ - sis->nBigvals = 0; - sis->part23Length = 0; - sis->sfCompress = 0; - } else if (sis->blockType == 2 && sis->mixedBlock == 0) { - /* short block, not mixed */ - sis->region0Count = 8; - } else { - /* start, stop, or short-mixed */ - sis->region0Count = 7; - } - sis->region1Count = 20 - sis->region0Count; - } else { - /* this is a normal block */ - sis->blockType = 0; - sis->mixedBlock = 0; - sis->tableSelect[0] = GetBits(bsi, 5); - sis->tableSelect[1] = GetBits(bsi, 5); - sis->tableSelect[2] = GetBits(bsi, 5); - sis->region0Count = GetBits(bsi, 4); - sis->region1Count = GetBits(bsi, 3); - } - sis->preFlag = (fh->ver == MPEG1 ? GetBits(bsi, 1) : 0); - sis->sfactScale = GetBits(bsi, 1); - sis->count1TableSelect = GetBits(bsi, 1); - } - } - mp3DecInfo->mainDataBegin = si->mainDataBegin; /* needed by main decode loop */ - - ASSERT(nBytes == CalcBitsUsed(bsi, buf, 0) >> 3); - - return nBytes; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/buffers.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/buffers.c deleted file mode 100644 index 52b9bcf7..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/buffers.c +++ /dev/null @@ -1,177 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * buffers.c - allocation and freeing of internal MP3 decoder buffers - * - * All memory allocation for the codec is done in this file, so if you don't want - * to use other the default system malloc() and free() for heap management this is - * the only file you'll need to change. - **************************************************************************************/ - -//#include "hlxclib/stdlib.h" /* for malloc, free */ -#include -#include -#include "coder.h" - -/************************************************************************************** - * Function: ClearBuffer - * - * Description: fill buffer with 0's - * - * Inputs: pointer to buffer - * number of bytes to fill with 0 - * - * Outputs: cleared buffer - * - * Return: none - * - * Notes: slow, platform-independent equivalent to memset(buf, 0, nBytes) - **************************************************************************************/ -#define ClearBuffer(buf, nBytes) memset(buf, 0, nBytes) //fb -/* -static void ClearBuffer(void *buf, int nBytes) -{ - int i; - unsigned char *cbuf = (unsigned char *)buf; - - for (i = 0; i < nBytes; i++) - cbuf[i] = 0; - - //fb - memset(buf, 0, nBytes) - - return; -} -*/ -/************************************************************************************** - * Function: AllocateBuffers - * - * Description: allocate all the memory needed for the MP3 decoder - * - * Inputs: none - * - * Outputs: none - * - * Return: pointer to MP3DecInfo structure (initialized with pointers to all - * the internal buffers needed for decoding, all other members of - * MP3DecInfo structure set to 0) - * - * Notes: if one or more mallocs fail, function frees any buffers already - * allocated before returning - **************************************************************************************/ -MP3DecInfo *AllocateBuffers(void) -{ - MP3DecInfo *mp3DecInfo; - FrameHeader *fh; - SideInfo *si; - ScaleFactorInfo *sfi; - HuffmanInfo *hi; - DequantInfo *di; - IMDCTInfo *mi; - SubbandInfo *sbi; - - mp3DecInfo = (MP3DecInfo *)malloc(sizeof(MP3DecInfo)); - if (!mp3DecInfo) - return 0; - ClearBuffer(mp3DecInfo, sizeof(MP3DecInfo)); - - fh = (FrameHeader *) malloc(sizeof(FrameHeader)); - si = (SideInfo *) malloc(sizeof(SideInfo)); - sfi = (ScaleFactorInfo *) malloc(sizeof(ScaleFactorInfo)); - hi = (HuffmanInfo *) malloc(sizeof(HuffmanInfo)); - di = (DequantInfo *) malloc(sizeof(DequantInfo)); - mi = (IMDCTInfo *) malloc(sizeof(IMDCTInfo)); - sbi = (SubbandInfo *) malloc(sizeof(SubbandInfo)); - - mp3DecInfo->FrameHeaderPS = (void *)fh; - mp3DecInfo->SideInfoPS = (void *)si; - mp3DecInfo->ScaleFactorInfoPS = (void *)sfi; - mp3DecInfo->HuffmanInfoPS = (void *)hi; - mp3DecInfo->DequantInfoPS = (void *)di; - mp3DecInfo->IMDCTInfoPS = (void *)mi; - mp3DecInfo->SubbandInfoPS = (void *)sbi; - - if (!fh || !si || !sfi || !hi || !di || !mi || !sbi) { - FreeBuffers(mp3DecInfo); /* safe to call - only frees memory that was successfully allocated */ - return 0; - } - - /* important to do this - DSP primitives assume a bunch of state variables are 0 on first use */ - ClearBuffer(fh, sizeof(FrameHeader)); - ClearBuffer(si, sizeof(SideInfo)); - ClearBuffer(sfi, sizeof(ScaleFactorInfo)); - ClearBuffer(hi, sizeof(HuffmanInfo)); - ClearBuffer(di, sizeof(DequantInfo)); - ClearBuffer(mi, sizeof(IMDCTInfo)); - ClearBuffer(sbi, sizeof(SubbandInfo)); - - return mp3DecInfo; -} - -#define SAFE_FREE(x) {if (x) free(x); (x) = 0;} /* helper macro */ - -/************************************************************************************** - * Function: FreeBuffers - * - * Description: frees all the memory used by the MP3 decoder - * - * Inputs: pointer to initialized MP3DecInfo structure - * - * Outputs: none - * - * Return: none - * - * Notes: safe to call even if some buffers were not allocated (uses SAFE_FREE) - **************************************************************************************/ -void FreeBuffers(MP3DecInfo *mp3DecInfo) -{ - if (!mp3DecInfo) - return; - - SAFE_FREE(mp3DecInfo->FrameHeaderPS); - SAFE_FREE(mp3DecInfo->SideInfoPS); - SAFE_FREE(mp3DecInfo->ScaleFactorInfoPS); - SAFE_FREE(mp3DecInfo->HuffmanInfoPS); - SAFE_FREE(mp3DecInfo->DequantInfoPS); - SAFE_FREE(mp3DecInfo->IMDCTInfoPS); - SAFE_FREE(mp3DecInfo->SubbandInfoPS); - - SAFE_FREE(mp3DecInfo); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/coder.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/coder.h deleted file mode 100644 index 5cc3ae43..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/coder.h +++ /dev/null @@ -1,309 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * coder.h - private, implementation-specific header file - **************************************************************************************/ - -#ifndef _CODER_H -#define _CODER_H - -#pragma GCC optimize ("O3") - -#include "mp3common.h" - -#if defined(ASSERT) -#undef ASSERT -#endif -#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS)) -#define ASSERT(x) if (!(x)) __asm int 3; -#else -#define ASSERT(x) /* do nothing */ -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -/* clip to range [-2^n, 2^n - 1] */ -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (n)) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} - -#define SIBYTES_MPEG1_MONO 17 -#define SIBYTES_MPEG1_STEREO 32 -#define SIBYTES_MPEG2_MONO 9 -#define SIBYTES_MPEG2_STEREO 17 - -/* number of fraction bits for pow43Tab (see comments there) */ -#define POW43_FRACBITS_LOW 22 -#define POW43_FRACBITS_HIGH 12 - -#define DQ_FRACBITS_OUT 25 /* number of fraction bits in output of dequant */ -#define IMDCT_SCALE 2 /* additional scaling (by sqrt(2)) for fast IMDCT36 */ - -#define HUFF_PAIRTABS 32 -#define BLOCK_SIZE 18 -#define NBANDS 32 -#define MAX_REORDER_SAMPS ((192-126)*3) /* largest critical band for short blocks (see sfBandTable) */ -#define VBUF_LENGTH (17 * 2 * NBANDS) /* for double-sized vbuf FIFO */ - -/* additional external symbols to name-mangle for static linking */ -#define SetBitstreamPointer STATNAME(SetBitstreamPointer) -#define GetBits STATNAME(GetBits) -#define CalcBitsUsed STATNAME(CalcBitsUsed) -#define DequantChannel STATNAME(DequantChannel) -#define MidSideProc STATNAME(MidSideProc) -#define IntensityProcMPEG1 STATNAME(IntensityProcMPEG1) -#define IntensityProcMPEG2 STATNAME(IntensityProcMPEG2) -#define PolyphaseMono STATNAME(PolyphaseMono) -#define PolyphaseStereo STATNAME(PolyphaseStereo) -#define FDCT32 STATNAME(FDCT32) - -#define ISFMpeg1 STATNAME(ISFMpeg1) -#define ISFMpeg2 STATNAME(ISFMpeg2) -#define ISFIIP STATNAME(ISFIIP) -#define uniqueIDTab STATNAME(uniqueIDTab) -#define coef32 STATNAME(coef32) -#define polyCoef STATNAME(polyCoef) -#define csa STATNAME(csa) -#define imdctWin STATNAME(imdctWin) - -#define huffTable STATNAME(huffTable) -#define huffTabOffset STATNAME(huffTabOffset) -#define huffTabLookup STATNAME(huffTabLookup) -#define quadTable STATNAME(quadTable) -#define quadTabOffset STATNAME(quadTabOffset) -#define quadTabMaxBits STATNAME(quadTabMaxBits) - -/* map these to the corresponding 2-bit values in the frame header */ -typedef enum { - Stereo = 0x00, /* two independent channels, but L and R frames might have different # of bits */ - Joint = 0x01, /* coupled channels - layer III: mix of M-S and intensity, Layers I/II: intensity and direct coding only */ - Dual = 0x02, /* two independent channels, L and R always have exactly 1/2 the total bitrate */ - Mono = 0x03 /* one channel */ -} StereoMode; - -typedef struct _BitStreamInfo { - unsigned char *bytePtr; - unsigned int iCache; - int cachedBits; - int nBytes; -} BitStreamInfo; - -typedef struct _FrameHeader { - MPEGVersion ver; /* version ID */ - int layer; /* layer index (1, 2, or 3) */ - int crc; /* CRC flag: 0 = disabled, 1 = enabled */ - int brIdx; /* bitrate index (0 - 15) */ - int srIdx; /* sample rate index (0 - 2) */ - int paddingBit; /* padding flag: 0 = no padding, 1 = single pad byte */ - int privateBit; /* unused */ - StereoMode sMode; /* mono/stereo mode */ - int modeExt; /* used to decipher joint stereo mode */ - int copyFlag; /* copyright flag: 0 = no, 1 = yes */ - int origFlag; /* original flag: 0 = copy, 1 = original */ - int emphasis; /* deemphasis mode */ - int CRCWord; /* CRC word (16 bits, 0 if crc not enabled) */ - - const SFBandTable *sfBand; -} FrameHeader; - -typedef struct _SideInfoSub { - int part23Length; /* number of bits in main data */ - int nBigvals; /* 2x this = first set of Huffman cw's (maximum amplitude can be > 1) */ - int globalGain; /* overall gain for dequantizer */ - int sfCompress; /* unpacked to figure out number of bits in scale factors */ - int winSwitchFlag; /* window switching flag */ - int blockType; /* block type */ - int mixedBlock; /* 0 = regular block (all short or long), 1 = mixed block */ - int tableSelect[3]; /* index of Huffman tables for the big values regions */ - int subBlockGain[3]; /* subblock gain offset, relative to global gain */ - int region0Count; /* 1+region0Count = num scale factor bands in first region of bigvals */ - int region1Count; /* 1+region1Count = num scale factor bands in second region of bigvals */ - int preFlag; /* for optional high frequency boost */ - int sfactScale; /* scaling of the scalefactors */ - int count1TableSelect; /* index of Huffman table for quad codewords */ -} SideInfoSub; - -typedef struct _SideInfo { - int mainDataBegin; - int privateBits; - int scfsi[MAX_NCHAN][MAX_SCFBD]; /* 4 scalefactor bands per channel */ - - SideInfoSub sis[MAX_NGRAN][MAX_NCHAN]; -} SideInfo; - -typedef struct { - int cbType; /* pure long = 0, pure short = 1, mixed = 2 */ - int cbEndS[3]; /* number nonzero short cb's, per subbblock */ - int cbEndSMax; /* max of cbEndS[] */ - int cbEndL; /* number nonzero long cb's */ -} CriticalBandInfo; - -typedef struct _DequantInfo { - int workBuf[MAX_REORDER_SAMPS]; /* workbuf for reordering short blocks */ - CriticalBandInfo cbi[MAX_NCHAN]; /* filled in dequantizer, used in joint stereo reconstruction */ -} DequantInfo; - -typedef struct _HuffmanInfo { - int huffDecBuf[MAX_NCHAN][MAX_NSAMP]; /* used both for decoded Huffman values and dequantized coefficients */ - int nonZeroBound[MAX_NCHAN]; /* number of coeffs in huffDecBuf[ch] which can be > 0 */ - int gb[MAX_NCHAN]; /* minimum number of guard bits in huffDecBuf[ch] */ -} HuffmanInfo; - -typedef enum _HuffTabType { - noBits, - oneShot, - loopNoLinbits, - loopLinbits, - quadA, - quadB, - invalidTab -} HuffTabType; - -typedef struct _HuffTabLookup { - int linBits; - int /*HuffTabType*/ tabType; -} HuffTabLookup; - -typedef struct _IMDCTInfo { - int outBuf[MAX_NCHAN][BLOCK_SIZE][NBANDS]; /* output of IMDCT */ - int overBuf[MAX_NCHAN][MAX_NSAMP / 2]; /* overlap-add buffer (by symmetry, only need 1/2 size) */ - int numPrevIMDCT[MAX_NCHAN]; /* how many IMDCT's calculated in this channel on prev. granule */ - int prevType[MAX_NCHAN]; - int prevWinSwitch[MAX_NCHAN]; - int gb[MAX_NCHAN]; -} IMDCTInfo; - -typedef struct _BlockCount { - int nBlocksLong; - int nBlocksTotal; - int nBlocksPrev; - int prevType; - int prevWinSwitch; - int currWinSwitch; - int gbIn; - int gbOut; -} BlockCount; - -/* max bits in scalefactors = 5, so use char's to save space */ -typedef struct _ScaleFactorInfoSub { - char l[23]; /* [band] */ - char s[13][3]; /* [band][window] */ -} ScaleFactorInfoSub; - -/* used in MPEG 2, 2.5 intensity (joint) stereo only */ -typedef struct _ScaleFactorJS { - int intensityScale; - int slen[4]; - int nr[4]; -} ScaleFactorJS; - -typedef struct _ScaleFactorInfo { - ScaleFactorInfoSub sfis[MAX_NGRAN][MAX_NCHAN]; - ScaleFactorJS sfjs; -} ScaleFactorInfo; - -/* NOTE - could get by with smaller vbuf if memory is more important than speed - * (in Subband, instead of replicating each block in FDCT32 you would do a memmove on the - * last 15 blocks to shift them down one, a hardware style FIFO) - */ -typedef struct _SubbandInfo { - int vbuf[MAX_NCHAN * VBUF_LENGTH]; /* vbuf for fast DCT-based synthesis PQMF - double size for speed (no modulo indexing) */ - int vindex; /* internal index for tracking position in vbuf */ -} SubbandInfo; - -/* bitstream.c */ -void SetBitstreamPointer(BitStreamInfo *bsi, int nBytes, unsigned char *buf); -unsigned int GetBits(BitStreamInfo *bsi, int nBits); -int CalcBitsUsed(BitStreamInfo *bsi, unsigned char *startBuf, int startOffset); - -/* dequant.c, dqchan.c, stproc.c */ -int DequantChannel(int *sampleBuf, int *workBuf, int *nonZeroBound, FrameHeader *fh, SideInfoSub *sis, - ScaleFactorInfoSub *sfis, CriticalBandInfo *cbi); -void MidSideProc(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, int mOut[2]); -void IntensityProcMPEG1(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, FrameHeader *fh, ScaleFactorInfoSub *sfis, - CriticalBandInfo *cbi, int midSideFlag, int mixFlag, int mOut[2]); -void IntensityProcMPEG2(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, FrameHeader *fh, ScaleFactorInfoSub *sfis, - CriticalBandInfo *cbi, ScaleFactorJS *sfjs, int midSideFlag, int mixFlag, int mOut[2]); - -/* dct32.c */ -// about 1 ms faster in RAM, but very large -void FDCT32(int *x, int *d, int offset, int oddBlock, int gb);// __attribute__ ((section (".data"))); - -/* hufftabs.c */ -extern const HuffTabLookup huffTabLookup[HUFF_PAIRTABS]; -extern const int huffTabOffset[HUFF_PAIRTABS]; -extern const unsigned short huffTable[]; -extern const unsigned char quadTable[64+16]; -extern const int quadTabOffset[2]; -extern const int quadTabMaxBits[2]; - -/* polyphase.c (or asmpoly.s) - * some platforms require a C++ compile of all source files, - * so if we're compiling C as C++ and using native assembly - * for these functions we need to prevent C++ name mangling. - */ -#ifdef __cplusplus -extern "C" { -#endif -void PolyphaseMono(short *pcm, int *vbuf, const int *coefBase); -void PolyphaseStereo(short *pcm, int *vbuf, const int *coefBase); -#ifdef __cplusplus -} -#endif - -/* trigtabs.c */ -extern const int imdctWin[4][36]; -extern const int ISFMpeg1[2][7]; -extern const int ISFMpeg2[2][2][16]; -extern const int ISFIIP[2][2]; -extern const int csa[8][2]; -extern const int coef32[31]; -extern const int polyCoef[264]; - -#endif /* _CODER_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dct32.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dct32.c deleted file mode 100644 index 4dacff7f..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dct32.c +++ /dev/null @@ -1,280 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * dct32.c - optimized implementations of 32-point DCT for matrixing stage of - * polyphase filter - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define COS0_0 0x4013c251 /* Q31 */ -#define COS0_1 0x40b345bd /* Q31 */ -#define COS0_2 0x41fa2d6d /* Q31 */ -#define COS0_3 0x43f93421 /* Q31 */ -#define COS0_4 0x46cc1bc4 /* Q31 */ -#define COS0_5 0x4a9d9cf0 /* Q31 */ -#define COS0_6 0x4fae3711 /* Q31 */ -#define COS0_7 0x56601ea7 /* Q31 */ -#define COS0_8 0x5f4cf6eb /* Q31 */ -#define COS0_9 0x6b6fcf26 /* Q31 */ -#define COS0_10 0x7c7d1db3 /* Q31 */ -#define COS0_11 0x4ad81a97 /* Q30 */ -#define COS0_12 0x5efc8d96 /* Q30 */ -#define COS0_13 0x41d95790 /* Q29 */ -#define COS0_14 0x6d0b20cf /* Q29 */ -#define COS0_15 0x518522fb /* Q27 */ - -#define COS1_0 0x404f4672 /* Q31 */ -#define COS1_1 0x42e13c10 /* Q31 */ -#define COS1_2 0x48919f44 /* Q31 */ -#define COS1_3 0x52cb0e63 /* Q31 */ -#define COS1_4 0x64e2402e /* Q31 */ -#define COS1_5 0x43e224a9 /* Q30 */ -#define COS1_6 0x6e3c92c1 /* Q30 */ -#define COS1_7 0x519e4e04 /* Q28 */ - -#define COS2_0 0x4140fb46 /* Q31 */ -#define COS2_1 0x4cf8de88 /* Q31 */ -#define COS2_2 0x73326bbf /* Q31 */ -#define COS2_3 0x52036742 /* Q29 */ - -#define COS3_0 0x4545e9ef /* Q31 */ -#define COS3_1 0x539eba45 /* Q30 */ - -#define COS4_0 0x5a82799a /* Q31 */ - -// faster in ROM -static const int dcttab[48] PROGMEM = { - /* first pass */ - COS0_0, COS0_15, COS1_0, /* 31, 27, 31 */ - COS0_1, COS0_14, COS1_1, /* 31, 29, 31 */ - COS0_2, COS0_13, COS1_2, /* 31, 29, 31 */ - COS0_3, COS0_12, COS1_3, /* 31, 30, 31 */ - COS0_4, COS0_11, COS1_4, /* 31, 30, 31 */ - COS0_5, COS0_10, COS1_5, /* 31, 31, 30 */ - COS0_6, COS0_9, COS1_6, /* 31, 31, 30 */ - COS0_7, COS0_8, COS1_7, /* 31, 31, 28 */ - /* second pass */ - COS2_0, COS2_3, COS3_0, /* 31, 29, 31 */ - COS2_1, COS2_2, COS3_1, /* 31, 31, 30 */ - -COS2_0, -COS2_3, COS3_0, /* 31, 29, 31 */ - -COS2_1, -COS2_2, COS3_1, /* 31, 31, 30 */ - COS2_0, COS2_3, COS3_0, /* 31, 29, 31 */ - COS2_1, COS2_2, COS3_1, /* 31, 31, 30 */ - -COS2_0, -COS2_3, COS3_0, /* 31, 29, 31 */ - -COS2_1, -COS2_2, COS3_1, /* 31, 31, 30 */ -}; - -#define D32FP(i, s0, s1, s2) { \ - a0 = buf[i]; a3 = buf[31-i]; \ - a1 = buf[15-i]; a2 = buf[16+i]; \ - b0 = a0 + a3; b3 = MULSHIFT32(*cptr++, a0 - a3) << (s0); \ - b1 = a1 + a2; b2 = MULSHIFT32(*cptr++, a1 - a2) << (s1); \ - buf[i] = b0 + b1; buf[15-i] = MULSHIFT32(*cptr, b0 - b1) << (s2); \ - buf[16+i] = b2 + b3; buf[31-i] = MULSHIFT32(*cptr++, b3 - b2) << (s2); \ -} - -/************************************************************************************** - * Function: FDCT32 - * - * Description: Ken's highly-optimized 32-point DCT (radix-4 + radix-8) - * - * Inputs: input buffer, length = 32 samples - * require at least 6 guard bits in input vector x to avoid possibility - * of overflow in internal calculations (see bbtest_imdct test app) - * buffer offset and oddblock flag for polyphase filter input buffer - * number of guard bits in input - * - * Outputs: output buffer, data copied and interleaved for polyphase filter - * no guarantees about number of guard bits in output - * - * Return: none - * - * Notes: number of muls = 4*8 + 12*4 = 80 - * final stage of DCT is hardcoded to shuffle data into the proper order - * for the polyphase filterbank - * fully unrolled stage 1, for max precision (scale the 1/cos() factors - * differently, depending on magnitude) - * guard bit analysis verified by exhaustive testing of all 2^32 - * combinations of max pos/max neg values in x[] - * - * TODO: code organization and optimization for ARM - * possibly interleave stereo (cut # of coef loads in half - may not have - * enough registers) - **************************************************************************************/ -// about 1ms faster in RAM -/* attribute__ ((section (".data"))) */ void FDCT32(int *buf, int *dest, int offset, int oddBlock, int gb) -{ - int i, s, tmp, es; - const int *cptr = dcttab; - int a0, a1, a2, a3, a4, a5, a6, a7; - int b0, b1, b2, b3, b4, b5, b6, b7; - int *d; - - /* scaling - ensure at least 6 guard bits for DCT - * (in practice this is already true 99% of time, so this code is - * almost never triggered) - */ - es = 0; - if (gb < 6) { - es = 6 - gb; - for (i = 0; i < 32; i++) - buf[i] >>= es; - } - - /* first pass */ - D32FP(0, 1, 5, 1); - D32FP(1, 1, 3, 1); - D32FP(2, 1, 3, 1); - D32FP(3, 1, 2, 1); - D32FP(4, 1, 2, 1); - D32FP(5, 1, 1, 2); - D32FP(6, 1, 1, 2); - D32FP(7, 1, 1, 4); - - /* second pass */ - for (i = 4; i > 0; i--) { - a0 = buf[0]; a7 = buf[7]; a3 = buf[3]; a4 = buf[4]; - b0 = a0 + a7; b7 = MULSHIFT32(*cptr++, a0 - a7) << 1; - b3 = a3 + a4; b4 = MULSHIFT32(*cptr++, a3 - a4) << 3; - a0 = b0 + b3; a3 = MULSHIFT32(*cptr, b0 - b3) << 1; - a4 = b4 + b7; a7 = MULSHIFT32(*cptr++, b7 - b4) << 1; - - a1 = buf[1]; a6 = buf[6]; a2 = buf[2]; a5 = buf[5]; - b1 = a1 + a6; b6 = MULSHIFT32(*cptr++, a1 - a6) << 1; - b2 = a2 + a5; b5 = MULSHIFT32(*cptr++, a2 - a5) << 1; - a1 = b1 + b2; a2 = MULSHIFT32(*cptr, b1 - b2) << 2; - a5 = b5 + b6; a6 = MULSHIFT32(*cptr++, b6 - b5) << 2; - - b0 = a0 + a1; b1 = MULSHIFT32(COS4_0, a0 - a1) << 1; - b2 = a2 + a3; b3 = MULSHIFT32(COS4_0, a3 - a2) << 1; - buf[0] = b0; buf[1] = b1; - buf[2] = b2 + b3; buf[3] = b3; - - b4 = a4 + a5; b5 = MULSHIFT32(COS4_0, a4 - a5) << 1; - b6 = a6 + a7; b7 = MULSHIFT32(COS4_0, a7 - a6) << 1; - b6 += b7; - buf[4] = b4 + b6; buf[5] = b5 + b7; - buf[6] = b5 + b6; buf[7] = b7; - - buf += 8; - } - buf -= 32; /* reset */ - - /* sample 0 - always delayed one block */ - d = dest + 64*16 + ((offset - oddBlock) & 7) + (oddBlock ? 0 : VBUF_LENGTH); - s = buf[ 0]; d[0] = d[8] = s; - - /* samples 16 to 31 */ - d = dest + offset + (oddBlock ? VBUF_LENGTH : 0); - - s = buf[ 1]; d[0] = d[8] = s; d += 64; - - tmp = buf[25] + buf[29]; - s = buf[17] + tmp; d[0] = d[8] = s; d += 64; - s = buf[ 9] + buf[13]; d[0] = d[8] = s; d += 64; - s = buf[21] + tmp; d[0] = d[8] = s; d += 64; - - tmp = buf[29] + buf[27]; - s = buf[ 5]; d[0] = d[8] = s; d += 64; - s = buf[21] + tmp; d[0] = d[8] = s; d += 64; - s = buf[13] + buf[11]; d[0] = d[8] = s; d += 64; - s = buf[19] + tmp; d[0] = d[8] = s; d += 64; - - tmp = buf[27] + buf[31]; - s = buf[ 3]; d[0] = d[8] = s; d += 64; - s = buf[19] + tmp; d[0] = d[8] = s; d += 64; - s = buf[11] + buf[15]; d[0] = d[8] = s; d += 64; - s = buf[23] + tmp; d[0] = d[8] = s; d += 64; - - tmp = buf[31]; - s = buf[ 7]; d[0] = d[8] = s; d += 64; - s = buf[23] + tmp; d[0] = d[8] = s; d += 64; - s = buf[15]; d[0] = d[8] = s; d += 64; - s = tmp; d[0] = d[8] = s; - - /* samples 16 to 1 (sample 16 used again) */ - d = dest + 16 + ((offset - oddBlock) & 7) + (oddBlock ? 0 : VBUF_LENGTH); - - s = buf[ 1]; d[0] = d[8] = s; d += 64; - - tmp = buf[30] + buf[25]; - s = buf[17] + tmp; d[0] = d[8] = s; d += 64; - s = buf[14] + buf[ 9]; d[0] = d[8] = s; d += 64; - s = buf[22] + tmp; d[0] = d[8] = s; d += 64; - s = buf[ 6]; d[0] = d[8] = s; d += 64; - - tmp = buf[26] + buf[30]; - s = buf[22] + tmp; d[0] = d[8] = s; d += 64; - s = buf[10] + buf[14]; d[0] = d[8] = s; d += 64; - s = buf[18] + tmp; d[0] = d[8] = s; d += 64; - s = buf[ 2]; d[0] = d[8] = s; d += 64; - - tmp = buf[28] + buf[26]; - s = buf[18] + tmp; d[0] = d[8] = s; d += 64; - s = buf[12] + buf[10]; d[0] = d[8] = s; d += 64; - s = buf[20] + tmp; d[0] = d[8] = s; d += 64; - s = buf[ 4]; d[0] = d[8] = s; d += 64; - - tmp = buf[24] + buf[28]; - s = buf[20] + tmp; d[0] = d[8] = s; d += 64; - s = buf[ 8] + buf[12]; d[0] = d[8] = s; d += 64; - s = buf[16] + tmp; d[0] = d[8] = s; - - /* this is so rarely invoked that it's not worth making two versions of the output - * shuffle code (one for no shift, one for clip + variable shift) like in IMDCT - * here we just load, clip, shift, and store on the rare instances that es != 0 - */ - if (es) { - d = dest + 64*16 + ((offset - oddBlock) & 7) + (oddBlock ? 0 : VBUF_LENGTH); - s = d[0]; CLIP_2N(s, 31 - es); d[0] = d[8] = (s << es); - - d = dest + offset + (oddBlock ? VBUF_LENGTH : 0); - for (i = 16; i <= 31; i++) { - s = d[0]; CLIP_2N(s, 31 - es); d[0] = d[8] = (s << es); d += 64; - } - - d = dest + 16 + ((offset - oddBlock) & 7) + (oddBlock ? 0 : VBUF_LENGTH); - for (i = 15; i >= 0; i--) { - s = d[0]; CLIP_2N(s, 31 - es); d[0] = d[8] = (s << es); d += 64; - } - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dequant.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dequant.c deleted file mode 100644 index b989b7de..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dequant.c +++ /dev/null @@ -1,158 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * dequant.c - dequantization, stereo processing (intensity, mid-side), short-block - * coefficient reordering - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: Dequantize - * - * Description: dequantize coefficients, decode stereo, reorder short blocks - * (one granule-worth) - * - * Inputs: MP3DecInfo structure filled by UnpackFrameHeader(), UnpackSideInfo(), - * UnpackScaleFactors(), and DecodeHuffman() (for this granule) - * index of current granule - * - * Outputs: dequantized and reordered coefficients in hi->huffDecBuf - * (one granule-worth, all channels), format = Q26 - * operates in-place on huffDecBuf but also needs di->workBuf - * updated hi->nonZeroBound index for both channels - * - * Return: 0 on success, -1 if null input pointers - * - * Notes: In calling output Q(DQ_FRACBITS_OUT), we assume an implicit bias - * of 2^15. Some (floating-point) reference implementations factor this - * into the 2^(0.25 * gain) scaling explicitly. But to avoid precision - * loss, we don't do that. Instead take it into account in the final - * round to PCM (>> by 15 less than we otherwise would have). - * Equivalently, we can think of the dequantized coefficients as - * Q(DQ_FRACBITS_OUT - 15) with no implicit bias. - **************************************************************************************/ -int Dequantize(MP3DecInfo *mp3DecInfo, int gr) -{ - int i, ch, nSamps, mOut[2]; - FrameHeader *fh; - SideInfo *si; - ScaleFactorInfo *sfi; - HuffmanInfo *hi; - DequantInfo *di; - CriticalBandInfo *cbi; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS || !mp3DecInfo->ScaleFactorInfoPS || - !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->DequantInfoPS) - return -1; - - fh = (FrameHeader *)(mp3DecInfo->FrameHeaderPS); - - /* si is an array of up to 4 structs, stored as gr0ch0, gr0ch1, gr1ch0, gr1ch1 */ - si = (SideInfo *)(mp3DecInfo->SideInfoPS); - sfi = (ScaleFactorInfo *)(mp3DecInfo->ScaleFactorInfoPS); - hi = (HuffmanInfo *)mp3DecInfo->HuffmanInfoPS; - di = (DequantInfo *)mp3DecInfo->DequantInfoPS; - cbi = di->cbi; - mOut[0] = mOut[1] = 0; - - /* dequantize all the samples in each channel */ - for (ch = 0; ch < mp3DecInfo->nChans; ch++) { - hi->gb[ch] = DequantChannel(hi->huffDecBuf[ch], di->workBuf, &hi->nonZeroBound[ch], fh, - &si->sis[gr][ch], &sfi->sfis[gr][ch], &cbi[ch]); - } - - /* joint stereo processing assumes one guard bit in input samples - * it's extremely rare not to have at least one gb, so if this is the case - * just make a pass over the data and clip to [-2^30+1, 2^30-1] - * in practice this may never happen - */ - if (fh->modeExt && (hi->gb[0] < 1 || hi->gb[1] < 1)) { - for (i = 0; i < hi->nonZeroBound[0]; i++) { - if (hi->huffDecBuf[0][i] < -0x3fffffff) hi->huffDecBuf[0][i] = -0x3fffffff; - if (hi->huffDecBuf[0][i] > 0x3fffffff) hi->huffDecBuf[0][i] = 0x3fffffff; - } - for (i = 0; i < hi->nonZeroBound[1]; i++) { - if (hi->huffDecBuf[1][i] < -0x3fffffff) hi->huffDecBuf[1][i] = -0x3fffffff; - if (hi->huffDecBuf[1][i] > 0x3fffffff) hi->huffDecBuf[1][i] = 0x3fffffff; - } - } - - /* do mid-side stereo processing, if enabled */ - if (fh->modeExt >> 1) { - if (fh->modeExt & 0x01) { - /* intensity stereo enabled - run mid-side up to start of right zero region */ - if (cbi[1].cbType == 0) - nSamps = fh->sfBand->l[cbi[1].cbEndL + 1]; - else - nSamps = 3 * fh->sfBand->s[cbi[1].cbEndSMax + 1]; - } else { - /* intensity stereo disabled - run mid-side on whole spectrum */ - nSamps = MAX(hi->nonZeroBound[0], hi->nonZeroBound[1]); - } - MidSideProc(hi->huffDecBuf, nSamps, mOut); - } - - /* do intensity stereo processing, if enabled */ - if (fh->modeExt & 0x01) { - nSamps = hi->nonZeroBound[0]; - if (fh->ver == MPEG1) { - IntensityProcMPEG1(hi->huffDecBuf, nSamps, fh, &sfi->sfis[gr][1], di->cbi, - fh->modeExt >> 1, si->sis[gr][1].mixedBlock, mOut); - } else { - IntensityProcMPEG2(hi->huffDecBuf, nSamps, fh, &sfi->sfis[gr][1], di->cbi, &sfi->sfjs, - fh->modeExt >> 1, si->sis[gr][1].mixedBlock, mOut); - } - } - - /* adjust guard bit count and nonZeroBound if we did any stereo processing */ - if (fh->modeExt) { - hi->gb[0] = CLZ(mOut[0]) - 1; - hi->gb[1] = CLZ(mOut[1]) - 1; - nSamps = MAX(hi->nonZeroBound[0], hi->nonZeroBound[1]); - hi->nonZeroBound[0] = nSamps; - hi->nonZeroBound[1] = nSamps; - } - - /* output format Q(DQ_FRACBITS_OUT) */ - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dqchan.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dqchan.c deleted file mode 100644 index db88e11b..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/dqchan.c +++ /dev/null @@ -1,376 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * August 2003 - * - * dqchan.c - dequantization of transform coefficients - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -typedef int ARRAY3[3]; /* for short-block reordering */ - -/* optional pre-emphasis for high-frequency scale factor bands */ -static const char preTab[22] = { 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0 }; - -/* pow(2,-i/4) for i=0..3, Q31 format */ -const int pow14[4] PROGMEM = { - 0x7fffffff, 0x6ba27e65, 0x5a82799a, 0x4c1bf829 -}; - -/* pow(2,-i/4) * pow(j,4/3) for i=0..3 j=0..15, Q25 format */ -const int pow43_14[4][16] PROGMEM = { -{ 0x00000000, 0x10000000, 0x285145f3, 0x453a5cdb, /* Q28 */ - 0x0cb2ff53, 0x111989d6, 0x15ce31c8, 0x1ac7f203, - 0x20000000, 0x257106b9, 0x2b16b4a3, 0x30ed74b4, - 0x36f23fa5, 0x3d227bd3, 0x437be656, 0x49fc823c, }, - -{ 0x00000000, 0x0d744fcd, 0x21e71f26, 0x3a36abd9, - 0x0aadc084, 0x0e610e6e, 0x12560c1d, 0x168523cf, - 0x1ae89f99, 0x1f7c03a4, 0x243bae49, 0x29249c67, - 0x2e34420f, 0x33686f85, 0x38bf3dff, 0x3e370182, }, - -{ 0x00000000, 0x0b504f33, 0x1c823e07, 0x30f39a55, - 0x08facd62, 0x0c176319, 0x0f6b3522, 0x12efe2ad, - 0x16a09e66, 0x1a79a317, 0x1e77e301, 0x2298d5b4, - 0x26da56fc, 0x2b3a902a, 0x2fb7e7e7, 0x3450f650, }, - -{ 0x00000000, 0x09837f05, 0x17f910d7, 0x2929c7a9, - 0x078d0dfa, 0x0a2ae661, 0x0cf73154, 0x0fec91cb, - 0x1306fe0a, 0x16434a6c, 0x199ee595, 0x1d17ae3d, - 0x20abd76a, 0x2459d551, 0x28204fbb, 0x2bfe1808, }, -}; - -/* pow(j,4/3) for j=16..63, Q23 format */ -const int pow43[] PROGMEM = { - 0x1428a2fa, 0x15db1bd6, 0x1796302c, 0x19598d85, - 0x1b24e8bb, 0x1cf7fcfa, 0x1ed28af2, 0x20b4582a, - 0x229d2e6e, 0x248cdb55, 0x26832fda, 0x28800000, - 0x2a832287, 0x2c8c70a8, 0x2e9bc5d8, 0x30b0ff99, - 0x32cbfd4a, 0x34eca001, 0x3712ca62, 0x393e6088, - 0x3b6f47e0, 0x3da56717, 0x3fe0a5fc, 0x4220ed72, - 0x44662758, 0x46b03e7c, 0x48ff1e87, 0x4b52b3f3, - 0x4daaebfd, 0x5007b497, 0x5268fc62, 0x54ceb29c, - 0x5738c721, 0x59a72a59, 0x5c19cd35, 0x5e90a129, - 0x610b9821, 0x638aa47f, 0x660db90f, 0x6894c90b, - 0x6b1fc80c, 0x6daeaa0d, 0x70416360, 0x72d7e8b0, - 0x75722ef9, 0x78102b85, 0x7ab1d3ec, 0x7d571e09, -}; - -/* sqrt(0.5) in Q31 format */ -#define SQRTHALF 0x5a82799a - -/* - * Minimax polynomial approximation to pow(x, 4/3), over the range - * poly43lo: x = [0.5, 0.7071] - * poly43hi: x = [0.7071, 1.0] - * - * Relative error < 1E-7 - * Coefs are scaled by 4, 2, 1, 0.5, 0.25 - */ -static const unsigned int poly43lo[5] PROGMEM = { 0x29a0bda9, 0xb02e4828, 0x5957aa1b, 0x236c498d, 0xff581859 }; -static const unsigned int poly43hi[5] PROGMEM = { 0x10852163, 0xd333f6a4, 0x46e9408b, 0x27c2cef0, 0xfef577b4 }; - -/* pow(2, i*4/3) as exp and frac */ -const int pow2exp[8] PROGMEM = { 14, 13, 11, 10, 9, 7, 6, 5 }; - -const int pow2frac[8] PROGMEM = { - 0x6597fa94, 0x50a28be6, 0x7fffffff, 0x6597fa94, - 0x50a28be6, 0x7fffffff, 0x6597fa94, 0x50a28be6 -}; - -/************************************************************************************** - * Function: DequantBlock - * - * Description: Ken's highly-optimized, low memory dequantizer performing the operation - * y = pow(x, 4.0/3.0) * pow(2, 25 - scale/4.0) - * - * Inputs: input buffer of decode Huffman codewords (signed-magnitude) - * output buffer of same length (in-place (outbuf = inbuf) is allowed) - * number of samples - * - * Outputs: dequantized samples in Q25 format - * - * Return: bitwise-OR of the unsigned outputs (for guard bit calculations) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static int DequantBlock(int *inbuf, int *outbuf, int num, int scale) -{ - int tab4[4]; - int scalef, scalei, shift; - int sx, x, y; - int mask = 0; - const int *tab16; - const unsigned int *coef; - - tab16 = pow43_14[scale & 0x3]; - scalef = pow14[scale & 0x3]; - scalei = MIN(scale >> 2, 31); /* smallest input scale = -47, so smallest scalei = -12 */ - - /* cache first 4 values */ - shift = MIN(scalei + 3, 31); - shift = MAX(shift, 0); - tab4[0] = 0; - tab4[1] = tab16[1] >> shift; - tab4[2] = tab16[2] >> shift; - tab4[3] = tab16[3] >> shift; - - do { - - sx = *inbuf++; - x = sx & 0x7fffffff; /* sx = sign|mag */ - - if (x < 4) { - - y = tab4[x]; - - } else if (x < 16) { - - y = tab16[x]; - y = (scalei < 0) ? y << -scalei : y >> scalei; - - } else { - - if (x < 64) { - - y = pow43[x-16]; - - /* fractional scale */ - y = MULSHIFT32(y, scalef); - shift = scalei - 3; - - } else { - - /* normalize to [0x40000000, 0x7fffffff] */ - x <<= 17; - shift = 0; - if (x < 0x08000000) - x <<= 4, shift += 4; - if (x < 0x20000000) - x <<= 2, shift += 2; - if (x < 0x40000000) - x <<= 1, shift += 1; - - coef = (x < SQRTHALF) ? poly43lo : poly43hi; - - /* polynomial */ - y = coef[0]; - y = MULSHIFT32(y, x) + coef[1]; - y = MULSHIFT32(y, x) + coef[2]; - y = MULSHIFT32(y, x) + coef[3]; - y = MULSHIFT32(y, x) + coef[4]; - y = MULSHIFT32(y, pow2frac[shift]) << 3; - - /* fractional scale */ - y = MULSHIFT32(y, scalef); - shift = scalei - pow2exp[shift]; - } - - /* integer scale */ - if (shift < 0) { - shift = -shift; - if (y > (0x7fffffff >> shift)) - y = 0x7fffffff; /* clip */ - else - y <<= shift; - } else { - y >>= shift; - } - } - - /* sign and store */ - mask |= y; - *outbuf++ = (sx < 0) ? -y : y; - - } while (--num); - - return mask; -} - -/************************************************************************************** - * Function: DequantChannel - * - * Description: dequantize one granule, one channel worth of decoded Huffman codewords - * - * Inputs: sample buffer (decoded Huffman codewords), length = MAX_NSAMP samples - * work buffer for reordering short-block, length = MAX_REORDER_SAMPS - * samples (3 * width of largest short-block critical band) - * non-zero bound for this channel/granule - * valid FrameHeader, SideInfoSub, ScaleFactorInfoSub, and CriticalBandInfo - * structures for this channel/granule - * - * Outputs: MAX_NSAMP dequantized samples in sampleBuf - * updated non-zero bound (indicating which samples are != 0 after DQ) - * filled-in cbi structure indicating start and end critical bands - * - * Return: minimum number of guard bits in dequantized sampleBuf - * - * Notes: dequantized samples in Q(DQ_FRACBITS_OUT) format - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ int DequantChannel(int *sampleBuf, int *workBuf, int *nonZeroBound, FrameHeader *fh, SideInfoSub *sis, - ScaleFactorInfoSub *sfis, CriticalBandInfo *cbi) -{ - int i, j, w, cb; - int /* cbStartL, */ cbEndL, cbStartS, cbEndS; - int nSamps, nonZero, sfactMultiplier, gbMask; - int globalGain, gainI; - int cbMax[3]; - ARRAY3 *buf; /* short block reorder */ - - /* set default start/end points for short/long blocks - will update with non-zero cb info */ - if (sis->blockType == 2) { - // cbStartL = 0; - if (sis->mixedBlock) { - cbEndL = (fh->ver == MPEG1 ? 8 : 6); - cbStartS = 3; - } else { - cbEndL = 0; - cbStartS = 0; - } - cbEndS = 13; - } else { - /* long block */ - //cbStartL = 0; - cbEndL = 22; - cbStartS = 13; - cbEndS = 13; - } - cbMax[2] = cbMax[1] = cbMax[0] = 0; - gbMask = 0; - i = 0; - - /* sfactScale = 0 --> quantizer step size = 2 - * sfactScale = 1 --> quantizer step size = sqrt(2) - * so sfactMultiplier = 2 or 4 (jump through globalGain by powers of 2 or sqrt(2)) - */ - sfactMultiplier = 2 * (sis->sfactScale + 1); - - /* offset globalGain by -2 if midSide enabled, for 1/sqrt(2) used in MidSideProc() - * (DequantBlock() does 0.25 * gainI so knocking it down by two is the same as - * dividing every sample by sqrt(2) = multiplying by 2^-.5) - */ - globalGain = sis->globalGain; - if (fh->modeExt >> 1) - globalGain -= 2; - globalGain += IMDCT_SCALE; /* scale everything by sqrt(2), for fast IMDCT36 */ - - /* long blocks */ - for (cb = 0; cb < cbEndL; cb++) { - - nonZero = 0; - nSamps = fh->sfBand->l[cb + 1] - fh->sfBand->l[cb]; - gainI = 210 - globalGain + sfactMultiplier * (sfis->l[cb] + (sis->preFlag ? (int)preTab[cb] : 0)); - - nonZero |= DequantBlock(sampleBuf + i, sampleBuf + i, nSamps, gainI); - i += nSamps; - - /* update highest non-zero critical band */ - if (nonZero) - cbMax[0] = cb; - gbMask |= nonZero; - - if (i >= *nonZeroBound) - break; - } - - /* set cbi (Type, EndS[], EndSMax will be overwritten if we proceed to do short blocks) */ - cbi->cbType = 0; /* long only */ - cbi->cbEndL = cbMax[0]; - cbi->cbEndS[0] = cbi->cbEndS[1] = cbi->cbEndS[2] = 0; - cbi->cbEndSMax = 0; - - /* early exit if no short blocks */ - if (cbStartS >= 12) - return CLZ(gbMask) - 1; - - /* short blocks */ - cbMax[2] = cbMax[1] = cbMax[0] = cbStartS; - for (cb = cbStartS; cb < cbEndS; cb++) { - - nSamps = fh->sfBand->s[cb + 1] - fh->sfBand->s[cb]; - for (w = 0; w < 3; w++) { - nonZero = 0; - gainI = 210 - globalGain + 8*sis->subBlockGain[w] + sfactMultiplier*(sfis->s[cb][w]); - - nonZero |= DequantBlock(sampleBuf + i + nSamps*w, workBuf + nSamps*w, nSamps, gainI); - - /* update highest non-zero critical band */ - if (nonZero) - cbMax[w] = cb; - gbMask |= nonZero; - } - - /* reorder blocks */ - buf = (ARRAY3 *)(sampleBuf + i); - i += 3*nSamps; - for (j = 0; j < nSamps; j++) { - buf[j][0] = workBuf[0*nSamps + j]; - buf[j][1] = workBuf[1*nSamps + j]; - buf[j][2] = workBuf[2*nSamps + j]; - } - - ASSERT(3*nSamps <= MAX_REORDER_SAMPS); - - if (i >= *nonZeroBound) - break; - } - - /* i = last non-zero INPUT sample processed, which corresponds to highest possible non-zero - * OUTPUT sample (after reorder) - * however, the original nzb is no longer necessarily true - * for each cb, buf[][] is updated with 3*nSamps samples (i increases 3*nSamps each time) - * (buf[j + 1][0] = 3 (input) samples ahead of buf[j][0]) - * so update nonZeroBound to i - */ - *nonZeroBound = i; - - ASSERT(*nonZeroBound <= MAX_NSAMP); - - cbi->cbType = (sis->mixedBlock ? 2 : 1); /* 2 = mixed short/long, 1 = short only */ - - cbi->cbEndS[0] = cbMax[0]; - cbi->cbEndS[1] = cbMax[1]; - cbi->cbEndS[2] = cbMax[2]; - - cbi->cbEndSMax = cbMax[0]; - cbi->cbEndSMax = MAX(cbi->cbEndSMax, cbMax[1]); - cbi->cbEndSMax = MAX(cbi->cbEndSMax, cbMax[2]); - - return CLZ(gbMask) - 1; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/huffman.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/huffman.c deleted file mode 100644 index 28f61d4a..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/huffman.c +++ /dev/null @@ -1,462 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * July 2003 - * - * huffman.c - Huffman decoding of transform coefficients - **************************************************************************************/ - -#include "coder.h" -#define PGM_READ_UNALIGNED 0 // Only support aligned reads, faster - -/* helper macros - see comments in hufftabs.c about the format of the huffman tables */ -#define GetMaxbits(x) ((int)( (((unsigned short)(x)) >> 0) & 0x000f)) -#define GetHLen(x) ((int)( (((unsigned short)(x)) >> 12) & 0x000f)) -#define GetCWY(x) ((int)( (((unsigned short)(x)) >> 8) & 0x000f)) -#define GetCWX(x) ((int)( (((unsigned short)(x)) >> 4) & 0x000f)) -#define GetSignBits(x) ((int)( (((unsigned short)(x)) >> 0) & 0x000f)) - -#define GetHLenQ(x) ((int)( (((unsigned char)(x)) >> 4) & 0x0f)) -#define GetCWVQ(x) ((int)( (((unsigned char)(x)) >> 3) & 0x01)) -#define GetCWWQ(x) ((int)( (((unsigned char)(x)) >> 2) & 0x01)) -#define GetCWXQ(x) ((int)( (((unsigned char)(x)) >> 1) & 0x01)) -#define GetCWYQ(x) ((int)( (((unsigned char)(x)) >> 0) & 0x01)) - -/* apply sign of s to the positive number x (save in MSB, will do two's complement in dequant) */ -#define ApplySign(x, s) { (x) |= ((s) & 0x80000000); } - -/************************************************************************************** - * Function: DecodeHuffmanPairs - * - * Description: decode 2-way vector Huffman codes in the "bigValues" region of spectrum - * - * Inputs: valid BitStreamInfo struct, pointing to start of pair-wise codes - * pointer to xy buffer to received decoded values - * number of codewords to decode - * index of Huffman table to use - * number of bits remaining in bitstream - * - * Outputs: pairs of decoded coefficients in vwxy - * updated BitStreamInfo struct - * - * Return: number of bits used, or -1 if out of bits - * - * Notes: assumes that nVals is an even number - * si_huff.bit tests every Huffman codeword in every table (though not - * necessarily all linBits outputs for x,y > 15) - **************************************************************************************/ -// no improvement with section=data -static int DecodeHuffmanPairs(int *xy, int nVals, int tabIdx, int bitsLeft, unsigned char *buf, int bitOffset) -{ - int i, x, y; - int cachedBits, padBits, len, startBits, linBits, maxBits, minBits; - HuffTabType tabType; - unsigned short cw, *tBase, *tCurr; - unsigned int cache; - - if(nVals <= 0) - return 0; - - if (bitsLeft < 0) - return -1; - startBits = bitsLeft; - - tBase = (unsigned short *)(huffTable + huffTabOffset[tabIdx]); - linBits = huffTabLookup[tabIdx].linBits; - tabType = huffTabLookup[tabIdx].tabType; - - ASSERT(!(nVals & 0x01)); - ASSERT(tabIdx < HUFF_PAIRTABS); - ASSERT(tabIdx >= 0); - ASSERT(tabType != invalidTab); - - /* initially fill cache with any partial byte */ - cache = 0; - cachedBits = (8 - bitOffset) & 0x07; - if (cachedBits) - cache = (unsigned int)(*buf++) << (32 - cachedBits); - bitsLeft -= cachedBits; - - if (tabType == noBits) { - /* table 0, no data, x = y = 0 */ - for (i = 0; i < nVals; i+=2) { - xy[i+0] = 0; - xy[i+1] = 0; - } - return 0; - } else if (tabType == oneShot) { - /* single lookup, no escapes */ - maxBits = GetMaxbits(pgm_read_word(&tBase[0])); - tBase++; - padBits = 0; - while (nVals > 0) { - /* refill cache - assumes cachedBits <= 16 */ - if (bitsLeft >= 16) { - /* load 2 new bytes into left-justified cache */ - cache |= (unsigned int)(*buf++) << (24 - cachedBits); - cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += 16; - bitsLeft -= 16; - } else { - /* last time through, pad cache with zeros and drain cache */ - if (cachedBits + bitsLeft <= 0) return -1; - if (bitsLeft > 0) cache |= (unsigned int)(*buf++) << (24 - cachedBits); - if (bitsLeft > 8) cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += bitsLeft; - bitsLeft = 0; - - cache &= (signed int)0x80000000 >> (cachedBits - 1); - padBits = 11; - cachedBits += padBits; /* okay if this is > 32 (0's automatically shifted in from right) */ - } - - /* largest maxBits = 9, plus 2 for sign bits, so make sure cache has at least 11 bits */ - while (nVals > 0 && cachedBits >= 11 ) { - cw = pgm_read_word(&tBase[cache >> (32 - maxBits)]); - len = GetHLen(cw); - cachedBits -= len; - cache <<= len; - - x = GetCWX(cw); if (x) {ApplySign(x, cache); cache <<= 1; cachedBits--;} - y = GetCWY(cw); if (y) {ApplySign(y, cache); cache <<= 1; cachedBits--;} - - /* ran out of bits - should never have consumed padBits */ - if (cachedBits < padBits) - return -1; - - *xy++ = x; - *xy++ = y; - nVals -= 2; - } - } - bitsLeft += (cachedBits - padBits); - return (startBits - bitsLeft); - } else if (tabType == loopLinbits || tabType == loopNoLinbits) { - tCurr = tBase; - padBits = 0; - while (nVals > 0) { - /* refill cache - assumes cachedBits <= 16 */ - if (bitsLeft >= 16) { - /* load 2 new bytes into left-justified cache */ - cache |= (unsigned int)(*buf++) << (24 - cachedBits); - cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += 16; - bitsLeft -= 16; - } else { - /* last time through, pad cache with zeros and drain cache */ - if (cachedBits + bitsLeft <= 0) return -1; - if (bitsLeft > 0) cache |= (unsigned int)(*buf++) << (24 - cachedBits); - if (bitsLeft > 8) cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += bitsLeft; - bitsLeft = 0; - - cache &= (signed int)0x80000000 >> (cachedBits - 1); - padBits = 11; - cachedBits += padBits; /* okay if this is > 32 (0's automatically shifted in from right) */ - } - - /* largest maxBits = 9, plus 2 for sign bits, so make sure cache has at least 11 bits */ - while (nVals > 0 && cachedBits >= 11 ) { - maxBits = GetMaxbits(pgm_read_word(&tCurr[0])); - cw = pgm_read_word(&tCurr[(cache >> (32 - maxBits)) + 1]); - len = GetHLen(cw); - if (!len) { - cachedBits -= maxBits; - cache <<= maxBits; - tCurr += cw; - continue; - } - cachedBits -= len; - cache <<= len; - - x = GetCWX(cw); - y = GetCWY(cw); - - if (x == 15 && tabType == loopLinbits) { - minBits = linBits + 1 + (y ? 1 : 0); - if (cachedBits + bitsLeft < minBits) - return -1; - while (cachedBits < minBits) { - cache |= (unsigned int)(*buf++) << (24 - cachedBits); - cachedBits += 8; - bitsLeft -= 8; - } - if (bitsLeft < 0) { - cachedBits += bitsLeft; - bitsLeft = 0; - cache &= (signed int)0x80000000 >> (cachedBits - 1); - } - x += (int)(cache >> (32 - linBits)); - cachedBits -= linBits; - cache <<= linBits; - } - if (x) {ApplySign(x, cache); cache <<= 1; cachedBits--;} - - if (y == 15 && tabType == loopLinbits) { - minBits = linBits + 1; - if (cachedBits + bitsLeft < minBits) - return -1; - while (cachedBits < minBits) { - cache |= (unsigned int)(*buf++) << (24 - cachedBits); - cachedBits += 8; - bitsLeft -= 8; - } - if (bitsLeft < 0) { - cachedBits += bitsLeft; - bitsLeft = 0; - cache &= (signed int)0x80000000 >> (cachedBits - 1); - } - y += (int)(cache >> (32 - linBits)); - cachedBits -= linBits; - cache <<= linBits; - } - if (y) {ApplySign(y, cache); cache <<= 1; cachedBits--;} - - /* ran out of bits - should never have consumed padBits */ - if (cachedBits < padBits) - return -1; - - *xy++ = x; - *xy++ = y; - nVals -= 2; - tCurr = tBase; - } - } - bitsLeft += (cachedBits - padBits); - return (startBits - bitsLeft); - } - - /* error in bitstream - trying to access unused Huffman table */ - return -1; -} - -/************************************************************************************** - * Function: DecodeHuffmanQuads - * - * Description: decode 4-way vector Huffman codes in the "count1" region of spectrum - * - * Inputs: valid BitStreamInfo struct, pointing to start of quadword codes - * pointer to vwxy buffer to received decoded values - * maximum number of codewords to decode - * index of quadword table (0 = table A, 1 = table B) - * number of bits remaining in bitstream - * - * Outputs: quadruples of decoded coefficients in vwxy - * updated BitStreamInfo struct - * - * Return: index of the first "zero_part" value (index of the first sample - * of the quad word after which all samples are 0) - * - * Notes: si_huff.bit tests every vwxy output in both quad tables - **************************************************************************************/ -// no improvement with section=data -static int DecodeHuffmanQuads(int *vwxy, int nVals, int tabIdx, int bitsLeft, unsigned char *buf, int bitOffset) -{ - int i, v, w, x, y; - int len, maxBits, cachedBits, padBits; - unsigned int cache; - unsigned char cw, *tBase; - - if (bitsLeft <= 0) - return 0; - - tBase = (unsigned char *)quadTable + quadTabOffset[tabIdx]; - maxBits = quadTabMaxBits[tabIdx]; - - /* initially fill cache with any partial byte */ - cache = 0; - cachedBits = (8 - bitOffset) & 0x07; - if (cachedBits) - cache = (unsigned int)(*buf++) << (32 - cachedBits); - bitsLeft -= cachedBits; - - i = padBits = 0; - while (i < (nVals - 3)) { - /* refill cache - assumes cachedBits <= 16 */ - if (bitsLeft >= 16) { - /* load 2 new bytes into left-justified cache */ - cache |= (unsigned int)(*buf++) << (24 - cachedBits); - cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += 16; - bitsLeft -= 16; - } else { - /* last time through, pad cache with zeros and drain cache */ - if (cachedBits + bitsLeft <= 0) return i; - if (bitsLeft > 0) cache |= (unsigned int)(*buf++) << (24 - cachedBits); - if (bitsLeft > 8) cache |= (unsigned int)(*buf++) << (16 - cachedBits); - cachedBits += bitsLeft; - bitsLeft = 0; - - cache &= (signed int)0x80000000 >> (cachedBits - 1); - padBits = 10; - cachedBits += padBits; /* okay if this is > 32 (0's automatically shifted in from right) */ - } - - /* largest maxBits = 6, plus 4 for sign bits, so make sure cache has at least 10 bits */ - while (i < (nVals - 3) && cachedBits >= 10 ) { - cw = pgm_read_byte(&tBase[cache >> (32 - maxBits)]); - len = GetHLenQ(cw); - cachedBits -= len; - cache <<= len; - - v = GetCWVQ(cw); if(v) {ApplySign(v, cache); cache <<= 1; cachedBits--;} - w = GetCWWQ(cw); if(w) {ApplySign(w, cache); cache <<= 1; cachedBits--;} - x = GetCWXQ(cw); if(x) {ApplySign(x, cache); cache <<= 1; cachedBits--;} - y = GetCWYQ(cw); if(y) {ApplySign(y, cache); cache <<= 1; cachedBits--;} - - /* ran out of bits - okay (means we're done) */ - if (cachedBits < padBits) - return i; - - *vwxy++ = v; - *vwxy++ = w; - *vwxy++ = x; - *vwxy++ = y; - i += 4; - } - } - - /* decoded max number of quad values */ - return i; -} - -/************************************************************************************** - * Function: DecodeHuffman - * - * Description: decode one granule, one channel worth of Huffman codes - * - * Inputs: MP3DecInfo structure filled by UnpackFrameHeader(), UnpackSideInfo(), - * and UnpackScaleFactors() (for this granule) - * buffer pointing to start of Huffman data in MP3 frame - * pointer to bit offset (0-7) indicating starting bit in buf[0] - * number of bits in the Huffman data section of the frame - * (could include padding bits) - * index of current granule and channel - * - * Outputs: decoded coefficients in hi->huffDecBuf[ch] (hi pointer in mp3DecInfo) - * updated bitOffset - * - * Return: length (in bytes) of Huffman codes - * bitOffset also returned in parameter (0 = MSB, 7 = LSB of - * byte located at buf + offset) - * -1 if null input pointers, huffBlockBits < 0, or decoder runs - * out of bits prematurely (invalid bitstream) - **************************************************************************************/ -// .data about 1ms faster per frame -/* __attribute__ ((section (".data"))) */ int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch) -{ - int r1Start, r2Start, rEnd[4]; /* region boundaries */ - int i, w, bitsUsed, bitsLeft; - unsigned char *startBuf = buf; - - FrameHeader *fh; - SideInfo *si; - SideInfoSub *sis; - //ScaleFactorInfo *sfi; - HuffmanInfo *hi; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS || !mp3DecInfo->ScaleFactorInfoPS || !mp3DecInfo->HuffmanInfoPS) - return -1; - - fh = ((FrameHeader *)(mp3DecInfo->FrameHeaderPS)); - si = ((SideInfo *)(mp3DecInfo->SideInfoPS)); - sis = &si->sis[gr][ch]; - //sfi = ((ScaleFactorInfo *)(mp3DecInfo->ScaleFactorInfoPS)); - hi = (HuffmanInfo*)(mp3DecInfo->HuffmanInfoPS); - - if (huffBlockBits < 0) - return -1; - - /* figure out region boundaries (the first 2*bigVals coefficients divided into 3 regions) */ - if (sis->winSwitchFlag && sis->blockType == 2) { - if (sis->mixedBlock == 0) { - r1Start = fh->sfBand->s[(sis->region0Count + 1)/3] * 3; - } else { - if (fh->ver == MPEG1) { - r1Start = fh->sfBand->l[sis->region0Count + 1]; - } else { - /* see MPEG2 spec for explanation */ - w = fh->sfBand->s[4] - fh->sfBand->s[3]; - r1Start = fh->sfBand->l[6] + 2*w; - } - } - r2Start = MAX_NSAMP; /* short blocks don't have region 2 */ - } else { - r1Start = fh->sfBand->l[sis->region0Count + 1]; - r2Start = fh->sfBand->l[sis->region0Count + 1 + sis->region1Count + 1]; - } - - /* offset rEnd index by 1 so first region = rEnd[1] - rEnd[0], etc. */ - rEnd[3] = MIN(MAX_NSAMP, 2 * sis->nBigvals); - rEnd[2] = MIN(r2Start, rEnd[3]); - rEnd[1] = MIN(r1Start, rEnd[3]); - rEnd[0] = 0; - - /* rounds up to first all-zero pair (we don't check last pair for (x,y) == (non-zero, zero)) */ - hi->nonZeroBound[ch] = rEnd[3]; - - /* decode Huffman pairs (rEnd[i] are always even numbers) */ - bitsLeft = huffBlockBits; - for (i = 0; i < 3; i++) { - bitsUsed = DecodeHuffmanPairs(hi->huffDecBuf[ch] + rEnd[i], rEnd[i+1] - rEnd[i], sis->tableSelect[i], bitsLeft, buf, *bitOffset); - if (bitsUsed < 0 || bitsUsed > bitsLeft) /* error - overran end of bitstream */ - return -1; - - /* update bitstream position */ - buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - bitsLeft -= bitsUsed; - } - - /* decode Huffman quads (if any) */ - hi->nonZeroBound[ch] += DecodeHuffmanQuads(hi->huffDecBuf[ch] + rEnd[3], MAX_NSAMP - rEnd[3], sis->count1TableSelect, bitsLeft, buf, *bitOffset); - - ASSERT(hi->nonZeroBound[ch] <= MAX_NSAMP); - for (i = hi->nonZeroBound[ch]; i < MAX_NSAMP; i++) - hi->huffDecBuf[ch][i] = 0; - - /* If bits used for 576 samples < huffBlockBits, then the extras are considered - * to be stuffing bits (throw away, but need to return correct bitstream position) - */ - buf += (bitsLeft + *bitOffset) >> 3; - *bitOffset = (bitsLeft + *bitOffset) & 0x07; - - return (buf - startBuf); -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/hufftabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/hufftabs.c deleted file mode 100644 index 90c9e257..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/hufftabs.c +++ /dev/null @@ -1,755 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * hufftabs.c - compressed Huffman code tables - **************************************************************************************/ - -#include "coder.h" - -/* NOTE - regenerated tables to use shorts instead of ints - * (all needed data can fit in 16 bits - see below) - * - * format 0xABCD - * A = length of codeword - * B = y value - * C = x value - * D = number of sign bits (0, 1, or 2) - * - * to read a CW, the code reads maxbits from the stream (dep. on - * table index), but doesn't remove them from the bitstream reader - * then it gets the correct CW by direct lookup into the table - * of length (2^maxbits) (more complicated for non-oneShot...) - * for CW's with hlen < maxbits, there are multiple entries in the - * table (extra bits are don't cares) - * the bitstream reader then "purges" (or removes) only the correct - * number of bits for the chosen CW - * - * entries starting with F are special: D (signbits) is maxbits, - * so the decoder always checks huffTableXX[0] first, gets the - * signbits, and reads that many bits from the bitstream - * (sometimes it takes > 1 read to get the value, so maxbits is - * can get updated by jumping to another value starting with 0xF) - * entries starting with 0 are also special: A = hlen = 0, rest of - * value is an offset to jump higher in the table (for tables of - * type loopNoLinbits or loopLinbits) - */ - -/* store Huffman codes as one big table plus table of offsets, since some platforms - * don't properly support table-of-tables (table of pointers to other const tables) - */ -const unsigned short huffTable[] PROGMEM = { - /* huffTable01[9] */ - 0xf003, 0x3112, 0x3101, 0x2011, 0x2011, 0x1000, 0x1000, 0x1000, - 0x1000, - - /* huffTable02[65] */ - 0xf006, 0x6222, 0x6201, 0x5212, 0x5212, 0x5122, 0x5122, 0x5021, - 0x5021, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, - - /* huffTable03[65] */ - 0xf006, 0x6222, 0x6201, 0x5212, 0x5212, 0x5122, 0x5122, 0x5021, - 0x5021, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, - 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, 0x2101, - 0x2101, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, - - /* huffTable05[257] */ - 0xf008, 0x8332, 0x8322, 0x7232, 0x7232, 0x6132, 0x6132, 0x6132, - 0x6132, 0x7312, 0x7312, 0x7301, 0x7301, 0x7031, 0x7031, 0x7222, - 0x7222, 0x6212, 0x6212, 0x6212, 0x6212, 0x6122, 0x6122, 0x6122, - 0x6122, 0x6201, 0x6201, 0x6201, 0x6201, 0x6021, 0x6021, 0x6021, - 0x6021, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, - - /* huffTable06[129] */ - 0xf007, 0x7332, 0x7301, 0x6322, 0x6322, 0x6232, 0x6232, 0x6031, - 0x6031, 0x5312, 0x5312, 0x5312, 0x5312, 0x5132, 0x5132, 0x5132, - 0x5132, 0x5222, 0x5222, 0x5222, 0x5222, 0x5201, 0x5201, 0x5201, - 0x5201, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, - 0x4122, 0x4021, 0x4021, 0x4021, 0x4021, 0x4021, 0x4021, 0x4021, - 0x4021, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, - - /* huffTable07[110] */ - 0xf006, 0x0041, 0x0052, 0x005b, 0x0060, 0x0063, 0x0068, 0x006b, - 0x6212, 0x5122, 0x5122, 0x6201, 0x6021, 0x4112, 0x4112, 0x4112, - 0x4112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0xf004, 0x4552, 0x4542, 0x4452, 0x4352, 0x3532, 0x3532, - 0x3442, 0x3442, 0x3522, 0x3522, 0x3252, 0x3252, 0x2512, 0x2512, - 0x2512, 0x2512, 0xf003, 0x2152, 0x2152, 0x3501, 0x3432, 0x2051, - 0x2051, 0x3342, 0x3332, 0xf002, 0x2422, 0x2242, 0x1412, 0x1412, - 0xf001, 0x1142, 0x1041, 0xf002, 0x2401, 0x2322, 0x2232, 0x2301, - 0xf001, 0x1312, 0x1132, 0xf001, 0x1031, 0x1222, - - /* huffTable08[280] */ - 0xf008, 0x0101, 0x010a, 0x010f, 0x8512, 0x8152, 0x0112, 0x0115, - 0x8422, 0x8242, 0x8412, 0x7142, 0x7142, 0x8401, 0x8041, 0x8322, - 0x8232, 0x8312, 0x8132, 0x8301, 0x8031, 0x6222, 0x6222, 0x6222, - 0x6222, 0x6201, 0x6201, 0x6201, 0x6201, 0x6021, 0x6021, 0x6021, - 0x6021, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, - 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, - 0x4122, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, 0x2112, - 0x2112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0xf003, 0x3552, 0x3452, 0x2542, 0x2542, 0x1352, 0x1352, - 0x1352, 0x1352, 0xf002, 0x2532, 0x2442, 0x1522, 0x1522, 0xf001, - 0x1252, 0x1501, 0xf001, 0x1432, 0x1342, 0xf001, 0x1051, 0x1332, - - /* huffTable09[93] */ - 0xf006, 0x0041, 0x004a, 0x004f, 0x0052, 0x0057, 0x005a, 0x6412, - 0x6142, 0x6322, 0x6232, 0x5312, 0x5312, 0x5132, 0x5132, 0x6301, - 0x6031, 0x5222, 0x5222, 0x5201, 0x5201, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4122, 0x4122, 0x4122, 0x4122, 0x4021, 0x4021, 0x4021, - 0x4021, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0xf003, 0x3552, 0x3542, 0x2532, 0x2532, 0x2352, 0x2352, - 0x3452, 0x3501, 0xf002, 0x2442, 0x2522, 0x2252, 0x2512, 0xf001, - 0x1152, 0x1432, 0xf002, 0x1342, 0x1342, 0x2051, 0x2401, 0xf001, - 0x1422, 0x1242, 0xf001, 0x1332, 0x1041, - - /* huffTable10[320] */ - 0xf008, 0x0101, 0x010a, 0x010f, 0x0118, 0x011b, 0x0120, 0x0125, - 0x8712, 0x8172, 0x012a, 0x012d, 0x0132, 0x8612, 0x8162, 0x8061, - 0x0137, 0x013a, 0x013d, 0x8412, 0x8142, 0x8041, 0x8322, 0x8232, - 0x8301, 0x7312, 0x7312, 0x7132, 0x7132, 0x7031, 0x7031, 0x7222, - 0x7222, 0x6212, 0x6212, 0x6212, 0x6212, 0x6122, 0x6122, 0x6122, - 0x6122, 0x6201, 0x6201, 0x6201, 0x6201, 0x6021, 0x6021, 0x6021, - 0x6021, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0xf003, 0x3772, 0x3762, 0x3672, 0x3752, 0x3572, 0x3662, - 0x2742, 0x2742, 0xf002, 0x2472, 0x2652, 0x2562, 0x2732, 0xf003, - 0x2372, 0x2372, 0x2642, 0x2642, 0x3552, 0x3452, 0x2362, 0x2362, - 0xf001, 0x1722, 0x1272, 0xf002, 0x2462, 0x2701, 0x1071, 0x1071, - 0xf002, 0x1262, 0x1262, 0x2542, 0x2532, 0xf002, 0x1601, 0x1601, - 0x2352, 0x2442, 0xf001, 0x1632, 0x1622, 0xf002, 0x2522, 0x2252, - 0x1512, 0x1512, 0xf002, 0x1152, 0x1152, 0x2432, 0x2342, 0xf001, - 0x1501, 0x1051, 0xf001, 0x1422, 0x1242, 0xf001, 0x1332, 0x1401, - - /* huffTable11[296] */ - 0xf008, 0x0101, 0x0106, 0x010f, 0x0114, 0x0117, 0x8722, 0x8272, - 0x011c, 0x7172, 0x7172, 0x8712, 0x8071, 0x8632, 0x8362, 0x8061, - 0x011f, 0x0122, 0x8512, 0x7262, 0x7262, 0x8622, 0x8601, 0x7612, - 0x7612, 0x7162, 0x7162, 0x8152, 0x8432, 0x8051, 0x0125, 0x8422, - 0x8242, 0x8412, 0x8142, 0x8401, 0x8041, 0x7322, 0x7322, 0x7232, - 0x7232, 0x6312, 0x6312, 0x6312, 0x6312, 0x6132, 0x6132, 0x6132, - 0x6132, 0x7301, 0x7301, 0x7031, 0x7031, 0x6222, 0x6222, 0x6222, - 0x6222, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, - 0x5122, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, - 0x5201, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, - 0x5021, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, - 0x2000, 0xf002, 0x2772, 0x2762, 0x2672, 0x2572, 0xf003, 0x2662, - 0x2662, 0x2742, 0x2742, 0x2472, 0x2472, 0x3752, 0x3552, 0xf002, - 0x2652, 0x2562, 0x1732, 0x1732, 0xf001, 0x1372, 0x1642, 0xf002, - 0x2542, 0x2452, 0x2532, 0x2352, 0xf001, 0x1462, 0x1701, 0xf001, - 0x1442, 0x1522, 0xf001, 0x1252, 0x1501, 0xf001, 0x1342, 0x1332, - - /* huffTable12[185] */ - 0xf007, 0x0081, 0x008a, 0x008f, 0x0092, 0x0097, 0x009a, 0x009d, - 0x00a2, 0x00a5, 0x00a8, 0x7622, 0x7262, 0x7162, 0x00ad, 0x00b0, - 0x00b3, 0x7512, 0x7152, 0x7432, 0x7342, 0x00b6, 0x7422, 0x7242, - 0x7412, 0x6332, 0x6332, 0x6142, 0x6142, 0x6322, 0x6322, 0x6232, - 0x6232, 0x7041, 0x7301, 0x6031, 0x6031, 0x5312, 0x5312, 0x5312, - 0x5312, 0x5132, 0x5132, 0x5132, 0x5132, 0x5222, 0x5222, 0x5222, - 0x5222, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, 0x4212, - 0x4212, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, 0x4122, - 0x4122, 0x5201, 0x5201, 0x5201, 0x5201, 0x5021, 0x5021, 0x5021, - 0x5021, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, - 0x4000, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, 0x3101, - 0x3101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0xf003, 0x3772, 0x3762, 0x2672, 0x2672, 0x2752, 0x2752, - 0x2572, 0x2572, 0xf002, 0x2662, 0x2742, 0x2472, 0x2562, 0xf001, - 0x1652, 0x1732, 0xf002, 0x2372, 0x2552, 0x1722, 0x1722, 0xf001, - 0x1272, 0x1642, 0xf001, 0x1462, 0x1712, 0xf002, 0x1172, 0x1172, - 0x2701, 0x2071, 0xf001, 0x1632, 0x1362, 0xf001, 0x1542, 0x1452, - 0xf002, 0x1442, 0x1442, 0x2601, 0x2501, 0xf001, 0x1612, 0x1061, - 0xf001, 0x1532, 0x1352, 0xf001, 0x1522, 0x1252, 0xf001, 0x1051, - 0x1401, - - /* huffTable13[497] */ - 0xf006, 0x0041, 0x0082, 0x00c3, 0x00e4, 0x0105, 0x0116, 0x011f, - 0x0130, 0x0139, 0x013e, 0x0143, 0x0146, 0x6212, 0x6122, 0x6201, - 0x6021, 0x4112, 0x4112, 0x4112, 0x4112, 0x4101, 0x4101, 0x4101, - 0x4101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0xf006, 0x0108, 0x0111, 0x011a, 0x0123, 0x012c, 0x0131, - 0x0136, 0x013f, 0x0144, 0x0147, 0x014c, 0x0151, 0x0156, 0x015b, - 0x6f12, 0x61f2, 0x60f1, 0x0160, 0x0163, 0x0166, 0x62e2, 0x0169, - 0x6e12, 0x61e2, 0x016c, 0x016f, 0x0172, 0x0175, 0x0178, 0x017b, - 0x66c2, 0x6d32, 0x017e, 0x6d22, 0x62d2, 0x6d12, 0x67b2, 0x0181, - 0x0184, 0x63c2, 0x0187, 0x6b42, 0x51d2, 0x51d2, 0x6d01, 0x60d1, - 0x6a82, 0x68a2, 0x6c42, 0x64c2, 0x6b62, 0x66b2, 0x5c32, 0x5c32, - 0x5c22, 0x5c22, 0x52c2, 0x52c2, 0x5b52, 0x5b52, 0x65b2, 0x6982, - 0x5c12, 0x5c12, 0xf006, 0x51c2, 0x51c2, 0x6892, 0x6c01, 0x50c1, - 0x50c1, 0x64b2, 0x6a62, 0x66a2, 0x6972, 0x5b32, 0x5b32, 0x53b2, - 0x53b2, 0x6882, 0x6a52, 0x5b22, 0x5b22, 0x65a2, 0x6962, 0x54a2, - 0x54a2, 0x6872, 0x6782, 0x5492, 0x5492, 0x6772, 0x6672, 0x42b2, - 0x42b2, 0x42b2, 0x42b2, 0x4b12, 0x4b12, 0x4b12, 0x4b12, 0x41b2, - 0x41b2, 0x41b2, 0x41b2, 0x5b01, 0x5b01, 0x50b1, 0x50b1, 0x5692, - 0x5692, 0x5a42, 0x5a42, 0x5a32, 0x5a32, 0x53a2, 0x53a2, 0x5952, - 0x5952, 0x5592, 0x5592, 0x4a22, 0x4a22, 0x4a22, 0x4a22, 0x42a2, - 0x42a2, 0x42a2, 0x42a2, 0xf005, 0x4a12, 0x4a12, 0x41a2, 0x41a2, - 0x5a01, 0x5862, 0x40a1, 0x40a1, 0x5682, 0x5942, 0x4392, 0x4392, - 0x5932, 0x5852, 0x5582, 0x5762, 0x4922, 0x4922, 0x4292, 0x4292, - 0x5752, 0x5572, 0x4832, 0x4832, 0x4382, 0x4382, 0x5662, 0x5742, - 0x5472, 0x5652, 0x5562, 0x5372, 0xf005, 0x3912, 0x3912, 0x3912, - 0x3912, 0x3192, 0x3192, 0x3192, 0x3192, 0x4901, 0x4901, 0x4091, - 0x4091, 0x4842, 0x4842, 0x4482, 0x4482, 0x4272, 0x4272, 0x5642, - 0x5462, 0x3822, 0x3822, 0x3822, 0x3822, 0x3282, 0x3282, 0x3282, - 0x3282, 0x3812, 0x3812, 0x3812, 0x3812, 0xf004, 0x4732, 0x4722, - 0x3712, 0x3712, 0x3172, 0x3172, 0x4552, 0x4701, 0x4071, 0x4632, - 0x4362, 0x4542, 0x4452, 0x4622, 0x4262, 0x4532, 0xf003, 0x2182, - 0x2182, 0x3801, 0x3081, 0x3612, 0x3162, 0x3601, 0x3061, 0xf004, - 0x4352, 0x4442, 0x3522, 0x3522, 0x3252, 0x3252, 0x3501, 0x3501, - 0x2512, 0x2512, 0x2512, 0x2512, 0x2152, 0x2152, 0x2152, 0x2152, - 0xf003, 0x3432, 0x3342, 0x3051, 0x3422, 0x3242, 0x3332, 0x2412, - 0x2412, 0xf002, 0x1142, 0x1142, 0x2401, 0x2041, 0xf002, 0x2322, - 0x2232, 0x1312, 0x1312, 0xf001, 0x1132, 0x1301, 0xf001, 0x1031, - 0x1222, 0xf003, 0x0082, 0x008b, 0x008e, 0x0091, 0x0094, 0x0097, - 0x3ce2, 0x3dd2, 0xf003, 0x0093, 0x3eb2, 0x3be2, 0x3f92, 0x39f2, - 0x3ae2, 0x3db2, 0x3bd2, 0xf003, 0x3f82, 0x38f2, 0x3cc2, 0x008d, - 0x3e82, 0x0090, 0x27f2, 0x27f2, 0xf003, 0x2ad2, 0x2ad2, 0x3da2, - 0x3cb2, 0x3bc2, 0x36f2, 0x2f62, 0x2f62, 0xf002, 0x28e2, 0x2f52, - 0x2d92, 0x29d2, 0xf002, 0x25f2, 0x27e2, 0x2ca2, 0x2bb2, 0xf003, - 0x2f42, 0x2f42, 0x24f2, 0x24f2, 0x3ac2, 0x36e2, 0x23f2, 0x23f2, - 0xf002, 0x1f32, 0x1f32, 0x2d82, 0x28d2, 0xf001, 0x1f22, 0x12f2, - 0xf002, 0x2e62, 0x2c92, 0x1f01, 0x1f01, 0xf002, 0x29c2, 0x2e52, - 0x1ba2, 0x1ba2, 0xf002, 0x2d72, 0x27d2, 0x1e42, 0x1e42, 0xf002, - 0x28c2, 0x26d2, 0x1e32, 0x1e32, 0xf002, 0x19b2, 0x19b2, 0x2b92, - 0x2aa2, 0xf001, 0x1ab2, 0x15e2, 0xf001, 0x14e2, 0x1c82, 0xf001, - 0x1d62, 0x13e2, 0xf001, 0x1e22, 0x1e01, 0xf001, 0x10e1, 0x1d52, - 0xf001, 0x15d2, 0x1c72, 0xf001, 0x17c2, 0x1d42, 0xf001, 0x1b82, - 0x18b2, 0xf001, 0x14d2, 0x1a92, 0xf001, 0x19a2, 0x1c62, 0xf001, - 0x13d2, 0x1b72, 0xf001, 0x1c52, 0x15c2, 0xf001, 0x1992, 0x1a72, - 0xf001, 0x17a2, 0x1792, 0xf003, 0x0023, 0x3df2, 0x2de2, 0x2de2, - 0x1ff2, 0x1ff2, 0x1ff2, 0x1ff2, 0xf001, 0x1fe2, 0x1fd2, 0xf001, - 0x1ee2, 0x1fc2, 0xf001, 0x1ed2, 0x1fb2, 0xf001, 0x1bf2, 0x1ec2, - 0xf002, 0x1cd2, 0x1cd2, 0x2fa2, 0x29e2, 0xf001, 0x1af2, 0x1dc2, - 0xf001, 0x1ea2, 0x1e92, 0xf001, 0x1f72, 0x1e72, 0xf001, 0x1ef2, - 0x1cf2, - - /* huffTable15[580] */ - 0xf008, 0x0101, 0x0122, 0x0143, 0x0154, 0x0165, 0x0176, 0x017f, - 0x0188, 0x0199, 0x01a2, 0x01ab, 0x01b4, 0x01bd, 0x01c2, 0x01cb, - 0x01d4, 0x01d9, 0x01de, 0x01e3, 0x01e8, 0x01ed, 0x01f2, 0x01f7, - 0x01fc, 0x0201, 0x0204, 0x0207, 0x020a, 0x020f, 0x0212, 0x0215, - 0x021a, 0x021d, 0x0220, 0x8192, 0x0223, 0x0226, 0x0229, 0x022c, - 0x022f, 0x8822, 0x8282, 0x8812, 0x8182, 0x0232, 0x0235, 0x0238, - 0x023b, 0x8722, 0x8272, 0x8462, 0x8712, 0x8552, 0x8172, 0x023e, - 0x8632, 0x8362, 0x8542, 0x8452, 0x8622, 0x8262, 0x8612, 0x0241, - 0x8532, 0x7162, 0x7162, 0x8352, 0x8442, 0x7522, 0x7522, 0x7252, - 0x7252, 0x7512, 0x7512, 0x7152, 0x7152, 0x8501, 0x8051, 0x7432, - 0x7432, 0x7342, 0x7342, 0x7422, 0x7422, 0x7242, 0x7242, 0x7332, - 0x7332, 0x6142, 0x6142, 0x6142, 0x6142, 0x7412, 0x7412, 0x7401, - 0x7401, 0x6322, 0x6322, 0x6322, 0x6322, 0x6232, 0x6232, 0x6232, - 0x6232, 0x7041, 0x7041, 0x7301, 0x7301, 0x6312, 0x6312, 0x6312, - 0x6312, 0x6132, 0x6132, 0x6132, 0x6132, 0x6031, 0x6031, 0x6031, - 0x6031, 0x5222, 0x5222, 0x5222, 0x5222, 0x5222, 0x5222, 0x5222, - 0x5222, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, - 0x5212, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, - 0x5122, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, 0x5201, - 0x5201, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, 0x5021, - 0x5021, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, 0x3112, - 0x3112, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, 0x3000, - 0x3000, 0xf005, 0x5ff2, 0x5fe2, 0x5ef2, 0x5fd2, 0x4ee2, 0x4ee2, - 0x5df2, 0x5fc2, 0x5cf2, 0x5ed2, 0x5de2, 0x5fb2, 0x4bf2, 0x4bf2, - 0x5ec2, 0x5ce2, 0x4dd2, 0x4dd2, 0x4fa2, 0x4fa2, 0x4af2, 0x4af2, - 0x4eb2, 0x4eb2, 0x4be2, 0x4be2, 0x4dc2, 0x4dc2, 0x4cd2, 0x4cd2, - 0x4f92, 0x4f92, 0xf005, 0x49f2, 0x49f2, 0x4ae2, 0x4ae2, 0x4db2, - 0x4db2, 0x4bd2, 0x4bd2, 0x4f82, 0x4f82, 0x48f2, 0x48f2, 0x4cc2, - 0x4cc2, 0x4e92, 0x4e92, 0x49e2, 0x49e2, 0x4f72, 0x4f72, 0x47f2, - 0x47f2, 0x4da2, 0x4da2, 0x4ad2, 0x4ad2, 0x4cb2, 0x4cb2, 0x4f62, - 0x4f62, 0x5ea2, 0x5f01, 0xf004, 0x3bc2, 0x3bc2, 0x36f2, 0x36f2, - 0x4e82, 0x48e2, 0x4f52, 0x4d92, 0x35f2, 0x35f2, 0x3e72, 0x3e72, - 0x37e2, 0x37e2, 0x3ca2, 0x3ca2, 0xf004, 0x3ac2, 0x3ac2, 0x3bb2, - 0x3bb2, 0x49d2, 0x4d82, 0x3f42, 0x3f42, 0x34f2, 0x34f2, 0x3f32, - 0x3f32, 0x33f2, 0x33f2, 0x38d2, 0x38d2, 0xf004, 0x36e2, 0x36e2, - 0x3f22, 0x3f22, 0x32f2, 0x32f2, 0x4e62, 0x40f1, 0x3f12, 0x3f12, - 0x31f2, 0x31f2, 0x3c92, 0x3c92, 0x39c2, 0x39c2, 0xf003, 0x3e52, - 0x3ba2, 0x3ab2, 0x35e2, 0x3d72, 0x37d2, 0x3e42, 0x34e2, 0xf003, - 0x3c82, 0x38c2, 0x3e32, 0x3d62, 0x36d2, 0x33e2, 0x3b92, 0x39b2, - 0xf004, 0x3e22, 0x3e22, 0x3aa2, 0x3aa2, 0x32e2, 0x32e2, 0x3e12, - 0x3e12, 0x31e2, 0x31e2, 0x4e01, 0x40e1, 0x3d52, 0x3d52, 0x35d2, - 0x35d2, 0xf003, 0x3c72, 0x37c2, 0x3d42, 0x3b82, 0x24d2, 0x24d2, - 0x38b2, 0x3a92, 0xf003, 0x39a2, 0x3c62, 0x36c2, 0x3d32, 0x23d2, - 0x23d2, 0x22d2, 0x22d2, 0xf003, 0x3d22, 0x3d01, 0x2d12, 0x2d12, - 0x2b72, 0x2b72, 0x27b2, 0x27b2, 0xf003, 0x21d2, 0x21d2, 0x3c52, - 0x30d1, 0x25c2, 0x25c2, 0x2a82, 0x2a82, 0xf002, 0x28a2, 0x2c42, - 0x24c2, 0x2b62, 0xf003, 0x26b2, 0x26b2, 0x3992, 0x3c01, 0x2c32, - 0x2c32, 0x23c2, 0x23c2, 0xf003, 0x2a72, 0x2a72, 0x27a2, 0x27a2, - 0x26a2, 0x26a2, 0x30c1, 0x3b01, 0xf002, 0x12c2, 0x12c2, 0x2c22, - 0x2b52, 0xf002, 0x25b2, 0x2c12, 0x2982, 0x2892, 0xf002, 0x21c2, - 0x2b42, 0x24b2, 0x2a62, 0xf002, 0x2b32, 0x2972, 0x13b2, 0x13b2, - 0xf002, 0x2792, 0x2882, 0x2b22, 0x2a52, 0xf002, 0x12b2, 0x12b2, - 0x25a2, 0x2b12, 0xf002, 0x11b2, 0x11b2, 0x20b1, 0x2962, 0xf002, - 0x2692, 0x2a42, 0x24a2, 0x2872, 0xf002, 0x2782, 0x2a32, 0x13a2, - 0x13a2, 0xf001, 0x1952, 0x1592, 0xf001, 0x1a22, 0x12a2, 0xf001, - 0x1a12, 0x11a2, 0xf002, 0x2a01, 0x20a1, 0x1862, 0x1862, 0xf001, - 0x1682, 0x1942, 0xf001, 0x1492, 0x1932, 0xf002, 0x1392, 0x1392, - 0x2772, 0x2901, 0xf001, 0x1852, 0x1582, 0xf001, 0x1922, 0x1762, - 0xf001, 0x1672, 0x1292, 0xf001, 0x1912, 0x1091, 0xf001, 0x1842, - 0x1482, 0xf001, 0x1752, 0x1572, 0xf001, 0x1832, 0x1382, 0xf001, - 0x1662, 0x1742, 0xf001, 0x1472, 0x1801, 0xf001, 0x1081, 0x1652, - 0xf001, 0x1562, 0x1732, 0xf001, 0x1372, 0x1642, 0xf001, 0x1701, - 0x1071, 0xf001, 0x1601, 0x1061, - - /* huffTable16[651] */ - 0xf008, 0x0101, 0x010a, 0x0113, 0x8ff2, 0x0118, 0x011d, 0x0120, - 0x82f2, 0x0131, 0x8f12, 0x81f2, 0x0134, 0x0145, 0x0156, 0x0167, - 0x0178, 0x0189, 0x019a, 0x01a3, 0x01ac, 0x01b5, 0x01be, 0x01c7, - 0x01d0, 0x01d9, 0x01de, 0x01e3, 0x01e6, 0x01eb, 0x01f0, 0x8152, - 0x01f3, 0x01f6, 0x01f9, 0x01fc, 0x8412, 0x8142, 0x01ff, 0x8322, - 0x8232, 0x7312, 0x7312, 0x7132, 0x7132, 0x8301, 0x8031, 0x7222, - 0x7222, 0x6212, 0x6212, 0x6212, 0x6212, 0x6122, 0x6122, 0x6122, - 0x6122, 0x6201, 0x6201, 0x6201, 0x6201, 0x6021, 0x6021, 0x6021, - 0x6021, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, 0x3011, - 0x3011, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, - 0x1000, 0xf003, 0x3fe2, 0x3ef2, 0x3fd2, 0x3df2, 0x3fc2, 0x3cf2, - 0x3fb2, 0x3bf2, 0xf003, 0x2fa2, 0x2fa2, 0x3af2, 0x3f92, 0x39f2, - 0x38f2, 0x2f82, 0x2f82, 0xf002, 0x2f72, 0x27f2, 0x2f62, 0x26f2, - 0xf002, 0x2f52, 0x25f2, 0x1f42, 0x1f42, 0xf001, 0x14f2, 0x13f2, - 0xf004, 0x10f1, 0x10f1, 0x10f1, 0x10f1, 0x10f1, 0x10f1, 0x10f1, - 0x10f1, 0x2f32, 0x2f32, 0x2f32, 0x2f32, 0x00e2, 0x00f3, 0x00fc, - 0x0105, 0xf001, 0x1f22, 0x1f01, 0xf004, 0x00fa, 0x00ff, 0x0104, - 0x0109, 0x010c, 0x0111, 0x0116, 0x0119, 0x011e, 0x0123, 0x0128, - 0x43e2, 0x012d, 0x0130, 0x0133, 0x0136, 0xf004, 0x0128, 0x012b, - 0x012e, 0x4d01, 0x0131, 0x0134, 0x0137, 0x4c32, 0x013a, 0x4c12, - 0x40c1, 0x013d, 0x32e2, 0x32e2, 0x4e22, 0x4e12, 0xf004, 0x43d2, - 0x4d22, 0x42d2, 0x41d2, 0x4b32, 0x012f, 0x3d12, 0x3d12, 0x44c2, - 0x4b62, 0x43c2, 0x47a2, 0x3c22, 0x3c22, 0x42c2, 0x45b2, 0xf004, - 0x41c2, 0x4c01, 0x4b42, 0x44b2, 0x4a62, 0x46a2, 0x33b2, 0x33b2, - 0x4a52, 0x45a2, 0x3b22, 0x3b22, 0x32b2, 0x32b2, 0x3b12, 0x3b12, - 0xf004, 0x31b2, 0x31b2, 0x4b01, 0x40b1, 0x4962, 0x4692, 0x4a42, - 0x44a2, 0x4872, 0x4782, 0x33a2, 0x33a2, 0x4a32, 0x4952, 0x3a22, - 0x3a22, 0xf004, 0x4592, 0x4862, 0x31a2, 0x31a2, 0x4682, 0x4772, - 0x3492, 0x3492, 0x4942, 0x4752, 0x3762, 0x3762, 0x22a2, 0x22a2, - 0x22a2, 0x22a2, 0xf003, 0x2a12, 0x2a12, 0x3a01, 0x30a1, 0x3932, - 0x3392, 0x3852, 0x3582, 0xf003, 0x2922, 0x2922, 0x2292, 0x2292, - 0x3672, 0x3901, 0x2912, 0x2912, 0xf003, 0x2192, 0x2192, 0x3091, - 0x3842, 0x3482, 0x3572, 0x3832, 0x3382, 0xf003, 0x3662, 0x3822, - 0x2282, 0x2282, 0x3742, 0x3472, 0x2812, 0x2812, 0xf003, 0x2182, - 0x2182, 0x2081, 0x2081, 0x3801, 0x3652, 0x2732, 0x2732, 0xf003, - 0x2372, 0x2372, 0x3562, 0x3642, 0x2722, 0x2722, 0x2272, 0x2272, - 0xf003, 0x3462, 0x3552, 0x2701, 0x2701, 0x1712, 0x1712, 0x1712, - 0x1712, 0xf002, 0x1172, 0x1172, 0x2071, 0x2632, 0xf002, 0x2362, - 0x2542, 0x2452, 0x2622, 0xf001, 0x1262, 0x1612, 0xf002, 0x1162, - 0x1162, 0x2601, 0x2061, 0xf002, 0x1352, 0x1352, 0x2532, 0x2442, - 0xf001, 0x1522, 0x1252, 0xf001, 0x1512, 0x1501, 0xf001, 0x1432, - 0x1342, 0xf001, 0x1051, 0x1422, 0xf001, 0x1242, 0x1332, 0xf001, - 0x1401, 0x1041, 0xf004, 0x4ec2, 0x0086, 0x3ed2, 0x3ed2, 0x39e2, - 0x39e2, 0x4ae2, 0x49d2, 0x2ee2, 0x2ee2, 0x2ee2, 0x2ee2, 0x3de2, - 0x3de2, 0x3be2, 0x3be2, 0xf003, 0x2eb2, 0x2eb2, 0x2dc2, 0x2dc2, - 0x3cd2, 0x3bd2, 0x2ea2, 0x2ea2, 0xf003, 0x2cc2, 0x2cc2, 0x3da2, - 0x3ad2, 0x3e72, 0x3ca2, 0x2ac2, 0x2ac2, 0xf003, 0x39c2, 0x3d72, - 0x2e52, 0x2e52, 0x1db2, 0x1db2, 0x1db2, 0x1db2, 0xf002, 0x1e92, - 0x1e92, 0x2cb2, 0x2bc2, 0xf002, 0x2e82, 0x28e2, 0x2d92, 0x27e2, - 0xf002, 0x2bb2, 0x2d82, 0x28d2, 0x2e62, 0xf001, 0x16e2, 0x1c92, - 0xf002, 0x2ba2, 0x2ab2, 0x25e2, 0x27d2, 0xf002, 0x1e42, 0x1e42, - 0x24e2, 0x2c82, 0xf001, 0x18c2, 0x1e32, 0xf002, 0x1d62, 0x1d62, - 0x26d2, 0x2b92, 0xf002, 0x29b2, 0x2aa2, 0x11e2, 0x11e2, 0xf002, - 0x14d2, 0x14d2, 0x28b2, 0x29a2, 0xf002, 0x1b72, 0x1b72, 0x27b2, - 0x20d1, 0xf001, 0x1e01, 0x10e1, 0xf001, 0x1d52, 0x15d2, 0xf001, - 0x1c72, 0x17c2, 0xf001, 0x1d42, 0x1b82, 0xf001, 0x1a92, 0x1c62, - 0xf001, 0x16c2, 0x1d32, 0xf001, 0x1c52, 0x15c2, 0xf001, 0x1a82, - 0x18a2, 0xf001, 0x1992, 0x1c42, 0xf001, 0x16b2, 0x1a72, 0xf001, - 0x1b52, 0x1982, 0xf001, 0x1892, 0x1972, 0xf001, 0x1792, 0x1882, - 0xf001, 0x1ce2, 0x1dd2, - - /* huffTable24[705] */ - 0xf009, 0x8fe2, 0x8fe2, 0x8ef2, 0x8ef2, 0x8fd2, 0x8fd2, 0x8df2, - 0x8df2, 0x8fc2, 0x8fc2, 0x8cf2, 0x8cf2, 0x8fb2, 0x8fb2, 0x8bf2, - 0x8bf2, 0x7af2, 0x7af2, 0x7af2, 0x7af2, 0x8fa2, 0x8fa2, 0x8f92, - 0x8f92, 0x79f2, 0x79f2, 0x79f2, 0x79f2, 0x78f2, 0x78f2, 0x78f2, - 0x78f2, 0x8f82, 0x8f82, 0x8f72, 0x8f72, 0x77f2, 0x77f2, 0x77f2, - 0x77f2, 0x7f62, 0x7f62, 0x7f62, 0x7f62, 0x76f2, 0x76f2, 0x76f2, - 0x76f2, 0x7f52, 0x7f52, 0x7f52, 0x7f52, 0x75f2, 0x75f2, 0x75f2, - 0x75f2, 0x7f42, 0x7f42, 0x7f42, 0x7f42, 0x74f2, 0x74f2, 0x74f2, - 0x74f2, 0x7f32, 0x7f32, 0x7f32, 0x7f32, 0x73f2, 0x73f2, 0x73f2, - 0x73f2, 0x7f22, 0x7f22, 0x7f22, 0x7f22, 0x72f2, 0x72f2, 0x72f2, - 0x72f2, 0x71f2, 0x71f2, 0x71f2, 0x71f2, 0x8f12, 0x8f12, 0x80f1, - 0x80f1, 0x9f01, 0x0201, 0x0206, 0x020b, 0x0210, 0x0215, 0x021a, - 0x021f, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, - 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, - 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, - 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, 0x4ff2, - 0x4ff2, 0x0224, 0x0229, 0x0232, 0x0237, 0x023a, 0x023f, 0x0242, - 0x0245, 0x024a, 0x024d, 0x0250, 0x0253, 0x0256, 0x0259, 0x025c, - 0x025f, 0x0262, 0x0265, 0x0268, 0x026b, 0x026e, 0x0271, 0x0274, - 0x0277, 0x027a, 0x027d, 0x0280, 0x0283, 0x0288, 0x028b, 0x028e, - 0x0291, 0x0294, 0x0297, 0x029a, 0x029f, 0x94b2, 0x02a4, 0x02a7, - 0x02aa, 0x93b2, 0x9882, 0x02af, 0x92b2, 0x02b2, 0x02b5, 0x9692, - 0x94a2, 0x02b8, 0x9782, 0x9a32, 0x93a2, 0x9952, 0x9592, 0x9a22, - 0x92a2, 0x91a2, 0x9862, 0x9682, 0x9772, 0x9942, 0x9492, 0x9932, - 0x9392, 0x9852, 0x9582, 0x9922, 0x9762, 0x9672, 0x9292, 0x9912, - 0x9192, 0x9842, 0x9482, 0x9752, 0x9572, 0x9832, 0x9382, 0x9662, - 0x9822, 0x9282, 0x9812, 0x9742, 0x9472, 0x9182, 0x02bb, 0x9652, - 0x9562, 0x9712, 0x02be, 0x8372, 0x8372, 0x9732, 0x9722, 0x8272, - 0x8272, 0x8642, 0x8642, 0x8462, 0x8462, 0x8552, 0x8552, 0x8172, - 0x8172, 0x8632, 0x8632, 0x8362, 0x8362, 0x8542, 0x8542, 0x8452, - 0x8452, 0x8622, 0x8622, 0x8262, 0x8262, 0x8612, 0x8612, 0x8162, - 0x8162, 0x9601, 0x9061, 0x8532, 0x8532, 0x8352, 0x8352, 0x8442, - 0x8442, 0x8522, 0x8522, 0x8252, 0x8252, 0x8512, 0x8512, 0x9501, - 0x9051, 0x7152, 0x7152, 0x7152, 0x7152, 0x8432, 0x8432, 0x8342, - 0x8342, 0x7422, 0x7422, 0x7422, 0x7422, 0x7242, 0x7242, 0x7242, - 0x7242, 0x7332, 0x7332, 0x7332, 0x7332, 0x7412, 0x7412, 0x7412, - 0x7412, 0x7142, 0x7142, 0x7142, 0x7142, 0x8401, 0x8401, 0x8041, - 0x8041, 0x7322, 0x7322, 0x7322, 0x7322, 0x7232, 0x7232, 0x7232, - 0x7232, 0x6312, 0x6312, 0x6312, 0x6312, 0x6312, 0x6312, 0x6312, - 0x6312, 0x6132, 0x6132, 0x6132, 0x6132, 0x6132, 0x6132, 0x6132, - 0x6132, 0x7301, 0x7301, 0x7301, 0x7301, 0x7031, 0x7031, 0x7031, - 0x7031, 0x6222, 0x6222, 0x6222, 0x6222, 0x6222, 0x6222, 0x6222, - 0x6222, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, - 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, 0x5212, - 0x5212, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, - 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, 0x5122, - 0x5122, 0x6201, 0x6201, 0x6201, 0x6201, 0x6201, 0x6201, 0x6201, - 0x6201, 0x6021, 0x6021, 0x6021, 0x6021, 0x6021, 0x6021, 0x6021, - 0x6021, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, 0x4112, - 0x4112, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, 0x4101, - 0x4101, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, 0x4011, - 0x4011, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, - 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, - 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, - 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000, - 0x4000, 0xf002, 0x2ee2, 0x2ed2, 0x2de2, 0x2ec2, 0xf002, 0x2ce2, - 0x2dd2, 0x2eb2, 0x2be2, 0xf002, 0x2dc2, 0x2cd2, 0x2ea2, 0x2ae2, - 0xf002, 0x2db2, 0x2bd2, 0x2cc2, 0x2e92, 0xf002, 0x29e2, 0x2da2, - 0x2ad2, 0x2cb2, 0xf002, 0x2bc2, 0x2e82, 0x28e2, 0x2d92, 0xf002, - 0x29d2, 0x2e72, 0x27e2, 0x2ca2, 0xf002, 0x2ac2, 0x2bb2, 0x2d82, - 0x28d2, 0xf003, 0x3e01, 0x30e1, 0x2d01, 0x2d01, 0x16e2, 0x16e2, - 0x16e2, 0x16e2, 0xf002, 0x2e62, 0x2c92, 0x19c2, 0x19c2, 0xf001, - 0x1e52, 0x1ab2, 0xf002, 0x15e2, 0x15e2, 0x2ba2, 0x2d72, 0xf001, - 0x17d2, 0x14e2, 0xf001, 0x1c82, 0x18c2, 0xf002, 0x2e42, 0x2e22, - 0x1e32, 0x1e32, 0xf001, 0x1d62, 0x16d2, 0xf001, 0x13e2, 0x1b92, - 0xf001, 0x19b2, 0x1aa2, 0xf001, 0x12e2, 0x1e12, 0xf001, 0x11e2, - 0x1d52, 0xf001, 0x15d2, 0x1c72, 0xf001, 0x17c2, 0x1d42, 0xf001, - 0x1b82, 0x18b2, 0xf001, 0x14d2, 0x1a92, 0xf001, 0x19a2, 0x1c62, - 0xf001, 0x16c2, 0x1d32, 0xf001, 0x13d2, 0x1d22, 0xf001, 0x12d2, - 0x1d12, 0xf001, 0x1b72, 0x17b2, 0xf001, 0x11d2, 0x1c52, 0xf001, - 0x15c2, 0x1a82, 0xf001, 0x18a2, 0x1992, 0xf001, 0x1c42, 0x14c2, - 0xf001, 0x1b62, 0x16b2, 0xf002, 0x20d1, 0x2c01, 0x1c32, 0x1c32, - 0xf001, 0x13c2, 0x1a72, 0xf001, 0x17a2, 0x1c22, 0xf001, 0x12c2, - 0x1b52, 0xf001, 0x15b2, 0x1c12, 0xf001, 0x1982, 0x1892, 0xf001, - 0x11c2, 0x1b42, 0xf002, 0x20c1, 0x2b01, 0x1b32, 0x1b32, 0xf002, - 0x20b1, 0x2a01, 0x1a12, 0x1a12, 0xf001, 0x1a62, 0x16a2, 0xf001, - 0x1972, 0x1792, 0xf002, 0x20a1, 0x2901, 0x1091, 0x1091, 0xf001, - 0x1b22, 0x1a52, 0xf001, 0x15a2, 0x1b12, 0xf001, 0x11b2, 0x1962, - 0xf001, 0x1a42, 0x1872, 0xf001, 0x1801, 0x1081, 0xf001, 0x1701, - 0x1071, -}; - -#define HUFF_OFFSET_01 0 -#define HUFF_OFFSET_02 ( 9 + HUFF_OFFSET_01) -#define HUFF_OFFSET_03 ( 65 + HUFF_OFFSET_02) -#define HUFF_OFFSET_05 ( 65 + HUFF_OFFSET_03) -#define HUFF_OFFSET_06 (257 + HUFF_OFFSET_05) -#define HUFF_OFFSET_07 (129 + HUFF_OFFSET_06) -#define HUFF_OFFSET_08 (110 + HUFF_OFFSET_07) -#define HUFF_OFFSET_09 (280 + HUFF_OFFSET_08) -#define HUFF_OFFSET_10 ( 93 + HUFF_OFFSET_09) -#define HUFF_OFFSET_11 (320 + HUFF_OFFSET_10) -#define HUFF_OFFSET_12 (296 + HUFF_OFFSET_11) -#define HUFF_OFFSET_13 (185 + HUFF_OFFSET_12) -#define HUFF_OFFSET_15 (497 + HUFF_OFFSET_13) -#define HUFF_OFFSET_16 (580 + HUFF_OFFSET_15) -#define HUFF_OFFSET_24 (651 + HUFF_OFFSET_16) - -const int huffTabOffset[HUFF_PAIRTABS] PROGMEM = { - 0, - HUFF_OFFSET_01, - HUFF_OFFSET_02, - HUFF_OFFSET_03, - 0, - HUFF_OFFSET_05, - HUFF_OFFSET_06, - HUFF_OFFSET_07, - HUFF_OFFSET_08, - HUFF_OFFSET_09, - HUFF_OFFSET_10, - HUFF_OFFSET_11, - HUFF_OFFSET_12, - HUFF_OFFSET_13, - 0, - HUFF_OFFSET_15, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_16, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, - HUFF_OFFSET_24, -}; - -const HuffTabLookup huffTabLookup[HUFF_PAIRTABS] PROGMEM = { - { 0, noBits }, - { 0, oneShot }, - { 0, oneShot }, - { 0, oneShot }, - { 0, invalidTab }, - { 0, oneShot }, - { 0, oneShot }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, loopNoLinbits }, - { 0, invalidTab }, - { 0, loopNoLinbits }, - { 1, loopLinbits }, - { 2, loopLinbits }, - { 3, loopLinbits }, - { 4, loopLinbits }, - { 6, loopLinbits }, - { 8, loopLinbits }, - { 10, loopLinbits }, - { 13, loopLinbits }, - { 4, loopLinbits }, - { 5, loopLinbits }, - { 6, loopLinbits }, - { 7, loopLinbits }, - { 8, loopLinbits }, - { 9, loopLinbits }, - { 11, loopLinbits }, - { 13, loopLinbits }, -}; - -/* tables for quadruples - * format 0xAB - * A = length of codeword - * B = codeword - */ -const unsigned char quadTable[64+16] PROGMEM = { - /* table A */ - 0x6b, 0x6f, 0x6d, 0x6e, 0x67, 0x65, 0x59, 0x59, - 0x56, 0x56, 0x53, 0x53, 0x5a, 0x5a, 0x5c, 0x5c, - 0x42, 0x42, 0x42, 0x42, 0x41, 0x41, 0x41, 0x41, - 0x44, 0x44, 0x44, 0x44, 0x48, 0x48, 0x48, 0x48, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - /* table B */ - 0x4f, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, - 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, -}; - -const int quadTabOffset[2] PROGMEM = {0, 64}; -const int quadTabMaxBits[2] PROGMEM = {6, 4}; diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/imdct.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/imdct.c deleted file mode 100644 index e24c50ae..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/imdct.c +++ /dev/null @@ -1,787 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * imdct.c - antialias, inverse transform (short/long/mixed), windowing, - * overlap-add, frequency inversion - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" -#include - -/************************************************************************************** - * Function: AntiAlias - * - * Description: smooth transition across DCT block boundaries (every 18 coefficients) - * - * Inputs: vector of dequantized coefficients, length = (nBfly+1) * 18 - * number of "butterflies" to perform (one butterfly means one - * inter-block smoothing operation) - * - * Outputs: updated coefficient vector x - * - * Return: none - * - * Notes: weighted average of opposite bands (pairwise) from the 8 samples - * before and after each block boundary - * nBlocks = (nonZeroBound + 7) / 18, since nZB is the first ZERO sample - * above which all other samples are also zero - * max gain per sample = 1.372 - * MAX(i) (abs(csa[i][0]) + abs(csa[i][1])) - * bits gained = 0 - * assume at least 1 guard bit in x[] to avoid overflow - * (should be guaranteed from dequant, and max gain from stproc * max - * gain from AntiAlias < 2.0) - **************************************************************************************/ -// a little bit faster in RAM (< 1 ms per block) -/* __attribute__ ((section (".data"))) */ static void AntiAlias(int *x, int nBfly) -{ - int k, a0, b0, c0, c1; - const int *c; - - /* csa = Q31 */ - for (k = nBfly; k > 0; k--) { - c = csa[0]; - x += 18; - - a0 = x[-1]; c0 = *c; c++; b0 = x[0]; c1 = *c; c++; - x[-1] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[0] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-2]; c0 = *c; c++; b0 = x[1]; c1 = *c; c++; - x[-2] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[1] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-3]; c0 = *c; c++; b0 = x[2]; c1 = *c; c++; - x[-3] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[2] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-4]; c0 = *c; c++; b0 = x[3]; c1 = *c; c++; - x[-4] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[3] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-5]; c0 = *c; c++; b0 = x[4]; c1 = *c; c++; - x[-5] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[4] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-6]; c0 = *c; c++; b0 = x[5]; c1 = *c; c++; - x[-6] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[5] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-7]; c0 = *c; c++; b0 = x[6]; c1 = *c; c++; - x[-7] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[6] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - - a0 = x[-8]; c0 = *c; c++; b0 = x[7]; c1 = *c; c++; - x[-8] = (MULSHIFT32(c0, a0) - MULSHIFT32(c1, b0)) << 1; - x[7] = (MULSHIFT32(c0, b0) + MULSHIFT32(c1, a0)) << 1; - } -} - -/************************************************************************************** - * Function: WinPrevious - * - * Description: apply specified window to second half of previous IMDCT (overlap part) - * - * Inputs: vector of 9 coefficients (xPrev) - * - * Outputs: 18 windowed output coefficients (gain 1 integer bit) - * window type (0, 1, 2, 3) - * - * Return: none - * - * Notes: produces 9 output samples from 18 input samples via symmetry - * all blocks gain at least 1 guard bit via window (long blocks get extra - * sign bit, short blocks can have one addition but max gain < 1.0) - **************************************************************************************/ -/*__attribute__ ((section (".data"))) */ static void WinPrevious(int *xPrev, int *xPrevWin, int btPrev) -{ - int i, x, *xp, *xpwLo, *xpwHi, wLo, wHi; - const int *wpLo, *wpHi; - - xp = xPrev; - /* mapping (see IMDCT12x3): xPrev[0-2] = sum[6-8], xPrev[3-8] = sum[12-17] */ - if (btPrev == 2) { - /* this could be reordered for minimum loads/stores */ - wpLo = imdctWin[btPrev]; - xPrevWin[ 0] = MULSHIFT32(wpLo[ 6], xPrev[2]) + MULSHIFT32(wpLo[0], xPrev[6]); - xPrevWin[ 1] = MULSHIFT32(wpLo[ 7], xPrev[1]) + MULSHIFT32(wpLo[1], xPrev[7]); - xPrevWin[ 2] = MULSHIFT32(wpLo[ 8], xPrev[0]) + MULSHIFT32(wpLo[2], xPrev[8]); - xPrevWin[ 3] = MULSHIFT32(wpLo[ 9], xPrev[0]) + MULSHIFT32(wpLo[3], xPrev[8]); - xPrevWin[ 4] = MULSHIFT32(wpLo[10], xPrev[1]) + MULSHIFT32(wpLo[4], xPrev[7]); - xPrevWin[ 5] = MULSHIFT32(wpLo[11], xPrev[2]) + MULSHIFT32(wpLo[5], xPrev[6]); - xPrevWin[ 6] = MULSHIFT32(wpLo[ 6], xPrev[5]); - xPrevWin[ 7] = MULSHIFT32(wpLo[ 7], xPrev[4]); - xPrevWin[ 8] = MULSHIFT32(wpLo[ 8], xPrev[3]); - xPrevWin[ 9] = MULSHIFT32(wpLo[ 9], xPrev[3]); - xPrevWin[10] = MULSHIFT32(wpLo[10], xPrev[4]); - xPrevWin[11] = MULSHIFT32(wpLo[11], xPrev[5]); - xPrevWin[12] = xPrevWin[13] = xPrevWin[14] = xPrevWin[15] = xPrevWin[16] = xPrevWin[17] = 0; - } else { - /* use ARM-style pointers (*ptr++) so that ADS compiles well */ - wpLo = imdctWin[btPrev] + 18; - wpHi = wpLo + 17; - xpwLo = xPrevWin; - xpwHi = xPrevWin + 17; - for (i = 9; i > 0; i--) { - x = *xp++; wLo = *wpLo++; wHi = *wpHi--; - *xpwLo++ = MULSHIFT32(wLo, x); - *xpwHi-- = MULSHIFT32(wHi, x); - } - } -} - -/************************************************************************************** - * Function: FreqInvertRescale - * - * Description: do frequency inversion (odd samples of odd blocks) and rescale - * if necessary (extra guard bits added before IMDCT) - * - * Inputs: output vector y (18 new samples, spaced NBANDS apart) - * previous sample vector xPrev (9 samples) - * index of current block - * number of extra shifts added before IMDCT (usually 0) - * - * Outputs: inverted and rescaled (as necessary) outputs - * rescaled (as necessary) previous samples - * - * Return: updated mOut (from new outputs y) - **************************************************************************************/ -/*__attribute__ ((section (".data")))*/ static int FreqInvertRescale(int *y, int *xPrev, int blockIdx, int es) -{ - int i, d, mOut; - int y0, y1, y2, y3, y4, y5, y6, y7, y8; - - if (es == 0) { - /* fast case - frequency invert only (no rescaling) - can fuse into overlap-add for speed, if desired */ - if (blockIdx & 0x01) { - y += NBANDS; - y0 = *y; y += 2*NBANDS; - y1 = *y; y += 2*NBANDS; - y2 = *y; y += 2*NBANDS; - y3 = *y; y += 2*NBANDS; - y4 = *y; y += 2*NBANDS; - y5 = *y; y += 2*NBANDS; - y6 = *y; y += 2*NBANDS; - y7 = *y; y += 2*NBANDS; - y8 = *y; y += 2*NBANDS; - - y -= 18*NBANDS; - *y = -y0; y += 2*NBANDS; - *y = -y1; y += 2*NBANDS; - *y = -y2; y += 2*NBANDS; - *y = -y3; y += 2*NBANDS; - *y = -y4; y += 2*NBANDS; - *y = -y5; y += 2*NBANDS; - *y = -y6; y += 2*NBANDS; - *y = -y7; y += 2*NBANDS; - *y = -y8; y += 2*NBANDS; - } - return 0; - } else { - /* undo pre-IMDCT scaling, clipping if necessary */ - mOut = 0; - if (blockIdx & 0x01) { - /* frequency invert */ - for (i = 0; i < 18; i+=2) { - d = *y; CLIP_2N(d, 31 - es); *y = d << es; mOut |= FASTABS(*y); y += NBANDS; - d = -*y; CLIP_2N(d, 31 - es); *y = d << es; mOut |= FASTABS(*y); y += NBANDS; - d = *xPrev; CLIP_2N(d, 31 - es); *xPrev++ = d << es; - } - } else { - for (i = 0; i < 18; i+=2) { - d = *y; CLIP_2N(d, 31 - es); *y = d << es; mOut |= FASTABS(*y); y += NBANDS; - d = *y; CLIP_2N(d, 31 - es); *y = d << es; mOut |= FASTABS(*y); y += NBANDS; - d = *xPrev; CLIP_2N(d, 31 - es); *xPrev++ = d << es; - } - } - return mOut; - } -} - -/* format = Q31 - * #define M_PI 3.14159265358979323846 - * double u = 2.0 * M_PI / 9.0; - * float c0 = sqrt(3.0) / 2.0; - * float c1 = cos(u); - * float c2 = cos(2*u); - * float c3 = sin(u); - * float c4 = sin(2*u); - */ - -static const int c9_0 = 0x6ed9eba1; -static const int c9_1 = 0x620dbe8b; -static const int c9_2 = 0x163a1a7e; -static const int c9_3 = 0x5246dd49; -static const int c9_4 = 0x7e0e2e32; - -/* format = Q31 - * cos(((0:8) + 0.5) * (pi/18)) - */ -static const int c18[9] PROGMEM = { - 0x7f834ed0, 0x7ba3751d, 0x7401e4c1, 0x68d9f964, 0x5a82799a, 0x496af3e2, 0x36185aee, 0x2120fb83, 0x0b27eb5c, -}; - -/* require at least 3 guard bits in x[] to ensure no overflow */ -static __inline void idct9(int *x) -{ - int a1, a2, a3, a4, a5, a6, a7, a8, a9; - int a10, a11, a12, a13, a14, a15, a16, a17, a18; - int a19, a20, a21, a22, a23, a24, a25, a26, a27; - int m1, m3, m5, m6, m7, m8, m9, m10, m11, m12; - int x0, x1, x2, x3, x4, x5, x6, x7, x8; - - x0 = x[0]; x1 = x[1]; x2 = x[2]; x3 = x[3]; x4 = x[4]; - x5 = x[5]; x6 = x[6]; x7 = x[7]; x8 = x[8]; - - a1 = x0 - x6; - a2 = x1 - x5; - a3 = x1 + x5; - a4 = x2 - x4; - a5 = x2 + x4; - a6 = x2 + x8; - a7 = x1 + x7; - - a8 = a6 - a5; /* ie x[8] - x[4] */ - a9 = a3 - a7; /* ie x[5] - x[7] */ - a10 = a2 - x7; /* ie x[1] - x[5] - x[7] */ - a11 = a4 - x8; /* ie x[2] - x[4] - x[8] */ - - /* do the << 1 as constant shifts where mX is actually used (free, no stall or extra inst.) */ - m1 = MULSHIFT32(c9_0, x3); - m3 = MULSHIFT32(c9_0, a10); - m5 = MULSHIFT32(c9_1, a5); - m6 = MULSHIFT32(c9_2, a6); - m7 = MULSHIFT32(c9_1, a8); - m8 = MULSHIFT32(c9_2, a5); - m9 = MULSHIFT32(c9_3, a9); - m10 = MULSHIFT32(c9_4, a7); - m11 = MULSHIFT32(c9_3, a3); - m12 = MULSHIFT32(c9_4, a9); - - a12 = x[0] + (x[6] >> 1); - a13 = a12 + ( m1 << 1); - a14 = a12 - ( m1 << 1); - a15 = a1 + ( a11 >> 1); - a16 = ( m5 << 1) + (m6 << 1); - a17 = ( m7 << 1) - (m8 << 1); - a18 = a16 + a17; - a19 = ( m9 << 1) + (m10 << 1); - a20 = (m11 << 1) - (m12 << 1); - - a21 = a20 - a19; - a22 = a13 + a16; - a23 = a14 + a16; - a24 = a14 + a17; - a25 = a13 + a17; - a26 = a14 - a18; - a27 = a13 - a18; - - x0 = a22 + a19; x[0] = x0; - x1 = a15 + (m3 << 1); x[1] = x1; - x2 = a24 + a20; x[2] = x2; - x3 = a26 - a21; x[3] = x3; - x4 = a1 - a11; x[4] = x4; - x5 = a27 + a21; x[5] = x5; - x6 = a25 - a20; x[6] = x6; - x7 = a15 - (m3 << 1); x[7] = x7; - x8 = a23 - a19; x[8] = x8; -} - -/* let c(j) = cos(M_PI/36 * ((j)+0.5)), s(j) = sin(M_PI/36 * ((j)+0.5)) - * then fastWin[2*j+0] = c(j)*(s(j) + c(j)), j = [0, 8] - * fastWin[2*j+1] = c(j)*(s(j) - c(j)) - * format = Q30 - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" -const int fastWin36[18] PROGMEM = { - 0x42aace8b, 0xc2e92724, 0x47311c28, 0xc95f619a, 0x4a868feb, 0xd0859d8c, - 0x4c913b51, 0xd8243ea0, 0x4d413ccc, 0xe0000000, 0x4c913b51, 0xe7dbc161, - 0x4a868feb, 0xef7a6275, 0x47311c28, 0xf6a09e67, 0x42aace8b, 0xfd16d8dd, -}; -#pragma GCC diagnostic pop -/************************************************************************************** - * Function: IMDCT36 - * - * Description: 36-point modified DCT, with windowing and overlap-add (50% overlap) - * - * Inputs: vector of 18 coefficients (N/2 inputs produces N outputs, by symmetry) - * overlap part of last IMDCT (9 samples - see output comments) - * window type (0,1,2,3) of current and previous block - * current block index (for deciding whether to do frequency inversion) - * number of guard bits in input vector - * - * Outputs: 18 output samples, after windowing and overlap-add with last frame - * second half of (unwindowed) 36-point IMDCT - save for next time - * only save 9 xPrev samples, using symmetry (see WinPrevious()) - * - * Notes: this is Ken's hyper-fast algorithm, including symmetric sin window - * optimization, if applicable - * total number of multiplies, general case: - * 2*10 (idct9) + 9 (last stage imdct) + 36 (for windowing) = 65 - * total number of multiplies, btCurr == 0 && btPrev == 0: - * 2*10 (idct9) + 9 (last stage imdct) + 18 (for windowing) = 47 - * - * blockType == 0 is by far the most common case, so it should be - * possible to use the fast path most of the time - * this is the fastest known algorithm for performing - * long IMDCT + windowing + overlap-add in MP3 - * - * Return: mOut (OR of abs(y) for all y calculated here) - * - * TODO: optimize for ARM (reorder window coefs, ARM-style pointers in C, - * inline asm may or may not be helpful) - **************************************************************************************/ -// barely faster in RAM -/*__attribute__ ((section (".data")))*/ static int IMDCT36(int *xCurr, int *xPrev, int *y, int btCurr, int btPrev, int blockIdx, int gb) -{ - int i, es, xBuf[18], xPrevWin[18]; - int acc1, acc2, s, d, t, mOut; - int xo, xe, c, *xp, yLo, yHi; - const int *cp, *wp; - - acc1 = acc2 = 0; - xCurr += 17; - - /* 7 gb is always adequate for antialias + accumulator loop + idct9 */ - if (gb < 7) { - /* rarely triggered - 5% to 10% of the time on normal clips (with Q25 input) */ - es = 7 - gb; - for (i = 8; i >= 0; i--) { - acc1 = ((*xCurr--) >> es) - acc1; - acc2 = acc1 - acc2; - acc1 = ((*xCurr--) >> es) - acc1; - xBuf[i+9] = acc2; /* odd */ - xBuf[i+0] = acc1; /* even */ - xPrev[i] >>= es; - } - } else { - es = 0; - /* max gain = 18, assume adequate guard bits */ - for (i = 8; i >= 0; i--) { - acc1 = (*xCurr--) - acc1; - acc2 = acc1 - acc2; - acc1 = (*xCurr--) - acc1; - xBuf[i+9] = acc2; /* odd */ - xBuf[i+0] = acc1; /* even */ - } - } - /* xEven[0] and xOdd[0] scaled by 0.5 */ - xBuf[9] >>= 1; - xBuf[0] >>= 1; - - /* do 9-point IDCT on even and odd */ - idct9(xBuf+0); /* even */ - idct9(xBuf+9); /* odd */ - - xp = xBuf + 8; - cp = c18 + 8; - mOut = 0; - if (btPrev == 0 && btCurr == 0) { - /* fast path - use symmetry of sin window to reduce windowing multiplies to 18 (N/2) */ - wp = fastWin36; - for (i = 0; i < 9; i++) { - /* do ARM-style pointer arithmetic (i still needed for y[] indexing - compiler spills if 2 y pointers) */ - c = *cp--; xo = *(xp + 9); xe = *xp--; - /* gain 2 int bits here */ - xo = MULSHIFT32(c, xo); /* 2*c18*xOdd (mul by 2 implicit in scaling) */ - xe >>= 2; - - s = -(*xPrev); /* sum from last block (always at least 2 guard bits) */ - d = -(xe - xo); /* gain 2 int bits, don't shift xo (effective << 1 to eat sign bit, << 1 for mul by 2) */ - (*xPrev++) = xe + xo; /* symmetry - xPrev[i] = xPrev[17-i] for long blocks */ - t = s - d; - - yLo = (d + (MULSHIFT32(t, *wp++) << 2)); - yHi = (s + (MULSHIFT32(t, *wp++) << 2)); - y[(i)*NBANDS] = yLo; - y[(17-i)*NBANDS] = yHi; - mOut |= FASTABS(yLo); - mOut |= FASTABS(yHi); - } - } else { - /* slower method - either prev or curr is using window type != 0 so do full 36-point window - * output xPrevWin has at least 3 guard bits (xPrev has 2, gain 1 in WinPrevious) - */ - WinPrevious(xPrev, xPrevWin, btPrev); - - wp = imdctWin[btCurr]; - for (i = 0; i < 9; i++) { - c = *cp--; xo = *(xp + 9); xe = *xp--; - /* gain 2 int bits here */ - xo = MULSHIFT32(c, xo); /* 2*c18*xOdd (mul by 2 implicit in scaling) */ - xe >>= 2; - - d = xe - xo; - (*xPrev++) = xe + xo; /* symmetry - xPrev[i] = xPrev[17-i] for long blocks */ - - yLo = (xPrevWin[i] + MULSHIFT32(d, wp[i])) << 2; - yHi = (xPrevWin[17-i] + MULSHIFT32(d, wp[17-i])) << 2; - y[(i)*NBANDS] = yLo; - y[(17-i)*NBANDS] = yHi; - mOut |= FASTABS(yLo); - mOut |= FASTABS(yHi); - } - } - - xPrev -= 9; - mOut |= FreqInvertRescale(y, xPrev, blockIdx, es); - - return mOut; -} - -static int c3_0 = 0x6ed9eba1; /* format = Q31, cos(pi/6) */ -static int c6[3] = { 0x7ba3751d, 0x5a82799a, 0x2120fb83 }; /* format = Q31, cos(((0:2) + 0.5) * (pi/6)) */ - -/* 12-point inverse DCT, used in IMDCT12x3() - * 4 input guard bits will ensure no overflow - */ -static __inline void imdct12 (int *x, int *out) -{ - int a0, a1, a2; - int x0, x1, x2, x3, x4, x5; - - x0 = *x; x+=3; x1 = *x; x+=3; - x2 = *x; x+=3; x3 = *x; x+=3; - x4 = *x; x+=3; x5 = *x; x+=3; - - x4 -= x5; - x3 -= x4; - x2 -= x3; - x3 -= x5; - x1 -= x2; - x0 -= x1; - x1 -= x3; - - x0 >>= 1; - x1 >>= 1; - - a0 = MULSHIFT32(c3_0, x2) << 1; - a1 = x0 + (x4 >> 1); - a2 = x0 - x4; - x0 = a1 + a0; - x2 = a2; - x4 = a1 - a0; - - a0 = MULSHIFT32(c3_0, x3) << 1; - a1 = x1 + (x5 >> 1); - a2 = x1 - x5; - - /* cos window odd samples, mul by 2, eat sign bit */ - x1 = MULSHIFT32(c6[0], a1 + a0) << 2; - x3 = MULSHIFT32(c6[1], a2) << 2; - x5 = MULSHIFT32(c6[2], a1 - a0) << 2; - - *out = x0 + x1; out++; - *out = x2 + x3; out++; - *out = x4 + x5; out++; - *out = x4 - x5; out++; - *out = x2 - x3; out++; - *out = x0 - x1; -} - -/************************************************************************************** - * Function: IMDCT12x3 - * - * Description: three 12-point modified DCT's for short blocks, with windowing, - * short block concatenation, and overlap-add - * - * Inputs: 3 interleaved vectors of 6 samples each - * (block0[0], block1[0], block2[0], block0[1], block1[1]....) - * overlap part of last IMDCT (9 samples - see output comments) - * window type (0,1,2,3) of previous block - * current block index (for deciding whether to do frequency inversion) - * number of guard bits in input vector - * - * Outputs: updated sample vector x, net gain of 1 integer bit - * second half of (unwindowed) IMDCT's - save for next time - * only save 9 xPrev samples, using symmetry (see WinPrevious()) - * - * Return: mOut (OR of abs(y) for all y calculated here) - * - * TODO: optimize for ARM - **************************************************************************************/ - // barely faster in RAM -/*__attribute__ ((section (".data")))*/ static int IMDCT12x3(int *xCurr, int *xPrev, int *y, int btPrev, int blockIdx, int gb) -{ - int i, es, mOut, yLo, xBuf[18], xPrevWin[18]; /* need temp buffer for reordering short blocks */ - const int *wp; - - es = 0; - /* 7 gb is always adequate for accumulator loop + idct12 + window + overlap */ - if (gb < 7) { - es = 7 - gb; - for (i = 0; i < 18; i+=2) { - xCurr[i+0] >>= es; - xCurr[i+1] >>= es; - *xPrev++ >>= es; - } - xPrev -= 9; - } - - /* requires 4 input guard bits for each imdct12 */ - imdct12(xCurr + 0, xBuf + 0); - imdct12(xCurr + 1, xBuf + 6); - imdct12(xCurr + 2, xBuf + 12); - - /* window previous from last time */ - WinPrevious(xPrev, xPrevWin, btPrev); - - /* could unroll this for speed, minimum loads (short blocks usually rare, so doesn't make much overall difference) - * xPrevWin[i] << 2 still has 1 gb always, max gain of windowed xBuf stuff also < 1.0 and gain the sign bit - * so y calculations won't overflow - */ - wp = imdctWin[2]; - mOut = 0; - for (i = 0; i < 3; i++) { - yLo = (xPrevWin[ 0+i] << 2); - mOut |= FASTABS(yLo); y[( 0+i)*NBANDS] = yLo; - yLo = (xPrevWin[ 3+i] << 2); - mOut |= FASTABS(yLo); y[( 3+i)*NBANDS] = yLo; - yLo = (xPrevWin[ 6+i] << 2) + (MULSHIFT32(wp[0+i], xBuf[3+i])); - mOut |= FASTABS(yLo); y[( 6+i)*NBANDS] = yLo; - yLo = (xPrevWin[ 9+i] << 2) + (MULSHIFT32(wp[3+i], xBuf[5-i])); - mOut |= FASTABS(yLo); y[( 9+i)*NBANDS] = yLo; - yLo = (xPrevWin[12+i] << 2) + (MULSHIFT32(wp[6+i], xBuf[2-i]) + MULSHIFT32(wp[0+i], xBuf[(6+3)+i])); - mOut |= FASTABS(yLo); y[(12+i)*NBANDS] = yLo; - yLo = (xPrevWin[15+i] << 2) + (MULSHIFT32(wp[9+i], xBuf[0+i]) + MULSHIFT32(wp[3+i], xBuf[(6+5)-i])); - mOut |= FASTABS(yLo); y[(15+i)*NBANDS] = yLo; - } - - /* save previous (unwindowed) for overlap - only need samples 6-8, 12-17 */ - for (i = 6; i < 9; i++) - *xPrev++ = xBuf[i] >> 2; - for (i = 12; i < 18; i++) - *xPrev++ = xBuf[i] >> 2; - - xPrev -= 9; - mOut |= FreqInvertRescale(y, xPrev, blockIdx, es); - - return mOut; -} - -/************************************************************************************** - * Function: HybridTransform - * - * Description: IMDCT's, windowing, and overlap-add on long/short/mixed blocks - * - * Inputs: vector of input coefficients, length = nBlocksTotal * 18) - * vector of overlap samples from last time, length = nBlocksPrev * 9) - * buffer for output samples, length = MAXNSAMP - * SideInfoSub struct for this granule/channel - * BlockCount struct with necessary info - * number of non-zero input and overlap blocks - * number of long blocks in input vector (rest assumed to be short blocks) - * number of blocks which use long window (type) 0 in case of mixed block - * (bc->currWinSwitch, 0 for non-mixed blocks) - * - * Outputs: transformed, windowed, and overlapped sample buffer - * does frequency inversion on odd blocks - * updated buffer of samples for overlap - * - * Return: number of non-zero IMDCT blocks calculated in this call - * (including overlap-add) - * - * TODO: examine mixedBlock/winSwitch logic carefully (test he_mode.bit) - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static int HybridTransform(int *xCurr, int *xPrev, int y[BLOCK_SIZE][NBANDS], SideInfoSub *sis, BlockCount *bc) -{ - int xPrevWin[18], currWinIdx, prevWinIdx; - int i, j, nBlocksOut, nonZero, mOut; - int fiBit, xp; - - ASSERT(bc->nBlocksLong <= NBANDS); - ASSERT(bc->nBlocksTotal <= NBANDS); - ASSERT(bc->nBlocksPrev <= NBANDS); - - mOut = 0; - - /* do long blocks, if any */ - for(i = 0; i < bc->nBlocksLong; i++) { - /* currWinIdx picks the right window for long blocks (if mixed, long blocks use window type 0) */ - currWinIdx = sis->blockType; - if (sis->mixedBlock && i < bc->currWinSwitch) - currWinIdx = 0; - - prevWinIdx = bc->prevType; - if (i < bc->prevWinSwitch) - prevWinIdx = 0; - - /* do 36-point IMDCT, including windowing and overlap-add */ - mOut |= IMDCT36(xCurr, xPrev, &(y[0][i]), currWinIdx, prevWinIdx, i, bc->gbIn); - xCurr += 18; - xPrev += 9; - } - - /* do short blocks (if any) */ - for ( ; i < bc->nBlocksTotal; i++) { - ASSERT(sis->blockType == 2); - - prevWinIdx = bc->prevType; - if (i < bc->prevWinSwitch) - prevWinIdx = 0; - - mOut |= IMDCT12x3(xCurr, xPrev, &(y[0][i]), prevWinIdx, i, bc->gbIn); - xCurr += 18; - xPrev += 9; - } - nBlocksOut = i; - - /* window and overlap prev if prev longer that current */ - for ( ; i < bc->nBlocksPrev; i++) { - prevWinIdx = bc->prevType; - if (i < bc->prevWinSwitch) - prevWinIdx = 0; - WinPrevious(xPrev, xPrevWin, prevWinIdx); - - nonZero = 0; - fiBit = i << 31; - for (j = 0; j < 9; j++) { - xp = xPrevWin[2*j+0] << 2; /* << 2 temp for scaling */ - nonZero |= xp; - y[2*j+0][i] = xp; - mOut |= FASTABS(xp); - - /* frequency inversion on odd blocks/odd samples (flip sign if i odd, j odd) */ - xp = xPrevWin[2*j+1] << 2; - xp = (xp ^ (fiBit >> 31)) + (i & 0x01); - nonZero |= xp; - y[2*j+1][i] = xp; - mOut |= FASTABS(xp); - - xPrev[j] = 0; - } - xPrev += 9; - if (nonZero) - nBlocksOut = i; - } - - /* clear rest of blocks */ - for ( ; i < 32; i++) { - for (j = 0; j < 18; j++) - y[j][i] = 0; - } - - bc->gbOut = CLZ(mOut) - 1; - - return nBlocksOut; -} - -/************************************************************************************** - * Function: IMDCT - * - * Description: do alias reduction, inverse MDCT, overlap-add, and frequency inversion - * - * Inputs: MP3DecInfo structure filled by UnpackFrameHeader(), UnpackSideInfo(), - * UnpackScaleFactors(), and DecodeHuffman() (for this granule, channel) - * includes PCM samples in overBuf (from last call to IMDCT) for OLA - * index of current granule and channel - * - * Outputs: PCM samples in outBuf, for input to subband transform - * PCM samples in overBuf, for OLA next time - * updated hi->nonZeroBound index for this channel - * - * Return: 0 on success, -1 if null input pointers - **************************************************************************************/ - // a bit faster in RAM -/*__attribute__ ((section (".data")))*/ int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch) -{ - int nBfly, blockCutoff; - FrameHeader *fh; - SideInfo *si; - HuffmanInfo *hi; - IMDCTInfo *mi; - BlockCount bc; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS || - !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->IMDCTInfoPS) - return -1; - - /* si is an array of up to 4 structs, stored as gr0ch0, gr0ch1, gr1ch0, gr1ch1 */ - fh = (FrameHeader *)(mp3DecInfo->FrameHeaderPS); - si = (SideInfo *)(mp3DecInfo->SideInfoPS); - hi = (HuffmanInfo*)(mp3DecInfo->HuffmanInfoPS); - mi = (IMDCTInfo *)(mp3DecInfo->IMDCTInfoPS); - - /* anti-aliasing done on whole long blocks only - * for mixed blocks, nBfly always 1, except 3 for 8 kHz MPEG 2.5 (see sfBandTab) - * nLongBlocks = number of blocks with (possibly) non-zero power - * nBfly = number of butterflies to do (nLongBlocks - 1, unless no long blocks) - */ - blockCutoff = fh->sfBand->l[(fh->ver == MPEG1 ? 8 : 6)] / 18; /* same as 3* num short sfb's in spec */ - if (si->sis[gr][ch].blockType != 2) { - /* all long transforms */ - bc.nBlocksLong = MIN((hi->nonZeroBound[ch] + 7) / 18 + 1, 32); - nBfly = bc.nBlocksLong - 1; - } else if (si->sis[gr][ch].blockType == 2 && si->sis[gr][ch].mixedBlock) { - /* mixed block - long transforms until cutoff, then short transforms */ - bc.nBlocksLong = blockCutoff; - nBfly = bc.nBlocksLong - 1; - } else { - /* all short transforms */ - bc.nBlocksLong = 0; - nBfly = 0; - } - - AntiAlias(hi->huffDecBuf[ch], nBfly); - hi->nonZeroBound[ch] = MAX(hi->nonZeroBound[ch], (nBfly * 18) + 8); - - ASSERT(hi->nonZeroBound[ch] <= MAX_NSAMP); - - /* for readability, use a struct instead of passing a million parameters to HybridTransform() */ - bc.nBlocksTotal = (hi->nonZeroBound[ch] + 17) / 18; - bc.nBlocksPrev = mi->numPrevIMDCT[ch]; - bc.prevType = mi->prevType[ch]; - bc.prevWinSwitch = mi->prevWinSwitch[ch]; - bc.currWinSwitch = (si->sis[gr][ch].mixedBlock ? blockCutoff : 0); /* where WINDOW switches (not nec. transform) */ - bc.gbIn = hi->gb[ch]; - - mi->numPrevIMDCT[ch] = HybridTransform(hi->huffDecBuf[ch], mi->overBuf[ch], mi->outBuf[ch], &si->sis[gr][ch], &bc); - mi->prevType[ch] = si->sis[gr][ch].blockType; - mi->prevWinSwitch[ch] = bc.currWinSwitch; /* 0 means not a mixed block (either all short or all long) */ - mi->gb[ch] = bc.gbOut; - - ASSERT(mi->numPrevIMDCT[ch] <= NBANDS); - - /* output has gained 2 int bits */ - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3common.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3common.h deleted file mode 100644 index 07548abf..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3common.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * mp3common.h - implementation-independent API's, datatypes, and definitions - **************************************************************************************/ - -#ifndef _MP3COMMON_H -#define _MP3COMMON_H - -#include "mp3dec.h" -#include "statname.h" /* do name-mangling for static linking */ - -#define MAX_SCFBD 4 /* max scalefactor bands per channel */ -#define NGRANS_MPEG1 2 -#define NGRANS_MPEG2 1 - -/* 11-bit syncword if MPEG 2.5 extensions are enabled */ -/* -#define SYNCWORDH 0xff -#define SYNCWORDL 0xe0 -*/ - -/* 12-bit syncword if MPEG 1,2 only are supported */ -#define SYNCWORDH 0xff -#define SYNCWORDL 0xf0 - -typedef struct _MP3DecInfo { - /* pointers to platform-specific data structures */ - void *FrameHeaderPS; - void *SideInfoPS; - void *ScaleFactorInfoPS; - void *HuffmanInfoPS; - void *DequantInfoPS; - void *IMDCTInfoPS; - void *SubbandInfoPS; - - /* buffer which must be large enough to hold largest possible main_data section */ - unsigned char mainBuf[MAINBUF_SIZE]; - - /* special info for "free" bitrate files */ - int freeBitrateFlag; - int freeBitrateSlots; - - /* user-accessible info */ - int bitrate; - int nChans; - int samprate; - int nGrans; /* granules per frame */ - int nGranSamps; /* samples per granule */ - int nSlots; - int layer; - MPEGVersion version; - - int mainDataBegin; - int mainDataBytes; - - int part23Length[MAX_NGRAN][MAX_NCHAN]; - -} MP3DecInfo; - -typedef struct _SFBandTable { - int/*short*/ l[23]; - int/*short*/ s[14]; -} SFBandTable; - -/* decoder functions which must be implemented for each platform */ -MP3DecInfo *AllocateBuffers(void); -void FreeBuffers(MP3DecInfo *mp3DecInfo); -int CheckPadBit(MP3DecInfo *mp3DecInfo); -int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf); -int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf); -int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch); -int Dequantize(MP3DecInfo *mp3DecInfo, int gr); -int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch); -int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch); -int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf); - -/* mp3tabs.c - global ROM tables */ -extern const int samplerateTab[3][3]; -extern const int/*short*/ bitrateTab[3][3][15]; -extern const int/*short*/ samplesPerFrameTab[3][3]; -extern const short bitsPerSlotTab[3]; -extern const int/*short*/ sideBytesTab[3][2]; -extern const int/*short*/ slotTab[3][3][15]; -extern const SFBandTable sfBandTable[3][3]; - -#endif /* _MP3COMMON_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.c deleted file mode 100644 index 5e68c7af..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.c +++ /dev/null @@ -1,484 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * mp3dec.c - platform-independent top level MP3 decoder API - **************************************************************************************/ - -#include "string.h" -//#include "hlxclib/string.h" /* for memmove, memcpy (can replace with different implementations if desired) */ -#include "mp3common.h" /* includes mp3dec.h (public API) and internal, platform-independent API */ - - -//#define PROFILE -#ifdef PROFILE -#include "systime.h" -#endif - -/************************************************************************************** - * Function: MP3InitDecoder - * - * Description: allocate memory for platform-specific data - * clear all the user-accessible fields - * - * Inputs: none - * - * Outputs: none - * - * Return: handle to mp3 decoder instance, 0 if malloc fails - **************************************************************************************/ -HMP3Decoder MP3InitDecoder(void) -{ - MP3DecInfo *mp3DecInfo; - - mp3DecInfo = AllocateBuffers(); - - return (HMP3Decoder)mp3DecInfo; -} - -/************************************************************************************** - * Function: MP3FreeDecoder - * - * Description: free platform-specific data allocated by InitMP3Decoder - * zero out the contents of MP3DecInfo struct - * - * Inputs: valid MP3 decoder instance pointer (HMP3Decoder) - * - * Outputs: none - * - * Return: none - **************************************************************************************/ -void MP3FreeDecoder(HMP3Decoder hMP3Decoder) -{ - MP3DecInfo *mp3DecInfo = (MP3DecInfo *)hMP3Decoder; - - if (!mp3DecInfo) - return; - - FreeBuffers(mp3DecInfo); -} - -/************************************************************************************** - * Function: MP3FindSyncWord - * - * Description: locate the next byte-alinged sync word in the raw mp3 stream - * - * Inputs: buffer to search for sync word - * max number of bytes to search in buffer - * - * Outputs: none - * - * Return: offset to first sync word (bytes from start of buf) - * -1 if sync not found after searching nBytes - **************************************************************************************/ -int MP3FindSyncWord(unsigned char *buf, int nBytes) -{ - int i; - - /* find byte-aligned syncword - need 12 (MPEG 1,2) or 11 (MPEG 2.5) matching bits */ - for (i = 0; i < nBytes - 1; i++) { - if ( (buf[i+0] & SYNCWORDH) == SYNCWORDH && (buf[i+1] & SYNCWORDL) == SYNCWORDL ) - return i; - } - - return -1; -} - -/************************************************************************************** - * Function: MP3FindFreeSync - * - * Description: figure out number of bytes between adjacent sync words in "free" mode - * - * Inputs: buffer to search for next sync word - * the 4-byte frame header starting at the current sync word - * max number of bytes to search in buffer - * - * Outputs: none - * - * Return: offset to next sync word, minus any pad byte (i.e. nSlots) - * -1 if sync not found after searching nBytes - * - * Notes: this checks that the first 22 bits of the next frame header are the - * same as the current frame header, but it's still not foolproof - * (could accidentally find a sequence in the bitstream which - * appears to match but is not actually the next frame header) - * this could be made more error-resilient by checking several frames - * in a row and verifying that nSlots is the same in each case - * since free mode requires CBR (see spec) we generally only call - * this function once (first frame) then store the result (nSlots) - * and just use it from then on - **************************************************************************************/ -static int MP3FindFreeSync(unsigned char *buf, unsigned char firstFH[4], int nBytes) -{ - int offset = 0; - unsigned char *bufPtr = buf; - - /* loop until we either: - * - run out of nBytes (FindMP3SyncWord() returns -1) - * - find the next valid frame header (sync word, version, layer, CRC flag, bitrate, and sample rate - * in next header must match current header) - */ - while (1) { - offset = MP3FindSyncWord(bufPtr, nBytes); - bufPtr += offset; - if (offset < 0) { - return -1; - } else if ( (bufPtr[0] == firstFH[0]) && (bufPtr[1] == firstFH[1]) && ((bufPtr[2] & 0xfc) == (firstFH[2] & 0xfc)) ) { - /* want to return number of bytes per frame, NOT counting the padding byte, so subtract one if padFlag == 1 */ - if ((firstFH[2] >> 1) & 0x01) - bufPtr--; - return bufPtr - buf; - } - bufPtr += 3; - nBytes -= (offset + 3); - }; - - return -1; -} - -/************************************************************************************** - * Function: MP3GetLastFrameInfo - * - * Description: get info about last MP3 frame decoded (number of sampled decoded, - * sample rate, bitrate, etc.) - * - * Inputs: valid MP3 decoder instance pointer (HMP3Decoder) - * pointer to MP3FrameInfo struct - * - * Outputs: filled-in MP3FrameInfo struct - * - * Return: none - * - * Notes: call this right after calling MP3Decode - **************************************************************************************/ -void MP3GetLastFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo) -{ - MP3DecInfo *mp3DecInfo = (MP3DecInfo *)hMP3Decoder; - - if (!mp3DecInfo || mp3DecInfo->layer != 3) { - mp3FrameInfo->bitrate = 0; - mp3FrameInfo->nChans = 0; - mp3FrameInfo->samprate = 0; - mp3FrameInfo->bitsPerSample = 0; - mp3FrameInfo->outputSamps = 0; - mp3FrameInfo->layer = 0; - mp3FrameInfo->version = 0; - } else { - mp3FrameInfo->bitrate = mp3DecInfo->bitrate; - mp3FrameInfo->nChans = mp3DecInfo->nChans; - mp3FrameInfo->samprate = mp3DecInfo->samprate; - mp3FrameInfo->bitsPerSample = 16; - mp3FrameInfo->outputSamps = mp3DecInfo->nChans * (int)samplesPerFrameTab[mp3DecInfo->version][mp3DecInfo->layer - 1]; - mp3FrameInfo->layer = mp3DecInfo->layer; - mp3FrameInfo->version = mp3DecInfo->version; - } -} - -/************************************************************************************** - * Function: MP3GetNextFrameInfo - * - * Description: parse MP3 frame header - * - * Inputs: valid MP3 decoder instance pointer (HMP3Decoder) - * pointer to MP3FrameInfo struct - * pointer to buffer containing valid MP3 frame header (located using - * MP3FindSyncWord(), above) - * - * Outputs: filled-in MP3FrameInfo struct - * - * Return: error code, defined in mp3dec.h (0 means no error, < 0 means error) - **************************************************************************************/ -int MP3GetNextFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo, unsigned char *buf) -{ - MP3DecInfo *mp3DecInfo = (MP3DecInfo *)hMP3Decoder; - - if (!mp3DecInfo) - return ERR_MP3_NULL_POINTER; - - if (UnpackFrameHeader(mp3DecInfo, buf) == -1 || mp3DecInfo->layer != 3) - return ERR_MP3_INVALID_FRAMEHEADER; - - MP3GetLastFrameInfo(mp3DecInfo, mp3FrameInfo); - - return ERR_MP3_NONE; -} - -/************************************************************************************** - * Function: MP3ClearBadFrame - * - * Description: zero out pcm buffer if error decoding MP3 frame - * - * Inputs: mp3DecInfo struct with correct frame size parameters filled in - * pointer pcm output buffer - * - * Outputs: zeroed out pcm buffer - * - * Return: none - **************************************************************************************/ -static void MP3ClearBadFrame(MP3DecInfo *mp3DecInfo, short *outbuf) -{ - int i; - - if (!mp3DecInfo) - return; - - for (i = 0; i < mp3DecInfo->nGrans * mp3DecInfo->nGranSamps * mp3DecInfo->nChans; i++) - outbuf[i] = 0; -} - -/************************************************************************************** - * Function: MP3Decode - * - * Description: decode one frame of MP3 data - * - * Inputs: valid MP3 decoder instance pointer (HMP3Decoder) - * double pointer to buffer of MP3 data (containing headers + mainData) - * number of valid bytes remaining in inbuf - * pointer to outbuf, big enough to hold one frame of decoded PCM samples - * flag indicating whether MP3 data is normal MPEG format (useSize = 0) - * or reformatted as "self-contained" frames (useSize = 1) - * - * Outputs: PCM data in outbuf, interleaved LRLRLR... if stereo - * number of output samples = nGrans * nGranSamps * nChans - * updated inbuf pointer, updated bytesLeft - * - * Return: error code, defined in mp3dec.h (0 means no error, < 0 means error) - * - * Notes: switching useSize on and off between frames in the same stream - * is not supported (bit reservoir is not maintained if useSize on) - **************************************************************************************/ -int MP3Decode(HMP3Decoder hMP3Decoder, unsigned char **inbuf, int *bytesLeft, short *outbuf, int useSize) -{ - int offset, bitOffset, mainBits, gr, ch, fhBytes, siBytes, freeFrameBytes; - int prevBitOffset, sfBlockBits, huffBlockBits; - unsigned char *mainPtr; - MP3DecInfo *mp3DecInfo = (MP3DecInfo *)hMP3Decoder; - - #ifdef PROFILE - long time; - #endif - - if (!mp3DecInfo) - return ERR_MP3_NULL_POINTER; - - /* unpack frame header */ - fhBytes = UnpackFrameHeader(mp3DecInfo, *inbuf); - if (fhBytes < 0) - return ERR_MP3_INVALID_FRAMEHEADER; /* don't clear outbuf since we don't know size (failed to parse header) */ - *inbuf += fhBytes; - -#ifdef PROFILE - time = systime_get(); -#endif - /* unpack side info */ - siBytes = UnpackSideInfo(mp3DecInfo, *inbuf); - if (siBytes < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_SIDEINFO; - } - *inbuf += siBytes; - *bytesLeft -= (fhBytes + siBytes); -#ifdef PROFILE - time = systime_get() - time; - printf("UnpackSideInfo: %i ms\n", time); -#endif - - - /* if free mode, need to calculate bitrate and nSlots manually, based on frame size */ - if (mp3DecInfo->bitrate == 0 || mp3DecInfo->freeBitrateFlag) { - if (!mp3DecInfo->freeBitrateFlag) { - /* first time through, need to scan for next sync word and figure out frame size */ - mp3DecInfo->freeBitrateFlag = 1; - mp3DecInfo->freeBitrateSlots = MP3FindFreeSync(*inbuf, *inbuf - fhBytes - siBytes, *bytesLeft); - if (mp3DecInfo->freeBitrateSlots < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_FREE_BITRATE_SYNC; - } - freeFrameBytes = mp3DecInfo->freeBitrateSlots + fhBytes + siBytes; - mp3DecInfo->bitrate = (freeFrameBytes * mp3DecInfo->samprate * 8) / (mp3DecInfo->nGrans * mp3DecInfo->nGranSamps); - } - mp3DecInfo->nSlots = mp3DecInfo->freeBitrateSlots + CheckPadBit(mp3DecInfo); /* add pad byte, if required */ - } - - /* useSize != 0 means we're getting reformatted (RTP) packets (see RFC 3119) - * - calling function assembles "self-contained" MP3 frames by shifting any main_data - * from the bit reservoir (in previous frames) to AFTER the sync word and side info - * - calling function should set mainDataBegin to 0, and tell us exactly how large this - * frame is (in bytesLeft) - */ - if (useSize) { - mp3DecInfo->nSlots = *bytesLeft; - if (mp3DecInfo->mainDataBegin != 0 || mp3DecInfo->nSlots <= 0) { - /* error - non self-contained frame, or missing frame (size <= 0), could do loss concealment here */ - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_FRAMEHEADER; - } - - /* can operate in-place on reformatted frames */ - mp3DecInfo->mainDataBytes = mp3DecInfo->nSlots; - mainPtr = *inbuf; - *inbuf += mp3DecInfo->nSlots; - *bytesLeft -= (mp3DecInfo->nSlots); - } else { - /* out of data - assume last or truncated frame */ - if (mp3DecInfo->nSlots > *bytesLeft) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INDATA_UNDERFLOW; - } - -#ifdef PROFILE - time = systime_get(); -#endif - /* fill main data buffer with enough new data for this frame */ - if (mp3DecInfo->mainDataBytes >= mp3DecInfo->mainDataBegin) { - /* adequate "old" main data available (i.e. bit reservoir) */ - memmove(mp3DecInfo->mainBuf, mp3DecInfo->mainBuf + mp3DecInfo->mainDataBytes - mp3DecInfo->mainDataBegin, mp3DecInfo->mainDataBegin); - memcpy(mp3DecInfo->mainBuf + mp3DecInfo->mainDataBegin, *inbuf, mp3DecInfo->nSlots); - - mp3DecInfo->mainDataBytes = mp3DecInfo->mainDataBegin + mp3DecInfo->nSlots; - *inbuf += mp3DecInfo->nSlots; - *bytesLeft -= (mp3DecInfo->nSlots); - mainPtr = mp3DecInfo->mainBuf; - } else { - /* not enough data in bit reservoir from previous frames (perhaps starting in middle of file) */ - memcpy(mp3DecInfo->mainBuf + mp3DecInfo->mainDataBytes, *inbuf, mp3DecInfo->nSlots); - mp3DecInfo->mainDataBytes += mp3DecInfo->nSlots; - *inbuf += mp3DecInfo->nSlots; - *bytesLeft -= (mp3DecInfo->nSlots); - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_MAINDATA_UNDERFLOW; - } -#ifdef PROFILE - time = systime_get() - time; - printf("data buffer filling: %i ms\n", time); -#endif - - } - bitOffset = 0; - mainBits = mp3DecInfo->mainDataBytes * 8; - - /* decode one complete frame */ - for (gr = 0; gr < mp3DecInfo->nGrans; gr++) { - for (ch = 0; ch < mp3DecInfo->nChans; ch++) { - - #ifdef PROFILE - time = systime_get(); - #endif - /* unpack scale factors and compute size of scale factor block */ - prevBitOffset = bitOffset; - offset = UnpackScaleFactors(mp3DecInfo, mainPtr, &bitOffset, mainBits, gr, ch); - #ifdef PROFILE - time = systime_get() - time; - printf("UnpackScaleFactors: %i ms\n", time); - #endif - - sfBlockBits = 8*offset - prevBitOffset + bitOffset; - huffBlockBits = mp3DecInfo->part23Length[gr][ch] - sfBlockBits; - mainPtr += offset; - mainBits -= sfBlockBits; - - if (offset < 0 || mainBits < huffBlockBits) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_SCALEFACT; - } - - #ifdef PROFILE - time = systime_get(); - #endif - /* decode Huffman code words */ - prevBitOffset = bitOffset; - offset = DecodeHuffman(mp3DecInfo, mainPtr, &bitOffset, huffBlockBits, gr, ch); - if (offset < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_HUFFCODES; - } - #ifdef PROFILE - time = systime_get() - time; - printf("Huffman: %i ms\n", time); - #endif - - mainPtr += offset; - mainBits -= (8*offset - prevBitOffset + bitOffset); - } - - #ifdef PROFILE - time = systime_get(); - #endif - /* dequantize coefficients, decode stereo, reorder short blocks */ - if (Dequantize(mp3DecInfo, gr) < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_DEQUANTIZE; - } - #ifdef PROFILE - time = systime_get() - time; - printf("Dequantize: %i ms\n", time); - #endif - - /* alias reduction, inverse MDCT, overlap-add, frequency inversion */ - for (ch = 0; ch < mp3DecInfo->nChans; ch++) - { - #ifdef PROFILE - time = systime_get(); - #endif - if (IMDCT(mp3DecInfo, gr, ch) < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_IMDCT; - } - #ifdef PROFILE - time = systime_get() - time; - printf("IMDCT: %i ms\n", time); - #endif - } - - #ifdef PROFILE - time = systime_get(); - #endif - /* subband transform - if stereo, interleaves pcm LRLRLR */ - if (Subband(mp3DecInfo, outbuf + gr*mp3DecInfo->nGranSamps*mp3DecInfo->nChans) < 0) { - MP3ClearBadFrame(mp3DecInfo, outbuf); - return ERR_MP3_INVALID_SUBBAND; - } - #ifdef PROFILE - time = systime_get() - time; - printf("Subband: %i ms\n", time); - #endif - - } - return ERR_MP3_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.h deleted file mode 100644 index f69eae39..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3dec.h +++ /dev/null @@ -1,148 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * mp3dec.h - public C API for MP3 decoder - **************************************************************************************/ - -#include -#define Word64 uint64_t - #ifdef ESP8266 -# include "pgmspace.h" -#elif defined(ESP_PLATFORM) && __has_include() -# include -#else -# define PROGMEM -# define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -# define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif -#ifndef _MP3DEC_H -#define _MP3DEC_H - -#if defined(_WIN32) && !defined(_WIN32_WCE) -# -#elif defined(_WIN32) && defined(WINCE_EMULATOR) -# -#elif defined(ARM_ADS) -# -#elif defined(__APPLE__) -# -#elif defined(_SYMBIAN) && defined(__WINS__) /* Symbian emulator for Ix86 */ -# -#elif defined(__GNUC__) && defined(__thumb__) -# -#elif defined(__GNUC__) && defined(__i386__) -# -#elif defined(__amd64__) -# -#elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR) -# -#elif defined (ESP_PLATFORM) -# -#else -#error No platform defined. See valid options in mp3dec.h -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/* determining MAINBUF_SIZE: - * max mainDataBegin = (2^9 - 1) bytes (since 9-bit offset) = 511 - * max nSlots (concatenated with mainDataBegin bytes from before) = 1440 - 9 - 4 + 1 = 1428 - * 511 + 1428 = 1939, round up to 1940 (4-byte align) - */ -#define MAINBUF_SIZE 1940 - -#define MAX_NGRAN 2 /* max granules */ -#define MAX_NCHAN 2 /* max channels */ -#define MAX_NSAMP 576 /* max samples per channel, per granule */ - -/* map to 0,1,2 to make table indexing easier */ -typedef enum { - MPEG1 = 0, - MPEG2 = 1, - MPEG25 = 2 -} MPEGVersion; - -typedef void *HMP3Decoder; - -enum { - ERR_MP3_NONE = 0, - ERR_MP3_INDATA_UNDERFLOW = -1, - ERR_MP3_MAINDATA_UNDERFLOW = -2, - ERR_MP3_FREE_BITRATE_SYNC = -3, - ERR_MP3_OUT_OF_MEMORY = -4, - ERR_MP3_NULL_POINTER = -5, - ERR_MP3_INVALID_FRAMEHEADER = -6, - ERR_MP3_INVALID_SIDEINFO = -7, - ERR_MP3_INVALID_SCALEFACT = -8, - ERR_MP3_INVALID_HUFFCODES = -9, - ERR_MP3_INVALID_DEQUANTIZE = -10, - ERR_MP3_INVALID_IMDCT = -11, - ERR_MP3_INVALID_SUBBAND = -12, - - ERR_UNKNOWN = -9999 -}; - -typedef struct _MP3FrameInfo { - int bitrate; - int nChans; - int samprate; - int bitsPerSample; - int outputSamps; - int layer; - int version; -} MP3FrameInfo; - -/* public API */ -HMP3Decoder MP3InitDecoder(void); -void MP3FreeDecoder(HMP3Decoder hMP3Decoder); -int MP3Decode(HMP3Decoder hMP3Decoder, unsigned char **inbuf, int *bytesLeft, short *outbuf, int useSize); - -void MP3GetLastFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo); -int MP3GetNextFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo, unsigned char *buf); -int MP3FindSyncWord(unsigned char *buf, int nBytes); - -#ifdef __cplusplus -} -#endif - -#endif /* _MP3DEC_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3tabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3tabs.c deleted file mode 100644 index 7d5fec22..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mp3tabs.c +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * mp3tabs.c - platform-independent tables for MP3 decoder (global, read-only) - **************************************************************************************/ - -#include "mp3common.h" -#include - -/* indexing = [version][samplerate index] - * sample rate of frame (Hz) - */ -const int samplerateTab[3][3] PROGMEM = { - {44100, 48000, 32000}, /* MPEG-1 */ - {22050, 24000, 16000}, /* MPEG-2 */ - {11025, 12000, 8000}, /* MPEG-2.5 */ -}; - -/* indexing = [version][layer][bitrate index] - * bitrate (kbps) of frame - * - bitrate index == 0 is "free" mode (bitrate determined on the fly by - * counting bits between successive sync words) - */ -const int/*short*/ bitrateTab[3][3][15] PROGMEM = { - { - /* MPEG-1 */ - { 0, 32, 64, 96,128,160,192,224,256,288,320,352,384,416,448}, /* Layer 1 */ - { 0, 32, 48, 56, 64, 80, 96,112,128,160,192,224,256,320,384}, /* Layer 2 */ - { 0, 32, 40, 48, 56, 64, 80, 96,112,128,160,192,224,256,320}, /* Layer 3 */ - }, - { - /* MPEG-2 */ - { 0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256}, /* Layer 1 */ - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}, /* Layer 2 */ - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}, /* Layer 3 */ - }, - { - /* MPEG-2.5 */ - { 0, 32, 48, 56, 64, 80, 96,112,128,144,160,176,192,224,256}, /* Layer 1 */ - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}, /* Layer 2 */ - { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}, /* Layer 3 */ - }, -}; - -/* indexing = [version][layer] - * number of samples in one frame (per channel) - */ -const int/*short*/ samplesPerFrameTab[3][3] PROGMEM = { - {384, 1152, 1152 }, /* MPEG1 */ - {384, 1152, 576 }, /* MPEG2 */ - {384, 1152, 576 }, /* MPEG2.5 */ -}; - -/* layers 1, 2, 3 */ -const short bitsPerSlotTab[3] = {32, 8, 8}; - -/* indexing = [version][mono/stereo] - * number of bytes in side info section of bitstream - */ -const int/*short*/ sideBytesTab[3][2] PROGMEM = { - {17, 32}, /* MPEG-1: mono, stereo */ - { 9, 17}, /* MPEG-2: mono, stereo */ - { 9, 17}, /* MPEG-2.5: mono, stereo */ -}; - -/* indexing = [version][sampleRate][bitRate] - * for layer3, nSlots = floor(samps/frame * bitRate / sampleRate / 8) - * - add one pad slot if necessary - */ -const int/*short*/ slotTab[3][3][15] PROGMEM = { - { - /* MPEG-1 */ - { 0, 104, 130, 156, 182, 208, 261, 313, 365, 417, 522, 626, 731, 835,1044 }, /* 44 kHz */ - { 0, 96, 120, 144, 168, 192, 240, 288, 336, 384, 480, 576, 672, 768, 960 }, /* 48 kHz */ - { 0, 144, 180, 216, 252, 288, 360, 432, 504, 576, 720, 864,1008,1152,1440 }, /* 32 kHz */ - }, - { - /* MPEG-2 */ - { 0, 26, 52, 78, 104, 130, 156, 182, 208, 261, 313, 365, 417, 470, 522 }, /* 22 kHz */ - { 0, 24, 48, 72, 96, 120, 144, 168, 192, 240, 288, 336, 384, 432, 480 }, /* 24 kHz */ - { 0, 36, 72, 108, 144, 180, 216, 252, 288, 360, 432, 504, 576, 648, 720 }, /* 16 kHz */ - }, - { - /* MPEG-2.5 */ - { 0, 52, 104, 156, 208, 261, 313, 365, 417, 522, 626, 731, 835, 940,1044 }, /* 11 kHz */ - { 0, 48, 96, 144, 192, 240, 288, 336, 384, 480, 576, 672, 768, 864, 960 }, /* 12 kHz */ - { 0, 72, 144, 216, 288, 360, 432, 504, 576, 720, 864,1008,1152,1296,1440 }, /* 8 kHz */ - }, -}; - -/* indexing = [version][sampleRate][long (.l) or short (.s) block] - * sfBandTable[v][s].l[cb] = index of first bin in critical band cb (long blocks) - * sfBandTable[v][s].s[cb] = index of first bin in critical band cb (short blocks) - */ -const SFBandTable sfBandTable[3][3] PROGMEM = { - { - /* MPEG-1 (44, 48, 32 kHz) */ - { - { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90,110,134,162,196,238,288,342,418,576 }, - { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84,106,136,192 } - }, - { - { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88,106,128,156,190,230,276,330,384,576 }, - { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80,100,126,192 } - }, - { - { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82,102,126,156,194,240,296,364,448,550,576 }, - { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78,104,138,180,192 } - } - }, - - { - /* MPEG-2 (22, 24, 16 kHz) */ - { - { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96,116,140,168,200,238,284,336,396,464,522,576 }, - { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74,100,132,174,192 } - }, - { - { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96,114,136,162,194,232,278,332,394,464,540,576 }, - { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80,104,136,180,192 } - }, - { - { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96,116,140,168,200,238,284,336,396,464,522,576 }, - { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80,104,134,174,192 } - }, - }, - - { - /* MPEG-2.5 (11, 12, 8 kHz) */ - { - { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96,116,140,168,200,238,284,336,396,464,522,576 }, - { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80,104,134,174,192 } - }, - { - { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96,116,140,168,200,238,284,336,396,464,522,576 }, - { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80,104,134,174,192 } - }, - { - { 0, 12, 24, 36, 48, 60, 72, 88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576 }, - { 0, 8, 16, 24, 36, 52, 72, 96,124,160,162,164,166,192 } - }, - }, -}; - - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mpadecobjfixpt.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mpadecobjfixpt.h deleted file mode 100644 index a8a5c40f..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/mpadecobjfixpt.h +++ /dev/null @@ -1,108 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef _MPADECOBJFIXPT_H_ -#define _MPADECOBJFIXPT_H_ - -#include "mp3dec.h" /* public C API for new MP3 decoder */ - -class CMpaDecObj -{ -public: - CMpaDecObj(); - ~CMpaDecObj(); - - /////////////////////////////////////////////////////////////////////////// - // Function: Init_n - // Purpose: Initialize the mp3 decoder. - // Parameters: pSync a pointer to a syncword - // ulSize the size of the buffer pSync points to - // bUseSize this tells the decoder to use the input frame - // size on the decode instead of calculating - // the frame size. This is necessary when - // our formatted mp3 data (main_data_begin always - // equal to 0). - // - // Returns: returns 1 on success, 0 on failure - /////////////////////////////////////////////////////////////////////////// - int Init_n(unsigned char *pSync, - unsigned long ulSize, - unsigned char bUseSize=0); - - /////////////////////////////////////////////////////////////////////////// - // Function: DecodeFrame_v - // Purpose: Decodes one mp3 frame - // Parameters: pSource pointer to an mp3 frame (at a syncword) - // pulSize size of the buffer pSource points to. It will - // contain the number of mp3 bytes decoded upon - // return. - // pPCM pointer to a buffer to decode into - // pulPCMSize size of the PCM buffer. It will contain the - // number of PCM bytes prodced upon return. - /////////////////////////////////////////////////////////////////////////// - void DecodeFrame_v(unsigned char *pSource, - unsigned long *pulSize, - unsigned char *pPCM, - unsigned long *pulPCMSize); - - // overloaded new version that returns error code in errCode - void DecodeFrame_v(unsigned char *pSource, - unsigned long *pulSize, - unsigned char *pPCM, - unsigned long *pulPCMSize, - int *errCode); - - void GetPCMInfo_v(unsigned long &ulSampRate, - int &nChannels, - int &nBitsPerSample); - - // return number of samples per frame, PER CHANNEL (renderer multiplies this result by nChannels) - int GetSamplesPerFrame_n(); - - void SetTrustPackets(unsigned char bTrust) { m_bTrustPackets = bTrust; } - -private: - void * m_pDec; // generic void ptr - - void * m_pDecL1; // not implemented (could use old Xing mpadecl1.cpp) - void * m_pDecL2; // not implemented (could use old Xing mpadecl2.cpp) - HMP3Decoder m_pDecL3; - - MP3FrameInfo m_lastMP3FrameInfo; - unsigned char m_bUseFrameSize; - unsigned char m_bTrustPackets; -}; - -#endif /* _MPADECOBJFIXPT_H_ */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/pgmspace.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/pgmspace.h deleted file mode 100644 index b5ace1fe..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/pgmspace.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef ESP8266 -# include "pgmspace.h" -#elif defined(ESP_PLATFORM) && __has_include() -# include -#else -# define PROGMEM -# define pgm_read_byte(addr) (*(const unsigned char *)(addr)) -# define pgm_read_word(addr) (*(const unsigned short *)(addr)) -#endif \ No newline at end of file diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/player.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/player.h deleted file mode 100644 index 40f939e7..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/player.h +++ /dev/null @@ -1,13 +0,0 @@ - - - -//SPI -#define PIN_SPI_SCK 14 -#define PIN_SPI_MOSI 7 -#define PIN_SPI_SDCARD_CS 10 //SD-Card CS -#define PIN_SPI_MEM_CS 6 //Flashmem CS - -//3V3 Voltage Regulator -#define PIN_SHUTDOWNPWR3V3 5 -#define PWR3V3_ON HIGH -#define PWR3V3_OFF LOW \ No newline at end of file diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/polyphase.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/polyphase.c deleted file mode 100644 index bd331dfe..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/polyphase.c +++ /dev/null @@ -1,295 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * polyphase.c - final stage of subband transform (polyphase synthesis filter) - * - * This is the C reference version using __int64 - * Look in the appropriate subdirectories for optimized asm implementations - * (e.g. arm/asmpoly.s) - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/* input to Polyphase = Q(DQ_FRACBITS_OUT-2), gain 2 bits in convolution - * we also have the implicit bias of 2^15 to add back, so net fraction bits = - * DQ_FRACBITS_OUT - 2 - 2 - 15 - * (see comment on Dequantize() for more info) - */ -#define DEF_NFRACBITS (DQ_FRACBITS_OUT - 2 - 2 - 15) -#define CSHIFT 12 /* coefficients have 12 leading sign bits for early-terminating mulitplies */ - -static __inline short ClipToShort(int x, int fracBits) -{ - int sign; - - /* assumes you've already rounded (x += (1 << (fracBits-1))) */ - x >>= fracBits; - - /* Ken's trick: clips to [-32768, 32767] */ - sign = x >> 31; - if (sign != (x >> 15)) - x = sign ^ ((1 << 15) - 1); - - return (short)x; -} - -#define MC0M(x) { \ - c1 = *coef; coef++; c2 = *coef; coef++; \ - vLo = *(vb1+(x)); vHi = *(vb1+(23-(x))); \ - sum1L = MADD64(sum1L, vLo, c1); sum1L = MADD64(sum1L, vHi, -c2); \ -} - -#define MC1M(x) { \ - c1 = *coef; coef++; \ - vLo = *(vb1+(x)); \ - sum1L = MADD64(sum1L, vLo, c1); \ -} - -#define MC2M(x) { \ - c1 = *coef; coef++; c2 = *coef; coef++; \ - vLo = *(vb1+(x)); vHi = *(vb1+(23-(x))); \ - sum1L = MADD64(sum1L, vLo, c1); sum2L = MADD64(sum2L, vLo, c2); \ - sum1L = MADD64(sum1L, vHi, -c2); sum2L = MADD64(sum2L, vHi, c1); \ -} - -/************************************************************************************** - * Function: PolyphaseMono - * - * Description: filter one subband and produce 32 output PCM samples for one channel - * - * Inputs: pointer to PCM output buffer - * number of "extra shifts" (vbuf format = Q(DQ_FRACBITS_OUT-2)) - * pointer to start of vbuf (preserved from last call) - * start of filter coefficient table (in proper, shuffled order) - * no minimum number of guard bits is required for input vbuf - * (see additional scaling comments below) - * - * Outputs: 32 samples of one channel of decoded PCM data, (i.e. Q16.0) - * - * Return: none - * - * TODO: add 32-bit version for platforms where 64-bit mul-acc is not supported - * (note max filter gain - see polyCoef[] comments) - **************************************************************************************/ -void PolyphaseMono(short *pcm, int *vbuf, const int *coefBase) -{ - int i; - const int *coef; - int *vb1; - int vLo, vHi, c1, c2; - Word64 sum1L, sum2L, rndVal; - - rndVal = (Word64)( 1 << (DEF_NFRACBITS - 1 + (32 - CSHIFT)) ); - - /* special case, output sample 0 */ - coef = coefBase; - vb1 = vbuf; - sum1L = rndVal; - - MC0M(0) - MC0M(1) - MC0M(2) - MC0M(3) - MC0M(4) - MC0M(5) - MC0M(6) - MC0M(7) - - *(pcm + 0) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - - /* special case, output sample 16 */ - coef = coefBase + 256; - vb1 = vbuf + 64*16; - sum1L = rndVal; - - MC1M(0) - MC1M(1) - MC1M(2) - MC1M(3) - MC1M(4) - MC1M(5) - MC1M(6) - MC1M(7) - - *(pcm + 16) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - - /* main convolution loop: sum1L = samples 1, 2, 3, ... 15 sum2L = samples 31, 30, ... 17 */ - coef = coefBase + 16; - vb1 = vbuf + 64; - pcm++; - - /* right now, the compiler creates bad asm from this... */ - for (i = 15; i > 0; i--) { - sum1L = sum2L = rndVal; - - MC2M(0) - MC2M(1) - MC2M(2) - MC2M(3) - MC2M(4) - MC2M(5) - MC2M(6) - MC2M(7) - - vb1 += 64; - *(pcm) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 2*i) = ClipToShort((int)SAR64(sum2L, (32-CSHIFT)), DEF_NFRACBITS); - pcm++; - } -} - -#define MC0S(x) { \ - c1 = *coef; coef++; c2 = *coef; coef++; \ - vLo = *(vb1+(x)); vHi = *(vb1+(23-(x))); \ - sum1L = MADD64(sum1L, vLo, c1); sum1L = MADD64(sum1L, vHi, -c2); \ - vLo = *(vb1+32+(x)); vHi = *(vb1+32+(23-(x))); \ - sum1R = MADD64(sum1R, vLo, c1); sum1R = MADD64(sum1R, vHi, -c2); \ -} - -#define MC1S(x) { \ - c1 = *coef; coef++; \ - vLo = *(vb1+(x)); \ - sum1L = MADD64(sum1L, vLo, c1); \ - vLo = *(vb1+32+(x)); \ - sum1R = MADD64(sum1R, vLo, c1); \ -} - -#define MC2S(x) { \ - c1 = *coef; coef++; c2 = *coef; coef++; \ - vLo = *(vb1+(x)); vHi = *(vb1+(23-(x))); \ - sum1L = MADD64(sum1L, vLo, c1); sum2L = MADD64(sum2L, vLo, c2); \ - sum1L = MADD64(sum1L, vHi, -c2); sum2L = MADD64(sum2L, vHi, c1); \ - vLo = *(vb1+32+(x)); vHi = *(vb1+32+(23-(x))); \ - sum1R = MADD64(sum1R, vLo, c1); sum2R = MADD64(sum2R, vLo, c2); \ - sum1R = MADD64(sum1R, vHi, -c2); sum2R = MADD64(sum2R, vHi, c1); \ -} - -/************************************************************************************** - * Function: PolyphaseStereo - * - * Description: filter one subband and produce 32 output PCM samples for each channel - * - * Inputs: pointer to PCM output buffer - * number of "extra shifts" (vbuf format = Q(DQ_FRACBITS_OUT-2)) - * pointer to start of vbuf (preserved from last call) - * start of filter coefficient table (in proper, shuffled order) - * no minimum number of guard bits is required for input vbuf - * (see additional scaling comments below) - * - * Outputs: 32 samples of two channels of decoded PCM data, (i.e. Q16.0) - * - * Return: none - * - * Notes: interleaves PCM samples LRLRLR... - * - * TODO: add 32-bit version for platforms where 64-bit mul-acc is not supported - **************************************************************************************/ -void PolyphaseStereo(short *pcm, int *vbuf, const int *coefBase) -{ - int i; - const int *coef; - int *vb1; - int vLo, vHi, c1, c2; - Word64 sum1L, sum2L, sum1R, sum2R, rndVal; - - rndVal = (Word64)( 1 << (DEF_NFRACBITS - 1 + (32 - CSHIFT)) ); - - /* special case, output sample 0 */ - coef = coefBase; - vb1 = vbuf; - sum1L = sum1R = rndVal; - - MC0S(0) - MC0S(1) - MC0S(2) - MC0S(3) - MC0S(4) - MC0S(5) - MC0S(6) - MC0S(7) - - *(pcm + 0) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 1) = ClipToShort((int)SAR64(sum1R, (32-CSHIFT)), DEF_NFRACBITS); - - /* special case, output sample 16 */ - coef = coefBase + 256; - vb1 = vbuf + 64*16; - sum1L = sum1R = rndVal; - - MC1S(0) - MC1S(1) - MC1S(2) - MC1S(3) - MC1S(4) - MC1S(5) - MC1S(6) - MC1S(7) - - *(pcm + 2*16 + 0) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 2*16 + 1) = ClipToShort((int)SAR64(sum1R, (32-CSHIFT)), DEF_NFRACBITS); - - /* main convolution loop: sum1L = samples 1, 2, 3, ... 15 sum2L = samples 31, 30, ... 17 */ - coef = coefBase + 16; - vb1 = vbuf + 64; - pcm += 2; - - /* right now, the compiler creates bad asm from this... */ - for (i = 15; i > 0; i--) { - sum1L = sum2L = rndVal; - sum1R = sum2R = rndVal; - - MC2S(0) - MC2S(1) - MC2S(2) - MC2S(3) - MC2S(4) - MC2S(5) - MC2S(6) - MC2S(7) - - vb1 += 64; - *(pcm + 0) = ClipToShort((int)SAR64(sum1L, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 1) = ClipToShort((int)SAR64(sum1R, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 2*2*i + 0) = ClipToShort((int)SAR64(sum2L, (32-CSHIFT)), DEF_NFRACBITS); - *(pcm + 2*2*i + 1) = ClipToShort((int)SAR64(sum2R, (32-CSHIFT)), DEF_NFRACBITS); - pcm += 2; - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/scalfact.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/scalfact.c deleted file mode 100644 index 4937e453..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/scalfact.c +++ /dev/null @@ -1,392 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * scalfact.c - scalefactor unpacking functions - **************************************************************************************/ - -#include "coder.h" - -/* scale factor lengths (num bits) */ -static const char SFLenTab[16][2] = { - {0, 0}, {0, 1}, - {0, 2}, {0, 3}, - {3, 0}, {1, 1}, - {1, 2}, {1, 3}, - {2, 1}, {2, 2}, - {2, 3}, {3, 1}, - {3, 2}, {3, 3}, - {4, 2}, {4, 3}, -}; - -/************************************************************************************** - * Function: UnpackSFMPEG1 - * - * Description: unpack MPEG 1 scalefactors from bitstream - * - * Inputs: BitStreamInfo, SideInfoSub, ScaleFactorInfoSub structs for this - * granule/channel - * vector of scfsi flags from side info, length = 4 (MAX_SCFBD) - * index of current granule - * ScaleFactorInfoSub from granule 0 (for granule 1, if scfsi[i] is set, - * then we just replicate the scale factors from granule 0 in the - * i'th set of scalefactor bands) - * - * Outputs: updated BitStreamInfo struct - * scalefactors in sfis (short and/or long arrays, as appropriate) - * - * Return: none - * - * Notes: set order of short blocks to s[band][window] instead of s[window][band] - * so that we index through consectutive memory locations when unpacking - * (make sure dequantizer follows same convention) - * Illegal Intensity Position = 7 (always) for MPEG1 scale factors - **************************************************************************************/ -static void UnpackSFMPEG1(BitStreamInfo *bsi, SideInfoSub *sis, ScaleFactorInfoSub *sfis, int *scfsi, int gr, ScaleFactorInfoSub *sfisGr0) -{ - int sfb; - int slen0, slen1; - - /* these can be 0, so make sure GetBits(bsi, 0) returns 0 (no >> 32 or anything) */ - slen0 = (int)SFLenTab[sis->sfCompress][0]; - slen1 = (int)SFLenTab[sis->sfCompress][1]; - - if (sis->blockType == 2) { - /* short block, type 2 (implies winSwitchFlag == 1) */ - if (sis->mixedBlock) { - /* do long block portion */ - for (sfb = 0; sfb < 8; sfb++) - sfis->l[sfb] = (char)GetBits(bsi, slen0); - sfb = 3; - } else { - /* all short blocks */ - sfb = 0; - } - - for ( ; sfb < 6; sfb++) { - sfis->s[sfb][0] = (char)GetBits(bsi, slen0); - sfis->s[sfb][1] = (char)GetBits(bsi, slen0); - sfis->s[sfb][2] = (char)GetBits(bsi, slen0); - } - - for ( ; sfb < 12; sfb++) { - sfis->s[sfb][0] = (char)GetBits(bsi, slen1); - sfis->s[sfb][1] = (char)GetBits(bsi, slen1); - sfis->s[sfb][2] = (char)GetBits(bsi, slen1); - } - - /* last sf band not transmitted */ - sfis->s[12][0] = sfis->s[12][1] = sfis->s[12][2] = 0; - } else { - /* long blocks, type 0, 1, or 3 */ - if(gr == 0) { - /* first granule */ - for (sfb = 0; sfb < 11; sfb++) - sfis->l[sfb] = (char)GetBits(bsi, slen0); - for (sfb = 11; sfb < 21; sfb++) - sfis->l[sfb] = (char)GetBits(bsi, slen1); - return; - } else { - /* second granule - * scfsi: 0 = different scalefactors for each granule, 1 = copy sf's from granule 0 into granule 1 - * for block type == 2, scfsi is always 0 - */ - sfb = 0; - if(scfsi[0]) for( ; sfb < 6 ; sfb++) sfis->l[sfb] = sfisGr0->l[sfb]; - else for( ; sfb < 6 ; sfb++) sfis->l[sfb] = (char)GetBits(bsi, slen0); - if(scfsi[1]) for( ; sfb <11 ; sfb++) sfis->l[sfb] = sfisGr0->l[sfb]; - else for( ; sfb <11 ; sfb++) sfis->l[sfb] = (char)GetBits(bsi, slen0); - if(scfsi[2]) for( ; sfb <16 ; sfb++) sfis->l[sfb] = sfisGr0->l[sfb]; - else for( ; sfb <16 ; sfb++) sfis->l[sfb] = (char)GetBits(bsi, slen1); - if(scfsi[3]) for( ; sfb <21 ; sfb++) sfis->l[sfb] = sfisGr0->l[sfb]; - else for( ; sfb <21 ; sfb++) sfis->l[sfb] = (char)GetBits(bsi, slen1); - } - /* last sf band not transmitted */ - sfis->l[21] = 0; - sfis->l[22] = 0; - } -} - -/* NRTab[size + 3*is_right][block type][partition] - * block type index: 0 = (bt0,bt1,bt3), 1 = bt2 non-mixed, 2 = bt2 mixed - * partition: scale factor groups (sfb1 through sfb4) - * for block type = 2 (mixed or non-mixed) / by 3 is rolled into this table - * (for 3 short blocks per long block) - * see 2.4.3.2 in MPEG 2 (low sample rate) spec - * stuff rolled into this table: - * NRTab[x][1][y] --> (NRTab[x][1][y]) / 3 - * NRTab[x][2][>=1] --> (NRTab[x][2][>=1]) / 3 (first partition is long block) - */ -static const char NRTab[6][3][4] = { - /* non-intensity stereo */ - { {6, 5, 5, 5}, - {3, 3, 3, 3}, /* includes / 3 */ - {6, 3, 3, 3}, /* includes / 3 except for first entry */ - }, - { {6, 5, 7, 3}, - {3, 3, 4, 2}, - {6, 3, 4, 2}, - }, - { {11, 10, 0, 0}, - {6, 6, 0, 0}, - {6, 3, 6, 0}, /* spec = [15,18,0,0], but 15 = 6L + 9S, so move 9/3=3 into col 1, 18/3=6 into col 2 and adj. slen[1,2] below */ - }, - /* intensity stereo, right chan */ - { {7, 7, 7, 0}, - {4, 4, 4, 0}, - {6, 5, 4, 0}, - }, - { {6, 6, 6, 3}, - {4, 3, 3, 2}, - {6, 4, 3, 2}, - }, - { {8, 8, 5, 0}, - {5, 4, 3, 0}, - {6, 6, 3, 0}, - } -}; - -/************************************************************************************** - * Function: UnpackSFMPEG2 - * - * Description: unpack MPEG 2 scalefactors from bitstream - * - * Inputs: BitStreamInfo, SideInfoSub, ScaleFactorInfoSub structs for this - * granule/channel - * index of current granule and channel - * ScaleFactorInfoSub from this granule - * modeExt field from frame header, to tell whether intensity stereo is on - * ScaleFactorJS struct for storing IIP info used in Dequant() - * - * Outputs: updated BitStreamInfo struct - * scalefactors in sfis (short and/or long arrays, as appropriate) - * updated intensityScale and preFlag flags - * - * Return: none - * - * Notes: Illegal Intensity Position = (2^slen) - 1 for MPEG2 scale factors - * - * TODO: optimize the / and % stuff (only do one divide, get modulo x - * with (x / m) * m, etc.) - **************************************************************************************/ -static void UnpackSFMPEG2(BitStreamInfo *bsi, SideInfoSub *sis, ScaleFactorInfoSub *sfis, int gr, int ch, int modeExt, ScaleFactorJS *sfjs) -{ - - int i, sfb, sfcIdx, btIdx, nrIdx;// iipTest; - int slen[4], nr[4]; - int sfCompress, preFlag, intensityScale; - (void)gr; - - sfCompress = sis->sfCompress; - preFlag = 0; - intensityScale = 0; - - /* stereo mode bits (1 = on): bit 1 = mid-side on/off, bit 0 = intensity on/off */ - if (! ((modeExt & 0x01) && (ch == 1)) ) { - /* in other words: if ((modeExt & 0x01) == 0 || ch == 0) */ - if (sfCompress < 400) { - /* max slen = floor[(399/16) / 5] = 4 */ - slen[0] = (sfCompress >> 4) / 5; - slen[1]= (sfCompress >> 4) % 5; - slen[2]= (sfCompress & 0x0f) >> 2; - slen[3]= (sfCompress & 0x03); - sfcIdx = 0; - } else if (sfCompress < 500) { - /* max slen = floor[(99/4) / 5] = 4 */ - sfCompress -= 400; - slen[0] = (sfCompress >> 2) / 5; - slen[1]= (sfCompress >> 2) % 5; - slen[2]= (sfCompress & 0x03); - slen[3]= 0; - sfcIdx = 1; - } else { - /* max slen = floor[11/3] = 3 (sfCompress = 9 bits in MPEG2) */ - sfCompress -= 500; - slen[0] = sfCompress / 3; - slen[1] = sfCompress % 3; - slen[2] = slen[3] = 0; - if (sis->mixedBlock) { - /* adjust for long/short mix logic (see comment above in NRTab[] definition) */ - slen[2] = slen[1]; - slen[1] = slen[0]; - } - preFlag = 1; - sfcIdx = 2; - } - } else { - /* intensity stereo ch = 1 (right) */ - intensityScale = sfCompress & 0x01; - sfCompress >>= 1; - if (sfCompress < 180) { - /* max slen = floor[35/6] = 5 (from mod 36) */ - slen[0] = (sfCompress / 36); - slen[1] = (sfCompress % 36) / 6; - slen[2] = (sfCompress % 36) % 6; - slen[3] = 0; - sfcIdx = 3; - } else if (sfCompress < 244) { - /* max slen = floor[63/16] = 3 */ - sfCompress -= 180; - slen[0] = (sfCompress & 0x3f) >> 4; - slen[1] = (sfCompress & 0x0f) >> 2; - slen[2] = (sfCompress & 0x03); - slen[3] = 0; - sfcIdx = 4; - } else { - /* max slen = floor[11/3] = 3 (max sfCompress >> 1 = 511/2 = 255) */ - sfCompress -= 244; - slen[0] = (sfCompress / 3); - slen[1] = (sfCompress % 3); - slen[2] = slen[3] = 0; - sfcIdx = 5; - } - } - - /* set index based on block type: (0,1,3) --> 0, (2 non-mixed) --> 1, (2 mixed) ---> 2 */ - btIdx = 0; - if (sis->blockType == 2) - btIdx = (sis->mixedBlock ? 2 : 1); - for (i = 0; i < 4; i++) - nr[i] = (int)NRTab[sfcIdx][btIdx][i]; - - /* save intensity stereo scale factor info */ - if( (modeExt & 0x01) && (ch == 1) ) { - for (i = 0; i < 4; i++) { - sfjs->slen[i] = slen[i]; - sfjs->nr[i] = nr[i]; - } - sfjs->intensityScale = intensityScale; - } - sis->preFlag = preFlag; - - /* short blocks */ - if(sis->blockType == 2) { - if(sis->mixedBlock) { - /* do long block portion */ - //iipTest = (1 << slen[0]) - 1; - for (sfb=0; sfb < 6; sfb++) { - sfis->l[sfb] = (char)GetBits(bsi, slen[0]); - } - sfb = 3; /* start sfb for short */ - nrIdx = 1; - } else { - /* all short blocks, so start nr, sfb at 0 */ - sfb = 0; - nrIdx = 0; - } - - /* remaining short blocks, sfb just keeps incrementing */ - for ( ; nrIdx <= 3; nrIdx++) { - //iipTest = (1 << slen[nrIdx]) - 1; - for (i=0; i < nr[nrIdx]; i++, sfb++) { - sfis->s[sfb][0] = (char)GetBits(bsi, slen[nrIdx]); - sfis->s[sfb][1] = (char)GetBits(bsi, slen[nrIdx]); - sfis->s[sfb][2] = (char)GetBits(bsi, slen[nrIdx]); - } - } - /* last sf band not transmitted */ - sfis->s[12][0] = sfis->s[12][1] = sfis->s[12][2] = 0; - } else { - /* long blocks */ - sfb = 0; - for (nrIdx = 0; nrIdx <= 3; nrIdx++) { - //iipTest = (1 << slen[nrIdx]) - 1; - for(i=0; i < nr[nrIdx]; i++, sfb++) { - sfis->l[sfb] = (char)GetBits(bsi, slen[nrIdx]); - } - } - /* last sf band not transmitted */ - sfis->l[21] = sfis->l[22] = 0; - - } -} - -/************************************************************************************** - * Function: UnpackScaleFactors - * - * Description: parse the fields of the MP3 scale factor data section - * - * Inputs: MP3DecInfo structure filled by UnpackFrameHeader() and UnpackSideInfo() - * buffer pointing to the MP3 scale factor data - * pointer to bit offset (0-7) indicating starting bit in buf[0] - * number of bits available in data buffer - * index of current granule and channel - * - * Outputs: updated platform-specific ScaleFactorInfo struct - * updated bitOffset - * - * Return: length (in bytes) of scale factor data, -1 if null input pointers - **************************************************************************************/ -int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch) -{ - int bitsUsed; - unsigned char *startBuf; - BitStreamInfo bitStreamInfo, *bsi; - FrameHeader *fh; - SideInfo *si; - ScaleFactorInfo *sfi; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->FrameHeaderPS || !mp3DecInfo->SideInfoPS || !mp3DecInfo->ScaleFactorInfoPS) - return -1; - fh = ((FrameHeader *)(mp3DecInfo->FrameHeaderPS)); - si = ((SideInfo *)(mp3DecInfo->SideInfoPS)); - sfi = ((ScaleFactorInfo *)(mp3DecInfo->ScaleFactorInfoPS)); - - /* init GetBits reader */ - startBuf = buf; - bsi = &bitStreamInfo; - SetBitstreamPointer(bsi, (bitsAvail + *bitOffset + 7) / 8, buf); - if (*bitOffset) - GetBits(bsi, *bitOffset); - - if (fh->ver == MPEG1) - UnpackSFMPEG1(bsi, &si->sis[gr][ch], &sfi->sfis[gr][ch], si->scfsi[ch], gr, &sfi->sfis[0][ch]); - else - UnpackSFMPEG2(bsi, &si->sis[gr][ch], &sfi->sfis[gr][ch], gr, ch, fh->modeExt, &sfi->sfjs); - - mp3DecInfo->part23Length[gr][ch] = si->sis[gr][ch].part23Length; - - bitsUsed = CalcBitsUsed(bsi, buf, *bitOffset); - buf += (bitsUsed + *bitOffset) >> 3; - *bitOffset = (bitsUsed + *bitOffset) & 0x07; - - return (buf - startBuf); -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/statname.h b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/statname.h deleted file mode 100644 index c7f985ea..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/statname.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * statname.h - name mangling macros for static linking - **************************************************************************************/ - -#ifndef _STATNAME_H -#define _STATNAME_H - -/* define STAT_PREFIX to a unique name for static linking - * all the C functions and global variables will be mangled by the preprocessor - * e.g. void FFT(int *fftbuf) becomes void cook_FFT(int *fftbuf) - */ -#define STAT_PREFIX xmp3 - - -#define STATCC1(x,y,z) STATCC2(x,y,z) -#define STATCC2(x,y,z) x##y##z - -#ifdef STAT_PREFIX -#define STATNAME(func) STATCC1(STAT_PREFIX, _, func) -#else -#define STATNAME(func) func -#endif - -/* these symbols are common to all implementations */ -#define CheckPadBit STATNAME(CheckPadBit) -#define UnpackFrameHeader STATNAME(UnpackFrameHeader) -#define UnpackSideInfo STATNAME(UnpackSideInfo) -#define AllocateBuffers STATNAME(AllocateBuffers) -#define FreeBuffers STATNAME(FreeBuffers) -#define DecodeHuffman STATNAME(DecodeHuffman) -#define Dequantize STATNAME(Dequantize) -#define IMDCT STATNAME(IMDCT) -#define UnpackScaleFactors STATNAME(UnpackScaleFactors) -#define Subband STATNAME(Subband) - -#define samplerateTab STATNAME(samplerateTab) -#define bitrateTab STATNAME(bitrateTab) -#define samplesPerFrameTab STATNAME(samplesPerFrameTab) -#define bitsPerSlotTab STATNAME(bitsPerSlotTab) -#define sideBytesTab STATNAME(sideBytesTab) -#define slotTab STATNAME(slotTab) -#define sfBandTable STATNAME(sfBandTable) - -/* in your implementation's top-level include file (e.g. real\coder.h) you should - * add new #define sym STATNAME(sym) lines for all the - * additional global functions or variables which your - * implementation uses - */ - -#endif /* _STATNAME_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/stproc.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/stproc.c deleted file mode 100644 index 7782a21b..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/stproc.c +++ /dev/null @@ -1,299 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * stproc.c - mid-side and intensity (MPEG1 and MPEG2) stereo processing - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: MidSideProc - * - * Description: sum-difference stereo reconstruction - * - * Inputs: vector x with dequantized samples from left and right channels - * number of non-zero samples (MAX of left and right) - * assume 1 guard bit in input - * guard bit mask (left and right channels) - * - * Outputs: updated sample vector x - * updated guard bit mask - * - * Return: none - * - * Notes: assume at least 1 GB in input - **************************************************************************************/ -void MidSideProc(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, int mOut[2]) -{ - int i, xr, xl, mOutL, mOutR; - - /* L = (M+S)/sqrt(2), R = (M-S)/sqrt(2) - * NOTE: 1/sqrt(2) done in DequantChannel() - see comments there - */ - mOutL = mOutR = 0; - for(i = 0; i < nSamps; i++) { - xl = x[0][i]; - xr = x[1][i]; - x[0][i] = xl + xr; - x[1][i] = xl - xr; - mOutL |= FASTABS(x[0][i]); - mOutR |= FASTABS(x[1][i]); - } - mOut[0] |= mOutL; - mOut[1] |= mOutR; -} - -/************************************************************************************** - * Function: IntensityProcMPEG1 - * - * Description: intensity stereo processing for MPEG1 - * - * Inputs: vector x with dequantized samples from left and right channels - * number of non-zero samples in left channel - * valid FrameHeader struct - * two each of ScaleFactorInfoSub, CriticalBandInfo structs (both channels) - * flags indicating midSide on/off, mixedBlock on/off - * guard bit mask (left and right channels) - * - * Outputs: updated sample vector x - * updated guard bit mask - * - * Return: none - * - * Notes: assume at least 1 GB in input - * - * TODO: combine MPEG1/2 into one function (maybe) - * make sure all the mixed-block and IIP logic is right - **************************************************************************************/ -void IntensityProcMPEG1(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, FrameHeader *fh, ScaleFactorInfoSub *sfis, - CriticalBandInfo *cbi, int midSideFlag, int mixFlag, int mOut[2]) -{ - int i=0, j=0, n=0, cb=0, w=0; - int sampsLeft, isf, mOutL, mOutR, xl, xr; - int fl, fr, fls[3], frs[3]; - int cbStartL=0, cbStartS=0, cbEndL=0, cbEndS=0; - int *isfTab; - (void)mixFlag; - - /* NOTE - this works fine for mixed blocks, as long as the switch point starts in the - * short block section (i.e. on or after sample 36 = sfBand->l[8] = 3*sfBand->s[3] - * is this a safe assumption? - * TODO - intensity + mixed not quite right (diff = 11 on he_mode) - * figure out correct implementation (spec ambiguous about when to do short block reorder) - */ - if (cbi[1].cbType == 0) { - /* long block */ - cbStartL = cbi[1].cbEndL + 1; - cbEndL = cbi[0].cbEndL + 1; - cbStartS = cbEndS = 0; - i = fh->sfBand->l[cbStartL]; - } else if (cbi[1].cbType == 1 || cbi[1].cbType == 2) { - /* short or mixed block */ - cbStartS = cbi[1].cbEndSMax + 1; - cbEndS = cbi[0].cbEndSMax + 1; - cbStartL = cbEndL = 0; - i = 3 * fh->sfBand->s[cbStartS]; - } - - sampsLeft = nSamps - i; /* process to length of left */ - isfTab = (int *)ISFMpeg1[midSideFlag]; - mOutL = mOutR = 0; - - /* long blocks */ - for (cb = cbStartL; cb < cbEndL && sampsLeft > 0; cb++) { - isf = sfis->l[cb]; - if (isf == 7) { - fl = ISFIIP[midSideFlag][0]; - fr = ISFIIP[midSideFlag][1]; - } else { - fl = isfTab[isf]; - fr = isfTab[6] - isfTab[isf]; - } - - n = fh->sfBand->l[cb + 1] - fh->sfBand->l[cb]; - for (j = 0; j < n && sampsLeft > 0; j++, i++) { - xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl); - sampsLeft--; - } - } - - /* short blocks */ - for (cb = cbStartS; cb < cbEndS && sampsLeft >= 3; cb++) { - for (w = 0; w < 3; w++) { - isf = sfis->s[cb][w]; - if (isf == 7) { - fls[w] = ISFIIP[midSideFlag][0]; - frs[w] = ISFIIP[midSideFlag][1]; - } else { - fls[w] = isfTab[isf]; - frs[w] = isfTab[6] - isfTab[isf]; - } - } - - n = fh->sfBand->s[cb + 1] - fh->sfBand->s[cb]; - for (j = 0; j < n && sampsLeft >= 3; j++, i+=3) { - xr = MULSHIFT32(frs[0], x[0][i+0]) << 2; x[1][i+0] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fls[0], x[0][i+0]) << 2; x[0][i+0] = xl; mOutL |= FASTABS(xl); - xr = MULSHIFT32(frs[1], x[0][i+1]) << 2; x[1][i+1] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fls[1], x[0][i+1]) << 2; x[0][i+1] = xl; mOutL |= FASTABS(xl); - xr = MULSHIFT32(frs[2], x[0][i+2]) << 2; x[1][i+2] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fls[2], x[0][i+2]) << 2; x[0][i+2] = xl; mOutL |= FASTABS(xl); - sampsLeft -= 3; - } - } - mOut[0] = mOutL; - mOut[1] = mOutR; - - return; -} - -/************************************************************************************** - * Function: IntensityProcMPEG2 - * - * Description: intensity stereo processing for MPEG2 - * - * Inputs: vector x with dequantized samples from left and right channels - * number of non-zero samples in left channel - * valid FrameHeader struct - * two each of ScaleFactorInfoSub, CriticalBandInfo structs (both channels) - * ScaleFactorJS struct with joint stereo info from UnpackSFMPEG2() - * flags indicating midSide on/off, mixedBlock on/off - * guard bit mask (left and right channels) - * - * Outputs: updated sample vector x - * updated guard bit mask - * - * Return: none - * - * Notes: assume at least 1 GB in input - * - * TODO: combine MPEG1/2 into one function (maybe) - * make sure all the mixed-block and IIP logic is right - * probably redo IIP logic to be simpler - **************************************************************************************/ -void IntensityProcMPEG2(int x[MAX_NCHAN][MAX_NSAMP], int nSamps, FrameHeader *fh, ScaleFactorInfoSub *sfis, - CriticalBandInfo *cbi, ScaleFactorJS *sfjs, int midSideFlag, int mixFlag, int mOut[2]) -{ - int i, j, k, n, r, cb, w; - int fl, fr, mOutL, mOutR, xl, xr; - int sampsLeft; - int isf, sfIdx, tmp, il[23]; - int *isfTab; - int cbStartL, cbStartS, cbEndL, cbEndS; - - (void)mixFlag; - - isfTab = (int *)ISFMpeg2[sfjs->intensityScale][midSideFlag]; - mOutL = mOutR = 0; - - /* fill buffer with illegal intensity positions (depending on slen) */ - for (k = r = 0; r < 4; r++) { - tmp = (1 << sfjs->slen[r]) - 1; - for (j = 0; j < sfjs->nr[r]; j++, k++) - il[k] = tmp; - } - - if (cbi[1].cbType == 0) { - /* long blocks */ - il[21] = il[22] = 1; - cbStartL = cbi[1].cbEndL + 1; /* start at end of right */ - cbEndL = cbi[0].cbEndL + 1; /* process to end of left */ - i = fh->sfBand->l[cbStartL]; - sampsLeft = nSamps - i; - - for(cb = cbStartL; cb < cbEndL; cb++) { - sfIdx = sfis->l[cb]; - if (sfIdx == il[cb]) { - fl = ISFIIP[midSideFlag][0]; - fr = ISFIIP[midSideFlag][1]; - } else { - isf = (sfis->l[cb] + 1) >> 1; - fl = isfTab[(sfIdx & 0x01 ? isf : 0)]; - fr = isfTab[(sfIdx & 0x01 ? 0 : isf)]; - } - n = MIN(fh->sfBand->l[cb + 1] - fh->sfBand->l[cb], sampsLeft); - - for(j = 0; j < n; j++, i++) { - xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl); - } - - /* early exit once we've used all the non-zero samples */ - sampsLeft -= n; - if (sampsLeft == 0) - break; - } - } else { - /* short or mixed blocks */ - il[12] = 1; - - for(w = 0; w < 3; w++) { - cbStartS = cbi[1].cbEndS[w] + 1; /* start at end of right */ - cbEndS = cbi[0].cbEndS[w] + 1; /* process to end of left */ - i = 3 * fh->sfBand->s[cbStartS] + w; - - /* skip through sample array by 3, so early-exit logic would be more tricky */ - for(cb = cbStartS; cb < cbEndS; cb++) { - sfIdx = sfis->s[cb][w]; - if (sfIdx == il[cb]) { - fl = ISFIIP[midSideFlag][0]; - fr = ISFIIP[midSideFlag][1]; - } else { - isf = (sfis->s[cb][w] + 1) >> 1; - fl = isfTab[(sfIdx & 0x01 ? isf : 0)]; - fr = isfTab[(sfIdx & 0x01 ? 0 : isf)]; - } - n = fh->sfBand->s[cb + 1] - fh->sfBand->s[cb]; - - for(j = 0; j < n; j++, i+=3) { - xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr); - xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl); - } - } - } - } - mOut[0] = mOutL; - mOut[1] = mOutR; - - return; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/subband.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/subband.c deleted file mode 100644 index e982a9fe..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/subband.c +++ /dev/null @@ -1,96 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * subband.c - subband transform (synthesis filterbank implemented via 32-point DCT - * followed by polyphase filter) - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: Subband - * - * Description: do subband transform on all the blocks in one granule, all channels - * - * Inputs: filled MP3DecInfo structure, after calling IMDCT for all channels - * vbuf[ch] and vindex[ch] must be preserved between calls - * - * Outputs: decoded PCM data, interleaved LRLRLR... if stereo - * - * Return: 0 on success, -1 if null input pointers - **************************************************************************************/ -/*__attribute__ ((section (".data"))) */ int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf) -{ - int b; - //HuffmanInfo *hi; - IMDCTInfo *mi; - SubbandInfo *sbi; - - /* validate pointers */ - if (!mp3DecInfo || !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->IMDCTInfoPS || !mp3DecInfo->SubbandInfoPS) - return -1; - - //hi = (HuffmanInfo *)mp3DecInfo->HuffmanInfoPS; - mi = (IMDCTInfo *)(mp3DecInfo->IMDCTInfoPS); - sbi = (SubbandInfo*)(mp3DecInfo->SubbandInfoPS); - - if (mp3DecInfo->nChans == 2) { - /* stereo */ - for (b = 0; b < BLOCK_SIZE; b++) { - FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]); - FDCT32(mi->outBuf[1][b], sbi->vbuf + 1*32, sbi->vindex, (b & 0x01), mi->gb[1]); - PolyphaseStereo(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef); - sbi->vindex = (sbi->vindex - (b & 0x01)) & 7; - pcmBuf += (2 * NBANDS); - } - } else { - /* mono */ - for (b = 0; b < BLOCK_SIZE; b++) { - FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]); - PolyphaseMono(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef); - sbi->vindex = (sbi->vindex - (b & 0x01)) & 7; - pcmBuf += NBANDS; - } - } - - return 0; -} - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/trigtabs.c b/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/trigtabs.c deleted file mode 100644 index 8686e816..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/libhelix-mp3/trigtabs.c +++ /dev/null @@ -1,319 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: RCSL 1.0/RPSL 1.0 - * - * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, are - * subject to the current version of the RealNetworks Public Source License - * Version 1.0 (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the RealNetworks Community Source License Version 1.0 - * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, - * in which case the RCSL will apply. You may also obtain the license terms - * directly from RealNetworks. You may not use this file except in - * compliance with the RPSL or, if you have a valid RCSL with RealNetworks - * applicable to this file, the RCSL. Please see the applicable RPSL or - * RCSL for the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the portions - * it created. - * - * This file, and the files included with this file, is distributed and made - * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point MP3 decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * June 2003 - * - * trigtabs.c - global ROM tables for pre-calculated trig coefficients - **************************************************************************************/ - -// constants in RAM are not significantly faster - -#include "coder.h" -#include - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" - -/* post-IMDCT window, win[blockType][i] - * format = Q31 - * Fused sin window with final stage of IMDCT - * includes 1/sqrt(2) scaling, since we scale by sqrt(2) in dequant in order - * for fast IMDCT36 to be usable - * - * for(i=0;i<9;i++) win[0][i] = sin(pi/36 *(i+0.5)); - * for(i=9;i<36;i++) win[0][i] = -sin(pi/36 *(i+0.5)); - * - * for(i=0;i<9;i++) win[1][i] = sin(pi/36 *(i+0.5)); - * for(i=9;i<18;i++) win[1][i] = -sin(pi/36 *(i+0.5)); - * for(i=18;i<24;i++) win[1][i] = -1; - * for(i=24;i<30;i++) win[1][i] = -sin(pi/12 *(i+0.5-18)); - * for(i=30;i<36;i++) win[1][i] = 0; - * - * for(i=0;i<6;i++) win[3][i] = 0; - * for(i=6;i<9;i++) win[3][i] = sin(pi/12 *(i+0.5-6)); - * for(i=9;i<12;i++) win[3][i] = -sin(pi/12 *(i+0.5-6)); - * for(i=12;i<18;i++) win[3][i] = -1; - * for(i=18;i<36;i++) win[3][i] = -sin(pi/36*(i+0.5)); - * - * for(i=0;i<3;i++) win[2][i] = sin(pi/12*(i+0.5)); - * for(i=3;i<12;i++) win[2][i] = -sin(pi/12*(i+0.5)); - * for(i=12;i<36;i++) win[2][i] = 0; - * - * for (i = 0; i < 4; i++) { - * if (i == 2) { - * win[i][8] *= cos(pi/12 * (0+0.5)); - * win[i][9] *= cos(pi/12 * (0+0.5)); - * win[i][7] *= cos(pi/12 * (1+0.5)); - * win[i][10] *= cos(pi/12 * (1+0.5)); - * win[i][6] *= cos(pi/12 * (2+0.5)); - * win[i][11] *= cos(pi/12 * (2+0.5)); - * win[i][0] *= cos(pi/12 * (3+0.5)); - * win[i][5] *= cos(pi/12 * (3+0.5)); - * win[i][1] *= cos(pi/12 * (4+0.5)); - * win[i][4] *= cos(pi/12 * (4+0.5)); - * win[i][2] *= cos(pi/12 * (5+0.5)); - * win[i][3] *= cos(pi/12 * (5+0.5)); - * } else { - * for (j = 0; j < 9; j++) { - * win[i][8-j] *= cos(pi/36 * (17-j+0.5)); - * win[i][9+j] *= cos(pi/36 * (17-j+0.5)); - * } - * for (j = 0; j < 9; j++) { - * win[i][18+8-j] *= cos(pi/36 * (j+0.5)); - * win[i][18+9+j] *= cos(pi/36 * (j+0.5)); - * } - * } - * } - * for (i = 0; i < 4; i++) - * for (j = 0; j < 36; j++) - * win[i][j] *= 1.0 / sqrt(2); - */ - -const int imdctWin[4][36] PROGMEM = { - { - 0x02aace8b, 0x07311c28, 0x0a868fec, 0x0c913b52, 0x0d413ccd, 0x0c913b52, 0x0a868fec, 0x07311c28, - 0x02aace8b, 0xfd16d8dd, 0xf6a09e66, 0xef7a6275, 0xe7dbc161, 0xe0000000, 0xd8243e9f, 0xd0859d8b, - 0xc95f619a, 0xc2e92723, 0xbd553175, 0xb8cee3d8, 0xb5797014, 0xb36ec4ae, 0xb2bec333, 0xb36ec4ae, - 0xb5797014, 0xb8cee3d8, 0xbd553175, 0xc2e92723, 0xc95f619a, 0xd0859d8b, 0xd8243e9f, 0xe0000000, - 0xe7dbc161, 0xef7a6275, 0xf6a09e66, 0xfd16d8dd, - }, - { - 0x02aace8b, 0x07311c28, 0x0a868fec, 0x0c913b52, 0x0d413ccd, 0x0c913b52, 0x0a868fec, 0x07311c28, - 0x02aace8b, 0xfd16d8dd, 0xf6a09e66, 0xef7a6275, 0xe7dbc161, 0xe0000000, 0xd8243e9f, 0xd0859d8b, - 0xc95f619a, 0xc2e92723, 0xbd44ef14, 0xb831a052, 0xb3aa3837, 0xafb789a4, 0xac6145bb, 0xa9adecdc, - 0xa864491f, 0xad1868f0, 0xb8431f49, 0xc8f42236, 0xdda8e6b1, 0xf47755dc, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - }, - { - 0x07311c28, 0x0d413ccd, 0x07311c28, 0xf6a09e66, 0xe0000000, 0xc95f619a, 0xb8cee3d8, 0xb2bec333, - 0xb8cee3d8, 0xc95f619a, 0xe0000000, 0xf6a09e66, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - }, - { - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x028e9709, 0x04855ec0, - 0x026743a1, 0xfcde2c10, 0xf515dc82, 0xec93e53b, 0xe4c880f8, 0xdd5d0b08, 0xd63510b7, 0xcf5e834a, - 0xc8e6b562, 0xc2da4105, 0xbd553175, 0xb8cee3d8, 0xb5797014, 0xb36ec4ae, 0xb2bec333, 0xb36ec4ae, - 0xb5797014, 0xb8cee3d8, 0xbd553175, 0xc2e92723, 0xc95f619a, 0xd0859d8b, 0xd8243e9f, 0xe0000000, - 0xe7dbc161, 0xef7a6275, 0xf6a09e66, 0xfd16d8dd, - }, -}; - -/* indexing = [mid-side off/on][intensity scale factor] - * format = Q30, range = [0.0, 1.414] - * - * mid-side off: - * ISFMpeg1[0][i] = tan(i*pi/12) / [1 + tan(i*pi/12)] (left scalefactor) - * = 1 / [1 + tan(i*pi/12)] (right scalefactor) - * - * mid-side on: - * ISFMpeg1[1][i] = sqrt(2) * ISFMpeg1[0][i] - * - * output L = ISFMpeg1[midSide][isf][0] * input L - * output R = ISFMpeg1[midSide][isf][1] * input L - * - * obviously left scalefactor + right scalefactor = 1 (m-s off) or sqrt(2) (m-s on) - * so just store left and calculate right as 1 - left - * (can derive as right = ISFMpeg1[x][6] - left) - * - * if mid-side enabled, multiply joint stereo scale factors by sqrt(2) - * - we scaled whole spectrum by 1/sqrt(2) in Dequant for the M+S/sqrt(2) in MidSideProc - * - but the joint stereo part of the spectrum doesn't need this, so we have to undo it - * - * if scale factor is and illegal intensity position, this becomes a passthrough - * - gain = [1, 0] if mid-side off, since L is coded directly and R = 0 in this region - * - gain = [1, 1] if mid-side on, since L = (M+S)/sqrt(2), R = (M-S)/sqrt(2) - * - and since S = 0 in the joint stereo region (above NZB right) then L = R = M * 1.0 - */ -const int ISFMpeg1[2][7] PROGMEM = { - {0x00000000, 0x0d8658ba, 0x176cf5d0, 0x20000000, 0x28930a2f, 0x3279a745, 0x40000000}, - {0x00000000, 0x13207f5c, 0x2120fb83, 0x2d413ccc, 0x39617e16, 0x4761fa3d, 0x5a827999} -}; - -/* indexing = [intensity scale on/off][mid-side off/on][intensity scale factor] - * format = Q30, range = [0.0, 1.414] - * - * if (isf == 0) kl = 1.0 kr = 1.0 - * else if (isf & 0x01 == 0x01) kl = i0^((isf+1)/2), kr = 1.0 - * else if (isf & 0x01 == 0x00) kl = 1.0, kr = i0^(isf/2) - * - * if (intensityScale == 1) i0 = 1/sqrt(2) = 0x2d413ccc (Q30) - * else i0 = 1/sqrt(sqrt(2)) = 0x35d13f32 (Q30) - * - * see comments for ISFMpeg1 (just above) regarding scaling, sqrt(2), etc. - * - * compress the MPEG2 table using the obvious identities above... - * for isf = [0, 1, 2, ... 30], let sf = table[(isf+1) >> 1] - * - if isf odd, L = sf*L, R = tab[0]*R - * - if isf even, L = tab[0]*L, R = sf*R - */ -const int ISFMpeg2[2][2][16] PROGMEM = { -{ - { - /* intensityScale off, mid-side off */ - 0x40000000, 0x35d13f32, 0x2d413ccc, 0x260dfc14, 0x1fffffff, 0x1ae89f99, 0x16a09e66, 0x1306fe0a, - 0x0fffffff, 0x0d744fcc, 0x0b504f33, 0x09837f05, 0x07ffffff, 0x06ba27e6, 0x05a82799, 0x04c1bf82, - }, - { - /* intensityScale off, mid-side on */ - 0x5a827999, 0x4c1bf827, 0x3fffffff, 0x35d13f32, 0x2d413ccc, 0x260dfc13, 0x1fffffff, 0x1ae89f99, - 0x16a09e66, 0x1306fe09, 0x0fffffff, 0x0d744fcc, 0x0b504f33, 0x09837f04, 0x07ffffff, 0x06ba27e6, - }, -}, -{ - { - /* intensityScale on, mid-side off */ - 0x40000000, 0x2d413ccc, 0x20000000, 0x16a09e66, 0x10000000, 0x0b504f33, 0x08000000, 0x05a82799, - 0x04000000, 0x02d413cc, 0x02000000, 0x016a09e6, 0x01000000, 0x00b504f3, 0x00800000, 0x005a8279, - }, - /* intensityScale on, mid-side on */ - { - 0x5a827999, 0x3fffffff, 0x2d413ccc, 0x1fffffff, 0x16a09e66, 0x0fffffff, 0x0b504f33, 0x07ffffff, - 0x05a82799, 0x03ffffff, 0x02d413cc, 0x01ffffff, 0x016a09e6, 0x00ffffff, 0x00b504f3, 0x007fffff, - } -} -}; - -/* indexing = [intensity scale on/off][left/right] - * format = Q30, range = [0.0, 1.414] - * - * illegal intensity position scalefactors (see comments on ISFMpeg1) - */ -const int ISFIIP[2][2] PROGMEM = { - {0x40000000, 0x00000000}, /* mid-side off */ - {0x40000000, 0x40000000}, /* mid-side on */ -}; - -const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f}; - -/* anti-alias coefficients - see spec Annex B, table 3-B.9 - * csa[0][i] = CSi, csa[1][i] = CAi - * format = Q31 - */ -const int csa[8][2] PROGMEM = { - {0x6dc253f0, 0xbe2500aa}, - {0x70dcebe4, 0xc39e4949}, - {0x798d6e73, 0xd7e33f4a}, - {0x7ddd40a7, 0xe8b71176}, - {0x7f6d20b7, 0xf3e4fe2f}, - {0x7fe47e40, 0xfac1a3c7}, - {0x7ffcb263, 0xfe2ebdc6}, - {0x7fffc694, 0xff86c25d}, -}; - -/* format = Q30, range = [0.0981, 1.9976] - * - * n = 16; - * k = 0; - * for(i=0; i<5; i++, n=n/2) { - * for(p=0; picsResBit = GetBits(bsi, 1); - icsInfo->winSequence = GetBits(bsi, 2); - icsInfo->winShape = GetBits(bsi, 1); - if (icsInfo->winSequence == 2) { - /* short block */ - icsInfo->maxSFB = GetBits(bsi, 4); - icsInfo->sfGroup = GetBits(bsi, 7); - icsInfo->numWinGroup = 1; - icsInfo->winGroupLen[0] = 1; - mask = 0x40; /* start with bit 6 */ - for (g = 0; g < 7; g++) { - if (icsInfo->sfGroup & mask) { - icsInfo->winGroupLen[icsInfo->numWinGroup - 1]++; - } else { - icsInfo->numWinGroup++; - icsInfo->winGroupLen[icsInfo->numWinGroup - 1] = 1; - } - mask >>= 1; - } - } else { - /* long block */ - icsInfo->maxSFB = GetBits(bsi, 6); - icsInfo->predictorDataPresent = GetBits(bsi, 1); - if (icsInfo->predictorDataPresent) { - icsInfo->predictorReset = GetBits(bsi, 1); - if (icsInfo->predictorReset) - icsInfo->predictorResetGroupNum = GetBits(bsi, 5); - for (sfb = 0; sfb < MIN(icsInfo->maxSFB, predSFBMax[sampRateIdx]); sfb++) - icsInfo->predictionUsed[sfb] = GetBits(bsi, 1); - } - icsInfo->numWinGroup = 1; - icsInfo->winGroupLen[0] = 1; - } -} - -/************************************************************************************** - * Function: DecodeSectionData - * - * Description: decode section data (scale factor band groupings and - * associated Huffman codebooks) - * - * Inputs: BitStreamInfo struct pointing to start of ICS info - * (14496-3, table 4.4.25) - * window sequence (short or long blocks) - * number of window groups (1 for long blocks, 1-8 for short blocks) - * max coded scalefactor band - * - * Outputs: index of Huffman codebook for each scalefactor band in each section - * - * Return: none - * - * Notes: sectCB, sectEnd, sfbCodeBook, ordered by window groups for short blocks - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodeSectionData(BitStreamInfo *bsi, int winSequence, int numWinGrp, int maxSFB, unsigned char *sfbCodeBook) -{ - int g, cb, sfb; - int sectLen, sectLenBits, sectLenIncr, sectEscapeVal; - - sectLenBits = (winSequence == 2 ? 3 : 5); - sectEscapeVal = (1 << sectLenBits) - 1; - - for (g = 0; g < numWinGrp; g++) { - sfb = 0; - while (sfb < maxSFB) { - cb = GetBits(bsi, 4); /* next section codebook */ - sectLen = 0; - do { - sectLenIncr = GetBits(bsi, sectLenBits); - sectLen += sectLenIncr; - } while (sectLenIncr == sectEscapeVal); - - sfb += sectLen; - while (sectLen--) - *sfbCodeBook++ = (unsigned char)cb; - } - ASSERT(sfb == maxSFB); - } -} - -/************************************************************************************** - * Function: DecodeOneScaleFactor - * - * Description: decode one scalefactor using scalefactor Huffman codebook - * - * Inputs: BitStreamInfo struct pointing to start of next coded scalefactor - * - * Outputs: updated BitstreamInfo struct - * - * Return: one decoded scalefactor, including index_offset of -60 - **************************************************************************************/ -static int DecodeOneScaleFactor(BitStreamInfo *bsi) -{ - int nBits, val; - unsigned int bitBuf; - - /* decode next scalefactor from bitstream */ - bitBuf = GetBitsNoAdvance(bsi, huffTabScaleFactInfo.maxBits) << (32 - huffTabScaleFactInfo.maxBits); - //PROFILE_START("DecodeHuffmanScalar"); - nBits = DecodeHuffmanScalar(huffTabScaleFact, &huffTabScaleFactInfo, bitBuf, &val); - AdvanceBitstream(bsi, nBits); - //PROFILE_END(); - return val; -} - -/************************************************************************************** - * Function: DecodeScaleFactors - * - * Description: decode scalefactors, PNS energy, and intensity stereo weights - * - * Inputs: BitStreamInfo struct pointing to start of ICS info - * (14496-3, table 4.4.26) - * number of window groups (1 for long blocks, 1-8 for short blocks) - * max coded scalefactor band - * global gain (starting value for differential scalefactor coding) - * index of Huffman codebook for each scalefactor band in each section - * - * Outputs: decoded scalefactor for each section - * - * Return: none - * - * Notes: sfbCodeBook, scaleFactors ordered by window groups for short blocks - * for section with codebook 13, scaleFactors buffer has decoded PNS - * energy instead of regular scalefactor - * for section with codebook 14 or 15, scaleFactors buffer has intensity - * stereo weight instead of regular scalefactor - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodeScaleFactors(BitStreamInfo *bsi, int numWinGrp, int maxSFB, int globalGain, - unsigned char *sfbCodeBook, short *scaleFactors) -{ - int g, sfbCB, nrg, npf, val, sf, is; - - /* starting values for differential coding */ - sf = globalGain; - is = 0; - nrg = globalGain - 90 - 256; - npf = 1; - - for (g = 0; g < numWinGrp * maxSFB; g++) { - sfbCB = *sfbCodeBook++; - - if (sfbCB == 14 || sfbCB == 15) { - /* intensity stereo - differential coding */ - val = DecodeOneScaleFactor(bsi); - is += val; - *scaleFactors++ = (short)is; - } else if (sfbCB == 13) { - /* PNS - first energy is directly coded, rest are Huffman coded (npf = noise_pcm_flag) */ - if (npf) { - val = GetBits(bsi, 9); - npf = 0; - } else { - val = DecodeOneScaleFactor(bsi); - } - nrg += val; - *scaleFactors++ = (short)nrg; - } else if (sfbCB >= 1 && sfbCB <= 11) { - /* regular (non-zero) region - differential coding */ - val = DecodeOneScaleFactor(bsi); - sf += val; - *scaleFactors++ = (short)sf; - } else { - /* inactive scalefactor band if codebook 0 */ - *scaleFactors++ = 0; - } - } -} - -/************************************************************************************** - * Function: DecodePulseInfo - * - * Description: decode pulse information - * - * Inputs: BitStreamInfo struct pointing to start of pulse info - * (14496-3, table 4.4.7) - * - * Outputs: updated PulseInfo struct - * - * Return: none - **************************************************************************************/ -/* __attribute__ ((section (".data"))) */ static void DecodePulseInfo(BitStreamInfo *bsi, PulseInfo *pi) -{ - int i; - - pi->numPulse = GetBits(bsi, 2) + 1; /* add 1 here */ - pi->startSFB = GetBits(bsi, 6); - for (i = 0; i < pi->numPulse; i++) { - pi->offset[i] = GetBits(bsi, 5); - pi->amp[i] = GetBits(bsi, 4); - } -} - -/************************************************************************************** - * Function: DecodeTNSInfo - * - * Description: decode TNS filter information - * - * Inputs: BitStreamInfo struct pointing to start of TNS info - * (14496-3, table 4.4.27) - * window sequence (short or long blocks) - * - * Outputs: updated TNSInfo struct - * buffer of decoded (signed) TNS filter coefficients - * - * Return: none - **************************************************************************************/ -static const signed char sgnMask[3] = {0x02, 0x04, 0x08}; -static const signed char negMask[3] = {~0x03, ~0x07, ~0x0f}; - -static void DecodeTNSInfo(BitStreamInfo *bsi, int winSequence, TNSInfo *ti, signed char *tnsCoef) -{ - int i, w, f, coefBits, compress; - signed char c, s, n; - - unsigned char *filtLength, *filtOrder, *filtDir; - - filtLength = ti->length; - filtOrder = ti->order; - filtDir = ti->dir; - - if (winSequence == 2) { - /* short blocks */ - for (w = 0; w < NWINDOWS_SHORT; w++) { - ti->numFilt[w] = GetBits(bsi, 1); - if (ti->numFilt[w]) { - ti->coefRes[w] = GetBits(bsi, 1) + 3; - *filtLength = GetBits(bsi, 4); - *filtOrder = GetBits(bsi, 3); - if (*filtOrder) { - *filtDir++ = GetBits(bsi, 1); - compress = GetBits(bsi, 1); - coefBits = (int)ti->coefRes[w] - compress; /* 2, 3, or 4 */ - s = sgnMask[coefBits - 2]; - n = negMask[coefBits - 2]; - for (i = 0; i < *filtOrder; i++) { - c = GetBits(bsi, coefBits); - if (c & s) c |= n; - *tnsCoef++ = c; - } - } - filtLength++; - filtOrder++; - } - } - } else { - /* long blocks */ - ti->numFilt[0] = GetBits(bsi, 2); - if (ti->numFilt[0]) - ti->coefRes[0] = GetBits(bsi, 1) + 3; - for (f = 0; f < ti->numFilt[0]; f++) { - *filtLength = GetBits(bsi, 6); - *filtOrder = GetBits(bsi, 5); - if (*filtOrder) { - *filtDir++ = GetBits(bsi, 1); - compress = GetBits(bsi, 1); - coefBits = (int)ti->coefRes[0] - compress; /* 2, 3, or 4 */ - s = sgnMask[coefBits - 2]; - n = negMask[coefBits - 2]; - for (i = 0; i < *filtOrder; i++) { - c = GetBits(bsi, coefBits); - if (c & s) c |= n; - *tnsCoef++ = c; - } - } - filtLength++; - filtOrder++; - } - } -} - -/* bitstream field lengths for gain control data: - * gainBits[winSequence][0] = maxWindow (how many gain windows there are) - * gainBits[winSequence][1] = locBitsZero (bits for alocCode if window == 0) - * gainBits[winSequence][2] = locBits (bits for alocCode if window != 0) - */ -static const unsigned char gainBits[4][3] = { - {1, 5, 5}, /* long */ - {2, 4, 2}, /* start */ - {8, 2, 2}, /* short */ - {2, 4, 5}, /* stop */ -}; - -/************************************************************************************** - * Function: DecodeGainControlInfo - * - * Description: decode gain control information (SSR profile only) - * - * Inputs: BitStreamInfo struct pointing to start of gain control info - * (14496-3, table 4.4.12) - * window sequence (short or long blocks) - * - * Outputs: updated GainControlInfo struct - * - * Return: none - **************************************************************************************/ -static void DecodeGainControlInfo(BitStreamInfo *bsi, int winSequence, GainControlInfo *gi) -{ - int bd, wd, ad; - int locBits, locBitsZero, maxWin; - - gi->maxBand = GetBits(bsi, 2); - maxWin = (int)gainBits[winSequence][0]; - locBitsZero = (int)gainBits[winSequence][1]; - locBits = (int)gainBits[winSequence][2]; - - for (bd = 1; bd <= gi->maxBand; bd++) { - for (wd = 0; wd < maxWin; wd++) { - gi->adjNum[bd][wd] = GetBits(bsi, 3); - for (ad = 0; ad < gi->adjNum[bd][wd]; ad++) { - gi->alevCode[bd][wd][ad] = GetBits(bsi, 4); - gi->alocCode[bd][wd][ad] = GetBits(bsi, (wd == 0 ? locBitsZero : locBits)); - } - } - } -} - -/************************************************************************************** - * Function: DecodeICS - * - * Description: decode individual channel stream - * - * Inputs: platform specific info struct - * BitStreamInfo struct pointing to start of individual channel stream - * (14496-3, table 4.4.24) - * index of current channel - * - * Outputs: updated section data, scale factor data, pulse data, TNS data, - * and gain control data - * - * Return: none - **************************************************************************************/ -static void DecodeICS(PSInfoBase *psi, BitStreamInfo *bsi, int ch) -{ - int globalGain; - ICSInfo *icsInfo; - PulseInfo *pi; - TNSInfo *ti; - GainControlInfo *gi; - - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - globalGain = GetBits(bsi, 8); - if (!psi->commonWin) - DecodeICSInfo(bsi, icsInfo, psi->sampRateIdx); - - DecodeSectionData(bsi, icsInfo->winSequence, icsInfo->numWinGroup, icsInfo->maxSFB, psi->sfbCodeBook[ch]); - - DecodeScaleFactors(bsi, icsInfo->numWinGroup, icsInfo->maxSFB, globalGain, psi->sfbCodeBook[ch], psi->scaleFactors[ch]); - - pi = &psi->pulseInfo[ch]; - pi->pulseDataPresent = GetBits(bsi, 1); - if (pi->pulseDataPresent) - DecodePulseInfo(bsi, pi); - - ti = &psi->tnsInfo[ch]; - ti->tnsDataPresent = GetBits(bsi, 1); - if (ti->tnsDataPresent) - DecodeTNSInfo(bsi, icsInfo->winSequence, ti, ti->coef); - - gi = &psi->gainControlInfo[ch]; - gi->gainControlDataPresent = GetBits(bsi, 1); - if (gi->gainControlDataPresent) - DecodeGainControlInfo(bsi, icsInfo->winSequence, gi); -} - -/************************************************************************************** - * Function: DecodeNoiselessData - * - * Description: decode noiseless data (side info and transform coefficients) - * - * Inputs: valid AACDecInfo struct - * double pointer to buffer pointing to start of individual channel stream - * (14496-3, table 4.4.24) - * pointer to bit offset - * pointer to number of valid bits remaining in buf - * index of current channel - * - * Outputs: updated global gain, section data, scale factor data, pulse data, - * TNS data, gain control data, and spectral data - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch) -{ - int bitsUsed; - BitStreamInfo bsi; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - SetBitstreamPointer(&bsi, (*bitsAvail+7) >> 3, *buf); - GetBits(&bsi, *bitOffset); - - DecodeICS(psi, &bsi, ch); - - if (icsInfo->winSequence == 2) - DecodeSpectrumShort(psi, &bsi, ch); - else - DecodeSpectrumLong(psi, &bsi, ch); - - bitsUsed = CalcBitsUsed(&bsi, *buf, *bitOffset); - *buf += ((bitsUsed + *bitOffset) >> 3); - *bitOffset = ((bitsUsed + *bitOffset) & 0x07); - *bitsAvail -= bitsUsed; - - aacDecInfo->sbDeinterleaveReqd[ch] = 0; - aacDecInfo->tnsUsed |= psi->tnsInfo[ch].tnsDataPresent; /* set flag if TNS used for any channel */ - - return ERR_AAC_NONE; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/pns.c b/components/spotify/cspot/bell/external/libhelix-aac/pns.c deleted file mode 100644 index 3594c76d..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/pns.c +++ /dev/null @@ -1,357 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: pns.c,v 1.2 2005/03/10 17:01:56 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * pns.c - perceptual noise substitution - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: Get32BitVal - * - * Description: generate 32-bit unsigned random number - * - * Inputs: last number calculated (seed, first time through) - * - * Outputs: new number, saved in *last - * - * Return: 32-bit number, uniformly distributed between [0, 2^32) - * - * Notes: uses simple linear congruential generator - **************************************************************************************/ -static unsigned int Get32BitVal(unsigned int *last) -{ - unsigned int r = *last; - - /* use same coefs as MPEG reference code (classic LCG) - * use unsigned multiply to force reliable wraparound behavior in C (mod 2^32) - */ - r = (1664525U * r) + 1013904223U; - *last = r; - - return r; -} - - -#define NUM_ITER_INVSQRT 4 - -#define X0_COEF_2 0xc0000000 /* Q29: -2.0 */ -#define X0_OFF_2 0x60000000 /* Q29: 3.0 */ -#define Q26_3 0x0c000000 /* Q26: 3.0 */ - -/************************************************************************************** - * Function: InvRootR - * - * Description: use Newton's method to solve for x = 1/sqrt(r) - * - * Inputs: r in Q30 format, range = [0.25, 1] (normalize inputs to this range) - * - * Outputs: none - * - * Return: x = Q29, range = (1, 2) - * - * Notes: guaranteed to converge and not overflow for any r in this range - * - * xn+1 = xn - f(xn)/f'(xn) - * f(x) = 1/sqrt(r) - x = 0 (find root) - * = 1/x^2 - r - * f'(x) = -2/x^3 - * - * so xn+1 = xn/2 * (3 - r*xn^2) - * - * NUM_ITER_INVSQRT = 3, maxDiff = 1.3747e-02 - * NUM_ITER_INVSQRT = 4, maxDiff = 3.9832e-04 - **************************************************************************************/ -static int InvRootR(int r) -{ - int i, xn, t; - - /* use linear equation for initial guess - * x0 = -2*r + 3 (so x0 always >= correct answer in range [0.25, 1)) - * xn = Q29 (at every step) - */ - xn = (MULSHIFT32(r, X0_COEF_2) << 2) + X0_OFF_2; - - for (i = 0; i < NUM_ITER_INVSQRT; i++) { - t = MULSHIFT32(xn, xn); /* Q26 = Q29*Q29 */ - t = Q26_3 - (MULSHIFT32(r, t) << 2); /* Q26 = Q26 - (Q31*Q26 << 1) */ - xn = MULSHIFT32(xn, t) << (6 - 1); /* Q29 = (Q29*Q26 << 6), and -1 for division by 2 */ - } - - /* clip to range (1.0, 2.0) - * (because of rounding, this can converge to xn slightly > 2.0 when r is near 0.25) - */ - if (xn >> 30) - xn = (1 << 30) - 1; - - return xn; -} - -/************************************************************************************** - * Function: ScaleNoiseVector - * - * Description: apply scaling to vector of noise coefficients for one scalefactor band - * - * Inputs: unscaled coefficients - * number of coefficients in vector (one scalefactor band of coefs) - * scalefactor for this band (i.e. noise energy) - * - * Outputs: nVals coefficients in Q(FBITS_OUT_DQ_OFF) - * - * Return: guard bit mask (OR of abs value of all noise coefs) - **************************************************************************************/ -static int ScaleNoiseVector(int *coef, int nVals, int sf) -{ - -/* pow(2, i/4.0) for i = [0,1,2,3], format = Q30 */ -static const int pow14[4] PROGMEM = { - 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 -}; - - int i, c, spec, energy, sq, scalef, scalei, invSqrtEnergy, z, gbMask; - - energy = 0; - for (i = 0; i < nVals; i++) { - spec = coef[i]; - - /* max nVals = max SFB width = 96, so energy can gain < 2^7 bits in accumulation */ - sq = (spec * spec) >> 8; /* spec*spec range = (-2^30, 2^30) */ - energy += sq; - } - - /* unless nVals == 1 (or the number generator is broken...), this should not happen */ - if (energy == 0) - return 0; /* coef[i] must = 0 for i = [0, nVals-1], so gbMask = 0 */ - - /* pow(2, sf/4) * pow(2, FBITS_OUT_DQ_OFF) */ - scalef = pow14[sf & 0x3]; - scalei = (sf >> 2) + FBITS_OUT_DQ_OFF; - - /* energy has implied factor of 2^-8 since we shifted the accumulator - * normalize energy to range [0.25, 1.0), calculate 1/sqrt(1), and denormalize - * i.e. divide input by 2^(30-z) and convert to Q30 - * output of 1/sqrt(i) now has extra factor of 2^((30-z)/2) - * for energy > 0, z is an even number between 0 and 28 - * final scaling of invSqrtEnergy: - * 2^(15 - z/2) to compensate for implicit 2^(30-z) factor in input - * +4 to compensate for implicit 2^-8 factor in input - */ - z = CLZ(energy) - 2; /* energy has at least 2 leading zeros (see acc loop) */ - z &= 0xfffffffe; /* force even */ - invSqrtEnergy = InvRootR(energy << z); /* energy << z must be in range [0x10000000, 0x40000000] */ - scalei -= (15 - z/2 + 4); /* nInt = 1/sqrt(energy) in Q29 */ - - /* normalize for final scaling */ - z = CLZ(invSqrtEnergy) - 1; - invSqrtEnergy <<= z; - scalei -= (z - 3 - 2); /* -2 for scalef, z-3 for invSqrtEnergy */ - scalef = MULSHIFT32(scalef, invSqrtEnergy); /* scalef (input) = Q30, invSqrtEnergy = Q29 * 2^z */ - gbMask = 0; - - if (scalei < 0) { - scalei = -scalei; - if (scalei > 31) - scalei = 31; - for (i = 0; i < nVals; i++) { - c = MULSHIFT32(coef[i], scalef) >> scalei; - gbMask |= FASTABS(c); - coef[i] = c; - } - } else { - /* for scalei <= 16, no clipping possible (coef[i] is < 2^15 before scaling) - * for scalei > 16, just saturate exponent (rare) - * scalef is close to full-scale (since we normalized invSqrtEnergy) - * remember, we are just producing noise here - */ - if (scalei > 16) - scalei = 16; - for (i = 0; i < nVals; i++) { - c = MULSHIFT32(coef[i] << scalei, scalef); - coef[i] = c; - gbMask |= FASTABS(c); - } - } - - return gbMask; -} - -/************************************************************************************** - * Function: GenerateNoiseVector - * - * Description: create vector of noise coefficients for one scalefactor band - * - * Inputs: seed for number generator - * number of coefficients to generate - * - * Outputs: buffer of nVals coefficients, range = [-2^15, 2^15) - * updated seed for number generator - * - * Return: none - **************************************************************************************/ -static void GenerateNoiseVector(int *coef, int *last, int nVals) -{ - int i; - - for (i = 0; i < nVals; i++) - coef[i] = ((signed int)Get32BitVal((unsigned int *)last)) >> 16; -} - -/************************************************************************************** - * Function: CopyNoiseVector - * - * Description: copy vector of noise coefficients for one scalefactor band from L to R - * - * Inputs: buffer of left coefficients - * number of coefficients to copy - * - * Outputs: buffer of right coefficients - * - * Return: none - **************************************************************************************/ -static void CopyNoiseVector(int *coefL, int *coefR, int nVals) -{ - int i; - - for (i = 0; i < nVals; i++) - coefR[i] = coefL[i]; -} - -/************************************************************************************** - * Function: PNS - * - * Description: apply perceptual noise substitution, if enabled (MPEG-4 only) - * - * Inputs: valid AACDecInfo struct - * index of current channel - * - * Outputs: shaped noise in scalefactor bands where PNS is active - * updated minimum guard bit count for this channel - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int PNS(AACDecInfo *aacDecInfo, int ch) -{ - int gp, sfb, win, width, nSamps, gb, gbMask; - int *coef; - const /*short*/ int *sfbTab; - unsigned char *sfbCodeBook; - short *scaleFactors; - int msMaskOffset, checkCorr, genNew; - unsigned char msMask; - unsigned char *msMaskPtr; - PSInfoBase *psi; - ICSInfo *icsInfo; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - - if (!psi->pnsUsed[ch]) - return 0; - - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coef = psi->coef[ch]; - sfbCodeBook = psi->sfbCodeBook[ch]; - scaleFactors = psi->scaleFactors[ch]; - checkCorr = (aacDecInfo->currBlockID == AAC_ID_CPE && psi->commonWin == 1 ? 1 : 0); - - gbMask = 0; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - msMaskPtr = psi->msMaskBits + ((gp*icsInfo->maxSFB) >> 3); - msMaskOffset = ((gp*icsInfo->maxSFB) & 0x07); - msMask = (*msMaskPtr++) >> msMaskOffset; - - for (sfb = 0; sfb < icsInfo->maxSFB; sfb++) { - width = sfbTab[sfb+1] - sfbTab[sfb]; - if (sfbCodeBook[sfb] == 13) { - if (ch == 0) { - /* generate new vector, copy into ch 1 if it's possible that the channels will be correlated - * if ch 1 has PNS enabled for this SFB but it's uncorrelated (i.e. ms_used == 0), - * the copied values will be overwritten when we process ch 1 - */ - GenerateNoiseVector(coef, &psi->pnsLastVal, width); - if (checkCorr && psi->sfbCodeBook[1][gp*icsInfo->maxSFB + sfb] == 13) - CopyNoiseVector(coef, psi->coef[1] + (coef - psi->coef[0]), width); - } else { - /* generate new vector if no correlation between channels */ - genNew = 1; - if (checkCorr && psi->sfbCodeBook[0][gp*icsInfo->maxSFB + sfb] == 13) { - if ( (psi->msMaskPresent == 1 && (msMask & 0x01)) || psi->msMaskPresent == 2 ) - genNew = 0; - } - if (genNew) - GenerateNoiseVector(coef, &psi->pnsLastVal, width); - } - gbMask |= ScaleNoiseVector(coef, width, psi->scaleFactors[ch][gp*icsInfo->maxSFB + sfb]); - } - coef += width; - - /* get next mask bit (should be branchless on ARM) */ - msMask >>= 1; - if (++msMaskOffset == 8) { - msMask = *msMaskPtr++; - msMaskOffset = 0; - } - } - coef += (nSamps - sfbTab[icsInfo->maxSFB]); - } - sfbCodeBook += icsInfo->maxSFB; - scaleFactors += icsInfo->maxSFB; - } - - /* update guard bit count if necessary */ - gb = CLZ(gbMask) - 1; - if (psi->gbCurrent[ch] > gb) - psi->gbCurrent[ch] = gb; - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/readme.txt b/components/spotify/cspot/bell/external/libhelix-aac/readme.txt deleted file mode 100644 index de4ca0ee..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/readme.txt +++ /dev/null @@ -1,127 +0,0 @@ -Fixed-point HE-AAC decoder -Developed by RealNetworks, 2005 -=============================== - -Overview --------- -This module contains a high-performance HE-AAC decoder for 32-bit fixed-point -processors. The following is a summary of what is and is not supported: - -Supported: - - MPEG2, MPEG4 low complexity decoding (intensity stereo, M-S, TNS, PNS) - - spectral band replication (SBR), high-quality mode - - mono, stereo, and multichannel modes - - ADTS, ADIF, and raw data block file formats - -Not currently supported: - - main or SSR profile, LTP - - coupling channel elements (CCE) - - 960/1920-sample frame size - - low-power mode SBR - - downsampled (single-rate) SBR - - parametric stereo - -Highlights ----------- - - highly optimized for ARM processors (details in docs/ subdirectory) - - reference x86 implementation - - C and assembly code only (C++ not required for codec library) - - reentrant, statically linkable - - low memory (details in docs/ subdirectory) - - option to use Intel Integrated Performance Primitives (details below) - -Supported platforms and toolchains ----------------------------------- -This codec should run on any 32-bit fixed-point processor which can perform a full 32x32-bit -multiply (providing a 64-bit result). The following processors and toolchains are supported: - - x86, Microsoft Visual C++ - - x86, GNU toolchain (gcc) - - ARM, ARM Developer Suite (ADS) - - ARM, Microsoft Embedded Visual C++ - - ARM, GNU toolchain (gcc) - -ARM refers to any processor supporting ARM architecture v.4 or above. Thumb is not required. - -Generally ADS produces the fastest code. EVC 3 does not support inline assembly code for -ARM targets, so calls to MULSHIFT32 (smull on ARM) are left as function calls. This incurs -a significant performance penalty. For the fastest code on targets which do not normally use -ADS consider compiling with ADS, using the -S option to output assembly code, and -feeding this assembly code to the assembler of your choice. This might require some -syntax changes in the .S file. - -Adding support for a new processor is fairly simple. Simply add a new block to the file -real/assembly.h which implements the required inline assembly functions for your processor. -Something like - -... -#elif defined NEW_PROCESSOR - -/* you implement MULSHIFT32() and so forth */ - -#else -#error Unsupported platform in assembly.h -#endif - -Optionally you can rewrite or add assembly language files optimized for your platform. Note -that many of the algorithms are designed for an ARM-type processor, so performance of the -unmodified C code might be noticeably worse on other architectures. - -Adding support for a new toolchain is straightforward. Use the sample projects or the -Helix makefiles as a template for which source files to include. - -Multichannel ------------- -For multichannel, just set AAC_MAX_NCHANS in pub/aacdec.h to the desired max number -of channels (default = 2) and recompile. This increases RAM usage since more memory -is required to save state for multiple channels. See docs/memory.xls for details. - -Directory structure -------------------- -fixpt/ platform-independent code and tables, public API -fixpt/docs memory and CPU usage figures, callgraphs -fixpt/hxwrap Helix wrapper code and makefiles -fixpt/ipp source code which uses IPP for decoding (see the "IPP" section below) -fixpt/pub public header files -fixpt/real source code for RealNetworks' AAC decoder -fixpt/testwrap sample code to build a command-line test application - -Code organization ------------------ -fixpt/ - aacdec.c main decode functions, exports C-only API - aactabs.c common tables used by all implementations -fixpt/pub/ - aaccommon.h low-level codec API which aacdec.c calls - aacdec.h high-level codec API which applications call - statname.h symbols which get name-mangled by C preprocessor to allow static linking -fixpt/ipp source code for wrapper files which link in IPP libraries -fixpt/real full source code for RealNetworks AAC decoder, including SBR -fixpt/real/asm optimized assembly code files for certain platforms - -To build an AAC decoder library, you'll need to compile the top-level files and EITHER -real/*.c OR ipp/*.c and the appropriate IPP library. - -Decoder using Real code: aacdec.c + aactabs.c + real/*.c + real/asm/[platform]/*.s (if necessary) -Decoder using IPP code: aacdec.c + aactabs.c + ipp/*.c + ippac*.lib - -IPP ---- -For certain platforms Intel® has created highly-optimized object code libraries of DSP -routines. These are called the Intel® Integrated Performance Primitives (IPP). If IPP -libraries are available for a platform, this AAC decoder can link them in and use them -instead of the RealNetworks source code. To use IPP, you still need to build the top-level -files (aacdec.c, aactabs.c). You also build the files in ipp/*.c. These are just thin -wrappers which provide the glue logic between the top-level decode functions in -aacdec.c and the optimized DSP primitives in the IPP libraries. IPP libraries are not -included in this module. You must obtain them WITH A LICENSE directly from Intel. -Further info on the latest versions of IPP (as of the date of this readme) is available -from the URL below: - -http://www.intel.com/software/products/ipp/ - -This site explains how to obtain IPP and the terms under which IPP libraries may be used. -The code in this module is merely wrapper code which calls IPP functions. You are fully -responsible for adhering to the license agreement under which you obtain the IPP -libraries from Intel. - -readme.txt last updated 02/25/05 diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbr.c b/components/spotify/cspot/bell/external/libhelix-aac/sbr.c deleted file mode 100644 index 691694d0..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbr.c +++ /dev/null @@ -1,431 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbr.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbr.c - top level functions for SBR - **************************************************************************************/ - -#if defined(USE_DEFAULT_STDLIB) || defined(ESP_PLATFORM) -#include -#include -#else -#include "hlxclib/stdlib.h" -#endif - -#include "sbr.h" - -/************************************************************************************** - * Function: InitSBRState - * - * Description: initialize PSInfoSBR struct at start of stream or after flush - * - * Inputs: valid AACDecInfo struct - * - * Outputs: PSInfoSBR struct with proper initial state - * - * Return: none - **************************************************************************************/ -static void InitSBRState(PSInfoSBR *psi) -{ - int i, ch; - unsigned char *c; - - if (!psi) - return; - - /* clear SBR state structure */ - c = (unsigned char *)psi; - for (i = 0; i < (int)sizeof(PSInfoSBR); i++) - *c++ = 0; - - /* initialize non-zero state variables */ - for (ch = 0; ch < AAC_MAX_NCHANS; ch++) { - psi->sbrChan[ch].reset = 1; - psi->sbrChan[ch].laPrev = -1; - } -} - -/************************************************************************************** - * Function: InitSBR - * - * Description: initialize SBR decoder - * - * Inputs: valid AACDecInfo struct - * - * Outputs: PSInfoSBR struct to hold SBR state information - * - * Return: 0 if successful, error code (< 0) if error - * - * Note: memory allocation for SBR is only done here - **************************************************************************************/ -int InitSBR(AACDecInfo *aacDecInfo) -{ - PSInfoSBR *psi; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* allocate SBR state structure */ - psi = (PSInfoSBR *)malloc(sizeof(PSInfoSBR)); - if (!psi) { - printf("OOM in SBR, can't allocate %d bytes\n", sizeof(PSInfoSBR)); - return ERR_AAC_SBR_INIT; - } - InitSBRState(psi); - - aacDecInfo->psInfoSBR = psi; - return ERR_AAC_NONE; -} - -int InitSBRPre(AACDecInfo *aacDecInfo, void **ptr, int *sz) -{ - PSInfoSBR *psi; - - if (!aacDecInfo) - return ERR_AAC_NULL_POINTER; - - /* allocate SBR state structure */ - psi = (PSInfoSBR *)*ptr; - *sz -= sizeof(PSInfoSBR); - if (*sz < 0) { - printf("OOM in SBR, can't allocate %d bytes\n", sizeof(PSInfoSBR)); - return ERR_AAC_SBR_INIT; - } - InitSBRState(psi); - - *ptr = (void*)((char*)(*ptr) + sizeof(PSInfoSBR)); - aacDecInfo->psInfoSBR = psi; - return ERR_AAC_NONE; -} - - - -/************************************************************************************** - * Function: FreeSBR - * - * Description: free SBR decoder - * - * Inputs: valid AACDecInfo struct - * - * Outputs: none - * - * Return: none - * - * Note: memory deallocation for SBR is only done here - **************************************************************************************/ -void FreeSBR(AACDecInfo *aacDecInfo) -{ - if (aacDecInfo && aacDecInfo->psInfoSBR) - free(aacDecInfo->psInfoSBR); - - return; -} - -/************************************************************************************** - * Function: DecodeSBRBitstream - * - * Description: decode sideband information for SBR - * - * Inputs: valid AACDecInfo struct - * fill buffer with SBR extension block - * number of bytes in fill buffer - * base output channel (range = [0, nChans-1]) - * - * Outputs: initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan) - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: SBR payload should be in aacDecInfo->fillBuf - * returns with no error if fill buffer is not an SBR extension block, - * or if current block is not a fill block (e.g. for LFE upsampling) - **************************************************************************************/ -int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase) -{ - int headerFlag; - BitStreamInfo bsi; - PSInfoSBR *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - if (aacDecInfo->currBlockID != AAC_ID_FIL || (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC)) - return ERR_AAC_NONE; - - SetBitstreamPointer(&bsi, aacDecInfo->fillCount, aacDecInfo->fillBuf); - if (GetBits(&bsi, 4) != (unsigned int)aacDecInfo->fillExtType) - return ERR_AAC_SBR_BITSTREAM; - - if (aacDecInfo->fillExtType == EXT_SBR_DATA_CRC) - psi->crcCheckWord = GetBits(&bsi, 10); - - headerFlag = GetBits(&bsi, 1); - if (headerFlag) { - /* get sample rate index for output sample rate (2x base rate) */ - psi->sampRateIdx = GetSampRateIdx(2 * aacDecInfo->sampRate); - if (psi->sampRateIdx < 0 || psi->sampRateIdx >= NUM_SAMPLE_RATES) - return ERR_AAC_SBR_BITSTREAM; - else if (psi->sampRateIdx >= NUM_SAMPLE_RATES_SBR) - return ERR_AAC_SBR_SINGLERATE_UNSUPPORTED; - - /* reset flag = 1 if header values changed */ - if (UnpackSBRHeader(&bsi, &(psi->sbrHdr[chBase]))) - psi->sbrChan[chBase].reset = 1; - - /* first valid SBR header should always trigger CalcFreqTables(), since psi->reset was set in InitSBR() */ - if (psi->sbrChan[chBase].reset) - CalcFreqTables(&(psi->sbrHdr[chBase+0]), &(psi->sbrFreq[chBase]), psi->sampRateIdx); - - /* copy and reset state to right channel for CPE */ - if (aacDecInfo->prevBlockID == AAC_ID_CPE) - psi->sbrChan[chBase+1].reset = psi->sbrChan[chBase+0].reset; - } - - - /* if no header has been received, upsample only */ - if (psi->sbrHdr[chBase].count == 0) - return ERR_AAC_NONE; - - if (aacDecInfo->prevBlockID == AAC_ID_SCE) { - UnpackSBRSingleChannel(&bsi, psi, chBase); - } else if (aacDecInfo->prevBlockID == AAC_ID_CPE) { - UnpackSBRChannelPair(&bsi, psi, chBase); - } else { - return ERR_AAC_SBR_BITSTREAM; - } - - ByteAlignBitstream(&bsi); - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: DecodeSBRData - * - * Description: apply SBR to one frame of PCM data - * - * Inputs: 1024 samples of decoded 32-bit PCM, before SBR - * size of input PCM samples (must be 4 bytes) - * number of fraction bits in input PCM samples - * base output channel (range = [0, nChans-1]) - * initialized state structs (SBRHdr, SBRGrid, SBRFreq, SBRChan) - * - * Outputs: 2048 samples of decoded 16-bit PCM, after SBR - * - * Return: 0 if successful, error code (< 0) if error - **************************************************************************************/ -int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf) -{ - int k, l, ch, chBlock, qmfaBands, qmfsBands; - int upsampleOnly, gbIdx, gbMask; - int *inbuf; - short *outptr; - PSInfoSBR *psi; - SBRHeader *sbrHdr; - SBRGrid *sbrGrid; - SBRFreq *sbrFreq; - SBRChan *sbrChan; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - /* same header and freq tables for both channels in CPE */ - sbrHdr = &(psi->sbrHdr[chBase]); - sbrFreq = &(psi->sbrFreq[chBase]); - - /* upsample only if we haven't received an SBR header yet or if we have an LFE block */ - if (aacDecInfo->currBlockID == AAC_ID_LFE) { - chBlock = 1; - upsampleOnly = 1; - } else if (aacDecInfo->currBlockID == AAC_ID_FIL) { - if (aacDecInfo->prevBlockID == AAC_ID_SCE) - chBlock = 1; - else if (aacDecInfo->prevBlockID == AAC_ID_CPE) - chBlock = 2; - else - return ERR_AAC_NONE; - - upsampleOnly = (sbrHdr->count == 0 ? 1 : 0); - if (aacDecInfo->fillExtType != EXT_SBR_DATA && aacDecInfo->fillExtType != EXT_SBR_DATA_CRC) - return ERR_AAC_NONE; - } else { - /* ignore non-SBR blocks */ - return ERR_AAC_NONE; - } - - if (upsampleOnly) { - sbrFreq->kStart = 32; - sbrFreq->numQMFBands = 0; - } - - for (ch = 0; ch < chBlock; ch++) { - sbrGrid = &(psi->sbrGrid[chBase + ch]); - sbrChan = &(psi->sbrChan[chBase + ch]); - - if (aacDecInfo->rawSampleBuf[ch] == 0 || aacDecInfo->rawSampleBytes != 4) - return ERR_AAC_SBR_PCM_FORMAT; - inbuf = (int *)aacDecInfo->rawSampleBuf[ch]; - outptr = outbuf + chBase + ch; - - /* restore delay buffers (could use ring buffer or keep in temp buffer for nChans == 1) */ - for (l = 0; l < HF_GEN; l++) { - for (k = 0; k < 64; k++) { - psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0]; - psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1]; - } - } - - /* step 1 - analysis QMF */ - qmfaBands = sbrFreq->kStart; - for (l = 0; l < 32; l++) { - gbMask = QMFAnalysis(inbuf + l*32, psi->delayQMFA[chBase + ch], psi->XBuf[l + HF_GEN][0], - aacDecInfo->rawSampleFBits, &(psi->delayIdxQMFA[chBase + ch]), qmfaBands); - - gbIdx = ((l + HF_GEN) >> 5) & 0x01; - sbrChan->gbMask[gbIdx] |= gbMask; /* gbIdx = (0 if i < 32), (1 if i >= 32) */ - } - - if (upsampleOnly) { - /* no SBR - just run synthesis QMF to upsample by 2x */ - qmfsBands = 32; - for (l = 0; l < 32; l++) { - /* step 4 - synthesis QMF */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - } else { - /* if previous frame had lower SBR starting freq than current, zero out the synthesized QMF - * bands so they aren't used as sources for patching - * after patch generation, restore from delay buffer - * can only happen after header reset - */ - for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) { - for (l = 0; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) { - psi->XBuf[l][k][0] = 0; - psi->XBuf[l][k][1] = 0; - } - } - - /* step 2 - HF generation */ - GenerateHighFreq(psi, sbrGrid, sbrFreq, sbrChan, ch); - - /* restore SBR bands that were cleared before patch generation (time slots 0, 1 no longer needed) */ - for (k = sbrFreq->kStartPrev; k < sbrFreq->kStart; k++) { - for (l = HF_ADJ; l < sbrGrid->envTimeBorder[0] + HF_ADJ; l++) { - psi->XBuf[l][k][0] = psi->XBufDelay[chBase + ch][l][k][0]; - psi->XBuf[l][k][1] = psi->XBufDelay[chBase + ch][l][k][1]; - } - } - - /* step 3 - HF adjustment */ - AdjustHighFreq(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch); - - /* step 4 - synthesis QMF */ - qmfsBands = sbrFreq->kStartPrev + sbrFreq->numQMFBandsPrev; - for (l = 0; l < sbrGrid->envTimeBorder[0]; l++) { - /* if new envelope starts mid-frame, use old settings until start of first envelope in this frame */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - - qmfsBands = sbrFreq->kStart + sbrFreq->numQMFBands; - for ( ; l < 32; l++) { - /* use new settings for rest of frame (usually the entire frame, unless the first envelope starts mid-frame) */ - QMFSynthesis(psi->XBuf[l + HF_ADJ][0], psi->delayQMFS[chBase + ch], &(psi->delayIdxQMFS[chBase + ch]), qmfsBands, outptr, aacDecInfo->nChans); - outptr += 64*aacDecInfo->nChans; - } - } - - /* save delay */ - for (l = 0; l < HF_GEN; l++) { - for (k = 0; k < 64; k++) { - psi->XBufDelay[chBase + ch][l][k][0] = psi->XBuf[l+32][k][0]; - psi->XBufDelay[chBase + ch][l][k][1] = psi->XBuf[l+32][k][1]; - } - } - sbrChan->gbMask[0] = sbrChan->gbMask[1]; - sbrChan->gbMask[1] = 0; - - if (sbrHdr->count > 0) - sbrChan->reset = 0; - } - sbrFreq->kStartPrev = sbrFreq->kStart; - sbrFreq->numQMFBandsPrev = sbrFreq->numQMFBands; - - if (aacDecInfo->nChans > 0 && (chBase + ch) == aacDecInfo->nChans) - psi->frameCount++; - - return ERR_AAC_NONE; -} - -/************************************************************************************** - * Function: FlushCodecSBR - * - * Description: flush internal SBR codec state (after seeking, for example) - * - * Inputs: valid AACDecInfo struct - * - * Outputs: updated state variables for SBR - * - * Return: 0 if successful, error code (< 0) if error - * - * Notes: SBR is heavily dependent on state from previous frames - * (e.g. delta coded scalefactors, previous envelope boundaries, etc.) - * On flush, we reset everything as if SBR had just been initialized - * for the first time. This triggers "upsample-only" mode until - * the first valid SBR header is received. Then SBR starts as usual. - **************************************************************************************/ -int FlushCodecSBR(AACDecInfo *aacDecInfo) -{ - PSInfoSBR *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoSBR) - return ERR_AAC_NULL_POINTER; - psi = (PSInfoSBR *)(aacDecInfo->psInfoSBR); - - InitSBRState(psi); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbr.h b/components/spotify/cspot/bell/external/libhelix-aac/sbr.h deleted file mode 100644 index 6c898a13..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbr.h +++ /dev/null @@ -1,383 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbr.h,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbr.h - definitions of platform-specific SBR data structures, functions, and tables - **************************************************************************************/ - -#ifndef _SBR_H -#define _SBR_H - -#include "aaccommon.h" -#include "bitstream.h" - -#ifndef ASSERT -#if defined(_WIN32) && defined(_M_IX86) && (defined (_DEBUG) || defined (REL_ENABLE_ASSERTS)) -#define ASSERT(x) if (!(x)) __asm int 3; -#else -#define ASSERT(x) /* do nothing */ -#endif -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define NUM_TIME_SLOTS 16 -#define SAMPLES_PER_SLOT 2 /* RATE in spec */ -#define NUM_SAMPLE_RATES_SBR 9 /* downsampled (single-rate) mode unsupported, so only use Fs_sbr >= 16 kHz */ - -#define MAX_NUM_ENV 5 -#define MAX_NUM_NOISE_FLOORS 2 -#define MAX_NUM_NOISE_FLOOR_BANDS 5 /* max Nq, see 4.6.18.3.6 */ -#define MAX_NUM_PATCHES 5 -#define MAX_NUM_SMOOTH_COEFS 5 - -#define HF_GEN 8 -#define HF_ADJ 2 - -#define MAX_QMF_BANDS 48 /* max QMF subbands covered by SBR (4.6.18.3.6) */ - -#define FBITS_IN_QMFA 14 -#define FBITS_LOST_QMFA (1 + 2 + 3 + 2 + 1) /* 1 from cTab, 2 in premul, 3 in FFT, 2 in postmul, 1 for implicit scaling by 2.0 */ -#define FBITS_OUT_QMFA (FBITS_IN_QMFA - FBITS_LOST_QMFA) - -#define MIN_GBITS_IN_QMFS 2 -#define FBITS_IN_QMFS FBITS_OUT_QMFA -#define FBITS_LOST_DCT4_64 (2 + 3 + 2) /* 2 in premul, 3 in FFT, 2 in postmul */ - -#define FBITS_OUT_DQ_ENV 29 /* dequantized env scalefactors are Q(29 - envDataDequantScale) */ -#define FBITS_OUT_DQ_NOISE 24 /* range of Q_orig = [2^-24, 2^6] */ -#define NOISE_FLOOR_OFFSET 6 - -/* see comments in ApplyBoost() */ -#define FBITS_GLIM_BOOST 24 -#define FBITS_QLIM_BOOST 14 - -#define MAX_HUFF_BITS 20 -#define NUM_QMF_DELAY_BUFS 10 -#define DELAY_SAMPS_QMFA (NUM_QMF_DELAY_BUFS * 32) -#define DELAY_SAMPS_QMFS (NUM_QMF_DELAY_BUFS * 128) - -/* additional external symbols to name-mangle for static linking */ -#define FFT32C STATNAME(FFT32C) -#define CalcFreqTables STATNAME(CalcFreqTables) -#define AdjustHighFreq STATNAME(AdjustHighFreq) -#define GenerateHighFreq STATNAME(GenerateHighFreq) -#define DecodeSBREnvelope STATNAME(DecodeSBREnvelope) -#define DecodeSBRNoise STATNAME(DecodeSBRNoise) -#define UncoupleSBREnvelope STATNAME(UncoupleSBREnvelope) -#define UncoupleSBRNoise STATNAME(UncoupleSBRNoise) -#define InvRNormalized STATNAME(InvRNormalized) -#define RatioPowInv STATNAME(RatioPowInv) -#define SqrtFix STATNAME(SqrtFix) -#define QMFAnalysis STATNAME(QMFAnalysis) -#define QMFSynthesis STATNAME(QMFSynthesis) -#define GetSampRateIdx STATNAME(GetSampRateIdx) -#define UnpackSBRHeader STATNAME(UnpackSBRHeader) -#define UnpackSBRSingleChannel STATNAME(UnpackSBRSingleChannel) -#define UnpackSBRChannelPair STATNAME(UnpackSBRChannelPair) - -/* asm functions */ -#define CVKernel1 STATNAME(CVKernel1) -#define CVKernel2 STATNAME(CVKernel2) -#define QMFAnalysisConv STATNAME(QMFAnalysisConv) -#define QMFSynthesisConv STATNAME(QMFSynthesisConv) - -#define k0Tab STATNAME(k0Tab) -#define k2Tab STATNAME(k2Tab) -#define goalSBTab STATNAME(goalSBTab) -#define huffTabSBR STATNAME(huffTabSBR) -#define huffTabSBRInfo STATNAME(huffTabSBRInfo) -#define log2Tab STATNAME(log2Tab) -#define noiseTab STATNAME(noiseTab) -#define cTabA STATNAME(cTabA) -#define cTabS STATNAME(cTabS) - -/* do y <<= n, clipping to range [-2^30, 2^30 - 1] (i.e. output has one guard bit) */ -#define CLIP_2N_SHIFT30(y, n) { \ - int sign = (y) >> 31; \ - if (sign != (y) >> (30 - (n))) { \ - (y) = sign ^ (0x3fffffff); \ - } else { \ - (y) = (y) << (n); \ - } \ -} - -/* -#define CLIP_2N(y, n) { \ - int sign = (y) >> 31; \ - if (sign != ((y) >> (n))) { \ - (y) = sign ^ ((1 << (n)) - 1); \ - } \ -} -*/ - -enum { - SBR_GRID_FIXFIX = 0, - SBR_GRID_FIXVAR = 1, - SBR_GRID_VARFIX = 2, - SBR_GRID_VARVAR = 3 -}; - -enum { - HuffTabSBR_tEnv15 = 0, - HuffTabSBR_fEnv15 = 1, - HuffTabSBR_tEnv15b = 2, - HuffTabSBR_fEnv15b = 3, - HuffTabSBR_tEnv30 = 4, - HuffTabSBR_fEnv30 = 5, - HuffTabSBR_tEnv30b = 6, - HuffTabSBR_fEnv30b = 7, - HuffTabSBR_tNoise30 = 8, - HuffTabSBR_fNoise30 = 5, - HuffTabSBR_tNoise30b = 9, - HuffTabSBR_fNoise30b = 7 -}; - -typedef struct _HuffInfo { - int maxBits; /* number of bits in longest codeword */ - unsigned /*char*/ int count[MAX_HUFF_BITS]; /* count[i] = number of codes with length i+1 bits */ - int offset; /* offset into symbol table */ -} HuffInfo; - -/* need one SBRHeader per element (SCE/CPE), updated only on new header */ -typedef struct _SBRHeader { - int count; - - unsigned char ampRes; - unsigned char startFreq; - unsigned char stopFreq; - unsigned char crossOverBand; - unsigned char resBitsHdr; - unsigned char hdrExtra1; - unsigned char hdrExtra2; - - unsigned char freqScale; - unsigned char alterScale; - unsigned char noiseBands; - - unsigned char limiterBands; - unsigned char limiterGains; - unsigned char interpFreq; - unsigned char smoothMode; -} SBRHeader; - -/* need one SBRGrid per channel, updated every frame */ -typedef struct _SBRGrid { - unsigned char frameClass; - unsigned char ampResFrame; - unsigned char pointer; - - unsigned char numEnv; /* L_E */ - unsigned char envTimeBorder[MAX_NUM_ENV+1]; /* t_E */ - unsigned char freqRes[MAX_NUM_ENV]; /* r */ - - unsigned char numNoiseFloors; /* L_Q */ - unsigned char noiseTimeBorder[MAX_NUM_NOISE_FLOORS+1]; /* t_Q */ - - unsigned char numEnvPrev; - unsigned char numNoiseFloorsPrev; - unsigned char freqResPrev; -} SBRGrid; - -/* need one SBRFreq per element (SCE/CPE/LFE), updated only on header reset */ -typedef struct _SBRFreq { - int kStart; /* k_x */ - int nMaster; - int nHigh; - int nLow; - int nLimiter; /* N_l */ - int numQMFBands; /* M */ - int numNoiseFloorBands; /* Nq */ - - int kStartPrev; - int numQMFBandsPrev; - - unsigned char freqMaster[MAX_QMF_BANDS + 1]; /* not necessary to save this after derived tables are generated */ - unsigned char freqHigh[MAX_QMF_BANDS + 1]; - unsigned char freqLow[MAX_QMF_BANDS / 2 + 1]; /* nLow = nHigh - (nHigh >> 1) */ - unsigned char freqNoise[MAX_NUM_NOISE_FLOOR_BANDS+1]; - unsigned char freqLimiter[MAX_QMF_BANDS / 2 + MAX_NUM_PATCHES]; /* max (intermediate) size = nLow + numPatches - 1 */ - - unsigned char numPatches; - unsigned char patchNumSubbands[MAX_NUM_PATCHES + 1]; - unsigned char patchStartSubband[MAX_NUM_PATCHES + 1]; -} SBRFreq; - -typedef struct _SBRChan { - int reset; - unsigned char deltaFlagEnv[MAX_NUM_ENV]; - unsigned char deltaFlagNoise[MAX_NUM_NOISE_FLOORS]; - - signed char envDataQuant[MAX_NUM_ENV][MAX_QMF_BANDS]; /* range = [0, 127] */ - signed char noiseDataQuant[MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS]; - - unsigned char invfMode[2][MAX_NUM_NOISE_FLOOR_BANDS]; /* invfMode[0/1][band] = prev/curr */ - int chirpFact[MAX_NUM_NOISE_FLOOR_BANDS]; /* bwArray */ - unsigned char addHarmonicFlag[2]; /* addHarmonicFlag[0/1] = prev/curr */ - unsigned char addHarmonic[2][64]; /* addHarmonic[0/1][band] = prev/curr */ - - int gbMask[2]; /* gbMask[0/1] = XBuf[0-31]/XBuf[32-39] */ - signed char laPrev; - - int noiseTabIndex; - int sinIndex; - int gainNoiseIndex; - int gTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS]; - int qTemp[MAX_NUM_SMOOTH_COEFS][MAX_QMF_BANDS]; - -} SBRChan; - -typedef struct _PSInfoSBR { - /* save for entire file */ - int frameCount; - int sampRateIdx; - - /* state info that must be saved for each channel */ - SBRHeader sbrHdr[AAC_MAX_NCHANS]; - SBRGrid sbrGrid[AAC_MAX_NCHANS]; - SBRFreq sbrFreq[AAC_MAX_NCHANS]; - SBRChan sbrChan[AAC_MAX_NCHANS]; - - /* temp variables, no need to save between blocks */ - unsigned char dataExtra; - unsigned char resBitsData; - unsigned char extendedDataPresent; - int extendedDataSize; - - signed char envDataDequantScale[MAX_NCHANS_ELEM][MAX_NUM_ENV]; - int envDataDequant[MAX_NCHANS_ELEM][MAX_NUM_ENV][MAX_QMF_BANDS]; - int noiseDataDequant[MAX_NCHANS_ELEM][MAX_NUM_NOISE_FLOORS][MAX_NUM_NOISE_FLOOR_BANDS]; - - int eCurr[MAX_QMF_BANDS]; - unsigned char eCurrExp[MAX_QMF_BANDS]; - unsigned char eCurrExpMax; - signed char la; - - int crcCheckWord; - int couplingFlag; - int envBand; - int eOMGainMax; - int gainMax; - int gainMaxFBits; - int noiseFloorBand; - int qp1Inv; - int qqp1Inv; - int sMapped; - int sBand; - int highBand; - - int sumEOrigMapped; - int sumECurrGLim; - int sumSM; - int sumQM; - int gLimBoost[MAX_QMF_BANDS]; - int qmLimBoost[MAX_QMF_BANDS]; - int smBoost[MAX_QMF_BANDS]; - - int smBuf[MAX_QMF_BANDS]; - int qmLimBuf[MAX_QMF_BANDS]; - int gLimBuf[MAX_QMF_BANDS]; - int gLimFbits[MAX_QMF_BANDS]; - - int gFiltLast[MAX_QMF_BANDS]; - int qFiltLast[MAX_QMF_BANDS]; - - /* large buffers */ - int delayIdxQMFA[AAC_MAX_NCHANS]; - int delayQMFA[AAC_MAX_NCHANS][DELAY_SAMPS_QMFA]; - int delayIdxQMFS[AAC_MAX_NCHANS]; - int delayQMFS[AAC_MAX_NCHANS][DELAY_SAMPS_QMFS]; - int XBufDelay[AAC_MAX_NCHANS][HF_GEN][64][2]; - int XBuf[32+8][64][2]; - -} PSInfoSBR; - -/* sbrfft.c */ -void FFT32C(int *x); - -/* sbrfreq.c */ -int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx); - -/* sbrhfadj.c */ -void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); - -/* sbrhfgen.c */ -void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); - -/* sbrhuff.c */ -void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); -void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch); -void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR); -void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR); - -/* sbrmath.c */ -int InvRNormalized(int r); -int RatioPowInv(int a, int b, int c); -int SqrtFix(int x, int fBitsIn, int *fBitsOut); - -/* sbrqmf.c */ -int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands); -void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans); - -/* sbrside.c */ -int GetSampRateIdx(int sampRate); -int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr); -void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut); -void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chOut); - -/* sbrtabs.c */ -extern const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16]; -extern const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14]; -extern const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR]; -extern const HuffInfo huffTabSBRInfo[10]; -extern const signed int /*short*/ huffTabSBR[604]; -extern const int log2Tab[65]; -extern const int noiseTab[512*2]; -extern const int cTabA[165]; -extern const int cTabS[640]; - -#endif /* _SBR_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrfft.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrfft.c deleted file mode 100644 index 23b36ac3..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrfft.c +++ /dev/null @@ -1,368 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrfft.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * sbrfft.c - optimized FFT for SBR QMF filters - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define SQRT1_2 0x5a82799a - -/* swap RE{p0} with RE{p1} and IM{P0} with IM{P1} */ -#define swapcplx(p0,p1) \ - t = p0; t1 = *(&(p0)+1); p0 = p1; *(&(p0)+1) = *(&(p1)+1); p1 = t; *(&(p1)+1) = t1 - -/* nfft = 32, hard coded since small, fixed size FFT -static const unsigned char bitrevtab32[9] = { - 0x01, 0x04, 0x03, 0x06, 0x00, 0x02, 0x05, 0x07, 0x00, -}; -*/ - -/* twiddle table for radix 4 pass, format = Q31 */ -static const int twidTabOdd32[8*6] = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59, - 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, - 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862, - 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, - 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, -}; - -/************************************************************************************** - * Function: BitReverse32 - * - * Description: Ken's fast in-place bit reverse - * - * Inputs: buffer of 32 complex samples - * - * Outputs: bit-reversed samples in same buffer - * - * Return: none -**************************************************************************************/ -static void BitReverse32(int *inout) -{ - int t, t1; - - swapcplx(inout[2], inout[32]); - swapcplx(inout[4], inout[16]); - swapcplx(inout[6], inout[48]); - swapcplx(inout[10], inout[40]); - swapcplx(inout[12], inout[24]); - swapcplx(inout[14], inout[56]); - swapcplx(inout[18], inout[36]); - swapcplx(inout[22], inout[52]); - swapcplx(inout[26], inout[44]); - swapcplx(inout[30], inout[60]); - swapcplx(inout[38], inout[50]); - swapcplx(inout[46], inout[58]); -} - -/************************************************************************************** - * Function: R8FirstPass32 - * - * Description: radix-8 trivial pass for decimation-in-time FFT (log2(N) = 5) - * - * Inputs: buffer of (bit-reversed) samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits, gains 1 integer bit - * guard bits out = guard bits in - 3 (if inputs are full scale) - * or guard bits in - 2 (if inputs bounded to +/- sqrt(2)/2) - * see scaling comments in fft.c for base AAC - * should compile with no stack spills on ARM (verify compiled output) - * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU - **************************************************************************************/ -static void R8FirstPass32(int *r0) -{ - int r1, r2, r3, r4, r5, r6, r7; - int r8, r9, r10, r11, r12, r14; - - /* number of passes = fft size / 8 = 32 / 8 = 4 */ - r1 = (32 >> 3); - do { - - r2 = r0[8]; - r3 = r0[9]; - r4 = r0[10]; - r5 = r0[11]; - r6 = r0[12]; - r7 = r0[13]; - r8 = r0[14]; - r9 = r0[15]; - - r10 = r2 + r4; - r11 = r3 + r5; - r12 = r6 + r8; - r14 = r7 + r9; - - r2 -= r4; - r3 -= r5; - r6 -= r8; - r7 -= r9; - - r4 = r2 - r7; - r5 = r2 + r7; - r8 = r3 - r6; - r9 = r3 + r6; - - r2 = r4 - r9; - r3 = r4 + r9; - r6 = r5 - r8; - r7 = r5 + r8; - - r2 = MULSHIFT32(SQRT1_2, r2); /* can use r4, r5, r8, or r9 for constant and lo32 scratch reg */ - r3 = MULSHIFT32(SQRT1_2, r3); - r6 = MULSHIFT32(SQRT1_2, r6); - r7 = MULSHIFT32(SQRT1_2, r7); - - r4 = r10 + r12; - r5 = r10 - r12; - r8 = r11 + r14; - r9 = r11 - r14; - - r10 = r0[0]; - r11 = r0[2]; - r12 = r0[4]; - r14 = r0[6]; - - r10 += r11; - r12 += r14; - - r4 >>= 1; - r10 += r12; - r4 += (r10 >> 1); - r0[ 0] = r4; - r4 -= (r10 >> 1); - r4 = (r10 >> 1) - r4; - r0[ 8] = r4; - - r9 >>= 1; - r10 -= 2*r12; - r4 = (r10 >> 1) + r9; - r0[ 4] = r4; - r4 = (r10 >> 1) - r9; - r0[12] = r4; - r10 += r12; - - r10 -= 2*r11; - r12 -= 2*r14; - - r4 = r0[1]; - r9 = r0[3]; - r11 = r0[5]; - r14 = r0[7]; - - r4 += r9; - r11 += r14; - - r8 >>= 1; - r4 += r11; - r8 += (r4 >> 1); - r0[ 1] = r8; - r8 -= (r4 >> 1); - r8 = (r4 >> 1) - r8; - r0[ 9] = r8; - - r5 >>= 1; - r4 -= 2*r11; - r8 = (r4 >> 1) - r5; - r0[ 5] = r8; - r8 = (r4 >> 1) + r5; - r0[13] = r8; - r4 += r11; - - r4 -= 2*r9; - r11 -= 2*r14; - - r9 = r10 - r11; - r10 += r11; - r14 = r4 + r12; - r4 -= r12; - - r5 = (r10 >> 1) + r7; - r8 = (r4 >> 1) - r6; - r0[ 2] = r5; - r0[ 3] = r8; - - r5 = (r9 >> 1) - r2; - r8 = (r14 >> 1) - r3; - r0[ 6] = r5; - r0[ 7] = r8; - - r5 = (r10 >> 1) - r7; - r8 = (r4 >> 1) + r6; - r0[10] = r5; - r0[11] = r8; - - r5 = (r9 >> 1) + r2; - r8 = (r14 >> 1) + r3; - r0[14] = r5; - r0[15] = r8; - - r0 += 16; - r1--; - } while (r1 != 0); -} - -/************************************************************************************** - * Function: R4Core32 - * - * Description: radix-4 pass for 32-point decimation-in-time FFT - * - * Inputs: buffer of samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: gain 2 integer bits - * guard bits out = guard bits in - 1 (if inputs are full scale) - * see scaling comments in fft.c for base AAC - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - * should compile with no stack spills on ARM (verify compiled output) - * current instruction count (per pass): 16 LDR, 16 STR, 4 SMULL, 61 ALU - **************************************************************************************/ -static void R4Core32(int *r0) -{ - int r2, r3, r4, r5, r6, r7; - int r8, r9, r10, r12, r14; - int *r1; - - r1 = (int *)twidTabOdd32; - r10 = 8; - do { - /* can use r14 for lo32 scratch register in all MULSHIFT32 */ - r2 = r1[0]; - r3 = r1[1]; - r4 = r0[16]; - r5 = r0[17]; - r12 = r4 + r5; - r12 = MULSHIFT32(r3, r12); - r5 = MULSHIFT32(r2, r5) + r12; - r2 += 2*r3; - r4 = MULSHIFT32(r2, r4) - r12; - - r2 = r1[2]; - r3 = r1[3]; - r6 = r0[32]; - r7 = r0[33]; - r12 = r6 + r7; - r12 = MULSHIFT32(r3, r12); - r7 = MULSHIFT32(r2, r7) + r12; - r2 += 2*r3; - r6 = MULSHIFT32(r2, r6) - r12; - - r2 = r1[4]; - r3 = r1[5]; - r8 = r0[48]; - r9 = r0[49]; - r12 = r8 + r9; - r12 = MULSHIFT32(r3, r12); - r9 = MULSHIFT32(r2, r9) + r12; - r2 += 2*r3; - r8 = MULSHIFT32(r2, r8) - r12; - - r2 = r0[0]; - r3 = r0[1]; - - r12 = r6 + r8; - r8 = r6 - r8; - r14 = r9 - r7; - r9 = r9 + r7; - - r6 = (r2 >> 2) - r4; - r7 = (r3 >> 2) - r5; - r4 += (r2 >> 2); - r5 += (r3 >> 2); - - r2 = r4 + r12; - r3 = r5 + r9; - r0[0] = r2; - r0[1] = r3; - r2 = r6 - r14; - r3 = r7 - r8; - r0[16] = r2; - r0[17] = r3; - r2 = r4 - r12; - r3 = r5 - r9; - r0[32] = r2; - r0[33] = r3; - r2 = r6 + r14; - r3 = r7 + r8; - r0[48] = r2; - r0[49] = r3; - - r0 += 2; - r1 += 6; - r10--; - } while (r10 != 0); -} - -/************************************************************************************** - * Function: FFT32C - * - * Description: Ken's very fast in-place radix-4 decimation-in-time FFT - * - * Inputs: buffer of 32 complex samples (before bit-reversal) - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: assumes 3 guard bits in, gains 3 integer bits - * guard bits out = guard bits in - 2 - * (guard bit analysis includes assumptions about steps immediately - * before and after, i.e. PreMul and PostMul for DCT) - **************************************************************************************/ -void FFT32C(int *x) -{ - /* decimation in time */ - BitReverse32(x); - - /* 32-point complex FFT */ - R8FirstPass32(x); /* gain 1 int bit, lose 2 GB (making assumptions about input) */ - R4Core32(x); /* gain 2 int bits, lose 0 GB (making assumptions about input) */ -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrfreq.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrfreq.c deleted file mode 100644 index 26a76063..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrfreq.c +++ /dev/null @@ -1,641 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrfreq.c,v 1.2 2005/05/20 18:05:41 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrfreq.c - frequency band table calculation for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/************************************************************************************** - * Function: BubbleSort - * - * Description: in-place sort of unsigned chars - * - * Inputs: buffer of elements to sort - * number of elements to sort - * - * Outputs: sorted buffer - * - * Return: none - **************************************************************************************/ -static void BubbleSort(unsigned char *v, int nItems) -{ - int i; - unsigned char t; - - while (nItems >= 2) { - for (i = 0; i < nItems-1; i++) { - if (v[i+1] < v[i]) { - t = v[i+1]; - v[i+1] = v[i]; - v[i] = t; - } - } - nItems--; - } -} - -/************************************************************************************** - * Function: VMin - * - * Description: find smallest element in a buffer of unsigned chars - * - * Inputs: buffer of elements to search - * number of elements to search - * - * Outputs: none - * - * Return: smallest element in buffer - **************************************************************************************/ -static unsigned char VMin(unsigned char *v, int nItems) -{ - int i; - unsigned char vMin; - - vMin = v[0]; - for (i = 1; i < nItems; i++) { - if (v[i] < vMin) - vMin = v[i]; - } - return vMin; -} - -/************************************************************************************** - * Function: VMax - * - * Description: find largest element in a buffer of unsigned chars - * - * Inputs: buffer of elements to search - * number of elements to search - * - * Outputs: none - * - * Return: largest element in buffer - **************************************************************************************/ -static unsigned char VMax(unsigned char *v, int nItems) -{ - int i; - unsigned char vMax; - - vMax = v[0]; - for (i = 1; i < nItems; i++) { - if (v[i] > vMax) - vMax = v[i]; - } - return vMax; -} - -/************************************************************************************** - * Function: CalcFreqMasterScaleZero - * - * Description: calculate master frequency table when freqScale == 0 - * (4.6.18.3.2.1, figure 4.39) - * - * Inputs: alterScale flag - * index of first QMF subband in master freq table (k0) - * index of last QMF subband (k2) - * - * Outputs: master frequency table - * - * Return: number of bands in master frequency table - * - * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6) - **************************************************************************************/ -static int CalcFreqMasterScaleZero(unsigned char *freqMaster, int alterScale, int k0, int k2) -{ - int nMaster, k, nBands, k2Achieved, dk, vDk[64], k2Diff; - - if (alterScale) { - dk = 2; - nBands = 2 * ((k2 - k0 + 2) >> 2); - } else { - dk = 1; - nBands = 2 * ((k2 - k0) >> 1); - } - - if (nBands <= 0) - return 0; - - k2Achieved = k0 + nBands * dk; - k2Diff = k2 - k2Achieved; - for (k = 0; k < nBands; k++) - vDk[k] = dk; - - if (k2Diff > 0) { - k = nBands - 1; - while (k2Diff) { - vDk[k]++; - k--; - k2Diff--; - } - } else if (k2Diff < 0) { - k = 0; - while (k2Diff) { - vDk[k]--; - k++; - k2Diff++; - } - } - - nMaster = nBands; - freqMaster[0] = k0; - for (k = 1; k <= nBands; k++) - freqMaster[k] = freqMaster[k-1] + vDk[k-1]; - - return nMaster; -} - -/* mBandTab[i] = temp1[i] / 2 */ -static const int mBandTab[3] PROGMEM = {6, 5, 4}; - -/* invWarpTab[i] = 1.0 / temp2[i], Q30 (see 4.6.18.3.2.1) */ -static const int invWarpTab[2] PROGMEM = {0x40000000, 0x313b13b1}; - -/************************************************************************************** - * Function: CalcFreqMasterScale - * - * Description: calculate master frequency table when freqScale > 0 - * (4.6.18.3.2.1, figure 4.39) - * - * Inputs: alterScale flag - * freqScale flag - * index of first QMF subband in master freq table (k0) - * index of last QMF subband (k2) - * - * Outputs: master frequency table - * - * Return: number of bands in master frequency table - * - * Notes: assumes k2 - k0 <= 48 and k2 >= k0 (4.6.18.3.6) - **************************************************************************************/ -static int CalcFreqMaster(unsigned char *freqMaster, int freqScale, int alterScale, int k0, int k2) -{ - int bands, twoRegions, k, k1, t, vLast, vCurr, pCurr; - int invWarp, nBands0, nBands1, change; - unsigned char vDk1Min, vDk0Max; - unsigned char *vDelta; - - if (freqScale < 1 || freqScale > 3) - return -1; - - bands = mBandTab[freqScale - 1]; - invWarp = invWarpTab[alterScale]; - - /* tested for all k0 = [5, 64], k2 = [k0, 64] */ - if (k2*10000 > 22449*k0) { - twoRegions = 1; - k1 = 2*k0; - } else { - twoRegions = 0; - k1 = k2; - } - - /* tested for all k0 = [5, 64], k1 = [k0, 64], freqScale = [1,3] */ - t = (log2Tab[k1] - log2Tab[k0]) >> 3; /* log2(k1/k0), Q28 to Q25 */ - nBands0 = 2 * (((bands * t) + (1 << 24)) >> 25); /* multiply by bands/2, round to nearest int (mBandTab has factor of 1/2 rolled in) */ - - /* tested for all valid combinations of k0, k1, nBands (from sampRate, freqScale, alterScale) - * roundoff error can be a problem with fixpt (e.g. pCurr = 12.499999 instead of 12.50003) - * because successive multiplication always undershoots a little bit, but this - * doesn't occur in any of the ratios we encounter from the valid k0/k1 bands in the spec - */ - t = RatioPowInv(k1, k0, nBands0); - pCurr = k0 << 24; - vLast = k0; - vDelta = freqMaster + 1; /* operate in-place */ - for (k = 0; k < nBands0; k++) { - pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */ - vCurr = (pCurr + (1 << 23)) >> 24; - vDelta[k] = (vCurr - vLast); - vLast = vCurr; - } - - /* sort the deltas and find max delta for first region */ - BubbleSort(vDelta, nBands0); - vDk0Max = VMax(vDelta, nBands0); - - /* fill master frequency table with bands from first region */ - freqMaster[0] = k0; - for (k = 1; k <= nBands0; k++) - freqMaster[k] += freqMaster[k-1]; - - /* if only one region, then the table is complete */ - if (!twoRegions) - return nBands0; - - /* tested for all k1 = [10, 64], k2 = [k0, 64], freqScale = [1,3] */ - t = (log2Tab[k2] - log2Tab[k1]) >> 3; /* log2(k1/k0), Q28 to Q25 */ - t = MULSHIFT32(bands * t, invWarp) << 2; /* multiply by bands/2, divide by warp factor, keep Q25 */ - nBands1 = 2 * ((t + (1 << 24)) >> 25); /* round to nearest int */ - - /* see comments above for calculations in first region */ - t = RatioPowInv(k2, k1, nBands1); - pCurr = k1 << 24; - vLast = k1; - vDelta = freqMaster + nBands0 + 1; /* operate in-place */ - for (k = 0; k < nBands1; k++) { - pCurr = MULSHIFT32(pCurr, t) << 8; /* keep in Q24 */ - vCurr = (pCurr + (1 << 23)) >> 24; - vDelta[k] = (vCurr - vLast); - vLast = vCurr; - } - - /* sort the deltas, adjusting first and last if the second region has smaller deltas than the first */ - vDk1Min = VMin(vDelta, nBands1); - if (vDk1Min < vDk0Max) { - BubbleSort(vDelta, nBands1); - change = vDk0Max - vDelta[0]; - if (change > ((vDelta[nBands1 - 1] - vDelta[0]) >> 1)) - change = ((vDelta[nBands1 - 1] - vDelta[0]) >> 1); - vDelta[0] += change; - vDelta[nBands1-1] -= change; - } - BubbleSort(vDelta, nBands1); - - /* fill master frequency table with bands from second region - * Note: freqMaster[nBands0] = k1 - */ - for (k = 1; k <= nBands1; k++) - freqMaster[k + nBands0] += freqMaster[k + nBands0 - 1]; - - return (nBands0 + nBands1); -} - -/************************************************************************************** - * Function: CalcFreqHigh - * - * Description: calculate high resolution frequency table (4.6.18.3.2.2) - * - * Inputs: master frequency table - * number of bands in master frequency table - * crossover band from header - * - * Outputs: high resolution frequency table - * - * Return: number of bands in high resolution frequency table - **************************************************************************************/ -static int CalcFreqHigh(unsigned char *freqHigh, unsigned char *freqMaster, int nMaster, int crossOverBand) -{ - int k, nHigh; - - nHigh = nMaster - crossOverBand; - - for (k = 0; k <= nHigh; k++) - freqHigh[k] = freqMaster[k + crossOverBand]; - - return nHigh; -} - -/************************************************************************************** - * Function: CalcFreqLow - * - * Description: calculate low resolution frequency table (4.6.18.3.2.2) - * - * Inputs: high resolution frequency table - * number of bands in high resolution frequency table - * - * Outputs: low resolution frequency table - * - * Return: number of bands in low resolution frequency table - **************************************************************************************/ -static int CalcFreqLow(unsigned char *freqLow, unsigned char *freqHigh, int nHigh) -{ - int k, nLow, oddFlag; - - nLow = nHigh - (nHigh >> 1); - freqLow[0] = freqHigh[0]; - oddFlag = nHigh & 0x01; - - for (k = 1; k <= nLow; k++) - freqLow[k] = freqHigh[2*k - oddFlag]; - - return nLow; -} - -/************************************************************************************** - * Function: CalcFreqNoise - * - * Description: calculate noise floor frequency table (4.6.18.3.2.2) - * - * Inputs: low resolution frequency table - * number of bands in low resolution frequency table - * index of starting QMF subband for SBR (kStart) - * index of last QMF subband (k2) - * number of noise bands - * - * Outputs: noise floor frequency table - * - * Return: number of bands in noise floor frequency table - **************************************************************************************/ -static int CalcFreqNoise(unsigned char *freqNoise, unsigned char *freqLow, int nLow, int kStart, int k2, int noiseBands) -{ - int i, iLast, k, nQ, lTop, lBottom; - - lTop = log2Tab[k2]; - lBottom = log2Tab[kStart]; - nQ = noiseBands*((lTop - lBottom) >> 2); /* Q28 to Q26, noiseBands = [0,3] */ - nQ = (nQ + (1 << 25)) >> 26; - if (nQ < 1) - nQ = 1; - - ASSERT(nQ <= MAX_NUM_NOISE_FLOOR_BANDS); /* required from 4.6.18.3.6 */ - - iLast = 0; - freqNoise[0] = freqLow[0]; - for (k = 1; k <= nQ; k++) { - i = iLast + (nLow - iLast) / (nQ + 1 - k); /* truncating division */ - freqNoise[k] = freqLow[i]; - iLast = i; - } - - return nQ; -} - -/************************************************************************************** - * Function: BuildPatches - * - * Description: build high frequency patches (4.6.18.6.3) - * - * Inputs: master frequency table - * number of bands in low resolution frequency table - * index of first QMF subband in master freq table (k0) - * index of starting QMF subband for SBR (kStart) - * number of QMF bands in high resolution frequency table - * sample rate index - * - * Outputs: starting subband for each patch - * number of subbands in each patch - * - * Return: number of patches - **************************************************************************************/ -static int BuildPatches(unsigned char *patchNumSubbands, unsigned char *patchStartSubband, unsigned char *freqMaster, - int nMaster, int k0, int kStart, int numQMFBands, int sampRateIdx) -{ - int i, j, k; - int msb, sb, usb, numPatches, goalSB, oddFlag; - - msb = k0; - usb = kStart; - numPatches = 0; - goalSB = goalSBTab[sampRateIdx]; - - if (nMaster == 0) { - patchNumSubbands[0] = 0; - patchStartSubband[0] = 0; - return 0; - } - - if (goalSB < kStart + numQMFBands) { - k = 0; - for (i = 0; freqMaster[i] < goalSB; i++) - k = i+1; - } else { - k = nMaster; - } - - do { - j = k+1; - do { - j--; - sb = freqMaster[j]; - oddFlag = (sb - 2 + k0) & 0x01; - } while (sb > k0 - 1 + msb - oddFlag); - - patchNumSubbands[numPatches] = MAX(sb - usb, 0); - patchStartSubband[numPatches] = k0 - oddFlag - patchNumSubbands[numPatches]; - - /* from MPEG reference code - slightly different from spec */ - if ((patchNumSubbands[numPatches] < 3) && (numPatches > 0)) - break; - - if (patchNumSubbands[numPatches] > 0) { - usb = sb; - msb = sb; - numPatches++; - } else { - msb = kStart; - } - - if (freqMaster[k] - sb < 3) - k = nMaster; - - } while (sb != (kStart + numQMFBands) && numPatches <= MAX_NUM_PATCHES); - - return numPatches; -} - -/************************************************************************************** - * Function: FindFreq - * - * Description: search buffer of unsigned chars for a specific value - * - * Inputs: buffer of elements to search - * number of elements to search - * value to search for - * - * Outputs: none - * - * Return: non-zero if the value is found anywhere in the buffer, zero otherwise - **************************************************************************************/ -static int FindFreq(unsigned char *freq, int nFreq, unsigned char val) -{ - int k; - - for (k = 0; k < nFreq; k++) { - if (freq[k] == val) - return 1; - } - - return 0; -} - -/************************************************************************************** - * Function: RemoveFreq - * - * Description: remove one element from a buffer of unsigned chars - * - * Inputs: buffer of elements - * number of elements - * index of element to remove - * - * Outputs: new buffer of length nFreq-1 - * - * Return: none - **************************************************************************************/ -static void RemoveFreq(unsigned char *freq, int nFreq, int removeIdx) -{ - int k; - - if (removeIdx >= nFreq) - return; - - for (k = removeIdx; k < nFreq - 1; k++) - freq[k] = freq[k+1]; -} - -/************************************************************************************** - * Function: CalcFreqLimiter - * - * Description: calculate limiter frequency table (4.6.18.3.2.3) - * - * Inputs: number of subbands in each patch - * low resolution frequency table - * number of bands in low resolution frequency table - * index of starting QMF subband for SBR (kStart) - * number of limiter bands - * number of patches - * - * Outputs: limiter frequency table - * - * Return: number of bands in limiter frequency table - **************************************************************************************/ -static int CalcFreqLimiter(unsigned char *freqLimiter, unsigned char *patchNumSubbands, unsigned char *freqLow, - int nLow, int kStart, int limiterBands, int numPatches) -{ - int k, bands, nLimiter, nOctaves; - int limBandsPerOctave[3] = {120, 200, 300}; /* [1.2, 2.0, 3.0] * 100 */ - unsigned char patchBorders[MAX_NUM_PATCHES + 1]; - - /* simple case */ - if (limiterBands == 0) { - freqLimiter[0] = freqLow[0] - kStart; - freqLimiter[1] = freqLow[nLow] - kStart; - return 1; - } - - bands = limBandsPerOctave[limiterBands - 1]; - patchBorders[0] = kStart; - - /* from MPEG reference code - slightly different from spec (top border) */ - for (k = 1; k < numPatches; k++) - patchBorders[k] = patchBorders[k-1] + patchNumSubbands[k-1]; - patchBorders[k] = freqLow[nLow]; - - for (k = 0; k <= nLow; k++) - freqLimiter[k] = freqLow[k]; - - for (k = 1; k < numPatches; k++) - freqLimiter[k+nLow] = patchBorders[k]; - - k = 1; - nLimiter = nLow + numPatches - 1; - BubbleSort(freqLimiter, nLimiter + 1); - - while (k <= nLimiter) { - nOctaves = log2Tab[freqLimiter[k]] - log2Tab[freqLimiter[k-1]]; /* Q28 */ - nOctaves = (nOctaves >> 9) * bands; /* Q19, max bands = 300 < 2^9 */ - if (nOctaves < (49 << 19)) { /* compare with 0.49*100, in Q19 */ - if (freqLimiter[k] == freqLimiter[k-1] || FindFreq(patchBorders, numPatches + 1, freqLimiter[k]) == 0) { - RemoveFreq(freqLimiter, nLimiter + 1, k); - nLimiter--; - } else if (FindFreq(patchBorders, numPatches + 1, freqLimiter[k-1]) == 0) { - RemoveFreq(freqLimiter, nLimiter + 1, k-1); - nLimiter--; - } else { - k++; - } - } else { - k++; - } - } - - /* store limiter boundaries as offsets from kStart */ - for (k = 0; k <= nLimiter; k++) - freqLimiter[k] -= kStart; - - return nLimiter; -} - -/************************************************************************************** - * Function: CalcFreqTables - * - * Description: calulate master and derived frequency tables, and patches - * - * Inputs: initialized SBRHeader struct for this SCE/CPE block - * initialized SBRFreq struct for this SCE/CPE block - * sample rate index of output sample rate (after SBR) - * - * Outputs: master and derived frequency tables, and patches - * - * Return: non-zero if error, zero otherwise - **************************************************************************************/ -int CalcFreqTables(SBRHeader *sbrHdr, SBRFreq *sbrFreq, int sampRateIdx) -{ - int k0, k2; - - k0 = k0Tab[sampRateIdx][sbrHdr->startFreq]; - - if (sbrHdr->stopFreq == 14) - k2 = 2*k0; - else if (sbrHdr->stopFreq == 15) - k2 = 3*k0; - else - k2 = k2Tab[sampRateIdx][sbrHdr->stopFreq]; - if (k2 > 64) - k2 = 64; - - /* calculate master frequency table */ - if (sbrHdr->freqScale == 0) - sbrFreq->nMaster = CalcFreqMasterScaleZero(sbrFreq->freqMaster, sbrHdr->alterScale, k0, k2); - else - sbrFreq->nMaster = CalcFreqMaster(sbrFreq->freqMaster, sbrHdr->freqScale, sbrHdr->alterScale, k0, k2); - - /* calculate high frequency table and related parameters */ - sbrFreq->nHigh = CalcFreqHigh(sbrFreq->freqHigh, sbrFreq->freqMaster, sbrFreq->nMaster, sbrHdr->crossOverBand); - sbrFreq->numQMFBands = sbrFreq->freqHigh[sbrFreq->nHigh] - sbrFreq->freqHigh[0]; - sbrFreq->kStart = sbrFreq->freqHigh[0]; - - /* calculate low frequency table */ - sbrFreq->nLow = CalcFreqLow(sbrFreq->freqLow, sbrFreq->freqHigh, sbrFreq->nHigh); - - /* calculate noise floor frequency table */ - sbrFreq->numNoiseFloorBands = CalcFreqNoise(sbrFreq->freqNoise, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, k2, sbrHdr->noiseBands); - - /* calculate limiter table */ - sbrFreq->numPatches = BuildPatches(sbrFreq->patchNumSubbands, sbrFreq->patchStartSubband, sbrFreq->freqMaster, - sbrFreq->nMaster, k0, sbrFreq->kStart, sbrFreq->numQMFBands, sampRateIdx); - sbrFreq->nLimiter = CalcFreqLimiter(sbrFreq->freqLimiter, sbrFreq->patchNumSubbands, sbrFreq->freqLow, sbrFreq->nLow, sbrFreq->kStart, - sbrHdr->limiterBands, sbrFreq->numPatches); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrhfadj.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrhfadj.c deleted file mode 100644 index f16cb07b..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrhfadj.c +++ /dev/null @@ -1,853 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhfadj.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhfadj.c - high frequency adjustment for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/* invBandTab[i] = 1.0 / (i + 1), Q31 */ -static const int invBandTab[64] PROGMEM = { - 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555555, 0x12492492, 0x10000000, - 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba, 0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000, - 0x07878788, 0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216, 0x05555555, - 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58, 0x04444444, 0x04210842, 0x04000000, - 0x03e0f83e, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333, - 0x031f3832, 0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105, 0x02aaaaab, - 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f, 0x025ed098, 0x0253c825, 0x02492492, - 0x023ee090, 0x0234f72c, 0x022b63cc, 0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000, -}; - -/************************************************************************************** - * Function: EstimateEnvelope - * - * Description: estimate power of generated HF QMF bands in one time-domain envelope - * (4.6.18.7.3) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * index of current envelope - * - * Outputs: power of each QMF subband, stored as integer (Q0) * 2^N, N >= 0 - * - * Return: none - **************************************************************************************/ -static void EstimateEnvelope(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int env) -{ - int i, m, iStart, iEnd, xre, xim, nScale, expMax; - int p, n, mStart, mEnd, invFact, t; - int *XBuf; - U64 eCurr; - unsigned char *freqBandTab; - - /* estimate current envelope */ - iStart = sbrGrid->envTimeBorder[env] + HF_ADJ; - iEnd = sbrGrid->envTimeBorder[env+1] + HF_ADJ; - if (sbrGrid->freqRes[env]) { - n = sbrFreq->nHigh; - freqBandTab = sbrFreq->freqHigh; - } else { - n = sbrFreq->nLow; - freqBandTab = sbrFreq->freqLow; - } - - /* ADS should inline MADD64 (smlal) properly, but check to make sure */ - expMax = 0; - if (sbrHdr->interpFreq) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - eCurr.w64 = 0; - XBuf = psi->XBuf[iStart][sbrFreq->kStart + m]; - for (i = iStart; i < iEnd; i++) { - /* scale to int before calculating power (precision not critical, and avoids overflow) */ - xre = (*XBuf) >> FBITS_OUT_QMFA; XBuf += 1; - xim = (*XBuf) >> FBITS_OUT_QMFA; XBuf += (2*64 - 1); - eCurr.w64 = MADD64(eCurr.w64, xre, xre); - eCurr.w64 = MADD64(eCurr.w64, xim, xim); - } - - /* eCurr.w64 is now Q(64 - 2*FBITS_OUT_QMFA) (64-bit word) - * if energy is too big to fit in 32-bit word (> 2^31) scale down by power of 2 - */ - nScale = 0; - if (eCurr.r.hi32) { - nScale = (32 - CLZ(eCurr.r.hi32)) + 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - t |= eCurr.r.hi32 << (32 - nScale); - } else if (eCurr.r.lo32 >> 31) { - nScale = 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - } else { - t = (int)eCurr.r.lo32; - } - - invFact = invBandTab[(iEnd - iStart)-1]; - psi->eCurr[m] = MULSHIFT32(t, invFact); - psi->eCurrExp[m] = nScale + 1; /* +1 for invFact = Q31 */ - if (psi->eCurrExp[m] > expMax) - expMax = psi->eCurrExp[m]; - } - } else { - for (p = 0; p < n; p++) { - mStart = freqBandTab[p]; - mEnd = freqBandTab[p+1]; - eCurr.w64 = 0; - for (i = iStart; i < iEnd; i++) { - XBuf = psi->XBuf[i][mStart]; - for (m = mStart; m < mEnd; m++) { - xre = (*XBuf++) >> FBITS_OUT_QMFA; - xim = (*XBuf++) >> FBITS_OUT_QMFA; - eCurr.w64 = MADD64(eCurr.w64, xre, xre); - eCurr.w64 = MADD64(eCurr.w64, xim, xim); - } - } - - nScale = 0; - if (eCurr.r.hi32) { - nScale = (32 - CLZ(eCurr.r.hi32)) + 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - t |= eCurr.r.hi32 << (32 - nScale); - } else if (eCurr.r.lo32 >> 31) { - nScale = 1; - t = (int)(eCurr.r.lo32 >> nScale); /* logical (unsigned) >> */ - } else { - t = (int)eCurr.r.lo32; - } - - invFact = invBandTab[(iEnd - iStart)-1]; - invFact = MULSHIFT32(invBandTab[(mEnd - mStart)-1], invFact) << 1; - t = MULSHIFT32(t, invFact); - - for (m = mStart; m < mEnd; m++) { - psi->eCurr[m - sbrFreq->kStart] = t; - psi->eCurrExp[m - sbrFreq->kStart] = nScale + 1; /* +1 for invFact = Q31 */ - } - if (psi->eCurrExp[mStart - sbrFreq->kStart] > expMax) - expMax = psi->eCurrExp[mStart - sbrFreq->kStart]; - } - } - psi->eCurrExpMax = expMax; -} - -/************************************************************************************** - * Function: GetSMapped - * - * Description: calculate SMapped (4.6.18.7.2) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current envelope - * index of current QMF band - * la flag for this envelope - * - * Outputs: none - * - * Return: 1 if a sinusoid is present in this band, 0 if not - **************************************************************************************/ -static int GetSMapped(SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int band, int la) -{ - int bandStart, bandEnd, oddFlag, r; - - if (sbrGrid->freqRes[env]) { - /* high resolution */ - bandStart = band; - bandEnd = band+1; - } else { - /* low resolution (see CalcFreqLow() for mapping) */ - oddFlag = sbrFreq->nHigh & 0x01; - bandStart = (band > 0 ? 2*band - oddFlag : 0); /* starting index for freqLow[band] */ - bandEnd = 2*(band+1) - oddFlag; /* ending index for freqLow[band+1] */ - } - - /* sMapped = 1 if sIndexMapped == 1 for any frequency in this band */ - for (band = bandStart; band < bandEnd; band++) { - if (sbrChan->addHarmonic[1][band]) { - r = ((sbrFreq->freqHigh[band+1] + sbrFreq->freqHigh[band]) >> 1); - if (env >= la || sbrChan->addHarmonic[0][r] == 1) - return 1; - } - } - return 0; -} - -#define GBOOST_MAX 0x2830afd3 /* Q28, 1.584893192 squared */ -#define ACC_SCALE 6 - -/* squared version of table in 4.6.18.7.5 */ -static const int limGainTab[4] PROGMEM = {0x20138ca7, 0x40000000, 0x7fb27dce, 0x80000000}; /* Q30 (0x80000000 = sentinel for GMAX) */ - -/************************************************************************************** - * Function: CalcMaxGain - * - * Description: calculate max gain in one limiter band (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * index of current limiter band - * number of fraction bits in dequantized envelope - * (max = Q(FBITS_OUT_DQ_ENV - 6) = Q23, can go negative) - * - * Outputs: updated gainMax, gainMaxFBits, and sumEOrigMapped in PSInfoSBR struct - * - * Return: none - **************************************************************************************/ -static void CalcMaxGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, int ch, int env, int lim, int fbitsDQ) -{ - int m, mStart, mEnd, q, z, r; - int sumEOrigMapped, sumECurr, gainMax, eOMGainMax, envBand; - unsigned char eCurrExpMax; - unsigned char *freqBandTab; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow); - - /* calculate max gain to apply to signal in this limiter band */ - sumECurr = 0; - sumEOrigMapped = 0; - eCurrExpMax = psi->eCurrExpMax; - eOMGainMax = psi->eOMGainMax; - envBand = psi->envBand; - for (m = mStart; m < mEnd; m++) { - /* map current QMF band to appropriate envelope band */ - if (m == freqBandTab[envBand + 1] - sbrFreq->kStart) { - envBand++; - eOMGainMax = psi->envDataDequant[ch][env][envBand] >> ACC_SCALE; /* summing max 48 bands */ - } - sumEOrigMapped += eOMGainMax; - - /* easy test for overflow on ARM */ - sumECurr += (psi->eCurr[m] >> (eCurrExpMax - psi->eCurrExp[m])); - if (sumECurr >> 30) { - sumECurr >>= 1; - eCurrExpMax++; - } - } - psi->eOMGainMax = eOMGainMax; - psi->envBand = envBand; - - psi->gainMaxFBits = 30; /* Q30 tables */ - if (sumECurr == 0) { - /* any non-zero numerator * 1/EPS_0 is > G_MAX */ - gainMax = (sumEOrigMapped == 0 ? (int)limGainTab[sbrHdr->limiterGains] : (int)0x80000000); - } else if (sumEOrigMapped == 0) { - /* 1/(any non-zero denominator) * EPS_0 * limGainTab[x] is appx. 0 */ - gainMax = 0; - } else { - /* sumEOrigMapped = Q(fbitsDQ - ACC_SCALE), sumECurr = Q(-eCurrExpMax) */ - gainMax = limGainTab[sbrHdr->limiterGains]; - if (sbrHdr->limiterGains != 3) { - q = MULSHIFT32(sumEOrigMapped, gainMax); /* Q(fbitsDQ - ACC_SCALE - 2), gainMax = Q30 */ - z = CLZ(sumECurr) - 1; - r = InvRNormalized(sumECurr << z); /* in = Q(z - eCurrExpMax), out = Q(29 + 31 - z + eCurrExpMax) */ - gainMax = MULSHIFT32(q, r); /* Q(29 + 31 - z + eCurrExpMax + fbitsDQ - ACC_SCALE - 2 - 32) */ - psi->gainMaxFBits = 26 - z + eCurrExpMax + fbitsDQ - ACC_SCALE; - } - } - psi->sumEOrigMapped = sumEOrigMapped; - psi->gainMax = gainMax; -} - -/************************************************************************************** - * Function: CalcNoiseDivFactors - * - * Description: calculate 1/(1+Q) and Q/(1+Q) (4.6.18.7.4; 4.6.18.7.5) - * - * Inputs: dequantized noise floor scalefactor - * - * Outputs: 1/(1+Q) and Q/(1+Q), format = Q31 - * - * Return: none - **************************************************************************************/ -static void CalcNoiseDivFactors(int q, int *qp1Inv, int *qqp1Inv) -{ - int z, qp1, t, s; - - /* 1 + Q_orig */ - qp1 = (q >> 1); - qp1 += (1 << (FBITS_OUT_DQ_NOISE - 1)); /* >> 1 to avoid overflow when adding 1.0 */ - z = CLZ(qp1) - 1; /* z <= 31 - FBITS_OUT_DQ_NOISE */ - qp1 <<= z; /* Q(FBITS_OUT_DQ_NOISE + z) = Q31 * 2^-(31 - (FBITS_OUT_DQ_NOISE + z)) */ - t = InvRNormalized(qp1) << 1; /* Q30 * 2^(31 - (FBITS_OUT_DQ_NOISE + z)), guaranteed not to overflow */ - - /* normalize to Q31 */ - s = (31 - (FBITS_OUT_DQ_NOISE - 1) - z - 1); /* clearly z >= 0, z <= (30 - (FBITS_OUT_DQ_NOISE - 1)) */ - *qp1Inv = (t >> s); /* s = [0, 31 - FBITS_OUT_DQ_NOISE] */ - *qqp1Inv = MULSHIFT32(t, q) << (32 - FBITS_OUT_DQ_NOISE - s); -} - -/************************************************************************************** - * Function: CalcComponentGains - * - * Description: calculate gain of envelope, sinusoids, and noise in one limiter band - * (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * index of current limiter band - * number of fraction bits in dequantized envelope - * - * Outputs: gains for envelope, sinusoids and noise - * number of fraction bits for envelope gain - * sum of the total gain for each component in this band - * other updated state variables - * - * Return: none - **************************************************************************************/ -static void CalcComponentGains(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env, int lim, int fbitsDQ) -{ - int d, m, mStart, mEnd, q, qm, noiseFloor, sIndexMapped; - int shift, eCurr, maxFlag, gainMax, gainMaxFBits; - int gain, sm, z, r, fbitsGain, gainScale; - unsigned char *freqBandTab; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - - gainMax = psi->gainMax; - gainMaxFBits = psi->gainMaxFBits; - - d = (env == psi->la || env == sbrChan->laPrev ? 0 : 1); - freqBandTab = (sbrGrid->freqRes[env] ? sbrFreq->freqHigh : sbrFreq->freqLow); - - /* figure out which noise floor this envelope is in (only 1 or 2 noise floors allowed) */ - noiseFloor = 0; - if (sbrGrid->numNoiseFloors == 2 && sbrGrid->noiseTimeBorder[1] <= sbrGrid->envTimeBorder[env]) - noiseFloor++; - - psi->sumECurrGLim = 0; - psi->sumSM = 0; - psi->sumQM = 0; - /* calculate energy of noise to add in this limiter band */ - for (m = mStart; m < mEnd; m++) { - if (m == sbrFreq->freqNoise[psi->noiseFloorBand + 1] - sbrFreq->kStart) { - /* map current QMF band to appropriate noise floor band (NOTE: freqLimiter[0] == freqLow[0] = freqHigh[0]) */ - psi->noiseFloorBand++; - CalcNoiseDivFactors(psi->noiseDataDequant[ch][noiseFloor][psi->noiseFloorBand], &(psi->qp1Inv), &(psi->qqp1Inv)); - } - if (m == sbrFreq->freqHigh[psi->highBand + 1] - sbrFreq->kStart) - psi->highBand++; - if (m == freqBandTab[psi->sBand + 1] - sbrFreq->kStart) { - psi->sBand++; - psi->sMapped = GetSMapped(sbrGrid, sbrFreq, sbrChan, env, psi->sBand, psi->la); - } - - /* get sIndexMapped for this QMF subband */ - sIndexMapped = 0; - r = ((sbrFreq->freqHigh[psi->highBand+1] + sbrFreq->freqHigh[psi->highBand]) >> 1); - if (m + sbrFreq->kStart == r) { - /* r = center frequency, deltaStep = (env >= la || sIndexMapped'(r, numEnv'-1) == 1) */ - if (env >= psi->la || sbrChan->addHarmonic[0][r] == 1) - sIndexMapped = sbrChan->addHarmonic[1][psi->highBand]; - } - - /* save sine flags from last envelope in this frame: - * addHarmonic[0][0...63] = saved sine present flag from previous frame, for each QMF subband - * addHarmonic[1][0...nHigh-1] = addHarmonic bit from current frame, for each high-res frequency band - * from MPEG reference code - slightly different from spec - * (sIndexMapped'(m,LE'-1) can still be 0 when numEnv == psi->la) - */ - if (env == sbrGrid->numEnv - 1) { - if (m + sbrFreq->kStart == r) - sbrChan->addHarmonic[0][m + sbrFreq->kStart] = sbrChan->addHarmonic[1][psi->highBand]; - else - sbrChan->addHarmonic[0][m + sbrFreq->kStart] = 0; - } - - gain = psi->envDataDequant[ch][env][psi->sBand]; - qm = MULSHIFT32(gain, psi->qqp1Inv) << 1; - sm = (sIndexMapped ? MULSHIFT32(gain, psi->qp1Inv) << 1 : 0); - - /* three cases: (sMapped == 0 && delta == 1), (sMapped == 0 && delta == 0), (sMapped == 1) */ - if (d == 1 && psi->sMapped == 0) - gain = MULSHIFT32(psi->qp1Inv, gain) << 1; - else if (psi->sMapped != 0) - gain = MULSHIFT32(psi->qqp1Inv, gain) << 1; - - /* gain, qm, sm = Q(fbitsDQ), gainMax = Q(fbitsGainMax) */ - eCurr = psi->eCurr[m]; - if (eCurr) { - z = CLZ(eCurr) - 1; - r = InvRNormalized(eCurr << z); /* in = Q(z - eCurrExp), out = Q(29 + 31 - z + eCurrExp) */ - gainScale = MULSHIFT32(gain, r); /* out = Q(29 + 31 - z + eCurrExp + fbitsDQ - 32) */ - fbitsGain = 29 + 31 - z + psi->eCurrExp[m] + fbitsDQ - 32; - } else { - /* if eCurr == 0, then gain is unchanged (divide by EPS = 1) */ - gainScale = gain; - fbitsGain = fbitsDQ; - } - - /* see if gain for this band exceeds max gain */ - maxFlag = 0; - if (gainMax != (int)0x80000000) { - if (fbitsGain >= gainMaxFBits) { - shift = MIN(fbitsGain - gainMaxFBits, 31); - maxFlag = ((gainScale >> shift) > gainMax ? 1 : 0); - } else { - shift = MIN(gainMaxFBits - fbitsGain, 31); - maxFlag = (gainScale > (gainMax >> shift) ? 1 : 0); - } - } - - if (maxFlag) { - /* gainScale > gainMax, calculate ratio with 32/16 division */ - q = 0; - r = gainScale; /* guaranteed > 0, else maxFlag could not have been set */ - z = CLZ(r); - if (z < 16) { - q = 16 - z; - r >>= q; /* out = Q(fbitsGain - q) */ - } - - z = CLZ(gainMax) - 1; - r = (gainMax << z) / r; /* out = Q((fbitsGainMax + z) - (fbitsGain - q)) */ - q = (gainMaxFBits + z) - (fbitsGain - q); /* r = Q(q) */ - if (q > 30) { - r >>= MIN(q - 30, 31); - } else { - z = MIN(30 - q, 30); - CLIP_2N_SHIFT30(r, z); /* let r = Q30 since range = [0.0, 1.0) (clip to 0x3fffffff = 0.99999) */ - } - - qm = MULSHIFT32(qm, r) << 2; - gain = MULSHIFT32(gain, r) << 2; - psi->gLimBuf[m] = gainMax; - psi->gLimFbits[m] = gainMaxFBits; - } else { - psi->gLimBuf[m] = gainScale; - psi->gLimFbits[m] = fbitsGain; - } - - /* sumSM, sumQM, sumECurrGLim = Q(fbitsDQ - ACC_SCALE) */ - psi->smBuf[m] = sm; - psi->sumSM += (sm >> ACC_SCALE); - - psi->qmLimBuf[m] = qm; - if (env != psi->la && env != sbrChan->laPrev && sm == 0) - psi->sumQM += (qm >> ACC_SCALE); - - /* eCurr * gain^2 same as gain^2, before division by eCurr - * (but note that gain != 0 even if eCurr == 0, since it's divided by eps) - */ - if (eCurr) - psi->sumECurrGLim += (gain >> ACC_SCALE); - } -} - -/************************************************************************************** - * Function: ApplyBoost - * - * Description: calculate and apply boost factor for envelope, sinusoids, and noise - * in this limiter band (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRFreq struct for this SCE/CPE block - * index of current limiter band - * number of fraction bits in dequantized envelope - * - * Outputs: envelope gain, sinusoids and noise after scaling by gBoost - * format = Q(FBITS_GLIM_BOOST) for envelope gain, - * = Q(FBITS_QLIM_BOOST) for noise - * = Q(FBITS_OUT_QMFA) for sinusoids - * - * Return: none - * - * Notes: after scaling, each component has at least 1 GB - **************************************************************************************/ -static void ApplyBoost(PSInfoSBR *psi, SBRFreq *sbrFreq, int lim, int fbitsDQ) -{ - int m, mStart, mEnd, q, z, r; - int sumEOrigMapped, gBoost; - - mStart = sbrFreq->freqLimiter[lim]; /* these are offsets from kStart */ - mEnd = sbrFreq->freqLimiter[lim + 1]; - - sumEOrigMapped = psi->sumEOrigMapped >> 1; - r = (psi->sumECurrGLim >> 1) + (psi->sumSM >> 1) + (psi->sumQM >> 1); /* 1 GB fine (sm and qm are mutually exclusive in acc) */ - if (r < (1 << (31-28))) { - /* any non-zero numerator * 1/EPS_0 is > GBOOST_MAX - * round very small r to zero to avoid scaling problems - */ - gBoost = (sumEOrigMapped == 0 ? (1 << 28) : GBOOST_MAX); - z = 0; - } else if (sumEOrigMapped == 0) { - /* 1/(any non-zero denominator) * EPS_0 is appx. 0 */ - gBoost = 0; - z = 0; - } else { - /* numerator (sumEOrigMapped) and denominator (r) have same Q format (before << z) */ - z = CLZ(r) - 1; /* z = [0, 27] */ - r = InvRNormalized(r << z); - gBoost = MULSHIFT32(sumEOrigMapped, r); - } - - /* gBoost = Q(28 - z) */ - if (gBoost > (GBOOST_MAX >> z)) { - gBoost = GBOOST_MAX; - z = 0; - } - gBoost <<= z; /* gBoost = Q28, minimum 1 GB */ - - /* convert gain, noise, sinusoids to fixed Q format, clipping if necessary - * (rare, usually only happens at very low bitrates, introduces slight - * distortion into final HF mapping, but should be inaudible) - */ - for (m = mStart; m < mEnd; m++) { - /* let gLimBoost = Q24, since in practice the max values are usually 16 to 20 - * unless limiterGains == 3 (limiter off) and eCurr ~= 0 (i.e. huge gain, but only - * because the envelope has 0 power anyway) - */ - q = MULSHIFT32(psi->gLimBuf[m], gBoost) << 2; /* Q(gLimFbits) * Q(28) --> Q(gLimFbits[m]-2) */ - r = SqrtFix(q, psi->gLimFbits[m] - 2, &z); - z -= FBITS_GLIM_BOOST; - if (z >= 0) { - psi->gLimBoost[m] = r >> MIN(z, 31); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->gLimBoost[m] = r; - } - - q = MULSHIFT32(psi->qmLimBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */ - r = SqrtFix(q, fbitsDQ - 2, &z); - z -= FBITS_QLIM_BOOST; /* << by 14, since integer sqrt of x < 2^16, and we want to leave 1 GB */ - if (z >= 0) { - psi->qmLimBoost[m] = r >> MIN(31, z); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->qmLimBoost[m] = r; - } - - q = MULSHIFT32(psi->smBuf[m], gBoost) << 2; /* Q(fbitsDQ) * Q(28) --> Q(fbitsDQ-2) */ - r = SqrtFix(q, fbitsDQ - 2, &z); - z -= FBITS_OUT_QMFA; /* justify for adding to signal (xBuf) later */ - if (z >= 0) { - psi->smBoost[m] = r >> MIN(31, z); - } else { - z = MIN(30, -z); - CLIP_2N_SHIFT30(r, z); - psi->smBoost[m] = r; - } - } -} - -/************************************************************************************** - * Function: CalcGain - * - * Description: calculate and apply proper gain to HF components in one envelope - * (4.6.18.7.5) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * index of current envelope - * - * Outputs: envelope gain, sinusoids and noise after scaling - * - * Return: none - **************************************************************************************/ -static void CalcGain(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch, int env) -{ - int lim, fbitsDQ; - - /* initialize to -1 so that mapping limiter bands to env/noise bands works right on first pass */ - psi->envBand = -1; - psi->noiseFloorBand = -1; - psi->sBand = -1; - psi->highBand = -1; - - fbitsDQ = (FBITS_OUT_DQ_ENV - psi->envDataDequantScale[ch][env]); /* Q(29 - optional scalefactor) */ - for (lim = 0; lim < sbrFreq->nLimiter; lim++) { - /* the QMF bands are divided into lim regions (consecutive, non-overlapping) */ - CalcMaxGain(psi, sbrHdr, sbrGrid, sbrFreq, ch, env, lim, fbitsDQ); - CalcComponentGains(psi, sbrGrid, sbrFreq, sbrChan, ch, env, lim, fbitsDQ); - ApplyBoost(psi, sbrFreq, lim, fbitsDQ); - } -} - -/* hSmooth table from 4.7.18.7.6, format = Q31 */ -static const int hSmoothCoef[MAX_NUM_SMOOTH_COEFS] PROGMEM = { - 0x2aaaaaab, 0x2697a512, 0x1becfa68, 0x0ebdb043, 0x04130598, -}; - -/************************************************************************************** - * Function: MapHF - * - * Description: map HF components to proper QMF bands, with optional gain smoothing - * filter (4.6.18.7.6) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current envelope - * reset flag (can be non-zero for first envelope only) - * - * Outputs: complete reconstructed subband QMF samples for this envelope - * - * Return: none - * - * Notes: ensures that output has >= MIN_GBITS_IN_QMFS guard bits, - * so it's not necessary to check anything in the synth QMF - **************************************************************************************/ -static void MapHF(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int env, int hfReset) -{ - int noiseTabIndex, sinIndex, gainNoiseIndex, hSL; - int i, iStart, iEnd, m, idx, j, s, n, smre, smim; - int gFilt, qFilt, xre, xim, gbMask, gbIdx; - int *XBuf; - - noiseTabIndex = sbrChan->noiseTabIndex; - sinIndex = sbrChan->sinIndex; - gainNoiseIndex = sbrChan->gainNoiseIndex; /* oldest entries in filter delay buffer */ - - if (hfReset) - noiseTabIndex = 2; /* starts at 1, double since complex */ - hSL = (sbrHdr->smoothMode ? 0 : 4); - - if (hfReset) { - for (i = 0; i < hSL; i++) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m]; - sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m]; - } - gainNoiseIndex++; - if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) - gainNoiseIndex = 0; - } - ASSERT(env == 0); /* should only be reset when env == 0 */ - } - - iStart = sbrGrid->envTimeBorder[env]; - iEnd = sbrGrid->envTimeBorder[env+1]; - for (i = iStart; i < iEnd; i++) { - /* save new values in temp buffers (delay) - * we only store MAX_NUM_SMOOTH_COEFS most recent values, - * so don't keep storing the same value over and over - */ - if (i - iStart < MAX_NUM_SMOOTH_COEFS) { - for (m = 0; m < sbrFreq->numQMFBands; m++) { - sbrChan->gTemp[gainNoiseIndex][m] = psi->gLimBoost[m]; - sbrChan->qTemp[gainNoiseIndex][m] = psi->qmLimBoost[m]; - } - } - - /* see 4.6.18.7.6 */ - XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart]; - gbMask = 0; - for (m = 0; m < sbrFreq->numQMFBands; m++) { - if (env == psi->la || env == sbrChan->laPrev) { - /* no smoothing filter for gain, and qFilt = 0 (only need to do once) */ - if (i == iStart) { - psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m]; - psi->qFiltLast[m] = 0; - } - } else if (hSL == 0) { - /* no smoothing filter for gain, (only need to do once) */ - if (i == iStart) { - psi->gFiltLast[m] = sbrChan->gTemp[gainNoiseIndex][m]; - psi->qFiltLast[m] = sbrChan->qTemp[gainNoiseIndex][m]; - } - } else { - /* apply smoothing filter to gain and noise (after MAX_NUM_SMOOTH_COEFS, it's always the same) */ - if (i - iStart < MAX_NUM_SMOOTH_COEFS) { - gFilt = 0; - qFilt = 0; - idx = gainNoiseIndex; - for (j = 0; j < MAX_NUM_SMOOTH_COEFS; j++) { - /* sum(abs(hSmoothCoef[j])) for all j < 1.0 */ - gFilt += MULSHIFT32(sbrChan->gTemp[idx][m], hSmoothCoef[j]); - qFilt += MULSHIFT32(sbrChan->qTemp[idx][m], hSmoothCoef[j]); - idx--; - if (idx < 0) - idx += MAX_NUM_SMOOTH_COEFS; - } - psi->gFiltLast[m] = gFilt << 1; /* restore to Q(FBITS_GLIM_BOOST) (gain of filter < 1.0, so no overflow) */ - psi->qFiltLast[m] = qFilt << 1; /* restore to Q(FBITS_QLIM_BOOST) */ - } - } - - if (psi->smBoost[m] != 0) { - /* add scaled signal and sinusoid, don't add noise (qFilt = 0) */ - smre = psi->smBoost[m]; - smim = smre; - - /* sinIndex: [0] xre += sm [1] xim += sm*s [2] xre -= sm [3] xim -= sm*s */ - s = (sinIndex >> 1); /* if 2 or 3, flip sign to subtract sm */ - s <<= 31; - smre ^= (s >> 31); - smre -= (s >> 31); - s ^= ((m + sbrFreq->kStart) << 31); - smim ^= (s >> 31); - smim -= (s >> 31); - - /* if sinIndex == 0 or 2, smim = 0; if sinIndex == 1 or 3, smre = 0 */ - s = sinIndex << 31; - smim &= (s >> 31); - s ^= 0x80000000; - smre &= (s >> 31); - - noiseTabIndex += 2; /* noise filtered by 0, but still need to bump index */ - } else { - /* add scaled signal and scaled noise */ - qFilt = psi->qFiltLast[m]; - n = noiseTab[noiseTabIndex++]; - smre = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA); - - n = noiseTab[noiseTabIndex++]; - smim = MULSHIFT32(n, qFilt) >> (FBITS_QLIM_BOOST - 1 - FBITS_OUT_QMFA); - } - noiseTabIndex &= 1023; /* 512 complex numbers */ - - gFilt = psi->gFiltLast[m]; - xre = MULSHIFT32(gFilt, XBuf[0]); - xim = MULSHIFT32(gFilt, XBuf[1]); - CLIP_2N_SHIFT30(xre, 32 - FBITS_GLIM_BOOST); - CLIP_2N_SHIFT30(xim, 32 - FBITS_GLIM_BOOST); - - xre += smre; *XBuf++ = xre; - xim += smim; *XBuf++ = xim; - - gbMask |= FASTABS(xre); - gbMask |= FASTABS(xim); - } - /* update circular buffer index */ - gainNoiseIndex++; - if (gainNoiseIndex == MAX_NUM_SMOOTH_COEFS) - gainNoiseIndex = 0; - - sinIndex++; - sinIndex &= 3; - - /* ensure MIN_GBITS_IN_QMFS guard bits in output - * almost never occurs in practice, but checking here makes synth QMF logic very simple - */ - if (gbMask >> (31 - MIN_GBITS_IN_QMFS)) { - XBuf = psi->XBuf[i + HF_ADJ][sbrFreq->kStart]; - for (m = 0; m < sbrFreq->numQMFBands; m++) { - xre = XBuf[0]; xim = XBuf[1]; - CLIP_2N(xre, (31 - MIN_GBITS_IN_QMFS)); - CLIP_2N(xim, (31 - MIN_GBITS_IN_QMFS)); - *XBuf++ = xre; *XBuf++ = xim; - } - CLIP_2N(gbMask, (31 - MIN_GBITS_IN_QMFS)); - } - gbIdx = ((i + HF_ADJ) >> 5) & 0x01; - sbrChan->gbMask[gbIdx] |= gbMask; - } - sbrChan->noiseTabIndex = noiseTabIndex; - sbrChan->sinIndex = sinIndex; - sbrChan->gainNoiseIndex = gainNoiseIndex; -} - -/************************************************************************************** - * Function: AdjustHighFreq - * - * Description: adjust high frequencies and add noise and sinusoids (4.6.18.7) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRHeader struct for this SCE/CPE block - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: complete reconstructed subband QMF samples for this channel - * - * Return: none - **************************************************************************************/ -void AdjustHighFreq(PSInfoSBR *psi, SBRHeader *sbrHdr, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int i, env, hfReset; - unsigned char frameClass, pointer; - - frameClass = sbrGrid->frameClass; - pointer = sbrGrid->pointer; - - /* derive la from table 4.159 */ - if ((frameClass == SBR_GRID_FIXVAR || frameClass == SBR_GRID_VARVAR) && pointer > 0) - psi->la = sbrGrid->numEnv + 1 - pointer; - else if (frameClass == SBR_GRID_VARFIX && pointer > 1) - psi->la = pointer - 1; - else - psi->la = -1; - - /* for each envelope, estimate gain and adjust SBR QMF bands */ - hfReset = sbrChan->reset; - for (env = 0; env < sbrGrid->numEnv; env++) { - EstimateEnvelope(psi, sbrHdr, sbrGrid, sbrFreq, env); - CalcGain(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, ch, env); - MapHF(psi, sbrHdr, sbrGrid, sbrFreq, sbrChan, env, hfReset); - hfReset = 0; /* only set for first envelope after header reset */ - } - - /* set saved sine flags to 0 for QMF bands outside of current frequency range */ - for (i = 0; i < sbrFreq->freqLimiter[0] + sbrFreq->kStart; i++) - sbrChan->addHarmonic[0][i] = 0; - for (i = sbrFreq->freqLimiter[sbrFreq->nLimiter] + sbrFreq->kStart; i < 64; i++) - sbrChan->addHarmonic[0][i] = 0; - sbrChan->addHarmonicFlag[0] = sbrChan->addHarmonicFlag[1]; - - /* save la for next frame */ - if (psi->la == sbrGrid->numEnv) - sbrChan->laPrev = 0; - else - sbrChan->laPrev = -1; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrhfgen.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrhfgen.c deleted file mode 100644 index e5f27eb6..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrhfgen.c +++ /dev/null @@ -1,616 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhfgen.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhfgen.c - high frequency generation for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define FBITS_LPCOEFS 29 /* Q29 for range of (-4, 4) */ -#define MAG_16 (16 * (1 << (32 - (2*(32-FBITS_LPCOEFS))))) /* i.e. 16 in Q26 format */ -#define RELAX_COEF 0x7ffff79c /* 1.0 / (1.0 + 1e-6), Q31 */ - -/* newBWTab[prev invfMode][curr invfMode], format = Q31 (table 4.158) - * sample file which uses all of these: al_sbr_sr_64_2_fsaac32.aac - */ -static const int newBWTab[4][4] PROGMEM = { - {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7}, - {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7}, - {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, - {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, -}; - -/************************************************************************************** - * Function: CVKernel1 - * - * Description: kernel of covariance matrix calculation for p01, p11, p12, p22 - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: 64-bit accumulators for p01re, p01im, p12re, p12im, p11re, p22re - * stored in accBuf - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrcov.s when building for ARM! - **************************************************************************************/ -#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__)) -#ifdef __cplusplus -extern "C" -#endif -void CVKernel1(int *XBuf, int *accBuf); -#else -void CVKernel1(int *XBuf, int *accBuf) -{ - U64 p01re, p01im, p12re, p12im, p11re, p22re; - int n, x0re, x0im, x1re, x1im; - - x0re = XBuf[0]; - x0im = XBuf[1]; - XBuf += (2*64); - x1re = XBuf[0]; - x1im = XBuf[1]; - XBuf += (2*64); - - p01re.w64 = p01im.w64 = 0; - p12re.w64 = p12im.w64 = 0; - p11re.w64 = 0; - p22re.w64 = 0; - - p12re.w64 = MADD64(p12re.w64, x1re, x0re); - p12re.w64 = MADD64(p12re.w64, x1im, x0im); - p12im.w64 = MADD64(p12im.w64, x0re, x1im); - p12im.w64 = MADD64(p12im.w64, -x0im, x1re); - p22re.w64 = MADD64(p22re.w64, x0re, x0re); - p22re.w64 = MADD64(p22re.w64, x0im, x0im); - for (n = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6); n != 0; n--) { - /* 4 input, 3*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */ - x0re = x1re; - x0im = x1im; - x1re = XBuf[0]; - x1im = XBuf[1]; - - p01re.w64 = MADD64(p01re.w64, x1re, x0re); - p01re.w64 = MADD64(p01re.w64, x1im, x0im); - p01im.w64 = MADD64(p01im.w64, x0re, x1im); - p01im.w64 = MADD64(p01im.w64, -x0im, x1re); - p11re.w64 = MADD64(p11re.w64, x0re, x0re); - p11re.w64 = MADD64(p11re.w64, x0im, x0im); - - XBuf += (2*64); - } - /* these can be derived by slight changes to account for boundary conditions */ - p12re.w64 += p01re.w64; - p12re.w64 = MADD64(p12re.w64, x1re, -x0re); - p12re.w64 = MADD64(p12re.w64, x1im, -x0im); - p12im.w64 += p01im.w64; - p12im.w64 = MADD64(p12im.w64, x0re, -x1im); - p12im.w64 = MADD64(p12im.w64, x0im, x1re); - p22re.w64 += p11re.w64; - p22re.w64 = MADD64(p22re.w64, x0re, -x0re); - p22re.w64 = MADD64(p22re.w64, x0im, -x0im); - - accBuf[0] = p01re.r.lo32; accBuf[1] = p01re.r.hi32; - accBuf[2] = p01im.r.lo32; accBuf[3] = p01im.r.hi32; - accBuf[4] = p11re.r.lo32; accBuf[5] = p11re.r.hi32; - accBuf[6] = p12re.r.lo32; accBuf[7] = p12re.r.hi32; - accBuf[8] = p12im.r.lo32; accBuf[9] = p12im.r.hi32; - accBuf[10] = p22re.r.lo32; accBuf[11] = p22re.r.hi32; -} -#endif - -/************************************************************************************** - * Function: CalcCovariance1 - * - * Description: calculate covariance matrix for p01, p12, p11, p22 (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index 0, - * freq index = patch subband - * - * Outputs: complex covariance elements p01re, p01im, p12re, p12im, p11re, p22re - * (p11im = p22im = 0) - * format = integer (Q0) * 2^N, with scalefactor N >= 0 - * - * Return: scalefactor N - * - * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits) - **************************************************************************************/ -static int CalcCovariance1(int *XBuf, int *p01reN, int *p01imN, int *p12reN, int *p12imN, int *p11reN, int *p22reN) -{ - int accBuf[2*6]; - int n, z, s, loShift, hiShift, gbMask; - U64 p01re, p01im, p12re, p12im, p11re, p22re; - - CVKernel1(XBuf, accBuf); - p01re.r.lo32 = accBuf[0]; p01re.r.hi32 = accBuf[1]; - p01im.r.lo32 = accBuf[2]; p01im.r.hi32 = accBuf[3]; - p11re.r.lo32 = accBuf[4]; p11re.r.hi32 = accBuf[5]; - p12re.r.lo32 = accBuf[6]; p12re.r.hi32 = accBuf[7]; - p12im.r.lo32 = accBuf[8]; p12im.r.hi32 = accBuf[9]; - p22re.r.lo32 = accBuf[10]; p22re.r.hi32 = accBuf[11]; - - /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits - * want to scale them down to integers (32-bit signed, Q0) - * with scale factor of 2^n, n >= 0 - * leave 2 GB's for calculating determinant, so take top 30 non-zero bits - */ - gbMask = ((p01re.r.hi32) ^ (p01re.r.hi32 >> 31)) | ((p01im.r.hi32) ^ (p01im.r.hi32 >> 31)); - gbMask |= ((p12re.r.hi32) ^ (p12re.r.hi32 >> 31)) | ((p12im.r.hi32) ^ (p12im.r.hi32 >> 31)); - gbMask |= ((p11re.r.hi32) ^ (p11re.r.hi32 >> 31)) | ((p22re.r.hi32) ^ (p22re.r.hi32 >> 31)); - if (gbMask == 0) { - s = p01re.r.hi32 >> 31; gbMask = (p01re.r.lo32 ^ s) - s; - s = p01im.r.hi32 >> 31; gbMask |= (p01im.r.lo32 ^ s) - s; - s = p12re.r.hi32 >> 31; gbMask |= (p12re.r.lo32 ^ s) - s; - s = p12im.r.hi32 >> 31; gbMask |= (p12im.r.lo32 ^ s) - s; - s = p11re.r.hi32 >> 31; gbMask |= (p11re.r.lo32 ^ s) - s; - s = p22re.r.hi32 >> 31; gbMask |= (p22re.r.lo32 ^ s) - s; - z = 32 + CLZ(gbMask); - } else { - gbMask = FASTABS(p01re.r.hi32) | FASTABS(p01im.r.hi32); - gbMask |= FASTABS(p12re.r.hi32) | FASTABS(p12im.r.hi32); - gbMask |= FASTABS(p11re.r.hi32) | FASTABS(p22re.r.hi32); - z = CLZ(gbMask); - } - - n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */ - if (n <= 30) { - loShift = (30 - n); - *p01reN = p01re.r.lo32 << loShift; *p01imN = p01im.r.lo32 << loShift; - *p12reN = p12re.r.lo32 << loShift; *p12imN = p12im.r.lo32 << loShift; - *p11reN = p11re.r.lo32 << loShift; *p22reN = p22re.r.lo32 << loShift; - return -(loShift + 2*FBITS_OUT_QMFA); - } else if (n < 32 + 30) { - loShift = (n - 30); - hiShift = 32 - loShift; - *p01reN = (p01re.r.hi32 << hiShift) | (p01re.r.lo32 >> loShift); - *p01imN = (p01im.r.hi32 << hiShift) | (p01im.r.lo32 >> loShift); - *p12reN = (p12re.r.hi32 << hiShift) | (p12re.r.lo32 >> loShift); - *p12imN = (p12im.r.hi32 << hiShift) | (p12im.r.lo32 >> loShift); - *p11reN = (p11re.r.hi32 << hiShift) | (p11re.r.lo32 >> loShift); - *p22reN = (p22re.r.hi32 << hiShift) | (p22re.r.lo32 >> loShift); - return (loShift - 2*FBITS_OUT_QMFA); - } else { - hiShift = n - (32 + 30); - *p01reN = p01re.r.hi32 >> hiShift; *p01imN = p01im.r.hi32 >> hiShift; - *p12reN = p12re.r.hi32 >> hiShift; *p12imN = p12im.r.hi32 >> hiShift; - *p11reN = p11re.r.hi32 >> hiShift; *p22reN = p22re.r.hi32 >> hiShift; - return (32 - 2*FBITS_OUT_QMFA - hiShift); - } - - return 0; -} - -/************************************************************************************** - * Function: CVKernel2 - * - * Description: kernel of covariance matrix calculation for p02 - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: 64-bit accumulators for p02re, p02im stored in accBuf - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrcov.s when building for ARM! - **************************************************************************************/ -#if (defined (XXXX__arm) && defined (__ARMCC_VERSION)) || (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) || (defined(__GNUC__) && defined(XXXX__arm__)) -#ifdef __cplusplus -extern "C" -#endif -void CVKernel2(int *XBuf, int *accBuf); -#else -void CVKernel2(int *XBuf, int *accBuf) -{ - U64 p02re, p02im; - int n, x0re, x0im, x1re, x1im, x2re, x2im; - - p02re.w64 = p02im.w64 = 0; - - x0re = XBuf[0]; - x0im = XBuf[1]; - XBuf += (2*64); - x1re = XBuf[0]; - x1im = XBuf[1]; - XBuf += (2*64); - - for (n = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6); n != 0; n--) { - /* 6 input, 2*2 acc, 1 ptr, 1 loop counter = 12 registers (use same for x0im, -x0im) */ - x2re = XBuf[0]; - x2im = XBuf[1]; - - p02re.w64 = MADD64(p02re.w64, x2re, x0re); - p02re.w64 = MADD64(p02re.w64, x2im, x0im); - p02im.w64 = MADD64(p02im.w64, x0re, x2im); - p02im.w64 = MADD64(p02im.w64, -x0im, x2re); - - x0re = x1re; - x0im = x1im; - x1re = x2re; - x1im = x2im; - XBuf += (2*64); - } - - accBuf[0] = p02re.r.lo32; - accBuf[1] = p02re.r.hi32; - accBuf[2] = p02im.r.lo32; - accBuf[3] = p02im.r.hi32; -} -#endif - -/************************************************************************************** - * Function: CalcCovariance2 - * - * Description: calculate covariance matrix for p02 (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * - * Outputs: complex covariance element p02re, p02im - * format = integer (Q0) * 2^N, with scalefactor N >= 0 - * - * Return: scalefactor N - * - * Notes: outputs are normalized to have 1 GB (sign in at least top 2 bits) - **************************************************************************************/ -static int CalcCovariance2(int *XBuf, int *p02reN, int *p02imN) -{ - U64 p02re, p02im; - int n, z, s, loShift, hiShift, gbMask; - int accBuf[2*2]; - - CVKernel2(XBuf, accBuf); - p02re.r.lo32 = accBuf[0]; - p02re.r.hi32 = accBuf[1]; - p02im.r.lo32 = accBuf[2]; - p02im.r.hi32 = accBuf[3]; - - /* 64-bit accumulators now have 2*FBITS_OUT_QMFA fraction bits - * want to scale them down to integers (32-bit signed, Q0) - * with scale factor of 2^n, n >= 0 - * leave 1 GB for calculating determinant, so take top 30 non-zero bits - */ - gbMask = ((p02re.r.hi32) ^ (p02re.r.hi32 >> 31)) | ((p02im.r.hi32) ^ (p02im.r.hi32 >> 31)); - if (gbMask == 0) { - s = p02re.r.hi32 >> 31; gbMask = (p02re.r.lo32 ^ s) - s; - s = p02im.r.hi32 >> 31; gbMask |= (p02im.r.lo32 ^ s) - s; - z = 32 + CLZ(gbMask); - } else { - gbMask = FASTABS(p02re.r.hi32) | FASTABS(p02im.r.hi32); - z = CLZ(gbMask); - } - n = 64 - z; /* number of non-zero bits in bottom of 64-bit word */ - - if (n <= 30) { - loShift = (30 - n); - *p02reN = p02re.r.lo32 << loShift; - *p02imN = p02im.r.lo32 << loShift; - return -(loShift + 2*FBITS_OUT_QMFA); - } else if (n < 32 + 30) { - loShift = (n - 30); - hiShift = 32 - loShift; - *p02reN = (p02re.r.hi32 << hiShift) | (p02re.r.lo32 >> loShift); - *p02imN = (p02im.r.hi32 << hiShift) | (p02im.r.lo32 >> loShift); - return (loShift - 2*FBITS_OUT_QMFA); - } else { - hiShift = n - (32 + 30); - *p02reN = p02re.r.hi32 >> hiShift; - *p02imN = p02im.r.hi32 >> hiShift; - return (32 - 2*FBITS_OUT_QMFA - hiShift); - } - - return 0; -} - -/************************************************************************************** - * Function: CalcLPCoefs - * - * Description: calculate linear prediction coefficients for one subband (4.6.18.6.2) - * - * Inputs: buffer of low-freq samples, starting at time index = 0, - * freq index = patch subband - * number of guard bits in input sample buffer - * - * Outputs: complex LP coefficients a0re, a0im, a1re, a1im, format = Q29 - * - * Return: none - * - * Notes: output coefficients (a0re, a0im, a1re, a1im) clipped to range (-4, 4) - * if the comples coefficients have magnitude >= 4.0, they are all - * set to 0 (see spec) - **************************************************************************************/ -static void CalcLPCoefs(int *XBuf, int *a0re, int *a0im, int *a1re, int *a1im, int gb) -{ - int zFlag, n1, n2, nd, d, dInv, tre, tim; - int p01re, p01im, p02re, p02im, p12re, p12im, p11re, p22re; - - /* pre-scale to avoid overflow - probably never happens in practice (see QMFA) - * max bit growth per accumulator = 38*2 = 76 mul-adds (X * X) - * using 64-bit MADD, so if X has n guard bits, X*X has 2n+1 guard bits - * gain 1 extra sign bit per multiply, so ensure ceil(log2(76/2) / 2) = 3 guard bits on inputs - */ - if (gb < 3) { - nd = 3 - gb; - for (n1 = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) { - XBuf[0] >>= nd; XBuf[1] >>= nd; - XBuf += (2*64); - } - XBuf -= (2*64*(NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2)); - } - - /* calculate covariance elements */ - n1 = CalcCovariance1(XBuf, &p01re, &p01im, &p12re, &p12im, &p11re, &p22re); - n2 = CalcCovariance2(XBuf, &p02re, &p02im); - - /* normalize everything to larger power of 2 scalefactor, call it n1 */ - if (n1 < n2) { - nd = MIN(n2 - n1, 31); - p01re >>= nd; p01im >>= nd; - p12re >>= nd; p12im >>= nd; - p11re >>= nd; p22re >>= nd; - n1 = n2; - } else if (n1 > n2) { - nd = MIN(n1 - n2, 31); - p02re >>= nd; p02im >>= nd; - } - - /* calculate determinant of covariance matrix (at least 1 GB in pXX) */ - d = MULSHIFT32(p12re, p12re) + MULSHIFT32(p12im, p12im); - d = MULSHIFT32(d, RELAX_COEF) << 1; - d = MULSHIFT32(p11re, p22re) - d; - ASSERT(d >= 0); /* should never be < 0 */ - - zFlag = 0; - *a0re = *a0im = 0; - *a1re = *a1im = 0; - if (d > 0) { - /* input = Q31 d = Q(-2*n1 - 32 + nd) = Q31 * 2^(31 + 2*n1 + 32 - nd) - * inverse = Q29 dInv = Q29 * 2^(-31 - 2*n1 - 32 + nd) = Q(29 + 31 + 2*n1 + 32 - nd) - * - * numerator has same Q format as d, since it's sum of normalized squares - * so num * inverse = Q(-2*n1 - 32) * Q(29 + 31 + 2*n1 + 32 - nd) - * = Q(29 + 31 - nd), drop low 32 in MULSHIFT32 - * = Q(29 + 31 - 32 - nd) = Q(28 - nd) - */ - nd = CLZ(d) - 1; - d <<= nd; - dInv = InvRNormalized(d); - - /* 1 GB in pXX */ - tre = MULSHIFT32(p01re, p12re) - MULSHIFT32(p01im, p12im) - MULSHIFT32(p02re, p11re); - tre = MULSHIFT32(tre, dInv); - tim = MULSHIFT32(p01re, p12im) + MULSHIFT32(p01im, p12re) - MULSHIFT32(p02im, p11re); - tim = MULSHIFT32(tim, dInv); - - /* if d is extremely small, just set coefs to 0 (would have poor precision anyway) */ - if (nd > 28 || (FASTABS(tre) >> (28 - nd)) >= 4 || (FASTABS(tim) >> (28 - nd)) >= 4) { - zFlag = 1; - } else { - *a1re = tre << (FBITS_LPCOEFS - 28 + nd); /* i.e. convert Q(28 - nd) to Q(29) */ - *a1im = tim << (FBITS_LPCOEFS - 28 + nd); - } - } - - if (p11re) { - /* input = Q31 p11re = Q(-n1 + nd) = Q31 * 2^(31 + n1 - nd) - * inverse = Q29 dInv = Q29 * 2^(-31 - n1 + nd) = Q(29 + 31 + n1 - nd) - * - * numerator is Q(-n1 - 3) - * so num * inverse = Q(-n1 - 3) * Q(29 + 31 + n1 - nd) - * = Q(29 + 31 - 3 - nd), drop low 32 in MULSHIFT32 - * = Q(29 + 31 - 3 - 32 - nd) = Q(25 - nd) - */ - nd = CLZ(p11re) - 1; /* assume positive */ - p11re <<= nd; - dInv = InvRNormalized(p11re); - - /* a1re, a1im = Q29, so scaled by (n1 + 3) */ - tre = (p01re >> 3) + MULSHIFT32(p12re, *a1re) + MULSHIFT32(p12im, *a1im); - tre = -MULSHIFT32(tre, dInv); - tim = (p01im >> 3) - MULSHIFT32(p12im, *a1re) + MULSHIFT32(p12re, *a1im); - tim = -MULSHIFT32(tim, dInv); - - if (nd > 25 || (FASTABS(tre) >> (25 - nd)) >= 4 || (FASTABS(tim) >> (25 - nd)) >= 4) { - zFlag = 1; - } else { - *a0re = tre << (FBITS_LPCOEFS - 25 + nd); /* i.e. convert Q(25 - nd) to Q(29) */ - *a0im = tim << (FBITS_LPCOEFS - 25 + nd); - } - } - - /* see 4.6.18.6.2 - if magnitude of a0 or a1 >= 4 then a0 = a1 = 0 - * i.e. a0re < 4, a0im < 4, a1re < 4, a1im < 4 - * Q29*Q29 = Q26 - */ - if (zFlag || MULSHIFT32(*a0re, *a0re) + MULSHIFT32(*a0im, *a0im) >= MAG_16 || MULSHIFT32(*a1re, *a1re) + MULSHIFT32(*a1im, *a1im) >= MAG_16) { - *a0re = *a0im = 0; - *a1re = *a1im = 0; - } - - /* no need to clip - we never changed the XBuf data, just used it to calculate a0 and a1 */ - if (gb < 3) { - nd = 3 - gb; - for (n1 = (NUM_TIME_SLOTS*SAMPLES_PER_SLOT + 6 + 2); n1 != 0; n1--) { - XBuf[0] <<= nd; XBuf[1] <<= nd; - XBuf += (2*64); - } - } -} - -/************************************************************************************** - * Function: GenerateHighFreq - * - * Description: generate high frequencies with SBR (4.6.18.6) - * - * Inputs: initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: new high frequency samples starting at frequency kStart - * - * Return: none - **************************************************************************************/ -void GenerateHighFreq(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int band, newBW, c, t, gb, gbMask, gbIdx; - int currPatch, p, x, k, g, i, iStart, iEnd, bw, bwsq; - int a0re, a0im, a1re, a1im; - int x1re, x1im, x2re, x2im; - int ACCre, ACCim; - int *XBufLo, *XBufHi; - (void) ch; - - /* calculate array of chirp factors */ - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - c = sbrChan->chirpFact[band]; /* previous (bwArray') */ - newBW = newBWTab[sbrChan->invfMode[0][band]][sbrChan->invfMode[1][band]]; - - /* weighted average of new and old (can't overflow - total gain = 1.0) */ - if (newBW < c) - t = MULSHIFT32(newBW, 0x60000000) + MULSHIFT32(0x20000000, c); /* new is smaller: 0.75*new + 0.25*old */ - else - t = MULSHIFT32(newBW, 0x74000000) + MULSHIFT32(0x0c000000, c); /* new is larger: 0.90625*new + 0.09375*old */ - t <<= 1; - - if (t < 0x02000000) /* below 0.015625, clip to 0 */ - t = 0; - if (t > 0x7f800000) /* clip to 0.99609375 */ - t = 0x7f800000; - - /* save curr as prev for next time */ - sbrChan->chirpFact[band] = t; - sbrChan->invfMode[0][band] = sbrChan->invfMode[1][band]; - } - - iStart = sbrGrid->envTimeBorder[0] + HF_ADJ; - iEnd = sbrGrid->envTimeBorder[sbrGrid->numEnv] + HF_ADJ; - - /* generate new high freqs from low freqs, patches, and chirp factors */ - k = sbrFreq->kStart; - g = 0; - bw = sbrChan->chirpFact[g]; - bwsq = MULSHIFT32(bw, bw) << 1; - - gbMask = (sbrChan->gbMask[0] | sbrChan->gbMask[1]); /* older 32 | newer 8 */ - gb = CLZ(gbMask) - 1; - - for (currPatch = 0; currPatch < sbrFreq->numPatches; currPatch++) { - for (x = 0; x < sbrFreq->patchNumSubbands[currPatch]; x++) { - /* map k to corresponding noise floor band */ - if (k >= sbrFreq->freqNoise[g+1]) { - g++; - bw = sbrChan->chirpFact[g]; /* Q31 */ - bwsq = MULSHIFT32(bw, bw) << 1; /* Q31 */ - } - - p = sbrFreq->patchStartSubband[currPatch] + x; /* low QMF band */ - XBufHi = psi->XBuf[iStart][k]; - if (bw) { - CalcLPCoefs(psi->XBuf[0][p], &a0re, &a0im, &a1re, &a1im, gb); - - a0re = MULSHIFT32(bw, a0re); /* Q31 * Q29 = Q28 */ - a0im = MULSHIFT32(bw, a0im); - a1re = MULSHIFT32(bwsq, a1re); - a1im = MULSHIFT32(bwsq, a1im); - - XBufLo = psi->XBuf[iStart-2][p]; - - x2re = XBufLo[0]; /* RE{XBuf[n-2]} */ - x2im = XBufLo[1]; /* IM{XBuf[n-2]} */ - XBufLo += (64*2); - - x1re = XBufLo[0]; /* RE{XBuf[n-1]} */ - x1im = XBufLo[1]; /* IM{XBuf[n-1]} */ - XBufLo += (64*2); - - for (i = iStart; i < iEnd; i++) { - /* a0re/im, a1re/im are Q28 with at least 1 GB, - * so the summing for AACre/im is fine (1 GB in, plus 1 from MULSHIFT32) - */ - ACCre = MULSHIFT32(x2re, a1re) - MULSHIFT32(x2im, a1im); - ACCim = MULSHIFT32(x2re, a1im) + MULSHIFT32(x2im, a1re); - x2re = x1re; - x2im = x1im; - - ACCre += MULSHIFT32(x1re, a0re) - MULSHIFT32(x1im, a0im); - ACCim += MULSHIFT32(x1re, a0im) + MULSHIFT32(x1im, a0re); - x1re = XBufLo[0]; /* RE{XBuf[n]} */ - x1im = XBufLo[1]; /* IM{XBuf[n]} */ - XBufLo += (64*2); - - /* lost 4 fbits when scaling by a0re/im, a1re/im (Q28) */ - CLIP_2N_SHIFT30(ACCre, 4); - ACCre += x1re; - CLIP_2N_SHIFT30(ACCim, 4); - ACCim += x1im; - - XBufHi[0] = ACCre; - XBufHi[1] = ACCim; - XBufHi += (64*2); - - /* update guard bit masks */ - gbMask = FASTABS(ACCre); - gbMask |= FASTABS(ACCim); - gbIdx = (i >> 5) & 0x01; /* 0 if i < 32, 1 if i >= 32 */ - sbrChan->gbMask[gbIdx] |= gbMask; - } - } else { - XBufLo = (int *)psi->XBuf[iStart][p]; - for (i = iStart; i < iEnd; i++) { - XBufHi[0] = XBufLo[0]; - XBufHi[1] = XBufLo[1]; - XBufLo += (64*2); - XBufHi += (64*2); - } - } - k++; /* high QMF band */ - } - } -} - - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrhuff.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrhuff.c deleted file mode 100644 index a174e1e8..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrhuff.c +++ /dev/null @@ -1,476 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrhuff.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrhuff.c - functions for unpacking Huffman-coded envelope and noise data - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/************************************************************************************** - * Function: DecodeHuffmanScalar - * - * Description: decode one Huffman symbol from bitstream - * - * Inputs: pointers to Huffman table and info struct - * left-aligned bit buffer with >= huffTabInfo->maxBits bits - * - * Outputs: decoded symbol in *val - * - * Return: number of bits in symbol - * - * Notes: assumes canonical Huffman codes: - * first CW always 0, we have "count" CW's of length "nBits" bits - * starting CW for codes of length nBits+1 = - * (startCW[nBits] + count[nBits]) << 1 - * if there are no codes at nBits, then we just keep << 1 each time - * (since count[nBits] = 0) - **************************************************************************************/ -static int DecodeHuffmanScalar(const signed /*short*/ int *huffTab, const HuffInfo *huffTabInfo, unsigned int bitBuf, signed int *val) -{ - unsigned int count, start, shift, t; - const unsigned int /*char*/ *countPtr; - const signed int /*short*/ *map; - - map = huffTab + huffTabInfo->offset; - countPtr = huffTabInfo->count; - - start = 0; - count = 0; - shift = 32; - do { - start += count; - start <<= 1; - map += count; - count = *countPtr++; - shift--; - t = (bitBuf >> shift) - start; - } while (t >= count); - - *val = (signed int)map[t]; - return (countPtr - huffTabInfo->count); -} - -/************************************************************************************** - * Function: DecodeOneSymbol - * - * Description: dequantize one Huffman symbol from bitstream, - * using table huffTabSBR[huffTabIndex] - * - * Inputs: BitStreamInfo struct pointing to start of next Huffman codeword - * index of Huffman table - * - * Outputs: bitstream advanced by number of bits in codeword - * - * Return: one decoded symbol - **************************************************************************************/ -static int DecodeOneSymbol(BitStreamInfo *bsi, int huffTabIndex) -{ - int nBits, val; - unsigned int bitBuf; - const HuffInfo *hi; - - hi = &(huffTabSBRInfo[huffTabIndex]); - - bitBuf = GetBitsNoAdvance(bsi, hi->maxBits) << (32 - hi->maxBits); - nBits = DecodeHuffmanScalar(huffTabSBR, hi, bitBuf, &val); - AdvanceBitstream(bsi, nBits); - - return val; -} - -/* [1.0, sqrt(2)], format = Q29 (one guard bit for decoupling) */ -static const int envDQTab[2] PROGMEM = {0x20000000, 0x2d413ccc}; - -/************************************************************************************** - * Function: DequantizeEnvelope - * - * Description: dequantize envelope scalefactors - * - * Inputs: number of scalefactors to process - * amplitude resolution flag for this frame (0 or 1) - * quantized envelope scalefactors - * - * Outputs: dequantized envelope scalefactors - * - * Return: extra int bits in output (6 + expMax) - * in other words, output format = Q(FBITS_OUT_DQ_ENV - (6 + expMax)) - * - * Notes: dequantized scalefactors have at least 2 GB - **************************************************************************************/ -static int DequantizeEnvelope(int nBands, int ampRes, signed char *envQuant, int *envDequant) -{ - int exp, expMax, i, scalei; - - if (nBands <= 0) - return 0; - - /* scan for largest dequant value (do separately from envelope decoding to keep code cleaner) */ - expMax = 0; - for (i = 0; i < nBands; i++) { - if (envQuant[i] > expMax) - expMax = envQuant[i]; - } - - /* dequantized envelope gains - * envDequant = 64*2^(envQuant / alpha) = 2^(6 + envQuant / alpha) - * if ampRes == 0, alpha = 2 and range of envQuant = [0, 127] - * if ampRes == 1, alpha = 1 and range of envQuant = [0, 63] - * also if coupling is on, envDequant is scaled by something in range [0, 2] - * so range of envDequant = [2^6, 2^69] (no coupling), [2^6, 2^70] (with coupling) - * - * typical range (from observation) of envQuant/alpha = [0, 27] --> largest envQuant ~= 2^33 - * output: Q(29 - (6 + expMax)) - * - * reference: 14496-3:2001(E)/4.6.18.3.5 and 14496-4:200X/FPDAM8/5.6.5.1.2.1.5 - */ - if (ampRes) { - do { - exp = *envQuant++; - scalei = MIN(expMax - exp, 31); - *envDequant++ = envDQTab[0] >> scalei; - } while (--nBands); - - return (6 + expMax); - } else { - expMax >>= 1; - do { - exp = *envQuant++; - scalei = MIN(expMax - (exp >> 1), 31); - *envDequant++ = envDQTab[exp & 0x01] >> scalei; - } while (--nBands); - - return (6 + expMax); - } - -} - -/************************************************************************************** - * Function: DequantizeNoise - * - * Description: dequantize noise scalefactors - * - * Inputs: number of scalefactors to process - * quantized noise scalefactors - * - * Outputs: dequantized noise scalefactors, format = Q(FBITS_OUT_DQ_NOISE) - * - * Return: none - * - * Notes: dequantized scalefactors have at least 2 GB - **************************************************************************************/ -static void DequantizeNoise(int nBands, signed char *noiseQuant, int *noiseDequant) -{ - int exp, scalei; - - if (nBands <= 0) - return; - - /* dequantize noise floor gains (4.6.18.3.5): - * noiseDequant = 2^(NOISE_FLOOR_OFFSET - noiseQuant) - * - * range of noiseQuant = [0, 30] (see 4.6.18.3.6), NOISE_FLOOR_OFFSET = 6 - * so range of noiseDequant = [2^-24, 2^6] - */ - do { - exp = *noiseQuant++; - scalei = NOISE_FLOOR_OFFSET - exp + FBITS_OUT_DQ_NOISE; /* 6 + 24 - exp, exp = [0,30] */ - - if (scalei < 0) - *noiseDequant++ = 0; - else if (scalei < 30) - *noiseDequant++ = 1 << scalei; - else - *noiseDequant++ = 0x3fffffff; /* leave 2 GB */ - - } while (--nBands); -} - -/************************************************************************************** - * Function: DecodeSBREnvelope - * - * Description: decode delta Huffman coded envelope scalefactors from bitstream - * - * Inputs: BitStreamInfo struct pointing to start of env data - * initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: dequantized env scalefactors for left channel (before decoupling) - * dequantized env scalefactors for right channel (if coupling off) - * or raw decoded env scalefactors for right channel (if coupling on) - * - * Return: none - **************************************************************************************/ -void DecodeSBREnvelope(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int huffIndexTime, huffIndexFreq, env, envStartBits, band, nBands, sf, lastEnv; - int freqRes, freqResPrev, dShift, i; - - if (psi->couplingFlag && ch) { - dShift = 1; - if (sbrGrid->ampResFrame) { - huffIndexTime = HuffTabSBR_tEnv30b; - huffIndexFreq = HuffTabSBR_fEnv30b; - envStartBits = 5; - } else { - huffIndexTime = HuffTabSBR_tEnv15b; - huffIndexFreq = HuffTabSBR_fEnv15b; - envStartBits = 6; - } - } else { - dShift = 0; - if (sbrGrid->ampResFrame) { - huffIndexTime = HuffTabSBR_tEnv30; - huffIndexFreq = HuffTabSBR_fEnv30; - envStartBits = 6; - } else { - huffIndexTime = HuffTabSBR_tEnv15; - huffIndexFreq = HuffTabSBR_fEnv15; - envStartBits = 7; - } - } - - /* range of envDataQuant[] = [0, 127] (see comments in DequantizeEnvelope() for reference) */ - for (env = 0; env < sbrGrid->numEnv; env++) { - nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow); - freqRes = (sbrGrid->freqRes[env]); - freqResPrev = (env == 0 ? sbrGrid->freqResPrev : sbrGrid->freqRes[env-1]); - lastEnv = (env == 0 ? sbrGrid->numEnvPrev-1 : env-1); - if (lastEnv < 0) - lastEnv = 0; /* first frame */ - - ASSERT(nBands <= MAX_QMF_BANDS); - - if (sbrChan->deltaFlagEnv[env] == 0) { - /* delta coding in freq */ - sf = GetBits(bsi, envStartBits) << dShift; - sbrChan->envDataQuant[env][0] = sf; - for (band = 1; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift; - sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[env][band-1]; - } - } else if (freqRes == freqResPrev) { - /* delta coding in time - same freq resolution for both frames */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf + sbrChan->envDataQuant[lastEnv][band]; - } - } else if (freqRes == 0 && freqResPrev == 1) { - /* delta coding in time - low freq resolution for new frame, high freq resolution for old frame */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf; - for (i = 0; i < sbrFreq->nHigh; i++) { - if (sbrFreq->freqHigh[i] == sbrFreq->freqLow[band]) { - sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i]; - break; - } - } - } - } else if (freqRes == 1 && freqResPrev == 0) { - /* delta coding in time - high freq resolution for new frame, low freq resolution for old frame */ - for (band = 0; band < nBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->envDataQuant[env][band] = sf; - for (i = 0; i < sbrFreq->nLow; i++) { - if (sbrFreq->freqLow[i] <= sbrFreq->freqHigh[band] && sbrFreq->freqHigh[band] < sbrFreq->freqLow[i+1] ) { - sbrChan->envDataQuant[env][band] += sbrChan->envDataQuant[lastEnv][i]; - break; - } - } - } - } - - /* skip coupling channel */ - if (ch != 1 || psi->couplingFlag != 1) - psi->envDataDequantScale[ch][env] = DequantizeEnvelope(nBands, sbrGrid->ampResFrame, sbrChan->envDataQuant[env], psi->envDataDequant[ch][env]); - } - sbrGrid->numEnvPrev = sbrGrid->numEnv; - sbrGrid->freqResPrev = sbrGrid->freqRes[sbrGrid->numEnv-1]; -} - -/************************************************************************************** - * Function: DecodeSBRNoise - * - * Description: decode delta Huffman coded noise scalefactors from bitstream - * - * Inputs: BitStreamInfo struct pointing to start of noise data - * initialized PSInfoSBR struct - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel - * index of current channel (0 for SCE, 0 or 1 for CPE) - * - * Outputs: dequantized noise scalefactors for left channel (before decoupling) - * dequantized noise scalefactors for right channel (if coupling off) - * or raw decoded noise scalefactors for right channel (if coupling on) - * - * Return: none - **************************************************************************************/ -void DecodeSBRNoise(BitStreamInfo *bsi, PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChan, int ch) -{ - int huffIndexTime, huffIndexFreq, noiseFloor, band, dShift, sf, lastNoiseFloor; - - if (psi->couplingFlag && ch) { - dShift = 1; - huffIndexTime = HuffTabSBR_tNoise30b; - huffIndexFreq = HuffTabSBR_fNoise30b; - } else { - dShift = 0; - huffIndexTime = HuffTabSBR_tNoise30; - huffIndexFreq = HuffTabSBR_fNoise30; - } - - for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) { - lastNoiseFloor = (noiseFloor == 0 ? sbrGrid->numNoiseFloorsPrev-1 : noiseFloor-1); - if (lastNoiseFloor < 0) - lastNoiseFloor = 0; /* first frame */ - - ASSERT(sbrFreq->numNoiseFloorBands <= MAX_QMF_BANDS); - - if (sbrChan->deltaFlagNoise[noiseFloor] == 0) { - /* delta coding in freq */ - sbrChan->noiseDataQuant[noiseFloor][0] = GetBits(bsi, 5) << dShift; - for (band = 1; band < sbrFreq->numNoiseFloorBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexFreq) << dShift; - sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[noiseFloor][band-1]; - } - } else { - /* delta coding in time */ - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - sf = DecodeOneSymbol(bsi, huffIndexTime) << dShift; - sbrChan->noiseDataQuant[noiseFloor][band] = sf + sbrChan->noiseDataQuant[lastNoiseFloor][band]; - } - } - - /* skip coupling channel */ - if (ch != 1 || psi->couplingFlag != 1) - DequantizeNoise(sbrFreq->numNoiseFloorBands, sbrChan->noiseDataQuant[noiseFloor], psi->noiseDataDequant[ch][noiseFloor]); - } - sbrGrid->numNoiseFloorsPrev = sbrGrid->numNoiseFloors; -} - -/* dqTabCouple[i] = 2 / (1 + 2^(12 - i)), format = Q30 */ -static const int dqTabCouple[25] PROGMEM = { - 0x0007ff80, 0x000ffe00, 0x001ff802, 0x003fe010, 0x007f8080, 0x00fe03f8, 0x01f81f82, 0x03e0f83e, - 0x07878788, 0x0e38e38e, 0x1999999a, 0x2aaaaaab, 0x40000000, 0x55555555, 0x66666666, 0x71c71c72, - 0x78787878, 0x7c1f07c2, 0x7e07e07e, 0x7f01fc08, 0x7f807f80, 0x7fc01ff0, 0x7fe007fe, 0x7ff00200, - 0x7ff80080, -}; - -/************************************************************************************** - * Function: UncoupleSBREnvelope - * - * Description: scale dequantized envelope scalefactors according to channel - * coupling rules - * - * Inputs: initialized PSInfoSBR struct including - * dequantized envelope data for left channel - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for right channel including - * quantized envelope scalefactors - * - * Outputs: dequantized envelope data for left channel (after decoupling) - * dequantized envelope data for right channel (after decoupling) - * - * Return: none - **************************************************************************************/ -void UncoupleSBREnvelope(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR) -{ - int env, band, nBands, scalei, E_1; - - scalei = (sbrGrid->ampResFrame ? 0 : 1); - for (env = 0; env < sbrGrid->numEnv; env++) { - nBands = (sbrGrid->freqRes[env] ? sbrFreq->nHigh : sbrFreq->nLow); - psi->envDataDequantScale[1][env] = psi->envDataDequantScale[0][env]; /* same scalefactor for L and R */ - for (band = 0; band < nBands; band++) { - /* clip E_1 to [0, 24] (scalefactors approach 0 or 2) */ - E_1 = sbrChanR->envDataQuant[env][band] >> scalei; - if (E_1 < 0) E_1 = 0; - if (E_1 > 24) E_1 = 24; - - /* envDataDequant[0] has 1 GB, so << by 2 is okay */ - psi->envDataDequant[1][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[24 - E_1]) << 2; - psi->envDataDequant[0][env][band] = MULSHIFT32(psi->envDataDequant[0][env][band], dqTabCouple[E_1]) << 2; - } - } -} - -/************************************************************************************** - * Function: UncoupleSBRNoise - * - * Description: scale dequantized noise floor scalefactors according to channel - * coupling rules - * - * Inputs: initialized PSInfoSBR struct including - * dequantized noise data for left channel - * initialized SBRGrid struct for this channel - * initialized SBRFreq struct for this SCE/CPE block - * initialized SBRChan struct for this channel including - * quantized noise scalefactors - * - * Outputs: dequantized noise data for left channel (after decoupling) - * dequantized noise data for right channel (after decoupling) - * - * Return: none - **************************************************************************************/ -void UncoupleSBRNoise(PSInfoSBR *psi, SBRGrid *sbrGrid, SBRFreq *sbrFreq, SBRChan *sbrChanR) -{ - int noiseFloor, band, Q_1; - - for (noiseFloor = 0; noiseFloor < sbrGrid->numNoiseFloors; noiseFloor++) { - for (band = 0; band < sbrFreq->numNoiseFloorBands; band++) { - /* Q_1 should be in range [0, 24] according to 4.6.18.3.6, but check to make sure */ - Q_1 = sbrChanR->noiseDataQuant[noiseFloor][band]; - if (Q_1 < 0) Q_1 = 0; - if (Q_1 > 24) Q_1 = 24; - - /* noiseDataDequant[0] has 1 GB, so << by 2 is okay */ - psi->noiseDataDequant[1][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[24 - Q_1]) << 2; - psi->noiseDataDequant[0][noiseFloor][band] = MULSHIFT32(psi->noiseDataDequant[0][noiseFloor][band], dqTabCouple[Q_1]) << 2; - } - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrimdct.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrimdct.c deleted file mode 100644 index 365ff02a..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrimdct.c +++ /dev/null @@ -1,447 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrimdct.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrimdct.c - inverse MDCT without clipping or interleaving, for input to SBR - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/************************************************************************************** - * Function: DecWindowOverlapNoClip - * - * Description: apply synthesis window, do overlap-add without clipping, - * for winSequence LONG-LONG - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - if (winTypeCurr == winTypePrev) { - /* cut window loads in half since current and overlap sections use same symmetric window */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } else { - /* different windows for current and overlap parts - should still fit in registers on ARM w/o stack spill */ - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStart - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence LONG-START - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapLongStartNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - in = *buf1--; - - *over1-- = 0; /* Wn = 0 for n = (2047, 2046, ... 1600) */ - *over0++ = in >> 1; /* Wn = 1 for n = (1024, 1025, ... 1471) */ - } while (--i); - - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; - w1 = *wndPrev++; - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; /* W[0], W[1], ... --> W[255], W[254], ... */ - w1 = *wndCurr++; /* W[127], W[126], ... --> W[128], W[129], ... */ - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); /* Wn = short window for n = (1599, 1598, ... , 1536) */ - *over0++ = MULSHIFT32(w1, in); /* Wn = short window for n = (1472, 1473, ... , 1535) */ - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapLongStop - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence LONG-STOP - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapLongStopNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - buf0 += (1024 >> 1); - buf1 = buf0 - 1; - out1 = out0 + 1024 - 1; - over1 = over0 + 1024 - 1; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[1] : sinWindow + sinWindowOffset[1]); - - i = 448; /* 2 outputs, 2 overlaps per loop */ - do { - /* Wn = 0 for n = (0, 1, ... 447) */ - /* Wn = 1 for n = (576, 577, ... 1023) */ - in = *buf0++; - f1 = in >> 1; /* scale since skipping multiply by Q31 */ - - in = *over0; - *out0++ = in; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (--i); - - /* do 64 more loops - 2 outputs, 2 overlaps per loop */ - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); -} - -/************************************************************************************** - * Function: DecWindowOverlapShort - * - * Description: apply synthesis window, do overlap-add, without clipping - * for winSequence EIGHT-SHORT (does all 8 short blocks) - * - * Inputs: input buffer (output of type-IV DCT) - * overlap buffer (saved from last time) - * window type (sin or KBD) for input buffer - * window type (sin or KBD) for overlap buffer - * - * Outputs: one channel, one frame of 32-bit PCM, non-interleaved - * - * Return: none - * - * Notes: use this function when the decoded PCM is going to the SBR decoder - **************************************************************************************/ -void DecWindowOverlapShortNoClip(int *buf0, int *over0, int *out0, int winTypeCurr, int winTypePrev) -{ - int i, in, w0, w1, f0, f1; - int *buf1, *over1, *out1; - const int *wndPrev, *wndCurr; - - wndPrev = (winTypePrev == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - wndCurr = (winTypeCurr == 1 ? kbdWindow + kbdWindowOffset[0] : sinWindow + sinWindowOffset[0]); - - /* pcm[0-447] = 0 + overlap[0-447] */ - i = 448; - do { - f0 = *over0++; - f1 = *over0++; - *out0++ = f0; - *out0++ = f1; - i -= 2; - } while (i); - - /* pcm[448-575] = Wp[0-127] * block0[0-127] + overlap[448-575] */ - out1 = out0 + (128 - 1); - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - do { - w0 = *wndPrev++; /* W[0], W[1], ...W[63] */ - w1 = *wndPrev++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *over0; - *out0++ = in - f0; - - in = *over1; - *out1-- = in + f1; - - w0 = *wndCurr++; - w1 = *wndCurr++; - in = *buf1--; - - /* save over0/over1 for next short block, in the slots just vacated */ - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - - /* pcm[576-703] = Wc[128-255] * block0[128-255] + Wc[0-127] * block1[0-127] + overlap[576-703] - * pcm[704-831] = Wc[128-255] * block1[128-255] + Wc[0-127] * block2[0-127] + overlap[704-831] - * pcm[832-959] = Wc[128-255] * block2[128-255] + Wc[0-127] * block3[0-127] + overlap[832-959] - */ - for (i = 0; i < 3; i++) { - out0 += 64; - out1 = out0 + 128 - 1; - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 - 128); /* from last short block */ - in += *(over0 + 0); /* from last full frame */ - *out0++ = in - f0; - - in = *(over1 - 128); /* from last short block */ - in += *(over1 + 0); /* from last full frame */ - *out1-- = in + f1; - - /* save over0/over1 for next short block, in the slots just vacated */ - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* pcm[960-1023] = Wc[128-191] * block3[128-191] + Wc[0-63] * block4[0-63] + overlap[960-1023] - * over[0-63] = Wc[192-255] * block3[192-255] + Wc[64-127] * block4[64-127] - */ - out0 += 64; - over0 -= 832; /* points at overlap[64] */ - over1 = over0 + 128 - 1; /* points at overlap[191] */ - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - in = *(over0 + 768); /* from last short block */ - in += *(over0 + 896); /* from last full frame */ - *out0++ = in - f0; - - in = *(over1 + 768); /* from last short block */ - *(over1 - 128) = in + f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); /* save in overlap[128-191] */ - *over0++ = MULSHIFT32(w1, in); /* save in overlap[64-127] */ - } while (over0 < over1); - - /* over0 now points at overlap[128] */ - - /* over[64-191] = Wc[128-255] * block4[128-255] + Wc[0-127] * block5[0-127] - * over[192-319] = Wc[128-255] * block5[128-255] + Wc[0-127] * block6[0-127] - * over[320-447] = Wc[128-255] * block6[128-255] + Wc[0-127] * block7[0-127] - * over[448-576] = Wc[128-255] * block7[128-255] - */ - for (i = 0; i < 3; i++) { - over0 += 64; - over1 = over0 + 128 - 1; - buf0 += 64; - buf1 = buf0 - 1; - wndCurr -= 128; - do { - w0 = *wndCurr++; /* W[0], W[1], ...W[63] */ - w1 = *wndCurr++; /* W[127], W[126], ... W[64] */ - in = *buf0++; - - f0 = MULSHIFT32(w0, in); - f1 = MULSHIFT32(w1, in); - - /* from last short block */ - *(over0 - 128) -= f0; - *(over1 - 128)+= f1; - - in = *buf1--; - *over1-- = MULSHIFT32(w0, in); - *over0++ = MULSHIFT32(w1, in); - } while (over0 < over1); - } - - /* over[576-1024] = 0 */ - i = 448; - over0 += 64; - do { - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - *over0++ = 0; - i -= 4; - } while (i); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrmath.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrmath.c deleted file mode 100644 index 930889d8..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrmath.c +++ /dev/null @@ -1,195 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrmath.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrmath.c - fixed-point math functions for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -#define Q28_2 0x20000000 /* Q28: 2.0 */ -#define Q28_15 0x30000000 /* Q28: 1.5 */ - -#define NUM_ITER_IRN 5 - -/************************************************************************************** - * Function: InvRNormalized - * - * Description: use Newton's method to solve for x = 1/r - * - * Inputs: r = Q31, range = [0.5, 1) (normalize your inputs to this range) - * - * Outputs: none - * - * Return: x = Q29, range ~= [1.0, 2.0] - * - * Notes: guaranteed to converge and not overflow for any r in [0.5, 1) - * - * xn+1 = xn - f(xn)/f'(xn) - * f(x) = 1/r - x = 0 (find root) - * = 1/x - r - * f'(x) = -1/x^2 - * - * so xn+1 = xn - (1/xn - r) / (-1/xn^2) - * = xn * (2 - r*xn) - * - * NUM_ITER_IRN = 2, maxDiff = 6.2500e-02 (precision of about 4 bits) - * NUM_ITER_IRN = 3, maxDiff = 3.9063e-03 (precision of about 8 bits) - * NUM_ITER_IRN = 4, maxDiff = 1.5288e-05 (precision of about 16 bits) - * NUM_ITER_IRN = 5, maxDiff = 3.0034e-08 (precision of about 24 bits) - **************************************************************************************/ -int InvRNormalized(int r) -{ - int i, xn, t; - - /* r = [0.5, 1.0) - * 1/r = (1.0, 2.0] - * so use 1.5 as initial guess - */ - xn = Q28_15; - - /* xn = xn*(2.0 - r*xn) */ - for (i = NUM_ITER_IRN; i != 0; i--) { - t = MULSHIFT32(r, xn); /* Q31*Q29 = Q28 */ - t = Q28_2 - t; /* Q28 */ - xn = MULSHIFT32(xn, t) << 4; /* Q29*Q28 << 4 = Q29 */ - } - - return xn; -} - -#define NUM_TERMS_RPI 5 -#define LOG2_EXP_INV 0x58b90bfc /* 1/log2(e), Q31 */ - -/* invTab[x] = 1/(x+1), format = Q30 */ -static const int invTab[NUM_TERMS_RPI] PROGMEM = {0x40000000, 0x20000000, 0x15555555, 0x10000000, 0x0ccccccd}; - -/************************************************************************************** - * Function: RatioPowInv - * - * Description: use Taylor (MacLaurin) series expansion to calculate (a/b) ^ (1/c) - * - * Inputs: a = [1, 64], b = [1, 64], c = [1, 64], a >= b - * - * Outputs: none - * - * Return: y = Q24, range ~= [0.015625, 64] - **************************************************************************************/ -int RatioPowInv(int a, int b, int c) -{ - int lna, lnb, i, p, t, y; - - if (a < 1 || b < 1 || c < 1 || a > 64 || b > 64 || c > 64 || a < b) - return 0; - - lna = MULSHIFT32(log2Tab[a], LOG2_EXP_INV) << 1; /* ln(a), Q28 */ - lnb = MULSHIFT32(log2Tab[b], LOG2_EXP_INV) << 1; /* ln(b), Q28 */ - p = (lna - lnb) / c; /* Q28 */ - - /* sum in Q24 */ - y = (1 << 24); - t = p >> 4; /* t = p^1 * 1/1! (Q24)*/ - y += t; - - for (i = 2; i <= NUM_TERMS_RPI; i++) { - t = MULSHIFT32(invTab[i-1], t) << 2; - t = MULSHIFT32(p, t) << 4; /* t = p^i * 1/i! (Q24) */ - y += t; - } - - return y; -} - -/************************************************************************************** - * Function: SqrtFix - * - * Description: use binary search to calculate sqrt(q) - * - * Inputs: q = Q30 - * number of fraction bits in input - * - * Outputs: number of fraction bits in output - * - * Return: lo = Q(fBitsOut) - * - * Notes: absolute precision varies depending on fBitsIn - * normalizes input to range [0x200000000, 0x7fffffff] and takes - * floor(sqrt(input)), and sets fBitsOut appropriately - **************************************************************************************/ -int SqrtFix(int q, int fBitsIn, int *fBitsOut) -{ - int z, lo, hi, mid; - - if (q <= 0) { - *fBitsOut = fBitsIn; - return 0; - } - - /* force even fBitsIn */ - z = fBitsIn & 0x01; - q >>= z; - fBitsIn -= z; - - /* for max precision, normalize to [0x20000000, 0x7fffffff] */ - z = (CLZ(q) - 1); - z >>= 1; - q <<= (2*z); - - /* choose initial bounds */ - lo = 1; - if (q >= 0x10000000) - lo = 16384; /* (int)sqrt(0x10000000) */ - hi = 46340; /* (int)sqrt(0x7fffffff) */ - - /* do binary search with 32x32->32 multiply test */ - do { - mid = (lo + hi) >> 1; - if (mid*mid > q) - hi = mid - 1; - else - lo = mid + 1; - } while (hi >= lo); - lo--; - - *fBitsOut = ((fBitsIn + 2*z) >> 1); - return lo; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrqmf.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrqmf.c deleted file mode 100644 index 45fc8629..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrqmf.c +++ /dev/null @@ -1,527 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrqmf.c,v 1.2 2005/05/19 20:45:20 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrqmf.c - analysis and synthesis QMF filters for SBR - **************************************************************************************/ - -#include "sbr.h" -#include "assembly.h" - -/* PreMultiply64() table - * format = Q30 - * reordered for sequential access - * - * for (i = 0; i < 64/4; i++) { - * angle = (i + 0.25) * M_PI / nmdct; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * - * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -static const int cos4sin4tab64[64] PROGMEM = { - 0x40c7d2bd, 0x00c90e90, 0x424ff28f, 0x3ff4e5e0, 0x43cdd89a, 0x03ecadcf, 0x454149fc, 0x3fc395f9, - 0x46aa0d6d, 0x070de172, 0x4807eb4b, 0x3f6af2e3, 0x495aada2, 0x0a2abb59, 0x4aa22036, 0x3eeb3347, - 0x4bde1089, 0x0d415013, 0x4d0e4de2, 0x3e44a5ef, 0x4e32a956, 0x104fb80e, 0x4f4af5d1, 0x3d77b192, - 0x50570819, 0x135410c3, 0x5156b6d9, 0x3c84d496, 0x5249daa2, 0x164c7ddd, 0x53304df6, 0x3b6ca4c4, - 0x5409ed4b, 0x19372a64, 0x54d69714, 0x3a2fcee8, 0x55962bc0, 0x1c1249d8, 0x56488dc5, 0x38cf1669, - 0x56eda1a0, 0x1edc1953, 0x57854ddd, 0x374b54ce, 0x580f7b19, 0x2192e09b, 0x588c1404, 0x35a5793c, - 0x58fb0568, 0x2434f332, 0x595c3e2a, 0x33de87de, 0x59afaf4c, 0x26c0b162, 0x59f54bee, 0x31f79948, - 0x5a2d0957, 0x29348937, 0x5a56deec, 0x2ff1d9c7, 0x5a72c63b, 0x2b8ef77d, 0x5a80baf6, 0x2dce88aa, -}; - -/* PostMultiply64() table - * format = Q30 - * reordered for sequential access - * - * for (i = 0; i <= (32/2); i++) { - * angle = i * M_PI / 64; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -static const int cos1sin1tab64[34] PROGMEM = { - 0x40000000, 0x00000000, 0x43103085, 0x0323ecbe, 0x45f704f7, 0x0645e9af, 0x48b2b335, 0x09640837, - 0x4b418bbe, 0x0c7c5c1e, 0x4da1fab5, 0x0f8cfcbe, 0x4fd288dc, 0x1294062f, 0x51d1dc80, 0x158f9a76, - 0x539eba45, 0x187de2a7, 0x553805f2, 0x1b5d100a, 0x569cc31b, 0x1e2b5d38, 0x57cc15bc, 0x20e70f32, - 0x58c542c5, 0x238e7673, 0x5987b08a, 0x261feffa, 0x5a12e720, 0x2899e64a, 0x5a6690ae, 0x2afad269, - 0x5a82799a, 0x2d413ccd, -}; - -/************************************************************************************** - * Function: PreMultiply64 - * - * Description: pre-twiddle stage of 64-point DCT-IV - * - * Inputs: buffer of 64 samples - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits - * gbOut = gbIn + 1 - * output is limited to sqrt(2)/2 plus GB in full GB - * uses 3-mul, 3-add butterflies instead of 4-mul, 2-add - **************************************************************************************/ -static void PreMultiply64(int *zbuf1) -{ - int i, ar1, ai1, ar2, ai2, z1, z2; - int t, cms2, cps2a, sin2a, cps2b, sin2b; - int *zbuf2; - const int *csptr; - - zbuf2 = zbuf1 + 64 - 1; - csptr = cos4sin4tab64; - - /* whole thing should fit in registers - verify that compiler does this */ - for (i = 64 >> 2; i != 0; i--) { - /* cps2 = (cos+sin), sin2 = sin, cms2 = (cos-sin) */ - cps2a = *csptr++; - sin2a = *csptr++; - cps2b = *csptr++; - sin2b = *csptr++; - - ar1 = *(zbuf1 + 0); - ai2 = *(zbuf1 + 1); - ai1 = *(zbuf2 + 0); - ar2 = *(zbuf2 - 1); - - /* gain 2 ints bit from MULSHIFT32 by Q30 - * max per-sample gain (ignoring implicit scaling) = MAX(sin(angle)+cos(angle)) = 1.414 - * i.e. gain 1 GB since worst case is sin(angle) = cos(angle) = 0.707 (Q30), gain 2 from - * extra sign bits, and eat one in adding - */ - t = MULSHIFT32(sin2a, ar1 + ai1); - z2 = MULSHIFT32(cps2a, ai1) - t; - cms2 = cps2a - 2*sin2a; - z1 = MULSHIFT32(cms2, ar1) + t; - *zbuf1++ = z1; /* cos*ar1 + sin*ai1 */ - *zbuf1++ = z2; /* cos*ai1 - sin*ar1 */ - - t = MULSHIFT32(sin2b, ar2 + ai2); - z2 = MULSHIFT32(cps2b, ai2) - t; - cms2 = cps2b - 2*sin2b; - z1 = MULSHIFT32(cms2, ar2) + t; - *zbuf2-- = z2; /* cos*ai2 - sin*ar2 */ - *zbuf2-- = z1; /* cos*ar2 + sin*ai2 */ - } -} - -/************************************************************************************** - * Function: PostMultiply64 - * - * Description: post-twiddle stage of 64-point type-IV DCT - * - * Inputs: buffer of 64 samples - * number of output samples to calculate - * - * Outputs: processed samples in same buffer - * - * Return: none - * - * Notes: minimum 1 GB in, 2 GB out, gains 2 int bits - * gbOut = gbIn + 1 - * output is limited to sqrt(2)/2 plus GB in full GB - * nSampsOut is rounded up to next multiple of 4, since we calculate - * 4 samples per loop - **************************************************************************************/ -static void PostMultiply64(int *fft1, int nSampsOut) -{ - int i, ar1, ai1, ar2, ai2; - int t, cms2, cps2, sin2; - int *fft2; - const int *csptr; - - csptr = cos1sin1tab64; - fft2 = fft1 + 64 - 1; - - /* load coeffs for first pass - * cps2 = (cos+sin)/2, sin2 = sin/2, cms2 = (cos-sin)/2 - */ - cps2 = *csptr++; - sin2 = *csptr++; - cms2 = cps2 - 2*sin2; - - for (i = (nSampsOut + 3) >> 2; i != 0; i--) { - ar1 = *(fft1 + 0); - ai1 = *(fft1 + 1); - ar2 = *(fft2 - 1); - ai2 = *(fft2 + 0); - - /* gain 2 int bits (multiplying by Q30), max gain = sqrt(2) */ - t = MULSHIFT32(sin2, ar1 + ai1); - *fft2-- = t - MULSHIFT32(cps2, ai1); - *fft1++ = t + MULSHIFT32(cms2, ar1); - - cps2 = *csptr++; - sin2 = *csptr++; - - ai2 = -ai2; - t = MULSHIFT32(sin2, ar2 + ai2); - *fft2-- = t - MULSHIFT32(cps2, ai2); - cms2 = cps2 - 2*sin2; - *fft1++ = t + MULSHIFT32(cms2, ar2); - } -} - -/************************************************************************************** - * Function: QMFAnalysisConv - * - * Description: convolution kernel for analysis QMF - * - * Inputs: pointer to coefficient table, reordered for sequential access - * delay buffer of size 32*10 = 320 real-valued PCM samples - * index for delay ring buffer (range = [0, 9]) - * - * Outputs: 64 consecutive 32-bit samples - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrqmfak.s when building for ARM! - **************************************************************************************/ -#if (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) -#ifdef __cplusplus -extern "C" -#endif -void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf); -#else -void QMFAnalysisConv(int *cTab, int *delay, int dIdx, int *uBuf) -{ - int k, dOff; - int *cPtr0, *cPtr1; - U64 u64lo, u64hi; - - dOff = dIdx*32 + 31; - cPtr0 = cTab; - cPtr1 = cTab + 33*5 - 1; - - /* special first pass since we need to flip sign to create cTab[384], cTab[512] */ - u64lo.w64 = 0; - u64hi.w64 = 0; - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, -(*cPtr1--), delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - - uBuf[0] = u64lo.r.hi32; - uBuf[32] = u64hi.r.hi32; - uBuf++; - dOff--; - - /* max gain for any sample in uBuf, after scaling by cTab, ~= 0.99 - * so we can just sum the uBuf values with no overflow problems - */ - for (k = 1; k <= 31; k++) { - u64lo.w64 = 0; - u64hi.w64 = 0; - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr0++, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64lo.w64 = MADD64(u64lo.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - u64hi.w64 = MADD64(u64hi.w64, *cPtr1--, delay[dOff]); dOff -= 32; if (dOff < 0) {dOff += 320;} - - uBuf[0] = u64lo.r.hi32; - uBuf[32] = u64hi.r.hi32; - uBuf++; - dOff--; - } -} -#endif - -/************************************************************************************** - * Function: QMFAnalysis - * - * Description: 32-subband analysis QMF (4.6.18.4.1) - * - * Inputs: 32 consecutive samples of decoded 32-bit PCM, format = Q(fBitsIn) - * delay buffer of size 32*10 = 320 PCM samples - * number of fraction bits in input PCM - * index for delay ring buffer (range = [0, 9]) - * number of subbands to calculate (range = [0, 32]) - * - * Outputs: qmfaBands complex subband samples, format = Q(FBITS_OUT_QMFA) - * updated delay buffer - * updated delay index - * - * Return: guard bit mask - * - * Notes: output stored as RE{X0}, IM{X0}, RE{X1}, IM{X1}, ... RE{X31}, IM{X31} - * output stored in int buffer of size 64*2 = 128 - * (zero-filled from XBuf[2*qmfaBands] to XBuf[127]) - **************************************************************************************/ -int QMFAnalysis(int *inbuf, int *delay, int *XBuf, int fBitsIn, int *delayIdx, int qmfaBands) -{ - int n, y, shift, gbMask; - int *delayPtr, *uBuf, *tBuf; - - /* use XBuf[128] as temp buffer for reordering */ - uBuf = XBuf; /* first 64 samples */ - tBuf = XBuf + 64; /* second 64 samples */ - - /* overwrite oldest PCM with new PCM - * delay[n] has 1 GB after shifting (either << or >>) - */ - delayPtr = delay + (*delayIdx * 32); - if (fBitsIn > FBITS_IN_QMFA) { - shift = MIN(fBitsIn - FBITS_IN_QMFA, 31); - for (n = 32; n != 0; n--) { - y = (*inbuf) >> shift; - inbuf++; - *delayPtr++ = y; - } - } else { - shift = MIN(FBITS_IN_QMFA - fBitsIn, 30); - for (n = 32; n != 0; n--) { - y = *inbuf++; - CLIP_2N_SHIFT30(y, shift); - *delayPtr++ = y; - } - } - - QMFAnalysisConv((int *)cTabA, delay, *delayIdx, uBuf); - - /* uBuf has at least 2 GB right now (1 from clipping to Q(FBITS_IN_QMFA), one from - * the scaling by cTab (MULSHIFT32(*delayPtr--, *cPtr++), with net gain of < 1.0) - * TODO - fuse with QMFAnalysisConv to avoid separate reordering - */ - tBuf[2*0 + 0] = uBuf[0]; - tBuf[2*0 + 1] = uBuf[1]; - for (n = 1; n < 31; n++) { - tBuf[2*n + 0] = -uBuf[64-n]; - tBuf[2*n + 1] = uBuf[n+1]; - } - tBuf[2*31 + 1] = uBuf[32]; - tBuf[2*31 + 0] = -uBuf[33]; - - /* fast in-place DCT-IV - only need 2*qmfaBands output samples */ - PreMultiply64(tBuf); /* 2 GB in, 3 GB out */ - FFT32C(tBuf); /* 3 GB in, 1 GB out */ - PostMultiply64(tBuf, qmfaBands*2); /* 1 GB in, 2 GB out */ - - /* TODO - roll into PostMultiply (if enough registers) */ - gbMask = 0; - for (n = 0; n < qmfaBands; n++) { - XBuf[2*n+0] = tBuf[ n + 0]; /* implicit scaling of 2 in our output Q format */ - gbMask |= FASTABS(XBuf[2*n+0]); - XBuf[2*n+1] = -tBuf[63 - n]; - gbMask |= FASTABS(XBuf[2*n+1]); - } - - /* fill top section with zeros for HF generation */ - for ( ; n < 64; n++) { - XBuf[2*n+0] = 0; - XBuf[2*n+1] = 0; - } - - *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1); - - /* minimum of 2 GB in output */ - return gbMask; -} - -/* lose FBITS_LOST_DCT4_64 in DCT4, gain 6 for implicit scaling by 1/64, lose 1 for cTab multiply (Q31) */ -#define FBITS_OUT_QMFS (FBITS_IN_QMFS - FBITS_LOST_DCT4_64 + 6 - 1) -#define RND_VAL (1 << (FBITS_OUT_QMFS-1)) - -/************************************************************************************** - * Function: QMFSynthesisConv - * - * Description: final convolution kernel for synthesis QMF - * - * Inputs: pointer to coefficient table, reordered for sequential access - * delay buffer of size 64*10 = 640 complex samples (1280 ints) - * index for delay ring buffer (range = [0, 9]) - * number of QMF subbands to process (range = [0, 64]) - * number of channels - * - * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans - * - * Return: none - * - * Notes: this is carefully written to be efficient on ARM - * use the assembly code version in sbrqmfsk.s when building for ARM! - **************************************************************************************/ -#if (defined (_WIN32) && defined (_WIN32_WCE) && defined (ARM)) -#ifdef __cplusplus -extern "C" -#endif -void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans); -#else -void QMFSynthesisConv(int *cPtr, int *delay, int dIdx, short *outbuf, int nChans) -{ - int k, dOff0, dOff1; - U64 sum64; - - dOff0 = (dIdx)*128; - dOff1 = dOff0 - 1; - if (dOff1 < 0) - dOff1 += 1280; - - /* scaling note: total gain of coefs (cPtr[0]-cPtr[9] for any k) is < 2.0, so 1 GB in delay values is adequate */ - for (k = 0; k <= 63; k++) { - sum64.w64 = 0; - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff0]); dOff0 -= 256; if (dOff0 < 0) {dOff0 += 1280;} - sum64.w64 = MADD64(sum64.w64, *cPtr++, delay[dOff1]); dOff1 -= 256; if (dOff1 < 0) {dOff1 += 1280;} - - dOff0++; - dOff1--; - *outbuf = CLIPTOSHORT((sum64.r.hi32 + RND_VAL) >> FBITS_OUT_QMFS); - outbuf += nChans; - } -} -#endif - -/************************************************************************************** - * Function: QMFSynthesis - * - * Description: 64-subband synthesis QMF (4.6.18.4.2) - * - * Inputs: 64 consecutive complex subband QMF samples, format = Q(FBITS_IN_QMFS) - * delay buffer of size 64*10 = 640 complex samples (1280 ints) - * index for delay ring buffer (range = [0, 9]) - * number of QMF subbands to process (range = [0, 64]) - * number of channels - * - * Outputs: 64 consecutive 16-bit PCM samples, interleaved by factor of nChans - * updated delay buffer - * updated delay index - * - * Return: none - * - * Notes: assumes MIN_GBITS_IN_QMFS guard bits in input, either from - * QMFAnalysis (if upsampling only) or from MapHF (if SBR on) - **************************************************************************************/ -void QMFSynthesis(int *inbuf, int *delay, int *delayIdx, int qmfsBands, short *outbuf, int nChans) -{ - int n, a0, a1, b0, b1, dOff0, dOff1, dIdx; - int *tBufLo, *tBufHi; - - dIdx = *delayIdx; - tBufLo = delay + dIdx*128 + 0; - tBufHi = delay + dIdx*128 + 127; - - /* reorder inputs to DCT-IV, only use first qmfsBands (complex) samples - * TODO - fuse with PreMultiply64 to avoid separate reordering steps - */ - for (n = 0; n < qmfsBands >> 1; n++) { - a0 = *inbuf++; - b0 = *inbuf++; - a1 = *inbuf++; - b1 = *inbuf++; - *tBufLo++ = a0; - *tBufLo++ = a1; - *tBufHi-- = b0; - *tBufHi-- = b1; - } - if (qmfsBands & 0x01) { - a0 = *inbuf++; - b0 = *inbuf++; - *tBufLo++ = a0; - *tBufHi-- = b0; - *tBufLo++ = 0; - *tBufHi-- = 0; - n++; - } - for ( ; n < 32; n++) { - *tBufLo++ = 0; - *tBufHi-- = 0; - *tBufLo++ = 0; - *tBufHi-- = 0; - } - - tBufLo = delay + dIdx*128 + 0; - tBufHi = delay + dIdx*128 + 64; - - /* 2 GB in, 3 GB out */ - PreMultiply64(tBufLo); - PreMultiply64(tBufHi); - - /* 3 GB in, 1 GB out */ - FFT32C(tBufLo); - FFT32C(tBufHi); - - /* 1 GB in, 2 GB out */ - PostMultiply64(tBufLo, 64); - PostMultiply64(tBufHi, 64); - - /* could fuse with PostMultiply64 to avoid separate pass */ - dOff0 = dIdx*128; - dOff1 = dIdx*128 + 64; - for (n = 32; n != 0; n--) { - a0 = (*tBufLo++); - a1 = (*tBufLo++); - b0 = (*tBufHi++); - b1 = -(*tBufHi++); - - delay[dOff0++] = (b0 - a0); - delay[dOff0++] = (b1 - a1); - delay[dOff1++] = (b0 + a0); - delay[dOff1++] = (b1 + a1); - } - - QMFSynthesisConv((int *)cTabS, delay, dIdx, outbuf, nChans); - - *delayIdx = (*delayIdx == NUM_QMF_DELAY_BUFS - 1 ? 0 : *delayIdx + 1); -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrside.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrside.c deleted file mode 100644 index 6bb49f31..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrside.c +++ /dev/null @@ -1,575 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrside.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrside.c - functions for unpacking side info from SBR bitstream - **************************************************************************************/ - -#include "sbr.h" - -/************************************************************************************** - * Function: GetSampRateIdx - * - * Description: get index of given sample rate - * - * Inputs: sample rate (in Hz) - * - * Outputs: none - * - * Return: index of sample rate (table 1.15 in 14496-3:2001(E)) - * -1 if sample rate not found in table - **************************************************************************************/ -int GetSampRateIdx(int sampRate) -{ - int idx; - - for (idx = 0; idx < NUM_SAMPLE_RATES; idx++) { - if (sampRate == sampRateTab[idx]) - return idx; - } - - return -1; -} - -/************************************************************************************** - * Function: UnpackSBRHeader - * - * Description: unpack SBR header (table 4.56) - * - * Inputs: BitStreamInfo struct pointing to start of SBR header - * - * Outputs: initialized SBRHeader struct for this SCE/CPE block - * - * Return: non-zero if frame reset is triggered, zero otherwise - **************************************************************************************/ -int UnpackSBRHeader(BitStreamInfo *bsi, SBRHeader *sbrHdr) -{ - SBRHeader sbrHdrPrev; - - /* save previous values so we know whether to reset decoder */ - sbrHdrPrev.startFreq = sbrHdr->startFreq; - sbrHdrPrev.stopFreq = sbrHdr->stopFreq; - sbrHdrPrev.freqScale = sbrHdr->freqScale; - sbrHdrPrev.alterScale = sbrHdr->alterScale; - sbrHdrPrev.crossOverBand = sbrHdr->crossOverBand; - sbrHdrPrev.noiseBands = sbrHdr->noiseBands; - - sbrHdr->ampRes = GetBits(bsi, 1); - sbrHdr->startFreq = GetBits(bsi, 4); - sbrHdr->stopFreq = GetBits(bsi, 4); - sbrHdr->crossOverBand = GetBits(bsi, 3); - sbrHdr->resBitsHdr = GetBits(bsi, 2); - sbrHdr->hdrExtra1 = GetBits(bsi, 1); - sbrHdr->hdrExtra2 = GetBits(bsi, 1); - - if (sbrHdr->hdrExtra1) { - sbrHdr->freqScale = GetBits(bsi, 2); - sbrHdr->alterScale = GetBits(bsi, 1); - sbrHdr->noiseBands = GetBits(bsi, 2); - } else { - /* defaults */ - sbrHdr->freqScale = 2; - sbrHdr->alterScale = 1; - sbrHdr->noiseBands = 2; - } - - if (sbrHdr->hdrExtra2) { - sbrHdr->limiterBands = GetBits(bsi, 2); - sbrHdr->limiterGains = GetBits(bsi, 2); - sbrHdr->interpFreq = GetBits(bsi, 1); - sbrHdr->smoothMode = GetBits(bsi, 1); - } else { - /* defaults */ - sbrHdr->limiterBands = 2; - sbrHdr->limiterGains = 2; - sbrHdr->interpFreq = 1; - sbrHdr->smoothMode = 1; - } - sbrHdr->count++; - - /* if any of these have changed from previous frame, reset the SBR module */ - if (sbrHdr->startFreq != sbrHdrPrev.startFreq || sbrHdr->stopFreq != sbrHdrPrev.stopFreq || - sbrHdr->freqScale != sbrHdrPrev.freqScale || sbrHdr->alterScale != sbrHdrPrev.alterScale || - sbrHdr->crossOverBand != sbrHdrPrev.crossOverBand || sbrHdr->noiseBands != sbrHdrPrev.noiseBands - ) - return -1; - else - return 0; -} - -/* cLog2[i] = ceil(log2(i)) (disregard i == 0) */ -static const unsigned char cLog2[9] = {0, 0, 1, 2, 2, 3, 3, 3, 3}; - -/************************************************************************************** - * Function: UnpackSBRGrid - * - * Description: unpack SBR grid (table 4.62) - * - * Inputs: BitStreamInfo struct pointing to start of SBR grid - * initialized SBRHeader struct for this SCE/CPE block - * - * Outputs: initialized SBRGrid struct for this channel - * - * Return: none - **************************************************************************************/ -static void UnpackSBRGrid(BitStreamInfo *bsi, SBRHeader *sbrHdr, SBRGrid *sbrGrid) -{ - int numEnvRaw, env, rel, pBits, border, middleBorder=0; - unsigned char relBordLead[MAX_NUM_ENV], relBordTrail[MAX_NUM_ENV]; - unsigned char relBorder0[3], relBorder1[3], relBorder[3]; - unsigned char numRelBorder0, numRelBorder1, numRelBorder, numRelLead=0, numRelTrail; - unsigned char absBordLead=0, absBordTrail=0, absBorder; - - sbrGrid->ampResFrame = sbrHdr->ampRes; - sbrGrid->frameClass = GetBits(bsi, 2); - switch (sbrGrid->frameClass) { - - case SBR_GRID_FIXFIX: - numEnvRaw = GetBits(bsi, 2); - sbrGrid->numEnv = (1 << numEnvRaw); - if (sbrGrid->numEnv == 1) - sbrGrid->ampResFrame = 0; - - ASSERT(sbrGrid->numEnv == 1 || sbrGrid->numEnv == 2 || sbrGrid->numEnv == 4); - - sbrGrid->freqRes[0] = GetBits(bsi, 1); - for (env = 1; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = sbrGrid->freqRes[0]; - - absBordLead = 0; - absBordTrail = NUM_TIME_SLOTS; - numRelLead = sbrGrid->numEnv - 1; - numRelTrail = 0; - - /* numEnv = 1, 2, or 4 */ - if (sbrGrid->numEnv == 1) border = NUM_TIME_SLOTS / 1; - else if (sbrGrid->numEnv == 2) border = NUM_TIME_SLOTS / 2; - else border = NUM_TIME_SLOTS / 4; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = border; - - middleBorder = (sbrGrid->numEnv >> 1); - - break; - - case SBR_GRID_FIXVAR: - absBorder = GetBits(bsi, 2) + NUM_TIME_SLOTS; - numRelBorder = GetBits(bsi, 2); - sbrGrid->numEnv = numRelBorder + 1; - for (rel = 0; rel < numRelBorder; rel++) - relBorder[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[sbrGrid->numEnv + 1]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = sbrGrid->numEnv - 1; env >= 0; env--) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - absBordLead = 0; - absBordTrail = absBorder; - numRelLead = 0; - numRelTrail = numRelBorder; - - for (rel = 0; rel < numRelTrail; rel++) - relBordTrail[rel] = relBorder[rel]; - - if (sbrGrid->pointer > 1) middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer; - else middleBorder = sbrGrid->numEnv - 1; - - break; - - case SBR_GRID_VARFIX: - absBorder = GetBits(bsi, 2); - numRelBorder = GetBits(bsi, 2); - sbrGrid->numEnv = numRelBorder + 1; - for (rel = 0; rel < numRelBorder; rel++) - relBorder[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[sbrGrid->numEnv + 1]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = 0; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - absBordLead = absBorder; - absBordTrail = NUM_TIME_SLOTS; - numRelLead = numRelBorder; - numRelTrail = 0; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = relBorder[rel]; - - if (sbrGrid->pointer == 0) middleBorder = 1; - else if (sbrGrid->pointer == 1) middleBorder = sbrGrid->numEnv - 1; - else middleBorder = sbrGrid->pointer - 1; - - break; - - case SBR_GRID_VARVAR: - absBordLead = GetBits(bsi, 2); /* absBorder0 */ - absBordTrail = GetBits(bsi, 2) + NUM_TIME_SLOTS; /* absBorder1 */ - numRelBorder0 = GetBits(bsi, 2); - numRelBorder1 = GetBits(bsi, 2); - - sbrGrid->numEnv = numRelBorder0 + numRelBorder1 + 1; - ASSERT(sbrGrid->numEnv <= 5); - - for (rel = 0; rel < numRelBorder0; rel++) - relBorder0[rel] = 2*GetBits(bsi, 2) + 2; - - for (rel = 0; rel < numRelBorder1; rel++) - relBorder1[rel] = 2*GetBits(bsi, 2) + 2; - - pBits = cLog2[numRelBorder0 + numRelBorder1 + 2]; - sbrGrid->pointer = GetBits(bsi, pBits); - - for (env = 0; env < sbrGrid->numEnv; env++) - sbrGrid->freqRes[env] = GetBits(bsi, 1); - - numRelLead = numRelBorder0; - numRelTrail = numRelBorder1; - - for (rel = 0; rel < numRelLead; rel++) - relBordLead[rel] = relBorder0[rel]; - - for (rel = 0; rel < numRelTrail; rel++) - relBordTrail[rel] = relBorder1[rel]; - - if (sbrGrid->pointer > 1) middleBorder = sbrGrid->numEnv + 1 - sbrGrid->pointer; - else middleBorder = sbrGrid->numEnv - 1; - - break; - } - - /* build time border vector */ - sbrGrid->envTimeBorder[0] = absBordLead * SAMPLES_PER_SLOT; - - rel = 0; - border = absBordLead; - for (env = 1; env <= numRelLead; env++) { - border += relBordLead[rel++]; - sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT; - } - - rel = 0; - border = absBordTrail; - for (env = sbrGrid->numEnv - 1; env > numRelLead; env--) { - border -= relBordTrail[rel++]; - sbrGrid->envTimeBorder[env] = border * SAMPLES_PER_SLOT; - } - - sbrGrid->envTimeBorder[sbrGrid->numEnv] = absBordTrail * SAMPLES_PER_SLOT; - - if (sbrGrid->numEnv > 1) { - sbrGrid->numNoiseFloors = 2; - sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0]; - sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[middleBorder]; - sbrGrid->noiseTimeBorder[2] = sbrGrid->envTimeBorder[sbrGrid->numEnv]; - } else { - sbrGrid->numNoiseFloors = 1; - sbrGrid->noiseTimeBorder[0] = sbrGrid->envTimeBorder[0]; - sbrGrid->noiseTimeBorder[1] = sbrGrid->envTimeBorder[1]; - } -} - -/************************************************************************************** - * Function: UnpackDeltaTimeFreq - * - * Description: unpack time/freq flags for delta coding of SBR envelopes (table 4.63) - * - * Inputs: BitStreamInfo struct pointing to start of dt/df flags - * number of envelopes - * number of noise floors - * - * Outputs: delta flags for envelope and noise floors - * - * Return: none - **************************************************************************************/ -static void UnpackDeltaTimeFreq(BitStreamInfo *bsi, int numEnv, unsigned char *deltaFlagEnv, - int numNoiseFloors, unsigned char *deltaFlagNoise) -{ - int env, noiseFloor; - - for (env = 0; env < numEnv; env++) - deltaFlagEnv[env] = GetBits(bsi, 1); - - for (noiseFloor = 0; noiseFloor < numNoiseFloors; noiseFloor++) - deltaFlagNoise[noiseFloor] = GetBits(bsi, 1); -} - -/************************************************************************************** - * Function: UnpackInverseFilterMode - * - * Description: unpack invf flags for chirp factor calculation (table 4.64) - * - * Inputs: BitStreamInfo struct pointing to start of invf flags - * number of noise floor bands - * - * Outputs: invf flags for noise floor bands - * - * Return: none - **************************************************************************************/ -static void UnpackInverseFilterMode(BitStreamInfo *bsi, int numNoiseFloorBands, unsigned char *mode) -{ - int n; - - for (n = 0; n < numNoiseFloorBands; n++) - mode[n] = GetBits(bsi, 2); -} - -/************************************************************************************** - * Function: UnpackSinusoids - * - * Description: unpack sinusoid (harmonic) flags for each SBR subband (table 4.67) - * - * Inputs: BitStreamInfo struct pointing to start of sinusoid flags - * number of high resolution SBR subbands (nHigh) - * - * Outputs: sinusoid flags for each SBR subband, zero-filled above nHigh - * - * Return: none - **************************************************************************************/ -static void UnpackSinusoids(BitStreamInfo *bsi, int nHigh, int addHarmonicFlag, unsigned char *addHarmonic) -{ - int n; - - n = 0; - if (addHarmonicFlag) { - for ( ; n < nHigh; n++) - addHarmonic[n] = GetBits(bsi, 1); - } - - /* zero out unused bands */ - for ( ; n < MAX_QMF_BANDS; n++) - addHarmonic[n] = 0; -} - -/************************************************************************************** - * Function: CopyCouplingGrid - * - * Description: copy grid parameters from left to right for channel coupling - * - * Inputs: initialized SBRGrid struct for left channel - * - * Outputs: initialized SBRGrid struct for right channel - * - * Return: none - **************************************************************************************/ -static void CopyCouplingGrid(SBRGrid *sbrGridLeft, SBRGrid *sbrGridRight) -{ - int env, noiseFloor; - - sbrGridRight->frameClass = sbrGridLeft->frameClass; - sbrGridRight->ampResFrame = sbrGridLeft->ampResFrame; - sbrGridRight->pointer = sbrGridLeft->pointer; - - sbrGridRight->numEnv = sbrGridLeft->numEnv; - for (env = 0; env < sbrGridLeft->numEnv; env++) { - sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; - sbrGridRight->freqRes[env] = sbrGridLeft->freqRes[env]; - } - sbrGridRight->envTimeBorder[env] = sbrGridLeft->envTimeBorder[env]; /* borders are [0, numEnv] inclusive */ - - sbrGridRight->numNoiseFloors = sbrGridLeft->numNoiseFloors; - for (noiseFloor = 0; noiseFloor <= sbrGridLeft->numNoiseFloors; noiseFloor++) - sbrGridRight->noiseTimeBorder[noiseFloor] = sbrGridLeft->noiseTimeBorder[noiseFloor]; - - /* numEnvPrev, numNoiseFloorsPrev, freqResPrev are updated in DecodeSBREnvelope() and DecodeSBRNoise() */ -} - -/************************************************************************************** - * Function: CopyCouplingInverseFilterMode - * - * Description: copy invf flags from left to right for channel coupling - * - * Inputs: invf flags for left channel - * number of noise floor bands - * - * Outputs: invf flags for right channel - * - * Return: none - **************************************************************************************/ -static void CopyCouplingInverseFilterMode(int numNoiseFloorBands, unsigned char *modeLeft, unsigned char *modeRight) -{ - int band; - - for (band = 0; band < numNoiseFloorBands; band++) - modeRight[band] = modeLeft[band]; -} - -/************************************************************************************** - * Function: UnpackSBRSingleChannel - * - * Description: unpack sideband info (grid, delta flags, invf flags, envelope and - * noise floor configuration, sinusoids) for a single channel - * - * Inputs: BitStreamInfo struct pointing to start of sideband info - * initialized PSInfoSBR struct (after parsing SBR header and building - * frequency tables) - * base output channel (range = [0, nChans-1]) - * - * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan) - * - * Return: none - **************************************************************************************/ -void UnpackSBRSingleChannel(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase) -{ - int bitsLeft; - SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]); - SBRGrid *sbrGridL = &(psi->sbrGrid[chBase+0]); - SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]); - SBRChan *sbrChanL = &(psi->sbrChan[chBase+0]); - - psi->dataExtra = GetBits(bsi, 1); - if (psi->dataExtra) - psi->resBitsData = GetBits(bsi, 4); - - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - - sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]); - - psi->extendedDataPresent = GetBits(bsi, 1); - if (psi->extendedDataPresent) { - psi->extendedDataSize = GetBits(bsi, 4); - if (psi->extendedDataSize == 15) - psi->extendedDataSize += GetBits(bsi, 8); - - bitsLeft = 8 * psi->extendedDataSize; - - /* get ID, unpack extension info, do whatever is necessary with it... */ - while (bitsLeft > 0) { - GetBits(bsi, 8); - bitsLeft -= 8; - } - } -} - -/************************************************************************************** - * Function: UnpackSBRChannelPair - * - * Description: unpack sideband info (grid, delta flags, invf flags, envelope and - * noise floor configuration, sinusoids) for a channel pair - * - * Inputs: BitStreamInfo struct pointing to start of sideband info - * initialized PSInfoSBR struct (after parsing SBR header and building - * frequency tables) - * base output channel (range = [0, nChans-1]) - * - * Outputs: updated PSInfoSBR struct (SBRGrid and SBRChan for both channels) - * - * Return: none - **************************************************************************************/ -void UnpackSBRChannelPair(BitStreamInfo *bsi, PSInfoSBR *psi, int chBase) -{ - int bitsLeft; - SBRHeader *sbrHdr = &(psi->sbrHdr[chBase]); - SBRGrid *sbrGridL = &(psi->sbrGrid[chBase+0]), *sbrGridR = &(psi->sbrGrid[chBase+1]); - SBRFreq *sbrFreq = &(psi->sbrFreq[chBase]); - SBRChan *sbrChanL = &(psi->sbrChan[chBase+0]), *sbrChanR = &(psi->sbrChan[chBase+1]); - - psi->dataExtra = GetBits(bsi, 1); - if (psi->dataExtra) { - psi->resBitsData = GetBits(bsi, 4); - psi->resBitsData = GetBits(bsi, 4); - } - - psi->couplingFlag = GetBits(bsi, 1); - if (psi->couplingFlag) { - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - CopyCouplingGrid(sbrGridL, sbrGridR); - - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise); - - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - CopyCouplingInverseFilterMode(sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1], sbrChanR->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - - /* pass RIGHT sbrChan struct */ - UncoupleSBREnvelope(psi, sbrGridL, sbrFreq, sbrChanR); - UncoupleSBRNoise(psi, sbrGridL, sbrFreq, sbrChanR); - - } else { - UnpackSBRGrid(bsi, sbrHdr, sbrGridL); - UnpackSBRGrid(bsi, sbrHdr, sbrGridR); - UnpackDeltaTimeFreq(bsi, sbrGridL->numEnv, sbrChanL->deltaFlagEnv, sbrGridL->numNoiseFloors, sbrChanL->deltaFlagNoise); - UnpackDeltaTimeFreq(bsi, sbrGridR->numEnv, sbrChanR->deltaFlagEnv, sbrGridR->numNoiseFloors, sbrChanR->deltaFlagNoise); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanL->invfMode[1]); - UnpackInverseFilterMode(bsi, sbrFreq->numNoiseFloorBands, sbrChanR->invfMode[1]); - - DecodeSBREnvelope(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBREnvelope(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - DecodeSBRNoise(bsi, psi, sbrGridL, sbrFreq, sbrChanL, 0); - DecodeSBRNoise(bsi, psi, sbrGridR, sbrFreq, sbrChanR, 1); - } - - sbrChanL->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanL->addHarmonicFlag[1], sbrChanL->addHarmonic[1]); - - sbrChanR->addHarmonicFlag[1] = GetBits(bsi, 1); - UnpackSinusoids(bsi, sbrFreq->nHigh, sbrChanR->addHarmonicFlag[1], sbrChanR->addHarmonic[1]); - - psi->extendedDataPresent = GetBits(bsi, 1); - if (psi->extendedDataPresent) { - psi->extendedDataSize = GetBits(bsi, 4); - if (psi->extendedDataSize == 15) - psi->extendedDataSize += GetBits(bsi, 8); - - bitsLeft = 8 * psi->extendedDataSize; - - /* get ID, unpack extension info, do whatever is necessary with it... */ - while (bitsLeft > 0) { - GetBits(bsi, 8); - bitsLeft -= 8; - } - } -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/sbrtabs.c b/components/spotify/cspot/bell/external/libhelix-aac/sbrtabs.c deleted file mode 100644 index 01da8617..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/sbrtabs.c +++ /dev/null @@ -1,400 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: sbrtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * sbrtabs.c - platform-independent tables for SBR (global, read-only) - **************************************************************************************/ - -#include "sbr.h" - -/* k0Tab[sampRateIdx][k] = k0 = startMin + offset(bs_start_freq) for given sample rate (4.6.18.3.2.1) - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char k0Tab[NUM_SAMPLE_RATES_SBR][16] = { - { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 96 kHz */ - { 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 31 }, /* 88 kHz */ - { 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 23, 26, 30 }, /* 64 kHz */ - { 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 27, 31 }, /* 48 kHz */ - { 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 25, 28, 32 }, /* 44 kHz */ - { 10, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 32 kHz */ - { 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 27, 29, 32 }, /* 24 kHz */ - { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 28, 30 }, /* 22 kHz */ - { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, /* 16 kHz */ -}; - -/* k2Tab[sampRateIdx][k] = stopVector(bs_stop_freq) for given sample rate, bs_stop_freq = [0, 13] (4.6.18.3.2.1) - * generated with Matlab script calc_stopvec.m - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char k2Tab[NUM_SAMPLE_RATES_SBR][14] = { - { 13, 15, 17, 19, 21, 24, 27, 31, 35, 39, 44, 50, 57, 64 }, /* 96 kHz */ - { 15, 17, 19, 21, 23, 26, 29, 33, 37, 41, 46, 51, 57, 64 }, /* 88 kHz */ - { 20, 22, 24, 26, 28, 31, 34, 37, 41, 45, 49, 54, 59, 64 }, /* 64 kHz */ - { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59, 64 }, /* 48 kHz */ - { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64 }, /* 44 kHz */ - { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 32 kHz */ - { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61, 64 }, /* 24 kHz */ - { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61, 64 }, /* 22 kHz */ - { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 64 }, /* 16 kHz */ -}; - -/* NINT(2.048E6 / Fs) (figure 4.47) - * downsampled (single-rate) SBR not currently supported - */ -const unsigned char goalSBTab[NUM_SAMPLE_RATES_SBR] = { - 21, 23, 32, 43, 46, 64, 85, 93, 128 -}; - -const HuffInfo huffTabSBRInfo[10] PROGMEM = { - {19, { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 2, 7, 4, 8, 72, 0}, 0}, - {20, { 0, 2, 2, 2, 2, 2, 1, 3, 3, 2, 4, 4, 4, 3, 2, 5, 6, 13, 15, 46}, 121}, - {17, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 0, 0, 1, 25, 10, 0, 0, 0}, 242}, - {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 3, 1, 0, 1, 1, 2, 1, 29, 2, 0}, 291}, - {19, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 5, 1, 4, 2, 3, 34, 0}, 340}, - {20, { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 1, 2, 3, 4, 4, 7, 10, 16}, 403}, - {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 13, 2, 0, 0, 0, 0, 0, 0}, 466}, - {14, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 6, 8, 0, 0, 0, 0, 0, 0}, 491}, - {14, { 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 0, 51, 2, 0, 0, 0, 0, 0, 0}, 516}, - { 8, { 1, 1, 1, 0, 1, 1, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 579}, -}; - -/* Huffman tables from appendix 4.A.6.1, includes offset of -LAV[i] for table i */ -const signed int /*short*/ huffTabSBR[604] PROGMEM = { - /* SBR table sbr_tenv15 [121] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, - -9, 8, -10, 9, -11, 10, -12, -13, 11, -14, 12, -15, -16, 13, -19, -18, - -17, 14, -24, -20, 16, -26, -21, 15, -23, -25, -22, -60, -59, -58, -57, -56, - -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, - -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, - /* SBR table sbr_fenv15 [121] (signed) */ - 0, -1, 1, -2, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7, - -9, 8, -10, 9, -11, 10, 11, -12, 12, -13, 13, 14, -14, -15, 15, 16, - 17, -16, -17, -18, -19, 18, 19, -20, -21, 20, 21, -24, -23, -22, -26, -28, - 22, 23, 25, -41, -25, 26, 27, -30, -27, 24, 28, 44, -51, -46, -44, -43, - -37, -33, -31, -29, 30, 37, 42, 47, 48, -60, -59, -58, -57, -56, -55, -54, - -53, -52, -50, -49, -48, -47, -45, -42, -40, -39, -38, -36, -35, -34, -32, 29, - 31, 32, 33, 34, 35, 36, 38, 39, 40, 41, 43, 45, 46, 49, 50, 51, - 52, 53, 54, 55, 56, 57, 58, 59, 60, - /* SBR table sbr_tenv15b [49] (signed) */ - 0, 1, -1, 2, -2, 3, -3, 4, -4, -5, 5, -6, 6, 7, -7, 8, - -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, - -8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, - /* SBR table sbr_fenv15b [49] (signed) */ - 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, -6, 6, -7, 7, 8, - -9, -8, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, - -10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, - /* SBR table sbr_tenv30 [63] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, -7, 6, -8, 7, - -9, -10, 8, 9, 10, -13, -11, -12, -14, 11, 12, -31, -30, -29, -28, -27, - -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_fenv30 [63] (signed) */ - 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, - 8, 9, -9, -10, 10, 11, -11, -12, 12, 13, -13, -15, 14, 15, -14, 18, - -18, -24, -19, 16, 17, -22, -21, -16, 20, 21, 22, 25, -23, -20, 24, -31, - -30, -29, -28, -27, -26, -25, -17, 19, 23, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_tenv30b [25] (signed) */ - 0, 1, -1, -2, 2, 3, -3, -4, 4, -5, -12, -11, -10, -9, -8, -7, - -6, 5, 6, 7, 8, 9, 10, 11, 12, - /* SBR table sbr_fenv30b [25] (signed) */ - 0, -1, 1, -2, 2, 3, -3, -4, 4, -5, 5, 6, -12, -11, -10, -9, - -8, -7, -6, 7, 8, 9, 10, 11, 12, - /* SBR table sbr_tnoise30 [63] (signed) */ - 0, 1, -1, -2, 2, -3, 3, -4, 4, -5, 5, 11, -31, -30, -29, -28, - -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, - -11, -10, -9, -8, -7, -6, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - /* SBR table sbr_tnoise30b [25] (signed) */ - 0, -1, 1, -2, 2, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, -}; - -/* log2Tab[x] = floor(log2(x)), format = Q28 */ -const int log2Tab[65] PROGMEM = { - 0x00000000, 0x00000000, 0x10000000, 0x195c01a3, 0x20000000, 0x25269e12, 0x295c01a3, 0x2ceaecfe, - 0x30000000, 0x32b80347, 0x35269e12, 0x3759d4f8, 0x395c01a3, 0x3b350047, 0x3ceaecfe, 0x3e829fb6, - 0x40000000, 0x41663f6f, 0x42b80347, 0x43f782d7, 0x45269e12, 0x4646eea2, 0x4759d4f8, 0x48608280, - 0x495c01a3, 0x4a4d3c25, 0x4b350047, 0x4c1404ea, 0x4ceaecfe, 0x4dba4a47, 0x4e829fb6, 0x4f446359, - 0x50000000, 0x50b5d69b, 0x51663f6f, 0x52118b11, 0x52b80347, 0x5359ebc5, 0x53f782d7, 0x549101ea, - 0x55269e12, 0x55b88873, 0x5646eea2, 0x56d1fafd, 0x5759d4f8, 0x57dea15a, 0x58608280, 0x58df988f, - 0x595c01a3, 0x59d5d9fd, 0x5a4d3c25, 0x5ac24113, 0x5b350047, 0x5ba58feb, 0x5c1404ea, 0x5c80730b, - 0x5ceaecfe, 0x5d53847a, 0x5dba4a47, 0x5e1f4e51, 0x5e829fb6, 0x5ee44cd5, 0x5f446359, 0x5fa2f045, - 0x60000000 -}; - -/* coefficient table 4.A.87, format = Q31 - * reordered as: - * cTab[0], cTab[64], cTab[128], cTab[192], cTab[256], - * cTab[2], cTab[66], cTab[130], cTab[194], cTab[258], - * ... - * cTab[64], cTab[128], cTab[192], cTab[256], cTab[320] - * - * NOTE: cTab[1, 2, ... , 318, 319] = cTab[639, 638, ... 322, 321] - * except cTab[384] = -cTab[256], cTab[512] = -cTab[128] - */ -const int cTabA[165] PROGMEM = { - 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, - 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, - 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, - 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, - 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, - 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, - 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, - 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, - 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, - 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, - 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, - 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, - 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, - 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, - 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, - 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, - 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, -}; - -/* coefficient table 4.A.87, format = Q31 - * reordered as cTab[0], cTab[64], cTab[128], ... cTab[576], cTab[1], cTab[65], cTab[129], ... cTab[639] - * keeping full table (not using symmetry) to allow sequential access in synth filter inner loop - * format = Q31 - */ -const int cTabS[640] PROGMEM = { - 0x00000000, 0x0055dba1, 0x01b2e41d, 0x09015651, 0x2e3a7532, 0x6d474e1d, 0xd1c58ace, 0x09015651, 0xfe4d1be3, 0x0055dba1, - 0xffede50e, 0x005b5371, 0x01d78bfc, 0x08d3e41b, 0x2faa221c, 0x6d41d963, 0xd3337b3d, 0x09299ead, 0xfe70b8d1, 0x0050b177, - 0xffed978a, 0x006090c4, 0x01fd3ba0, 0x08a24899, 0x311af3a4, 0x6d32730f, 0xd49fd55f, 0x094d7ec2, 0xfe933dc0, 0x004b6c46, - 0xffefc9b9, 0x0065fde5, 0x02244a24, 0x086b1eeb, 0x328cc6f0, 0x6d18520e, 0xd60a46e5, 0x096d0e21, 0xfeb48d0d, 0x00465348, - 0xfff0065d, 0x006b47fa, 0x024bf7a1, 0x082f552e, 0x33ff670e, 0x6cf4073e, 0xd7722f04, 0x09881dc5, 0xfed4bec3, 0x004103f4, - 0xffeff6ca, 0x0070c8a5, 0x0274ba43, 0x07ee507c, 0x3572ec70, 0x6cc59bab, 0xd8d7f21f, 0x099ec3dc, 0xfef3f6ab, 0x003c1fa4, - 0xffef7b8b, 0x0075fded, 0x029e35b4, 0x07a8127d, 0x36e69691, 0x6c8c4c7a, 0xda3b176a, 0x09b18a1d, 0xff120d70, 0x003745f9, - 0xffeedfa4, 0x007b3875, 0x02c89901, 0x075ca90c, 0x385a49c4, 0x6c492217, 0xdb9b5b12, 0x09c018ce, 0xff2ef725, 0x00329ab6, - 0xffee1650, 0x00807994, 0x02f3e48d, 0x070bbf58, 0x39ce0477, 0x6bfbdd98, 0xdcf898fb, 0x09caeb0f, 0xff4aabc8, 0x002d8e42, - 0xffed651d, 0x0085c217, 0x03201116, 0x06b559c3, 0x3b415115, 0x6ba4629f, 0xde529086, 0x09d1fa23, 0xff6542d1, 0x00293718, - 0xffecc31b, 0x008a7dd7, 0x034d01f0, 0x06593912, 0x3cb41219, 0x6b42a864, 0xdfa93ab5, 0x09d5560b, 0xff7ee3f1, 0x0024dd50, - 0xffebe77b, 0x008f4bfc, 0x037ad438, 0x05f7fb90, 0x3e25b17e, 0x6ad73e8d, 0xe0fc421e, 0x09d52709, 0xff975c01, 0x002064f8, - 0xffeb50b2, 0x009424c6, 0x03a966bb, 0x0590a67d, 0x3f962fb8, 0x6a619c5e, 0xe24b8f66, 0x09d19ca9, 0xffaea5d6, 0x001c3549, - 0xffea9192, 0x0098b855, 0x03d8afe6, 0x05237f9d, 0x41058bc6, 0x69e29784, 0xe396a45d, 0x09cab9f2, 0xffc4e365, 0x0018703f, - 0xffe9ca76, 0x009d10bf, 0x04083fec, 0x04b0adcb, 0x4272a385, 0x6959709d, 0xe4de0cb0, 0x09c0e59f, 0xffda17f2, 0x001471f8, - 0xffe940f4, 0x00a1039c, 0x043889c6, 0x0437fb0a, 0x43de620a, 0x68c7269b, 0xe620c476, 0x09b3d77f, 0xffee183b, 0x0010bc63, - 0xffe88ba8, 0x00a520bb, 0x04694101, 0x03b8f8dc, 0x4547daea, 0x682b39a4, 0xe75f8bb8, 0x09a3e163, 0x0000e790, 0x000d31b5, - 0xffe83a07, 0x00a8739d, 0x049aa82f, 0x03343533, 0x46aea856, 0x6785c24d, 0xe89971b7, 0x099140a7, 0x00131c75, 0x0009aa3f, - 0xffe79e16, 0x00abe79e, 0x04cc2fcf, 0x02a99097, 0x4812f848, 0x66d76725, 0xe9cea84a, 0x097c1ee8, 0x0023b989, 0x0006b1cf, - 0xffe7746e, 0x00af374c, 0x04fe20be, 0x02186a91, 0x4973fef1, 0x661fd6b8, 0xeafee7f1, 0x0963ed46, 0x0033b927, 0x00039609, - 0xffe6d466, 0x00b1978d, 0x05303f87, 0x01816e06, 0x4ad237a2, 0x655f63f2, 0xec2a3f5f, 0x0949eaac, 0x00426f36, 0x00007134, - 0xffe6afee, 0x00b3d15c, 0x05626209, 0x00e42fa2, 0x4c2ca3df, 0x64964063, 0xed50a31d, 0x092d7970, 0x00504f41, 0xfffdfa25, - 0xffe65416, 0x00b5c867, 0x05950122, 0x0040c496, 0x4d83976c, 0x63c45243, 0xee71b2fe, 0x090ec1fc, 0x005d36df, 0xfffb42b0, - 0xffe681c6, 0x00b74c37, 0x05c76fed, 0xff96db90, 0x4ed62be3, 0x62ea6474, 0xef8d4d7b, 0x08edfeaa, 0x006928a0, 0xfff91fca, - 0xffe66dd0, 0x00b8394b, 0x05f9c051, 0xfee723c6, 0x5024d70e, 0x6207f220, 0xf0a3959f, 0x08cb4e23, 0x007400b8, 0xfff681d6, - 0xffe66fac, 0x00b8fe0d, 0x062bf5ec, 0xfe310657, 0x516eefb9, 0x611d58a3, 0xf1b461ab, 0x08a75da4, 0x007e0393, 0xfff48700, - 0xffe69423, 0x00b8c6b0, 0x065dd56a, 0xfd7475d8, 0x52b449de, 0x602b0c7f, 0xf2bf6ea4, 0x0880ffdd, 0x00872c63, 0xfff294c3, - 0xffe6fed4, 0x00b85f70, 0x068f8b44, 0xfcb1d740, 0x53f495aa, 0x5f30ff5f, 0xf3c4e887, 0x08594887, 0x008f87aa, 0xfff0e7ef, - 0xffe75361, 0x00b73ab0, 0x06c0f0c0, 0xfbe8f5bd, 0x552f8ff7, 0x5e2f6367, 0xf4c473c6, 0x08303897, 0x0096dcc2, 0xffef2395, - 0xffe80414, 0x00b58c8c, 0x06f1825d, 0xfb19b7bd, 0x56654bdd, 0x5d26be9b, 0xf5be0fa9, 0x08061671, 0x009da526, 0xffedc418, - 0xffe85b4b, 0x00b36acd, 0x0721bf22, 0xfa44a069, 0x579505f5, 0x5c16d0ae, 0xf6b1f3c3, 0x07da2b7f, 0x00a3508f, 0xffec8409, - 0xffe954d0, 0x00b06b68, 0x075112a2, 0xf96916f5, 0x58befacd, 0x5b001db8, 0xf79fa13a, 0x07ad8c26, 0x00a85e94, 0xffeb3849, - 0xffea353a, 0x00acbd2f, 0x077fedb3, 0xf887507c, 0x59e2f69e, 0x59e2f69e, 0xf887507c, 0x077fedb3, 0x00acbd2f, 0xffea353a, - 0xffeb3849, 0x00a85e94, 0x07ad8c26, 0xf79fa13a, 0x5b001db8, 0x58befacd, 0xf96916f5, 0x075112a2, 0x00b06b68, 0xffe954d0, - 0xffec8409, 0x00a3508f, 0x07da2b7f, 0xf6b1f3c3, 0x5c16d0ae, 0x579505f5, 0xfa44a069, 0x0721bf22, 0x00b36acd, 0xffe85b4b, - 0xffedc418, 0x009da526, 0x08061671, 0xf5be0fa9, 0x5d26be9b, 0x56654bdd, 0xfb19b7bd, 0x06f1825d, 0x00b58c8c, 0xffe80414, - 0xffef2395, 0x0096dcc2, 0x08303897, 0xf4c473c6, 0x5e2f6367, 0x552f8ff7, 0xfbe8f5bd, 0x06c0f0c0, 0x00b73ab0, 0xffe75361, - 0xfff0e7ef, 0x008f87aa, 0x08594887, 0xf3c4e887, 0x5f30ff5f, 0x53f495aa, 0xfcb1d740, 0x068f8b44, 0x00b85f70, 0xffe6fed4, - 0xfff294c3, 0x00872c63, 0x0880ffdd, 0xf2bf6ea4, 0x602b0c7f, 0x52b449de, 0xfd7475d8, 0x065dd56a, 0x00b8c6b0, 0xffe69423, - 0xfff48700, 0x007e0393, 0x08a75da4, 0xf1b461ab, 0x611d58a3, 0x516eefb9, 0xfe310657, 0x062bf5ec, 0x00b8fe0d, 0xffe66fac, - 0xfff681d6, 0x007400b8, 0x08cb4e23, 0xf0a3959f, 0x6207f220, 0x5024d70e, 0xfee723c6, 0x05f9c051, 0x00b8394b, 0xffe66dd0, - 0xfff91fca, 0x006928a0, 0x08edfeaa, 0xef8d4d7b, 0x62ea6474, 0x4ed62be3, 0xff96db90, 0x05c76fed, 0x00b74c37, 0xffe681c6, - 0xfffb42b0, 0x005d36df, 0x090ec1fc, 0xee71b2fe, 0x63c45243, 0x4d83976c, 0x0040c496, 0x05950122, 0x00b5c867, 0xffe65416, - 0xfffdfa25, 0x00504f41, 0x092d7970, 0xed50a31d, 0x64964063, 0x4c2ca3df, 0x00e42fa2, 0x05626209, 0x00b3d15c, 0xffe6afee, - 0x00007134, 0x00426f36, 0x0949eaac, 0xec2a3f5f, 0x655f63f2, 0x4ad237a2, 0x01816e06, 0x05303f87, 0x00b1978d, 0xffe6d466, - 0x00039609, 0x0033b927, 0x0963ed46, 0xeafee7f1, 0x661fd6b8, 0x4973fef1, 0x02186a91, 0x04fe20be, 0x00af374c, 0xffe7746e, - 0x0006b1cf, 0x0023b989, 0x097c1ee8, 0xe9cea84a, 0x66d76725, 0x4812f848, 0x02a99097, 0x04cc2fcf, 0x00abe79e, 0xffe79e16, - 0x0009aa3f, 0x00131c75, 0x099140a7, 0xe89971b7, 0x6785c24d, 0x46aea856, 0x03343533, 0x049aa82f, 0x00a8739d, 0xffe83a07, - 0x000d31b5, 0x0000e790, 0x09a3e163, 0xe75f8bb8, 0x682b39a4, 0x4547daea, 0x03b8f8dc, 0x04694101, 0x00a520bb, 0xffe88ba8, - 0x0010bc63, 0xffee183b, 0x09b3d77f, 0xe620c476, 0x68c7269b, 0x43de620a, 0x0437fb0a, 0x043889c6, 0x00a1039c, 0xffe940f4, - 0x001471f8, 0xffda17f2, 0x09c0e59f, 0xe4de0cb0, 0x6959709d, 0x4272a385, 0x04b0adcb, 0x04083fec, 0x009d10bf, 0xffe9ca76, - 0x0018703f, 0xffc4e365, 0x09cab9f2, 0xe396a45d, 0x69e29784, 0x41058bc6, 0x05237f9d, 0x03d8afe6, 0x0098b855, 0xffea9192, - 0x001c3549, 0xffaea5d6, 0x09d19ca9, 0xe24b8f66, 0x6a619c5e, 0x3f962fb8, 0x0590a67d, 0x03a966bb, 0x009424c6, 0xffeb50b2, - 0x002064f8, 0xff975c01, 0x09d52709, 0xe0fc421e, 0x6ad73e8d, 0x3e25b17e, 0x05f7fb90, 0x037ad438, 0x008f4bfc, 0xffebe77b, - 0x0024dd50, 0xff7ee3f1, 0x09d5560b, 0xdfa93ab5, 0x6b42a864, 0x3cb41219, 0x06593912, 0x034d01f0, 0x008a7dd7, 0xffecc31b, - 0x00293718, 0xff6542d1, 0x09d1fa23, 0xde529086, 0x6ba4629f, 0x3b415115, 0x06b559c3, 0x03201116, 0x0085c217, 0xffed651d, - 0x002d8e42, 0xff4aabc8, 0x09caeb0f, 0xdcf898fb, 0x6bfbdd98, 0x39ce0477, 0x070bbf58, 0x02f3e48d, 0x00807994, 0xffee1650, - 0x00329ab6, 0xff2ef725, 0x09c018ce, 0xdb9b5b12, 0x6c492217, 0x385a49c4, 0x075ca90c, 0x02c89901, 0x007b3875, 0xffeedfa4, - 0x003745f9, 0xff120d70, 0x09b18a1d, 0xda3b176a, 0x6c8c4c7a, 0x36e69691, 0x07a8127d, 0x029e35b4, 0x0075fded, 0xffef7b8b, - 0x003c1fa4, 0xfef3f6ab, 0x099ec3dc, 0xd8d7f21f, 0x6cc59bab, 0x3572ec70, 0x07ee507c, 0x0274ba43, 0x0070c8a5, 0xffeff6ca, - 0x004103f4, 0xfed4bec3, 0x09881dc5, 0xd7722f04, 0x6cf4073e, 0x33ff670e, 0x082f552e, 0x024bf7a1, 0x006b47fa, 0xfff0065d, - 0x00465348, 0xfeb48d0d, 0x096d0e21, 0xd60a46e5, 0x6d18520e, 0x328cc6f0, 0x086b1eeb, 0x02244a24, 0x0065fde5, 0xffefc9b9, - 0x004b6c46, 0xfe933dc0, 0x094d7ec2, 0xd49fd55f, 0x6d32730f, 0x311af3a4, 0x08a24899, 0x01fd3ba0, 0x006090c4, 0xffed978a, - 0x0050b177, 0xfe70b8d1, 0x09299ead, 0xd3337b3d, 0x6d41d963, 0x2faa221c, 0x08d3e41b, 0x01d78bfc, 0x005b5371, 0xffede50f, -}; - -/* noise table 4.A.88, format = Q31 */ -const int noiseTab[512*2] PROGMEM = { - 0x8010fd38, 0xb3dc7948, 0x7c4e2301, 0xa9904192, 0x121622a7, 0x86489625, 0xc3d53d25, 0xd0343fa9, - 0x674d6f70, 0x25f4e9fd, 0xce1a8c8b, 0x72a726c5, 0xfea6efc6, 0xaa4adb1a, 0x8b2dd628, 0xf14029e4, - 0x46321c1a, 0x604889a0, 0x33363b63, 0x815ed069, 0x802b4315, 0x8f2bf7f3, 0x85b86073, 0x745cfb46, - 0xc57886b3, 0xb76731f0, 0xa2a66772, 0x828ca631, 0x60cc145e, 0x1ad1010f, 0x090c83d4, 0x9bd7ba87, - 0x5f5aeea2, 0x8b4dbd99, 0x848e7b1e, 0x86bb9fa2, 0x26f18ae5, 0xc0b81194, 0x553407bf, 0x52c17953, - 0x755f468d, 0x166b04f8, 0xa5687981, 0x4343248b, 0xa6558d5e, 0xc5f6fab7, 0x80a4fb8c, 0x8cb53cb7, - 0x7da68a54, 0x9cd8df8a, 0xba05376c, 0xfcb58ee2, 0xfdd657a4, 0x005e35ca, 0x91c75c55, 0x367651e6, - 0x816abf85, 0x8f831c4f, 0x423f9c9c, 0x55aa919e, 0x80779834, 0xb59f4244, 0x800a095c, 0x7de9e0cc, - 0x46bda5cb, 0x4c184464, 0x2c438f71, 0x797216b5, 0x5035cee6, 0xa0c3a26e, 0x9d3f95fa, 0xd4a100c0, - 0x8ac30dac, 0x04b87397, 0x9e5ac516, 0x8b0b442e, 0x66210ad6, 0x88ba7598, 0x45b9bd33, 0xf0be5087, - 0x9261b85e, 0x364f6a31, 0x891c4b50, 0x23ad08ce, 0xf10366a6, 0x80414276, 0x1b562e06, 0x8be21591, - 0x9e798195, 0x7fb4045c, 0x7d9506cf, 0x854e691f, 0x9207f092, 0x7a94c9d5, 0x88911536, 0x3f45cc61, - 0x27059279, 0xa5b57109, 0x6d2bb67b, 0x3bdc5379, 0x74e662d8, 0x80348f8c, 0xf875e638, 0x5a8caea1, - 0x2459ae75, 0x2c54b939, 0x79ee3203, 0xb9bc8683, 0x9b6f630c, 0x9f45b351, 0x8563b2b9, 0xe5dbba41, - 0x697c7d0d, 0x7bb7c90e, 0xac900866, 0x8e6b5177, 0x8822dd37, 0x7fd5a91e, 0x7506da05, 0x82302aca, - 0xa5e4be04, 0x4b4288eb, 0x00b8bc9f, 0x4f1033e4, 0x7200d612, 0x43900c8c, 0xa815b900, 0x676ed1d4, - 0x5c5f23b2, 0xa758ee11, 0xaf73abfa, 0x11714ec0, 0x265239e0, 0xc50de679, 0x8a84e341, 0xa1438354, - 0x7f1a341f, 0x343ec96b, 0x696e71b0, 0xa13bde39, 0x81e75094, 0x80091111, 0x853a73bf, 0x80f9c1ee, - 0xe4980086, 0x886a8e28, 0xa7e89426, 0xdd93edd7, 0x7592100d, 0x0bfa8123, 0x850a26d4, 0x2e34f395, - 0x421b6c00, 0xa4a462e4, 0x4e3f5090, 0x3c189f4c, 0x3c971a56, 0xdd0376d2, 0x747a5367, 0x7bcbc9d7, - 0x3966be6a, 0x7efda616, 0x55445e15, 0x7ba2ab3f, 0x5fe684f2, 0x8cf42af9, 0x808c61c3, 0x4390c27b, - 0x7cac62ff, 0xea6cab22, 0x5d0902ad, 0xc27b7208, 0x7a27389d, 0x5820a357, 0xa29bbe59, 0x9df0f1fd, - 0x92bd67e5, 0x7195b587, 0x97cac65b, 0x8339807e, 0x8f72d832, 0x5fad8685, 0xa462d9d3, 0x81d46214, - 0x6ae93e1d, 0x6b23a5b9, 0xc2732874, 0x81795268, 0x7c568cb6, 0x668513ea, 0x428d024e, 0x66b78b3a, - 0xfee9ef03, 0x9ddcbb82, 0xa605f07e, 0x46dc55e0, 0x85415054, 0xc89ec271, 0x7c42edfb, 0x0befe59b, - 0x89b8f607, 0x6d732a1a, 0xa7081ebd, 0x7e403258, 0x21feeb7b, 0x5dd7a1e7, 0x23e3a31a, 0x129bc896, - 0xa11a6b54, 0x7f1e031c, 0xfdc1a4d1, 0x96402e53, 0xb9700f1a, 0x8168ecd6, 0x7d63d3cc, 0x87a70d65, - 0x81075a7a, 0x55c8caa7, 0xa95d00b5, 0x102b1652, 0x0bb30215, 0xe5b63237, 0xa446ca44, 0x82d4c333, - 0x67b2e094, 0x44c3d661, 0x33fd6036, 0xde1ea2a1, 0xa95e8e47, 0x78f66eb9, 0x6f2aef1e, 0xe8887247, - 0x80a3b70e, 0xfca0d9d3, 0x6bf0fd20, 0x0d5226de, 0xf4341c87, 0x5902df05, 0x7ff1a38d, 0xf02e5a5b, - 0x99f129af, 0x8ac63d01, 0x7b53f599, 0x7bb32532, 0x99ac59b0, 0x5255a80f, 0xf1320a41, 0x2497aa5c, - 0xcce60bd8, 0x787c634b, 0x7ed58c5b, 0x8a28eb3a, 0x24a5e647, 0x8b79a2c1, 0x955f5ce5, 0xa9d12bc4, - 0x7a1e20c6, 0x3eeda7ac, 0xf7be823a, 0x042924ce, 0x808b3f03, 0x364248da, 0xac2895e5, 0x69a8b5fa, - 0x97fe8b63, 0xbdeac9aa, 0x8073e0ad, 0x6c25dba7, 0x005e51d2, 0x52e74389, 0x59d3988c, 0xe5d1f39c, - 0x7b57dc91, 0x341adbe7, 0xa7d42b8d, 0x74e9f335, 0xd35bf7d8, 0x5b7c0a4b, 0x75bc0874, 0x552129bf, - 0x8144b70d, 0x6de93bbb, 0x5825f14b, 0x473ec5ca, 0x80a8f37c, 0xe6552d69, 0x7898360b, 0x806379b0, - 0xa9b59339, 0x3f6bf60c, 0xc367d731, 0x920ade99, 0x125592f7, 0x877e5ed1, 0xda895d95, 0x075f2ece, - 0x380e5f5e, 0x9b006b62, 0xd17a6dd2, 0x530a0e13, 0xf4cc9a14, 0x7d0a0ed4, 0x847c6e3f, 0xbaee4975, - 0x47131163, 0x64fb2cac, 0x5e2100a6, 0x7b756a42, 0xd87609f4, 0x98bfe48c, 0x0493745e, 0x836c5784, - 0x7e5ccb40, 0x3df6b476, 0x97700d28, 0x8bbd93fd, 0x56de9cdb, 0x680b4e65, 0xebc3d90e, 0x6d286793, - 0x6753712e, 0xe05c98a7, 0x3d2b6b85, 0xc4b18ddb, 0x7b59b869, 0x31435688, 0x811888e9, 0xe011ee7a, - 0x6a5844f9, 0x86ae35ea, 0xb4cbc10b, 0x01a6f5d6, 0x7a49ed64, 0x927caa49, 0x847ddaed, 0xae0d9bb6, - 0x836bdb04, 0x0fd810a6, 0x74fe126b, 0x4a346b5f, 0x80184d36, 0x5afd153c, 0x90cc8102, 0xe606d0e6, - 0xde69aa58, 0xa89f1222, 0xe06df715, 0x8fd16144, 0x0317c3e8, 0x22ce92fc, 0x690c3eca, 0x93166f02, - 0x71573414, 0x8d43cffb, 0xe8bd0bb6, 0xde86770f, 0x0bf99a41, 0x4633a661, 0xba064108, 0x7adafae3, - 0x2f6cde5d, 0xb350a52c, 0xa5ebfb0b, 0x74c57b46, 0xd3b603b5, 0x80b70892, 0xa7f7fa53, 0xd94b566c, - 0xdda3fd86, 0x6a635793, 0x3ed005ca, 0xc5f087d8, 0x31e3a746, 0x7a4278f9, 0x82def1f9, 0x06caa2b2, - 0xe9d2c349, 0x8940e7f7, 0x7feef8dd, 0x4a9b01f0, 0xacde69f8, 0x57ddc280, 0xf09e4ba4, 0xb6d9f729, - 0xb48c18f2, 0xd3654aa9, 0xca7a03c8, 0x14d57545, 0x7fda87a5, 0x0e411366, 0xb77d0df0, 0x8c2aa467, - 0x787f2590, 0x2d292db1, 0x9f12682c, 0x44ac364d, 0x1a4b31a6, 0x871f7ded, 0x7ff99167, 0x6630a1d5, - 0x25385eb9, 0x2d4dd549, 0xaf8a7004, 0x319ebe0f, 0x379ab730, 0x81dc56a4, 0x822d8523, 0x1ae8554c, - 0x18fa0786, 0x875f7de4, 0x85ca350f, 0x7de818dc, 0x7786a38f, 0xa5456355, 0x92e60f88, 0xf5526122, - 0x916039bc, 0xc561e2de, 0x31c42042, 0x7c82e290, 0x75d158b2, 0xb015bda1, 0x7220c750, 0x46565441, - 0xd0da1fdd, 0x7b777481, 0x782e73c6, 0x8cd72b7b, 0x7f1006aa, 0xfb30e51e, 0x87994818, 0x34e7c7db, - 0x7faae06b, 0xea74fbc0, 0xd20c7af4, 0xc44f396b, 0x06b4234e, 0xdf2e2a93, 0x2efb07c8, 0xce861911, - 0x7550ea05, 0xd8d90bbb, 0x58522eec, 0x746b3520, 0xce844ce9, 0x7f5cacc3, 0xda8f17e0, 0x2fedf9cb, - 0xb2f77ec4, 0x6f13f4c0, 0x834de085, 0x7b7ace4b, 0x713b16ac, 0x499c5ab0, 0x06a7961d, 0x1b39a48a, - 0xbb853e6e, 0x7c781cc1, 0xc0baebf5, 0x7dace394, 0x815ceebc, 0xcc7b27d4, 0x8274b181, 0xa2be40a2, - 0xdd01d5dc, 0x7fefeb14, 0x0813ec78, 0xba3077cc, 0xe5cf1e1c, 0xedcfacae, 0x54c43a9b, 0x5cd62a42, - 0x93806b55, 0x03095c5b, 0x8e076ae3, 0x71bfcd2a, 0x7ac1989b, 0x623bc71a, 0x5e15d4d2, 0xfb341dd1, - 0xd75dfbca, 0xd0da32be, 0xd4569063, 0x337869da, 0x3d30606a, 0xcd89cca2, 0x7dd2ae36, 0x028c03cd, - 0xd85e052c, 0xe8dc9ec5, 0x7ffd9241, 0xde5bf4c6, 0x88c4b235, 0x8228be2e, 0x7fe6ec64, 0x996abe6a, - 0xdeb0666d, 0x9eb86611, 0xd249b922, 0x18b3e26b, 0x80211168, 0x5f8bb99c, 0x6ecb0dd2, 0x4728ff8d, - 0x2ac325b8, 0x6e5169d2, 0x7ebbd68d, 0x05e41d17, 0xaaa19f28, 0x8ab238a6, 0x51f105be, 0x140809cc, - 0x7f7345d9, 0x3aae5a9d, 0xaecec6e4, 0x1afb3473, 0xf6229ed1, 0x8d55f467, 0x7e32003a, 0x70f30c14, - 0x6686f33f, 0xd0d45ed8, 0x644fab57, 0x3a3fbbd3, 0x0b255fc4, 0x679a1701, 0x90e17b6e, 0x325d537b, - 0xcd7b9b87, 0xaa7be2a2, 0x7d47c966, 0xa33dbce5, 0x8659c3bb, 0x72a41367, 0x15c446e0, 0x45fe8b0a, - 0x9d8ddf26, 0x84d47643, 0x7fabe0da, 0x36a70122, 0x7a28ebfe, 0x7c29b8b8, 0x7f760406, 0xbabe4672, - 0x23ea216e, 0x92bcc50a, 0x6d20dba2, 0xad5a7c7e, 0xbf3897f5, 0xabb793e1, 0x8391fc7e, 0xe270291c, - 0x7a248d58, 0x80f8fd15, 0x83ef19f3, 0x5e6ece7d, 0x278430c1, 0x35239f4d, 0xe09c073b, 0x50e78cb5, - 0xd4b811bd, 0xce834ee0, 0xf88aaa34, 0xf71da5a9, 0xe2b0a1d5, 0x7c3aef31, 0xe84eabca, 0x3ce25964, - 0xf29336d3, 0x8fa78b2c, 0xa3fc3415, 0x63e1313d, 0x7fbc74e0, 0x7340bc93, 0x49ae583b, 0x8b79de4b, - 0x25011ce9, 0x7b462279, 0x36007db0, 0x3da1599c, 0x77780772, 0xc845c9bb, 0x83ba68be, 0x6ee507d1, - 0x2f0159b8, 0x5392c4ed, 0x98336ff6, 0x0b3c7f11, 0xde697aac, 0x893fc8d0, 0x6b83f8f3, 0x47799a0d, - 0x801d9dfc, 0x8516a83e, 0x5f8d22ec, 0x0f8ba384, 0xa049dc4b, 0xdd920b05, 0x7a99bc9f, 0x9ad19344, - 0x7a345dba, 0xf501a13f, 0x3e58bf19, 0x7fffaf9a, 0x3b4e1511, 0x0e08b991, 0x9e157620, 0x7230a326, - 0x4977f9ff, 0x2d2bbae1, 0x607aa7fc, 0x7bc85d5f, 0xb441bbbe, 0x8d8fa5f2, 0x601cce26, 0xda1884f2, - 0x81c82d64, 0x200b709c, 0xcbd36abe, 0x8cbdddd3, 0x55ab61d3, 0x7e3ee993, 0x833f18aa, 0xffc1aaea, - 0x7362e16a, 0x7fb85db2, 0x904ee04c, 0x7f04dca6, 0x8ad7a046, 0xebe7d8f7, 0xfbc4c687, 0xd0609458, - 0x093ed977, 0x8e546085, 0x7f5b8236, 0x7c47e118, 0xa01f2641, 0x7ffb3e48, 0x05de7cda, 0x7fc281b9, - 0x8e0278fc, 0xd74e6d07, 0x94c24450, 0x7cf9e641, 0x2ad27871, 0x919fa815, 0x805fd205, 0x7758397f, - 0xe2c7e02c, 0x1828e194, 0x5613d6fe, 0xfb55359f, 0xf9699516, 0x8978ee26, 0x7feebad9, 0x77d71d82, - 0x55b28b60, 0x7e997600, 0x80821a6b, 0xc6d78af1, 0x691822ab, 0x7f6982a0, 0x7ef56f99, 0x5c307f40, - 0xac6f8b76, 0x42cc8ba4, 0x782c61d9, 0xa0224dd0, 0x7bd234d1, 0x74576e3b, 0xe38cfe9a, 0x491e66ef, - 0xc78291c5, 0x895bb87f, 0x924f7889, 0x71b89394, 0x757b779d, 0xc4a9c604, 0x5cdf7829, 0x8020e9df, - 0x805e8245, 0x4a82c398, 0x6360bd62, 0x78bb60fc, 0x09e0d014, 0x4b0ea180, 0xb841978b, 0x69a0e864, - 0x7df35977, 0x3284b0dd, 0x3cdc2efd, 0x57d31f5e, 0x541069cc, 0x1776e92e, 0x04309ea3, 0xa015eb2d, - 0xce7bfabc, 0x41b638f8, 0x8365932e, 0x846ab44c, 0xbbcc80cb, 0x8afa6cac, 0x7fc422ea, 0x4e403fc0, - 0xbfac9aee, 0x8e4c6709, 0x028e01fb, 0x6d160a9b, 0x7fe93004, 0x790f9cdc, 0x6a1f37a0, 0xf7e7ef30, - 0xb4ea0f04, 0x7bf4c8e6, 0xe981701f, 0xc258a9d3, 0x6acbbfba, 0xef5479c7, 0x079c8bd8, 0x1a410f56, - 0x6853b799, 0x86cd4f01, 0xc66e23b6, 0x34585565, 0x8d1fe00d, 0x7fcdba1a, 0x32c9717b, 0xa02f9f48, - 0xf64940db, 0x5ed7d8f1, 0x61b823b2, 0x356f8918, 0xa0a7151e, 0x793fc969, 0x530beaeb, 0x34e93270, - 0x4fc4ddb5, 0x88d58b6c, 0x36094774, 0xf620ac80, 0x03763a72, 0xf910c9a6, 0x6666fb2d, 0x752c8be8, - 0x9a6dfdd8, 0xd1a7117d, 0x51c1b1d4, 0x0a67773d, 0x43b32a79, 0x4cdcd085, 0x5f067d30, 0x05bfe92a, - 0x7ed7d203, 0xe71a3c85, 0x99127ce2, 0x8eb3cac4, 0xad4bbcea, 0x5c6a0fd0, 0x0eec04af, 0x94e95cd4, - 0x8654f921, 0x83eabb5d, 0xb058d7ca, 0x69f12d3c, 0x03d881b2, 0x80558ef7, 0x82938cb3, 0x2ec0e1d6, - 0x80044422, 0xd1e47051, 0x720fc6ff, 0x82b20316, 0x0d527b02, 0x63049a15, 0x7ad5b9ad, 0xd2a4641d, - 0x41144f86, 0x7b04917a, 0x15c4a2c0, 0x9da07916, 0x211df54a, 0x7fdd09af, 0xfe924f3f, 0x7e132cfe, - 0x9a1d18d6, 0x7c56508b, 0x80f0f0af, 0x8095ced6, 0x8037d0d7, 0x026719d1, 0xa55fec43, 0x2b1c7cb7, - 0xa5cd5ac1, 0x77639fad, 0x7fcd8b62, 0x81a18c27, 0xaee4912e, 0xeae9eebe, 0xeb3081de, 0x8532aada, - 0xc822362e, 0x86a649a9, 0x8031a71d, 0x7b319dc6, 0xea8022e6, 0x814bc5a9, 0x8f62f7a1, 0xa430ea17, - 0x388deafb, 0x883b5185, 0x776fe13c, 0x801c683f, 0x87c11b98, 0xb7cbc644, 0x8e9ad3e8, 0x3cf5a10c, - 0x7ff6a634, 0x949ef096, 0x9f84aa7c, 0x010af13f, 0x782d1de8, 0xf18e492a, 0x6cf63b01, 0x4301cd81, - 0x32d15c9e, 0x68ad8cef, 0xd09bd2d6, 0x908c5c15, 0xd1e36260, 0x2c5bfdd0, 0x88765a99, 0x93deba1e, - 0xac6ae342, 0xe865b84c, 0x0f4f2847, 0x7fdf0499, 0x78b1c9b3, 0x6a73261e, 0x601a96f6, 0xd2847933, - 0x489aa888, 0xe12e8093, 0x3bfa5a5f, 0xd96ba5f7, 0x7c8f4c8d, 0x80940c6f, 0xcef9dd1a, 0x7e1a055f, - 0x3483558b, 0x02b59cc4, 0x0c56333e, 0x05a5b813, 0x92d66287, 0x7516b679, 0x71bfe03f, 0x8056bf68, - 0xc24d0724, 0x8416bcf3, 0x234afbdb, 0x4b0d6f9c, 0xaba97333, 0x4b4f42b6, 0x7e8343ab, 0x7ffe2603, - 0xe590f73c, 0x45e10c76, 0xb07a6a78, 0xb35609d3, 0x1a027dfd, 0x90cb6e20, 0x82d3fe38, 0x7b409257, - 0x0e395afa, 0x1b802093, 0xcb0c6c59, 0x241e17e7, 0x1ee3ea0a, 0x41a82302, 0xab04350a, 0xf570beb7, - 0xbb444b9b, 0x83021459, 0x838d65dc, 0x1c439c84, 0x6fdcc454, 0xef9ef325, 0x18626c1c, 0x020d251f, - 0xc4aae786, 0x8614cb48, 0xf6f53ca6, 0x8710dbab, 0x89abec0d, 0xf29d41c1, 0x94b50336, 0xfdd49178, - 0x604658d1, 0x800e85be, 0xca1bb079, 0x7fa48eeb, 0xa3b7fafe, 0xd330436b, 0x64eb604c, 0x43a658ae, - 0x7caa1337, 0xddd445e6, 0x7efbf955, 0xb706ec71, 0x624a6b53, 0x9e0e231f, 0x97097248, 0xa1e1a17a, - 0x68dd2e44, 0x7f9d2e14, 0xddcc7074, 0x58324197, 0xc88fc426, 0x6d3640ae, 0x7ef83600, 0x759a0270, - 0x98b6d854, 0xd63c9b84, 0x372474a2, 0xe3f18cfd, 0x56ab0bdb, 0x85c9be7e, 0x47dfcfeb, 0xa5830d41, - 0x0ddd6283, 0xf4f480ad, 0x74c60e38, 0xab8943c3, 0xc1508fe7, 0x480cdc39, 0x8e097362, 0xa44793be, - 0x538b7e18, 0x545f5b41, 0x56529175, 0x9771a97e, 0xc2da7421, 0xea8265f2, 0x805d1163, 0x883c5d28, - 0x8ba94c48, 0x4f676e65, 0xf78735b3, 0xe1853671, 0x7f454f53, 0x18147f85, 0x7d09e15d, 0xdb4f3494, - 0x795c8973, 0x83310632, 0x85d8061c, 0x9a1a0ebf, 0xc125583c, 0x2a1b1a95, 0x7fd9103f, 0x71e98c72, - 0x40932ed7, 0x91ed227a, 0x3c5e560e, 0xe816dee9, 0xb0891b80, 0x600038ba, 0xc7d9a80d, 0x7fff5e09, - 0x7e3f4351, 0xbb6b4424, 0xb14448d4, 0x8d6bb7e1, 0xfb153626, 0xa68ad537, 0xd9782006, 0xf62f6991, - 0x359ba8c1, 0x02ccff0b, 0x91bf2256, 0x7ea71c4d, 0x560ce5df, 0xeeba289b, 0xa574c4e7, 0x9e04f6ee, - 0x7860a5ec, 0x0b8db4a2, 0x968ba3d7, 0x0b6c77df, 0xd6f3157d, 0x402eff1a, 0x49b820b3, 0x8152aebb, - 0xd180b0b6, 0x098604d4, 0x7ff92224, 0xede9c996, 0x89c58061, 0x829624c4, 0xc6e71ea7, 0xba94d915, - 0x389c3cf6, 0x5b4c5a06, 0x04b335e6, 0x516a8aab, 0x42c8d7d9, 0x92b12af6, 0x86c8549f, 0xfda98acf, - 0x819673b6, 0x69545dac, 0x6feaa230, 0x726e6d3f, 0x886ebdfe, 0x34f5730a, 0x7af63ba2, 0x77307bbf, - 0x7cd80630, 0x6e45efe0, 0x7f8ad7eb, 0x59d7df99, 0x86c70946, 0xda233629, 0x753f6cbf, 0x825eeb40, -}; diff --git a/components/spotify/cspot/bell/external/libhelix-aac/statname.h b/components/spotify/cspot/bell/external/libhelix-aac/statname.h deleted file mode 100644 index a27f04d5..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/statname.h +++ /dev/null @@ -1,115 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: statname.h,v 1.1 2005/02/26 01:47:34 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * statname.h - name mangling macros for static linking - **************************************************************************************/ - -#ifndef _STATNAME_H -#define _STATNAME_H - -/* define STAT_PREFIX to a unique name for static linking - * all the C functions and global variables will be mangled by the preprocessor - * e.g. void DCT4(...) becomes void raac_DCT4(...) - */ -#define STAT_PREFIX raac - -#define STATCC1(x,y,z) STATCC2(x,y,z) -#define STATCC2(x,y,z) x##y##z - -#ifdef STAT_PREFIX -#define STATNAME(func) STATCC1(STAT_PREFIX, _, func) -#else -#define STATNAME(func) func -#endif - -/* these symbols are common to all implementations */ -#define AllocateBuffers STATNAME(AllocateBuffers) -#define FreeBuffers STATNAME(FreeBuffers) -#define ClearBuffer STATNAME(ClearBuffer) - -#define SetRawBlockParams STATNAME(SetRawBlockParams) -#define PrepareRawBlock STATNAME(PrepareRawBlock) -#define FlushCodec STATNAME(FlushCodec) - -#define UnpackADTSHeader STATNAME(UnpackADTSHeader) -#define GetADTSChannelMapping STATNAME(GetADTSChannelMapping) -#define UnpackADIFHeader STATNAME(UnpackADIFHeader) -#define DecodeNextElement STATNAME(DecodeNextElement) -#define DecodeNoiselessData STATNAME(DecodeNoiselessData) -#define Dequantize STATNAME(Dequantize) -#define StereoProcess STATNAME(StereoProcess) -#define DeinterleaveShortBlocks STATNAME(DeinterleaveShortBlocks) -#define PNS STATNAME(PNS) -#define TNSFilter STATNAME(TNSFilter) -#define IMDCT STATNAME(IMDCT) - -#define InitSBR STATNAME(InitSBR) -#define DecodeSBRBitstream STATNAME(DecodeSBRBitstream) -#define DecodeSBRData STATNAME(DecodeSBRData) -#define FreeSBR STATNAME(FreeSBR) -#define FlushCodecSBR STATNAME(FlushCodecSBR) - -/* global ROM tables */ -#define sampRateTab STATNAME(sampRateTab) -#define predSFBMax STATNAME(predSFBMax) -#define channelMapTab STATNAME(channelMapTab) -#define elementNumChans STATNAME(elementNumChans) -#define sfBandTotalShort STATNAME(sfBandTotalShort) -#define sfBandTotalLong STATNAME(sfBandTotalLong) -#define sfBandTabShortOffset STATNAME(sfBandTabShortOffset) -#define sfBandTabShort STATNAME(sfBandTabShort) -#define sfBandTabLongOffset STATNAME(sfBandTabLongOffset) -#define sfBandTabLong STATNAME(sfBandTabLong) -#define tnsMaxBandsShortOffset STATNAME(tnsMaxBandsShortOffset) -#define tnsMaxBandsShort STATNAME(tnsMaxBandsShort) -#define tnsMaxOrderShort STATNAME(tnsMaxOrderShort) -#define tnsMaxBandsLongOffset STATNAME(tnsMaxBandsLongOffset) -#define tnsMaxBandsLong STATNAME(tnsMaxBandsLong) -#define tnsMaxOrderLong STATNAME(tnsMaxOrderLong) - -/* in your implementation's top-level include file (e.g. real\coder.h) you should - * add new #define sym STATNAME(sym) lines for all the - * additional global functions or variables which your - * implementation uses - */ - -#endif /* _STATNAME_H */ diff --git a/components/spotify/cspot/bell/external/libhelix-aac/stproc.c b/components/spotify/cspot/bell/external/libhelix-aac/stproc.c deleted file mode 100644 index 93854e45..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/stproc.c +++ /dev/null @@ -1,246 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: stproc.c,v 1.3 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * stproc.c - mid-side and intensity stereo processing - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -/* pow14[0][i] = -pow(2, i/4.0) - * pow14[1][i] = +pow(2, i/4.0) - * - * i = [0,1,2,3] - * format = Q30 - */ - - -/************************************************************************************** - * Function: StereoProcessGroup - * - * Description: apply mid-side and intensity stereo to group of transform coefficients - * - * Inputs: dequantized transform coefficients for both channels - * pointer to appropriate scalefactor band table - * mid-side mask enabled flag - * buffer with mid-side mask (one bit for each scalefactor band) - * bit offset into mid-side mask buffer - * max coded scalefactor band - * buffer of codebook indices for right channel - * buffer of scalefactors for right channel, range = [0, 256] - * - * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF) - * updated minimum guard bit count for both channels - * - * Return: none - * - * Notes: assume no guard bits in input - * gains 0 int bits - **************************************************************************************/ -static void StereoProcessGroup(int *coefL, int *coefR, const /*short*/ int *sfbTab, - int msMaskPres, unsigned char *msMaskPtr, int msMaskOffset, int maxSFB, - unsigned char *cbRight, short *sfRight, int *gbCurrent) -{ -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" -static const int pow14[2][4] PROGMEM = { - { 0xc0000000, 0xb3e407d7, 0xa57d8666, 0x945d819b }, - { 0x40000000, 0x4c1bf829, 0x5a82799a, 0x6ba27e65 } -}; -#pragma GCC diagnostic pop - - int sfb, width, cbIdx, sf, cl, cr, scalef, scalei; - int gbMaskL, gbMaskR; - unsigned char msMask; - - msMask = (*msMaskPtr++) >> msMaskOffset; - gbMaskL = 0; - gbMaskR = 0; - - for (sfb = 0; sfb < maxSFB; sfb++) { - width = sfbTab[sfb+1] - sfbTab[sfb]; /* assume >= 0 (see sfBandTabLong/sfBandTabShort) */ - cbIdx = cbRight[sfb]; - - if (cbIdx == 14 || cbIdx == 15) { - /* intensity stereo */ - if (msMaskPres == 1 && (msMask & 0x01)) - cbIdx ^= 0x01; /* invert_intensity(): 14 becomes 15, or 15 becomes 14 */ - sf = -sfRight[sfb]; /* negative since we use identity 0.5^(x) = 2^(-x) (see spec) */ - cbIdx &= 0x01; /* choose - or + scale factor */ - scalef = pow14[cbIdx][sf & 0x03]; - scalei = (sf >> 2) + 2; /* +2 to compensate for scalef = Q30 */ - - if (scalei > 0) { - if (scalei > 30) - scalei = 30; - do { - cr = MULSHIFT32(*coefL++, scalef); - CLIP_2N(cr, 31-scalei); - cr <<= scalei; - gbMaskR |= FASTABS(cr); - *coefR++ = cr; - } while (--width); - } else { - scalei = -scalei; - if (scalei > 31) - scalei = 31; - do { - cr = MULSHIFT32(*coefL++, scalef) >> scalei; - gbMaskR |= FASTABS(cr); - *coefR++ = cr; - } while (--width); - } - } else if ( cbIdx != 13 && ((msMaskPres == 1 && (msMask & 0x01)) || msMaskPres == 2) ) { - /* mid-side stereo (assumes no GB in inputs) */ - do { - cl = *coefL; - cr = *coefR; - - if ( (FASTABS(cl) | FASTABS(cr)) >> 30 ) { - /* avoid overflow (rare) */ - cl >>= 1; - sf = cl + (cr >> 1); CLIP_2N(sf, 30); sf <<= 1; - cl = cl - (cr >> 1); CLIP_2N(cl, 30); cl <<= 1; - } else { - /* usual case */ - sf = cl + cr; - cl -= cr; - } - - *coefL++ = sf; - gbMaskL |= FASTABS(sf); - *coefR++ = cl; - gbMaskR |= FASTABS(cl); - } while (--width); - - } else { - /* nothing to do */ - coefL += width; - coefR += width; - } - - /* get next mask bit (should be branchless on ARM) */ - msMask >>= 1; - if (++msMaskOffset == 8) { - msMask = *msMaskPtr++; - msMaskOffset = 0; - } - } - - cl = CLZ(gbMaskL) - 1; - if (gbCurrent[0] > cl) - gbCurrent[0] = cl; - - cr = CLZ(gbMaskR) - 1; - if (gbCurrent[1] > cr) - gbCurrent[1] = cr; - - return; -} - -/************************************************************************************** - * Function: StereoProcess - * - * Description: apply mid-side and intensity stereo, if enabled - * - * Inputs: valid AACDecInfo struct (including dequantized transform coefficients) - * - * Outputs: updated transform coefficients in Q(FBITS_OUT_DQ_OFF) - * updated minimum guard bit count for both channels - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int StereoProcess(AACDecInfo *aacDecInfo) -{ - PSInfoBase *psi; - ICSInfo *icsInfo; - int gp, win, nSamps, msMaskOffset; - int *coefL, *coefR; - unsigned char *msMaskPtr; - const /*short*/ int *sfbTab; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - - /* mid-side and intensity stereo require common_window == 1 (see MPEG4 spec, Correction 2, 2004) */ - if (psi->commonWin != 1 || aacDecInfo->currBlockID != AAC_ID_CPE) - return 0; - - /* nothing to do */ - if (!psi->msMaskPresent && !psi->intensityUsed[1]) - return 0; - - icsInfo = &(psi->icsInfo[0]); - if (icsInfo->winSequence == 2) { - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - nSamps = NSAMPS_SHORT; - } else { - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - nSamps = NSAMPS_LONG; - } - coefL = psi->coef[0]; - coefR = psi->coef[1]; - - /* do fused mid-side/intensity processing for each block (one long or eight short) */ - msMaskOffset = 0; - msMaskPtr = psi->msMaskBits; - for (gp = 0; gp < icsInfo->numWinGroup; gp++) { - for (win = 0; win < icsInfo->winGroupLen[gp]; win++) { - StereoProcessGroup(coefL, coefR, sfbTab, psi->msMaskPresent, - msMaskPtr, msMaskOffset, icsInfo->maxSFB, psi->sfbCodeBook[1] + gp*icsInfo->maxSFB, - psi->scaleFactors[1] + gp*icsInfo->maxSFB, psi->gbCurrent); - coefL += nSamps; - coefR += nSamps; - } - /* we use one bit per sfb, so there are maxSFB bits for each window group */ - msMaskPtr += (msMaskOffset + icsInfo->maxSFB) >> 3; - msMaskOffset = (msMaskOffset + icsInfo->maxSFB) & 0x07; - } - - ASSERT(coefL == psi->coef[0] + 1024); - ASSERT(coefR == psi->coef[1] + 1024); - - return 0; -} diff --git a/components/spotify/cspot/bell/external/libhelix-aac/tns.c b/components/spotify/cspot/bell/external/libhelix-aac/tns.c deleted file mode 100644 index 87726067..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/tns.c +++ /dev/null @@ -1,300 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: tns.c,v 1.2 2005/05/24 16:01:55 albertofloyd Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com) - * February 2005 - * - * tns.c - apply TNS to spectrum - **************************************************************************************/ - -#include "coder.h" -#include "assembly.h" - -#define FBITS_LPC_COEFS 20 - -//fb -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" - -/* inverse quantization tables for TNS filter coefficients, format = Q31 - * see bottom of file for table generation - * negative (vs. spec) since we use MADD for filter kernel - */ -static const int invQuant3[16] PROGMEM = { - 0x00000000, 0xc8767f65, 0x9becf22c, 0x83358feb, 0x83358feb, 0x9becf22c, 0xc8767f65, 0x00000000, - 0x2bc750e9, 0x5246dd49, 0x6ed9eba1, 0x7e0e2e32, 0x7e0e2e32, 0x6ed9eba1, 0x5246dd49, 0x2bc750e9, -}; - -static const int invQuant4[16] PROGMEM = { - 0x00000000, 0xe5632654, 0xcbf00dbe, 0xb4c373ee, 0xa0e0a15f, 0x9126145f, 0x8643c7b3, 0x80b381ac, - 0x7f7437ad, 0x7b1d1a49, 0x7294b5f2, 0x66256db2, 0x563ba8aa, 0x4362210e, 0x2e3d2abb, 0x17851aad, -}; - -#pragma GCC diagnostic pop - -/************************************************************************************** - * Function: DecodeLPCCoefs - * - * Description: decode LPC coefficients for TNS - * - * Inputs: order of TNS filter - * resolution of coefficients (3 or 4 bits) - * coefficients unpacked from bitstream - * scratch buffer (b) of size >= order - * - * Outputs: LPC coefficients in Q(FBITS_LPC_COEFS), in 'a' - * - * Return: none - * - * Notes: assumes no guard bits in input transform coefficients - * a[i] = Q(FBITS_LPC_COEFS), don't store a0 = 1.0 - * (so a[0] = first delay tap, etc.) - * max abs(a[i]) < log2(order), so for max order = 20 a[i] < 4.4 - * (up to 3 bits of gain) so a[i] has at least 31 - FBITS_LPC_COEFS - 3 - * guard bits - * to ensure no intermediate overflow in all-pole filter, set - * FBITS_LPC_COEFS such that number of guard bits >= log2(max order) - **************************************************************************************/ -static void DecodeLPCCoefs(int order, int res, signed char *filtCoef, int *a, int *b) -{ - int i, m, t; - const int *invQuantTab; - - if (res == 3) invQuantTab = invQuant3; - else if (res == 4) invQuantTab = invQuant4; - else return; - - for (m = 0; m < order; m++) { - t = invQuantTab[filtCoef[m] & 0x0f]; /* t = Q31 */ - for (i = 0; i < m; i++) - b[i] = a[i] - (MULSHIFT32(t, a[m-i-1]) << 1); - for (i = 0; i < m; i++) - a[i] = b[i]; - a[m] = t >> (31 - FBITS_LPC_COEFS); - } -} - -/************************************************************************************** - * Function: FilterRegion - * - * Description: apply LPC filter to one region of coefficients - * - * Inputs: number of transform coefficients in this region - * direction flag (forward = 1, backward = -1) - * order of filter - * 'size' transform coefficients - * 'order' LPC coefficients in Q(FBITS_LPC_COEFS) - * scratch buffer for history (must be >= order samples long) - * - * Outputs: filtered transform coefficients - * - * Return: guard bit mask (OR of abs value of all filtered transform coefs) - * - * Notes: assumes no guard bits in input transform coefficients - * gains 0 int bits - * history buffer does not need to be preserved between regions - **************************************************************************************/ -static int FilterRegion(int size, int dir, int order, int *audioCoef, int *a, int *hist) -{ - int i, j, y, hi32, inc, gbMask; - U64 sum64; - - /* init history to 0 every time */ - for (i = 0; i < order; i++) - hist[i] = 0; - - sum64.w64 = 0; /* avoid warning */ - gbMask = 0; - inc = (dir ? -1 : 1); - do { - /* sum64 = a0*y[n] = 1.0*y[n] */ - y = *audioCoef; - sum64.r.hi32 = y >> (32 - FBITS_LPC_COEFS); - sum64.r.lo32 = y << FBITS_LPC_COEFS; - - /* sum64 += (a1*y[n-1] + a2*y[n-2] + ... + a[order-1]*y[n-(order-1)]) */ - for (j = order - 1; j > 0; j--) { - sum64.w64 = MADD64(sum64.w64, hist[j], a[j]); - hist[j] = hist[j-1]; - } - sum64.w64 = MADD64(sum64.w64, hist[0], a[0]); - y = (sum64.r.hi32 << (32 - FBITS_LPC_COEFS)) | (sum64.r.lo32 >> FBITS_LPC_COEFS); - - /* clip output (rare) */ - hi32 = sum64.r.hi32; - if ((hi32 >> 31) != (hi32 >> (FBITS_LPC_COEFS-1))) - y = (hi32 >> 31) ^ 0x7fffffff; - - hist[0] = y; - *audioCoef = y; - audioCoef += inc; - gbMask |= FASTABS(y); - } while (--size); - - return gbMask; -} - -/************************************************************************************** - * Function: TNSFilter - * - * Description: apply temporal noise shaping, if enabled - * - * Inputs: valid AACDecInfo struct - * index of current channel - * - * Outputs: updated transform coefficients - * updated minimum guard bit count for this channel - * - * Return: 0 if successful, -1 if error - **************************************************************************************/ -int TNSFilter(AACDecInfo *aacDecInfo, int ch) -{ - int win, winLen, nWindows, nSFB, filt, bottom, top, order, maxOrder, dir; - int start, end, size, tnsMaxBand, numFilt, gbMask; - int *audioCoef; - unsigned char *filtLength, *filtOrder, *filtRes, *filtDir; - signed char *filtCoef; - const unsigned /*char*/ int *tnsMaxBandTab; - const /*short*/ int *sfbTab; - ICSInfo *icsInfo; - TNSInfo *ti; - PSInfoBase *psi; - - /* validate pointers */ - if (!aacDecInfo || !aacDecInfo->psInfoBase) - return -1; - psi = (PSInfoBase *)(aacDecInfo->psInfoBase); - icsInfo = (ch == 1 && psi->commonWin == 1) ? &(psi->icsInfo[0]) : &(psi->icsInfo[ch]); - ti = &psi->tnsInfo[ch]; - - if (!ti->tnsDataPresent) - return 0; - - if (icsInfo->winSequence == 2) { - nWindows = NWINDOWS_SHORT; - winLen = NSAMPS_SHORT; - nSFB = sfBandTotalShort[psi->sampRateIdx]; - maxOrder = tnsMaxOrderShort[aacDecInfo->profile]; - sfbTab = sfBandTabShort + sfBandTabShortOffset[psi->sampRateIdx]; - tnsMaxBandTab = tnsMaxBandsShort + tnsMaxBandsShortOffset[aacDecInfo->profile]; - tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx]; - } else { - nWindows = NWINDOWS_LONG; - winLen = NSAMPS_LONG; - nSFB = sfBandTotalLong[psi->sampRateIdx]; - maxOrder = tnsMaxOrderLong[aacDecInfo->profile]; - sfbTab = sfBandTabLong + sfBandTabLongOffset[psi->sampRateIdx]; - tnsMaxBandTab = tnsMaxBandsLong + tnsMaxBandsLongOffset[aacDecInfo->profile]; - tnsMaxBand = tnsMaxBandTab[psi->sampRateIdx]; - } - - if (tnsMaxBand > icsInfo->maxSFB) - tnsMaxBand = icsInfo->maxSFB; - - filtRes = ti->coefRes; - filtLength = ti->length; - filtOrder = ti->order; - filtDir = ti->dir; - filtCoef = ti->coef; - - gbMask = 0; - audioCoef = psi->coef[ch]; - for (win = 0; win < nWindows; win++) { - bottom = nSFB; - numFilt = ti->numFilt[win]; - for (filt = 0; filt < numFilt; filt++) { - top = bottom; - bottom = top - *filtLength++; - bottom = MAX(bottom, 0); - order = *filtOrder++; - order = MIN(order, maxOrder); - - if (order) { - start = sfbTab[MIN(bottom, tnsMaxBand)]; - end = sfbTab[MIN(top, tnsMaxBand)]; - size = end - start; - if (size > 0) { - dir = *filtDir++; - if (dir) - start = end - 1; - - DecodeLPCCoefs(order, filtRes[win], filtCoef, psi->tnsLPCBuf, psi->tnsWorkBuf); - gbMask |= FilterRegion(size, dir, order, audioCoef + start, psi->tnsLPCBuf, psi->tnsWorkBuf); - } - filtCoef += order; - } - } - audioCoef += winLen; - } - - /* update guard bit count if necessary */ - size = CLZ(gbMask) - 1; - if (psi->gbCurrent[ch] > size) - psi->gbCurrent[ch] = size; - - return 0; -} - -/* Code to generate invQuantXXX[] tables - * { - * int res, i, t; - * double powScale, iqfac, iqfac_m, d; - * - * powScale = pow(2.0, 31) * -1.0; / ** make coefficients negative for using MADD in kernel ** / - * for (res = 3; res <= 4; res++) { - * iqfac = ( ((1 << (res-1)) - 0.5) * (2.0 / M_PI) ); - * iqfac_m = ( ((1 << (res-1)) + 0.5) * (2.0 / M_PI) ); - * printf("static const int invQuant%d[16] = {\n", res); - * for (i = 0; i < 16; i++) { - * / ** extend bottom 4 bits into signed, 2's complement number ** / - * t = (i << 28) >> 28; - * - * if (t >= 0) d = sin(t / iqfac); - * else d = sin(t / iqfac_m); - * - * d *= powScale; - * printf("0x%08x, ", (int)(d > 0 ? d + 0.5 : d - 0.5)); - * if ((i & 0x07) == 0x07) - * printf("\n"); - * } - * printf("};\n\n"); - * } - * } - */ - diff --git a/components/spotify/cspot/bell/external/libhelix-aac/trigtabs.c b/components/spotify/cspot/bell/external/libhelix-aac/trigtabs.c deleted file mode 100644 index 43012904..00000000 --- a/components/spotify/cspot/bell/external/libhelix-aac/trigtabs.c +++ /dev/null @@ -1,1004 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Source last modified: $Id: trigtabs.c,v 1.1 2005/02/26 01:47:35 jrecker Exp $ - * - * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. - * - * The contents of this file, and the files included with this file, - * are subject to the current version of the RealNetworks Public - * Source License (the "RPSL") available at - * http://www.helixcommunity.org/content/rpsl unless you have licensed - * the file under the current version of the RealNetworks Community - * Source License (the "RCSL") available at - * http://www.helixcommunity.org/content/rcsl, in which case the RCSL - * will apply. You may also obtain the license terms directly from - * RealNetworks. You may not use this file except in compliance with - * the RPSL or, if you have a valid RCSL with RealNetworks applicable - * to this file, the RCSL. Please see the applicable RPSL or RCSL for - * the rights, obligations and limitations governing use of the - * contents of the file. - * - * This file is part of the Helix DNA Technology. RealNetworks is the - * developer of the Original Code and owns the copyrights in the - * portions it created. - * - * This file, and the files included with this file, is distributed - * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY - * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS - * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET - * ENJOYMENT OR NON-INFRINGEMENT. - * - * Technology Compatibility Kit Test Suite(s) Location: - * http://www.helixcommunity.org/content/tck - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ - -/************************************************************************************** - * Fixed-point HE-AAC decoder - * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com) - * February 2005 - * - * trigtabs.c - tables of sin, cos, etc. for IMDCT - **************************************************************************************/ - -#include "coder.h" - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnarrowing" - -const int cos4sin4tabOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* PreMultiply() tables - * format = Q30 * 2^[-7, -10] for nmdct = [128, 1024] - * reordered for sequential access - * - * invM = -1.0 / nmdct; - * for (i = 0; i < nmdct/4; i++) { - * angle = (i + 0.25) * M_PI / nmdct; - * x = invM * (cos(angle) + sin(angle)); - * x = invM * sin(angle); - * - * angle = (nmdct/2 - 1 - i + 0.25) * M_PI / nmdct; - * x = invM * (cos(angle) + sin(angle)); - * x = invM * sin(angle); - * } - */ -const int cos4sin4tab[128 + 1024] PROGMEM = { -/* 128 - format = Q30 * 2^-7 */ -0xbf9bc731, 0xff9b783c, 0xbed5332c, 0xc002c697, 0xbe112251, 0xfe096c8d, 0xbd4f9c30, 0xc00f1c4a, -0xbc90a83f, 0xfc77ae5e, 0xbbd44dd9, 0xc0254e27, 0xbb1a9443, 0xfae67ba2, 0xba6382a6, 0xc04558c0, -0xb9af200f, 0xf9561237, 0xb8fd7373, 0xc06f3726, 0xb84e83ac, 0xf7c6afdc, 0xb7a25779, 0xc0a2e2e3, -0xb6f8f57c, 0xf6389228, 0xb652643e, 0xc0e05401, 0xb5aeaa2a, 0xf4abf67e, 0xb50dcd90, 0xc1278104, -0xb46fd4a4, 0xf3211a07, 0xb3d4c57c, 0xc1785ef4, 0xb33ca614, 0xf19839a6, 0xb2a77c49, 0xc1d2e158, -0xb2154dda, 0xf01191f3, 0xb186206b, 0xc236fa3b, 0xb0f9f981, 0xee8d5f29, 0xb070de82, 0xc2a49a2e, -0xafead4b9, 0xed0bdd25, 0xaf67e14f, 0xc31bb049, 0xaee80952, 0xeb8d475b, 0xae6b51ae, 0xc39c2a2f, -0xadf1bf34, 0xea11d8c8, 0xad7b5692, 0xc425f410, 0xad081c5a, 0xe899cbf1, 0xac9814fd, 0xc4b8f8ad, -0xac2b44cc, 0xe7255ad1, 0xabc1aff9, 0xc555215a, 0xab5b5a96, 0xe5b4bed8, 0xaaf84896, 0xc5fa5603, -0xaa987dca, 0xe44830dd, 0xaa3bfde3, 0xc6a87d2d, 0xa9e2cc73, 0xe2dfe917, 0xa98cece9, 0xc75f7bfe, -0xa93a6296, 0xe17c1f15, 0xa8eb30a7, 0xc81f363d, 0xa89f5a2b, 0xe01d09b4, 0xa856e20e, 0xc8e78e5b, -0xa811cb1b, 0xdec2df18, 0xa7d017fc, 0xc9b86572, 0xa791cb39, 0xdd6dd4a2, 0xa756e73a, 0xca919b4e, -0xa71f6e43, 0xdc1e1ee9, 0xa6eb6279, 0xcb730e70, 0xa6bac5dc, 0xdad3f1b1, 0xa68d9a4c, 0xcc5c9c14, -0xa663e188, 0xd98f7fe6, 0xa63d9d2b, 0xcd4e2037, 0xa61aceaf, 0xd850fb8e, 0xa5fb776b, 0xce47759a, -0xa5df9894, 0xd71895c9, 0xa5c7333e, 0xcf4875ca, 0xa5b2485a, 0xd5e67ec1, 0xa5a0d8b5, 0xd050f926, -0xa592e4fd, 0xd4bae5ab, 0xa5886dba, 0xd160d6e5, 0xa5817354, 0xd395f8ba, 0xa57df60f, 0xd277e518, -/* 1024 - format = Q30 * 2^-10 */ -0xbff3703e, 0xfff36f02, 0xbfda5824, 0xc0000b1a, 0xbfc149ed, 0xffc12b16, 0xbfa845a0, 0xc0003c74, -0xbf8f4b3e, 0xff8ee750, 0xbf765acc, 0xc0009547, 0xbf5d744e, 0xff5ca3d0, 0xbf4497c8, 0xc0011594, -0xbf2bc53d, 0xff2a60b4, 0xbf12fcb2, 0xc001bd5c, 0xbefa3e2a, 0xfef81e1d, 0xbee189a8, 0xc0028c9c, -0xbec8df32, 0xfec5dc28, 0xbeb03eca, 0xc0038356, 0xbe97a875, 0xfe939af5, 0xbe7f1c36, 0xc004a188, -0xbe669a10, 0xfe615aa3, 0xbe4e2209, 0xc005e731, 0xbe35b423, 0xfe2f1b50, 0xbe1d5062, 0xc0075452, -0xbe04f6cb, 0xfdfcdd1d, 0xbdeca760, 0xc008e8e8, 0xbdd46225, 0xfdcaa027, 0xbdbc2720, 0xc00aa4f3, -0xbda3f652, 0xfd98648d, 0xbd8bcfbf, 0xc00c8872, 0xbd73b36d, 0xfd662a70, 0xbd5ba15d, 0xc00e9364, -0xbd439995, 0xfd33f1ed, 0xbd2b9c17, 0xc010c5c7, 0xbd13a8e7, 0xfd01bb24, 0xbcfbc00a, 0xc0131f9b, -0xbce3e182, 0xfccf8634, 0xbccc0d53, 0xc015a0dd, 0xbcb44382, 0xfc9d533b, 0xbc9c8411, 0xc018498c, -0xbc84cf05, 0xfc6b2259, 0xbc6d2461, 0xc01b19a7, 0xbc558428, 0xfc38f3ac, 0xbc3dee5f, 0xc01e112b, -0xbc266309, 0xfc06c754, 0xbc0ee22a, 0xc0213018, 0xbbf76bc4, 0xfbd49d70, 0xbbdfffdd, 0xc024766a, -0xbbc89e77, 0xfba2761e, 0xbbb14796, 0xc027e421, 0xbb99fb3e, 0xfb70517d, 0xbb82b972, 0xc02b7939, -0xbb6b8235, 0xfb3e2fac, 0xbb54558d, 0xc02f35b1, 0xbb3d337b, 0xfb0c10cb, 0xbb261c04, 0xc0331986, -0xbb0f0f2b, 0xfad9f4f8, 0xbaf80cf4, 0xc03724b6, 0xbae11561, 0xfaa7dc52, 0xbaca2878, 0xc03b573f, -0xbab3463b, 0xfa75c6f8, 0xba9c6eae, 0xc03fb11d, 0xba85a1d4, 0xfa43b508, 0xba6edfb1, 0xc044324f, -0xba582849, 0xfa11a6a3, 0xba417b9e, 0xc048dad1, 0xba2ad9b5, 0xf9df9be6, 0xba144291, 0xc04daaa1, -0xb9fdb635, 0xf9ad94f0, 0xb9e734a4, 0xc052a1bb, 0xb9d0bde4, 0xf97b91e1, 0xb9ba51f6, 0xc057c01d, -0xb9a3f0de, 0xf94992d7, 0xb98d9aa0, 0xc05d05c3, 0xb9774f3f, 0xf91797f0, 0xb9610ebe, 0xc06272aa, -0xb94ad922, 0xf8e5a14d, 0xb934ae6d, 0xc06806ce, 0xb91e8ea3, 0xf8b3af0c, 0xb90879c7, 0xc06dc22e, -0xb8f26fdc, 0xf881c14b, 0xb8dc70e7, 0xc073a4c3, 0xb8c67cea, 0xf84fd829, 0xb8b093ea, 0xc079ae8c, -0xb89ab5e8, 0xf81df3c5, 0xb884e2e9, 0xc07fdf85, 0xb86f1af0, 0xf7ec143e, 0xb8595e00, 0xc08637a9, -0xb843ac1d, 0xf7ba39b3, 0xb82e0549, 0xc08cb6f5, 0xb818698a, 0xf7886442, 0xb802d8e0, 0xc0935d64, -0xb7ed5351, 0xf756940a, 0xb7d7d8df, 0xc09a2af3, 0xb7c2698e, 0xf724c92a, 0xb7ad0561, 0xc0a11f9d, -0xb797ac5b, 0xf6f303c0, 0xb7825e80, 0xc0a83b5e, 0xb76d1bd2, 0xf6c143ec, 0xb757e455, 0xc0af7e33, -0xb742b80d, 0xf68f89cb, 0xb72d96fd, 0xc0b6e815, 0xb7188127, 0xf65dd57d, 0xb7037690, 0xc0be7901, -0xb6ee773a, 0xf62c2721, 0xb6d98328, 0xc0c630f2, 0xb6c49a5e, 0xf5fa7ed4, 0xb6afbce0, 0xc0ce0fe3, -0xb69aeab0, 0xf5c8dcb6, 0xb68623d1, 0xc0d615cf, 0xb6716847, 0xf59740e5, 0xb65cb815, 0xc0de42b2, -0xb648133e, 0xf565ab80, 0xb63379c5, 0xc0e69686, 0xb61eebae, 0xf5341ca5, 0xb60a68fb, 0xc0ef1147, -0xb5f5f1b1, 0xf5029473, 0xb5e185d1, 0xc0f7b2ee, 0xb5cd255f, 0xf4d11308, 0xb5b8d05f, 0xc1007b77, -0xb5a486d2, 0xf49f9884, 0xb59048be, 0xc1096add, 0xb57c1624, 0xf46e2504, 0xb567ef08, 0xc1128119, -0xb553d36c, 0xf43cb8a7, 0xb53fc355, 0xc11bbe26, 0xb52bbec4, 0xf40b538b, 0xb517c5be, 0xc12521ff, -0xb503d845, 0xf3d9f5cf, 0xb4eff65c, 0xc12eac9d, 0xb4dc2007, 0xf3a89f92, 0xb4c85548, 0xc1385dfb, -0xb4b49622, 0xf37750f2, 0xb4a0e299, 0xc1423613, 0xb48d3ab0, 0xf3460a0d, 0xb4799e69, 0xc14c34df, -0xb4660dc8, 0xf314cb02, 0xb45288cf, 0xc1565a58, 0xb43f0f82, 0xf2e393ef, 0xb42ba1e4, 0xc160a678, -0xb4183ff7, 0xf2b264f2, 0xb404e9bf, 0xc16b193a, 0xb3f19f3e, 0xf2813e2a, 0xb3de6078, 0xc175b296, -0xb3cb2d70, 0xf2501fb5, 0xb3b80628, 0xc1807285, 0xb3a4eaa4, 0xf21f09b1, 0xb391dae6, 0xc18b5903, -0xb37ed6f1, 0xf1edfc3d, 0xb36bdec9, 0xc1966606, 0xb358f26f, 0xf1bcf777, 0xb34611e8, 0xc1a1998a, -0xb3333d36, 0xf18bfb7d, 0xb320745c, 0xc1acf386, 0xb30db75d, 0xf15b086d, 0xb2fb063b, 0xc1b873f5, -0xb2e860fa, 0xf12a1e66, 0xb2d5c79d, 0xc1c41ace, 0xb2c33a26, 0xf0f93d86, 0xb2b0b898, 0xc1cfe80a, -0xb29e42f6, 0xf0c865ea, 0xb28bd943, 0xc1dbdba3, 0xb2797b82, 0xf09797b2, 0xb26729b5, 0xc1e7f591, -0xb254e3e0, 0xf066d2fa, 0xb242aa05, 0xc1f435cc, 0xb2307c27, 0xf03617e2, 0xb21e5a49, 0xc2009c4e, -0xb20c446d, 0xf0056687, 0xb1fa3a97, 0xc20d290d, 0xb1e83cc9, 0xefd4bf08, 0xb1d64b06, 0xc219dc03, -0xb1c46551, 0xefa42181, 0xb1b28bad, 0xc226b528, 0xb1a0be1b, 0xef738e12, 0xb18efca0, 0xc233b473, -0xb17d473d, 0xef4304d8, 0xb16b9df6, 0xc240d9de, 0xb15a00cd, 0xef1285f2, 0xb1486fc5, 0xc24e255e, -0xb136eae1, 0xeee2117c, 0xb1257223, 0xc25b96ee, 0xb114058e, 0xeeb1a796, 0xb102a524, 0xc2692e83, -0xb0f150e9, 0xee81485c, 0xb0e008e0, 0xc276ec16, 0xb0cecd09, 0xee50f3ed, 0xb0bd9d6a, 0xc284cf9f, -0xb0ac7a03, 0xee20aa67, 0xb09b62d8, 0xc292d914, 0xb08a57eb, 0xedf06be6, 0xb079593f, 0xc2a1086d, -0xb06866d7, 0xedc0388a, 0xb05780b5, 0xc2af5da2, 0xb046a6db, 0xed901070, 0xb035d94e, 0xc2bdd8a9, -0xb025180e, 0xed5ff3b5, 0xb014631e, 0xc2cc7979, 0xb003ba82, 0xed2fe277, 0xaff31e3b, 0xc2db400a, -0xafe28e4d, 0xecffdcd4, 0xafd20ab9, 0xc2ea2c53, 0xafc19383, 0xeccfe2ea, 0xafb128ad, 0xc2f93e4a, -0xafa0ca39, 0xec9ff4d6, 0xaf90782a, 0xc30875e5, 0xaf803283, 0xec7012b5, 0xaf6ff945, 0xc317d31c, -0xaf5fcc74, 0xec403ca5, 0xaf4fac12, 0xc32755e5, 0xaf3f9822, 0xec1072c4, 0xaf2f90a5, 0xc336fe37, -0xaf1f959f, 0xebe0b52f, 0xaf0fa712, 0xc346cc07, 0xaeffc500, 0xebb10404, 0xaeefef6c, 0xc356bf4d, -0xaee02658, 0xeb815f60, 0xaed069c7, 0xc366d7fd, 0xaec0b9bb, 0xeb51c760, 0xaeb11636, 0xc377160f, -0xaea17f3b, 0xeb223c22, 0xae91f4cd, 0xc3877978, 0xae8276ed, 0xeaf2bdc3, 0xae73059f, 0xc398022f, -0xae63a0e3, 0xeac34c60, 0xae5448be, 0xc3a8b028, 0xae44fd31, 0xea93e817, 0xae35be3f, 0xc3b9835a, -0xae268be9, 0xea649105, 0xae176633, 0xc3ca7bba, 0xae084d1f, 0xea354746, 0xadf940ae, 0xc3db993e, -0xadea40e4, 0xea060af9, 0xaddb4dc2, 0xc3ecdbdc, 0xadcc674b, 0xe9d6dc3b, 0xadbd8d82, 0xc3fe4388, -0xadaec067, 0xe9a7bb28, 0xad9fffff, 0xc40fd037, 0xad914c4b, 0xe978a7dd, 0xad82a54c, 0xc42181e0, -0xad740b07, 0xe949a278, 0xad657d7c, 0xc4335877, 0xad56fcaf, 0xe91aab16, 0xad4888a0, 0xc44553f2, -0xad3a2153, 0xe8ebc1d3, 0xad2bc6ca, 0xc4577444, 0xad1d7907, 0xe8bce6cd, 0xad0f380c, 0xc469b963, -0xad0103db, 0xe88e1a20, 0xacf2dc77, 0xc47c2344, 0xace4c1e2, 0xe85f5be9, 0xacd6b41e, 0xc48eb1db, -0xacc8b32c, 0xe830ac45, 0xacbabf10, 0xc4a1651c, 0xacacd7cb, 0xe8020b52, 0xac9efd60, 0xc4b43cfd, -0xac912fd1, 0xe7d3792b, 0xac836f1f, 0xc4c73972, 0xac75bb4d, 0xe7a4f5ed, 0xac68145d, 0xc4da5a6f, -0xac5a7a52, 0xe77681b6, 0xac4ced2c, 0xc4ed9fe7, 0xac3f6cef, 0xe7481ca1, 0xac31f99d, 0xc50109d0, -0xac249336, 0xe719c6cb, 0xac1739bf, 0xc514981d, 0xac09ed38, 0xe6eb8052, 0xabfcada3, 0xc5284ac3, -0xabef7b04, 0xe6bd4951, 0xabe2555b, 0xc53c21b4, 0xabd53caa, 0xe68f21e5, 0xabc830f5, 0xc5501ce5, -0xabbb323c, 0xe6610a2a, 0xabae4082, 0xc5643c4a, 0xaba15bc9, 0xe633023e, 0xab948413, 0xc5787fd6, -0xab87b962, 0xe6050a3b, 0xab7afbb7, 0xc58ce77c, 0xab6e4b15, 0xe5d72240, 0xab61a77d, 0xc5a17330, -0xab5510f3, 0xe5a94a67, 0xab488776, 0xc5b622e6, 0xab3c0b0b, 0xe57b82cd, 0xab2f9bb1, 0xc5caf690, -0xab23396c, 0xe54dcb8f, 0xab16e43d, 0xc5dfee22, 0xab0a9c27, 0xe52024c9, 0xaafe612a, 0xc5f5098f, -0xaaf23349, 0xe4f28e96, 0xaae61286, 0xc60a48c9, 0xaad9fee3, 0xe4c50914, 0xaacdf861, 0xc61fabc4, -0xaac1ff03, 0xe497945d, 0xaab612ca, 0xc6353273, 0xaaaa33b8, 0xe46a308f, 0xaa9e61cf, 0xc64adcc7, -0xaa929d10, 0xe43cddc4, 0xaa86e57e, 0xc660aab5, 0xaa7b3b1b, 0xe40f9c1a, 0xaa6f9de7, 0xc6769c2e, -0xaa640de6, 0xe3e26bac, 0xaa588b18, 0xc68cb124, 0xaa4d157f, 0xe3b54c95, 0xaa41ad1e, 0xc6a2e98b, -0xaa3651f6, 0xe3883ef2, 0xaa2b0409, 0xc6b94554, 0xaa1fc358, 0xe35b42df, 0xaa148fe6, 0xc6cfc472, -0xaa0969b3, 0xe32e5876, 0xa9fe50c2, 0xc6e666d7, 0xa9f34515, 0xe3017fd5, 0xa9e846ad, 0xc6fd2c75, -0xa9dd558b, 0xe2d4b916, 0xa9d271b2, 0xc714153e, 0xa9c79b23, 0xe2a80456, 0xa9bcd1e0, 0xc72b2123, -0xa9b215ea, 0xe27b61af, 0xa9a76744, 0xc7425016, 0xa99cc5ee, 0xe24ed13d, 0xa99231eb, 0xc759a20a, -0xa987ab3c, 0xe222531c, 0xa97d31e3, 0xc77116f0, 0xa972c5e1, 0xe1f5e768, 0xa9686738, 0xc788aeb9, -0xa95e15e9, 0xe1c98e3b, 0xa953d1f7, 0xc7a06957, 0xa9499b62, 0xe19d47b1, 0xa93f722c, 0xc7b846ba, -0xa9355658, 0xe17113e5, 0xa92b47e5, 0xc7d046d6, 0xa92146d7, 0xe144f2f3, 0xa917532e, 0xc7e8699a, -0xa90d6cec, 0xe118e4f6, 0xa9039413, 0xc800aef7, 0xa8f9c8a4, 0xe0ecea09, 0xa8f00aa0, 0xc81916df, -0xa8e65a0a, 0xe0c10247, 0xa8dcb6e2, 0xc831a143, 0xa8d3212a, 0xe0952dcb, 0xa8c998e3, 0xc84a4e14, -0xa8c01e10, 0xe0696cb0, 0xa8b6b0b1, 0xc8631d42, 0xa8ad50c8, 0xe03dbf11, 0xa8a3fe57, 0xc87c0ebd, -0xa89ab95e, 0xe012250a, 0xa89181df, 0xc8952278, 0xa88857dc, 0xdfe69eb4, 0xa87f3b57, 0xc8ae5862, -0xa8762c4f, 0xdfbb2c2c, 0xa86d2ac8, 0xc8c7b06b, 0xa86436c2, 0xdf8fcd8b, 0xa85b503e, 0xc8e12a84, -0xa852773f, 0xdf6482ed, 0xa849abc4, 0xc8fac69e, 0xa840edd1, 0xdf394c6b, 0xa8383d66, 0xc91484a8, -0xa82f9a84, 0xdf0e2a22, 0xa827052d, 0xc92e6492, 0xa81e7d62, 0xdee31c2b, 0xa8160324, 0xc948664d, -0xa80d9675, 0xdeb822a1, 0xa8053756, 0xc96289c9, 0xa7fce5c9, 0xde8d3d9e, 0xa7f4a1ce, 0xc97ccef5, -0xa7ec6b66, 0xde626d3e, 0xa7e44294, 0xc99735c2, 0xa7dc2759, 0xde37b199, 0xa7d419b4, 0xc9b1be1e, -0xa7cc19a9, 0xde0d0acc, 0xa7c42738, 0xc9cc67fa, 0xa7bc4262, 0xdde278ef, 0xa7b46b29, 0xc9e73346, -0xa7aca18e, 0xddb7fc1e, 0xa7a4e591, 0xca021fef, 0xa79d3735, 0xdd8d9472, 0xa795967a, 0xca1d2de7, -0xa78e0361, 0xdd634206, 0xa7867dec, 0xca385d1d, 0xa77f061c, 0xdd3904f4, 0xa7779bf2, 0xca53ad7e, -0xa7703f70, 0xdd0edd55, 0xa768f095, 0xca6f1efc, 0xa761af64, 0xdce4cb44, 0xa75a7bdd, 0xca8ab184, -0xa7535602, 0xdcbacedb, 0xa74c3dd4, 0xcaa66506, 0xa7453353, 0xdc90e834, 0xa73e3681, 0xcac23971, -0xa7374760, 0xdc671768, 0xa73065ef, 0xcade2eb3, 0xa7299231, 0xdc3d5c91, 0xa722cc25, 0xcafa44bc, -0xa71c13ce, 0xdc13b7c9, 0xa715692c, 0xcb167b79, 0xa70ecc41, 0xdbea292b, 0xa7083d0d, 0xcb32d2da, -0xa701bb91, 0xdbc0b0ce, 0xa6fb47ce, 0xcb4f4acd, 0xa6f4e1c6, 0xdb974ece, 0xa6ee8979, 0xcb6be341, -0xa6e83ee8, 0xdb6e0342, 0xa6e20214, 0xcb889c23, 0xa6dbd2ff, 0xdb44ce46, 0xa6d5b1a9, 0xcba57563, -0xa6cf9e13, 0xdb1baff2, 0xa6c9983e, 0xcbc26eee, 0xa6c3a02b, 0xdaf2a860, 0xa6bdb5da, 0xcbdf88b3, -0xa6b7d94e, 0xdac9b7a9, 0xa6b20a86, 0xcbfcc29f, 0xa6ac4984, 0xdaa0dde7, 0xa6a69649, 0xcc1a1ca0, -0xa6a0f0d5, 0xda781b31, 0xa69b5929, 0xcc3796a5, 0xa695cf46, 0xda4f6fa3, 0xa690532d, 0xcc55309b, -0xa68ae4df, 0xda26db54, 0xa685845c, 0xcc72ea70, 0xa68031a6, 0xd9fe5e5e, 0xa67aecbd, 0xcc90c412, -0xa675b5a3, 0xd9d5f8d9, 0xa6708c57, 0xccaebd6e, 0xa66b70db, 0xd9adaadf, 0xa6666330, 0xccccd671, -0xa6616355, 0xd9857489, 0xa65c714d, 0xcceb0f0a, 0xa6578d18, 0xd95d55ef, 0xa652b6b6, 0xcd096725, -0xa64dee28, 0xd9354f2a, 0xa6493370, 0xcd27deb0, 0xa644868d, 0xd90d6053, 0xa63fe781, 0xcd467599, -0xa63b564c, 0xd8e58982, 0xa636d2ee, 0xcd652bcb, 0xa6325d6a, 0xd8bdcad0, 0xa62df5bf, 0xcd840134, -0xa6299bed, 0xd8962456, 0xa6254ff7, 0xcda2f5c2, 0xa62111db, 0xd86e962b, 0xa61ce19c, 0xcdc20960, -0xa618bf39, 0xd8472069, 0xa614aab3, 0xcde13bfd, 0xa610a40c, 0xd81fc328, 0xa60cab43, 0xce008d84, -0xa608c058, 0xd7f87e7f, 0xa604e34e, 0xce1ffde2, 0xa6011424, 0xd7d15288, 0xa5fd52db, 0xce3f8d05, -0xa5f99f73, 0xd7aa3f5a, 0xa5f5f9ed, 0xce5f3ad8, 0xa5f2624a, 0xd783450d, 0xa5eed88a, 0xce7f0748, -0xa5eb5cae, 0xd75c63ba, 0xa5e7eeb6, 0xce9ef241, 0xa5e48ea3, 0xd7359b78, 0xa5e13c75, 0xcebefbb0, -0xa5ddf82d, 0xd70eec60, 0xa5dac1cb, 0xcedf2380, 0xa5d79950, 0xd6e85689, 0xa5d47ebc, 0xceff699f, -0xa5d17210, 0xd6c1da0b, 0xa5ce734d, 0xcf1fcdf8, 0xa5cb8272, 0xd69b76fe, 0xa5c89f80, 0xcf405077, -0xa5c5ca77, 0xd6752d79, 0xa5c30359, 0xcf60f108, 0xa5c04a25, 0xd64efd94, 0xa5bd9edc, 0xcf81af97, -0xa5bb017f, 0xd628e767, 0xa5b8720d, 0xcfa28c10, 0xa5b5f087, 0xd602eb0a, 0xa5b37cee, 0xcfc3865e, -0xa5b11741, 0xd5dd0892, 0xa5aebf82, 0xcfe49e6d, 0xa5ac75b0, 0xd5b74019, 0xa5aa39cd, 0xd005d42a, -0xa5a80bd7, 0xd59191b5, 0xa5a5ebd0, 0xd027277e, 0xa5a3d9b8, 0xd56bfd7d, 0xa5a1d590, 0xd0489856, -0xa59fdf57, 0xd5468389, 0xa59df70e, 0xd06a269d, 0xa59c1cb5, 0xd52123f0, 0xa59a504c, 0xd08bd23f, -0xa59891d4, 0xd4fbdec9, 0xa596e14e, 0xd0ad9b26, 0xa5953eb8, 0xd4d6b42b, 0xa593aa14, 0xd0cf813e, -0xa5922362, 0xd4b1a42c, 0xa590aaa2, 0xd0f18472, 0xa58f3fd4, 0xd48caee4, 0xa58de2f8, 0xd113a4ad, -0xa58c940f, 0xd467d469, 0xa58b5319, 0xd135e1d9, 0xa58a2016, 0xd44314d3, 0xa588fb06, 0xd1583be2, -0xa587e3ea, 0xd41e7037, 0xa586dac1, 0xd17ab2b3, 0xa585df8c, 0xd3f9e6ad, 0xa584f24b, 0xd19d4636, -0xa58412fe, 0xd3d5784a, 0xa58341a5, 0xd1bff656, 0xa5827e40, 0xd3b12526, 0xa581c8d0, 0xd1e2c2fd, -0xa5812154, 0xd38ced57, 0xa58087cd, 0xd205ac17, 0xa57ffc3b, 0xd368d0f3, 0xa57f7e9d, 0xd228b18d, -0xa57f0ef5, 0xd344d011, 0xa57ead41, 0xd24bd34a, 0xa57e5982, 0xd320eac6, 0xa57e13b8, 0xd26f1138, -0xa57ddbe4, 0xd2fd2129, 0xa57db204, 0xd2926b41, 0xa57d961a, 0xd2d97350, 0xa57d8825, 0xd2b5e151, -}; - -/* PostMultiply() tables - * format = Q30 - * reordered for sequential access - * decimate (skip by 16 instead of 2) for small transform (128) - * - * for (i = 0; i <= (512/2); i++) { - * angle = i * M_PI / 1024; - * x = (cos(angle) + sin(angle)); - * x = sin(angle); - * } - */ -const int cos1sin1tab[514] PROGMEM = { -/* format = Q30 */ -0x40000000, 0x00000000, 0x40323034, 0x003243f1, 0x406438cf, 0x006487c4, 0x409619b2, 0x0096cb58, -0x40c7d2bd, 0x00c90e90, 0x40f963d3, 0x00fb514b, 0x412accd4, 0x012d936c, 0x415c0da3, 0x015fd4d2, -0x418d2621, 0x0192155f, 0x41be162f, 0x01c454f5, 0x41eeddaf, 0x01f69373, 0x421f7c84, 0x0228d0bb, -0x424ff28f, 0x025b0caf, 0x42803fb2, 0x028d472e, 0x42b063d0, 0x02bf801a, 0x42e05ecb, 0x02f1b755, -0x43103085, 0x0323ecbe, 0x433fd8e1, 0x03562038, 0x436f57c1, 0x038851a2, 0x439ead09, 0x03ba80df, -0x43cdd89a, 0x03ecadcf, 0x43fcda59, 0x041ed854, 0x442bb227, 0x0451004d, 0x445a5fe8, 0x0483259d, -0x4488e37f, 0x04b54825, 0x44b73ccf, 0x04e767c5, 0x44e56bbd, 0x0519845e, 0x4513702a, 0x054b9dd3, -0x454149fc, 0x057db403, 0x456ef916, 0x05afc6d0, 0x459c7d5a, 0x05e1d61b, 0x45c9d6af, 0x0613e1c5, -0x45f704f7, 0x0645e9af, 0x46240816, 0x0677edbb, 0x4650dff1, 0x06a9edc9, 0x467d8c6d, 0x06dbe9bb, -0x46aa0d6d, 0x070de172, 0x46d662d6, 0x073fd4cf, 0x47028c8d, 0x0771c3b3, 0x472e8a76, 0x07a3adff, -0x475a5c77, 0x07d59396, 0x47860275, 0x08077457, 0x47b17c54, 0x08395024, 0x47dcc9f9, 0x086b26de, -0x4807eb4b, 0x089cf867, 0x4832e02d, 0x08cec4a0, 0x485da887, 0x09008b6a, 0x4888443d, 0x09324ca7, -0x48b2b335, 0x09640837, 0x48dcf556, 0x0995bdfd, 0x49070a84, 0x09c76dd8, 0x4930f2a6, 0x09f917ac, -0x495aada2, 0x0a2abb59, 0x49843b5f, 0x0a5c58c0, 0x49ad9bc2, 0x0a8defc3, 0x49d6ceb3, 0x0abf8043, -0x49ffd417, 0x0af10a22, 0x4a28abd6, 0x0b228d42, 0x4a5155d6, 0x0b540982, 0x4a79d1ff, 0x0b857ec7, -0x4aa22036, 0x0bb6ecef, 0x4aca4065, 0x0be853de, 0x4af23270, 0x0c19b374, 0x4b19f641, 0x0c4b0b94, -0x4b418bbe, 0x0c7c5c1e, 0x4b68f2cf, 0x0cada4f5, 0x4b902b5c, 0x0cdee5f9, 0x4bb7354d, 0x0d101f0e, -0x4bde1089, 0x0d415013, 0x4c04bcf8, 0x0d7278eb, 0x4c2b3a84, 0x0da39978, 0x4c518913, 0x0dd4b19a, -0x4c77a88e, 0x0e05c135, 0x4c9d98de, 0x0e36c82a, 0x4cc359ec, 0x0e67c65a, 0x4ce8eb9f, 0x0e98bba7, -0x4d0e4de2, 0x0ec9a7f3, 0x4d33809c, 0x0efa8b20, 0x4d5883b7, 0x0f2b650f, 0x4d7d571c, 0x0f5c35a3, -0x4da1fab5, 0x0f8cfcbe, 0x4dc66e6a, 0x0fbdba40, 0x4deab226, 0x0fee6e0d, 0x4e0ec5d1, 0x101f1807, -0x4e32a956, 0x104fb80e, 0x4e565c9f, 0x10804e06, 0x4e79df95, 0x10b0d9d0, 0x4e9d3222, 0x10e15b4e, -0x4ec05432, 0x1111d263, 0x4ee345ad, 0x11423ef0, 0x4f06067f, 0x1172a0d7, 0x4f289692, 0x11a2f7fc, -0x4f4af5d1, 0x11d3443f, 0x4f6d2427, 0x12038584, 0x4f8f217e, 0x1233bbac, 0x4fb0edc1, 0x1263e699, -0x4fd288dc, 0x1294062f, 0x4ff3f2bb, 0x12c41a4f, 0x50152b47, 0x12f422db, 0x5036326e, 0x13241fb6, -0x50570819, 0x135410c3, 0x5077ac37, 0x1383f5e3, 0x50981eb1, 0x13b3cefa, 0x50b85f74, 0x13e39be9, -0x50d86e6d, 0x14135c94, 0x50f84b87, 0x144310dd, 0x5117f6ae, 0x1472b8a5, 0x51376fd0, 0x14a253d1, -0x5156b6d9, 0x14d1e242, 0x5175cbb5, 0x150163dc, 0x5194ae52, 0x1530d881, 0x51b35e9b, 0x15604013, -0x51d1dc80, 0x158f9a76, 0x51f027eb, 0x15bee78c, 0x520e40cc, 0x15ee2738, 0x522c270f, 0x161d595d, -0x5249daa2, 0x164c7ddd, 0x52675b72, 0x167b949d, 0x5284a96e, 0x16aa9d7e, 0x52a1c482, 0x16d99864, -0x52beac9f, 0x17088531, 0x52db61b0, 0x173763c9, 0x52f7e3a6, 0x1766340f, 0x5314326d, 0x1794f5e6, -0x53304df6, 0x17c3a931, 0x534c362d, 0x17f24dd3, 0x5367eb03, 0x1820e3b0, 0x53836c66, 0x184f6aab, -0x539eba45, 0x187de2a7, 0x53b9d48f, 0x18ac4b87, 0x53d4bb34, 0x18daa52f, 0x53ef6e23, 0x1908ef82, -0x5409ed4b, 0x19372a64, 0x5424389d, 0x196555b8, 0x543e5007, 0x19937161, 0x5458337a, 0x19c17d44, -0x5471e2e6, 0x19ef7944, 0x548b5e3b, 0x1a1d6544, 0x54a4a56a, 0x1a4b4128, 0x54bdb862, 0x1a790cd4, -0x54d69714, 0x1aa6c82b, 0x54ef4171, 0x1ad47312, 0x5507b76a, 0x1b020d6c, 0x551ff8ef, 0x1b2f971e, -0x553805f2, 0x1b5d100a, 0x554fde64, 0x1b8a7815, 0x55678236, 0x1bb7cf23, 0x557ef15a, 0x1be51518, -0x55962bc0, 0x1c1249d8, 0x55ad315b, 0x1c3f6d47, 0x55c4021d, 0x1c6c7f4a, 0x55da9df7, 0x1c997fc4, -0x55f104dc, 0x1cc66e99, 0x560736bd, 0x1cf34baf, 0x561d338d, 0x1d2016e9, 0x5632fb3f, 0x1d4cd02c, -0x56488dc5, 0x1d79775c, 0x565deb11, 0x1da60c5d, 0x56731317, 0x1dd28f15, 0x568805c9, 0x1dfeff67, -0x569cc31b, 0x1e2b5d38, 0x56b14b00, 0x1e57a86d, 0x56c59d6a, 0x1e83e0eb, 0x56d9ba4e, 0x1eb00696, -0x56eda1a0, 0x1edc1953, 0x57015352, 0x1f081907, 0x5714cf59, 0x1f340596, 0x572815a8, 0x1f5fdee6, -0x573b2635, 0x1f8ba4dc, 0x574e00f2, 0x1fb7575c, 0x5760a5d5, 0x1fe2f64c, 0x577314d2, 0x200e8190, -0x57854ddd, 0x2039f90f, 0x579750ec, 0x20655cac, 0x57a91df2, 0x2090ac4d, 0x57bab4e6, 0x20bbe7d8, -0x57cc15bc, 0x20e70f32, 0x57dd406a, 0x21122240, 0x57ee34e5, 0x213d20e8, 0x57fef323, 0x21680b0f, -0x580f7b19, 0x2192e09b, 0x581fccbc, 0x21bda171, 0x582fe804, 0x21e84d76, 0x583fcce6, 0x2212e492, -0x584f7b58, 0x223d66a8, 0x585ef351, 0x2267d3a0, 0x586e34c7, 0x22922b5e, 0x587d3fb0, 0x22bc6dca, -0x588c1404, 0x22e69ac8, 0x589ab1b9, 0x2310b23e, 0x58a918c6, 0x233ab414, 0x58b74923, 0x2364a02e, -0x58c542c5, 0x238e7673, 0x58d305a6, 0x23b836ca, 0x58e091bd, 0x23e1e117, 0x58ede700, 0x240b7543, -0x58fb0568, 0x2434f332, 0x5907eced, 0x245e5acc, 0x59149d87, 0x2487abf7, 0x5921172e, 0x24b0e699, -0x592d59da, 0x24da0a9a, 0x59396584, 0x250317df, 0x59453a24, 0x252c0e4f, 0x5950d7b3, 0x2554edd1, -0x595c3e2a, 0x257db64c, 0x59676d82, 0x25a667a7, 0x597265b4, 0x25cf01c8, 0x597d26b8, 0x25f78497, -0x5987b08a, 0x261feffa, 0x59920321, 0x264843d9, 0x599c1e78, 0x2670801a, 0x59a60288, 0x2698a4a6, -0x59afaf4c, 0x26c0b162, 0x59b924bc, 0x26e8a637, 0x59c262d5, 0x2710830c, 0x59cb698f, 0x273847c8, -0x59d438e5, 0x275ff452, 0x59dcd0d3, 0x27878893, 0x59e53151, 0x27af0472, 0x59ed5a5c, 0x27d667d5, -0x59f54bee, 0x27fdb2a7, 0x59fd0603, 0x2824e4cc, 0x5a048895, 0x284bfe2f, 0x5a0bd3a1, 0x2872feb6, -0x5a12e720, 0x2899e64a, 0x5a19c310, 0x28c0b4d2, 0x5a20676c, 0x28e76a37, 0x5a26d42f, 0x290e0661, -0x5a2d0957, 0x29348937, 0x5a3306de, 0x295af2a3, 0x5a38ccc2, 0x2981428c, 0x5a3e5afe, 0x29a778db, -0x5a43b190, 0x29cd9578, 0x5a48d074, 0x29f3984c, 0x5a4db7a6, 0x2a19813f, 0x5a526725, 0x2a3f503a, -0x5a56deec, 0x2a650525, 0x5a5b1efa, 0x2a8a9fea, 0x5a5f274b, 0x2ab02071, 0x5a62f7dd, 0x2ad586a3, -0x5a6690ae, 0x2afad269, 0x5a69f1bb, 0x2b2003ac, 0x5a6d1b03, 0x2b451a55, 0x5a700c84, 0x2b6a164d, -0x5a72c63b, 0x2b8ef77d, 0x5a754827, 0x2bb3bdce, 0x5a779246, 0x2bd8692b, 0x5a79a498, 0x2bfcf97c, -0x5a7b7f1a, 0x2c216eaa, 0x5a7d21cc, 0x2c45c8a0, 0x5a7e8cac, 0x2c6a0746, 0x5a7fbfbb, 0x2c8e2a87, -0x5a80baf6, 0x2cb2324c, 0x5a817e5d, 0x2cd61e7f, 0x5a8209f1, 0x2cf9ef09, 0x5a825db0, 0x2d1da3d5, -0x5a82799a, 0x2d413ccd, -}; - -const int sinWindowOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* Synthesis window - SIN - * format = Q31 for nmdct = [128, 1024] - * reordered for sequential access - * - * for (i = 0; i < nmdct/2; i++) { - * angle = (i + 0.5) * M_PI / (2.0 * nmdct); - * x = sin(angle); - * - * angle = (nmdct - 1 - i + 0.5) * M_PI / (2.0 * nmdct); - * x = sin(angle); - * } - */ -const int sinWindow[128 + 1024] PROGMEM = { -/* 128 - format = Q31 * 2^0 */ -0x00c90f88, 0x7fff6216, 0x025b26d7, 0x7ffa72d1, 0x03ed26e6, 0x7ff09478, 0x057f0035, 0x7fe1c76b, -0x0710a345, 0x7fce0c3e, 0x08a2009a, 0x7fb563b3, 0x0a3308bd, 0x7f97cebd, 0x0bc3ac35, 0x7f754e80, -0x0d53db92, 0x7f4de451, 0x0ee38766, 0x7f2191b4, 0x1072a048, 0x7ef05860, 0x120116d5, 0x7eba3a39, -0x138edbb1, 0x7e7f3957, 0x151bdf86, 0x7e3f57ff, 0x16a81305, 0x7dfa98a8, 0x183366e9, 0x7db0fdf8, -0x19bdcbf3, 0x7d628ac6, 0x1b4732ef, 0x7d0f4218, 0x1ccf8cb3, 0x7cb72724, 0x1e56ca1e, 0x7c5a3d50, -0x1fdcdc1b, 0x7bf88830, 0x2161b3a0, 0x7b920b89, 0x22e541af, 0x7b26cb4f, 0x24677758, 0x7ab6cba4, -0x25e845b6, 0x7a4210d8, 0x27679df4, 0x79c89f6e, 0x28e5714b, 0x794a7c12, 0x2a61b101, 0x78c7aba2, -0x2bdc4e6f, 0x78403329, 0x2d553afc, 0x77b417df, 0x2ecc681e, 0x77235f2d, 0x3041c761, 0x768e0ea6, -0x31b54a5e, 0x75f42c0b, 0x3326e2c3, 0x7555bd4c, 0x34968250, 0x74b2c884, 0x36041ad9, 0x740b53fb, -0x376f9e46, 0x735f6626, 0x38d8fe93, 0x72af05a7, 0x3a402dd2, 0x71fa3949, 0x3ba51e29, 0x71410805, -0x3d07c1d6, 0x708378ff, 0x3e680b2c, 0x6fc19385, 0x3fc5ec98, 0x6efb5f12, 0x4121589b, 0x6e30e34a, -0x427a41d0, 0x6d6227fa, 0x43d09aed, 0x6c8f351c, 0x452456bd, 0x6bb812d1, 0x46756828, 0x6adcc964, -0x47c3c22f, 0x69fd614a, 0x490f57ee, 0x6919e320, 0x4a581c9e, 0x683257ab, 0x4b9e0390, 0x6746c7d8, -0x4ce10034, 0x66573cbb, 0x4e210617, 0x6563bf92, 0x4f5e08e3, 0x646c59bf, 0x5097fc5e, 0x637114cc, -0x51ced46e, 0x6271fa69, 0x53028518, 0x616f146c, 0x5433027d, 0x60686ccf, 0x556040e2, 0x5f5e0db3, -0x568a34a9, 0x5e50015d, 0x57b0d256, 0x5d3e5237, 0x58d40e8c, 0x5c290acc, 0x59f3de12, 0x5b1035cf, -/* 1024 - format = Q31 * 2^0 */ -0x001921fb, 0x7ffffd88, 0x004b65ee, 0x7fffe9cb, 0x007da9d4, 0x7fffc251, 0x00afeda8, 0x7fff8719, -0x00e23160, 0x7fff3824, 0x011474f6, 0x7ffed572, 0x0146b860, 0x7ffe5f03, 0x0178fb99, 0x7ffdd4d7, -0x01ab3e97, 0x7ffd36ee, 0x01dd8154, 0x7ffc8549, 0x020fc3c6, 0x7ffbbfe6, 0x024205e8, 0x7ffae6c7, -0x027447b0, 0x7ff9f9ec, 0x02a68917, 0x7ff8f954, 0x02d8ca16, 0x7ff7e500, 0x030b0aa4, 0x7ff6bcf0, -0x033d4abb, 0x7ff58125, 0x036f8a51, 0x7ff4319d, 0x03a1c960, 0x7ff2ce5b, 0x03d407df, 0x7ff1575d, -0x040645c7, 0x7fefcca4, 0x04388310, 0x7fee2e30, 0x046abfb3, 0x7fec7c02, 0x049cfba7, 0x7feab61a, -0x04cf36e5, 0x7fe8dc78, 0x05017165, 0x7fe6ef1c, 0x0533ab20, 0x7fe4ee06, 0x0565e40d, 0x7fe2d938, -0x05981c26, 0x7fe0b0b1, 0x05ca5361, 0x7fde7471, 0x05fc89b8, 0x7fdc247a, 0x062ebf22, 0x7fd9c0ca, -0x0660f398, 0x7fd74964, 0x06932713, 0x7fd4be46, 0x06c5598a, 0x7fd21f72, 0x06f78af6, 0x7fcf6ce8, -0x0729bb4e, 0x7fcca6a7, 0x075bea8c, 0x7fc9ccb2, 0x078e18a7, 0x7fc6df08, 0x07c04598, 0x7fc3dda9, -0x07f27157, 0x7fc0c896, 0x08249bdd, 0x7fbd9fd0, 0x0856c520, 0x7fba6357, 0x0888ed1b, 0x7fb7132b, -0x08bb13c5, 0x7fb3af4e, 0x08ed3916, 0x7fb037bf, 0x091f5d06, 0x7facac7f, 0x09517f8f, 0x7fa90d8e, -0x0983a0a7, 0x7fa55aee, 0x09b5c048, 0x7fa1949e, 0x09e7de6a, 0x7f9dbaa0, 0x0a19fb04, 0x7f99ccf4, -0x0a4c1610, 0x7f95cb9a, 0x0a7e2f85, 0x7f91b694, 0x0ab0475c, 0x7f8d8de1, 0x0ae25d8d, 0x7f895182, -0x0b147211, 0x7f850179, 0x0b4684df, 0x7f809dc5, 0x0b7895f0, 0x7f7c2668, 0x0baaa53b, 0x7f779b62, -0x0bdcb2bb, 0x7f72fcb4, 0x0c0ebe66, 0x7f6e4a5e, 0x0c40c835, 0x7f698461, 0x0c72d020, 0x7f64aabf, -0x0ca4d620, 0x7f5fbd77, 0x0cd6da2d, 0x7f5abc8a, 0x0d08dc3f, 0x7f55a7fa, 0x0d3adc4e, 0x7f507fc7, -0x0d6cda53, 0x7f4b43f2, 0x0d9ed646, 0x7f45f47b, 0x0dd0d01f, 0x7f409164, 0x0e02c7d7, 0x7f3b1aad, -0x0e34bd66, 0x7f359057, 0x0e66b0c3, 0x7f2ff263, 0x0e98a1e9, 0x7f2a40d2, 0x0eca90ce, 0x7f247ba5, -0x0efc7d6b, 0x7f1ea2dc, 0x0f2e67b8, 0x7f18b679, 0x0f604faf, 0x7f12b67c, 0x0f923546, 0x7f0ca2e7, -0x0fc41876, 0x7f067bba, 0x0ff5f938, 0x7f0040f6, 0x1027d784, 0x7ef9f29d, 0x1059b352, 0x7ef390ae, -0x108b8c9b, 0x7eed1b2c, 0x10bd6356, 0x7ee69217, 0x10ef377d, 0x7edff570, 0x11210907, 0x7ed94538, -0x1152d7ed, 0x7ed28171, 0x1184a427, 0x7ecbaa1a, 0x11b66dad, 0x7ec4bf36, 0x11e83478, 0x7ebdc0c6, -0x1219f880, 0x7eb6aeca, 0x124bb9be, 0x7eaf8943, 0x127d7829, 0x7ea85033, 0x12af33ba, 0x7ea1039b, -0x12e0ec6a, 0x7e99a37c, 0x1312a230, 0x7e922fd6, 0x13445505, 0x7e8aa8ac, 0x137604e2, 0x7e830dff, -0x13a7b1bf, 0x7e7b5fce, 0x13d95b93, 0x7e739e1d, 0x140b0258, 0x7e6bc8eb, 0x143ca605, 0x7e63e03b, -0x146e4694, 0x7e5be40c, 0x149fe3fc, 0x7e53d462, 0x14d17e36, 0x7e4bb13c, 0x1503153a, 0x7e437a9c, -0x1534a901, 0x7e3b3083, 0x15663982, 0x7e32d2f4, 0x1597c6b7, 0x7e2a61ed, 0x15c95097, 0x7e21dd73, -0x15fad71b, 0x7e194584, 0x162c5a3b, 0x7e109a24, 0x165dd9f0, 0x7e07db52, 0x168f5632, 0x7dff0911, -0x16c0cef9, 0x7df62362, 0x16f2443e, 0x7ded2a47, 0x1723b5f9, 0x7de41dc0, 0x17552422, 0x7ddafdce, -0x17868eb3, 0x7dd1ca75, 0x17b7f5a3, 0x7dc883b4, 0x17e958ea, 0x7dbf298d, 0x181ab881, 0x7db5bc02, -0x184c1461, 0x7dac3b15, 0x187d6c82, 0x7da2a6c6, 0x18aec0db, 0x7d98ff17, 0x18e01167, 0x7d8f4409, -0x19115e1c, 0x7d85759f, 0x1942a6f3, 0x7d7b93da, 0x1973ebe6, 0x7d719eba, 0x19a52ceb, 0x7d679642, -0x19d669fc, 0x7d5d7a74, 0x1a07a311, 0x7d534b50, 0x1a38d823, 0x7d4908d9, 0x1a6a0929, 0x7d3eb30f, -0x1a9b361d, 0x7d3449f5, 0x1acc5ef6, 0x7d29cd8c, 0x1afd83ad, 0x7d1f3dd6, 0x1b2ea43a, 0x7d149ad5, -0x1b5fc097, 0x7d09e489, 0x1b90d8bb, 0x7cff1af5, 0x1bc1ec9e, 0x7cf43e1a, 0x1bf2fc3a, 0x7ce94dfb, -0x1c240786, 0x7cde4a98, 0x1c550e7c, 0x7cd333f3, 0x1c861113, 0x7cc80a0f, 0x1cb70f43, 0x7cbcccec, -0x1ce80906, 0x7cb17c8d, 0x1d18fe54, 0x7ca618f3, 0x1d49ef26, 0x7c9aa221, 0x1d7adb73, 0x7c8f1817, -0x1dabc334, 0x7c837ad8, 0x1ddca662, 0x7c77ca65, 0x1e0d84f5, 0x7c6c06c0, 0x1e3e5ee5, 0x7c602fec, -0x1e6f342c, 0x7c5445e9, 0x1ea004c1, 0x7c4848ba, 0x1ed0d09d, 0x7c3c3860, 0x1f0197b8, 0x7c3014de, -0x1f325a0b, 0x7c23de35, 0x1f63178f, 0x7c179467, 0x1f93d03c, 0x7c0b3777, 0x1fc4840a, 0x7bfec765, -0x1ff532f2, 0x7bf24434, 0x2025dcec, 0x7be5ade6, 0x205681f1, 0x7bd9047c, 0x208721f9, 0x7bcc47fa, -0x20b7bcfe, 0x7bbf7860, 0x20e852f6, 0x7bb295b0, 0x2118e3dc, 0x7ba59fee, 0x21496fa7, 0x7b989719, -0x2179f64f, 0x7b8b7b36, 0x21aa77cf, 0x7b7e4c45, 0x21daf41d, 0x7b710a49, 0x220b6b32, 0x7b63b543, -0x223bdd08, 0x7b564d36, 0x226c4996, 0x7b48d225, 0x229cb0d5, 0x7b3b4410, 0x22cd12bd, 0x7b2da2fa, -0x22fd6f48, 0x7b1feee5, 0x232dc66d, 0x7b1227d3, 0x235e1826, 0x7b044dc7, 0x238e646a, 0x7af660c2, -0x23beab33, 0x7ae860c7, 0x23eeec78, 0x7ada4dd8, 0x241f2833, 0x7acc27f7, 0x244f5e5c, 0x7abdef25, -0x247f8eec, 0x7aafa367, 0x24afb9da, 0x7aa144bc, 0x24dfdf20, 0x7a92d329, 0x250ffeb7, 0x7a844eae, -0x25401896, 0x7a75b74f, 0x25702cb7, 0x7a670d0d, 0x25a03b11, 0x7a584feb, 0x25d0439f, 0x7a497feb, -0x26004657, 0x7a3a9d0f, 0x26304333, 0x7a2ba75a, 0x26603a2c, 0x7a1c9ece, 0x26902b39, 0x7a0d836d, -0x26c01655, 0x79fe5539, 0x26effb76, 0x79ef1436, 0x271fda96, 0x79dfc064, 0x274fb3ae, 0x79d059c8, -0x277f86b5, 0x79c0e062, 0x27af53a6, 0x79b15435, 0x27df1a77, 0x79a1b545, 0x280edb23, 0x79920392, -0x283e95a1, 0x79823f20, 0x286e49ea, 0x797267f2, 0x289df7f8, 0x79627e08, 0x28cd9fc1, 0x79528167, -0x28fd4140, 0x79427210, 0x292cdc6d, 0x79325006, 0x295c7140, 0x79221b4b, 0x298bffb2, 0x7911d3e2, -0x29bb87bc, 0x790179cd, 0x29eb0957, 0x78f10d0f, 0x2a1a847b, 0x78e08dab, 0x2a49f920, 0x78cffba3, -0x2a796740, 0x78bf56f9, 0x2aa8ced3, 0x78ae9fb0, 0x2ad82fd2, 0x789dd5cb, 0x2b078a36, 0x788cf94c, -0x2b36ddf7, 0x787c0a36, 0x2b662b0e, 0x786b088c, 0x2b957173, 0x7859f44f, 0x2bc4b120, 0x7848cd83, -0x2bf3ea0d, 0x7837942b, 0x2c231c33, 0x78264849, 0x2c52478a, 0x7814e9df, 0x2c816c0c, 0x780378f1, -0x2cb089b1, 0x77f1f581, 0x2cdfa071, 0x77e05f91, 0x2d0eb046, 0x77ceb725, 0x2d3db928, 0x77bcfc3f, -0x2d6cbb10, 0x77ab2ee2, 0x2d9bb5f6, 0x77994f11, 0x2dcaa9d5, 0x77875cce, 0x2df996a3, 0x7775581d, -0x2e287c5a, 0x776340ff, 0x2e575af3, 0x77511778, 0x2e863267, 0x773edb8b, 0x2eb502ae, 0x772c8d3a, -0x2ee3cbc1, 0x771a2c88, 0x2f128d99, 0x7707b979, 0x2f41482e, 0x76f5340e, 0x2f6ffb7a, 0x76e29c4b, -0x2f9ea775, 0x76cff232, 0x2fcd4c19, 0x76bd35c7, 0x2ffbe95d, 0x76aa670d, 0x302a7f3a, 0x76978605, -0x30590dab, 0x768492b4, 0x308794a6, 0x76718d1c, 0x30b61426, 0x765e7540, 0x30e48c22, 0x764b4b23, -0x3112fc95, 0x76380ec8, 0x31416576, 0x7624c031, 0x316fc6be, 0x76115f63, 0x319e2067, 0x75fdec60, -0x31cc7269, 0x75ea672a, 0x31fabcbd, 0x75d6cfc5, 0x3228ff5c, 0x75c32634, 0x32573a3f, 0x75af6a7b, -0x32856d5e, 0x759b9c9b, 0x32b398b3, 0x7587bc98, 0x32e1bc36, 0x7573ca75, 0x330fd7e1, 0x755fc635, -0x333debab, 0x754bafdc, 0x336bf78f, 0x7537876c, 0x3399fb85, 0x75234ce8, 0x33c7f785, 0x750f0054, -0x33f5eb89, 0x74faa1b3, 0x3423d78a, 0x74e63108, 0x3451bb81, 0x74d1ae55, 0x347f9766, 0x74bd199f, -0x34ad6b32, 0x74a872e8, 0x34db36df, 0x7493ba34, 0x3508fa66, 0x747eef85, 0x3536b5be, 0x746a12df, -0x356468e2, 0x74552446, 0x359213c9, 0x744023bc, 0x35bfb66e, 0x742b1144, 0x35ed50c9, 0x7415ece2, -0x361ae2d3, 0x7400b69a, 0x36486c86, 0x73eb6e6e, 0x3675edd9, 0x73d61461, 0x36a366c6, 0x73c0a878, -0x36d0d746, 0x73ab2ab4, 0x36fe3f52, 0x73959b1b, 0x372b9ee3, 0x737ff9ae, 0x3758f5f2, 0x736a4671, -0x37864477, 0x73548168, 0x37b38a6d, 0x733eaa96, 0x37e0c7cc, 0x7328c1ff, 0x380dfc8d, 0x7312c7a5, -0x383b28a9, 0x72fcbb8c, 0x38684c19, 0x72e69db7, 0x389566d6, 0x72d06e2b, 0x38c278d9, 0x72ba2cea, -0x38ef821c, 0x72a3d9f7, 0x391c8297, 0x728d7557, 0x39497a43, 0x7276ff0d, 0x39766919, 0x7260771b, -0x39a34f13, 0x7249dd86, 0x39d02c2a, 0x72333251, 0x39fd0056, 0x721c7580, 0x3a29cb91, 0x7205a716, -0x3a568dd4, 0x71eec716, 0x3a834717, 0x71d7d585, 0x3aaff755, 0x71c0d265, 0x3adc9e86, 0x71a9bdba, -0x3b093ca3, 0x71929789, 0x3b35d1a5, 0x717b5fd3, 0x3b625d86, 0x7164169d, 0x3b8ee03e, 0x714cbbeb, -0x3bbb59c7, 0x71354fc0, 0x3be7ca1a, 0x711dd220, 0x3c143130, 0x7106430e, 0x3c408f03, 0x70eea28e, -0x3c6ce38a, 0x70d6f0a4, 0x3c992ec0, 0x70bf2d53, 0x3cc5709e, 0x70a7589f, 0x3cf1a91c, 0x708f728b, -0x3d1dd835, 0x70777b1c, 0x3d49fde1, 0x705f7255, 0x3d761a19, 0x70475839, 0x3da22cd7, 0x702f2ccd, -0x3dce3614, 0x7016f014, 0x3dfa35c8, 0x6ffea212, 0x3e262bee, 0x6fe642ca, 0x3e52187f, 0x6fcdd241, -0x3e7dfb73, 0x6fb5507a, 0x3ea9d4c3, 0x6f9cbd79, 0x3ed5a46b, 0x6f841942, 0x3f016a61, 0x6f6b63d8, -0x3f2d26a0, 0x6f529d40, 0x3f58d921, 0x6f39c57d, 0x3f8481dd, 0x6f20dc92, 0x3fb020ce, 0x6f07e285, -0x3fdbb5ec, 0x6eeed758, 0x40074132, 0x6ed5bb10, 0x4032c297, 0x6ebc8db0, 0x405e3a16, 0x6ea34f3d, -0x4089a7a8, 0x6e89ffb9, 0x40b50b46, 0x6e709f2a, 0x40e064ea, 0x6e572d93, 0x410bb48c, 0x6e3daaf8, -0x4136fa27, 0x6e24175c, 0x416235b2, 0x6e0a72c5, 0x418d6729, 0x6df0bd35, 0x41b88e84, 0x6dd6f6b1, -0x41e3abbc, 0x6dbd1f3c, 0x420ebecb, 0x6da336dc, 0x4239c7aa, 0x6d893d93, 0x4264c653, 0x6d6f3365, -0x428fbabe, 0x6d551858, 0x42baa4e6, 0x6d3aec6e, 0x42e584c3, 0x6d20afac, 0x43105a50, 0x6d066215, -0x433b2585, 0x6cec03af, 0x4365e65b, 0x6cd1947c, 0x43909ccd, 0x6cb71482, 0x43bb48d4, 0x6c9c83c3, -0x43e5ea68, 0x6c81e245, 0x44108184, 0x6c67300b, 0x443b0e21, 0x6c4c6d1a, 0x44659039, 0x6c319975, -0x449007c4, 0x6c16b521, 0x44ba74bd, 0x6bfbc021, 0x44e4d71c, 0x6be0ba7b, 0x450f2edb, 0x6bc5a431, -0x45397bf4, 0x6baa7d49, 0x4563be60, 0x6b8f45c7, 0x458df619, 0x6b73fdae, 0x45b82318, 0x6b58a503, -0x45e24556, 0x6b3d3bcb, 0x460c5cce, 0x6b21c208, 0x46366978, 0x6b0637c1, 0x46606b4e, 0x6aea9cf8, -0x468a624a, 0x6acef1b2, 0x46b44e65, 0x6ab335f4, 0x46de2f99, 0x6a9769c1, 0x470805df, 0x6a7b8d1e, -0x4731d131, 0x6a5fa010, 0x475b9188, 0x6a43a29a, 0x478546de, 0x6a2794c1, 0x47aef12c, 0x6a0b7689, -0x47d8906d, 0x69ef47f6, 0x48022499, 0x69d3090e, 0x482badab, 0x69b6b9d3, 0x48552b9b, 0x699a5a4c, -0x487e9e64, 0x697dea7b, 0x48a805ff, 0x69616a65, 0x48d16265, 0x6944da10, 0x48fab391, 0x6928397e, -0x4923f97b, 0x690b88b5, 0x494d341e, 0x68eec7b9, 0x49766373, 0x68d1f68f, 0x499f8774, 0x68b5153a, -0x49c8a01b, 0x689823bf, 0x49f1ad61, 0x687b2224, 0x4a1aaf3f, 0x685e106c, 0x4a43a5b0, 0x6840ee9b, -0x4a6c90ad, 0x6823bcb7, 0x4a957030, 0x68067ac3, 0x4abe4433, 0x67e928c5, 0x4ae70caf, 0x67cbc6c0, -0x4b0fc99d, 0x67ae54ba, 0x4b387af9, 0x6790d2b6, 0x4b6120bb, 0x677340ba, 0x4b89badd, 0x67559eca, -0x4bb24958, 0x6737ecea, 0x4bdacc28, 0x671a2b20, 0x4c034345, 0x66fc596f, 0x4c2baea9, 0x66de77dc, -0x4c540e4e, 0x66c0866d, 0x4c7c622d, 0x66a28524, 0x4ca4aa41, 0x66847408, 0x4ccce684, 0x6666531d, -0x4cf516ee, 0x66482267, 0x4d1d3b7a, 0x6629e1ec, 0x4d455422, 0x660b91af, 0x4d6d60df, 0x65ed31b5, -0x4d9561ac, 0x65cec204, 0x4dbd5682, 0x65b0429f, 0x4de53f5a, 0x6591b38c, 0x4e0d1c30, 0x657314cf, -0x4e34ecfc, 0x6554666d, 0x4e5cb1b9, 0x6535a86b, 0x4e846a60, 0x6516dacd, 0x4eac16eb, 0x64f7fd98, -0x4ed3b755, 0x64d910d1, 0x4efb4b96, 0x64ba147d, 0x4f22d3aa, 0x649b08a0, 0x4f4a4f89, 0x647bed3f, -0x4f71bf2e, 0x645cc260, 0x4f992293, 0x643d8806, 0x4fc079b1, 0x641e3e38, 0x4fe7c483, 0x63fee4f8, -0x500f0302, 0x63df7c4d, 0x50363529, 0x63c0043b, 0x505d5af1, 0x63a07cc7, 0x50847454, 0x6380e5f6, -0x50ab814d, 0x63613fcd, 0x50d281d5, 0x63418a50, 0x50f975e6, 0x6321c585, 0x51205d7b, 0x6301f171, -0x5147388c, 0x62e20e17, 0x516e0715, 0x62c21b7e, 0x5194c910, 0x62a219aa, 0x51bb7e75, 0x628208a1, -0x51e22740, 0x6261e866, 0x5208c36a, 0x6241b8ff, 0x522f52ee, 0x62217a72, 0x5255d5c5, 0x62012cc2, -0x527c4bea, 0x61e0cff5, 0x52a2b556, 0x61c06410, 0x52c91204, 0x619fe918, 0x52ef61ee, 0x617f5f12, -0x5315a50e, 0x615ec603, 0x533bdb5d, 0x613e1df0, 0x536204d7, 0x611d66de, 0x53882175, 0x60fca0d2, -0x53ae3131, 0x60dbcbd1, 0x53d43406, 0x60bae7e1, 0x53fa29ed, 0x6099f505, 0x542012e1, 0x6078f344, -0x5445eedb, 0x6057e2a2, 0x546bbdd7, 0x6036c325, 0x54917fce, 0x601594d1, 0x54b734ba, 0x5ff457ad, -0x54dcdc96, 0x5fd30bbc, 0x5502775c, 0x5fb1b104, 0x55280505, 0x5f90478a, 0x554d858d, 0x5f6ecf53, -0x5572f8ed, 0x5f4d4865, 0x55985f20, 0x5f2bb2c5, 0x55bdb81f, 0x5f0a0e77, 0x55e303e6, 0x5ee85b82, -0x5608426e, 0x5ec699e9, 0x562d73b2, 0x5ea4c9b3, 0x565297ab, 0x5e82eae5, 0x5677ae54, 0x5e60fd84, -0x569cb7a8, 0x5e3f0194, 0x56c1b3a1, 0x5e1cf71c, 0x56e6a239, 0x5dfade20, 0x570b8369, 0x5dd8b6a7, -0x5730572e, 0x5db680b4, 0x57551d80, 0x5d943c4e, 0x5779d65b, 0x5d71e979, 0x579e81b8, 0x5d4f883b, -0x57c31f92, 0x5d2d189a, 0x57e7afe4, 0x5d0a9a9a, 0x580c32a7, 0x5ce80e41, 0x5830a7d6, 0x5cc57394, -0x58550f6c, 0x5ca2ca99, 0x58796962, 0x5c801354, 0x589db5b3, 0x5c5d4dcc, 0x58c1f45b, 0x5c3a7a05, -0x58e62552, 0x5c179806, 0x590a4893, 0x5bf4a7d2, 0x592e5e19, 0x5bd1a971, 0x595265df, 0x5bae9ce7, -0x59765fde, 0x5b8b8239, 0x599a4c12, 0x5b68596d, 0x59be2a74, 0x5b452288, 0x59e1faff, 0x5b21dd90, -0x5a05bdae, 0x5afe8a8b, 0x5a29727b, 0x5adb297d, 0x5a4d1960, 0x5ab7ba6c, 0x5a70b258, 0x5a943d5e, -}; - -const int kbdWindowOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 128}; - -/* Synthesis window - KBD - * format = Q31 for nmdct = [128, 1024] - * reordered for sequential access - * - * aacScaleFact = -sqrt(1.0 / (2.0 * nmdct)); - * for (i = 0; i < nmdct/2; i++) { - * x = kbdWindowRef[i] * aacScaleFact; - * x = kbdWindowRef[nmdct - 1 - i] * aacScaleFact; - * } - * Note: see below for code to generate kbdWindowRef[] - */ -const int kbdWindow[128 + 1024] PROGMEM = { -/* 128 - format = Q31 * 2^0 */ -0x00016f63, 0x7ffffffe, 0x0003e382, 0x7ffffff1, 0x00078f64, 0x7fffffc7, 0x000cc323, 0x7fffff5d, -0x0013d9ed, 0x7ffffe76, 0x001d3a9d, 0x7ffffcaa, 0x0029581f, 0x7ffff953, 0x0038b1bd, 0x7ffff372, -0x004bd34d, 0x7fffe98b, 0x00635538, 0x7fffd975, 0x007fdc64, 0x7fffc024, 0x00a219f1, 0x7fff995b, -0x00cacad0, 0x7fff5f5b, 0x00fab72d, 0x7fff0a75, 0x0132b1af, 0x7ffe9091, 0x01739689, 0x7ffde49e, -0x01be4a63, 0x7ffcf5ef, 0x0213b910, 0x7ffbaf84, 0x0274d41e, 0x7ff9f73a, 0x02e2913a, 0x7ff7acf1, -0x035de86c, 0x7ff4a99a, 0x03e7d233, 0x7ff0be3d, 0x0481457c, 0x7febb2f1, 0x052b357c, 0x7fe545d4, -0x05e68f77, 0x7fdd2a02, 0x06b4386f, 0x7fd30695, 0x07950acb, 0x7fc675b4, 0x0889d3ef, 0x7fb703be, -0x099351e0, 0x7fa42e89, 0x0ab230e0, 0x7f8d64d8, 0x0be70923, 0x7f7205f8, 0x0d325c93, 0x7f516195, -0x0e9494ae, 0x7f2ab7d0, 0x100e0085, 0x7efd3997, 0x119ed2ef, 0x7ec8094a, 0x134720d8, 0x7e8a3ba7, -0x1506dfdc, 0x7e42d906, 0x16dde50b, 0x7df0dee4, 0x18cbe3f7, 0x7d9341b4, 0x1ad06e07, 0x7d28ef02, -0x1ceaf215, 0x7cb0cfcc, 0x1f1abc4f, 0x7c29cb20, 0x215ef677, 0x7b92c8eb, 0x23b6a867, 0x7aeab4ec, -0x2620b8ec, 0x7a3081d0, 0x289beef5, 0x79632c5a, 0x2b26f30b, 0x7881be95, 0x2dc0511f, 0x778b5304, -0x30667aa2, 0x767f17c0, 0x3317c8dd, 0x755c5178, 0x35d27f98, 0x74225e50, 0x3894cff3, 0x72d0b887, -0x3b5cdb7b, 0x7166f8e7, 0x3e28b770, 0x6fe4d8e8, 0x40f6702a, 0x6e4a3491, 0x43c40caa, 0x6c970bfc, -0x468f9231, 0x6acb8483, 0x495707f5, 0x68e7e994, 0x4c187ac7, 0x66ecad1c, 0x4ed200c5, 0x64da6797, -0x5181bcea, 0x62b1d7b7, 0x5425e28e, 0x6073e1ae, 0x56bcb8c2, 0x5e218e16, 0x59449d76, 0x5bbc0875, -/* 1024 - format = Q31 * 2^0 */ -0x0009962f, 0x7fffffa4, 0x000e16fb, 0x7fffff39, 0x0011ea65, 0x7ffffebf, 0x0015750e, 0x7ffffe34, -0x0018dc74, 0x7ffffd96, 0x001c332e, 0x7ffffce5, 0x001f83f5, 0x7ffffc1f, 0x0022d59a, 0x7ffffb43, -0x00262cc2, 0x7ffffa4f, 0x00298cc4, 0x7ffff942, 0x002cf81f, 0x7ffff81a, 0x003070c4, 0x7ffff6d6, -0x0033f840, 0x7ffff573, 0x00378fd9, 0x7ffff3f1, 0x003b38a1, 0x7ffff24d, 0x003ef381, 0x7ffff085, -0x0042c147, 0x7fffee98, 0x0046a2a8, 0x7fffec83, 0x004a9847, 0x7fffea44, 0x004ea2b7, 0x7fffe7d8, -0x0052c283, 0x7fffe53f, 0x0056f829, 0x7fffe274, 0x005b4422, 0x7fffdf76, 0x005fa6dd, 0x7fffdc43, -0x006420c8, 0x7fffd8d6, 0x0068b249, 0x7fffd52f, 0x006d5bc4, 0x7fffd149, 0x00721d9a, 0x7fffcd22, -0x0076f828, 0x7fffc8b6, 0x007bebca, 0x7fffc404, 0x0080f8d9, 0x7fffbf06, 0x00861fae, 0x7fffb9bb, -0x008b609e, 0x7fffb41e, 0x0090bbff, 0x7fffae2c, 0x00963224, 0x7fffa7e1, 0x009bc362, 0x7fffa13a, -0x00a17009, 0x7fff9a32, 0x00a7386c, 0x7fff92c5, 0x00ad1cdc, 0x7fff8af0, 0x00b31da8, 0x7fff82ad, -0x00b93b21, 0x7fff79f9, 0x00bf7596, 0x7fff70cf, 0x00c5cd57, 0x7fff672a, 0x00cc42b1, 0x7fff5d05, -0x00d2d5f3, 0x7fff525c, 0x00d9876c, 0x7fff4729, 0x00e05769, 0x7fff3b66, 0x00e74638, 0x7fff2f10, -0x00ee5426, 0x7fff221f, 0x00f58182, 0x7fff148e, 0x00fcce97, 0x7fff0658, 0x01043bb3, 0x7ffef776, -0x010bc923, 0x7ffee7e2, 0x01137733, 0x7ffed795, 0x011b4631, 0x7ffec68a, 0x01233669, 0x7ffeb4ba, -0x012b4827, 0x7ffea21d, 0x01337bb8, 0x7ffe8eac, 0x013bd167, 0x7ffe7a61, 0x01444982, 0x7ffe6533, -0x014ce454, 0x7ffe4f1c, 0x0155a229, 0x7ffe3813, 0x015e834d, 0x7ffe2011, 0x0167880c, 0x7ffe070d, -0x0170b0b2, 0x7ffdecff, 0x0179fd8b, 0x7ffdd1df, 0x01836ee1, 0x7ffdb5a2, 0x018d0500, 0x7ffd9842, -0x0196c035, 0x7ffd79b3, 0x01a0a0ca, 0x7ffd59ee, 0x01aaa70a, 0x7ffd38e8, 0x01b4d341, 0x7ffd1697, -0x01bf25b9, 0x7ffcf2f2, 0x01c99ebd, 0x7ffccdee, 0x01d43e99, 0x7ffca780, 0x01df0597, 0x7ffc7f9e, -0x01e9f401, 0x7ffc563d, 0x01f50a22, 0x7ffc2b51, 0x02004844, 0x7ffbfecf, 0x020baeb1, 0x7ffbd0ab, -0x02173db4, 0x7ffba0da, 0x0222f596, 0x7ffb6f4f, 0x022ed6a1, 0x7ffb3bfd, 0x023ae11f, 0x7ffb06d8, -0x02471558, 0x7ffacfd3, 0x02537397, 0x7ffa96e0, 0x025ffc25, 0x7ffa5bf2, 0x026caf4a, 0x7ffa1efc, -0x02798d4f, 0x7ff9dfee, 0x0286967c, 0x7ff99ebb, 0x0293cb1b, 0x7ff95b55, 0x02a12b72, 0x7ff915ab, -0x02aeb7cb, 0x7ff8cdaf, 0x02bc706d, 0x7ff88351, 0x02ca559f, 0x7ff83682, 0x02d867a9, 0x7ff7e731, -0x02e6a6d2, 0x7ff7954e, 0x02f51361, 0x7ff740c8, 0x0303ad9c, 0x7ff6e98e, 0x031275ca, 0x7ff68f8f, -0x03216c30, 0x7ff632ba, 0x03309116, 0x7ff5d2fb, 0x033fe4bf, 0x7ff57042, 0x034f6773, 0x7ff50a7a, -0x035f1975, 0x7ff4a192, 0x036efb0a, 0x7ff43576, 0x037f0c78, 0x7ff3c612, 0x038f4e02, 0x7ff35353, -0x039fbfeb, 0x7ff2dd24, 0x03b06279, 0x7ff26370, 0x03c135ed, 0x7ff1e623, 0x03d23a8b, 0x7ff16527, -0x03e37095, 0x7ff0e067, 0x03f4d84e, 0x7ff057cc, 0x040671f7, 0x7fefcb40, 0x04183dd3, 0x7fef3aad, -0x042a3c22, 0x7feea5fa, 0x043c6d25, 0x7fee0d11, 0x044ed11d, 0x7fed6fda, 0x04616849, 0x7fecce3d, -0x047432eb, 0x7fec2821, 0x04873140, 0x7feb7d6c, 0x049a6388, 0x7feace07, 0x04adca01, 0x7fea19d6, -0x04c164ea, 0x7fe960c0, 0x04d53481, 0x7fe8a2aa, 0x04e93902, 0x7fe7df79, 0x04fd72aa, 0x7fe71712, -0x0511e1b6, 0x7fe6495a, 0x05268663, 0x7fe57634, 0x053b60eb, 0x7fe49d83, 0x05507189, 0x7fe3bf2b, -0x0565b879, 0x7fe2db0f, 0x057b35f4, 0x7fe1f110, 0x0590ea35, 0x7fe10111, 0x05a6d574, 0x7fe00af3, -0x05bcf7ea, 0x7fdf0e97, 0x05d351cf, 0x7fde0bdd, 0x05e9e35c, 0x7fdd02a6, 0x0600acc8, 0x7fdbf2d2, -0x0617ae48, 0x7fdadc40, 0x062ee814, 0x7fd9becf, 0x06465a62, 0x7fd89a5e, 0x065e0565, 0x7fd76eca, -0x0675e954, 0x7fd63bf1, 0x068e0662, 0x7fd501b0, 0x06a65cc3, 0x7fd3bfe4, 0x06beecaa, 0x7fd2766a, -0x06d7b648, 0x7fd1251e, 0x06f0b9d1, 0x7fcfcbda, 0x0709f775, 0x7fce6a7a, 0x07236f65, 0x7fcd00d8, -0x073d21d2, 0x7fcb8ecf, 0x07570eea, 0x7fca1439, 0x077136dd, 0x7fc890ed, 0x078b99da, 0x7fc704c7, -0x07a6380d, 0x7fc56f9d, 0x07c111a4, 0x7fc3d147, 0x07dc26cc, 0x7fc2299e, 0x07f777b1, 0x7fc07878, -0x0813047d, 0x7fbebdac, 0x082ecd5b, 0x7fbcf90f, 0x084ad276, 0x7fbb2a78, 0x086713f7, 0x7fb951bc, -0x08839206, 0x7fb76eaf, 0x08a04ccb, 0x7fb58126, 0x08bd446e, 0x7fb388f4, 0x08da7915, 0x7fb185ee, -0x08f7eae7, 0x7faf77e5, 0x09159a09, 0x7fad5ead, 0x0933869f, 0x7fab3a17, 0x0951b0cd, 0x7fa909f6, -0x097018b7, 0x7fa6ce1a, 0x098ebe7f, 0x7fa48653, 0x09ada248, 0x7fa23273, 0x09ccc431, 0x7f9fd249, -0x09ec245b, 0x7f9d65a4, 0x0a0bc2e7, 0x7f9aec53, 0x0a2b9ff3, 0x7f986625, 0x0a4bbb9e, 0x7f95d2e7, -0x0a6c1604, 0x7f933267, 0x0a8caf43, 0x7f908472, 0x0aad8776, 0x7f8dc8d5, 0x0ace9eb9, 0x7f8aff5c, -0x0aeff526, 0x7f8827d3, 0x0b118ad8, 0x7f854204, 0x0b335fe6, 0x7f824dbb, 0x0b557469, 0x7f7f4ac3, -0x0b77c879, 0x7f7c38e4, 0x0b9a5c2b, 0x7f7917e9, 0x0bbd2f97, 0x7f75e79b, 0x0be042d0, 0x7f72a7c3, -0x0c0395ec, 0x7f6f5828, 0x0c2728fd, 0x7f6bf892, 0x0c4afc16, 0x7f6888c9, 0x0c6f0f4a, 0x7f650894, -0x0c9362a8, 0x7f6177b9, 0x0cb7f642, 0x7f5dd5ff, 0x0cdcca26, 0x7f5a232a, 0x0d01de63, 0x7f565f00, -0x0d273307, 0x7f528947, 0x0d4cc81f, 0x7f4ea1c2, 0x0d729db7, 0x7f4aa835, 0x0d98b3da, 0x7f469c65, -0x0dbf0a92, 0x7f427e13, 0x0de5a1e9, 0x7f3e4d04, 0x0e0c79e7, 0x7f3a08f9, 0x0e339295, 0x7f35b1b4, -0x0e5aebfa, 0x7f3146f8, 0x0e82861a, 0x7f2cc884, 0x0eaa60fd, 0x7f28361b, 0x0ed27ca5, 0x7f238f7c, -0x0efad917, 0x7f1ed467, 0x0f237656, 0x7f1a049d, 0x0f4c5462, 0x7f151fdc, 0x0f75733d, 0x7f1025e3, -0x0f9ed2e6, 0x7f0b1672, 0x0fc8735e, 0x7f05f146, 0x0ff254a1, 0x7f00b61d, 0x101c76ae, 0x7efb64b4, -0x1046d981, 0x7ef5fcca, 0x10717d15, 0x7ef07e19, 0x109c6165, 0x7eeae860, 0x10c7866a, 0x7ee53b5b, -0x10f2ec1e, 0x7edf76c4, 0x111e9279, 0x7ed99a58, 0x114a7971, 0x7ed3a5d1, 0x1176a0fc, 0x7ecd98eb, -0x11a30910, 0x7ec77360, 0x11cfb1a1, 0x7ec134eb, 0x11fc9aa2, 0x7ebadd44, 0x1229c406, 0x7eb46c27, -0x12572dbf, 0x7eade14c, 0x1284d7bc, 0x7ea73c6c, 0x12b2c1ed, 0x7ea07d41, 0x12e0ec42, 0x7e99a382, -0x130f56a8, 0x7e92aee7, 0x133e010b, 0x7e8b9f2a, 0x136ceb59, 0x7e847402, 0x139c157b, 0x7e7d2d25, -0x13cb7f5d, 0x7e75ca4c, 0x13fb28e6, 0x7e6e4b2d, 0x142b1200, 0x7e66af7f, 0x145b3a92, 0x7e5ef6f8, -0x148ba281, 0x7e572150, 0x14bc49b4, 0x7e4f2e3b, 0x14ed300f, 0x7e471d70, 0x151e5575, 0x7e3eeea5, -0x154fb9c9, 0x7e36a18e, 0x15815ced, 0x7e2e35e2, 0x15b33ec1, 0x7e25ab56, 0x15e55f25, 0x7e1d019e, -0x1617bdf9, 0x7e14386e, 0x164a5b19, 0x7e0b4f7d, 0x167d3662, 0x7e02467e, 0x16b04fb2, 0x7df91d25, -0x16e3a6e2, 0x7defd327, 0x17173bce, 0x7de66837, 0x174b0e4d, 0x7ddcdc0a, 0x177f1e39, 0x7dd32e53, -0x17b36b69, 0x7dc95ec6, 0x17e7f5b3, 0x7dbf6d17, 0x181cbcec, 0x7db558f9, 0x1851c0e9, 0x7dab221f, -0x1887017d, 0x7da0c83c, 0x18bc7e7c, 0x7d964b05, 0x18f237b6, 0x7d8baa2b, 0x19282cfd, 0x7d80e563, -0x195e5e20, 0x7d75fc5e, 0x1994caee, 0x7d6aeed0, 0x19cb7335, 0x7d5fbc6d, 0x1a0256c2, 0x7d5464e6, -0x1a397561, 0x7d48e7ef, 0x1a70cede, 0x7d3d453b, 0x1aa86301, 0x7d317c7c, 0x1ae03195, 0x7d258d65, -0x1b183a63, 0x7d1977aa, 0x1b507d30, 0x7d0d3afc, 0x1b88f9c5, 0x7d00d710, 0x1bc1afe6, 0x7cf44b97, -0x1bfa9f58, 0x7ce79846, 0x1c33c7e0, 0x7cdabcce, 0x1c6d293f, 0x7ccdb8e4, 0x1ca6c337, 0x7cc08c39, -0x1ce0958a, 0x7cb33682, 0x1d1a9ff8, 0x7ca5b772, 0x1d54e240, 0x7c980ebd, 0x1d8f5c21, 0x7c8a3c14, -0x1dca0d56, 0x7c7c3f2e, 0x1e04f59f, 0x7c6e17bc, 0x1e4014b4, 0x7c5fc573, 0x1e7b6a53, 0x7c514807, -0x1eb6f633, 0x7c429f2c, 0x1ef2b80f, 0x7c33ca96, 0x1f2eaf9e, 0x7c24c9fa, 0x1f6adc98, 0x7c159d0d, -0x1fa73eb2, 0x7c064383, 0x1fe3d5a3, 0x7bf6bd11, 0x2020a11e, 0x7be7096c, 0x205da0d8, 0x7bd7284a, -0x209ad483, 0x7bc71960, 0x20d83bd1, 0x7bb6dc65, 0x2115d674, 0x7ba6710d, 0x2153a41b, 0x7b95d710, -0x2191a476, 0x7b850e24, 0x21cfd734, 0x7b7415ff, 0x220e3c02, 0x7b62ee59, 0x224cd28d, 0x7b5196e9, -0x228b9a82, 0x7b400f67, 0x22ca938a, 0x7b2e578a, 0x2309bd52, 0x7b1c6f0b, 0x23491783, 0x7b0a55a1, -0x2388a1c4, 0x7af80b07, 0x23c85bbf, 0x7ae58ef5, 0x2408451a, 0x7ad2e124, 0x24485d7c, 0x7ac0014e, -0x2488a48a, 0x7aacef2e, 0x24c919e9, 0x7a99aa7e, 0x2509bd3d, 0x7a8632f8, 0x254a8e29, 0x7a728858, -0x258b8c50, 0x7a5eaa5a, 0x25ccb753, 0x7a4a98b9, 0x260e0ed3, 0x7a365333, 0x264f9271, 0x7a21d983, -0x269141cb, 0x7a0d2b68, 0x26d31c80, 0x79f8489e, 0x2715222f, 0x79e330e4, 0x27575273, 0x79cde3f8, -0x2799acea, 0x79b8619a, 0x27dc3130, 0x79a2a989, 0x281ededf, 0x798cbb85, 0x2861b591, 0x7976974e, -0x28a4b4e0, 0x79603ca5, 0x28e7dc65, 0x7949ab4c, 0x292b2bb8, 0x7932e304, 0x296ea270, 0x791be390, -0x29b24024, 0x7904acb3, 0x29f6046b, 0x78ed3e30, 0x2a39eed8, 0x78d597cc, 0x2a7dff02, 0x78bdb94a, -0x2ac2347c, 0x78a5a270, 0x2b068eda, 0x788d5304, 0x2b4b0dae, 0x7874cacb, 0x2b8fb08a, 0x785c098d, -0x2bd47700, 0x78430f11, 0x2c1960a1, 0x7829db1f, 0x2c5e6cfd, 0x78106d7f, 0x2ca39ba3, 0x77f6c5fb, -0x2ce8ec23, 0x77dce45c, 0x2d2e5e0b, 0x77c2c86e, 0x2d73f0e8, 0x77a871fa, 0x2db9a449, 0x778de0cd, -0x2dff77b8, 0x777314b2, 0x2e456ac4, 0x77580d78, 0x2e8b7cf6, 0x773ccaeb, 0x2ed1addb, 0x77214cdb, -0x2f17fcfb, 0x77059315, 0x2f5e69e2, 0x76e99d69, 0x2fa4f419, 0x76cd6ba9, 0x2feb9b27, 0x76b0fda4, -0x30325e96, 0x7694532e, 0x30793dee, 0x76776c17, 0x30c038b5, 0x765a4834, 0x31074e72, 0x763ce759, -0x314e7eab, 0x761f4959, 0x3195c8e6, 0x76016e0b, 0x31dd2ca9, 0x75e35545, 0x3224a979, 0x75c4fedc, -0x326c3ed8, 0x75a66aab, 0x32b3ec4d, 0x75879887, 0x32fbb159, 0x7568884b, 0x33438d81, 0x754939d1, -0x338b8045, 0x7529acf4, 0x33d3892a, 0x7509e18e, 0x341ba7b1, 0x74e9d77d, 0x3463db5a, 0x74c98e9e, -0x34ac23a7, 0x74a906cd, 0x34f48019, 0x74883fec, 0x353cf02f, 0x746739d8, 0x3585736a, 0x7445f472, -0x35ce0949, 0x74246f9c, 0x3616b14c, 0x7402ab37, 0x365f6af0, 0x73e0a727, 0x36a835b5, 0x73be6350, -0x36f11118, 0x739bdf95, 0x3739fc98, 0x73791bdd, 0x3782f7b2, 0x7356180e, 0x37cc01e3, 0x7332d410, -0x38151aa8, 0x730f4fc9, 0x385e417e, 0x72eb8b24, 0x38a775e1, 0x72c7860a, 0x38f0b74d, 0x72a34066, -0x393a053e, 0x727eba24, 0x39835f30, 0x7259f331, 0x39ccc49e, 0x7234eb79, 0x3a163503, 0x720fa2eb, -0x3a5fafda, 0x71ea1977, 0x3aa9349e, 0x71c44f0c, 0x3af2c2ca, 0x719e439d, 0x3b3c59d7, 0x7177f71a, -0x3b85f940, 0x71516978, 0x3bcfa07e, 0x712a9aaa, 0x3c194f0d, 0x71038aa4, 0x3c630464, 0x70dc395e, -0x3cacbfff, 0x70b4a6cd, 0x3cf68155, 0x708cd2e9, 0x3d4047e1, 0x7064bdab, 0x3d8a131c, 0x703c670d, -0x3dd3e27e, 0x7013cf0a, 0x3e1db580, 0x6feaf59c, 0x3e678b9b, 0x6fc1dac1, 0x3eb16449, 0x6f987e76, -0x3efb3f01, 0x6f6ee0b9, 0x3f451b3d, 0x6f45018b, 0x3f8ef874, 0x6f1ae0eb, 0x3fd8d620, 0x6ef07edb, -0x4022b3b9, 0x6ec5db5d, 0x406c90b7, 0x6e9af675, 0x40b66c93, 0x6e6fd027, 0x410046c5, 0x6e446879, -0x414a1ec6, 0x6e18bf71, 0x4193f40d, 0x6decd517, 0x41ddc615, 0x6dc0a972, 0x42279455, 0x6d943c8d, -0x42715e45, 0x6d678e71, 0x42bb235f, 0x6d3a9f2a, 0x4304e31a, 0x6d0d6ec5, 0x434e9cf1, 0x6cdffd4f, -0x4398505b, 0x6cb24ad6, 0x43e1fcd1, 0x6c84576b, 0x442ba1cd, 0x6c56231c, 0x44753ec7, 0x6c27adfd, -0x44bed33a, 0x6bf8f81e, 0x45085e9d, 0x6bca0195, 0x4551e06b, 0x6b9aca75, 0x459b581e, 0x6b6b52d5, -0x45e4c52f, 0x6b3b9ac9, 0x462e2717, 0x6b0ba26b, 0x46777d52, 0x6adb69d3, 0x46c0c75a, 0x6aaaf11b, -0x470a04a9, 0x6a7a385c, 0x475334b9, 0x6a493fb3, 0x479c5707, 0x6a18073d, 0x47e56b0c, 0x69e68f17, -0x482e7045, 0x69b4d761, 0x4877662c, 0x6982e039, 0x48c04c3f, 0x6950a9c0, 0x490921f8, 0x691e341a, -0x4951e6d5, 0x68eb7f67, 0x499a9a51, 0x68b88bcd, 0x49e33beb, 0x68855970, 0x4a2bcb1f, 0x6851e875, -0x4a74476b, 0x681e3905, 0x4abcb04c, 0x67ea4b47, 0x4b050541, 0x67b61f63, 0x4b4d45c9, 0x6781b585, -0x4b957162, 0x674d0dd6, 0x4bdd878c, 0x67182883, 0x4c2587c6, 0x66e305b8, 0x4c6d7190, 0x66ada5a5, -0x4cb5446a, 0x66780878, 0x4cfcffd5, 0x66422e60, 0x4d44a353, 0x660c1790, 0x4d8c2e64, 0x65d5c439, -0x4dd3a08c, 0x659f348e, 0x4e1af94b, 0x656868c3, 0x4e623825, 0x6531610d, 0x4ea95c9d, 0x64fa1da3, -0x4ef06637, 0x64c29ebb, 0x4f375477, 0x648ae48d, 0x4f7e26e1, 0x6452ef53, 0x4fc4dcfb, 0x641abf46, -0x500b7649, 0x63e254a2, 0x5051f253, 0x63a9afa2, 0x5098509f, 0x6370d083, 0x50de90b3, 0x6337b784, -0x5124b218, 0x62fe64e3, 0x516ab455, 0x62c4d8e0, 0x51b096f3, 0x628b13bc, 0x51f6597b, 0x625115b8, -0x523bfb78, 0x6216df18, 0x52817c72, 0x61dc701f, 0x52c6dbf5, 0x61a1c912, 0x530c198d, 0x6166ea36, -0x535134c5, 0x612bd3d2, 0x53962d2a, 0x60f0862d, 0x53db024a, 0x60b50190, 0x541fb3b1, 0x60794644, -0x546440ef, 0x603d5494, 0x54a8a992, 0x60012cca, 0x54eced2b, 0x5fc4cf33, 0x55310b48, 0x5f883c1c, -0x5575037c, 0x5f4b73d2, 0x55b8d558, 0x5f0e76a5, 0x55fc806f, 0x5ed144e5, 0x56400452, 0x5e93dee1, -0x56836096, 0x5e5644ec, 0x56c694cf, 0x5e187757, 0x5709a092, 0x5dda7677, 0x574c8374, 0x5d9c429f, -0x578f3d0d, 0x5d5ddc24, 0x57d1ccf2, 0x5d1f435d, 0x581432bd, 0x5ce078a0, 0x58566e04, 0x5ca17c45, -0x58987e63, 0x5c624ea4, 0x58da6372, 0x5c22f016, 0x591c1ccc, 0x5be360f6, 0x595daa0d, 0x5ba3a19f, -0x599f0ad1, 0x5b63b26c, 0x59e03eb6, 0x5b2393ba, 0x5a214558, 0x5ae345e7, 0x5a621e56, 0x5aa2c951, -}; - - - -/* bit reverse tables for FFT */ - -const int bitrevtabOffset[NUM_IMDCT_SIZES] PROGMEM = {0, 17}; - -const unsigned char bitrevtab[17 + 129] PROGMEM = { -/* nfft = 64 */ -0x01, 0x08, 0x02, 0x04, 0x03, 0x0c, 0x05, 0x0a, 0x07, 0x0e, 0x0b, 0x0d, 0x00, 0x06, 0x09, 0x0f, -0x00, - -/* nfft = 512 */ -0x01, 0x40, 0x02, 0x20, 0x03, 0x60, 0x04, 0x10, 0x05, 0x50, 0x06, 0x30, 0x07, 0x70, 0x09, 0x48, -0x0a, 0x28, 0x0b, 0x68, 0x0c, 0x18, 0x0d, 0x58, 0x0e, 0x38, 0x0f, 0x78, 0x11, 0x44, 0x12, 0x24, -0x13, 0x64, 0x15, 0x54, 0x16, 0x34, 0x17, 0x74, 0x19, 0x4c, 0x1a, 0x2c, 0x1b, 0x6c, 0x1d, 0x5c, -0x1e, 0x3c, 0x1f, 0x7c, 0x21, 0x42, 0x23, 0x62, 0x25, 0x52, 0x26, 0x32, 0x27, 0x72, 0x29, 0x4a, -0x2b, 0x6a, 0x2d, 0x5a, 0x2e, 0x3a, 0x2f, 0x7a, 0x31, 0x46, 0x33, 0x66, 0x35, 0x56, 0x37, 0x76, -0x39, 0x4e, 0x3b, 0x6e, 0x3d, 0x5e, 0x3f, 0x7e, 0x43, 0x61, 0x45, 0x51, 0x47, 0x71, 0x4b, 0x69, -0x4d, 0x59, 0x4f, 0x79, 0x53, 0x65, 0x57, 0x75, 0x5b, 0x6d, 0x5f, 0x7d, 0x67, 0x73, 0x6f, 0x7b, -0x00, 0x08, 0x14, 0x1c, 0x22, 0x2a, 0x36, 0x3e, 0x41, 0x49, 0x55, 0x5d, 0x63, 0x6b, 0x77, 0x7f, -0x00, - -}; - -const unsigned char uniqueIDTab[8] = {0x5f, 0x4b, 0x43, 0x5f, 0x5f, 0x4a, 0x52, 0x5f}; - -/* Twiddle tables for FFT - * format = Q30 - * - * for (k = 4; k <= N/4; k <<= 1) { - * for (j = 0; j < k; j++) { - * double wr1, wi1, wr2, wi2, wr3, wi3; - * - * wr1 = cos(1.0 * M_PI * j / (2*k)); - * wi1 = sin(1.0 * M_PI * j / (2*k)); - * wr1 = (wr1 + wi1); - * wi1 = -wi1; - * - * wr2 = cos(2.0 * M_PI * j / (2*k)); - * wi2 = sin(2.0 * M_PI * j / (2*k)); - * wr2 = (wr2 + wi2); - * wi2 = -wi2; - * - * wr3 = cos(3.0 * M_PI * j / (2*k)); - * wi3 = sin(3.0 * M_PI * j / (2*k)); - * wr3 = (wr3 + wi3); - * wi3 = -wi3; - * - * if (k & 0xaaaaaaaa) { - * w_odd[iodd++] = (float)wr2; - * w_odd[iodd++] = (float)wi2; - * w_odd[iodd++] = (float)wr1; - * w_odd[iodd++] = (float)wi1; - * w_odd[iodd++] = (float)wr3; - * w_odd[iodd++] = (float)wi3; - * } else { - * w_even[ieven++] = (float)wr2; - * w_even[ieven++] = (float)wi2; - * w_even[ieven++] = (float)wr1; - * w_even[ieven++] = (float)wi1; - * w_even[ieven++] = (float)wr3; - * w_even[ieven++] = (float)wi3; - * } - * } - * } - */ -const int twidTabOdd[8*6 + 32*6 + 128*6] PROGMEM = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x539eba45, 0xe7821d59, - 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, - 0x539eba45, 0xc4df2862, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x22a2f4f8, 0xc4df2862, - 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, - 0xac6145bb, 0x187de2a7, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x45f704f7, 0xf9ba1651, - 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, - 0x4fd288dc, 0xed6bf9d1, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x569cc31b, 0xe1d4a2c8, - 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, - 0x5a12e720, 0xce86ff2a, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a12e720, 0xce86ff2a, - 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, - 0x45f704f7, 0xc04ee4b8, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x4fd288dc, 0xc2c17d52, - 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, - 0x1a4608ab, 0xc78e9a1d, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x396b3199, 0xc04ee4b8, - 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, - 0xe5b9f755, 0xe1d4a2c8, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1a4608ab, 0xc78e9a1d, - 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, - 0xba08fb09, 0x0645e9af, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xf720e574, 0xd76619b6, - 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, - 0xa5ed18e0, 0x2899e64a, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd5558381, 0xed6bf9d1, - 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, - 0xb02d7724, 0x3d3e82ae, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x418d2621, 0xfe6deaa1, - 0x40c7d2bd, 0xff36f170, 0x424ff28f, 0xfda4f351, 0x43103085, 0xfcdc1342, 0x418d2621, 0xfe6deaa1, - 0x4488e37f, 0xfb4ab7db, 0x4488e37f, 0xfb4ab7db, 0x424ff28f, 0xfda4f351, 0x46aa0d6d, 0xf8f21e8e, - 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, 0x48b2b335, 0xf69bf7c9, 0x475a5c77, 0xf82a6c6a, - 0x43cdd89a, 0xfc135231, 0x4aa22036, 0xf4491311, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, - 0x4c77a88e, 0xf1fa3ecb, 0x49ffd417, 0xf50ef5de, 0x454149fc, 0xfa824bfd, 0x4e32a956, 0xefb047f2, - 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4c77a88e, 0xf1fa3ecb, - 0x46aa0d6d, 0xf8f21e8e, 0x5156b6d9, 0xeb2e1dbe, 0x4da1fab5, 0xf0730342, 0x475a5c77, 0xf82a6c6a, - 0x52beac9f, 0xe8f77acf, 0x4ec05432, 0xeeee2d9d, 0x4807eb4b, 0xf7630799, 0x5409ed4b, 0xe6c8d59c, - 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, 0x553805f2, 0xe4a2eff6, 0x50d86e6d, 0xebeca36c, - 0x495aada2, 0xf5d544a7, 0x56488dc5, 0xe28688a4, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, - 0x573b2635, 0xe0745b24, 0x52beac9f, 0xe8f77acf, 0x4aa22036, 0xf4491311, 0x580f7b19, 0xde6d1f65, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x5471e2e6, 0xe61086bc, - 0x4bde1089, 0xf2beafed, 0x595c3e2a, 0xda8249b4, 0x553805f2, 0xe4a2eff6, 0x4c77a88e, 0xf1fa3ecb, - 0x59d438e5, 0xd8a00bae, 0x55f104dc, 0xe3399167, 0x4d0e4de2, 0xf136580d, 0x5a2d0957, 0xd6cb76c9, - 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, 0x5a6690ae, 0xd5052d97, 0x573b2635, 0xe0745b24, - 0x4e32a956, 0xefb047f2, 0x5a80baf6, 0xd34dcdb4, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, - 0x5a7b7f1a, 0xd1a5ef90, 0x584f7b58, 0xddc29958, 0x4f4af5d1, 0xee2cbbc1, 0x5a56deec, 0xd00e2639, - 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x592d59da, 0xdb25f566, - 0x50570819, 0xecabef3d, 0x59afaf4c, 0xcd110216, 0x5987b08a, 0xd9e01006, 0x50d86e6d, 0xebeca36c, - 0x592d59da, 0xcbacb0bf, 0x59d438e5, 0xd8a00bae, 0x5156b6d9, 0xeb2e1dbe, 0x588c1404, 0xca5a86c4, - 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, 0x57cc15bc, 0xc91af976, 0x5a43b190, 0xd6326a88, - 0x5249daa2, 0xe9b38223, 0x56eda1a0, 0xc7ee77b3, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, - 0x55f104dc, 0xc6d569be, 0x5a7b7f1a, 0xd3de9156, 0x53304df6, 0xe83c56cf, 0x54d69714, 0xc5d03118, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a7b7f1a, 0xd1a5ef90, - 0x5409ed4b, 0xe6c8d59c, 0x5249daa2, 0xc402a33c, 0x5a6690ae, 0xd09441bb, 0x5471e2e6, 0xe61086bc, - 0x50d86e6d, 0xc33aee27, 0x5a43b190, 0xcf89e3e8, 0x54d69714, 0xe55937d5, 0x4f4af5d1, 0xc2884e6e, - 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d, - 0x55962bc0, 0xe3edb628, 0x4bde1089, 0xc1633f8a, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, - 0x49ffd417, 0xc0f1360b, 0x592d59da, 0xcbacb0bf, 0x56488dc5, 0xe28688a4, 0x4807eb4b, 0xc0950d1d, - 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x584f7b58, 0xc9edeb50, - 0x56eda1a0, 0xe123e6ad, 0x43cdd89a, 0xc01ed535, 0x57cc15bc, 0xc91af976, 0x573b2635, 0xe0745b24, - 0x418d2621, 0xc004ef3f, 0x573b2635, 0xc8507ea7, 0x57854ddd, 0xdfc606f1, 0x3f35b59d, 0xc0013bd3, - 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, 0x3cc85709, 0xc013bc39, 0x55f104dc, 0xc6d569be, - 0x580f7b19, 0xde6d1f65, 0x3a45e1f7, 0xc03c6a07, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, - 0x37af354c, 0xc07b371e, 0x5471e2e6, 0xc57d965d, 0x588c1404, 0xdd196538, 0x350536f1, 0xc0d00db6, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x52beac9f, 0xc449d892, - 0x58fb0568, 0xdbcb0cce, 0x2f7afdfc, 0xc1bb5a11, 0x51d1dc80, 0xc3bdbdf6, 0x592d59da, 0xdb25f566, - 0x2c9caf6c, 0xc2517e31, 0x50d86e6d, 0xc33aee27, 0x595c3e2a, 0xda8249b4, 0x29aee694, 0xc2fd08a9, - 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, 0x26b2a794, 0xc3bdbdf6, 0x4ec05432, 0xc2517e31, - 0x59afaf4c, 0xd93f4e9e, 0x23a8fb93, 0xc4935b3c, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, - 0x2092f05f, 0xc57d965d, 0x4c77a88e, 0xc18e18a7, 0x59f54bee, 0xd8024d59, 0x1d719810, 0xc67c1e18, - 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x49ffd417, 0xc0f1360b, - 0x5a2d0957, 0xd6cb76c9, 0x17115bc0, 0xc8b4ab32, 0x48b2b335, 0xc0b15502, 0x5a43b190, 0xd6326a88, - 0x13d4ae08, 0xc9edeb50, 0x475a5c77, 0xc07b371e, 0x5a56deec, 0xd59afadb, 0x10911f04, 0xcb39edca, - 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, 0x0d47d096, 0xcc983f70, 0x4488e37f, 0xc02c64a6, - 0x5a72c63b, 0xd4710883, 0x09f9e6a1, 0xce0866b8, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, - 0x06a886a0, 0xcf89e3e8, 0x418d2621, 0xc004ef3f, 0x5a80baf6, 0xd34dcdb4, 0x0354d741, 0xd11c3142, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3e68fb62, 0xc004ef3f, - 0x5a80baf6, 0xd2317756, 0xfcab28bf, 0xd4710883, 0x3cc85709, 0xc013bc39, 0x5a7b7f1a, 0xd1a5ef90, - 0xf9577960, 0xd6326a88, 0x3b1e5335, 0xc02c64a6, 0x5a72c63b, 0xd11c3142, 0xf606195f, 0xd8024d59, - 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, 0xf2b82f6a, 0xd9e01006, 0x37af354c, 0xc07b371e, - 0x5a56deec, 0xd00e2639, 0xef6ee0fc, 0xdbcb0cce, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, - 0xec2b51f8, 0xddc29958, 0x341dbfd3, 0xc0f1360b, 0x5a2d0957, 0xcf077fe1, 0xe8eea440, 0xdfc606f1, - 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x306c2624, 0xc18e18a7, - 0x59f54bee, 0xce0866b8, 0xe28e67f0, 0xe3edb628, 0x2e88013a, 0xc1eb0209, 0x59d438e5, 0xcd8bbb6d, - 0xdf6d0fa1, 0xe61086bc, 0x2c9caf6c, 0xc2517e31, 0x59afaf4c, 0xcd110216, 0xdc57046d, 0xe83c56cf, - 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, 0xd94d586c, 0xea70658a, 0x28b1b544, 0xc33aee27, - 0x595c3e2a, 0xcc217822, 0xd651196c, 0xecabef3d, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, - 0xd3635094, 0xeeee2d9d, 0x24ada23d, 0xc449d892, 0x58fb0568, 0xcb39edca, 0xd0850204, 0xf136580d, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x2092f05f, 0xc57d965d, - 0x588c1404, 0xca5a86c4, 0xcafac90f, 0xf5d544a7, 0x1e7de5df, 0xc6250a18, 0x584f7b58, 0xc9edeb50, - 0xc850cab4, 0xf82a6c6a, 0x1c6427a9, 0xc6d569be, 0x580f7b19, 0xc9836582, 0xc5ba1e09, 0xfa824bfd, - 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, 0xc337a8f7, 0xfcdc1342, 0x1823dc7d, 0xc8507ea7, - 0x57854ddd, 0xc8b4ab32, 0xc0ca4a63, 0xff36f170, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, - 0xbe72d9df, 0x0192155f, 0x13d4ae08, 0xc9edeb50, 0x56eda1a0, 0xc7ee77b3, 0xbc322766, 0x03ecadcf, - 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0f7944a7, 0xcbacb0bf, - 0x56488dc5, 0xc730e997, 0xb7f814b5, 0x089cf867, 0x0d47d096, 0xcc983f70, 0x55f104dc, 0xc6d569be, - 0xb6002be9, 0x0af10a22, 0x0b145041, 0xcd8bbb6d, 0x55962bc0, 0xc67c1e18, 0xb421ef77, 0x0d415013, - 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, 0xb25e054b, 0x0f8cfcbe, 0x06a886a0, 0xcf89e3e8, - 0x54d69714, 0xc5d03118, 0xb0b50a2f, 0x11d3443f, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, - 0xaf279193, 0x14135c94, 0x0238a1c6, 0xd1a5ef90, 0x5409ed4b, 0xc52d3d18, 0xadb6255e, 0x164c7ddd, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfdc75e3a, 0xd3de9156, - 0x53304df6, 0xc4935b3c, 0xab2968ec, 0x1aa6c82b, 0xfb8f1424, 0xd5052d97, 0x52beac9f, 0xc449d892, - 0xaa0efb24, 0x1cc66e99, 0xf9577960, 0xd6326a88, 0x5249daa2, 0xc402a33c, 0xa9125e60, 0x1edc1953, - 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, 0xa833ea44, 0x20e70f32, 0xf4ebafbf, 0xd8a00bae, - 0x5156b6d9, 0xc37b2b6a, 0xa773ebfc, 0x22e69ac8, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, - 0xa6d2a626, 0x24da0a9a, 0xf086bb59, 0xdb25f566, 0x50570819, 0xc2fd08a9, 0xa65050b4, 0x26c0b162, - 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xec2b51f8, 0xddc29958, - 0x4f4af5d1, 0xc2884e6e, 0xa5a92114, 0x2a650525, 0xea0208a8, 0xdf18f0ce, 0x4ec05432, 0xc2517e31, - 0xa58480e6, 0x2c216eaa, 0xe7dc2383, 0xe0745b24, 0x4e32a956, 0xc21d0eb8, 0xa57f450a, 0x2dce88aa, - 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, 0xa5996f52, 0x2f6bbe45, 0xe39bd857, 0xe3399167, - 0x4d0e4de2, 0xc1bb5a11, 0xa5d2f6a9, 0x30f8801f, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, - 0xa62bc71b, 0x32744493, 0xdf6d0fa1, 0xe61086bc, 0x4bde1089, 0xc1633f8a, 0xa6a3c1d6, 0x33de87de, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xdb525dc3, 0xe8f77acf, - 0x4aa22036, 0xc114ccb9, 0xa7f084e7, 0x367c9a7e, 0xd94d586c, 0xea70658a, 0x49ffd417, 0xc0f1360b, - 0xa8c4d9cb, 0x37af8159, 0xd74e4abc, 0xebeca36c, 0x495aada2, 0xc0d00db6, 0xa9b7723b, 0x38cf1669, - 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, 0xaac7fa0e, 0x39daf5e8, 0xd3635094, 0xeeee2d9d, - 0x4807eb4b, 0xc0950d1d, 0xabf612b5, 0x3ad2c2e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, - 0xad415361, 0x3bb6276e, 0xcf93d9dc, 0xf1fa3ecb, 0x46aa0d6d, 0xc063d405, 0xaea94927, 0x3c84d496, - 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xcbe2402d, 0xf50ef5de, - 0x454149fc, 0xc03c6a07, 0xb1cd56aa, 0x3de2f148, 0xca155d39, 0xf69bf7c9, 0x4488e37f, 0xc02c64a6, - 0xb3885772, 0x3e71e759, 0xc850cab4, 0xf82a6c6a, 0x43cdd89a, 0xc01ed535, 0xb55ddfca, 0x3eeb3347, - 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, 0xb74d4ccb, 0x3f4eaafe, 0xc4e1accb, 0xfb4ab7db, - 0x424ff28f, 0xc00b1a20, 0xb955f293, 0x3f9c2bfb, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, - 0xbb771c81, 0x3fd39b5a, 0xc197049e, 0xfe6deaa1, 0x40c7d2bd, 0xc0013bd3, 0xbdb00d71, 0x3ff4e5e0, -}; - -const int twidTabEven[4*6 + 16*6 + 64*6] PROGMEM = { - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x5a82799a, 0xd2bec333, - 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, - 0x00000000, 0xd2bec333, 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x4b418bbe, 0xf383a3e2, - 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, - 0x58c542c5, 0xdc71898d, 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xcac933ae, - 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, - 0x3248d382, 0xc13ad060, 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3248d382, 0xc13ad060, - 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, - 0xcdb72c7e, 0xf383a3e2, 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xee57aa21, 0xdc71898d, - 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, - 0xa73abd3b, 0x3536cc52, 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, - - 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x40000000, 0x00000000, 0x43103085, 0xfcdc1342, - 0x418d2621, 0xfe6deaa1, 0x4488e37f, 0xfb4ab7db, 0x45f704f7, 0xf9ba1651, 0x43103085, 0xfcdc1342, - 0x48b2b335, 0xf69bf7c9, 0x48b2b335, 0xf69bf7c9, 0x4488e37f, 0xfb4ab7db, 0x4c77a88e, 0xf1fa3ecb, - 0x4b418bbe, 0xf383a3e2, 0x45f704f7, 0xf9ba1651, 0x4fd288dc, 0xed6bf9d1, 0x4da1fab5, 0xf0730342, - 0x475a5c77, 0xf82a6c6a, 0x52beac9f, 0xe8f77acf, 0x4fd288dc, 0xed6bf9d1, 0x48b2b335, 0xf69bf7c9, - 0x553805f2, 0xe4a2eff6, 0x51d1dc80, 0xea70658a, 0x49ffd417, 0xf50ef5de, 0x573b2635, 0xe0745b24, - 0x539eba45, 0xe7821d59, 0x4b418bbe, 0xf383a3e2, 0x58c542c5, 0xdc71898d, 0x553805f2, 0xe4a2eff6, - 0x4c77a88e, 0xf1fa3ecb, 0x59d438e5, 0xd8a00bae, 0x569cc31b, 0xe1d4a2c8, 0x4da1fab5, 0xf0730342, - 0x5a6690ae, 0xd5052d97, 0x57cc15bc, 0xdf18f0ce, 0x4ec05432, 0xeeee2d9d, 0x5a7b7f1a, 0xd1a5ef90, - 0x58c542c5, 0xdc71898d, 0x4fd288dc, 0xed6bf9d1, 0x5a12e720, 0xce86ff2a, 0x5987b08a, 0xd9e01006, - 0x50d86e6d, 0xebeca36c, 0x592d59da, 0xcbacb0bf, 0x5a12e720, 0xd76619b6, 0x51d1dc80, 0xea70658a, - 0x57cc15bc, 0xc91af976, 0x5a6690ae, 0xd5052d97, 0x52beac9f, 0xe8f77acf, 0x55f104dc, 0xc6d569be, - 0x5a82799a, 0xd2bec333, 0x539eba45, 0xe7821d59, 0x539eba45, 0xc4df2862, 0x5a6690ae, 0xd09441bb, - 0x5471e2e6, 0xe61086bc, 0x50d86e6d, 0xc33aee27, 0x5a12e720, 0xce86ff2a, 0x553805f2, 0xe4a2eff6, - 0x4da1fab5, 0xc1eb0209, 0x5987b08a, 0xcc983f70, 0x55f104dc, 0xe3399167, 0x49ffd417, 0xc0f1360b, - 0x58c542c5, 0xcac933ae, 0x569cc31b, 0xe1d4a2c8, 0x45f704f7, 0xc04ee4b8, 0x57cc15bc, 0xc91af976, - 0x573b2635, 0xe0745b24, 0x418d2621, 0xc004ef3f, 0x569cc31b, 0xc78e9a1d, 0x57cc15bc, 0xdf18f0ce, - 0x3cc85709, 0xc013bc39, 0x553805f2, 0xc6250a18, 0x584f7b58, 0xddc29958, 0x37af354c, 0xc07b371e, - 0x539eba45, 0xc4df2862, 0x58c542c5, 0xdc71898d, 0x3248d382, 0xc13ad060, 0x51d1dc80, 0xc3bdbdf6, - 0x592d59da, 0xdb25f566, 0x2c9caf6c, 0xc2517e31, 0x4fd288dc, 0xc2c17d52, 0x5987b08a, 0xd9e01006, - 0x26b2a794, 0xc3bdbdf6, 0x4da1fab5, 0xc1eb0209, 0x59d438e5, 0xd8a00bae, 0x2092f05f, 0xc57d965d, - 0x4b418bbe, 0xc13ad060, 0x5a12e720, 0xd76619b6, 0x1a4608ab, 0xc78e9a1d, 0x48b2b335, 0xc0b15502, - 0x5a43b190, 0xd6326a88, 0x13d4ae08, 0xc9edeb50, 0x45f704f7, 0xc04ee4b8, 0x5a6690ae, 0xd5052d97, - 0x0d47d096, 0xcc983f70, 0x43103085, 0xc013bc39, 0x5a7b7f1a, 0xd3de9156, 0x06a886a0, 0xcf89e3e8, - 0x40000000, 0xc0000000, 0x5a82799a, 0xd2bec333, 0x00000000, 0xd2bec333, 0x3cc85709, 0xc013bc39, - 0x5a7b7f1a, 0xd1a5ef90, 0xf9577960, 0xd6326a88, 0x396b3199, 0xc04ee4b8, 0x5a6690ae, 0xd09441bb, - 0xf2b82f6a, 0xd9e01006, 0x35eaa2c7, 0xc0b15502, 0x5a43b190, 0xcf89e3e8, 0xec2b51f8, 0xddc29958, - 0x3248d382, 0xc13ad060, 0x5a12e720, 0xce86ff2a, 0xe5b9f755, 0xe1d4a2c8, 0x2e88013a, 0xc1eb0209, - 0x59d438e5, 0xcd8bbb6d, 0xdf6d0fa1, 0xe61086bc, 0x2aaa7c7f, 0xc2c17d52, 0x5987b08a, 0xcc983f70, - 0xd94d586c, 0xea70658a, 0x26b2a794, 0xc3bdbdf6, 0x592d59da, 0xcbacb0bf, 0xd3635094, 0xeeee2d9d, - 0x22a2f4f8, 0xc4df2862, 0x58c542c5, 0xcac933ae, 0xcdb72c7e, 0xf383a3e2, 0x1e7de5df, 0xc6250a18, - 0x584f7b58, 0xc9edeb50, 0xc850cab4, 0xf82a6c6a, 0x1a4608ab, 0xc78e9a1d, 0x57cc15bc, 0xc91af976, - 0xc337a8f7, 0xfcdc1342, 0x15fdf758, 0xc91af976, 0x573b2635, 0xc8507ea7, 0xbe72d9df, 0x0192155f, - 0x11a855df, 0xcac933ae, 0x569cc31b, 0xc78e9a1d, 0xba08fb09, 0x0645e9af, 0x0d47d096, 0xcc983f70, - 0x55f104dc, 0xc6d569be, 0xb6002be9, 0x0af10a22, 0x08df1a8c, 0xce86ff2a, 0x553805f2, 0xc6250a18, - 0xb25e054b, 0x0f8cfcbe, 0x0470ebdc, 0xd09441bb, 0x5471e2e6, 0xc57d965d, 0xaf279193, 0x14135c94, - 0x00000000, 0xd2bec333, 0x539eba45, 0xc4df2862, 0xac6145bb, 0x187de2a7, 0xfb8f1424, 0xd5052d97, - 0x52beac9f, 0xc449d892, 0xaa0efb24, 0x1cc66e99, 0xf720e574, 0xd76619b6, 0x51d1dc80, 0xc3bdbdf6, - 0xa833ea44, 0x20e70f32, 0xf2b82f6a, 0xd9e01006, 0x50d86e6d, 0xc33aee27, 0xa6d2a626, 0x24da0a9a, - 0xee57aa21, 0xdc71898d, 0x4fd288dc, 0xc2c17d52, 0xa5ed18e0, 0x2899e64a, 0xea0208a8, 0xdf18f0ce, - 0x4ec05432, 0xc2517e31, 0xa58480e6, 0x2c216eaa, 0xe5b9f755, 0xe1d4a2c8, 0x4da1fab5, 0xc1eb0209, - 0xa5996f52, 0x2f6bbe45, 0xe1821a21, 0xe4a2eff6, 0x4c77a88e, 0xc18e18a7, 0xa62bc71b, 0x32744493, - 0xdd5d0b08, 0xe7821d59, 0x4b418bbe, 0xc13ad060, 0xa73abd3b, 0x3536cc52, 0xd94d586c, 0xea70658a, - 0x49ffd417, 0xc0f1360b, 0xa8c4d9cb, 0x37af8159, 0xd5558381, 0xed6bf9d1, 0x48b2b335, 0xc0b15502, - 0xaac7fa0e, 0x39daf5e8, 0xd177fec6, 0xf0730342, 0x475a5c77, 0xc07b371e, 0xad415361, 0x3bb6276e, - 0xcdb72c7e, 0xf383a3e2, 0x45f704f7, 0xc04ee4b8, 0xb02d7724, 0x3d3e82ae, 0xca155d39, 0xf69bf7c9, - 0x4488e37f, 0xc02c64a6, 0xb3885772, 0x3e71e759, 0xc694ce67, 0xf9ba1651, 0x43103085, 0xc013bc39, - 0xb74d4ccb, 0x3f4eaafe, 0xc337a8f7, 0xfcdc1342, 0x418d2621, 0xc004ef3f, 0xbb771c81, 0x3fd39b5a, -}; - -/* for reference, here's the code to generate the bitreverse tables - short blocks: nbits = 4 (nfft = 64) - long blocks: nbits = 7 (nfft = 512) - -static int bitrev(int n, int nbits) -{ - int r, i; - - r = 0; - for (i = 0; i < nbits; i++) { - r <<= 1; - r |= (n & 1); - n >>= 1; - } - - return r; -} - -static void InitBitrevTable(unsigned char *out, int nbits) -{ - int i, t; - - for (i = 0; i < (1< KBD_THRESH); - - return i0; -} - -static double CalcW(double nRef, double n, double a) -{ - double i0Base, i0Curr, nTemp; - - i0Base = CalcI0(M_PI * a); - - nTemp = (n - nRef/4) / (nRef/4); - i0Curr = CalcI0( M_PI * a * sqrt(1.0 - nTemp*nTemp) ); - - return i0Curr / i0Base; -} - -void InitKBDWindow(int nmdct) -{ - int n, nRef; - double a, wBase, wCurr; - - nRef = nmdct * 2; - - / *** kbd window *** / - if (nmdct == 128) - a = 6.0; - else - a = 4.0; - - wBase = 0; - for (n = 0; n <= nRef/2; n++) - wBase += CalcW(nRef, n, a); - - / *** left *** / - wCurr = 0; - for (n = 0; n < nRef/2; n++) { - wCurr += CalcW(nRef, n, a); - kbdWindowRef[n] = sqrt(wCurr / wBase); - } - - / *** - * symmetry: - * kbd_right(n) = kbd_ldef(N_REF - 1 - n), n = [N_REF/2, N_REF - 1] - * - * wCurr = 0; - * for (n = N_REF-1; n >= N_REF/2; n--) { - * wCurr += CalcW(N_REF-n-1, a); - * kbdWindowRef[n] = sqrt(wCurr / wBase); - * } - * - *** / - return; -} -*/ -#pragma GCC diagnostic pop diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/CMakeLists.txt b/components/spotify/cspot/bell/external/opencore-aacdec/CMakeLists.txt new file mode 100644 index 00000000..2a7b3299 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB AACDEC_SOURCES "src/*.c") +file(GLOB AACDEC_HEADERS "src/*.h" "oscl/*.h" "include/*.h") + +add_library(opencore-aacdec SHARED ${AACDEC_SOURCES}) +add_definitions(-DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DC_EQUIVALENT) +target_compile_options(opencore-aacdec PRIVATE -Wno-array-parameter) +target_include_directories(opencore-aacdec PUBLIC "src/" "oscl/" "include/") \ No newline at end of file diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/include/Makefile.am b/components/spotify/cspot/bell/external/opencore-aacdec/include/Makefile.am new file mode 100644 index 00000000..ddc4529e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/include/Makefile.am @@ -0,0 +1,6 @@ + +pkgincludedir = $(includedir)/aacdec +pkginclude_HEADERS = e_tmp4audioobjecttype.h \ + pv_audio_type_defs.h \ + pvmp4audiodecoder_api.h \ + getactualaacconfig.h diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/include/e_tmp4audioobjecttype.h b/components/spotify/cspot/bell/external/opencore-aacdec/include/e_tmp4audioobjecttype.h new file mode 100644 index 00000000..30b8d19e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/include/e_tmp4audioobjecttype.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_tmp4audioobjecttype.h + + This file contains enumerated types for MP4 Audio Object Types, as defined + in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15 + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_TMP4AUDIOOBJECTTYPE_H +#define E_TMP4AUDIOOBJECTTYPE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + typedef enum eMP4AudioObjectType + { + MP4AUDIO_NULL = 0, /* */ + MP4AUDIO_AAC_MAIN = 1, /* */ + MP4AUDIO_AAC_LC = 2, /* LC = Low Complexity */ + MP4AUDIO_AAC_SSR = 3, /* SSR = Scalable Sampling Rate */ + MP4AUDIO_LTP = 4, /* LTP = Long Term Prediction */ + MP4AUDIO_SBR = 5, /* SBR = Spectral Band Replication */ + MP4AUDIO_AAC_SCALABLE = 6, /* scales both bitrate and sampling rate */ + MP4AUDIO_TWINVQ = 7, /* low bit rate */ + MP4AUDIO_CELP = 8, + MP4AUDIO_HVXC = 9, + /* 10 is reserved */ + /* 11 is reserved */ + MP4AUDIO_TTSI = 12, + /* 13-16 are synthesis and MIDI types */ + MP4AUDIO_ER_AAC_LC = 17, /* */ + /* 18 is reserved */ + MP4AUDIO_ER_AAC_LTP = 19, /* */ + MP4AUDIO_ER_AAC_SCALABLE = 20, /* */ + MP4AUDIO_ER_TWINVQ = 21, /* */ + MP4AUDIO_ER_BSAC = 22, /* */ + MP4AUDIO_ER_AAC_LD = 23, /* */ + MP4AUDIO_ER_CELP = 24, /* */ + MP4AUDIO_ER_HVXC = 25, /* */ + MP4AUDIO_ER_HILN = 26, /* */ + MP4AUDIO_PARAMETRIC = 27, /* */ + MP4AUDIO_PS = 29 /* Explicit Parametric Stereo */ + + } tMP4AudioObjectType; + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /* Should not be any function declarations in this file */ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* E_TMP4AUDIOOBJECTTYPE_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/include/getactualaacconfig.h b/components/spotify/cspot/bell/external/opencore-aacdec/include/getactualaacconfig.h new file mode 100644 index 00000000..3fbb1e24 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/include/getactualaacconfig.h @@ -0,0 +1,45 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getactualaacconfig.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + getaacaudioinfo definition function + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef GETACTUALAACCONFIG_H +#define GETACTUALAACCONFIG_H + +#include "pv_audio_type_defs.h" + +OSCL_IMPORT_REF Int32 GetActualAacConfig(UInt8 *aConfigHeader, + UInt8 *aAudioObjectType, + Int32 *aConfigHeaderSize, + UInt8 *SamplingRateIndex, + UInt32 *NumChannels); + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/include/pv_audio_type_defs.h b/components/spotify/cspot/bell/external/opencore-aacdec/include/pv_audio_type_defs.h new file mode 100644 index 00000000..2c8c527c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/include/pv_audio_type_defs.h @@ -0,0 +1,205 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + Filename: pv_audio_type_defs.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file was derived from a number of standards bodies. The type + definitions below were created from some of the best practices observed + in the standards bodies. + + This file is dependent on limits.h for defining the bit widths. In an + ANSI C environment limits.h is expected to always be present and contain + the following definitions: + + SCHAR_MIN + SCHAR_MAX + UCHAR_MAX + + INT_MAX + INT_MIN + UINT_MAX + + SHRT_MIN + SHRT_MAX + USHRT_MAX + + LONG_MIN + LONG_MAX + ULONG_MAX + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_AUDIO_TYPE_DEFS_H +#define PV_AUDIO_TYPE_DEFS_H + +#include + +#ifndef Char +typedef int8_t Char; +#endif + +#ifndef Int8 +typedef int8_t Int8; +#endif + +#ifndef UChar +typedef uint8_t UChar; +#endif + +#ifndef UInt8 +typedef uint8_t UInt8; +#endif + + + +/*---------------------------------------------------------------------------- +; Define generic signed and unsigned int +----------------------------------------------------------------------------*/ +#ifndef Int +typedef signed int Int; +#endif + +#ifndef UInt +typedef unsigned int UInt; +#endif + + +/*---------------------------------------------------------------------------- +; Define 16 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int16 +typedef int16_t Int16; +#endif + +#ifndef INT16_MIN +#define INT16_MIN (-32768) +#endif + +#ifndef INT16_MAX +#define INT16_MAX 32767 +#endif + +#ifndef UInt16 +typedef uint16_t UInt16; + +#endif + + +/*---------------------------------------------------------------------------- +; Define 32 bit signed and unsigned words +----------------------------------------------------------------------------*/ + + +#ifndef Int32 +typedef int32_t Int32; +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-2147483647 - 1) +#endif +#ifndef INT32_MAX +#define INT32_MAX 2147483647 +#endif + +#ifndef UInt32 +typedef uint32_t UInt32; +#endif + +#ifndef UINT32_MIN +#define UINT32_MIN 0 +#endif +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffff +#endif + + +#ifndef INT_MAX +#define INT_MAX INT32_MAX /* for 32 bit */ +#endif + +/*---------------------------------------------------------------------------- +; Define 64 bit signed and unsigned words +----------------------------------------------------------------------------*/ +#ifndef Int64 +typedef int64_t Int64; +#endif + +#ifndef UInt64 +typedef uint64_t UInt64; +#endif + +/*---------------------------------------------------------------------------- +; Define boolean type +----------------------------------------------------------------------------*/ +#ifndef Bool +typedef Int Bool; +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef OFF +#define OFF 0 +#endif +#ifndef ON +#define ON 1 +#endif + +#ifndef NO +#define NO 0 +#endif +#ifndef YES +#define YES 1 +#endif + +#ifndef SUCCESS +#define SUCCESS 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef OSCL_IMPORT_REF +#define OSCL_IMPORT_REF +#endif + +#ifndef OSCL_EXPORT_REF +#define OSCL_EXPORT_REF +#endif + +#ifndef OSCL_IMPORT_REF +#define OSCL_IMPORT_REF +#endif + +#ifndef OSCL_UNUSED_ARG +#define OSCL_UNUSED_ARG(x) (void)(x) +#endif + +#endif /* PV_AUDIO_TYPE_DEFS_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/include/pvmp4audiodecoder_api.h b/components/spotify/cspot/bell/external/opencore-aacdec/include/pvmp4audiodecoder_api.h new file mode 100644 index 00000000..3b53f272 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/include/pvmp4audiodecoder_api.h @@ -0,0 +1,357 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Name: PVMP4AudioDecoder_API.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Main header file for the Packet Video MP4/AAC audio decoder library. The + constants, structures, and functions defined within this file, along with + a basic data types header file, is all that is needed to use and communicate + with the library. The internal data structures within the library are + purposely hidden. + + ---* Need description of the input buffering. *------- + + ---* Need an example of calling the library here *---- + +------------------------------------------------------------------------------ + REFERENCES + + (Normally header files do not have a reference section) + + ISO/EIC 14496-3:(1999) Document titled +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PVMP4AUDIODECODER_API_H +#define PVMP4AUDIODECODER_API_H + +#include "pv_audio_type_defs.h" /* Basic data types used within the lib */ + +#include "e_tmp4audioobjecttype.h" + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /* + * This constant is the guaranteed-to-work buffer size, specified in bytes, + * for the input buffer for 2 audio channels to decode one frame of data, + * as specified by the MPEG-2 or MPEG-4 standard. + * The standard, and this constant, do not take into account that lower + * bitrates will use less data per frame. Note that the number of bits + * used per frame is variable, and only that the average value will be the + * bit rate specified during encoding. The standard does not specify + * over how many frames the average must be maintained. + * + * The constant value is 6144 * 2 channels / 8 bits per byte + */ + + +#define PVMP4AUDIODECODER_INBUFSIZE 1536 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + /* + * This enumeration is used for the structure element outputFormat. It + * specifies how the output data is to be formatted. Presently only 16-bit + * PCM data is supported, and this enum informs how the single output + * buffer should be for two-channel stereo data. + * Grouped format stores all the left channel values, then right: + * "LLLL...LLRRRR...RR" + * Interleave format store left, then right audio samples: + * "LRLRLRLR...." + */ + typedef enum ePVMP4AudioDecoderOutputFormat + { + OUTPUTFORMAT_16PCM_GROUPED = 0, + OUTPUTFORMAT_16PCM_INTERLEAVED = 1 + + } tPVMP4AudioDecoderOutputFormat; + + /* + * This enumeration holds the possible return values for the main decoder + * function, PVMP4AudioDecodeFrame. The plan was to easily distinguish + * whether an error was recoverable (streaming mode) or not. Presently no + * errors are recoverable, which is a result of not supporting ADTS in + * this release. + */ + typedef enum ePVMP4AudioDecoderErrorCode + { + MP4AUDEC_SUCCESS = 0, + MP4AUDEC_INVALID_FRAME = 10, + MP4AUDEC_INCOMPLETE_FRAME = 20, + MP4AUDEC_LOST_FRAME_SYNC = 30 /* Cannot happen since no ADTS */ + } tPVMP4AudioDecoderErrorCode; + + + /* + * This enumeration holds the possible return values for stream type + * being decoded + */ + typedef enum + { + AAC = 0, + AACPLUS, + ENH_AACPLUS + } STREAMTYPE; + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + /* + * This structure is used to communicate information in to and out of the + * AAC decoder. + */ + + typedef struct +#ifdef __cplusplus + tPVMP4AudioDecoderExternal // To allow forward declaration of this struct in C++ +#endif + { + /* + * INPUT: + * Pointer to the input buffer that contains the encoded bistream data. + * The data is filled in such that the first bit transmitted is + * the most-significant bit (MSB) of the first array element. + * The buffer is accessed in a linear fashion for speed, and the number of + * bytes consumed varies frame to frame. + * The calling environment can change what is pointed to between calls to + * the decode function, library, as long as the inputBufferCurrentLength, + * and inputBufferUsedLength are updated too. Also, any remaining bits in + * the old buffer must be put at the beginning of the new buffer. + */ + UChar *pInputBuffer; + + /* + * INPUT: + * Number of valid bytes in the input buffer, set by the calling + * function. After decoding the bitstream the library checks to + * see if it when past this value; it would be to prohibitive to + * check after every read operation. This value is not modified by + * the AAC library. + */ + Int inputBufferCurrentLength; + + /* + * INPUT: + * The actual size of the buffer. + * This variable is not used by the library, but is used by the + * console test application. This parameter could be deleted + * if this value was passed into these function. The helper functions are + * not part of the library and are not used by the Common Audio Decoder + * Interface. + */ + Int inputBufferMaxLength; + + /* + * INPUT: + * Enumerated value the output is to be interleaved left-right-left-right. + * For further information look at the comments for the enumeration. + */ + tPVMP4AudioDecoderOutputFormat outputFormat; + + /* + * INPUT: (but what is pointed to is an output) + * Pointer to the output buffer to hold the 16-bit PCM audio samples. + * If the output is stereo, both left and right channels will be stored + * in this one buffer. Presently it must be of length of 2048 points. + * The format of the buffer is set by the parameter outputFormat. + */ + Int16 *pOutputBuffer; + + /* + * INPUT: (but what is pointed to is an output) + * Pointer to the output buffer to hold the 16-bit PCM AAC-plus audio samples. + * If the output is stereo, both left and right channels will be stored + * in this one buffer. Presently it must be of length of 2048 points. + * The format of the buffer is set by the parameter outputFormat. + */ + Int16 *pOutputBuffer_plus; /* Used in AAC+ and enhanced AAC+ */ + + /* + * INPUT: + * AAC Plus Upsampling Factor. Normally set to 2 when Spectrum Band + * Replication (SBR) is used + */ + Int32 aacPlusUpsamplingFactor; /* Used in AAC+ and enhanced AAC+ */ + + /* + * INPUT: + * AAC Plus enabler. Deafaults to be ON, unless run time conditions + * require the SBR and PS tools disabled + */ + Bool aacPlusEnabled; + /* + * INPUT: + * (Currently not being used inside the AAC library.) + * This flag is set to TRUE when the playback position has been changed, + * for example, rewind or fast forward. This informs the AAC library to + * take an appropriate action, which has yet to be determined. + */ + Bool repositionFlag; + + /* + * INPUT: + * Number of requested output audio channels. This relieves the calling + * environment from having to perform stereo-to-mono or mono-to-stereo + * conversions. + */ + Int desiredChannels; + + /* + * INPUT/OUTPUT: + * Number of elements used by the library, initially set to zero by + * the function PVMP4AudioDecoderInitLibrary, and modified by each + * call to PVMP4AudioDecodeFrame. + */ + Int inputBufferUsedLength; + + /* + * INPUT/OUTPUT: + * Number of bits left over in the next buffer element, + * This value will always be zero, unless support for ADTS is added. + */ + Int32 remainderBits; + + /* + * OUTPUT: + * The sampling rate decoded from the bitstream, in units of + * samples/second. For this release of the library this value does + * not change from frame to frame, but future versions will. + */ + Int32 samplingRate; + + /* + * OUTPUT: + * This value is the bitrate in units of bits/second. IT + * is calculated using the number of bits consumed for the current frame, + * and then multiplying by the sampling_rate, divided by points in a frame. + * This value can changes frame to frame. + */ + Int32 bitRate; + + /* + * OUTPUT: + * The number of channels decoded from the bitstream. The output data + * will have be the amount specified in the variable desiredChannels, + * this output is informative only, and can be ignored. + */ + Int encodedChannels; + + /* + * OUTPUT: + * This value is the number of output PCM samples per channel. + * It is presently hard-coded to 1024, but may change in the future. + * It will not change frame to frame, and would take on + * one of these four values: 1024, 960, 512, or 480. If an error occurs + * do not rely on this value. + */ + Int frameLength; + + /* + * This value is audio object type as defined in struct tMP4AudioObjectType + * in file e_tMP4AudioObjectType.h + */ + Int audioObjectType; + + /* + * This value is extended audio object type as defined in struct tMP4AudioObjectType + * in file e_tMP4AudioObjectType.h. It carries the output Audio Object Type + */ + Int extendedAudioObjectType; + + + } tPVMP4AudioDecoderExternal; + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + OSCL_IMPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void); + + OSCL_IMPORT_REF Int PVMP4AudioDecoderInitLibrary( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF Int PVMP4AudioDecodeFrame( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF Int PVMP4AudioDecoderConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + OSCL_IMPORT_REF void PVMP4AudioDecoderResetBuffer( + void *pMem); + + OSCL_IMPORT_REF void PVMP4AudioDecoderDisableAacPlus( + tPVMP4AudioDecoderExternal *pExt, + void *pMem); + + Int PVMP4SetAudioConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem, + Int upsamplingFactor, + Int samp_rate, + int num_ch, + tMP4AudioObjectType audioObjectType); + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + +#endif /* PVMP4AUDIODECODER_API_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/oscl/Makefile.am b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/Makefile.am new file mode 100644 index 00000000..3adeb7b0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/Makefile.am @@ -0,0 +1,4 @@ + +noinst_HEADERS = oscl_base.h \ + oscl_mem.h + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_base.h b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_base.h new file mode 100644 index 00000000..93e82461 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_base.h @@ -0,0 +1,37 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 2009 Martin Storsjo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_BASE_H +#define OSCL_BASE_H + +#include + +typedef int8_t int8; +typedef uint8_t uint8; +typedef int16_t int16; +typedef uint16_t uint16; +typedef int32_t int32; +typedef uint32_t uint32; +typedef int64_t int64; +typedef uint64_t uint64; + +#define OSCL_IMPORT_REF +#define OSCL_EXPORT_REF +#define OSCL_UNUSED_ARG(x) (void)(x) + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_mem.h b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_mem.h new file mode 100644 index 00000000..476b3b36 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/oscl/oscl_mem.h @@ -0,0 +1,38 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 2009 Martin Storsjo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ + +#ifndef OSCL_MEM_H +#define OSCL_MEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#define oscl_malloc malloc +#define oscl_free free +#define oscl_memset memset +#define oscl_memmove memmove +#define oscl_memcpy memcpy + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/Makefile.am b/components/spotify/cspot/bell/external/opencore-aacdec/src/Makefile.am new file mode 100644 index 00000000..58881db3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/Makefile.am @@ -0,0 +1,341 @@ +lib_LTLIBRARIES = libaacdec.la + +libaacdec_la_LDFLAGS = -version-info 1:0:0 $(libtool_flags) + +libaacdec_la_CFLAGS = -I$(top_srcdir)/oscl -I$(top_srcdir)/include + +libaacdecdir = $(includedir)/libaacdec + +libaacdec_la_SOURCES = analysis_sub_band.c \ + apply_ms_synt.c \ + apply_tns.c \ + buf_getbits.c \ + byte_align.c \ + calc_auto_corr.c \ + calc_gsfb_table.c \ + calc_sbr_anafilterbank.c \ + calc_sbr_envelope.c \ + calc_sbr_synfilterbank.c \ + check_crc.c \ + dct16.c \ + dct64.c \ + decode_huff_cw_binary.c \ + decode_noise_floorlevels.c \ + deinterleave.c \ + digit_reversal_tables.c \ + dst16.c \ + dst32.c \ + dst8.c \ + esc_iquant_scaling.c \ + extractframeinfo.c \ + fft_rx4_long.c \ + fft_rx4_short.c \ + fft_rx4_tables_fxp.c \ + find_adts_syncword.c \ + fwd_long_complex_rot.c \ + fwd_short_complex_rot.c \ + gen_rand_vector.c \ + get_adif_header.c \ + get_adts_header.c \ + get_audio_specific_config.c \ + get_dse.c \ + get_ele_list.c \ + getfill.c \ + get_ga_specific_config.c \ + getgroup.c \ + getics.c \ + get_ics_info.c \ + getmask.c \ + get_prog_config.c \ + get_pulse_data.c \ + get_sbr_bitstream.c \ + get_sbr_startfreq.c \ + get_sbr_stopfreq.c \ + get_tns.c \ + getactualaacconfig.c \ + hcbtables_binary.c \ + huffcb.c \ + huffdecode.c \ + hufffac.c \ + huffspec_fxp.c \ + idct16.c \ + idct32.c \ + idct8.c \ + imdct_fxp.c \ + infoinit.c \ + init_sbr_dec.c \ + intensity_right.c \ + inv_long_complex_rot.c \ + inv_short_complex_rot.c \ + iquant_table.c \ + long_term_prediction.c \ + long_term_synthesis.c \ + lt_decode.c \ + mdct_fxp.c \ + mdct_tables_fxp.c \ + mdst.c \ + mix_radix_fft.c \ + ms_synt.c \ + pns_corr.c \ + pns_intensity_right.c \ + pns_left.c \ + ps_allocate_decoder.c \ + ps_all_pass_filter_coeff.c \ + ps_all_pass_fract_delay_filter.c \ + ps_applied.c \ + ps_bstr_decoding.c \ + ps_channel_filtering.c \ + ps_decode_bs_utils.c \ + ps_decorrelate.c \ + ps_fft_rx8.c \ + ps_hybrid_analysis.c \ + ps_hybrid_filter_bank_allocation.c \ + ps_hybrid_synthesis.c \ + ps_init_stereo_mixing.c \ + ps_pwr_transient_detection.c \ + ps_read_data.c \ + ps_stereo_processing.c \ + pulse_nc.c \ + pv_div.c \ + pv_log2.c \ + pvmp4audiodecoderconfig.c \ + pvmp4audiodecoderframe.c \ + pvmp4audiodecodergetmemrequirements.c \ + pvmp4audiodecoderinitlibrary.c \ + pvmp4audiodecoderresetbuffer.c \ + pvmp4setaudioconfig.c \ + pv_normalize.c \ + pv_pow2.c \ + pv_sine.c \ + pv_sqrt.c \ + qmf_filterbank_coeff.c \ + q_normalize.c \ + sbr_aliasing_reduction.c \ + sbr_applied.c \ + sbr_code_book_envlevel.c \ + sbr_crc_check.c \ + sbr_create_limiter_bands.c \ + sbr_dec.c \ + sbr_decode_envelope.c \ + sbr_decode_huff_cw.c \ + sbr_downsample_lo_res.c \ + sbr_envelope_calc_tbl.c \ + sbr_envelope_unmapping.c \ + sbr_extract_extended_data.c \ + sbr_find_start_andstop_band.c \ + sbr_generate_high_freq.c \ + sbr_get_additional_data.c \ + sbr_get_cpe.c \ + sbr_get_dir_control_data.c \ + sbr_get_envelope.c \ + sbr_get_header_data.c \ + sbr_get_noise_floor_data.c \ + sbr_get_sce.c \ + sbr_inv_filt_levelemphasis.c \ + sbr_open.c \ + sbr_read_data.c \ + sbr_requantize_envelope_data.c \ + sbr_reset_dec.c \ + sbr_update_freq_scale.c \ + set_mc_info.c \ + sfb.c \ + shellsort.c \ + synthesis_sub_band.c \ + tns_ar_filter.c \ + tns_decode_coef.c \ + tns_inv_filter.c \ + trans4m_freq_2_time_fxp.c \ + trans4m_time_2_freq_fxp.c \ + unpack_idx.c \ + window_tables_fxp.c + +noinst_HEADERS = \ + aac_mem_funcs.h \ + analysis_sub_band.h \ + apply_ms_synt.h \ + apply_tns.h \ + bit_reversal_swap.h \ + buf_getbits.h \ + calc_auto_corr.h \ + calc_sbr_anafilterbank.h \ + calc_sbr_envelope.h \ + calc_sbr_synfilterbank.h \ + chans.h \ + check_crc.h \ + dct16.h \ + dct64.h \ + decode_noise_floorlevels.h \ + digit_reversal_tables.h \ + dst16.h \ + dst32.h \ + dst8.h \ + e_adif_const.h \ + e_blockswitching.h \ + e_coupling_mode.h \ + e_elementid.h \ + e_huffmanconst.h \ + e_infoinitconst.h \ + e_invf_mode.h \ + e_maskstatus.h \ + e_mp4ff_const.h \ + e_progconfigconst.h \ + e_rawbitstreamconst.h \ + e_sbr_element_id.h \ + e_sbr_error.h \ + e_sbr_header_status.h \ + e_sbr_master_status.h \ + e_sbr_sync_state.h \ + esc_iquant_scaling.h \ + e_sr_mode.h \ + e_tns_const.h \ + e_window_sequence.h \ + e_window_shape.h \ + extractframeinfo.h \ + fft_rx4.h \ + find_adts_syncword.h \ + fwd_long_complex_rot.h \ + fwd_short_complex_rot.h \ + fxp_mul32_arm_gcc.h \ + fxp_mul32_arm_v4_gcc.h \ + fxp_mul32_arm_v4.h \ + fxp_mul32_arm_v5.h \ + fxp_mul32_c_equivalent.h \ + fxp_mul32_c_msc_evc_armv5.h \ + fxp_mul32_c_msc_evc.h \ + fxp_mul32.h \ + fxp_mul32_pentium.h \ + gen_rand_vector.h \ + get_adif_header.h \ + get_adts_header.h \ + get_audio_specific_config.h \ + getbits.h \ + get_dse.h \ + get_ele_list.h \ + getfill.h \ + get_ga_specific_config.h \ + get_ics_info.h \ + get_prog_config.h \ + get_pulse_data.h \ + get_sbr_bitstream.h \ + get_sbr_startfreq.h \ + get_sbr_stopfreq.h \ + get_sign_bits.h \ + get_tns.h \ + hcbtables.h \ + huffman.h \ + ibstream.h \ + idct16.h \ + idct32.h \ + idct8.h \ + imdct_fxp.h \ + init_sbr_dec.h \ + intensity_right.h \ + inv_long_complex_rot.h \ + inv_short_complex_rot.h \ + iquant_table.h \ + long_term_prediction.h \ + long_term_synthesis.h \ + lt_decode.h \ + ltp_common_internal.h \ + lt_prediction.h \ + mdct_fxp.h \ + mdst.h \ + mix_radix_fft.h \ + ms_map_mask.h \ + ms_synt.h \ + pns_corr.h \ + pns_intensity_right.h \ + pns_left.h \ + ps_allocate_decoder.h \ + ps_all_pass_filter_coeff.h \ + ps_all_pass_fract_delay_filter.h \ + ps_applied.h \ + ps_bstr_decoding.h \ + ps_channel_filtering.h \ + ps_constants.h \ + ps_decode_bs_utils.h \ + ps_decorrelate.h \ + ps_fft_rx8.h \ + ps_hybrid_analysis.h \ + ps_hybrid_filter_bank_allocation.h \ + ps_hybrid_synthesis.h \ + ps_init_stereo_mixing.h \ + ps_pwr_transient_detection.h \ + ps_read_data.h \ + ps_stereo_processing.h \ + pulse_nc.h \ + pv_div.h \ + pv_log2.h \ + pv_normalize.h \ + pv_pow2.h \ + pv_sine.h \ + pv_sqrt.h \ + qmf_filterbank_coeff.h \ + q_normalize.h \ + s_adif_header.h \ + s_bit_buffer.h \ + s_bits.h \ + sbr_aliasing_reduction.h \ + sbr_applied.h \ + sbr_code_book_envlevel.h \ + sbr_constants.h \ + sbr_crc_check.h \ + sbr_create_limiter_bands.h \ + sbr_dec.h \ + sbr_decode_envelope.h \ + sbr_decode_huff_cw.h \ + sbr_downsample_lo_res.h \ + sbr_envelope_calc_tbl.h \ + sbr_envelope_unmapping.h \ + sbr_extract_extended_data.h \ + sbr_find_start_andstop_band.h \ + sbr_generate_high_freq.h \ + sbr_get_additional_data.h \ + sbr_get_cpe.h \ + sbr_get_dir_control_data.h \ + sbr_get_envelope.h \ + sbr_get_header_data.h \ + sbr_get_noise_floor_data.h \ + sbr_get_sce.h \ + sbr_inv_filt_levelemphasis.h \ + sbr_open.h \ + sbr_read_data.h \ + sbr_requantize_envelope_data.h \ + sbr_reset_dec.h \ + sbr_update_freq_scale.h \ + s_ch_info.h \ + s_crc_buffer.h \ + s_elelist.h \ + set_mc_info.h \ + sfb.h \ + s_frameinfo.h \ + s_hcb.h \ + shellsort.h \ + s_huffman.h \ + s_hybrid.h \ + s_lt_pred_status.h \ + s_mc_info.h \ + s_mixdown.h \ + s_patch.h \ + s_progconfig.h \ + s_ps_dec.h \ + s_pulseinfo.h \ + s_sbrbitstream.h \ + s_sbr_channel.h \ + s_sbr_dec.h \ + s_sbr_element_stream.h \ + s_sbr_frame_data.h \ + s_sbr_header_data.h \ + s_sectinfo.h \ + s_sr_info.h \ + s_tdec_int_chan.h \ + s_tdec_int_file.h \ + s_tnsfilt.h \ + s_tns_frame_info.h \ + s_wnd_shape.h \ + synthesis_sub_band.h \ + tns_ar_filter.h \ + tns_decode_coef.h \ + tns_inv_filter.h \ + unpack_idx.h \ + window_block_fxp.h diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/aac_mem_funcs.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/aac_mem_funcs.h new file mode 100644 index 00000000..cdd1e443 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/aac_mem_funcs.h @@ -0,0 +1,48 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: aac_mem_funcs.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ + +#ifndef AAC_MEM_FUNCS_H +#define AAC_MEM_FUNCS_H + + +#include "pv_audio_type_defs.h" +#include "oscl_mem.h" + + + +#define pv_memset(to, c, n) oscl_memset(to, c, n) + + +#define pv_memcpy(to, from, n) oscl_memcpy(to, from, n) +#define pv_memmove(to, from, n) oscl_memmove(to, from, n) +#define pv_memcmp(p, q, n) oscl_memcmp(p, q, n) + + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.c new file mode 100644 index 00000000..1094ae23 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.c @@ -0,0 +1,284 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: analysis_sub_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 vec[], Input vector, 32-bit + const Int32 *cosTerms, Cosine Terms + Int maxbands number of bands used + Int32 *scratch_mem Scratch memory + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "analysis_sub_band.h" +#include "dst32.h" +#include "idct32.h" +#include "mdst.h" + +#include "aac_mem_funcs.h" +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +#ifdef HQ_SBR + + +const Int32 exp_1_5_phi[32] = +{ + + 0x7FEA04B6, 0x7F380E1C, 0x7DD6176E, 0x7BC6209F, + 0x790A29A4, 0x75A6326E, 0x719E3AF3, 0x6CF94326, + 0x67BD4AFB, 0x61F15269, 0x5B9D5964, 0x54CA5FE4, + 0x4D8165DE, 0x45CD6B4B, 0x3DB87023, 0x354E7460, + 0x2C9977FB, 0x23A77AEF, 0x1A837D3A, 0x113A7ED6, + 0x07D97FC2, 0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60, + 0xE26D7C89, 0xD9587A06, 0xD07976D9, 0xC7DB7308, + 0xBF8C6E97, 0xB796698C, 0xB00563EF, 0xA8E25DC8, + +}; + +#endif + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void analysis_sub_band_LC(Int32 vec[64], + Int32 cosine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]) +{ + Int32 i; + Int32 *cosine_term = &scratch_mem[0][0]; + Int32 *sine_term = &scratch_mem[0][32]; + + Int32 *pt_cos_t; + + + Int32 *pt_vec = &vec[0]; + Int32 *pt_vec_32 = &vec[32]; + + Int32 *pt_cos = cosine_term; + Int32 *pt_sin = sine_term; + + for (i = 8; i != 0; i--) + { + Int32 tmp1 = *(pt_vec_32++); + Int32 tmp3 = *(pt_vec_32++); + Int32 tmp2 = *(pt_vec++); + Int32 tmp4 = *(pt_vec++); + *(pt_cos++) = (tmp1 - tmp2) >> 1; + *(pt_cos++) = (tmp3 - tmp4) >> 1; + *(pt_sin++) = (tmp1 + tmp2); + *(pt_sin++) = (tmp3 + tmp4); + tmp1 = *(pt_vec_32++); + tmp3 = *(pt_vec_32++); + tmp2 = *(pt_vec++); + tmp4 = *(pt_vec++); + *(pt_cos++) = (tmp1 - tmp2) >> 1; + *(pt_cos++) = (tmp3 - tmp4) >> 1; + *(pt_sin++) = (tmp1 + tmp2); + *(pt_sin++) = (tmp3 + tmp4); + } + + + idct_32(cosine_term, scratch_mem[1]); + + dst_32(sine_term, scratch_mem[1]); + + pt_cos = cosine_term; + pt_sin = sine_term; + + pt_cos_t = cosine_total; + + for (i = 0; i < maxBand; i += 4) + { + *(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++)); + *(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++)); + *(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++)); + *(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++)); + } + + pt_cos_t = &cosine_total[maxBand]; + + for (i = (32 - maxBand); i != 0; i--) + { + *(pt_cos_t++) = 0; + } +} + + +#ifdef HQ_SBR + + +void analysis_sub_band(Int32 vec[64], + Int32 cosine_total[], + Int32 sine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]) +{ + Int32 i; + Int32 *sine_term1 = &scratch_mem[0][0]; + Int32 *sine_term2 = &scratch_mem[0][32]; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + + const Int32 *pt_exp; + Int32 exp_1_5; + + Int32 *pt_vec = &vec[0]; + Int32 *pt_vec_32 = &vec[32]; + + Int32 *pt_cos1 = pt_vec; + Int32 *pt_sin1 = sine_term1; + Int32 *pt_cos2 = pt_vec_32; + Int32 *pt_sin2 = sine_term2; + + + pv_memcpy(sine_term1, vec, 64*sizeof(*vec)); + + mdst_32(sine_term1, scratch_mem[1]); + mdst_32(sine_term2, scratch_mem[1]); + + mdct_32(&vec[ 0]); + mdct_32(&vec[32]); + + pt_cos1 = &vec[ 0]; + pt_cos2 = &vec[32]; + + + pt_sin1 = sine_term1; + pt_sin2 = sine_term2; + + pt_vec = cosine_total; + pt_vec_32 = sine_total; + pt_exp = exp_1_5_phi; + + temp3 = (*(pt_cos1++) - *(pt_sin2++)); + temp4 = (*(pt_sin1++) + *(pt_cos2++)); + + for (i = 0; i < maxBand; i += 2) + { + + exp_1_5 = *(pt_exp++); + temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); + temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); + + *(pt_vec++) = shft_lft_1(temp1); + *(pt_vec_32++) = shft_lft_1(temp2); + + temp3 = (*(pt_cos1++) + *(pt_sin2++)); + temp4 = (*(pt_sin1++) - *(pt_cos2++)); + + exp_1_5 = *(pt_exp++); + temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5); + temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5); + + *(pt_vec++) = shft_lft_1(temp1); + *(pt_vec_32++) = shft_lft_1(temp2); + + temp3 = (*(pt_cos1++) - *(pt_sin2++)); + temp4 = (*(pt_sin1++) + *(pt_cos2++)); + } + + + pt_cos1 = &cosine_total[maxBand]; /* in the chance that maxband is not even */ + pt_sin1 = &sine_total[maxBand]; + + for (i = (32 - maxBand); i != 0; i--) + { + *(pt_cos1++) = 0; + *(pt_sin1++) = 0; + } + +} + + +#endif + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.h new file mode 100644 index 00000000..240135ac --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/analysis_sub_band.h @@ -0,0 +1,77 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: analysis_sub_band.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef ANALYSIS_SUB_BAND_H +#define ANALYSIS_SUB_BAND_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void analysis_sub_band_LC(Int32 vec[64], + Int32 cosine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]); + +#ifdef HQ_SBR + + + void analysis_sub_band(Int32 vec[64], + Int32 cosine_total[], + Int32 sine_total[], + Int32 maxBand, + Int32 scratch_mem[][64]); + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* ANALYSIS_SUB_BAND_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.c new file mode 100644 index 00000000..d37edd76 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.c @@ -0,0 +1,422 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_ms_synt.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const pFrameInfo * const] + + group = Array that contains indexes of the + first window in the next group. + [const Int *, length 8] + + mask_map = Array that denotes whether M/S stereo is turned on for + each grouped scalefactor band. + [const Int *, length MAX_SFB] + + codebook_map = Array that denotes which Huffman codebook was used for + the encoding of each grouped scalefactor band. + [const Int *, length MAX_SFB] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefLeft = Contains the new spectral information. + + coefRight = Contains the new spectral information. + + q_formatLeft = Q-format may be updated with changed to fixed-point + data in coefLeft. + + q_formatRight = Q-format may be updated with changed to fixed-point + data in coefRight. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function steps through all of the tools that are applied on a + scalefactor band basis. + + The use of M/S stereo is checked for. For M/S decoding to take + place, ms_mask_map must be TRUE for that particular SFB, AND the Huffman + codebook used must be < NOISE_HCB. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + + coef_per_win = pFrameInfo->coef_per_win[0]; + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + DO + + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *(pGroup); + + pGroup = pGroup + 1; + + band_start = 0; + + wins_in_group = (partition - window_start); + + FOR (sfb = sfb_per_win; sfb > 0; sfb--) + + band_stop = *(pBand); + + pBand = pBand + 1; + + codebook = *(pCodebookMap); + + pCodebookMap = pCodebookMap + 1; + + mask_enabled = *(pMaskMap); + + pMaskMap = pMaskMap + 1; + + IF (codebook < NOISE_HCB) + THEN + IF (mask_enabled != FALSE) + THEN + band_length = band_stop - band_start; + + CALL + ms_synt( + wins_in_group, + coef_per_win, + sfb_per_win, + band_length, + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]) ); + + MODIFYING + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]) + + RETURNING + None + ENDIF + ENDIF + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + ENDFOR + + pCoefRight = pCoefRight + coef_per_win * wins_in_group; + pCoefLeft = pCoefLeft + coef_per_win * wins_in_group; + + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + sfb_per_win * wins_in_group; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + + return; +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "apply_ms_synt.h" +#include "e_huffmanconst.h" +#include "ms_synt.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void apply_ms_synt( + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS]) + +{ + + Int32 *pCoefRight; + + Int32 *pCoefLeft; + + Int tot_sfb; + Int sfb; + + Int band_length; + Int band_start; + Int band_stop; + Int coef_per_win; + + Int codebook; + Int partition; + Int window_start; + + Int sfb_per_win; + Int wins_in_group; + + const Int16 *pBand; + const Int *pCodebookMap = codebook_map; + const Int *pGroup = group; + const Bool *pMaskMap = mask_map; + + Bool mask_enabled; + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + + /* + * Each window in the frame should have the same number of coef's, + * so coef_per_win is constant in all the loops + */ + coef_per_win = pFrameInfo->coef_per_win[0]; + + /* + * Because the number of scalefactor bands per window should be + * constant for each frame, sfb_per_win can be determined outside + * of the loop. + * + * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows + * sfb_per_win = 49 for long windows + */ + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + do + { + pBand = pFrameInfo->win_sfb_top[window_start]; + + /* + * Partition is equal to the first window in the next group + * + * { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + * [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + * + * pGroup[0] = 2 + * pGroup[1] = 5 + * pGroup[2] = 7 + * pGroup[3] = 8 + */ + + partition = *(pGroup++); + + band_start = 0; + + wins_in_group = (partition - window_start); + + for (sfb = sfb_per_win; sfb > 0; sfb--) + { + /* band is offset table, band_stop is last coef in band */ + band_stop = *(pBand++); + + codebook = *(pCodebookMap++); + + mask_enabled = *(pMaskMap++); + + /* + * When a codebook < NOISE_HCB is found, apply M/S to that + * scalefactorband. + * + * Example... sfb[3] == NOISE_HCB + * + * [ Group 1 ] + * [win 0 ][win 1 ] + * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7] + * + * The for(sfb) steps through the sfb's 0-7 in win 0. + * + * Finding sfb[3]'s codebook == NOISE_HCB, the code + * steps through all the windows in the group (they share + * the same scalefactors) and replaces that sfb with noise. + */ + + if (codebook < NOISE_HCB) + { + if (mask_enabled != FALSE) + { + band_length = band_stop - band_start; + + ms_synt( + wins_in_group, + coef_per_win, + sfb_per_win, + band_length, + &(pCoefLeft[band_start]), + &(pCoefRight[band_start]), + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb])); + } + } + band_start = band_stop; + + tot_sfb++; + + } /* for (sfb) */ + + /* + * Increment pCoefRight and pCoefLeft by + * coef_per_win * the number of windows + */ + + pCoefRight += coef_per_win * wins_in_group; + pCoefLeft += coef_per_win * wins_in_group--; + + /* + * Increase tot_sfb by sfb_per_win times the number of windows minus 1. + * The minus 1 comes from the fact that tot_sfb is already pointing + * to the first sfb in the 2nd window of the group. + */ + tot_sfb += sfb_per_win * wins_in_group; + + window_start = partition; + + } + while (partition < pFrameInfo->num_win); + + /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */ + + return; + +} /* apply_ms_synt() */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.h new file mode 100644 index 00000000..88b78745 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_ms_synt.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_ms_synt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for apply_ms_synt(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef APPLY_MS_SYNT_H +#define APPLY_MS_SYNT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void apply_ms_synt( + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.c new file mode 100644 index 00000000..8edbfae4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.c @@ -0,0 +1,402 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_tns.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + coef = Array of input coefficients. + [Int32 *, length 1024] + + q_format = Array of q-formats, one per scalefactor band, for the + entire frame. In the case of tns_inv_filter, only the + first element is used, since the input to tns_inv_filter + is all of the same q-format. + [Int * const, length MAX_SFB] + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const FrameInfo * const] + + pTNS_frame_info = pointer to structure containing the details on each + TNS filter (order, filter coefficients, + coefficient res., etc.) + [TNS_frame_info * const] + + inverse_flag = TRUE if inverse filter is to be applied. + FALSE if forward filter is to be applied. + [Bool] + + scratch_Int_buffer = Pointer to scratch memory to store the + filter's state memory. Used by both + tns_inv_filter. + [Int *, length TNS_MAX_ORDER] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef[] = TNS altered data. + q_format = q-formats in TNS scalefactor bands may be modified. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function applies either the TNS forward or TNS inverse filter, based + on inverse_flag being FALSE or TRUE, respectively. + + For the TNS forward filter, the data fed into tns_ar_filter is normalized + all to the same q-format. + +------------------------------------------------------------------------------ + REQUIREMENTS + + The input, coef, should use all 32-bits, else the scaling by tns_ar_filter + may eliminate the data. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + NO PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tns_frame_info.h" +#include "s_tnsfilt.h" +#include "s_frameinfo.h" +#include "tns_inv_filter.h" +#include "tns_ar_filter.h" +#include "apply_tns.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void apply_tns( + Int32 coef[], + Int q_format[], + const FrameInfo * const pFrameInfo, + TNS_frame_info * const pTNS_frame_info, + const Bool inverse_flag, + Int32 scratch_Int_buffer[]) +{ + Int num_tns_bands; + Int num_TNS_coef; + + Int f; + + Int tempInt; + Int tempInt2; + + Int sfb_per_win; + Int sfbWidth; + + Int coef_per_win; + Int min_q; + Int win; + + Int32 *pCoef = coef; + Int32 *pTempCoef; + + Int *pStartQformat = q_format; + + Int *pQformat; + Int32 *pLpcCoef; + + Int sfb_offset; + + const Int16 *pWinSfbTop; + + TNSfilt *pFilt; + + coef_per_win = pFrameInfo->coef_per_win[0]; + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + win = 0; + + pLpcCoef = pTNS_frame_info->lpc_coef; + + pFilt = pTNS_frame_info->filt; + + do + { + for (f = pTNS_frame_info->n_filt[win]; f > 0; f--) + { + /* Skip to the next filter if the order is 0 */ + tempInt = pFilt->order; + + if (tempInt > 0) + { + /* + * Do not call tns_ar_filter or tns_inv_filter + * if the difference + * between start_coef and stop_stop is <= 0. + * + */ + num_TNS_coef = (pFilt->stop_coef - pFilt->start_coef); + + if (num_TNS_coef > 0) + { + if (inverse_flag != FALSE) + { + tns_inv_filter( + &(pCoef[pFilt->start_coef]), + num_TNS_coef, + pFilt->direction, + pLpcCoef, + pFilt->q_lpc, + pFilt->order, + scratch_Int_buffer); + } + else + { + num_tns_bands = (pFilt->stop_band - pFilt->start_band); + + /* + * pQformat is initialized only once. + * + * Here is how TNS is applied on scalefactor bands + * + * [0][1][2][3][4][5][6][7][8] + * | \ + * start_band stop_band + * + * In this example, TNS would be applied to 8 + * scalefactor bands, 0-7. + * + * pQformat is initially set to &(pStartQformat[8]) + * + * 1st LOOP + * Entry: pQformat = &(pStartQformat[8]) + * + * pQformat is pre-decremented 8 times in the + * search for min_q + * + * Exit: pQformat = &(pStartQformat[0]) + * + * 2nd LOOP + * Entry: pQformat = &(pStartQformat[0]) + * + * pQformat is post-incremented 8 times in the + * normalization of the data loop. + * + * Exit: pQformat = &(pStartQformat[8] + * + * + * shift_amt = tns_ar_filter(...) + * + * 3rd LOOP + * Entry: pQformat = &(pStartQformat[8]) + * + * pQformat is pre-decremented 8 times in the + * adjustment of the q-format to min_q - shift_amt + * + * Exit: pQformat = &(pStartQformat[0]) + * + */ + + pQformat = + &(pStartQformat[pFilt->stop_band]); + + /* + * Scan the array of q-formats and find the minimum over + * the range where the filter is to be applied. + * + * At the end of this scan, + * pQformat = &(q-format[pFilt->start_band]); + * + */ + + min_q = INT16_MAX; + + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + tempInt2 = *(--pQformat); + + if (tempInt2 < min_q) + { + min_q = tempInt2; + } + } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/ + + /* + * Set up the pointers so we can index into coef[] + * on a scalefactor band basis. + */ + tempInt = pFilt->start_band; + + tempInt--; + + /* Initialize sfb_offset and pWinSfbTop */ + if (tempInt >= 0) + { + pWinSfbTop = + &(pFrameInfo->win_sfb_top[win][tempInt]); + + sfb_offset = *(pWinSfbTop++); + } + else + { + pWinSfbTop = pFrameInfo->win_sfb_top[win]; + sfb_offset = 0; + } + + pTempCoef = pCoef + pFilt->start_coef; + + /* Scale the data in the TNS bands to min_q q-format */ + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + sfbWidth = *(pWinSfbTop++) - sfb_offset; + + sfb_offset += sfbWidth; + + tempInt2 = *(pQformat++) - min_q; + + /* + * This should zero out the data in one scalefactor + * band if it is so much less than the neighboring + * scalefactor bands. + * + * The only way this "should" happen is if one + * scalefactor band contains zero data. + * + * Zero data can be of any q-format, but we always + * set it very high to avoid the zero-data band being + * picked as the one to normalize to in the scan for + * min_q. + * + */ + if (tempInt2 > 31) + { + tempInt2 = 31; + } + + for (sfbWidth >>= 2; sfbWidth > 0; sfbWidth--) + { + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + *(pTempCoef++) >>= tempInt2; + } + + } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/ + + tempInt2 = + tns_ar_filter( + &(pCoef[pFilt->start_coef]), + num_TNS_coef, + pFilt->direction, + pLpcCoef, + pFilt->q_lpc, + pFilt->order); + + /* + * Update the q-format for all the scalefactor bands + * taking into account the adjustment caused by + * tns_ar_filter + */ + + min_q -= tempInt2; + + for (tempInt = num_tns_bands; tempInt > 0; tempInt--) + { + *(--pQformat) = min_q; + } + + } /* if (inverse_flag != FALSE) */ + + } /* if (num_TNS_coef > 0) */ + + pLpcCoef += pFilt->order; + + } /* if (tempInt > 0) */ + + pFilt++; + + } /* for (f = pTNSinfo->n_filt; f > 0; f--) */ + + pCoef += coef_per_win; + pStartQformat += sfb_per_win; + + win++; + + } + while (win < pFrameInfo->num_win); + + return; + +} /* apply_tns() */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.h new file mode 100644 index 00000000..6c2d82b4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/apply_tns.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: apply_tns.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + apply_tns.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef APPLY_TNS_H +#define APPLY_TNS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tns_frame_info.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void apply_tns( + Int32 coef[], + Int q_format[], + const FrameInfo * const pFrameInfo, + TNS_frame_info * const pTNS_frame_info, + const Bool inverse_flag, + Int32 scratch_Int_buffer[]); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/bit_reversal_swap.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/bit_reversal_swap.h new file mode 100644 index 00000000..e72ad1cc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/bit_reversal_swap.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: bit_reversal_swap.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function bit_reversal_swap() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef BIT_REVERSAL_SWAP_H +#define BIT_REVERSAL_SWAP_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int Index_64_a[]; +extern const Int Index_64_b[]; + +extern const Int Index_512_a[]; +extern const Int Index_512_b[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void bit_reversal_swap( + Int32 Data[], + const Int *pIndex_a, + const Int *pIndex_b); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* BIT_REVERSAL_SWAP_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.c new file mode 100644 index 00000000..1cd5cb1a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.c @@ -0,0 +1,162 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: buf_getbits.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hBitBuf Handle to Bitbuffer + n Number of bits to read + + Return: bits + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads n bits from Bitbuffer + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n) +{ + + /* read bits from MSB side */ + if (hBitBuf->buffered_bits <= 16) + { + hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8); + hBitBuf->buffer_word |= *(hBitBuf->char_ptr++); + hBitBuf->buffered_bits += 16; + } + + hBitBuf->buffered_bits -= n; + hBitBuf->nrBitsRead += n; + + return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & ((1 << n) - 1)); + +} + + +UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf) +{ + + /* read bits from MSB side */ + if (hBitBuf->buffered_bits <= 16) + { + hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8); + hBitBuf->buffer_word |= *(hBitBuf->char_ptr++); + hBitBuf->buffered_bits += 16; + } + + hBitBuf->buffered_bits--; + hBitBuf->nrBitsRead++; + + return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & 1); + +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.h new file mode 100644 index 00000000..42489862 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/buf_getbits.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: buf_getbits.h + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef BUF_GETBITS_H +#define BUF_GETBITS_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n); + + UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/byte_align.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/byte_align.c new file mode 100644 index 00000000..76db1bc2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/byte_align.c @@ -0,0 +1,166 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Makes the input stream structure pointed to align to the next byte boundary. + If it is already at a byte boundary it is left alone. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +void byte_align( + BITS *pInputStream) + + MODIFYING(pInputStream->usedBits = pInputStream->usedBits + + (pInputStream->usedBits + 7) % 8) + + RETURN(nothing) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + + +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/* + * A negative number was used for this mask so that it works on both + * 16-bit or 32-bit machines. The mask must be cast to unsigned int to + * work with TI compiler, ver 1.80. + */ +#define BYTE_ALIGN_MASK ((UInt)(-8)) + +#define BYTE_ALIGN_ROUNDUP 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void byte_align( + BITS *pInputStream) +{ + /* + * Round up to the next byte by adding 7 and masking off with + * FFF8 or FFFFFFF8. The masking operation is a faster way to + * perform modulo arithmetic if the number is a power of 2. + * + * This code is the same as + * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8 + */ + pInputStream->usedBits += BYTE_ALIGN_ROUNDUP; + pInputStream->usedBits &= BYTE_ALIGN_MASK; + + return; +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.c new file mode 100644 index 00000000..f56228ff --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.c @@ -0,0 +1,411 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_auto_corr.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "calc_auto_corr.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#define N 2 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void calc_auto_corr_LC(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 bd, + Int32 len) +{ + Int32 j; + Int32 temp1; + Int32 temp3; + Int32 temp5; + + Int64 temp_r01r; + Int64 temp_r02r; + Int64 temp_r11r; + Int64 temp_r12r; + Int64 temp_r22r; + Int64 max = 0; + + + temp1 = (realBuf[ 0][bd]) >> N; + temp3 = (realBuf[-1][bd]) >> N; + temp5 = (realBuf[-2][bd]) >> N; + + + temp_r11r = fxp_mac64_Q31(0, temp3, temp3); /* [j-1]*[j-1] */ + temp_r12r = fxp_mac64_Q31(0, temp3, temp5); /* [j-1]*[j-2] */ + temp_r22r = fxp_mac64_Q31(0, temp5, temp5); /* [j-2]*[j-2] */ + + temp_r01r = 0; + temp_r02r = 0; + + for (j = 1; j < len; j++) + { + temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); /* [j ]*[j-1] */ + temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); /* [j ]*[j-2] */ + temp_r11r = fxp_mac64_Q31(temp_r11r, temp1, temp1); /* [j-1]*[j-1] */ + + temp5 = temp3; + temp3 = temp1; + temp1 = (realBuf[j][bd]) >> N; + } + + + temp_r22r += temp_r11r; + temp_r12r += temp_r01r; /* [j-1]*[j-2] */ + + temp_r22r = fxp_mac64_Q31(temp_r22r, -temp3, temp3); + + temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); + temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); + + max |= temp_r01r ^(temp_r01r >> 63); + max |= temp_r02r ^(temp_r02r >> 63); + max |= temp_r11r; + max |= temp_r12r ^(temp_r12r >> 63); + max |= temp_r22r; + + if (max) + { + temp1 = (UInt32)(max >> 32); + if (temp1) + { + temp3 = 33 - pv_normalize(temp1); + ac->r01r = (Int32)(temp_r01r >> temp3); + ac->r02r = (Int32)(temp_r02r >> temp3); + ac->r11r = (Int32)(temp_r11r >> temp3); + ac->r12r = (Int32)(temp_r12r >> temp3); + ac->r22r = (Int32)(temp_r22r >> temp3); + + } + else + { + temp3 = pv_normalize(((UInt32)max) >> 1) - 2; + + if (temp3 > 0) + { + ac->r01r = (Int32)(temp_r01r << temp3); + ac->r02r = (Int32)(temp_r02r << temp3); + ac->r11r = (Int32)(temp_r11r << temp3); + ac->r12r = (Int32)(temp_r12r << temp3); + ac->r22r = (Int32)(temp_r22r << temp3); + } + else + { + temp3 = -temp3; + ac->r01r = (Int32)(temp_r01r >> temp3); + ac->r02r = (Int32)(temp_r02r >> temp3); + ac->r11r = (Int32)(temp_r11r >> temp3); + ac->r12r = (Int32)(temp_r12r >> temp3); + ac->r22r = (Int32)(temp_r22r >> temp3); + } + + } + + /* + * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r); + */ + /* 1/(1 + 1e-6) == 1 - 1e-6 */ + /* 2^-20 == 1e-6 */ + ac->det = fxp_mul32_Q30(ac->r12r, ac->r12r); + + ac->det -= ac->det >> 20; + + ac->det = fxp_mul32_Q30(ac->r11r, ac->r22r) - ac->det; + } + else + { + pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS)); + } + + +} + + +#ifdef HQ_SBR + + +void calc_auto_corr(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 imagBuf[][32], + Int32 bd, + Int32 len) +{ + + + Int32 j; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 temp5; + Int32 temp6; + + Int64 accu1 = 0; + Int64 accu2 = 0; + Int64 accu3 = 0; + Int64 accu4 = 0; + Int64 accu5 = 0; + + + Int64 temp_r12r; + Int64 temp_r12i; + Int64 temp_r22r; + Int64 max = 0; + + + temp1 = realBuf[0 ][bd] >> N; + temp2 = imagBuf[0 ][bd] >> N; + temp3 = realBuf[0-1][bd] >> N; + temp4 = imagBuf[0-1][bd] >> N; + temp5 = realBuf[0-2][bd] >> N; + temp6 = imagBuf[0-2][bd] >> N; + + temp_r22r = fxp_mac64_Q31(0, temp5, temp5); + temp_r22r = fxp_mac64_Q31(temp_r22r, temp6, temp6); + temp_r12r = fxp_mac64_Q31(0, temp3, temp5); + temp_r12r = fxp_mac64_Q31(temp_r12r, temp4, temp6); + temp_r12i = -fxp_mac64_Q31(0, temp3, temp6); + temp_r12i = fxp_mac64_Q31(temp_r12i, temp4, temp5); + + for (j = 1; j < len; j++) + { + accu1 = fxp_mac64_Q31(accu1, temp3, temp3); + accu1 = fxp_mac64_Q31(accu1, temp4, temp4); + accu2 = fxp_mac64_Q31(accu2, temp1, temp3); + accu2 = fxp_mac64_Q31(accu2, temp2, temp4); + accu3 = fxp_mac64_Q31(accu3, temp2, temp3); + accu3 = fxp_mac64_Q31(accu3, -temp1, temp4); + accu4 = fxp_mac64_Q31(accu4, temp1, temp5); + accu4 = fxp_mac64_Q31(accu4, temp2, temp6); + accu5 = fxp_mac64_Q31(accu5, temp2, temp5); + accu5 = fxp_mac64_Q31(accu5, -temp1, temp6); + + temp5 = temp3; + temp6 = temp4; + temp3 = temp1; + temp4 = temp2; + temp1 = realBuf[j][bd] >> N; + temp2 = imagBuf[j][bd] >> N; + } + + + temp_r22r += accu1; + temp_r12r += accu2; + temp_r12i += accu3; + + + accu1 = fxp_mac64_Q31(accu1, temp3, temp3); + accu1 = fxp_mac64_Q31(accu1, temp4, temp4); + accu2 = fxp_mac64_Q31(accu2, temp1, temp3); + accu2 = fxp_mac64_Q31(accu2, temp2, temp4); + accu3 = fxp_mac64_Q31(accu3, temp2, temp3); + accu3 = fxp_mac64_Q31(accu3, -temp1, temp4); + accu4 = fxp_mac64_Q31(accu4, temp1, temp5); + accu4 = fxp_mac64_Q31(accu4, temp2, temp6); + accu5 = fxp_mac64_Q31(accu5, temp2, temp5); + accu5 = fxp_mac64_Q31(accu5, -temp1, temp6); + + + max |= accu5 ^(accu5 >> 63); + max |= accu4 ^(accu4 >> 63); + max |= accu3 ^(accu3 >> 63); + max |= accu2 ^(accu2 >> 63); + max |= accu1; + max |= temp_r12r ^(temp_r12r >> 63); + max |= temp_r12i ^(temp_r12i >> 63); + max |= temp_r22r; + + if (max) + { + + temp1 = (UInt32)(max >> 32); + if (temp1) + { + temp1 = 34 - pv_normalize(temp1); + ac->r11r = (Int32)(accu1 >> temp1); + ac->r01r = (Int32)(accu2 >> temp1); + ac->r01i = (Int32)(accu3 >> temp1); + ac->r02r = (Int32)(accu4 >> temp1); + ac->r02i = (Int32)(accu5 >> temp1); + ac->r12r = (Int32)(temp_r12r >> temp1); + ac->r12i = (Int32)(temp_r12i >> temp1); + ac->r22r = (Int32)(temp_r22r >> temp1); + } + else + { + temp1 = pv_normalize(((UInt32)max) >> 1) - 3; + + if (temp1 > 0) + { + ac->r11r = (Int32)(accu1 << temp1); + ac->r01r = (Int32)(accu2 << temp1); + ac->r01i = (Int32)(accu3 << temp1); + ac->r02r = (Int32)(accu4 << temp1); + ac->r02i = (Int32)(accu5 << temp1); + ac->r12r = (Int32)(temp_r12r << temp1); + ac->r12i = (Int32)(temp_r12i << temp1); + ac->r22r = (Int32)(temp_r22r << temp1); + } + else + { + temp1 = -temp1; + ac->r11r = (Int32)(accu1 >> temp1); + ac->r01r = (Int32)(accu2 >> temp1); + ac->r01i = (Int32)(accu3 >> temp1); + ac->r02r = (Int32)(accu4 >> temp1); + ac->r02i = (Int32)(accu5 >> temp1); + ac->r12r = (Int32)(temp_r12r >> temp1); + ac->r12i = (Int32)(temp_r12i >> temp1); + ac->r22r = (Int32)(temp_r22r >> temp1); + } + + } + + /* + * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r); + */ + /* 1/(1 + 1e-6) == 1 - 1e-6 */ + /* 2^-20 == 1e-6 */ + + ac->det = fxp_mul32_Q29(ac->r12i, ac->r12i); + ac->det = fxp_mac32_Q29(ac->r12r, ac->r12r, ac->det); + + ac->det -= ac->det >> 20; + + ac->det = -fxp_msu32_Q29(ac->r11r, ac->r22r, ac->det); + + } + else + { + pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS)); + } + +} + +#endif + + + + + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.h new file mode 100644 index 00000000..1091056c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_auto_corr.h @@ -0,0 +1,116 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_auto_corr.h + Funtions: + +------------------------------------------------------------------------------ + + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_AUTO_CORR_H +#define CALC_AUTO_CORR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +struct ACORR_COEFS +{ + Int32 r11r; + Int32 r01r; + Int32 r02r; + Int32 r12r; + Int32 r22r; +#ifdef HQ_SBR + Int32 r01i; + Int32 r02i; + Int32 r12i; +#endif + Int32 det; +}; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void calc_auto_corr_LC(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 bd, + Int32 len); + + +#ifdef HQ_SBR + + void calc_auto_corr(struct ACORR_COEFS *ac, + Int32 realBuf[][32], + Int32 imagBuf[][32], + Int32 bd, + Int32 len); + +#endif + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_gsfb_table.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_gsfb_table.c new file mode 100644 index 00000000..b86f6199 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_gsfb_table.c @@ -0,0 +1,231 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_gsfb_table.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = pointer to structure that holds information for current + frame. Data type FrameInfo + + group[] = array that contains the grouping information of short + windows (stop index of windows in each group). + Data type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pFrameInfo -> frame_sfb_top contains the cumulative bandwidth of + scalefactor bands in each group + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is only invoked when short windows are present. It calculates + the number of groups in one frame, and the scalefactor bandwidth of each + scalefactor band in each group. + All windows within one group share the same scalefactors and are interleaved + on a scalefactor band basis. Within each group, the actual length of one + scalefactor band equals to the number of windows times the number of + coefficients in a regular scalefactor band. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall replace the contents of pFrameInfo->frame_sfb_top + with the cumulative bandwidth of each scalefactor band in each group + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p54. 4.5.2.3.2 decoding process + +------------------------------------------------------------------------------ + PSEUDO-CODE + + offset = 0; + group_idx = 0; + + DO + pFrameInfo->group_len[group_idx] = group[group_idx] - offset; + offset = group[group_idx]; + group_idx++; + + WHILE (offset < NUM_SHORT_WINDOWS); + + + pFrameInfo->num_groups = group_idx; + + pFrameSfbTop = pFrameInfo->frame_sfb_top; + offset = 0; + + FOR (group_idx = 0; group_idx < pFrameInfo->num_groups; group_idx++) + + len = pFrameInfo->group_len[group_idx]; + + FOR (sfb = 0; sfb < pFrameInfo->sfb_per_win[group_idx]; sfb++) + + offset += pFrameInfo->sfb_width_128[sfb] * len; + *pFrameSfbTop++ = offset; + + ENDFOR + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void calc_gsfb_table( + FrameInfo *pFrameInfo, + Int group[]) +{ + + Int group_idx; + Int offset; + Int *pFrameSfbTop; + Int *pSfbWidth128; + Int sfb; + Int nsfb; + Int len; + Int ngroups; + + /* clear out the default values set by infoinit */ + /* */ + pv_memset(pFrameInfo->frame_sfb_top, + 0, + MAXBANDS*sizeof(pFrameInfo->frame_sfb_top[0])); + /* */ + /* first calculate the group length*/ + offset = 0; + ngroups = 0; + do + { + pFrameInfo->group_len[ngroups] = group[ngroups] - offset; + offset = group[ngroups]; + ngroups++; + + } + while (offset < NUM_SHORT_WINDOWS); + + + /* calculate the cumulative scalefactor bandwidth for one frame */ + pFrameInfo->num_groups = ngroups; + + pFrameSfbTop = pFrameInfo->frame_sfb_top; + offset = 0; + + + for (group_idx = 0; group_idx < ngroups; group_idx++) + { + len = pFrameInfo->group_len[ group_idx]; + nsfb = pFrameInfo->sfb_per_win[group_idx]; + + pSfbWidth128 = pFrameInfo->sfb_width_128; + + for (sfb = nsfb; sfb > 0; sfb--) + { + offset += *pSfbWidth128++ * len; + *pFrameSfbTop++ = offset; + } + } + + +} /* calc_gsfb_table */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.c new file mode 100644 index 00000000..082c6dd2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.c @@ -0,0 +1,355 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_anafilterbank.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "calc_sbr_anafilterbank.h" +#include "qmf_filterbank_coeff.h" +#include "analysis_sub_band.h" + +#include "aac_mem_funcs.h" +#include "fxp_mul32.h" + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_anafilterbank_LC(Int32 * Sr, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand) +{ + + Int i; + Int32 *p_Y_1; + Int32 *p_Y_2; + + Int16 * pt_X_1; + Int16 * pt_X_2; + Int32 realAccu1; + Int32 realAccu2; + + Int32 tmp1; + Int32 tmp2; + + + const Int32 * pt_C; + + p_Y_1 = scratch_mem[0]; + + + p_Y_2 = p_Y_1 + 63; + pt_C = &sbrDecoderFilterbankCoefficients_an_filt_LC[0]; + + pt_X_1 = X; + + + realAccu1 = fxp_mul32_by_16(Qfmt27(-0.51075594183097F), pt_X_1[-192]); + + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.51075594183097F), -pt_X_1[-128], realAccu1); + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), pt_X_1[-256], realAccu1); + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), -pt_X_1[ -64], realAccu1); + + + /* create array Y */ + + pt_X_1 = &X[-1]; + pt_X_2 = &X[-319]; + + + for (i = 15; i != 0; i--) + { + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + + } + + + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ +63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ +127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ +191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ +255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + + + pt_X_1 = X; + + realAccu2 = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]); + + realAccu2 = fxp_mac32_by_16(Qfmt27(0.00370548843500F), pt_X_1[-288], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[ -96], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[-224], realAccu2); + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), pt_X_1[-160], realAccu2); + + + analysis_sub_band_LC(scratch_mem[0], + Sr, + maxBand, + (Int32(*)[64])scratch_mem[1]); + +} + + + +#ifdef HQ_SBR + +void calc_sbr_anafilterbank(Int32 * Sr, + Int32 * Si, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand) +{ + Int i; + Int32 *p_Y_1; + Int32 *p_Y_2; + + + + + const Int32 * pt_C; + Int16 * pt_X_1; + Int16 * pt_X_2; + Int32 realAccu1; + Int32 realAccu2; + + Int32 tmp1; + Int32 tmp2; + + + p_Y_1 = scratch_mem[0]; + + + p_Y_2 = p_Y_1 + 63; + pt_C = &sbrDecoderFilterbankCoefficients_an_filt[0]; + + realAccu1 = fxp_mul32_by_16(Qfmt27(-0.36115899F), X[-192]); + + + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.36115899F), -X[-128], realAccu1); + realAccu1 = fxp_mac32_by_16(Qfmt27(-0.013271822F), X[-256], realAccu1); + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.013271822F), -X[ -64], realAccu1); + + /* create array Y */ + + pt_X_1 = &X[-1]; + pt_X_2 = &X[-319]; + + + for (i = 31; i != 0; i--) + { + tmp1 = *(pt_X_1--); + tmp2 = *(pt_X_2++); + realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1); + realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2); + tmp1 = pt_X_1[ -63]; + tmp2 = pt_X_2[ 63]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -127]; + tmp2 = pt_X_2[ 127]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -191]; + tmp2 = pt_X_2[ 191]; + realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + tmp1 = pt_X_1[ -255]; + tmp2 = pt_X_2[ 255]; + *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1); + *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2); + } + + + realAccu2 = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2); + realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2); + + + *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2); + + + analysis_sub_band(scratch_mem[0], + Sr, + Si, + maxBand, + (Int32(*)[64])scratch_mem[1]); + +} + + +#endif + + + +#endif /* AAC_PLUS */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.h new file mode 100644 index 00000000..1e8d9eb1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_anafilterbank.h @@ -0,0 +1,108 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_anafilterbank.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_SBR_ANAFILTERBANK_H +#define CALC_SBR_ANAFILTERBANK_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "config.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + +#define ROUND_ANAFIL 0 +//#define ROUND_ANAFIL 0 +#define ROUND_ANAFIL_LC (0) + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + void calc_sbr_anafilterbank_LC(Int32 * Sr, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand); + + +#ifdef HQ_SBR + + void calc_sbr_anafilterbank(Int32 * Sr, + Int32 * Si, + Int16 * X, + Int32 scratch_mem[][64], + Int32 maxBand); + +#endif + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* CALC_SBR_ANAFILTERBANK_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.c new file mode 100644 index 00000000..4866d524 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.c @@ -0,0 +1,2198 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: calc_sbr_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "calc_sbr_envelope.h" +#include "sbr_envelope_calc_tbl.h" +#include "sbr_create_limiter_bands.h" +#include "aac_mem_funcs.h" + +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#include "sbr_aliasing_reduction.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#include "pv_sqrt.h" + +#include "pv_div.h" +#include "fxp_mul32.h" +#include "pv_normalize.h" + +#define Q30fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F)) +#define Q15fmt(x) (Int32)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void envelope_application_LC(Int32 *aBufR, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 band_nrg_tone_detector, + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag); + + + void energy_estimation_LC(Int32 *aBufR, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2); + +#ifdef HQ_SBR + + + void envelope_application(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag, + Int32 band_nrg_tone_detector, + Int32 maxSmoothLength, + Int32 smooth_length); + + + void energy_estimation(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2); + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_envelope(SBR_FRAME_DATA *frameData, + Int32 *aBufR, + Int32 *aBufI, + Int freqBandTable1[2][MAX_FREQ_COEFFS + 1], + const Int32 *nSfb, + Int32 freqBandTable2[MAX_NOISE_COEFFS + 1], + Int32 nNBands, + Int32 reset, + Int32 *degreeAlias, + Int32 *harm_index, + Int32 *phase_index, + Int32 hFp[64], + Int32 *sUp, + Int32 limSbc[][13], + Int32 *gateMode, +#ifdef HQ_SBR + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], +#endif + Int32 scratch_mem[][64], + struct PATCH Patch, + Int32 sqrt_cache[][4], + Int32 LC_flag) +{ + + Int32 c; + Int32 li; + Int32 ui; + Int32 i; + Int32 j; + Int32 k = 0; + Int32 l; + Int m = 0; + Int kk = 0; + Int o; + Int next = -1; + Int32 ui2; + Int flag; + Int noNoiseFlag; + Int *ptr; + + + UInt32 nrg = 0; + Int32 nrg_exp = 0; + struct intg_div quotient; + struct intg_sqrt root_sq; + + Int32 aux1; + + Int32 *nL_man = frameData->sbrNoiseFloorLevel_man; + Int32 *nL_exp = frameData->sbrNoiseFloorLevel_exp; + + Int32 *sfb_nrg_man = frameData->iEnvelope_man; + Int32 *sfb_nrg_exp = frameData->iEnvelope_exp; + + Int32 tmp_q1; + Int32 tmp_q2; + + Int32 g_max_man; + Int32 g_max_exp; + + Int32 p_ref_man; + Int32 p_ref_exp; + + Int32 p_est_man; + Int32 p_est_exp; + + Int32 p_adj_man; + Int32 p_adj_exp; + Int32 avg_gain; + + Int32 boost_gain_q; + + Int32 band_nrg_tone_detector; + + Int32 *nrg_est_man = scratch_mem[0]; + Int32 *nrg_est_exp = scratch_mem[1]; + Int32 *nrg_ref_man = scratch_mem[2]; + Int32 *nrg_ref_exp = scratch_mem[3]; + Int32 *nrg_gain_man = scratch_mem[4]; + Int32 *nrg_gain_exp = scratch_mem[5]; + Int32 *noise_level_man = scratch_mem[6]; + Int32 *noise_level_exp = scratch_mem[7]; + Int32 *nrg_tone_man = scratch_mem[8]; + Int32 *nrg_tone_exp = scratch_mem[9]; + Int32 *hF = scratch_mem[10]; + + + + const Int32 *frame_info = frameData->frameInfo; + Int32 int_mode = frameData->sbr_header.interpolFreq; + + + + + + Int32 dontUseTheseGainValues[64]; + +#ifdef HQ_SBR + + Int32 n; + Int32 smooth_length; + Int32 smoothingLength = frameData->sbr_header.smoothingLength; + Int32 maxSmoothLength = smoothLengths[0]; + +#endif + + Int32 limiterBand = frameData->sbr_header.limiterBands; + Int32 limiterGains = frameData->sbr_header.limiterGains; + Int32 *addHarmonics = frameData->addHarmonics; + + Int32 lowSubband = freqBandTable1[LOW_RES][0]; + Int32 noSubbands = freqBandTable1[LOW_RES][nSfb[LOW_RES]] - lowSubband; + Int32 nEnv = frame_info[0]; + Int32 sEnv = frame_info[(nEnv + 1)<<1]; + + /* ensure that noSubbands in the range [0,64] */ + noSubbands = (noSubbands >> 31) ^ noSubbands; + if (noSubbands > 64) + { + noSubbands = 64; + } + + if (reset) + { + *sUp = 1; + *phase_index = 0; + sbr_create_limiter_bands(limSbc, + gateMode, + freqBandTable1[LOW_RES], + Patch, + nSfb[LOW_RES]); + } + + /* Mapping. */ + pv_memset((void*)hF, 0, (sizeof(*hF) << 6)); + + ptr = freqBandTable1[HI]; + l = *(ptr++); + + for (i = nSfb[HI]; i != 0; i--) + { + k = *(ptr++); + j = ((k + l) >> 1) - lowSubband; + l = k; + hF[j] = *(addHarmonics++); + } + + + /* Envelope adjustment. */ + + for (i = 0; i < nEnv; i++) + { + + if (frame_info[1+i] == frame_info[(nEnv<<1)+4+kk]) + { + kk++, next++; + } + + noNoiseFlag = (i == sEnv || i == frameData->prevEnvIsShort) ? 1 : 0; + +#ifdef HQ_SBR + smooth_length = (noNoiseFlag ? 0 : smoothLengths[smoothingLength]); +#endif + + + /* Estimate levels. */ + c = 0; + o = 0; + + band_nrg_tone_detector = 0; + + Int kkkk = freqBandTable1[ frame_info[nEnv+2+i] ][0]; + + for (j = 0; j < nSfb[frame_info[nEnv+2+i]]; j++) + { + li = freqBandTable1[ frame_info[nEnv+2+i] ][j ]; + ui = freqBandTable1[ frame_info[nEnv+2+i] ][j + 1]; + flag = 0; + + for (k = li; k < ui; k++) + { /* Calculate the average energy over the current envelope, */ + ui2 = (frame_info[1+i] << 1); + + if (LC_flag == ON) + { + energy_estimation_LC((Int32 *)aBufR, + nrg_est_man, + nrg_est_exp, + frame_info, + i, + k - kkkk, + c, + ui2); + } +#ifdef HQ_SBR + else + { + + energy_estimation((Int32 *)aBufR, + (Int32 *)aBufI, + nrg_est_man, + nrg_est_exp, + frame_info, + i, + k - kkkk, + c, + ui2); + } +#endif + + flag = (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? 1 : flag; + c++; + } + + + ui2 = freqBandTable2[o+1]; + + if (!int_mode) + { /* If no interpolation is used, */ + + tmp_q1 = -100; + + for (k = c - (ui - li); k < c; k++) + { + if (tmp_q1 < nrg_est_exp[k]) + { + tmp_q1 = nrg_est_exp[k]; + } + } + + nrg = 0; + for (k = c - (ui - li); k < c; k++) + { /* average the energy in all the QMF bands, */ + nrg += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); /* for the whole scalefactor band. */ + } + nrg /= (ui - li); + nrg_exp = tmp_q1; + + } + + c -= (ui - li); + + for (k = 0; k < ui - li; k++) + { + o = (k + li >= ui2) ? o + 1 : o; + ui2 = freqBandTable2[o+1]; + /* + * If no interpolation is used, use the averaged energy from above, + * otherwise do nothing. + */ + + + if (!int_mode) + { + nrg_est_man[c] = nrg; + nrg_est_exp[c] = nrg_exp; + } + + if (LC_flag == ON) + { + nrg_est_exp[c] += 1; + + if (flag) + { + dontUseTheseGainValues[k + li - lowSubband] = 1; + } + else + { + dontUseTheseGainValues[k + li - lowSubband] = 0; + } + } + + nrg_ref_man[c] = sfb_nrg_man[m]; + nrg_ref_exp[c] = sfb_nrg_exp[m]; + + /* + * compute nL/(1 + nL); where nL = nL_man*2^nL_exp + */ + aux1 = next * nNBands + o; + + tmp_q1 = nL_exp[aux1]; + + if (tmp_q1 >= 0) + { + pv_div(nL_man[aux1], nL_man[aux1] + (0x3FFFFFFF >> tmp_q1), "ient); + } + else + { + tmp_q1 = nL_man[aux1] >> (-tmp_q1); + pv_div(tmp_q1, tmp_q1 + 0x3FFFFFFF, "ient); + } + + /* + * tmp_q1 = nL/(1 + nL)*nrg_ref[c]; + */ + + tmp_q1 = fxp_mul32_Q30(quotient.quotient >> quotient.shift_factor, nrg_ref_man[c]); + + if (flag) + { + /* + * Calculate levels and gain, dependent on whether a synthetic, a sine is present or not. + * + * nrg_gain[c]=(float)pv_sqrt( tmp/(nrg_est[c] + 1), sqrt_cache[1] ); + */ + + + pv_div(tmp_q1, nrg_est_man[c] + 1, "ient); + /* + * nrg_est_man[c] is an integer number, while tmp_q1 and quotient.quotient + * are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[1]); + nrg_gain_man[c] = root_sq.root; /* in Q28 format */ + nrg_gain_exp[c] = root_sq.shift_factor; + + + /* + * nrg_tone[c]=(float)( (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? + * pv_sqrt(nrg_ref[c]/(1+tmp_nL), sqrt_cache[2]) : 0); + */ + if (hF[c] && (i >= sEnv || hFp[c+lowSubband])) + { + /* + * nrg_ref[c] and nL, as well as quotient.quotient + * are fractions in Q30 + */ + + /* aux1 == next*nNBands + o */ + + tmp_q2 = nL_exp[aux1]; + /* + * nrg_ref[c]/(1+tmp_nL) + */ + + if (tmp_q2 >= 0) + { + pv_div(nrg_ref_man[c], nL_man[aux1] + (0x3FFFFFFF >> tmp_q2), "ient); + } + else + { + tmp_q2 = nL_man[aux1] >> (-tmp_q2); + pv_div(nrg_ref_man[c], tmp_q2 + 0x3FFFFFFF, "ient); + tmp_q2 = 0; /* exponent has been applied to the sum ((man>>exp) + 1) */ + } + + tmp_q2 = nrg_ref_exp[c] - tmp_q2 - quotient.shift_factor; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[2]); + nrg_tone_man[c] = root_sq.root; + nrg_tone_exp[c] = root_sq.shift_factor; + + } + else + { + nrg_tone_man[c] = 0; + nrg_tone_exp[c] = 0; + } + + } + else + { + if (noNoiseFlag) + { + /* + * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c] /(nrg_est[c] + 1), sqrt_cache[3]); + */ + + pv_div(nrg_ref_man[c], nrg_est_man[c] + 1, "ient); + + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30; + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[3]); + nrg_gain_man[c] = root_sq.root; + nrg_gain_exp[c] = root_sq.shift_factor; + + } + else + { + /* + * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)), sqrt_cache[4]); + */ + /* aux1 == next*nNBands + o */ + + tmp_q2 = nL_exp[aux1]; + /* + * nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)) + */ + + if (nrg_est_man[c] == 0) + { + tmp_q2 = 0; /* avoid division by 0 in next if-else, this could be due to + rounding noise */ + } + + + if (tmp_q2 >= 0) + { + + tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, nL_man[aux1] + (0x3FFFFFFF >> tmp_q2)); + pv_div(nrg_ref_man[c], tmp_q2, "ient); + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1]; + if (nrg_est_man[c]) + { + tmp_q2 -= nrg_est_exp[c]; + } + + tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1]; + } + else + { + if (tmp_q2 > - 10) + { + tmp_q2 = nL_man[aux1] >> (-tmp_q2); + + tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, tmp_q2 + 0x3FFFFFFF); + } + else + { + tmp_q2 = nrg_est_man[c] + 1; + } + + + pv_div(nrg_ref_man[c], tmp_q2, "ient); + /* + * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and + * quotient.quotient are fractions in Q30 + */ + + tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30; + if (nrg_est_man[c]) + { + tmp_q2 -= nrg_est_exp[c]; + } + + } + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[4]); + nrg_gain_man[c] = root_sq.root; + nrg_gain_exp[c] = root_sq.shift_factor; + + } + + nrg_tone_man[c] = 0; + nrg_tone_exp[c] = -100; + + } + + band_nrg_tone_detector |= nrg_tone_man[c]; /* detect any tone activity */ + + pv_sqrt(tmp_q1, nrg_ref_exp[c], &root_sq, sqrt_cache[5]); + noise_level_man[c] = root_sq.root; + noise_level_exp[c] = root_sq.shift_factor; + + c++; + + } /* ---- end-for-loop (k) ------ */ + m++; + + } /* -------- Estimate levels end-for-loop (j) ----- */ + + + + /* + * Limiter + */ + + + for (c = 0; c < gateMode[limiterBand]; c++) + { + + p_ref_man = 0; + p_est_man = 0; + + /* + * get max exponent for the reference and estimated energy + */ + p_ref_exp = -100; + p_est_exp = -100; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + if (p_ref_exp < nrg_ref_exp[k]) + { + p_ref_exp = nrg_ref_exp[k]; /* max */ + } + if (p_est_exp < nrg_est_exp[k]) + { + p_est_exp = nrg_est_exp[k]; /* max */ + } + } + + k -= limSbc[limiterBand][c]; /* number of element used in the addition */ + + while (k != 0) /* bit guard protection depends on log2(k) */ + { + k >>= 1; + p_ref_exp++; /* add extra bit-overflow-guard, nrg_ref_exp is in Q30 format */ + } + + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { /*Calculate the average gain for the current limiter band.*/ + p_ref_man += (nrg_ref_man[k] >> (p_ref_exp - nrg_ref_exp[k])); + p_est_man += (nrg_est_man[k] >> (p_est_exp - nrg_est_exp[k])); + + } + + if (p_est_man) + { + /* + * "average gain" (not equal to average of nrg_gain) + */ + pv_div(p_ref_man, p_est_man, "ient); + + tmp_q2 = p_ref_exp - 30 - p_est_exp - quotient.shift_factor; + + /* + * avg_gain = sqrt(p_ref/p_est) + */ + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[6]); + avg_gain = root_sq.root; + g_max_exp = root_sq.shift_factor; + + /* + * maximum gain allowed is calculated from table. + */ + + /* + * g_max = avg_gain * limGains[limiterGains]; + */ + + g_max_man = fxp_mul32_Q30(avg_gain, limGains[limiterGains]); /* table is in Q30 */ + + if (limiterGains == 3) + { + g_max_exp = limGains[4]; + } + + tmp_q1 = g_max_exp >= 16 ? g_max_exp : 16; + + tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp); + tmp_q1 = Q28fmt(1.52587890625F) >> (tmp_q1 - 16); + + if (tmp_q2 > tmp_q1) + { + /* upper limit, +100 dB */ + g_max_man = Q28fmt(1.52587890625F); + g_max_exp = 16; + } + } + else + { + /* Qfmt(1.52587890625F) exp = 16 */ + g_max_man = Q28fmt(1.52587890625F); + g_max_exp = 16; + } + + /* + * Compute Adjusted power p_adj + */ + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + + tmp_q1 = g_max_exp >= nrg_gain_exp[k] ? g_max_exp : nrg_gain_exp[k]; + + tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp); + tmp_q1 = nrg_gain_man[k] >> (tmp_q1 - nrg_gain_exp[k]); + /* + * if(g_max <= nrg_gain[k]) + */ + if (tmp_q2 <= tmp_q1) + { + tmp_q1 = fxp_mul32_Q28(noise_level_man[k], g_max_man); + pv_div(tmp_q1, nrg_gain_man[k], "ient); + noise_level_man[k] = quotient.quotient >> 2; /* in Q28 */ + noise_level_exp[k] = noise_level_exp[k] + g_max_exp - quotient.shift_factor - nrg_gain_exp[k]; + + nrg_gain_man[k] = g_max_man; /* gains with noise supression */ + nrg_gain_exp[k] = g_max_exp; + } + } + + p_adj_exp = -100; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + tmp_q1 = nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28; /* 28 to match shift down by mult32_Q28 */ + + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + if (nrg_tone_man[k]) + { + tmp_q1 = (nrg_tone_exp[k] << 1); + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + } + else if (!noNoiseFlag) + { + tmp_q1 = (noise_level_exp[k] << 1); + + if (p_adj_exp < tmp_q1) + { + p_adj_exp = tmp_q1; + } + } + } + + p_adj_exp += 1; /* overflow bit-guard*/ + + p_adj_man = 0; + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + /* + * p_adj += nrg_gain[k]*nrg_gain[k]*nrg_est[k]; + */ + + if (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 59) + { + tmp_q1 = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]); + tmp_q1 = fxp_mul32_Q28(tmp_q1, nrg_est_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28))); + } + + if (nrg_tone_man[k]) + { + /* + * p_adj += nrg_tone[k]*nrg_tone[k]; + */ + if (p_adj_exp - (nrg_tone_exp[k] << 1) < 31) + { + tmp_q1 = fxp_mul32_Q28(nrg_tone_man[k], nrg_tone_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_tone_exp[k] << 1))); + } + } + else if (!noNoiseFlag) + { + /* + * p_adj += noise_level[k]*noise_level[k]; + */ + + if (p_adj_exp - (noise_level_exp[k] << 1) < 31) + { + tmp_q1 = fxp_mul32_Q28(noise_level_man[k], noise_level_man[k]); + p_adj_man += (tmp_q1 >> (p_adj_exp - (noise_level_exp[k] << 1))); + } + + } + } + + + if (p_adj_man) + { + pv_div(p_ref_man, p_adj_man, "ient); + tmp_q2 = p_ref_exp - p_adj_exp - 58 - quotient.shift_factor; /* 58 <> Q30 + Q28 */ + + pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[7]); + + if (root_sq.shift_factor > -28) + { + boost_gain_q = root_sq.root << (root_sq.shift_factor + 28); + } + else + { + boost_gain_q = root_sq.root >> (-28 - root_sq.shift_factor); + } + + tmp_q1 = root_sq.shift_factor >= -28 ? root_sq.shift_factor : -28; + + tmp_q2 = root_sq.root >> (tmp_q1 - root_sq.shift_factor); + tmp_q1 = Q28fmt(1.584893192f) >> (tmp_q1 + 28); + + + if (tmp_q2 > tmp_q1) + { + boost_gain_q = Q28fmt(1.584893192f); + } + } + else + { + boost_gain_q = Q28fmt(1.584893192f); + } + + if (band_nrg_tone_detector) + { + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q); + noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q); + nrg_tone_man[k] = fxp_mul32_Q28(nrg_tone_man[k], boost_gain_q); + } + } + else + { + + for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q); + noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q); + } + + + } + + } /* Limiter End for loop (c) */ + + + if (LC_flag == ON) + { + + /* + * Aliasing correction + */ + + sbr_aliasing_reduction(degreeAlias, + nrg_gain_man, + nrg_gain_exp, + nrg_est_man, + nrg_est_exp, + dontUseTheseGainValues, + noSubbands, + lowSubband, + sqrt_cache, + scratch_mem[3]); + + if (*sUp) /* Init only done once upon reset */ + { + *sUp = 0; + } + + envelope_application_LC((Int32 *)aBufR, + nrg_gain_man, + nrg_gain_exp, + noise_level_man, + noise_level_exp, + nrg_tone_man, + nrg_tone_exp, + band_nrg_tone_detector, + frame_info, + harm_index, + phase_index, + i, + lowSubband, + noSubbands, + noNoiseFlag); + } +#ifdef HQ_SBR + else + { + + if (*sUp) /* Init only done once upon reset */ + { + for (n = 0; n < maxSmoothLength; n++) + { + pv_memcpy(fBuf_man[n], nrg_gain_man, noSubbands*sizeof(*fBuf_man[n])); + pv_memcpy(fBufN_man[n], noise_level_man, noSubbands*sizeof(*fBufN_man[n])); + pv_memcpy(fBuf_exp[n], nrg_gain_exp, noSubbands*sizeof(*fBuf_exp[n])); + pv_memcpy(fBufN_exp[n], noise_level_exp, noSubbands*sizeof(*fBufN_exp[n])); + } + *sUp = 0; + } + + + envelope_application((Int32 *)aBufR, + (Int32 *)aBufI, + nrg_gain_man, + nrg_gain_exp, + noise_level_man, + noise_level_exp, + nrg_tone_man, + nrg_tone_exp, + fBuf_man, + fBuf_exp, + fBufN_man, + fBufN_exp, + frame_info, + harm_index, + phase_index, + i, + lowSubband, + noSubbands, + noNoiseFlag, + band_nrg_tone_detector, + maxSmoothLength, + smooth_length); + + } +#endif + + } /* ----- Envelope adjustment end for-loop (i) ---- */ + + + pv_memcpy(&hFp[0] + lowSubband, + hF, + (64 - lowSubband)*sizeof(*hF)); + + if (sEnv == nEnv) + { + frameData->prevEnvIsShort = 0; + } + else + { + frameData->prevEnvIsShort = -1; + } + + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void envelope_application_LC(Int32 *aBufR, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 band_nrg_tone_detector, + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag) +{ + + Int32 *ptrReal; + Int32 sb_gain_man; + Int32 sb_noise_man; + Int32 sb_noise_exp; + Int32 l; + Int32 k; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 tone_count; + Int16 tmp_16; + Int32 indexMinus1; + Int32 indexPlus1; + + + /* + * Application + */ + + if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */ + { + + /* + * pre-calculate tone application + */ + for (k = 0; k < noSubbands; k++) + { + tmp_q2 = (-nrg_tone_exp[k]); + tmp_q1 = nrg_tone_man[k]; + tmp_q2 = tmp_q1 >> tmp_q2; + tmp_q1 = fxp_mul32_by_16(tmp_q2, Q15fmt(0.0163f)); + nrg_tone_man[k] = tmp_q2; + nrg_tone_exp[k] = tmp_q1; + noise_level_exp[k] += 1; + nrg_gain_exp[k] += 28; + } + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + + tone_count = 0; + + indexPlus1 = (*harm_index + 1) & 3; + + if (indexPlus1 & 1) /* if indexPlus1 is odd */ + { + for (k = 0; k < noSubbands; k++) + { + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + if (!nrg_tone_man[k] && !noNoiseFlag) + + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + tmp_q1 = nrg_tone_man[k]; + + if (*harm_index) + { + *ptrReal -= tmp_q1; + } + else + { + *ptrReal += tmp_q1; + } + + if (tmp_q1) + { + tone_count++; + } + + ptrReal++; + + } /* for-loop (k) */ + + } + else /* if indexPlus1 is even */ + { + indexMinus1 = (*harm_index - 1) & 3; + + /* --- k = 0 ----- */ + + sb_gain_man = nrg_gain_man[0]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[0]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + tmp_q1 = nrg_tone_exp[0]; + tmp_q2 = nrg_tone_exp[1]; + + if ((indexPlus1 != 0) ^((lowSubband & 1) != 0)) + { + *(ptrReal - 1) -= tmp_q1; + *(ptrReal) += tmp_q2; + } + else + { + *(ptrReal - 1) += tmp_q1; + *(ptrReal) -= tmp_q2; + } + + if (!nrg_tone_man[0] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[0]; + sb_noise_exp = noise_level_exp[0]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + else + { + tone_count++; + } + + ptrReal++; + + /* ---- */ + + for (k = 1; k < noSubbands - 1; k++) + { + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -32) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + + if (tone_count < 16) + { + tmp_q1 = nrg_tone_exp[k - 1]; + tmp_q2 = nrg_tone_exp[k + 1]; + + tmp_q1 -= tmp_q2; + + + if ((indexPlus1 != 0) ^(((k + lowSubband) & 1) != 0)) + { + *(ptrReal) -= tmp_q1; + } + else + { + *(ptrReal) += tmp_q1; + } + } /* if (tone_count < 16) */ + + + if (!nrg_tone_man[k] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + else + { + tone_count++; + } + + ptrReal++; + + } /* for-loop (k) */ + + sb_gain_man = nrg_gain_man[k]; + tmp_q1 = *ptrReal; + tmp_q2 = nrg_gain_exp[k]; + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -31) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + + if ((tone_count < 16) && !(indexMinus1 &1)) + { + tmp_q1 = nrg_tone_exp[k - 1]; + tmp_q2 = nrg_tone_exp[k ]; + + if ((indexMinus1 != 0) ^(((k + lowSubband) & 1) != 0)) + { + *(ptrReal) += tmp_q1; + + if (k + lowSubband < 62) + { + *(ptrReal + 1) -= tmp_q2; + } + } + else + { + *(ptrReal) -= tmp_q1; + + if (k + lowSubband < 62) + { + *(ptrReal + 1) += tmp_q2; + } + } + } /* if (tone_count < 16) */ + + + if (!nrg_tone_man[k] && !noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -31) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + } /* if indexPlus1 is odd */ + + *harm_index = indexPlus1; + + + } /* for-loop (l) */ + + } + else /* if ( band_nrg_tone_detector) */ + { + + for (k = 0; k < noSubbands; k++) + { + tmp_q1 = noise_level_exp[k]; + tmp_q2 = nrg_gain_exp[k]; + noise_level_exp[k] = tmp_q1 + 1; + nrg_gain_exp[k] = tmp_q2 + 28; + } + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + + for (k = 0; k < noSubbands; k++) + { + + tmp_q1 = *ptrReal; + sb_gain_man = nrg_gain_man[k]; + + tmp_q2 = nrg_gain_exp[k]; + + tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man); + + if (tmp_q2 < 0) + { + if (tmp_q2 > -31) + { + *ptrReal = tmp_q1 >> (-tmp_q2); + } + } + else + { + *ptrReal = tmp_q1 << tmp_q2; + } + + *phase_index = (*phase_index + 1) & 511; + + if (! noNoiseFlag) + { + tmp_16 = rP_LCx[*phase_index]; + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -31) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + } + } + + ptrReal++; + + } /* for-loop (k) */ + + *harm_index = (*harm_index + 1) & 3; + + + } /* for-loop (l) */ + + } + +} + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +#define Qfmt15(a) (Int32)(a*((Int32)1<<15) + (a>=0?0.5F:-0.5F)) + + +const Int16 pow2[39] = { 0, 0, 1, 0, 2, + 0, Qfmt15(2 / 6.0f), 0, 3, 0, Qfmt15(2 / 10.0f), 0, Qfmt15(2 / 12.0f), 0, Qfmt15(2 / 14.0f), 0, 4, + 0, Qfmt15(2 / 18.0f), 0, Qfmt15(2 / 20.0f), 0, Qfmt15(2 / 22.0f), 0, Qfmt15(2 / 24.0f), + 0, Qfmt15(2 / 26.0f), 0, Qfmt15(2 / 28.0f), 0, Qfmt15(2 / 30.0f), 0, 5, 0, Qfmt15(2 / 34.0f), + 0, Qfmt15(2 / 36.0f), 0, Qfmt15(2 / 38.0f) + }; + +void energy_estimation_LC(Int32 *aBufR, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2) +{ + + + Int32 aux1; + Int32 aux2; + Int32 l; + + + Int64 nrg_h = 0; + Int32 tmp1; + UInt32 tmp2; + + for (l = ui2; l < (frame_info[2+i] << 1); l++) + { + + aux1 = aBufR[l++*SBR_NUM_BANDS + k ]; + aux2 = aBufR[l *SBR_NUM_BANDS + k ]; + + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + } + + /* + * Check for overflow and saturate if needed + */ + if (nrg_h < 0) + { + nrg_h = 0x7fffffff; + } + + + if (nrg_h) + { + tmp2 = (UInt32)(nrg_h >> 32); + if (tmp2) + { + aux2 = pv_normalize(tmp2); + aux2 -= 1; /* ensure Q30 */ + nrg_h = (nrg_h << aux2) >> 33; + tmp2 = (UInt32)(nrg_h); + nrg_est_exp[c] = 33 - aux2; + } + else + { + tmp2 = (UInt32)(nrg_h >> 2); + aux2 = pv_normalize(tmp2); + aux2 -= 1; /* ensure Q30 */ + + tmp2 = (tmp2 << aux2); + nrg_est_exp[c] = -aux2 + 2; + } + + tmp1 = (l - ui2); + + aux2 = pow2[tmp1]; + if (tmp1 == (tmp1 & (-tmp1))) + { + nrg_est_man[c] = tmp2 >> aux2; + } + else + { + nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2); + } + + } + else + { + nrg_est_man[c] = 0; + nrg_est_exp[c] = -100; + } + + + + + +} + + + + + + +#if HQ_SBR + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void envelope_application(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_gain_man, + Int32 *nrg_gain_exp, + Int32 *noise_level_man, + Int32 *noise_level_exp, + Int32 *nrg_tone_man, + Int32 *nrg_tone_exp, + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], + const Int32 *frame_info, + Int32 *harm_index, + Int32 *phase_index, + Int32 i, + Int32 lowSubband, + Int32 noSubbands, + Int32 noNoiseFlag, + Int32 band_nrg_tone_detector, + Int32 maxSmoothLength, + Int32 smooth_length) +{ + + Int32 *ptrReal; + Int32 *ptrImag; + Int32 sb_gain_man; + Int32 sb_gain_exp; + Int32 sb_noise_man; + Int32 sb_noise_exp; + Int32 l; + Int32 k; + Int32 n; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 aux1; + Int32 aux2; + Int32 filter_history = 0; + + + if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */ + { + + /* + * pre-calculate tone application + */ + + ptrReal = nrg_tone_exp; + ptrImag = nrg_tone_man; + tmp_q1 = - *(ptrReal++); + aux1 = *(ptrImag); + for (k = 0; k < noSubbands; k++) + { + *(ptrImag++) = aux1 >> tmp_q1; + tmp_q1 = - *(ptrReal++); + aux1 = *(ptrImag); + } + + /* + * Application + */ + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + ptrImag = (aBufI + l * SBR_NUM_BANDS); + + if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man)); + pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp)); + pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man)); + pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp)); + } + + /* + * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation + */ + for (k = 0; k < noSubbands; k++) + { + if (smooth_length == 0) /* no filter-smooth needed */ + { + sb_gain_man = nrg_gain_man[k]; + sb_gain_exp = nrg_gain_exp[k]; + + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + } + else + { /* else smooth_length == 4 and fir_4 filter is being used */ + + sb_gain_exp = fBuf_exp[maxSmoothLength][k]; + + sb_noise_exp = fBufN_exp[maxSmoothLength][k]; + + for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++) + { + if (sb_gain_exp < fBuf_exp[n][k]) + { + sb_gain_exp = fBuf_exp[n][k]; + } + + if (sb_noise_exp < fBufN_exp[n][k]) + { + sb_noise_exp = fBufN_exp[n][k]; + } + } + + sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]); + + sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]); + + n = maxSmoothLength - smooth_length; + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]); + + } + + + + /* + * *ptrReal = *ptrReal * sb_gain ; + * *ptrImag = *ptrImag * sb_gain; + */ + aux1 = *ptrReal; + aux2 = *ptrImag; + sb_gain_exp += 32; + aux1 = fxp_mul32_Q31(aux1, sb_gain_man); + aux2 = fxp_mul32_Q31(aux2, sb_gain_man); + + + if (sb_gain_exp < 0) + { + sb_gain_exp = -sb_gain_exp; + if (sb_gain_exp < 32) + { + *ptrReal = (aux1 >> sb_gain_exp); + *ptrImag = (aux2 >> sb_gain_exp); + } + } + else + { + *ptrReal = (aux1 << sb_gain_exp); + *ptrImag = (aux2 << sb_gain_exp); + } + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + *phase_index = (*phase_index + 1) & 511; + + if (nrg_tone_man[k] || noNoiseFlag) + { + sb_noise_man = 0; + sb_noise_exp = 0; + } + else + { + + Int32 tmp = rPxx[*phase_index]; + sb_noise_exp += 1; + tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp); + tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp); + + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + *ptrReal += tmp_q1 >> (-sb_noise_exp); + *ptrImag += tmp_q2 >> (-sb_noise_exp); + } + } + else + { + *ptrReal += tmp_q1 << sb_noise_exp; + *ptrImag += tmp_q2 << sb_noise_exp; + } + } + + /* + * tmp_q1 = nrg_tone[k] + */ + + tmp_q1 = nrg_tone_man[k]; + + if (*harm_index & 1) + { + if ((((k + lowSubband) & 1) != 0) ^(*harm_index != 1)) + { + *ptrImag -= tmp_q1; + } + else + { + *ptrImag += tmp_q1; + } + } + else + { + *ptrReal += (*harm_index) ? -tmp_q1 : tmp_q1; + } + + *ptrReal++ <<= 10; + *ptrImag++ <<= 10; + + + } /* for-loop (k) */ + + + *harm_index = (*harm_index + 1) & 3; + + /* + * Update smoothing filter history + */ + + if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + /* + * mantissas + */ + + ptrReal = (Int32 *)fBuf_man[0]; + ptrImag = (Int32 *)fBufN_man[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_man[n] = fBuf_man[n+1]; + fBufN_man[n] = fBufN_man[n+1]; + } + + fBuf_man[maxSmoothLength] = ptrReal; + fBufN_man[maxSmoothLength] = ptrImag; + + /* + * exponents + */ + ptrReal = (Int32 *)fBuf_exp[0]; + ptrImag = (Int32 *)fBufN_exp[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_exp[n] = fBuf_exp[n+1]; + fBufN_exp[n] = fBufN_exp[n+1]; + } + + fBuf_exp[maxSmoothLength] = ptrReal; + fBufN_exp[maxSmoothLength] = ptrImag; + } + + } /* for-loop (l) */ + + + } + else /* ---- if ( band_nrg_tone_detector) ---- */ + { + + /* + * Application + */ + + for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++) + { + ptrReal = (aBufR + l * SBR_NUM_BANDS); + ptrImag = (aBufI + l * SBR_NUM_BANDS); + + if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man)); + pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp)); + pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man)); + pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp)); + } + + /* + * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation + */ + for (k = 0; k < noSubbands; k++) + { + if (smooth_length == 0) /* no filter-smooth needed */ + { + sb_gain_man = nrg_gain_man[k]; + sb_gain_exp = nrg_gain_exp[k]; + + sb_noise_man = noise_level_man[k]; + sb_noise_exp = noise_level_exp[k]; + + } + else + { /* else smooth_length == 4 and fir_4 filter is being used */ + + sb_gain_exp = fBuf_exp[maxSmoothLength][k]; + + sb_noise_exp = fBufN_exp[maxSmoothLength][k]; + + for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++) + { + if (sb_gain_exp < fBuf_exp[n][k]) + { + sb_gain_exp = fBuf_exp[n][k]; + } + + if (sb_noise_exp < fBufN_exp[n][k]) + { + sb_noise_exp = fBufN_exp[n][k]; + } + } + + sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]); + + sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f)); + sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]); + + n = maxSmoothLength - smooth_length; + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]); + + tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f)); + sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]); + + tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f)); + sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]); + + } + + + + /* + * *ptrReal = *ptrReal * sb_gain ; + * *ptrImag = *ptrImag * sb_gain; + */ + aux1 = *ptrReal; + aux2 = *ptrImag; + sb_gain_exp += 32; + aux1 = fxp_mul32_Q31(aux1, sb_gain_man); + aux2 = fxp_mul32_Q31(aux2, sb_gain_man); + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + + + if (sb_gain_exp < 0) + { + if (sb_gain_exp > -32) + { + if (sb_gain_exp > -10) + { + *ptrReal = aux1 << (10 + sb_gain_exp); + *ptrImag = aux2 << (10 + sb_gain_exp); + } + else + { + *ptrReal = aux1 >> (-sb_gain_exp - 10); + *ptrImag = aux2 >> (-sb_gain_exp - 10); + } + } + } + else + { + *ptrReal = aux1 << (sb_gain_exp + 10); + *ptrImag = aux2 << (sb_gain_exp + 10); + } + + + + + /* + * if ( sb_noise != 0) + * { + * *ptrReal += sb_noise * rP[*phase_index][0]; + * *ptrImag += sb_noise * rP[*phase_index][1]; + * } + */ + *phase_index = (*phase_index + 1) & 511; + + if (!noNoiseFlag) + { + + Int32 tmp = rPxx[*phase_index]; + sb_noise_exp += 1; + tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp); + tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp); + + if (sb_noise_exp < 0) + { + if (sb_noise_exp > -32) + { + if (sb_noise_exp > -10) + { + *ptrReal += tmp_q1 << (10 + sb_noise_exp); + *ptrImag += tmp_q2 << (10 + sb_noise_exp); + } + else + { + *ptrReal += tmp_q1 >> (-sb_noise_exp - 10); + *ptrImag += tmp_q2 >> (-sb_noise_exp - 10); + } + } + } + else + { + *ptrReal += tmp_q1 << (sb_noise_exp + 10); + *ptrImag += tmp_q2 << (sb_noise_exp + 10); + } + } + + ptrReal++; + ptrImag++; + + + } /* for-loop (k) */ + + + *harm_index = (*harm_index + 1) & 3; + + /* + * Update smoothing filter history + */ + + if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */ + { + /* + * mantissas + */ + + ptrReal = (Int32 *)fBuf_man[0]; + ptrImag = (Int32 *)fBufN_man[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_man[n] = fBuf_man[n+1]; + fBufN_man[n] = fBufN_man[n+1]; + } + + fBuf_man[maxSmoothLength] = ptrReal; + fBufN_man[maxSmoothLength] = ptrImag; + + /* + * exponents + */ + ptrReal = (Int32 *)fBuf_exp[0]; + ptrImag = (Int32 *)fBufN_exp[0]; + + for (n = 0; n < maxSmoothLength; n++) + { + fBuf_exp[n] = fBuf_exp[n+1]; + fBufN_exp[n] = fBufN_exp[n+1]; + } + + fBuf_exp[maxSmoothLength] = ptrReal; + fBufN_exp[maxSmoothLength] = ptrImag; + } + + } /* for-loop (l) */ + + } /* if ( band_nrg_tone_detector) */ + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void energy_estimation(Int32 *aBufR, + Int32 *aBufI, + Int32 *nrg_est_man, + Int32 *nrg_est_exp, + const Int32 *frame_info, + Int32 i, + Int32 k, + Int32 c, + Int32 ui2) +{ + + Int32 aux1; + Int32 aux2; + Int32 l; + + + + Int64 nrg_h = 0; + Int32 tmp1; + Int32 tmp2; + + aux1 = aBufR[ui2*SBR_NUM_BANDS + k]; + aux2 = aBufI[ui2*SBR_NUM_BANDS + k]; + for (l = ui2 + 1; l < (frame_info[2+i] << 1); l++) + { + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + aux1 = aBufR[l*SBR_NUM_BANDS + k]; + aux2 = aBufI[l*SBR_NUM_BANDS + k]; + } + nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1); + nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2); + + + /* + * Check for overflow and saturate if needed + */ + if (nrg_h < 0) + { + nrg_h = 0x7fffffff; + } + + if (nrg_h) + { + + aux1 = (UInt32)(nrg_h >> 32); + if (aux1) + { + aux2 = pv_normalize(aux1); + if (aux2) + { + aux2 -= 1; /* ensure Q30 */ + nrg_h = (nrg_h << aux2) >> 33; + tmp2 = (UInt32)(nrg_h); + nrg_est_exp[c] = 33 - aux2; + } + else + { + tmp2 = (UInt32)(aux1 >> 1); + nrg_est_exp[c] = 33 ; + + + } + } + else + { + aux1 = (UInt32)(nrg_h >> 1); + aux2 = pv_normalize(aux1); + + tmp2 = (aux1 << aux2); + nrg_est_exp[c] = -aux2 + 1; + + + } + + + + tmp1 = (l - ui2); + aux2 = pow2[tmp1]; + if (tmp1 == (tmp1 & (-tmp1))) + { + nrg_est_man[c] = tmp2 >> aux2; + } + else + { + nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2); + } + } + else + { + nrg_est_man[c] = 0; + nrg_est_exp[c] = -100; + } + + +} + + + + + +#endif + + +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.h new file mode 100644 index 00000000..f2ddfd38 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_envelope.h @@ -0,0 +1,139 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_envelope.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALCULATE_SBR_ENVELOPE_H +#define CALCULATE_SBR_ENVELOPE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_sbr_frame_data.h" +#include "sbr_generate_high_freq.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void calc_sbr_envelope(SBR_FRAME_DATA *frameData, + Int32 *aBufR, + Int32 *aBufI, + Int freqBandTable1[2][MAX_FREQ_COEFFS + 1], + const Int32 *nSfb, + Int32 freqBandTable2[MAX_NOISE_COEFFS + 1], + Int32 nNBands, + Int32 reset, + Int32 *degreeAlias, + Int32 *harm_index, + Int32 *phase_index, + Int32 hFp[64], + Int32 *sUp, + Int32 limSbc[][13], + Int32 *gateMode, +#ifdef HQ_SBR + Int32 *fBuf_man[64], + Int32 *fBuf_exp[64], + Int32 *fBufN_man[64], + Int32 *fBufN_exp[64], +#endif + Int32 scratch_mem[][64], + struct PATCH Patch, + Int32 sqrt_cache[][4], + Int32 LC_flag); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* CALCULATE_SBR_ENVELOPE_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.c new file mode 100644 index 00000000..0f28d83c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.c @@ -0,0 +1,636 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: calc_sbr_synfilterbank.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#include "config.h" + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "calc_sbr_synfilterbank.h" +#include "qmf_filterbank_coeff.h" +#include "synthesis_sub_band.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#if defined (PV_ARM_V5) + + +static inline Int16 sat(Int32 y) +{ + Int32 x; + __asm + { + qdadd y, y, y + mov y, y, asr #16 + } + + return((Int16)y); +} + +#define saturate2( a, b, c, d) *c = sat( a); \ + *d = sat( b); \ + c += 2; \ + d -= 2; + + +#elif defined (PV_ARM_V4) + + +static inline Int16 sat(Int32 y) +{ + Int32 x; + Int32 z = 31; /* rvct compiler problem */ + __asm + { + sub y, y, y, asr 2 + mov y, y, asr N + mov x, y, asr #15 + teq x, y, asr z + eorne y, INT16_MAX, y, asr #31 + } + + return((Int16)y); +} + +#define saturate2( a, b, c, d) *c = sat( a); \ + *d = sat( b); \ + c += 2; \ + d -= 2; + +#elif defined(PV_ARM_GCC_V5) + +static inline Int16 sat(Int32 y) +{ + register Int32 x; + register Int32 ra = y; + + + asm volatile( + "qdadd %0, %1, %1\n\t" + "mov %0, %0, asr #16" + : "=&r*i"(x) + : "r"(ra)); + + return ((Int16)x); +} + + +#define saturate2( a, b, c, d) *c = sat( a); \ + *d = sat( b); \ + c += 2; \ + d -= 2; + + +#elif defined(PV_ARM_MSC_EVC_V5) + +#include "armintr.h" + +#define saturate2( a, b, c, d) *c = _DAddSatInt( a, a)>>16; \ + *d = _DAddSatInt( b, b)>>16; \ + c += 2; \ + d -= 2; + +#else + + +#define saturate2( a, b, c, d) a -= (a>>2); \ + a = (a>>N); \ + if((a>>15) != (a>>31)) \ + { \ + a = ((a >> 31) ^ INT16_MAX); \ + } \ + *c = (Int16)a; \ + c += 2; \ + b -= (b>>2); \ + b = (b>>N); \ + if((b>>15) != (b>>31)) \ + { \ + b = ((b >> 31) ^ INT16_MAX); \ + } \ + *d = (Int16)b; \ + d -= 2; + + +#endif + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void calc_sbr_synfilterbank_LC(Int32 * Sr, + Int16 * timeSig, + Int16 V[1280], + Bool bDownSampleSBR) +{ + Int32 i; + Int k; + + Int32 realAccu1; + Int32 realAccu2; + const Int32 *pt_C2; + + Int16 *pt_V1; + Int16 *pt_V2; + + + Int16 *pt_timeSig; + + Int16 *pt_timeSig_2; + Int32 test1; + Int16 tmp1; + Int16 tmp2; + + /* shift filterstates */ + + Int32 * pt_Sr = Sr; + + + if (bDownSampleSBR == FALSE) + { + + synthesis_sub_band_LC(pt_Sr, V); + + /* content of V[] is at most 16 bits */ + + pt_timeSig = &timeSig[0]; + pt_timeSig_2 = &timeSig[64]; + + + tmp1 = V[ 704]; + tmp2 = V[ 768]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1); + tmp1 = -V[ 512]; + tmp2 = V[ 960]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1); + tmp1 = V[ 448]; + tmp2 = V[1024]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1); + tmp1 = -V[ 256]; + tmp2 = V[ 192]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1); + realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1); + + tmp1 = V[ 32]; + tmp2 = V[1248]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2); + tmp1 = V[ 224]; + tmp2 = V[1056]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2); + tmp1 = V[ 992]; + tmp2 = V[ 288]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2); + tmp1 = V[ 480]; + tmp2 = V[ 800]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2); + tmp1 = V[ 736]; + tmp2 = V[ 544]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2); + + + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + pt_timeSig_2 = &timeSig[126]; + + pt_V1 = &V[1]; + pt_V2 = &V[1279]; + + pt_C2 = &sbrDecoderFilterbankCoefficients[0]; + + for (i = 31; i != 0; i--) + { + test1 = *(pt_C2++); + tmp1 = *(pt_V1++); + tmp2 = *(pt_V2--); + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL); + tmp1 = pt_V1[ 191]; + tmp2 = pt_V2[ -191]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 255]; + tmp2 = pt_V2[ -255]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 447]; + tmp2 = pt_V2[ -447]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 511]; + tmp2 = pt_V2[ -511]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 703]; + tmp2 = pt_V2[ -703]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 767]; + tmp2 = pt_V2[ -767]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 959]; + tmp2 = pt_V2[ -959]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 1023]; + tmp2 = pt_V2[ -1023]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 1215]; + tmp2 = pt_V2[ -1215]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + } + } + else + { + + synthesis_sub_band_LC_down_sampled(Sr, V); + + /* + * window signal + * calculate output samples + */ + + + pt_V1 = &V[0]; + pt_V2 = &V[96]; + + + Int32 * pt_out = Sr; + + for (i = 0; i < 8; i++) + { + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + } + + const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0]; + pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16]; + + for (k = 0; k < 5; k++) + { + pt_out -= 32; + for (i = 0; i < 16; i++) + { + realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1)); + realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++)); + realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2); + *(pt_out++) += realAccu1 >> 5; + *(pt_out++) += realAccu2 >> 5; + + } + pt_V1 += 96; + pt_V2 += 96; + pt_C1 += 16; + pt_C2 += 16; + } + pt_out -= 32; + + for (i = 0; i < 32; i++) + { + timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10); + } + + } + +} + + + +#ifdef HQ_SBR + +void calc_sbr_synfilterbank(Int32 * Sr, + Int32 * Si, + Int16 * timeSig, + Int16 V[1280], + Bool bDownSampleSBR) +{ + Int32 i; + Int k; + + const Int32 *pt_C2; + + Int32 realAccu1; + Int32 realAccu2; + + Int16 *pt_V1; + Int16 *pt_V2; + + Int16 *pt_timeSig; + + Int16 *pt_timeSig_2; + Int32 test1; + Int16 tmp1; + Int16 tmp2; + + + if (bDownSampleSBR == FALSE) + { + synthesis_sub_band(Sr, Si, V); + + /* content of V[] is at most 16 bits */ + pt_timeSig = &timeSig[0]; + pt_timeSig_2 = &timeSig[64]; + + tmp1 = V[ 704]; + tmp2 = V[ 768]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1); + tmp1 = -V[ 512]; + tmp2 = V[ 960]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1); + tmp1 = V[ 448]; + tmp2 = V[1024]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1); + tmp1 = -V[ 256]; + tmp2 = V[ 192]; + realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1); + realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1); + realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1); + + tmp1 = V[ 32]; + tmp2 = V[1248]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2); + tmp1 = V[ 224]; + tmp2 = V[1056]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2); + tmp1 = V[ 992]; + tmp2 = V[ 288]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2); + tmp1 = V[ 480]; + tmp2 = V[ 800]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2); + tmp1 = V[ 736]; + tmp2 = V[ 544]; + realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2); + realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2); + + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + + pt_timeSig_2 = &timeSig[126]; + + pt_V1 = &V[1]; + pt_V2 = &V[1279]; + + pt_C2 = &sbrDecoderFilterbankCoefficients[0]; + + for (i = 31; i != 0; i--) + { + test1 = *(pt_C2++); + tmp1 = *(pt_V1++); + tmp2 = *(pt_V2--); + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL); + tmp1 = pt_V1[ 191]; + tmp2 = pt_V2[ -191]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 255]; + tmp2 = pt_V2[ -255]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 447]; + tmp2 = pt_V2[ -447]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 511]; + tmp2 = pt_V2[ -511]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 703]; + tmp2 = pt_V2[ -703]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 767]; + tmp2 = pt_V2[ -767]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 959]; + tmp2 = pt_V2[ -959]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + test1 = *(pt_C2++); + tmp1 = pt_V1[ 1023]; + tmp2 = pt_V2[ -1023]; + realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2); + tmp1 = pt_V1[ 1215]; + tmp2 = pt_V2[ -1215]; + realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2); + + saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2); + } + + } + else + { + + synthesis_sub_band_down_sampled(Sr, Si, V); + + + Int32 * pt_out = Sr; + + for (i = 0; i < 8; i++) + { + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + *(pt_out++) = 0; + } + + + /* + * window signal + * calculate output samples + */ + + pt_V1 = &V[0]; + pt_V2 = &V[96]; + + + const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0]; + pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16]; + + for (k = 0; k < 5; k++) + { + pt_out -= 32; + for (i = 0; i < 16; i++) + { + realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1)); + realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++)); + realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1); + realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2); + *(pt_out++) += realAccu1 >> 5; + *(pt_out++) += realAccu2 >> 5; + } + pt_V1 += 96; + pt_V2 += 96; + pt_C1 += 16; + pt_C2 += 16; + } + pt_out -= 32; + + for (i = 0; i < 32; i++) + { + timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10); + } + + } +} + + +#endif /* --- HQ_SBR --- */ + + +#endif /* --- AAC_PLUS --- */ + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.h new file mode 100644 index 00000000..cfd26885 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/calc_sbr_synfilterbank.h @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CALC_SBR_SYNFILTERBANK_H +#define CALC_SBR_SYNFILTERBANK_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define N 14 + +#define ROUND_SYNFIL (32768 + 4096) + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + void calc_sbr_synfilterbank_LC(Int32 * Sr, + Int16 * timeSig, + Int16 V[1280], + Bool bDownSampleSBR); + +#ifdef HQ_SBR + + + void calc_sbr_synfilterbank(Int32 * Sr, + Int32 * Si, + Int16 * timeSig, + Int16 V[1280], + Bool bDownSampleSBR); + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/chans.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/chans.h new file mode 100644 index 00000000..869be3c7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/chans.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: chans.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CHANS_H +#define CHANS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + /* #define is required in order to use these args in #if () directive */ +#define ICChans 0 +#define DCChans 0 +#define XCChans 0 +#define CChans 0 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + enum + { + /* + * channels for 5.1 main profile configuration + * (modify for any desired decoder configuration) + */ + FChans = 2, /* front channels: left, center, right */ + FCenter = 0, /* 1 if decoder has front center channel */ + SChans = 0, /* side channels: */ + BChans = 0, /* back channels: left surround, right surround */ + BCenter = 0, /* 1 if decoder has back center channel */ + LChans = 0, /* LFE channels */ + XChans = 0, /* scratch space for parsing unused channels */ + + Chans = FChans + SChans + BChans + LChans + XChans + }; + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* CHANS_H */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.c new file mode 100644 index 00000000..9c5d5e4a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.c @@ -0,0 +1,137 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: check_crc.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "check_crc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void check_crc(HANDLE_CRC hCrcBuf, UInt32 bValue, Int32 nBits) +{ + Int32 i; + UInt32 bMask = (1UL << (nBits - 1)); + + for (i = 0; i < nBits; i++, bMask >>= 1) + { + UInt16 flag = (UInt16)((hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0); + UInt16 flag1 = (UInt16)((bMask & bValue) ? 1 : 0); + + flag ^= flag1; + hCrcBuf->crcState <<= 1; + if (flag) + hCrcBuf->crcState ^= hCrcBuf->crcPoly; + } + +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.h new file mode 100644 index 00000000..d4f3df42 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/check_crc.h @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: check_crc.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef CHECK_CRC_H +#define CHECK_CRC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_crc_buffer.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void check_crc(HANDLE_CRC hCrcBuf, + UInt32 bValue, + Int32 nBits); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/config.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/config.h new file mode 100644 index 00000000..cb70e2b8 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/config.h @@ -0,0 +1,72 @@ +/* SBR decoding */ +#define AAC_PLUS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_CURL_CURL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* High-Quality SBR */ +#define HQ_SBR 1 + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Parametric-Stereo decoding */ +#define PARAMETRICSTEREO 1 + +/* GCC ARM v4 */ +/* #undef PV_ARM_GCC_V4 */ + +/* GCC ARM v5 */ +/* #undef PV_ARM_GCC_V5 */ +// #define PV_ARM_GCC_V5 + +/* MSC EVC ARM v4 */ +/* #undef PV_ARM_MSC_EVC_V4 */ + +/* MSC EVC ARM v5 */ +/* #undef PV_ARM_MSC_EVC_V5 */ + +/* ARM v4 */ +/* #undef PV_ARM_V4 */ + +/* ARM v5 */ +/* #undef PV_ARM_V5 */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "1.0.0" \ No newline at end of file diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.c new file mode 100644 index 00000000..6861aeb0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.c @@ -0,0 +1,261 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: dct16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + Int32 flag 1 forward dct16, 0 modified dct-16 + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement dct of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "dct16.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dct_16(Int32 vec[], Int flag) +{ + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + Int32 tmp6; + Int32 tmp7; + Int32 tmp_o0; + Int32 tmp_o1; + Int32 tmp_o2; + Int32 tmp_o3; + Int32 tmp_o4; + Int32 tmp_o5; + Int32 tmp_o6; + Int32 tmp_o7; + Int32 itmp_e0; + Int32 itmp_e1; + Int32 itmp_e2; + + /* split input vector */ + + + tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F)); + tmp0 = vec[ 0] + vec[15]; + + tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F)); + tmp7 = vec[ 7] + vec[ 8]; + + itmp_e0 = (tmp0 + tmp7); + tmp7 = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F)); + + tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F)); + tmp1 = vec[ 1] + vec[14]; + tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F)); + tmp6 = vec[ 6] + vec[ 9]; + + itmp_e1 = (tmp1 + tmp6); + tmp6 = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F)); + + tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F)); + tmp2 = vec[ 2] + vec[13]; + tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F)); + tmp5 = vec[ 5] + vec[10]; + + itmp_e2 = (tmp2 + tmp5); + tmp5 = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F)); + + tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F)); + tmp3 = vec[ 3] + vec[12]; + tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F)); + tmp4 = vec[ 4] + vec[11]; + + tmp1 = (tmp3 + tmp4); + tmp4 = fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F)); + + /* split even part of tmp_e */ + + tmp0 = (itmp_e0 + tmp1); + tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F)); + + + tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F)); + tmp2 = (itmp_e1 + itmp_e2); + + vec[ 0] = (tmp0 + tmp2) >> 1; + vec[ 8] = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F)); + vec[12] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F)); + vec[ 4] = tmp1 + tmp3; + vec[ 4] += vec[12]; + + /* split odd part of tmp_e */ + + tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F)); + tmp7 += tmp4; + tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + + tmp6 += tmp5; + + vec[10] = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F)); + vec[ 2] = tmp7 + tmp6; + vec[14] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F)); + + tmp1 += tmp3 + vec[14]; + vec[ 2] += tmp1; + vec[ 6] = tmp1 + vec[10]; + + vec[10] += vec[14]; + + + // dct8; + + tmp7 = tmp_o0 + tmp_o7; + tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F)); + + tmp6 = tmp_o1 + tmp_o6; + tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F)); + + tmp5 = tmp_o2 + tmp_o5; + tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F)); + + tmp4 = tmp_o3 + tmp_o4; + + tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F)); + + if (!flag) + { + tmp7 = -tmp7; + tmp_o7 = -tmp_o7; + tmp6 = -tmp6; + tmp_o1 = -tmp_o1; + tmp5 = -tmp5; + tmp_o5 = -tmp_o5; + tmp4 = -tmp4; + tmp_o3 = -tmp_o3; + } + + // even part + + tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F)); + tmp0 = tmp7 + tmp4; + tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F)); + tmp2 = tmp6 + tmp5; + + vec[ 9] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F)); + vec[ 1] = tmp0 + tmp2; + vec[13] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + + vec[ 5] = tmp1 + tmp3 + vec[13]; + + // odd part + + tmp0 = tmp_o7 + tmp_o3; + tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F)); + tmp2 = tmp_o1 + tmp_o5; + tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F)); + + vec[11] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F)); + vec[ 3] = tmp0 + tmp2; + vec[15] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F)); + vec[ 7] = tmp1 + tmp3 + vec[15]; + + + vec[ 3] += vec[ 7]; + vec[ 7] += vec[11]; + vec[11] += vec[15]; + + vec[ 1] += vec[ 3]; + vec[ 3] += vec[ 5]; + vec[ 5] += vec[ 7]; + vec[ 7] += vec[ 9]; + vec[ 9] += vec[11]; + vec[11] += vec[13]; + vec[13] += vec[15]; + + +} + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.h new file mode 100644 index 00000000..1442c71d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct16.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DCT16_H +#define DCT16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dct_16(Int32 vec[], Int flag); + + +#ifdef __cplusplus +} +#endif + +#endif /* DCT16_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.c new file mode 100644 index 00000000..d0fea54f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.c @@ -0,0 +1,564 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct64.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 64 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement dct of lenght 64 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "dct16.h" +#include "dct64.h" + +#include "pv_audio_type_defs.h" +#include "synthesis_sub_band.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt(a) (Int32)(a*((Int32)1<<26) + (a>=0?0.5F:-0.5F)) +#define Qfmt31(a) (Int32)(a*0x7FFFFFFF) + +const Int32 CosTable_48[48] = +{ + Qfmt31(0.50015063602065F) , Qfmt31(0.50135845244641F) , + Qfmt31(0.50378872568104F) , Qfmt31(0.50747117207256F) , + Qfmt31(0.51245147940822F) , Qfmt31(0.51879271310533F) , + Qfmt31(0.52657731515427F) , Qfmt31(0.53590981690799F) , + Qfmt31(0.54692043798551F) , Qfmt31(0.55976981294708F) , + Qfmt31(0.57465518403266F) , Qfmt31(0.59181853585742F) , + Qfmt31(0.61155734788251F) , Qfmt31(0.63423893668840F) , + Qfmt31(0.66031980781371F) , Qfmt31(0.69037212820021F) , + Qfmt31(0.72512052237720F) , Qfmt31(0.76549416497309F) , + Qfmt31(0.81270209081449F) , Qfmt31(0.86834471522335F) , + Qfmt(0.93458359703641F) , Qfmt(1.01440826499705F) , + Qfmt(1.11207162057972F) , Qfmt(1.23383273797657F) , + Qfmt(1.38929395863283F) , Qfmt(1.59397228338563F) , + Qfmt(1.87467598000841F) , Qfmt(2.28205006800516F) , + Qfmt(2.92462842815822F) , Qfmt(4.08461107812925F) , + Qfmt(6.79675071167363F) , Qfmt(20.37387816723145F) , /* 32 */ + Qfmt(0.50060299823520F) , Qfmt(0.50547095989754F) , + Qfmt(0.51544730992262F) , Qfmt(0.53104259108978F) , + Qfmt(0.55310389603444F) , Qfmt(0.58293496820613F) , + Qfmt(0.62250412303566F) , Qfmt(0.67480834145501F) , + Qfmt(0.74453627100230F) , Qfmt(0.83934964541553F) , + Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) , + Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) , + Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F) +}; + + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; dct_64 +----------------------------------------------------------------------------*/ + +void pv_split_LC(Int32 *vector, + Int32 *temp_o) +{ + + Int32 i; + Int32 *pt_vector = &vector[0]; + Int32 *pt_vector_N_1 = &vector[31]; + const Int32 *pt_cosTerms = &CosTable_48[32]; + Int32 *pt_temp_o = temp_o; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + + + tmp1 = *(pt_vector); + tmp2 = *(pt_vector_N_1--); + for (i = 16; i != 0; i--) + { + tmp3 = *(pt_cosTerms++); + *(pt_vector++) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), tmp3); + tmp1 = *(pt_vector); + tmp2 = *(pt_vector_N_1--); + } + +} + + +#ifdef HQ_SBR + + +void dct_64(Int32 vec[], Int32 *scratch_mem) +{ + Int32 *temp_e1; + Int32 *temp_o1; + + Int32 *pt_vec; + + Int i; + + Int32 aux1; + Int32 aux2; + Int32 aux3; + Int32 aux4; + + const Int32 *cosTerms = &CosTable_48[31]; + + temp_o1 = &vec[32]; + temp_e1 = temp_o1 - 1; + + + for (i = 6; i != 0; i--) + { + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3); + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3); + } + + + for (i = 10; i != 0; i--) + { + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1; + aux1 = *(temp_e1); + aux2 = *(temp_o1); + aux3 = *(cosTerms--); + *(temp_e1--) = aux1 + aux2; + *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1; + } + + + pv_split(&vec[16]); + + dct_16(&vec[16], 0); + dct_16(vec, 1); // Even terms + + pv_merge_in_place_N32(vec); + + pv_split_z(&vec[32]); + + dct_16(&vec[32], 1); // Even terms + dct_16(&vec[48], 0); + + pv_merge_in_place_N32(&vec[32]); + + + + aux1 = vec[32]; + aux3 = vec[33]; + aux4 = vec[ 1]; /* vec[ 1] */ + + /* -----------------------------------*/ + aux1 = vec[32] + vec[33]; + vec[ 0] += aux1; + vec[ 1] += aux1; + + aux1 = vec[34]; + aux2 = vec[ 2]; /* vec[ 2] */ + aux3 += aux1; + vec[ 2] = aux4 + aux3; + aux4 = vec[ 3]; /* vec[ 3] */ + vec[ 3] = aux2 + aux3; + + aux3 = vec[35]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = vec[ 4]; + vec[33] = vec[ 5]; + vec[ 4] = aux2 + aux1; + vec[ 5] = aux4 + aux1; + + aux1 = vec[36]; + aux2 = vec[32]; /* vec[ 4] */ + aux3 += aux1; + vec[34] = vec[ 6]; + vec[35] = vec[ 7]; + vec[ 6] = aux4 + aux3; + vec[ 7] = aux2 + aux3; + + aux3 = vec[37]; + aux4 = vec[33]; /* vec[ 5] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = vec[ 8]; + vec[33] = vec[ 9]; + vec[ 8] = aux2 + aux1; + vec[ 9] = aux4 + aux1; + + aux1 = vec[38]; + aux2 = vec[34]; /* vec[ 6] */ + aux3 += aux1; + vec[34] = vec[10]; + vec[10] = aux4 + aux3; + aux4 = vec[35]; /* vec[ 7] */ + vec[35] = vec[11]; + vec[11] = aux2 + aux3; + + aux3 = vec[39]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[36] = vec[12]; + vec[37] = vec[13]; + vec[12] = aux2 + aux1; + vec[13] = aux4 + aux1; + + aux1 = vec[40]; + aux2 = vec[32]; /* vec[ 8] */ + aux3 += aux1; + vec[32] = vec[14]; + vec[14] = aux4 + aux3; + aux4 = vec[33]; /* vec[ 9] */ + vec[33] = vec[15]; + vec[15] = aux2 + aux3; + + aux3 = vec[41]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[38] = vec[16]; + vec[39] = vec[17]; + vec[16] = aux2 + aux1; + vec[17] = aux4 + aux1; + + aux1 = vec[42]; + aux2 = vec[34]; /* vec[10] */ + aux3 += aux1; + vec[34] = vec[18]; + vec[18] = aux4 + aux3; + aux4 = vec[35]; /* vec[11] */ + vec[35] = vec[19]; + vec[19] = aux2 + aux3; + + aux3 = vec[43]; + + /* -----------------------------------*/ + aux1 += aux3; + vec[40] = vec[20]; + vec[41] = vec[21]; + vec[20] = aux2 + aux1; + vec[21] = aux4 + aux1; + + aux1 = vec[44]; + aux2 = vec[36]; /* vec[12] */ + aux3 += aux1; + vec[42] = vec[22]; + vec[43] = vec[23]; + vec[22] = aux4 + aux3; + vec[23] = aux2 + aux3; + + aux3 = vec[45]; + aux4 = vec[37]; /* vec[13] */ + + /* -----------------------------------*/ + + + scratch_mem[0] = vec[24]; + scratch_mem[1] = vec[25]; + aux1 += aux3; + vec[24] = aux2 + aux1; + vec[25] = aux4 + aux1; + + aux1 = vec[46]; + aux2 = vec[32]; /* vec[14] */ + scratch_mem[2] = vec[26]; + scratch_mem[3] = vec[27]; + aux3 += aux1; + vec[26] = aux4 + aux3; + vec[27] = aux2 + aux3; + + aux3 = vec[47]; + aux4 = vec[33]; /* vec[15] */ + + /* -----------------------------------*/ + scratch_mem[4] = vec[28]; + scratch_mem[5] = vec[29]; + aux1 += aux3; + vec[28] = aux2 + aux1; + vec[29] = aux4 + aux1; + + aux1 = vec[48]; + aux2 = vec[38]; /* vec[16] */ + scratch_mem[6] = vec[30]; + scratch_mem[7] = vec[31]; + aux3 += aux1; + vec[30] = aux4 + aux3; + vec[31] = aux2 + aux3; + + aux3 = vec[49]; + aux4 = vec[39]; /* vec[17] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[32] = aux2 + aux1; + vec[33] = aux4 + aux1; + + aux1 = vec[50]; + aux2 = vec[34]; /* vec[18] */ + aux3 += aux1; + vec[34] = aux4 + aux3; + aux4 = vec[35]; /* vec[19] */ + vec[35] = aux2 + aux3; + + aux3 = vec[51]; + + + /* -----------------------------------*/ + aux1 += aux3; + vec[36] = aux2 + aux1; + vec[37] = aux4 + aux1; + + aux1 = vec[52]; + aux2 = vec[40]; /* vec[20] */ + aux3 += aux1; + vec[38] = aux4 + aux3; + vec[39] = aux2 + aux3; + + aux3 = vec[53]; + aux4 = vec[41]; /* vec[21] */ + + /* -----------------------------------*/ + aux1 += aux3; + vec[40] = aux2 + aux1; + vec[41] = aux4 + aux1; + + aux1 = vec[54]; + aux2 = vec[42]; /* vec[22] */ + aux3 += aux1; + vec[42] = aux4 + aux3; + aux4 = vec[43]; /* vec[23] */ + vec[43] = aux2 + aux3; + + aux3 = vec[55]; + + /* -----------------------------------*/ + + pt_vec = &vec[44]; + temp_o1 = &vec[56]; + temp_e1 = &scratch_mem[0]; + + for (i = 4; i != 0; i--) + { + aux1 += aux3; + *(pt_vec++) = aux2 + aux1; + *(pt_vec++) = aux4 + aux1; + + aux1 = *(temp_o1++); + aux3 += aux1; + aux2 = *(temp_e1++); + *(pt_vec++) = aux4 + aux3; + *(pt_vec++) = aux2 + aux3; + + aux3 = *(temp_o1++); + aux4 = *(temp_e1++); + } + + aux1 += aux3; + vec[60] = aux2 + aux1; + vec[61] = aux4 + aux1; + vec[62] = aux4 + aux3; + +} + + +#endif + +/*---------------------------------------------------------------------------- +; pv_split +----------------------------------------------------------------------------*/ + + +void pv_split(Int32 *temp_o) +{ + + Int32 i; + const Int32 *pt_cosTerms = &CosTable_48[47]; + Int32 *pt_temp_o = temp_o; + Int32 *pt_temp_e = pt_temp_o - 1; + Int32 tmp1; + Int32 tmp2; + Int32 cosx; + + for (i = 8; i != 0; i--) + { + tmp2 = *(pt_temp_o); + tmp1 = *(pt_temp_e); + cosx = *(pt_cosTerms--); + *(pt_temp_e--) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + tmp1 = *(pt_temp_e); + tmp2 = *(pt_temp_o); + cosx = *(pt_cosTerms--); + *(pt_temp_e--) = tmp1 + tmp2; + *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + } +} + + + +void pv_split_z(Int32 *vector) +{ + Int32 i; + Int32 *pt_vector = &vector[31]; + const Int32 *pt_cosTerms = &CosTable_48[32]; + Int32 *pt_temp_e = vector; + Int32 tmp1; + Int32 tmp2; + Int32 cosx; + + for (i = 8; i != 0; i--) + { + tmp1 = *(pt_vector); + tmp2 = *(pt_temp_e); + cosx = *(pt_cosTerms++); + *(pt_temp_e++) = tmp1 + tmp2; + *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + tmp2 = *(pt_temp_e); + tmp1 = *(pt_vector); + cosx = *(pt_cosTerms++); + *(pt_temp_e++) = tmp1 + tmp2; + *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx); + } +} + + +void pv_merge_in_place_N32(Int32 vec[]) +{ + + Int32 temp[4]; + + temp[0] = vec[14]; + vec[14] = vec[ 7]; + temp[1] = vec[12]; + vec[12] = vec[ 6]; + temp[2] = vec[10]; + vec[10] = vec[ 5]; + temp[3] = vec[ 8]; + vec[ 8] = vec[ 4]; + vec[ 6] = vec[ 3]; + vec[ 4] = vec[ 2]; + vec[ 2] = vec[ 1]; + + vec[ 1] = vec[16] + vec[17]; + vec[16] = temp[3]; + vec[ 3] = vec[18] + vec[17]; + vec[ 5] = vec[19] + vec[18]; + vec[18] = vec[9]; + temp[3] = vec[11]; + + vec[ 7] = vec[20] + vec[19]; + vec[ 9] = vec[21] + vec[20]; + vec[20] = temp[2]; + temp[2] = vec[13]; + vec[11] = vec[22] + vec[21]; + vec[13] = vec[23] + vec[22]; + vec[22] = temp[3]; + temp[3] = vec[15]; + vec[15] = vec[24] + vec[23]; + vec[17] = vec[25] + vec[24]; + vec[19] = vec[26] + vec[25]; + vec[21] = vec[27] + vec[26]; + vec[23] = vec[28] + vec[27]; + vec[25] = vec[29] + vec[28]; + vec[27] = vec[30] + vec[29]; + vec[29] = vec[30] + vec[31]; + vec[24] = temp[1]; + vec[26] = temp[2]; + vec[28] = temp[0]; + vec[30] = temp[3]; +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.h new file mode 100644 index 00000000..d230bad5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dct64.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dct64.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DCT64_H +#define DCT64_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + extern const Int32 CosTable_48[48]; + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void pv_split_LC(Int32 *vector, + Int32 *temp_o); + + +#ifdef HQ_SBR + + void dct_64(Int32 vec[], Int32 *scratch_mem); + +#endif + + void pv_split(Int32 *temp_o); + + void pv_split_z(Int32 *vector); + + void pv_merge_in_place_N32(Int32 vec[]); + +#ifdef __cplusplus +} +#endif + +#endif /* DCT64_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_huff_cw_binary.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_huff_cw_binary.c new file mode 100644 index 00000000..79859b03 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_huff_cw_binary.c @@ -0,0 +1,673 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_huff_cw_binary.cpp + Funtions: + decode_huff_cw_tab1 + decode_huff_cw_tab2 + decode_huff_cw_tab3 + decode_huff_cw_tab4 + decode_huff_cw_tab5 + decode_huff_cw_tab6 + decode_huff_cw_tab7 + decode_huff_cw_tab8 + decode_huff_cw_tab9 + decode_huff_cw_tab10 + decode_huff_cw_tab11 + decode_huff_cw_scl + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + BITS *pInputStream = pointer to input bit stream + + Local Stores/Buffers/Pointers Needed: + + + Global Stores/Buffers/Pointers Needed: + + + Outputs: + idx = bit field extracted from a leaf entry of packed Huffman Tables + + Pointers and Buffers Modified: + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + These functions are used to decode huffman codewords from the input + bitstream using combined binary search and look-up table approach. + + First the codewords are grouped and the input symbol is determined + which group it belongs. Then within that group, a look-up table is + used to determine which codeword the symbol is. + The table is created by ordering the codeword in the table according to their + normalized shifted binary value, i.e., all the codewords are left + shifted to meet the maximum codelength. Example, max codelength is + 10, the codeword with lenth 3 will left shift by 7. + The binary values of after the shift are sorted. + Then the sorted table is divided into several partition. + At the VLC decoding period, input is read in at max codelenght. + The partition is decided using if-else logic. + Inside each partition, a look-up table is used to map the input value + to a correct symbol. Table entries can appear to be repeated according + to the humming distance between adjacent codewords. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) Introduction to Algorithms, + Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest. + The MIT press, 1990 + + (3) "Selecting an Optimal Huffman Decoder for AAC", + Vladimir Z. Mesarovic, et al. + AES 111th Convention, September 21-24, 2001, New York, USA + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define MAX_CW_LEN (19) +#define MASK_IDX (0x1FF) +#define MASK_RIGHT (0xFE00) + +#define UPPER16 (16) +#define MASK_LOW16 (0xFFFF) +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int decode_huff_cw_tab1( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 11, + pInputStream); + if ((cw >> 10) == 0) + { + pInputStream->usedBits -= (11 - 1); + return 40; /* idx is 40 */ + } + else if ((cw >> 6) <= 23) + { + tab = (cw >> 6) - 16; + } + else if ((cw >> 4) <= 119) + { + tab = (cw >> 4) - 96 + 8; + } + else if ((cw >> 2) <= 503) + { + tab = (cw >> 2) - 480 + 32; + } + else + { + tab = cw - 2016 + 56; + } + + tab = *(huff_tab1 + tab); + + pInputStream->usedBits -= (11 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab2( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get9_n_lessbits( + 9, + pInputStream); + if ((cw >> 6) == 0) + { + pInputStream->usedBits -= (9 - 3); /* used 3 bits */ + return 40; /* idx is 40 */ + } + else if ((cw >> 3) <= 49) + { + tab = (cw >> 3) - 8; + } + else if ((cw >> 2) <= 114) + { + tab = (cw >> 2) - 100 + 42; + } + else if ((cw >> 1) <= 248) + { + tab = (cw >> 1) - 230 + 57; + } + else + { + tab = cw - 498 + 76; + } + + tab = *(huff_tab2 + tab); + + pInputStream->usedBits -= (9 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab3( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 16, + pInputStream); + if ((cw >> 15) == 0) + { + pInputStream->usedBits -= (16 - 1); /* used 1 bits */ + return 0; /* idx is 0 */ + } + else if ((cw >> 10) <= 57) + { + tab = (cw >> 10) - 32; + } + else if ((cw >> 7) <= 500) + { + tab = (cw >> 7) - 464 + 26; + } + else if ((cw >> 6) <= 1016) + { + tab = (cw >> 6) - 1002 + 63; + } + else if ((cw >> 4) <= 4092) + { + tab = (cw >> 4) - 4068 + 78; + } + else + { + tab = cw - 65488 + 103; + } + + tab = *(huff_tab3 + tab); + + pInputStream->usedBits -= (16 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab4( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 7) <= 25) + { + tab = (cw >> 7); + } + else if ((cw >> 4) <= 246) + { + tab = (cw >> 4) - 208 + 26; + } + else if ((cw >> 2) <= 1017) + { + tab = (cw >> 2) - 988 + 65; + } + else + { + tab = cw - 4072 + 95; + } + + tab = *(huff_tab4 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab5( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 13, + pInputStream); + + if ((cw >> 12) == 0) + { + pInputStream->usedBits -= (13 - 1); /* used 1 bits */ + return 40; /* idx is 40 */ + } + else if ((cw >> 8) <= 27) + { + tab = (cw >> 8) - 16; + } + else if ((cw >> 5) <= 243) + { + tab = (cw >> 5) - 224 + 12; + } + else if ((cw >> 3) <= 1011) + { + tab = (cw >> 3) - 976 + 32; + } + else if ((cw >> 2) <= 2041) + { + tab = (cw >> 2) - 2024 + 68; + } + else + { + tab = cw - 8168 + 86; + } + + tab = *(huff_tab5 + tab); + + pInputStream->usedBits -= (13 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab6( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 11, + pInputStream); + + if ((cw >> 7) <= 8) + { + tab = (cw >> 7); + } + else if ((cw >> 4) <= 116) + { + tab = (cw >> 4) - 72 + 9; + } + else if ((cw >> 2) <= 506) + { + tab = (cw >> 2) - 468 + 54; + } + else + { + tab = cw - 2028 + 93; + } + + tab = *(huff_tab6 + tab); + + pInputStream->usedBits -= (11 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab7( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 11) == 0) + { + pInputStream->usedBits -= (12 - 1); /* used 1 bits */ + return 0; /* idx is 0 */ + } + else if ((cw >> 6) <= 55) + { + tab = (cw >> 6) - 32; + } + else if ((cw >> 4) <= 243) + { + tab = (cw >> 4) - 224 + 24; + } + else if ((cw >> 2) <= 1018) + { + tab = (cw >> 2) - 976 + 44; + } + else + { + tab = cw - 4076 + 87; + } + + tab = *(huff_tab7 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + + +Int decode_huff_cw_tab8( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 10, + pInputStream); + + if ((cw >> 5) <= 20) + { + tab = (cw >> 5); + } + else if ((cw >> 3) <= 117) + { + tab = (cw >> 3) - 84 + 21; + } + else if ((cw >> 2) <= 250) + { + tab = (cw >> 2) - 236 + 55; + } + else + { + tab = cw - 1004 + 70; + } + + tab = *(huff_tab8 + tab); + + pInputStream->usedBits -= (10 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab9( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 15, + pInputStream); + + if ((cw >> 11) <= 12) + { + tab = (cw >> 11); + } + else if ((cw >> 8) <= 114) + { + tab = (cw >> 8) - 104 + 13; + } + else if ((cw >> 6) <= 486) + { + tab = (cw >> 6) - 460 + 24; + } + else if ((cw >> 5) <= 993) + { + tab = (cw >> 5) - 974 + 51; + } + else if ((cw >> 4) <= 2018) + { + tab = (cw >> 4) - 1988 + 71; + } + else if ((cw >> 3) <= 4075) + { + tab = (cw >> 3) - 4038 + 102; + } + else if ((cw >> 2) <= 8183) + { + tab = (cw >> 2) - 8152 + 140; + } + else + { + tab = cw - 32736 + 172; + } + + tab = *(huff_tab9 + tab); + + pInputStream->usedBits -= (15 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab10( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 6) <= 41) + { + tab = (cw >> 6); + } + else if ((cw >> 5) <= 100) + { + tab = (cw >> 5) - 84 + 42; + } + else if ((cw >> 4) <= 226) + { + tab = (cw >> 4) - 202 + 59; + } + else if ((cw >> 3) <= 484) + { + tab = (cw >> 3) - 454 + 84; + } + else if ((cw >> 2) <= 1010) + { + tab = (cw >> 2) - 970 + 115; + } + else if ((cw >> 1) <= 2043) + { + tab = (cw >> 1) - 2022 + 156; + } + else + { + tab = cw - 4088 + 178; + } + + tab = *(huff_tab10 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_cw_tab11( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = get17_n_lessbits( + 12, + pInputStream); + + if ((cw >> 6) <= 26) + { + tab = (cw >> 6); + } + else if ((cw >> 5) <= 69) + { + tab = (cw >> 5) - 54 + 27; + } + else if ((cw >> 4) <= 198) + { + tab = (cw >> 4) - 140 + 43; + } + else if ((cw >> 3) <= 452) + { + tab = (cw >> 3) - 398 + 102; + } + else if ((cw >> 2) <= 1000) + { + tab = (cw >> 2) - 906 + 157; + } + else if ((cw >> 1) <= 2044) + { + tab = (cw >> 1) - 2002 + 252; + } + else + { + tab = cw - 4090 + 295; + } + + tab = *(huff_tab11 + tab); + + pInputStream->usedBits -= (12 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + + +Int decode_huff_scl( + BITS *pInputStream) +{ + Int32 tab; + Int32 cw; + + cw = getbits( + 19, + pInputStream); + + if ((cw >> 18) == 0) + { + pInputStream->usedBits -= (19 - 1); /* used 1 bits */ + return 60; /* idx is 60 */ + } + else if ((cw >> 13) <= 59) + { + tab = (cw >> 13) - 32; + } + else if ((cw >> 10) <= 505) + { + tab = (cw >> 10) - 480 + 28; + } + else if ((cw >> 7) <= 4089) + { + tab = (cw >> 7) - 4048 + 54; + } + else if ((cw >> 5) <= 16377) + { + tab = (cw >> 5) - 16360 + 96; + } + else if ((cw >> 3) <= 65526) + { + tab = (cw >> 3) - 65512 + 114; + } + else if ((cw >> 1) <= 262120) + { + tab = (cw >> 1) - 262108 + 129; + } + else + { + tab = cw - 524242 + 142; + } + + tab = *(huff_tab_scl + tab); + + pInputStream->usedBits -= (19 - (tab & MASK_LOW16)); + return ((Int)(tab >> UPPER16)); +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.c new file mode 100644 index 00000000..06652e5b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.c @@ -0,0 +1,158 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_noise_floorlevels.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#include "config.h" + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "decode_noise_floorlevels.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData) + +{ + Int32 env; + Int32 i; + + Int32 * frameInfo = hFrameData->frameInfo; + Int32 nNfb = hFrameData->nNfb; + Int32 * domain_vec = hFrameData->domain_vec2; + + Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man; + Int32 * prevNoiseLevel_man = hFrameData->prevNoiseLevel_man; + + Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3]; + + for (env = 0; env < nEnv; env++) + { + if (domain_vec[env] == 0) + { + prevNoiseLevel_man[0] = *(sbrNoiseFloorLevel_man++); + + for (i = 1; i < nNfb; i++) + { + *sbrNoiseFloorLevel_man += *(sbrNoiseFloorLevel_man - 1); + prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++); + } + } + else + { + for (i = 0; i < nNfb; i++) + { + *sbrNoiseFloorLevel_man += prevNoiseLevel_man[i]; + prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++); + } + } + + } +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.h new file mode 100644 index 00000000..05a1c575 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/decode_noise_floorlevels.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: decode_noise_floorlevels.h + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef DECODENOISEFLOORLEVELS_H +#define DECODENOISEFLOORLEVELS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/deinterleave.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/deinterleave.c new file mode 100644 index 00000000..7e7bcca9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/deinterleave.c @@ -0,0 +1,250 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: deinterleave.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + interleaved = input array that contains interleaved coefficients + Data Type Int + + deinterleaved = output array that will be updated with de-interleaved + coefficients of input array. Data Type Int + + pFrameInfo = pointer to structure that holds information of current + frame. Data Type FrameInfo + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + deinterleaved contents updated with de-interleaved coefficients from + the input array: interleaved + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs the deinterleaving across all short windows in + each group + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the contents of pDeinterleaved with the + de-interleaved 1024 coefficients of one frame + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p78 quant_to_spec + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pInterleaved = interleaved; + pDeinterleaved = deinterleaved; + + pSfbPerWin = pFrameInfo->sfb_per_win; + ngroups = pFrameInfo->num_groups; + pGroupLen = pFrameInfo->group_len; + + pGroup = pDeinterleaved; + + FOR (group = ngroups; group > 0; group--) + + pSfbWidth = pFrameInfo->sfb_width_128; + sfb_inc = 0; + pStart = pInterleaved; + + FOR (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--) + + pWin = pGroup; + + FOR (win = pGroupLen[ngroups-group]; win > 0; win--) + + pDeinterleaved = pWin + sfb_inc; + + pv_memcpy( + pDeinterleaved, + pInterleaved, + *pSfbWidth*sizeof(*pInterleaved)); + + pInterleaved += *pSfbWidth; + + pWin += SN2; + + ENDFOR (win) + + sfb_inc += *pSfbWidth++; + + ENDFOR (sfb) + + pGroup += (pInterleaved - pStart); + + ENDFOR (group) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void deinterleave( + Int16 interleaved[], + Int16 deinterleaved[], + FrameInfo *pFrameInfo) +{ + + Int group; /* group index */ + Int sfb; /* scalefactor band index */ + Int win; /* window index */ + Int16 *pGroup; + Int16 *pWin; + Int16 *pStart; + Int16 *pInterleaved; + Int16 *pDeinterleaved; + Int sfb_inc; + + Int ngroups; + Int *pGroupLen; + Int *pSfbPerWin; + Int *pSfbWidth; + + pInterleaved = interleaved; + pDeinterleaved = deinterleaved; + + pSfbPerWin = pFrameInfo->sfb_per_win; + ngroups = pFrameInfo->num_groups; + pGroupLen = pFrameInfo->group_len; + + pGroup = pDeinterleaved; + + for (group = ngroups; group > 0; group--) + { + pSfbWidth = pFrameInfo->sfb_width_128; + sfb_inc = 0; + pStart = pInterleaved; + + /* Perform the deinterleaving across all windows in a group */ + + for (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--) + { + pWin = pGroup; + + for (win = pGroupLen[ngroups-group]; win > 0; win--) + { + pDeinterleaved = pWin + sfb_inc; + + pv_memcpy( + pDeinterleaved, + pInterleaved, + *pSfbWidth*sizeof(*pInterleaved)); + + pInterleaved += *pSfbWidth; + + pWin += SN2; + + } /* for (win) */ + + sfb_inc += *pSfbWidth++; + + } /* for (sfb) */ + + pGroup += (pInterleaved - pStart); + + } /* for (group) */ + +} /* deinterleave */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.c new file mode 100644 index 00000000..0669328f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.c @@ -0,0 +1,274 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: digit_reversal_tables.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Tables for digit reverse operation + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/* +------------------------------------------------------------------------------ + Digit Reverse tables +------------------------------------------------------------------------------ +*/ + +const Int16 digit_reverse_64[ 64] = +{ + + 0, + 32, + 64, + 96, + + 8, + 40, + 72, + 104, + + 16, + 48, + 80, + 112, + + 24, + 56, + 88, + 120, + + 2, + 34, + 66, + 98, + + 10, + 42, + 74, + 106, + + 18, + 50, + 82, + 114, + + 26, + 58, + 90, + 122, + + 4, + 36, + 68, + 100, + + 12, + 44, + 76, + 108, + + 20, + 52, + 84, + 116, + + 28, + 60, + 92, + 124, + + 6, + 38, + 70, + 102, + + 14, + 46, + 78, + 110, + + 22, + 54, + 86, + 118, + + 30, + 62, + 94, + 126 +}; + + +const Int16 digit_reverse_256[ 256] = +{ + + 0, + 128, + 256, + 384, + + 32, + 160, + 288, + 416, + + 64, + 192, + 320, + 448, + + 96, + 224, + 352, + 480, + + 8, + 136, + 264, + 392, + + 40, + 168, + 296, + 424, + + 72, + 200, + 328, + 456, + + 104, + 232, + 360, + 488, + + 16, + 144, + 272, + 400, + + 48, + 176, + 304, + 432, + + 80, + 208, + 336, + 464, + + 112, + 240, + 368, + 496, + + 24, + 152, + 280, + 408, + + 56, + 184, + 312, + 440, + + 88, + 216, + 344, + 472, + + 120, + 248, + 376, + 504, + + 2, + 130, + 258, + 386, + + 34, + 162, + 290, + 418, + + 66, + 194, + 322, + 450, + + 98, + 226, + 354, + 482, + + 10, + 138, + 266, + 394, + + 42, + 170, + 298, + 426, + + 74, + 202, + 330, + 458, + + 106, + 234, + 362, + 490, + + 18, + 146, + 274, + 402, + + 50, + 178, + 306, + 434, + + 82, + 210, + 338, + 466, + + 114, + 242, + 370, + 498, + + 26, + 154, + 282, + 410, + + 58, + 186, + 314, + 442, + + 90, + 218, + 346, + 474, + + 122, + 250, + 378, + 506, + + 4, + 132, + 260, + 388, + + 36, + 164, + 292, + 420, + + 68, + 196, + 324, + 452, + + 100, + 228, + 356, + 484, + + 12, + 140, + 268, + 396, + + 44, + 172, + 300, + 428, + + 76, + 204, + 332, + 460, + + 108, + 236, + 364, + 492, + + 20, + 148, + 276, + 404, + + 52, + 180, + 308, + 436, + + 84, + 212, + 340, + 468, + + 116, + 244, + 372, + 500, + + 28, + 156, + 284, + 412, + + 60, + 188, + 316, + 444, + + 92, + 220, + 348, + 476, + + 124, + 252, + 380, + 508, + + 6, + 134, + 262, + 390, + + 38, + 166, + 294, + 422, + + 70, + 198, + 326, + 454, + + 102, + 230, + 358, + 486, + + 14, + 142, + 270, + 398, + + 46, + 174, + 302, + 430, + + 78, + 206, + 334, + 462, + + 110, + 238, + 366, + 494, + + 22, + 150, + 278, + 406, + + 54, + 182, + 310, + 438, + + 86, + 214, + 342, + 470, + + 118, + 246, + 374, + 502, + + 30, + 158, + 286, + 414, + + 62, + 190, + 318, + 446, + + 94, + 222, + 350, + 478, + + 126, + 254, + 382, + 510 +}; + + + + +const Int16 digit_reverse_swap_256[ 241] = +{ + + 2, + 128, + 4, + 256, + + 6, + 384, + 8, + 32, + + 10, + 160, + 12, + 288, + + 14, + 416, + 16, + 64, + + 18, + 192, + 20, + 320, + + 22, + 448, + 24, + 96, + + 26, + 224, + 28, + 352, + + 30, + 480, + 34, + 136, + + 36, + 264, + 38, + 392, + + 42, + 168, + 44, + 296, + + 46, + 424, + 48, + 72, + + 50, + 200, + 52, + 328, + + 54, + 456, + 56, + 104, + + 58, + 232, + 60, + 360, + + 62, + 488, + 66, + 144, + + 68, + 272, + 70, + 400, + + 74, + 176, + 76, + 304, + + 78, + 432, + 82, + 208, + + 84, + 336, + 86, + 464, + + 88, + 112, + 90, + 240, + + 92, + 368, + 94, + 496, + + 98, + 152, + 100, + 280, + + 102, + 408, + 106, + 184, + + 108, + 312, + 110, + 440, + + 114, + 216, + 116, + 344, + + 118, + 472, + 122, + 248, + + 124, + 376, + 126, + 504, + + 132, + 258, + 134, + 386, + + 138, + 162, + 140, + 290, + + 142, + 418, + 146, + 194, + + 148, + 322, + 150, + 450, + + 154, + 226, + 156, + 354, + + 158, + 482, + 164, + 266, + + 166, + 394, + 172, + 298, + + 174, + 426, + 178, + 202, + + 180, + 330, + 182, + 458, + + 186, + 234, + 188, + 362, + + 190, + 490, + 196, + 274, + + 198, + 402, + 204, + 306, + + 206, + 434, + 212, + 338, + + 214, + 466, + 218, + 242, + + 220, + 370, + 222, + 498, + + 228, + 282, + 230, + 410, + + 236, + 314, + 238, + 442, + + 244, + 346, + 246, + 474, + + 252, + 378, + 254, + 506, + + 262, + 388, + 268, + 292, + + 270, + 420, + 276, + 324, + + 278, + 452, + 284, + 356, + + 286, + 484, + 294, + 396, + + 302, + 428, + 308, + 332, + + 310, + 460, + 316, + 364, + + 318, + 492, + 326, + 404, + + 334, + 436, + 342, + 468, + + 348, + 372, + 350, + 500, + + 358, + 412, + 366, + 444, + + 374, + 476, + 382, + 508, + + 398, + 422, + 406, + 454, + + 414, + 486, + 438, + 462, + + 446, + 494, + 478, + 502 +}; + + +#ifdef __cplusplus +extern "C" +{ +#endif + + void digit_reversal_swapping(Int32 *y, Int32 *x); + +#ifdef __cplusplus +} +#endif + +void digit_reversal_swapping(Int32 *y, Int32 *x) +{ + Int16 i, j; + Int32 tmp[2]; + const Int16 *pTable; + Int k; + + pTable = digit_reverse_swap_256; + + for (k = 120; k != 0; k--) + { + i = *pTable++; + j = *pTable++; + tmp[0] = y[i]; + tmp[1] = y[i+1]; + y[i] = y[j]; + y[i+1] = y[j+1]; + y[j] = tmp[0]; + y[j+1] = tmp[1]; + + tmp[0] = x[j]; + tmp[1] = x[j+1]; + x[j] = x[i]; + x[j+1] = x[i+1]; + x[i] = tmp[0]; + x[i+1] = tmp[1]; + + } + +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.h new file mode 100644 index 00000000..6526531c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/digit_reversal_tables.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: digit_reversal_tables.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions digit_reversal_tables + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef DIGIT_REVERSAL_TABLES_H +#define DIGIT_REVERSAL_TABLES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 digit_reverse_64[]; +extern const Int16 digit_reverse_256[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* DIGIT_REVERSAL_TABLES_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.c new file mode 100644 index 00000000..1d1bb84f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.c @@ -0,0 +1,167 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "dst16.h" +#include "dst8.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 28 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 CosTable_8[8] = +{ + Qfmt(0.50241928618816F), Qfmt(0.52249861493969F), + Qfmt(0.56694403481636F), Qfmt(0.64682178335999F), + Qfmt(0.78815462345125F), Qfmt(1.06067768599035F), + Qfmt(1.72244709823833F), Qfmt(5.10114861868916F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dst_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */ +{ + Int32 *temp_even = scratch_mem; + + Int i; + const Int32 *pt_cos = &CosTable_8[7]; + Int32 tmp0 = vec[15] >> 1; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1; + Int32 tmp3; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp1; + + for (i = 3; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + tmp1 = tmp3; + + } + + *(pt_even) = *(pt_vec++); + *(pt_odd++) = *(pt_vec) + tmp1; + + + dst_8(temp_even); + dst_8(vec); + + pt_vec = &vec[7]; + + pt_even = &temp_even[7]; + pt_vecN_1 = &vec[8]; + + tmp1 = *(pt_even--); + + for (i = 4; i != 0; i--) + { + tmp3 = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp3 - tmp2; + *(pt_vec--) = tmp3 + tmp2; + } + +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.h new file mode 100644 index 00000000..952908ad --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst16.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST16_H +#define DST16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_16(Int32 vec[], Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +#endif /* DST16_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.c new file mode 100644 index 00000000..c07c7805 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.c @@ -0,0 +1,195 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst32.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 32 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 32 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "dst32.h" +#include "dst16.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT1 29 +#define Qfmt29(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Qfmt31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + +const Int32 CosTable_16[14] = +{ + Qfmt31(0.50060299823520F), Qfmt31(0.50547095989754F), + Qfmt31(0.51544730992262F), Qfmt31(0.53104259108978F), + Qfmt31(0.55310389603444F), Qfmt31(0.58293496820613F), + Qfmt31(0.62250412303566F), Qfmt31(0.67480834145501F), + Qfmt31(0.74453627100230F), Qfmt31(0.83934964541553F), + Qfmt29(0.97256823786196F), Qfmt29(1.16943993343288F), + Qfmt29(1.48416461631417F), Qfmt29(2.05778100995341F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void dst_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = &CosTable_16[13]; + Int32 tmp0 = vec[31] >> 1; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1 = vec; + Int32 tmp3; + + + tmp1 = 0; + + for (i = 5; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp1 + tmp3; + } + + *(pt_even) = *(pt_vec++); + *(pt_odd) = *(pt_vec) + tmp1; + + + dst_16(temp_even, &scratch_mem[16]); + dst_16(vec, &scratch_mem[24]); + + + pt_vecN_1 = &vec[16]; + + tmp1 = temp_even[15]; + + tmp3 = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2; + tmp2 = temp_even[14]; + *(pt_vecN_1++) = tmp3 - tmp1; + vec[15] = tmp3 + tmp1; + tmp1 = temp_even[13]; + tmp3 = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F)); + *(pt_vecN_1++) = tmp3 - tmp2; + vec[14] = tmp3 + tmp2; + + pt_even = &temp_even[12]; + pt_vec = &vec[13]; + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp2; + *(pt_vecN_1++) = tmp3 - tmp2; + } + + for (i = 5; i != 0; i--) + { + tmp3 = fxp_mul32_Q31((*(pt_vec) - tmp0) << 1, *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp1; + *(pt_vecN_1++) = tmp3 - tmp1; + tmp3 = fxp_mul32_Q31((*(pt_vec) + tmp0) << 1, *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vec--) = tmp3 + tmp2; + *(pt_vecN_1++) = tmp3 - tmp2; + } + + +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.h new file mode 100644 index 00000000..e395c796 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst32.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST32_H +#define DST32_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + extern const Int32 CosTable_16[]; + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_32(Int32 vec[], Int32 scratch_mem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* DST32_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.c new file mode 100644 index 00000000..ab45c410 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.c @@ -0,0 +1,174 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst8.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 8 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement discrete sine transform of lenght 8 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "dst8.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(x) (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F)) + + +void dst_8(Int32 vec[]) +{ + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 temp5; + Int32 temp6; + Int32 temp7; + Int32 tmp_a; + Int32 tmp_aa; + Int32 tmp_b; + Int32 tmp_bb; + Int32 tmp_c; + Int32 tmp_cc; + Int32 tmp_d; + Int32 tmp_dd; + + temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ + temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ + temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ + temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ + temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F)); /* (1/(2*cos(6*phi)));*/ + temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F)); /* (1/(2*cos(7*phi)));*/ + + /* even */ + tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F)); + tmp_b = (temp2 - temp6) + tmp_a; + + temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F)); + vec[0] = tmp_a + temp4; + vec[1] = tmp_b + temp4; + vec[2] = tmp_b - temp4; + vec[3] = tmp_a - temp4; + + + /* odd */ + + tmp_a = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi))); */ + tmp_aa = (temp1 - temp7); + tmp_bb = (temp5 - temp3); + temp5 = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi))); */ + + + tmp_c = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F)); + tmp_cc = tmp_a - temp5; + + tmp_d = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c); + tmp_dd = (tmp_aa + tmp_bb); + + tmp_dd += tmp_c; + tmp_a = tmp_d + tmp_cc; + vec[5] = tmp_a - vec[2]; + vec[2] += tmp_a; + + temp5 = tmp_dd + tmp_cc; + + vec[4] = temp5 - vec[3]; + vec[3] += temp5; + vec[7] = tmp_c - vec[0]; + vec[0] += tmp_c; + vec[6] = tmp_d - vec[1]; + vec[1] += tmp_d; + +} + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.h new file mode 100644 index 00000000..a25673c3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/dst8.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: dst8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef DST8_H +#define DST8_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void dst_8(Int32 vec[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* DST8_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_adif_const.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_adif_const.h new file mode 100644 index 00000000..8ee53810 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_adif_const.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_adif_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for ADIF header related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_ADIF_CONST_H +#define E_ADIF_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * audio data interchange format header + */ + LEN_ADIF_ID = (32 / 8), + LEN_COPYRT_PRES = 1, + LEN_COPYRT_ID = (72 / 8), + LEN_ORIG = 1, + LEN_HOME = 1, + LEN_BS_TYPE = 1, + LEN_BIT_RATE = 23, + LEN_NUM_PCE = 4, + LEN_ADIF_BF = 20 + +} eADIF_Const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_blockswitching.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_blockswitching.h new file mode 100644 index 00000000..2aae688b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_blockswitching.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_blockswitching.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for BlockSwitching related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_BLOCK_SWITCHING_H +#define E_BLOCK_SWITCHING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * block switching + */ + LN = 2048, + SN = 256, + LN2 = LN / 2, + SN2 = SN / 2, + LN4 = LN / 4, + SN4 = SN / 4, + NSHORT = LN / SN, + MAX_SBK = NSHORT, + MAX_WIN = MAX_SBK, + + ONLY_LONG_WINDOW = 0, + LONG_START_WINDOW, + EIGHT_SHORT_WINDOW, + LONG_STOP_WINDOW, + NUM_WIN_SEQ, + + WLONG = ONLY_LONG_WINDOW, + WSTART, + WSHORT, + WSTOP, + + MAXBANDS = 16 * NSHORT, /* max number of scale factor bands */ + MAXFAC = 121, /* maximum scale factor */ + MIDFAC = (MAXFAC - 1) / 2, + SF_OFFSET = 100 /* global gain must be positive */ +} eBlockSwitching; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_coupling_mode.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_coupling_mode.h new file mode 100644 index 00000000..c217d30b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_coupling_mode.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_coupling_mode.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_COUPLING_MODE_H +#define E_COUPLING_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + COUPLING_OFF, + COUPLING_LEVEL, + COUPLING_BAL +} +COUPLING_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_elementid.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_elementid.h new file mode 100644 index 00000000..45a47d72 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_elementid.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: e_elementid.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for BlockType related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_ELEMENTID_H +#define E_ELEMENTID_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz + * this is also the highest number of bins used + * by predictor for any sampling rate + */ + MAX_PRED_SFB = 40, /* 48 kHz only, now obsolete */ + MAX_PRED_BINS = 672, + + ID_SCE = 0, + ID_CPE, + ID_CCE, + ID_LFE, + ID_DSE, + ID_PCE, + ID_FIL, + ID_END +} +ElementId; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_huffmanconst.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_huffmanconst.h new file mode 100644 index 00000000..5c6037e3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_huffmanconst.h @@ -0,0 +1,113 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_huffmanconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Huffman related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_HUFFMAN_CONST_H +#define E_HUFFMAN_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * specify huffman tables as signed (1) or unsigned (0) + */ + HUF1SGN = 1, + HUF2SGN = 1, + HUF3SGN = 0, + HUF4SGN = 0, + HUF5SGN = 1, + HUF6SGN = 1, + HUF7SGN = 0, + HUF8SGN = 0, + HUF9SGN = 0, + HUF10SGN = 0, + HUF11SGN = 0, + + ZERO_HCB = 0, + BY4BOOKS = 4, + ESCBOOK = 11, + NSPECBOOKS = ESCBOOK + 1, + BOOKSCL = NSPECBOOKS, + NBOOKS = NSPECBOOKS + 1, + INTENSITY_HCB2 = 14, + INTENSITY_HCB = 15, + NOISE_HCB = 13, + NOISE_HCB2 = 113, + + NOISE_PCM_BITS = 9, + NOISE_PCM_OFFSET = (1 << (NOISE_PCM_BITS - 1)), + + NOISE_OFFSET = 90, + + LONG_SECT_BITS = 5, + SHORT_SECT_BITS = 3 +} eHuffmanConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_infoinitconst.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_infoinitconst.h new file mode 100644 index 00000000..f3a520ed --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_infoinitconst.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_infoinitconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Infoinit related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_INFOINIT_CONST_H +#define E_INFOINIT_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "chans.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* block switch windows for single channels or channel pairs */ + Winds = Chans, + + /* average channel block length, bytes */ + Avjframe = 341, + + TEXP = 128, /* size of exp cache table */ + MAX_IQ_TBL = 128, /* size of inv quant table */ + MAXFFT = LN4 + +} infoinitConst; + + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_invf_mode.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_invf_mode.h new file mode 100644 index 00000000..68f36142 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_invf_mode.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_invf_mode.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_INVF_MODE_H +#define E_INVF_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + INVF_OFF, + INVF_LOW_LEVEL, + INVF_MID_LEVEL, + INVF_HIGH_LEVEL, + + INVF_NO_OVERRIDE +} +INVF_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_maskstatus.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_maskstatus.h new file mode 100644 index 00000000..fd3d2e50 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_maskstatus.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_maskstatus.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file gives the enum of mask_present value used in getmask.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_MASKSTATUS_H +#define E_MASKSTATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +enum +{ + MASK_NOT_PRESENT, + MASK_FROM_BITSTREAM, + MASK_ALL_FRAME, + MASK_ERROR +}; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_mp4ff_const.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_mp4ff_const.h new file mode 100644 index 00000000..f0379510 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_mp4ff_const.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_mp4ff_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file enums the constants used by MP4FF header + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_MP4FF_CONST_H +#define E_MP4FF_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + LEN_OBJ_TYPE = 5, + LEN_SAMP_RATE_IDX = 4, + LEN_SAMP_RATE = 24, + LEN_CHAN_CONFIG = 4, + LEN_SYNC_EXTENSION_TYPE = 11, + LEN_FRAME_LEN_FLAG = 1, + LEN_DEPEND_ON_CORE = 1, + LEN_CORE_DELAY = 14, + LEN_EXT_FLAG = 1, + LEN_EP_CONFIG = 2, + LEN_LAYER_NUM = 3, + LEN_SUB_FRAME = 5, + LEN_LAYER_LEN = 11, + LEN_SECT_RES_FLAG = 1, + LEN_SCF_RES_FLAG = 1, + LEN_SPEC_RES_FLAG = 1, + LEN_EXT_FLAG3 = 1 +} eMP4FF_const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_progconfigconst.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_progconfigconst.h new file mode 100644 index 00000000..ece09e08 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_progconfigconst.h @@ -0,0 +1,104 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_progconfigconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for ProgConfig related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_PROG_CONFIG_CONST_H +#define E_PROG_CONFIG_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + /* + * Program Configuration + */ + Main_Profile = 0, + LC_Profile = 1, + + Fs_48 = 3, + Fs_44 = 4, + Fs_32 = 5, + + LEN_PROFILE = 2, + LEN_SAMP_IDX = 4, + LEN_NUM_ELE = 4, + LEN_NUM_LFE = 2, + LEN_NUM_DAT = 3, + LEN_NUM_CCE = 4, + LEN_MIX_PRES = 1, + LEN_MMIX_IDX = 2, + LEN_PSUR_ENAB = 1, + LEN_ELE_IS_CPE = 1, + LEN_IND_SW_CCE = 1, + LEN_COMMENT_BYTES = 8 + +} eProgConfigConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_rawbitstreamconst.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_rawbitstreamconst.h new file mode 100644 index 00000000..48bc1599 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_rawbitstreamconst.h @@ -0,0 +1,124 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_rawbitstreamconst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for the Raw Bitstream related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_RAW_BITSTREAM_CONST_H +#define E_RAW_BITSTREAM_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + LEN_SE_ID = 3, + LEN_TAG = 4, + LEN_COM_WIN = 1, + LEN_ICS_RESERV = 1, + LEN_WIN_SEQ = 2, + LEN_WIN_SH = 1, + LEN_MAX_SFBL = 6, + LEN_MAX_SFBS = 4, + LEN_CB = 4, + LEN_SCL_PCM = 8, + LEN_PRED_PRES = 1, + LEN_PRED_RST = 1, + LEN_PRED_RSTGRP = 5, + LEN_PRED_ENAB = 1, + LEN_MASK_PRES = 2, + LEN_MASK = 1, + LEN_PULSE_PRES = 1, + LEN_TNS_PRES = 1, + LEN_GAIN_PRES = 1, + + LEN_PULSE_NPULSE = 2, + LEN_PULSE_ST_SFB = 6, + LEN_PULSE_POFF = 5, + LEN_PULSE_PAMP = 4, + NUM_PULSE_LINES = 4, + PULSE_OFFSET_AMP = 4, + + LEN_IND_CCE_FLG = 1, + LEN_NCC = 3, + LEN_IS_CPE = 1, + LEN_CC_LR = 1, + LEN_CC_DOM = 1, + LEN_CC_SGN = 1, + LEN_CCH_GES = 2, + LEN_CCH_CGP = 1, + + LEN_D_ALIGN = 1, + LEN_D_CNT = 8, + LEN_D_ESC = 8, + LEN_F_CNT = 4, + LEN_F_ESC = 8, + LEN_BYTE = 8, + LEN_PAD_DATA = 8, + + LEN_PC_COMM = 9 + +} eRawBitstreamConst; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_element_id.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_element_id.h new file mode 100644 index 00000000..d8a820d3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_element_id.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_element_id.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_ELEMENT_ID_H +#define E_SBR_ELEMENT_ID_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SBR_ID_SCE = 0, + SBR_ID_CPE +} +SBR_ELEMENT_ID; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_error.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_error.h new file mode 100644 index 00000000..ca836dfa --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_error.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_error.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_ERROR_H +#define E_SBR_ERROR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define HANDLE_ERROR_INFO Int32 +#define noError 0 + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef enum +{ + SBRDEC_OK = 0, + SBRDEC_NOSYNCH, + SBRDEC_ILLEGAL_PROGRAM, + SBRDEC_ILLEGAL_TAG, + SBRDEC_ILLEGAL_CHN_CONFIG, + SBRDEC_ILLEGAL_SECTION, + SBRDEC_ILLEGAL_SCFACTORS, + SBRDEC_ILLEGAL_PULSE_DATA, + SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED, + SBRDEC_GC_NOT_IMPLEMENTED, + SBRDEC_ILLEGAL_PLUS_ELE_ID, + SBRDEC_CREATE_ERROR, + SBRDEC_NOT_INITIALIZED, + SBRDEC_TOO_MANY_SBR_ENVELOPES, + SBRDEC_INVALID_BITSTREAM +} +SBR_ERROR; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_header_status.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_header_status.h new file mode 100644 index 00000000..cd221a1f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_header_status.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_header_status.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_HEADER_STATUS_H +#define E_SBR_HEADER_STATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + HEADER_OK, + HEADER_RESET, + HEADER_NOT_INITIALIZED +} +SBR_HEADER_STATUS; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_master_status.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_master_status.h new file mode 100644 index 00000000..4e30acff --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_master_status.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_master_status.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_MASTER_STATUS_H +#define E_SBR_MASTER_STATUS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + MASTER_OK, + MASTER_RESET +} +SBR_MASTER_STATUS; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_sync_state.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_sync_state.h new file mode 100644 index 00000000..9cef63c9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sbr_sync_state.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sbr_sync_state.h + Funtions: + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SBR_SYNC_STATE_H +#define E_SBR_SYNC_STATE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SBR_NOT_INITIALIZED, + UPSAMPLING, + SBR_ACTIVE +} +SBR_SYNC_STATE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sr_mode.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sr_mode.h new file mode 100644 index 00000000..bf24106e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_sr_mode.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_sr_mode.h + Funtions: + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_SR_MODE_H +#define E_SR_MODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SINGLE_RATE = 1, + UP_BY_2 +} +SR_MODE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_tns_const.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_tns_const.h new file mode 100644 index 00000000..6cda4396 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_tns_const.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_tns_const.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for TNS related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_TNS_CONST_H +#define E_TNS_CONST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + TNS_MAX_BANDS = 49, + TNS_MAX_ORDER = 20, + TNS_MAX_WIN = 8, + TNS_MAX_FILT = 3, + Q_SPEC = 11, + Q_LPC = 19 + +} eTNS_Const; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_sequence.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_sequence.h new file mode 100644 index 00000000..cb87a9d9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_sequence.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_window_sequence.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Window Sequence related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_WINDOW_SEQUENCE_H +#define E_WINDOW_SEQUENCE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + ONLY_LONG_SEQUENCE, + LONG_START_SEQUENCE, + EIGHT_SHORT_SEQUENCE, + LONG_STOP_SEQUENCE, + NUM_WINDOW_SEQUENCE, + ENSURE_WINDOW_SEQUENCE_INT_SIZE = 0x7FFFFF +} +WINDOW_SEQUENCE; +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_shape.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_shape.h new file mode 100644 index 00000000..85b48075 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/e_window_shape.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: e_window_shape.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + enum for Window Sequence related constants + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef E_WINDOW_SHAPE_H +#define E_WINDOW_SHAPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef enum +{ + SINE_WINDOW = 0, + KAISER_BESSEL_WINDOW, + NUM_WINDOW_SHAPES, + ENSURE_WINDOW_SHAPE_INT_SIZE = 0x7FFFFF +} +WINDOW_SHAPE; + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.c new file mode 100644 index 00000000..926d8a9e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.c @@ -0,0 +1,759 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: esc_iquant_scaling.cpp + Funtions: esc_iquant_scaling + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + quantSpec[] = array of quantized compressed spectral coefficients, of + data type Int and length sfbWidth. + + sfbWidth = number of array elements in quantSpec and the output array + coef, data type Int. + + coef[] = output array of uncompressed coefficients, stored in a + variable Q format, depending on the maximum value found + for the group, array of Int32, length sfbWdith to be + overwritten. + + QFormat = the output Q format for the array coef[]. + + + scale = scaling factor after separating power of 2 factor out from + 0.25*(sfb_scale - 100), i.e., 0.25*sfb_scale. + + maxInput = maximum absolute value of quantSpec. + + Local Stores/Buffers/Pointers Needed: None. + + Global Stores/Buffers/Pointers Needed: + inverseQuantTable = lookup table of const integer values to the one third + power stored in Q27 format, in file iquant_table.c, const + array of UInt32, of size 1025. + + Outputs: None + + Pointers and Buffers Modified: + coef[] contents are overwritten with the uncompressed values from + quantSpec[] + + + + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs the inverse quantization of the spectral coeficients + read from huffman decoding. It takes each input array value to the four + thirds power, then scales it according to the scaling factor input argument + ,and stores the result in the output array in a variable Q format + depending upon the maximum input value found. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not have static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Section 10.3, "Decoding process", page 43. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + maxInput = 0; + + FOR (i = sfbWidth - 1; i >= 0; i--) + x = quantSpec[i]; + + IF ( x >= 0) + absX = x; + ELSE + absX = -x; + ENDIF + + coef[i] = absX; + + IF (absX > maxInput) + maxInput = absX; + ENDIF + ENDFOR + + IF (maxInput == 0) + *pQFormat = QTABLE; + ELSE + temp = inverseQuantTable[(maxInput >> ORDER) + 1]; + + temp += ((1 << (QTABLE))-1); + + temp >>= (QTABLE-1); + + temp *= maxInput; + + binaryDigits = 0; + WHILE( temp != 0) + temp >>= 1; + binaryDigits++; + WEND + + IF (binaryDigits < (SIGNED32BITS - QTABLE)) + binaryDigits = SIGNED32BITS - QTABLE; + ENDIF + + *pQFormat = SIGNED32BITS - binaryDigits; + shift = QTABLE - *pQFormat; + + IF (maxInput < TABLESIZE) + FOR (i = sfbWidth - 1; i >= 0; i--) + x = quantSpec[i]; + + absX = coef[i]; + + tmp_coef = x * (inverseQuantTable[absX] >> shift); + + b_low = (tmp_coef & 0xFFFF); + b_high = (tmp_coef >> 16); + + mult_low = ( (UInt32) b_low * scale ); + mult_high = ( (Int32) b_high * scale ); + + mult_low >>= 16; + + coef[i] = (Int32) (mult_high + mult_low); + + ENDFOR + ELSE + FOR (i = sfbWidth; i >= 0 ; i--) + x = quantSpec[i]; + absX = coef[i]; + + IF (absX < TABLESIZE) + tmp_coef = x * (inverseQuantTable[absX] >> shift); + ELSE + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + + approxOneThird = (w1 * FACTOR) >> shift; + + + x1 = index * SPACING; + w2 = inverseQuantTable[index+1]; + + deltaOneThird = (w2 - w1) * (absX - x1); + + deltaOneThird >>= (shift + ORDER - 1); + + tmp_coef = x * (approxOneThird + deltaOneThird); + + ENDIF + + b_low = (mult_high & 0xFFFF); + b_high = (mult_high >> 16); + + mult_low = ( (UInt32) b_low * scale ); + mult_high = ( (Int32) b_high * scale ); + + mult_low >>= 16; + + coef[i] = (Int32) (mult_high + mult_low); + + ENDFOR + ENDIF + ENDIF + + RETURN + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#include "pv_audio_type_defs.h" +#include "iquant_table.h" +#include "esc_iquant_scaling.h" +#include "aac_mem_funcs.h" /* For pv_memset */ + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +/* + * Read further on what order is. + * Note: If ORDER is not a multiple of 3, FACTOR is not an integer. + * Note: Portions of this function assume ORDER is 3, and so does the table + * in iquant_table.c + */ +#define ORDER (3) +/* + * For input values > TABLESIZE, multiply by FACTOR to get x ^ (1/3) + * FACTOR = 2 ^ (ORDER/3) + */ +#define FACTOR (2) + +/* + * This is one more than the range of expected inputs. + */ +#define INPUTRANGE (8192) + +/* + * SPACING is 2 ^ ORDER, and is the spacing between points when in the + * interpolation range. + */ +#define SPACING (1< 0)? (x) : (-x) + +#endif + + + + + +void esc_iquant_scaling( + const Int16 quantSpec[], + Int32 coef[], + const Int sfbWidth, + Int const QFormat, + UInt16 scale, + Int maxInput) +{ + Int i; + Int x; + Int y; + Int index; + Int shift; + UInt absX; + UInt32 w1, w2; + UInt32 deltaOneThird; + UInt32 x1; + UInt32 approxOneThird; + Int32 mult_high; + + +#if ( defined(_ARM) || defined(_ARM_V4)) + + { + Int32 *temp; + Int32 R12, R11, R10, R9; + + deltaOneThird = sizeof(Int32) * sfbWidth; + temp = coef; + + // from standard library call for __rt_memset + __asm + { + MOV R12, #0x0 + MOV R11, #0x0 + MOV R10, #0x0 + MOV R9, #0x0 + SUBS deltaOneThird, deltaOneThird, #0x20 +loop: + STMCSIA temp!, {R12, R11, R10, R9} + STMCSIA temp!, {R12, R11, R10, R9} + SUBCSS deltaOneThird, deltaOneThird, #0x20 + BCS loop + + MOVS deltaOneThird, deltaOneThird, LSL #28 + STMCSIA temp!, {R12, R11, R10, R9} + STMMIIA temp!, {R12, R11} + } + } + +#else + pv_memset(coef, 0, sizeof(Int32) * sfbWidth); +#endif + + if (maxInput > 0) + { + + shift = QTABLE - QFormat; + + if (scale != 0) + { + if (maxInput < TABLESIZE) + { + + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + y = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + mult_high = (x * (inverseQuantTable[absX] >> shift)); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + x = quantSpec[i-2]; + y = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + + } /* end if (maxInput < TABLESIZE)*/ + + else /* maxInput >= TABLESIZE) */ + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + } /* if(x) */ + + + x = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = (x * (inverseQuantTable[absX] >> shift)); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* if(x) */ + + x = quantSpec[i-2]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1; + } + } /* if(x) */ + + x = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1; + + } + } /* if(x) */ + + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + } /* end else for if (maxInput < TABLESIZE)*/ + } + else /* scale == 0 */ + { + if (maxInput < TABLESIZE) + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + y = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = mult_high >> 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-1] = mult_high >> 1; + } + + x = quantSpec[i-2]; + y = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = mult_high >> 1; + } + + if (y) + { + absX = pv_abs(y); + mult_high = y * (inverseQuantTable[absX] >> shift); + coef[i-3] = mult_high >> 1; + } + } + + } /* end if (maxInput < TABLESIZE)*/ + + else /* maxInput >= TABLESIZE) */ + { + for (i = sfbWidth - 1; i >= 0; i -= 4) + { + x = quantSpec[i]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-1]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-1] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-1] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-2]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-2] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-2] = (mult_high >> 1); + } + } /* if(x) */ + + x = quantSpec[i-3]; + if (x) + { + absX = pv_abs(x); + if (absX < TABLESIZE) + { + mult_high = x * (inverseQuantTable[absX] >> shift); + coef[i-3] = (mult_high >> 1); + } /* end if (absX < TABLESIZE) */ + else + { + index = absX >> ORDER; + w1 = inverseQuantTable[index]; + w2 = inverseQuantTable[index+1]; + approxOneThird = (w1 * FACTOR) >> shift; + x1 = index << ORDER; + deltaOneThird = (w2 - w1) * (absX - x1); + deltaOneThird >>= (shift + 2); + mult_high = x * (approxOneThird + deltaOneThird); + coef[i-3] = (mult_high >> 1); + } + + } /* if(x) */ + + } /* end for (i = sfbWidth - 1; i >= 0; i--) */ + + } /* end else for if (maxInput < TABLESIZE)*/ + + } /* end else for if(scale!=0) */ + + } /* end else for if(maxInput == 0) */ + +} /* end esc_iquant_fxp */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.h new file mode 100644 index 00000000..8adef3d2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/esc_iquant_scaling.h @@ -0,0 +1,96 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: esc_iquant_scaling.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for esc_iquant_scaling.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef ESC_IQUANT_SCALING_H +#define ESC_IQUANT_SCALING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + void esc_iquant_scaling( + const Int16 quantSpec[], + Int32 coef[], + const Int sfbWidth, + Int const pQFormat, + UInt16 scale, + Int maxInput); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* ESC_IQUANT_SCALING_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.c new file mode 100644 index 00000000..2f5903ab --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.c @@ -0,0 +1,482 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: extractframeinfo.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hBitBuf - bitbuffer handle + v_frame_info - pointer to memorylocation where the frame-info will + be stored. + + Return: none. + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +Extracts a frame_info vector from control data read from the bitstream. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "extractframeinfo.h" +#include "buf_getbits.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/* + * (int) ceil (log (bs_num_env + 1) / log (2)) + * ceil(log([0:5]+1)/log(2)) + */ + +const Int32 bs_pointer_bits_tbl[MAX_ENVELOPES + 1] = { 0, 1, 2, 2, 3, 3}; + +/* + * (int)((float)numTimeSlots/bs_num_env + 0.5f) + * floor(16./[0:5] + 0.5) + */ + +const Int32 T_16_ov_bs_num_env_tbl[MAX_ENVELOPES + 1] = { 2147483647, 16, 8, + 5, 4, 3 + }; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf, + SBR_FRAME_DATA * h_frame_data) +{ + + Int32 absBordLead = 0; + Int32 nRelLead = 0; + Int32 nRelTrail = 0; + Int32 bs_num_env = 0; + Int32 bs_num_rel = 0; + Int32 bs_var_bord = 0; + Int32 bs_var_bord_0 = 0; + Int32 bs_var_bord_1 = 0; + Int32 bs_pointer = 0; + Int32 bs_pointer_bits; + Int32 frameClass; + Int32 temp; + Int32 env; + Int32 k; + Int32 bs_num_rel_0 = 0; + Int32 bs_num_rel_1 = 0; + Int32 absBordTrail = 0; + Int32 middleBorder = 0; + Int32 bs_num_noise; + Int32 lA = 0; + + Int32 tE[MAX_ENVELOPES + 1]; + Int32 tQ[2 + 1]; + Int32 f[MAX_ENVELOPES + 1]; + Int32 bs_rel_bord[3]; + Int32 bs_rel_bord_0[3]; + Int32 bs_rel_bord_1[3]; + Int32 relBordLead[3]; + Int32 relBordTrail[3]; + + + Int32 *v_frame_info = h_frame_data->frameInfo; + + SBR_ERROR err = SBRDEC_OK; + + + /* + * First read from the bitstream. + */ + + /* Read frame class */ + h_frame_data->frameClass = frameClass = buf_getbits(hBitBuf, SBR_CLA_BITS); + + + switch (frameClass) + { + + case FIXFIX: + temp = buf_getbits(hBitBuf, SBR_ENV_BITS); /* 2 bits */ + + bs_num_env = 1 << temp; + + + f[0] = buf_getbits(hBitBuf, SBR_RES_BITS); /* 1 bit */ + + for (env = 1; env < bs_num_env; env++) + { + f[env] = f[0]; + } + + nRelLead = bs_num_env - 1; + absBordTrail = 16; + + + break; + + case FIXVAR: + bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_env = bs_num_rel + 1; + + for (k = 0; k < bs_num_env - 1; k++) + { + bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[bs_num_env - 1 - env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordTrail = 16 + bs_var_bord; + nRelTrail = bs_num_rel; + + break; + + case VARFIX: + bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_env = bs_num_rel + 1; + + for (k = 0; k < bs_num_env - 1; k++) + { + bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordTrail = 16; + absBordLead = bs_var_bord; + nRelLead = bs_num_rel; + + break; + + case VARVAR: + bs_var_bord_0 = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */ + bs_var_bord_1 = buf_getbits(hBitBuf, SBR_ABS_BITS); + bs_num_rel_0 = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */ + bs_num_rel_1 = buf_getbits(hBitBuf, SBR_NUM_BITS); + + bs_num_env = bs_num_rel_0 + bs_num_rel_1 + 1; + + for (k = 0; k < bs_num_rel_0; k++) + { /* 2 bits */ + bs_rel_bord_0[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + for (k = 0; k < bs_num_rel_1; k++) + { /* 2 bits */ + bs_rel_bord_1[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1; + } + + + bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env]; + + bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits); + + for (env = 0; env < bs_num_env; env++) + { /* 1 bit */ + f[env] = buf_getbits(hBitBuf, SBR_RES_BITS); + } + + absBordLead = bs_var_bord_0; + absBordTrail = 16 + bs_var_bord_1; + nRelLead = bs_num_rel_0; + nRelTrail = bs_num_rel_1; + + break; + + }; + + + /* + * Calculate the framing. + */ + + + switch (frameClass) + { + case FIXFIX: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = T_16_ov_bs_num_env_tbl[bs_num_env]; + } + break; + case VARFIX: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = bs_rel_bord[k]; + } + break; + case VARVAR: + for (k = 0; k < nRelLead; k++) + { + relBordLead[k] = bs_rel_bord_0[k]; + } + for (k = 0; k < nRelTrail; k++) + { + relBordTrail[k] = bs_rel_bord_1[k]; + } + break; + case FIXVAR: + for (k = 0; k < nRelTrail; k++) + { + relBordTrail[k] = bs_rel_bord[k]; + } + break; + } + + + tE[0] = absBordLead; + tE[bs_num_env] = absBordTrail; + + for (env = 1; env <= nRelLead; env++) + { + tE[env] = absBordLead; + for (k = 0; k <= env - 1; k++) + { + tE[env] += relBordLead[k]; + } + } + + for (env = nRelLead + 1; env < bs_num_env; env++) + { + tE[env] = absBordTrail; + for (k = 0; k <= bs_num_env - env - 1; k++) + { + tE[env] -= relBordTrail[k]; + } + } + + + + switch (frameClass) + { + case FIXFIX: + middleBorder = bs_num_env >> 1; + break; + case VARFIX: + switch (bs_pointer) + { + case 0: + middleBorder = 1; + break; + case 1: + middleBorder = bs_num_env - 1; + break; + default: + middleBorder = bs_pointer - 1; + break; + }; + break; + case FIXVAR: + case VARVAR: + switch (bs_pointer) + { + case 0: + case 1: + middleBorder = bs_num_env - 1; + break; + default: + middleBorder = bs_num_env + 1 - bs_pointer; + break; + }; + break; + }; + + + tQ[0] = tE[0]; + if (bs_num_env > 1) + { + tQ[1] = tE[middleBorder]; + tQ[2] = tE[bs_num_env]; + bs_num_noise = 2; + } + else + { + tQ[1] = tE[bs_num_env]; + bs_num_noise = 1; + } + + /* + * Check consistency on freq bands + */ + + if ((tE[bs_num_env] < tE[0]) || (tE[0] < 0)) + { + err = SBRDEC_INVALID_BITSTREAM; + } + + + switch (frameClass) + { + case FIXFIX: + lA = -1; + break; + case VARFIX: + switch (bs_pointer) + { + case 0: + case 1: + lA = -1; + break; + default: + lA = bs_pointer - 1; + break; + }; + break; + case FIXVAR: + case VARVAR: + switch (bs_pointer) + { + case 0: + lA = - 1; + break; + default: + lA = bs_num_env + 1 - bs_pointer; + break; + }; + break; + }; + + /* + * Build the frameInfo vector... + */ + + v_frame_info[0] = bs_num_env; /* Number of envelopes*/ + pv_memcpy(v_frame_info + 1, tE, (bs_num_env + 1)*sizeof(Int32)); /* time borders*/ + /* frequency resolution */ + pv_memcpy(v_frame_info + 1 + bs_num_env + 1, f, bs_num_env*sizeof(Int32)); + + temp = (1 + bs_num_env) << 1; + v_frame_info[temp] = lA; /* transient envelope*/ + v_frame_info[temp + 1] = bs_num_noise; /* Number of noise envelopes */ + /* noise borders */ + pv_memcpy(v_frame_info + temp + 2, tQ, (bs_num_noise + 1)*sizeof(Int32)); + + + return (err); + +} + + + + + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.h new file mode 100644 index 00000000..e912f62c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/extractframeinfo.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: extractframeinfo.h + + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef EXTRACTFRAMEINFO_H +#define EXTRACTFRAMEINFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef Int32 FRAME_INFO[LENGTH_FRAME_INFO]; + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf, + SBR_FRAME_DATA * h_frame_data); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4.h new file mode 100644 index 00000000..6aa55756 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fft_rx4() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FFT_RX4_H +#define FFT_RX4_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FFT_RX4_LONG 256 +#define ONE_FOURTH_FFT_RX4_LONG ((FFT_RX4_LONG)>>2) +#define FFT_RX4_SHORT 64 +#define ONE_FOURTH_FFT_RX4_SHORT ((FFT_RX4_SHORT)>>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 w_64rx4[]; +extern const Int32 W_64rx4[]; +extern const Int32 W_256rx4[]; +extern const Int32 w_512rx2[]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void fft_rx4_long( + Int32 Data[], + Int32 *peak_value); + + Int fft_rx4_short( + Int32 Data[], + Int32 *peak_value); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FFT_RX4_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_long.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_long.c new file mode 100644 index 00000000..2aac5014 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_long.c @@ -0,0 +1,381 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_long.cpp + Funtions: fft_rx4_long + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input complex vector, arranged in the following order: + real, imag, real, imag... + This is a complex vector whose elements (real and Imag) are + Int32. + type Int32 * + + peak_value = Input, peak value of the input vector + Output, peak value of the resulting vector + type Int32 * + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Fast Fourier Transform, radix 4 with Decimation in Frequency and block + floating point arithmetic. + The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of + the smaller FFTs is then further divided into smaller ones and so on. + It consists of log 4 N stages and each stage consists of N/4 dragonflies. + + An FFT is nothing but a bundle of multiplications and summations which + may overflow during calculations. + + + This routine uses a scheme to test and scale the result output from + each FFT stage in order to fix the accumulation overflow. + + The Input Data should be in Q13 format to get the highest precision. + At the end of each dragonfly calculation, a test for possible bit growth + is made, if bit growth is possible the Data is scale down back to Q13. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for an input array + of size 256. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "fft_rx4.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void fft_rx4_long( + Int32 Data[], + Int32 *peak_value) + +{ + Int n1; + Int n2; + Int j; + Int k; + Int i; + + Int32 t1; + Int32 t2; + Int32 r1; + Int32 r2; + Int32 r3; + Int32 r4; + Int32 s1; + Int32 s2; + Int32 s3; + Int32 *pData1; + Int32 *pData2; + Int32 *pData3; + Int32 *pData4; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 max; + + Int32 exp_jw1; + Int32 exp_jw2; + Int32 exp_jw3; + + + + const Int32 *pw = W_256rx4; + + n2 = FFT_RX4_LONG; + + for (k = FFT_RX4_LONG; k > 4; k >>= 2) + { + + n1 = n2; + n2 >>= 2; + + for (i = 0; i < FFT_RX4_LONG; i += n1) + { + pData1 = &Data[ i<<1]; + pData2 = pData1 + n1; + + temp1 = *pData1; + temp2 = *pData2; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + (n1 >> 1); + pData4 = pData3 + n1; + temp3 = *pData3++; + temp4 = *pData4++; + + t1 = temp3 + temp4; + + *(pData1++) = (r1 + t1); + t2 = temp3 - temp4; + *(pData2++) = (r1 - t1); + + temp1 = *pData1; + temp2 = *pData2; + + s1 = temp1 + temp2; + temp3 = *pData3; + s2 = temp1 - temp2; + temp4 = *pData4; + *pData3-- = (s2 - t2); + *pData4-- = (s2 + t2); + + t1 = temp3 + temp4; + + *pData1 = (s1 + t1); + *pData2 = (s1 - t1); + + r1 = temp3 - temp4; + + *pData4 = (r2 - r1); + *pData3 = (r2 + r1); + + } /* i */ + + + + for (j = 1; j < n2; j++) + { + + exp_jw1 = (*pw++); + exp_jw2 = (*pw++); + exp_jw3 = (*pw++); + + + for (i = j; i < FFT_RX4_LONG; i += n1) + { + pData1 = &Data[ i<<1]; + pData2 = pData1 + n1; + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + (n1 >> 1); + pData4 = pData3 + n1; + temp3 = *pData3++; + temp4 = *pData4++; + + r3 = temp3 + temp4; + r4 = temp3 - temp4; + + *(pData1++) = (r1 + r3); + r1 = (r1 - r3) << 1; + + temp2 = *pData2; + temp1 = *pData1; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + s3 = (s2 + r4) << 1; + s2 = (s2 - r4) << 1; + + temp3 = *pData3; + temp4 = *pData4; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *pData1 = (s1 + t1); + s1 = (s1 - t1) << 1; + + *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2); + r3 = (r2 - t2) << 1; + *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2); + + r2 = (r2 + t2) << 1; + + *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1); + *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1); + + *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3); + *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3); + + } /* i */ + + } /* j */ + + } /* k */ + + + max = 0; + + pData1 = Data - 7; + + + for (i = ONE_FOURTH_FFT_RX4_LONG; i != 0 ; i--) + { + pData1 += 7; + pData2 = pData1 + 4; + + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + pData3 = pData1 + 2; + pData4 = pData1 + 6; + temp1 = *pData3++; + temp2 = *pData4++; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (r1 + t1); + r1 = (r1 - t1); + *(pData1++) = temp1; + max |= (temp1 >> 31) ^ temp1; + + + + temp2 = *pData2; + temp1 = *pData1; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + + temp1 = *pData3; + temp2 = *pData4; + + s3 = (s2 + t2); + s2 = (s2 - t2); + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (s1 + t1); + *pData1 = temp1; + temp2 = (s1 - t1); + + max |= (temp1 >> 31) ^ temp1; + *pData2-- = temp2; + max |= (temp2 >> 31) ^ temp2; + + *pData2 = r1; + max |= (r1 >> 31) ^ r1; + *pData3-- = s2; + max |= (s2 >> 31) ^ s2; + *pData4-- = s3; + max |= (s3 >> 31) ^ s3; + + temp1 = (r2 - t2); + *pData4 = temp1; + temp2 = (r2 + t2); + *pData3 = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } /* i */ + + *peak_value = max; + + return ; + +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_short.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_short.c new file mode 100644 index 00000000..0b66dded --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_short.c @@ -0,0 +1,424 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_short.cpp + Funtions: fft_rx4_short + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input complex vector, arranged in the following order: + real, imag, real, imag... + This is a complex vector whose elements (real and Imag) are + Int32. + type Int32 * + + peak_value = Input, peak value of the input vector + Output, peak value of the resulting vector + type Int32 * + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exponent returns a shift to compensate the scaling introduced by + overflow protection + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Fast Fourier Transform, radix 4 with Decimation in Frequency and block + floating point arithmetic. + The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of + the smaller FFTs is then further divided into smaller ones and so on. + It consists of log 4 N stages and each stage consists of N/4 dragonflies. + + An FFT is nothing but a bundle of multiplications and summations which + may overflow during calculations. + + + This routine uses a scheme to test and scale the result output from + each FFT stage in order to fix the accumulation overflow. + + The Input Data should be in Q13 format to get the highest precision. + At the end of each dragonfly calculation, a test for possible bit growth + is made, if bit growth is possible the Data is scale down back to Q13. + + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for an input array + of size 64. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "fft_rx4.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int fft_rx4_short( + Int32 Data[], + Int32 *peak_value) + +{ + Int n1; + Int n2; + Int n3; + Int j; + Int k; + Int i; + Int32 exp_jw1; + Int32 exp_jw2; + Int32 exp_jw3; + + + Int32 t1; + Int32 t2; + Int32 r1; + Int32 r2; + Int32 r3; + Int32 s1; + Int32 s2; + Int32 s3; + + Int32 *pData1; + Int32 *pData2; + Int32 *pData3; + Int32 *pData4; + const Int32 *pw; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 max; + Int exp; + Int exponent = 0; + Int shift; + + + max = *peak_value; + exp = 0; + + if (max > 0x008000) + { + exp = 8 - pv_normalize(max); /* use 24 bits */ + + exponent = exp; /* keeps track of # of shifts */ + + } + + n2 = FFT_RX4_SHORT; + + pw = W_64rx4; + + + /* shift down to avoid possible overflow in first pass of the loop */ + shift = 2; + + for (k = FFT_RX4_SHORT; k > 4; k >>= 2) + { + + n1 = n2; + n2 >>= 2; + n3 = n1 >> 1; + + exp -= 2; + + for (i = 0; i < FFT_RX4_SHORT; i += n1) + { + pData1 = &Data[ i<<1]; + pData3 = pData1 + n3; + pData2 = pData1 + n1; + pData4 = pData3 + n1; + + temp1 = *(pData1); + temp2 = *(pData2); + temp1 >>= shift; + temp2 >>= shift; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + temp3 = *(pData3++); + temp4 = *(pData4++); + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *(pData1++) = (r1 + t1) >> exp; + *(pData2++) = (r1 - t1) >> exp; + + temp1 = *pData1; + temp2 = *pData2; + temp1 >>= shift; + temp2 >>= shift; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + temp3 = *pData3; + temp4 = *pData4; + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + r1 = temp3 - temp4; + + *pData1 = (s1 + t1) >> exp; + *pData2 = (s1 - t1) >> exp; + + *pData4-- = (s2 + t2) >> exp; + *pData4 = (r2 - r1) >> exp; + + *pData3-- = (s2 - t2) >> exp; + *pData3 = (r2 + r1) >> exp; + + + } /* i */ + + for (j = 1; j < n2; j++) + { + exp_jw1 = *pw++; + exp_jw2 = *pw++; + exp_jw3 = *pw++; + + + for (i = j; i < FFT_RX4_SHORT; i += n1) + { + pData1 = &Data[ i<<1]; + pData3 = pData1 + n3; + pData2 = pData1 + n1; + pData4 = pData3 + n1; + + temp1 = *(pData1); + temp2 = *(pData2++); + temp1 >>= shift; + temp2 >>= shift; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + temp3 = *(pData3++); + temp4 = *(pData4++); + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *(pData1++) = (r1 + t1) >> exp; + r1 = (r1 - t1) >> exp; + + temp1 = *pData1; + temp2 = *pData2; + temp1 >>= shift; + temp2 >>= shift; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + s3 = (s2 + t2) >> exp; + s2 = (s2 - t2) >> exp; + + temp3 = *pData3; + temp4 = *pData4 ; + temp3 >>= shift; + temp4 >>= shift; + + t1 = temp3 + temp4; + t2 = temp3 - temp4; + + *pData1 = (s1 + t1) >> exp; + s1 = (s1 - t1) >> exp; + + + *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2) << 1; + *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2) << 1; + + r3 = ((r2 - t2) >> exp); + r2 = ((r2 + t2) >> exp); + + *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1) << 1; + *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1) << 1; + + *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3) << 1; + *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3) << 1; + + } /* i */ + + } /* j */ + + /* + * this will reset exp and shift to zero for the second pass of the + * loop + */ + exp = 2; + shift = 0; + + } /* k */ + + + max = 0; + + pData1 = Data - 7; + + for (i = ONE_FOURTH_FFT_RX4_SHORT; i != 0 ; i--) + { + pData1 += 7; + + pData3 = pData1 + 2; + pData2 = pData1 + 4; + pData4 = pData1 + 6; + + temp1 = *pData1; + temp2 = *pData2++; + + r1 = temp1 + temp2; + r2 = temp1 - temp2; + + temp1 = *pData3++; + temp2 = *pData4++; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (r1 + t1); + r1 = (r1 - t1); + *(pData1++) = temp1; + max |= (temp1 >> 31) ^ temp1; + + + + temp1 = *pData1; + temp2 = *pData2; + + s1 = temp1 + temp2; + s2 = temp1 - temp2; + + s3 = (s2 + t2); + s2 = (s2 - t2); + + temp1 = *pData3; + temp2 = *pData4; + + t1 = temp1 + temp2; + t2 = temp1 - temp2; + + temp1 = (s1 + t1); + temp2 = (s1 - t1); + *pData1 = temp1; + *pData2-- = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + *pData2 = r1; + *pData3-- = s2; + *pData4-- = s3; + max |= (r1 >> 31) ^ r1; + max |= (s2 >> 31) ^ s2; + max |= (s3 >> 31) ^ s3; + + temp1 = (r2 - t2); + temp2 = (r2 + t2); + *pData4 = temp1; + *pData3 = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } /* i */ + + *peak_value = max; + + + return (exponent); + +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_tables_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_tables_fxp.c new file mode 100644 index 00000000..977a1682 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fft_rx4_tables_fxp.c @@ -0,0 +1,249 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fft_rx4_tables_fxp.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Table generation + + n = 256 or 64; + M = precision; 2^10, 2^12, 2^13 + + for j=1; jusedBits < + (pInputStream->availableBits + syncword_length) ) + + max_search_length = (pInputStream->availableBits - pInputStream->usedBits); + + max_search_length = max_search_length - syncword_length; + + search_length = 0; + + adts_header = + CALL getbits(syncword_length, pInputStream); + MODIFYING pInputStream->usedBits + RETURNING bits from bitstream of length (syncword_length) + + test_for_syncword = adts_header AND syncword_mask; + test_for_syncword = test_for_syncword XOR syncword; + + WHILE ( (test_for_syncword != 0) && (search_length > 0) ) + + search_length = search_length - 1; + + adts_header = adts_header << 1; + adts_header = adts_header OR ... + + CALL getbits(syncword_length, pInputStream); + MODIFYING pInputStream->usedBits + RETURNING 1 bit from the bitstream + + test_for_syncword = adts_header AND syncword_mask; + test_for_syncword = test_for_syncword XOR syncword; + + ENDWHILE + + IF (search_length == 0) + status = ERROR; + ENDIF + + *(pSyncword) = adts_header; + + pInputStream->byteAlignOffset = + (pInputStream->usedBits - syncwordlength) AND 0x7; + + ELSE + status = ERROR; + ENDIF + + return (status); + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" +#include "find_adts_syncword.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define FIND_ADTS_ERROR -1 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int find_adts_syncword( + UInt32 *pSyncword, + BITS *pInputStream, + Int syncword_length, + UInt32 syncword_mask) +{ + + Int status = SUCCESS; + UInt search_length; + UInt32 adts_header = 0; + UInt32 test_for_syncword; + UInt32 syncword = *(pSyncword); + + /* + * Determine the maximum number of bits available to this function for + * the syncword search. + */ + if ((Int)pInputStream->usedBits < + ((Int)pInputStream->availableBits - syncword_length)) + { + search_length = (pInputStream->availableBits - pInputStream->usedBits); + + search_length -= syncword_length; + + adts_header = getbits(syncword_length, pInputStream); + + /* + * Mask the result in adts_header with the syncword_mask, so only the + * bits relevant to syncword detection are compared to *(pSyncword). + */ + test_for_syncword = adts_header & syncword_mask; + test_for_syncword ^= syncword; + + /* + * Scan bit-by-bit through the bitstream, until the function either + * runs out of bits, or finds the syncword. + */ + + while ((test_for_syncword != 0) && (search_length > 0)) + { + search_length--; + + adts_header <<= 1; + adts_header |= getbits(1, pInputStream); + + test_for_syncword = adts_header & syncword_mask; + test_for_syncword ^= syncword; + } + + if (search_length == 0) + { + status = FIND_ADTS_ERROR; + } + + /* + * Return the syncword's position in the bitstream. Correct placement + * of the syncword will result in byte_align_offset == 0. + * If the syncword is found not to be byte-aligned, then return + * the degree of disalignment, so further decoding can + * be shifted as necessary. + * + */ + pInputStream->byteAlignOffset = + (pInputStream->usedBits - syncword_length) & 0x7; + + } /* END if (pInputStream->usedBits < ...) */ + + else + { + status = FIND_ADTS_ERROR; + } + + *(pSyncword) = adts_header; + + return (status); + +} /* find_adts_syncword() */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/find_adts_syncword.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/find_adts_syncword.h new file mode 100644 index 00000000..f04b613e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/find_adts_syncword.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: find_adts_syncword.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for find_adts_syncword() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FIND_ADTS_SYNCWORD_H +#define FIND_ADTS_SYNCWORD_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int find_adts_syncword( + UInt32 *pSyncword, + BITS *pInputStream, + Int syncword_length, + UInt32 syncword_mask); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.c new file mode 100644 index 00000000..149eff3e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.c @@ -0,0 +1,244 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_long_complex_rot.cpp + Funtions: fwd_long_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for long windows + TWICE_FWD_LONG_CX_ROT_LENGTH), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)), + (sized for long windows TWICE_FWD_LONG_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + fwd_long_complex_rot() performs the pre complex rotation for the MDCT + for the case of long windows. It also performs digit reverse ordering of + the first and second halves of the input vector "Data_in", as well as + reordering of the two half vectors (following radix-2 decomposition) + Word normalization is also done to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + fwd_long_complex_rot() should execute a pre-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and normalization +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fwd_long_complex_rot.h" +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int fwd_long_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) +{ + Int i; + const Int32 *p_rotate; + Int32 temp_re; + Int32 temp_im; + Int32 *pData_in_ref1; + Int32 *pData_in_ref2; + Int32 exp_jw; + Int32 temp_re_32; + Int32 temp_im_32; + + Int32 *pData_out_1; + Int32 *pData_out_2; + Int32 *pData_out_3; + Int32 *pData_out_4; + + Int32 *pData_in_1; + Int32 *pData_in_2; + + Int exp; + + p_rotate = exp_rotation_N_2048; + + pData_in_ref1 = Data_in; + pData_in_ref2 = &Data_in[TWICE_FWD_LONG_CX_ROT_LENGTH]; + + pData_out_1 = Data_out; + pData_out_2 = &Data_out[LONG_WINDOW_LENGTH_m_1]; + pData_out_3 = &Data_out[LONG_WINDOW_LENGTH]; + pData_out_4 = &Data_out[TWICE_LONG_WINDOW_LENGTH_m_1]; + + /* + * Data_out + * >>>> <<<< + * pData_out_3 pData_out_4 + * | | | | | + * pData_out_1 pData_out_2 + * >>>> <<<< + */ + + + exp = 16 - pv_normalize(max); + + if (exp < 0) + { + exp = 0; + } + + /* + * Apply A/2^(diff) + B + */ + + + pData_in_1 = pData_in_ref1; + pData_in_2 = pData_in_ref2; + + for (i = FWD_LONG_CX_ROT_LENGTH; i != 0; i--) + { + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1++) >> exp; + temp_im = *(pData_in_1++) >> exp; + + /* + * Pre-rotation + */ + + temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw)); + temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw)); + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + /* + * Pointer increment to jump over imag (1 & 4) or real parts + * (2 & 3) + */ + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + /* + * Repeat procedure for odd index at the output + */ + + exp_jw = *p_rotate++; + + temp_re = *(pData_in_2++) >> exp; + temp_im = *(pData_in_2++) >> exp; + + temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw)); + temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw)); + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + } + + return (exp + 1); +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.h new file mode 100644 index 00000000..fb5060b6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_long_complex_rot.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_long_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fwd_long_complex_rot + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FWD_LONG_COMPLEX_ROT_H +#define FWD_LONG_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FWD_LONG_CX_ROT_LENGTH 256 +#define TWICE_FWD_LONG_CX_ROT_LENGTH (FWD_LONG_CX_ROT_LENGTH<<1) +#define LONG_WINDOW_LENGTH 1024 +#define LONG_WINDOW_LENGTH_m_1 (LONG_WINDOW_LENGTH - 1) +#define TWICE_LONG_WINDOW_LENGTH_m_1 ((LONG_WINDOW_LENGTH<<1) - 1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + + +Int fwd_long_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FWD_LONG_COMPLEX_ROT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.c new file mode 100644 index 00000000..002b3778 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.c @@ -0,0 +1,222 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: fwd_short_complex_rot.cpp + Funtions: fwd_short_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for short windows + 2*FWD_SHORT_CX_ROT_LENGTH elements), with freq. domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)), + (sized for short windows 2*FWD_SHORT_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + fwd_short_complex_rot() performs the complex rotation for the MDCT + for the case of short windows. It performs digit reverse ordering as well + word normalization to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + fwd_short_complex_rot() should execute a pre-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fwd_short_complex_rot.h" +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "pv_normalize.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int fwd_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) + +{ + Int i; + Int16 I; + const Int16 *pTable; + const Int32 *p_rotate; + + Int32 *pData_in_1; + Int exp; + Int32 temp_re; + Int32 temp_im; + + Int32 cos_n; + Int32 sin_n; + Int32 temp_re_32; + Int32 temp_im_32; + + Int32 *pData_in_ref; + + Int32 *pData_out_1; + Int32 *pData_out_2; + Int32 *pData_out_3; + Int32 *pData_out_4; + + pTable = digit_reverse_64; + p_rotate = exp_rotation_N_256; + + pData_in_ref = Data_in; + + exp = 16 - pv_normalize(max); + + if (exp < 0) + { + exp = 0; + } + + pData_out_1 = Data_out; + pData_out_2 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1]; + pData_out_3 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH]; + pData_out_4 = &Data_out[FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1]; + + /* + * Data_out + * >>>> <<<< + * pData_out_3 pData_out_4 + * | | | | | + * pData_out_1 pData_out_2 + * >>>> <<<< + */ + + + for (i = FWD_SHORT_CX_ROT_LENGTH; i != 0; i--) + { + /* + * Perform digit reversal by accessing index I from table + */ + + I = *pTable++; + pData_in_1 = pData_in_ref + I; + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + sin_n = *p_rotate++; + cos_n = sin_n >> 16; + sin_n = sin_n & 0xFFFF; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1++) >> exp; + temp_im = *(pData_in_1) >> exp; + + /* + * Pre-rotation + */ + + temp_re_32 = (temp_re * cos_n + temp_im * sin_n) >> 16; + temp_im_32 = (temp_im * cos_n - temp_re * sin_n) >> 16; + + *(pData_out_1++) = - temp_re_32; + *(pData_out_2--) = temp_im_32; + *(pData_out_3++) = - temp_im_32; + *(pData_out_4--) = temp_re_32; + + /* + * Pointer increment to jump over imag (1 & 4) or real parts + * (2 & 3) + */ + + pData_out_1++; + pData_out_2--; + pData_out_3++; + pData_out_4--; + + } /* for(i) */ + + return (exp); +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.h new file mode 100644 index 00000000..2d98daab --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fwd_short_complex_rot.h @@ -0,0 +1,85 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fwd_short_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions fwd_short_complex_rot + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef FWD_SHORT_COMPLEX_ROT_H +#define FWD_SHORT_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FWD_SHORT_CX_ROT_LENGTH 64 +#define TWICE_FWD_SHORT_CX_ROT_LENGTH (FWD_SHORT_CX_ROT_LENGTH<<1) +#define TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<1) - 1) +#define FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<2) - 1) +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int fwd_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* FWD_SHORT_COMPLEX_ROT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32.h new file mode 100644 index 00000000..61ac78b0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32 +#define FXP_MUL32 + +#include "config.h" + +#if defined(PV_ARM_V5) + +#include "fxp_mul32_arm_v5.h" + +#elif defined(PV_ARM_V4) + +#include "fxp_mul32_arm_v4.h" + +#elif defined(PV_ARM_MSC_EVC_V4) + +#include "fxp_mul32_c_msc_evc.h" + +#elif defined(PV_ARM_MSC_EVC_V5) + +#include "fxp_mul32_c_msc_evc_armv5.h" + +#elif defined(PV_ARM_GCC_V5) + +#include "fxp_mul32_arm_gcc.h" + +#elif defined(PV_ARM_GCC_V4) + +#include "fxp_mul32_arm_v4_gcc.h" + +#else + +#ifndef C_EQUIVALENT +#define C_EQUIVALENT +#endif + +#include "fxp_mul32_c_equivalent.h" + +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_gcc.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_gcc.h new file mode 100644 index 00000000..b3cfc580 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_gcc.h @@ -0,0 +1,543 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_gcc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_ARM_GCC +#define FXP_MUL32_ARM_GCC + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include "config.h" +#include "pv_audio_type_defs.h" + + +#if (defined (PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5)) /* ARM GNU COMPILER */ + + + +#define preload_cache( a) + + + static inline Int32 shft_lft_1(Int32 y) + { + register Int32 x; + register Int32 ra = y; + + + asm volatile( + "qadd %0, %1, %1\n\t" + : "=&r*i"(x) + : "r"(ra)); + + return (x); + } + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, const Int32 L_var2) + { + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulbb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smultb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulbt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smultt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlabt %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) +{ + register Int32 cx_sum; + register Int32 rx = (Int32)x; + register Int32 ry = (Int32)y; + register Int32 rexp = (Int32)exp_jw; + asm volatile( + "smulwt %0, %1, %3\n\t" + "smlawb %0, %2, %3, %0" + : "=&r*i"(cx_sum) + : "r"(rx), + "r"(ry), + "r"(rexp)); + + return (cx_sum); + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulwb %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "smulwt %0, %1, %2" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb)); + + return (tmp); + } + + + + static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) +{ + + register Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "smlawb %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) +{ + sum += (Int64)L_var1 * L_var2; + return (sum); + } + + + + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) +{ + + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #2\n\t" + "orr %0, %0, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, lsl #3\n\t" + "add %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %4, %4, %0, lsl #3\n\t" + "sub %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #3\n\t" + "orr %0, %0, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #4\n\t" + "orr %0, %0, %1, lsr #28" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #5\n\t" + "orr %0, %0, %1, lsr #27" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #6\n\t" + "orr %0, %0, %1, lsr #26" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #12\n\t" + "orr %0, %0, %1, lsr #20" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #17\n\t" + "orr %0, %0, %1, lsr #15" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #18\n\t" + "orr %0, %0, %1, lsr #14" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4.h new file mode 100644 index 00000000..69a23a5d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4.h @@ -0,0 +1,424 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_v4.h + + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_ARM_V4 +#define FXP_MUL32_ARM_V4 + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + + +#if defined(PV_ARM_V4) + +#define preload_cache( a) + + + static inline Int32 shft_lft_1(Int32 L_var1) + { + Int32 x; + Int32 z = 1; /* rvct compiler problem */ + __asm + { + mov x, L_var1, asl 1 + teq L_var1, x, asr z + eorne x, INT32_MAX, L_var1, asr #31 + } + + return(x); + } + + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) + { + __asm + { + + mov L_var2, L_var2, asl #16 + mov L_var2, L_var2, asr #16 + mov L_var1, L_var1, asl #16 + mov L_var1, L_var1, asr #16 + + + mul L_var1, L_var2, L_var1 + } + + return L_var1; + + } + + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) + { + __asm + { + mov L_var2, L_var2, asl #16 + mov L_var2, L_var2, asr #16 + mov L_var1, L_var1, asr #16 + + mul L_var1, L_var2, L_var1 + } + return L_var1; + } + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) + { + __asm + { + mov L_var2, L_var2, asr #16 + mov L_var1, L_var1, asl #16 + mov L_var1, L_var1, asr #16 + + mul L_var1, L_var2, L_var1 + } + + return L_var1; + + } + + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) + { + __asm + { + mov L_var2, L_var2, asr #16 + mov L_var1, L_var1, asr #16 + + mul L_var1, L_var2, L_var1 + } + + return L_var1; + + } + + static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + __asm + { + mla L_add, L_var1, L_var2, L_add + } + return (L_add); + } + + + static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + mov L_var2, L_var2, asl #16 + mov L_var2, L_var2, asr #16 + mla L_add, L_var1, L_var2, L_add + } + return L_add; + } + + static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + mov L_var2, L_var2, asr #16 + mla L_add, L_var1, L_var2, L_add + } + return L_add; + } + + + static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) + { + + Int32 result64_hi; + Int32 rTmp0; + Int32 iTmp0; + __asm + { + mov rTmp0, exp_jw, asr #16 + mov rTmp0, rTmp0, asl #16 + mov iTmp0, exp_jw, asl #16 + smull rTmp0, result64_hi, x, rTmp0 + smlal iTmp0, result64_hi, y, iTmp0 + } + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2) + { + Int32 result64_hi; + __asm + { + mov L_var2, L_var2, asl #16 + smull L_var1, result64_hi, L_var2, L_var1 + } + return (result64_hi); + } + + + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2) + { + + Int32 result64_hi; + __asm + { + mov L_var2, L_var2, asr #16 + mov L_var2, L_var2, asl #16 + smull L_var1, result64_hi, L_var2, L_var1 + } + return (result64_hi); + + } + + static inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add) + { + + __asm + { + mov L_var2, L_var2, asl #16 + smlal L_var1, L_add, L_var2, L_var1 + } + + return (L_add); + } + + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) + { + uint32 b = (UInt32)(sum); + int32 c = Int32(sum >> 32); + __asm + { + smlal b, c, L_var1, L_var2 + } + return (((Int64(c)) << 32) | b); + } + + + static inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + __asm + { + smull L_var1, result64_hi, L_var2, L_var1 + } + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2) + { + __asm + { + smlal L_var1, L_add, L_var2, L_var1 + } + return L_add; + } + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2) + { + __asm + { + rsb L_var1, L_var1, #0 + smlal L_var1, L_sub, L_var2, L_var1 + } + return L_sub; + } + + + static inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #2 + orr result64_hi, result64_hi, result64_lo, lsr #30 + } + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + add L_add, L_add, result64_hi, asl #2 + add L_add, L_add, result64_lo, lsr #30 + } + return (L_add); + } + + + static inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #3 + orr result64_hi, result64_hi, result64_lo, lsr #29 + } + return (result64_hi); + } + + static inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + add L_add, L_add, result64_hi, asl #3 + add L_add, L_add, result64_lo, lsr #29 + } + return (L_add); + } + + static inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + sub L_sub, L_sub, result64_hi, asl #3 + sub L_sub, L_sub, result64_lo, lsr #29 + } + return (L_sub); + } + + static inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #4 + orr result64_hi, result64_hi, result64_lo, lsr #28 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #5 + orr result64_hi, result64_hi, result64_lo, lsr #27 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #6 + orr result64_hi, result64_hi, result64_lo, lsr #26 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #12 + orr result64_hi, result64_hi, result64_lo, lsr #20 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #17 + orr result64_hi, result64_hi, result64_lo, lsr #15 + } + return (result64_hi); + } + + + + + static inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #18 + orr result64_hi, result64_hi, result64_lo, lsr #14 + } + return (result64_hi); + } + + + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4_gcc.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4_gcc.h new file mode 100644 index 00000000..12740d7e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v4_gcc.h @@ -0,0 +1,625 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_v4_gcc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + + + +#ifndef FXP_MUL32_V4_ARM_GCC +#define FXP_MUL32_V4_ARM_GCC + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + + +#if defined (PV_ARM_GCC_V4) /* ARM_V4 GNU COMPILER */ + + +#define preload_cache( a) + + + static inline Int32 shft_lft_1(Int32 L_var1) + { + Int32 x; + register Int32 ra = L_var1; + Int32 z = INT32_MAX; + + asm volatile( + "mov %0, %1, asl #1\n\t" + "teq %1, %0, asr #1\n\t" + "eorne %0, %2, %1, asr #31" + : "=&r*i"(x) + : "r"(ra), + "r"(z)); + + return(x); + } + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mov %1, %2, asl #16\n\t" + "mov %1, %1, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mov %1, %2, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mov %1, %2, asl #16\n\t" + "mov %1, %1, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mov %1, %2, asr #16\n\t" + "mul %0, %1, %0" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb)); + + return (tmp1); + + } + + + + static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add) +{ + + Int32 tmp; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mla %0, %1, %2, %3" + : "=&r*i"(tmp) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp); + } + + + + static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %3, asl #16\n\t" + "mov %0, %0, asr #16\n\t" + "mla %1, %0, %2, %4" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp2); + } + + + + static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 tmp1; + Int32 tmp2; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %3, asr #16\n\t" + "mla %1, %0, %2, %4" + : "=&r*i"(tmp1), + "=&r*i"(tmp2) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (tmp2); + + } + + + + static inline Int32 cmplx_mul32_by_16(Int32 x, Int32 y, Int32 exp_jw) +{ + + Int32 rTmp0; + Int32 iTmp0; + Int32 result64_hi; + register Int32 ra = (Int32)x; + register Int32 rb = (Int32)y; + register Int32 rc = (Int32)exp_jw; + + + + asm volatile( + "mov %0, %5, asr #16\n\t" + "mov %1, %5, asl #16\n\t" + "mov %0, %0, asl #16\n\t" + : "=&r*i"(rTmp0), + "=&r*i"(iTmp0), + "=&r*i"(result64_hi) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + asm volatile( + "smull %0, %2, %3, %0\n\t" + "smlal %1, %2, %4, %1" + : "=&r*i"(rTmp0), + "=&r*i"(iTmp0), + "=&r*i"(result64_hi) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + + + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %4, asl #16\n\t" + "smull %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + + asm volatile( + "mov %0, %4, asr #16\n\t" + "mov %0, %0, asl #16\n\t" + "smull %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add) +{ + + Int32 rTmp0; + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)L_var1; + register Int32 rb = (Int32)L_var2; + register Int32 rc = (Int32)L_add; + + asm volatile( + "mov %0, %4, asl #16\n\t" + "mov %1, %5\n\t" + "smlal %2, %1, %0, %3" + : "=&r*i"(rTmp0), + "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) +{ + sum += (Int64)L_var1 * L_var2; + return (sum); + } + + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, asl #2\n\t" + "add %0, %4, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) +{ + + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %0, %0, %4" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %0, %4, %0" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile( + "smull %1, %0, %2, %3" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #2\n\t" + "orr %0, %0, %1, lsr #30" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_add; + + asm volatile("smull %1, %0, %2, %3\n\t" + "add %4, %4, %0, lsl #3\n\t" + "add %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + register Int32 rc = (Int32)L_sub; + + asm volatile("smull %1, %0, %2, %3\n\t" + "sub %4, %4, %0, lsl #3\n\t" + "sub %0, %4, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb), + "r"(rc)); + + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #3\n\t" + "orr %0, %0, %1, lsr #29" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #4\n\t" + "orr %0, %0, %1, lsr #28" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #5\n\t" + "orr %0, %0, %1, lsr #27" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #6\n\t" + "orr %0, %0, %1, lsr #26" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #12\n\t" + "orr %0, %0, %1, lsr #20" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #17\n\t" + "orr %0, %0, %1, lsr #15" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + + + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) +{ + Int32 result64_hi; + Int32 result64_lo; + register Int32 ra = (Int32)a; + register Int32 rb = (Int32)b; + asm volatile("smull %1, %0, %2, %3\n\t" + "mov %0, %0, lsl #18\n\t" + "orr %0, %0, %1, lsr #14" + : "=&r*i"(result64_hi), + "=&r*i"(result64_lo) + : "r"(ra), + "r"(rb)); + + return (result64_hi); + } + +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32_V4_ARM_GCC */ + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v5.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v5.h new file mode 100644 index 00000000..b2b69950 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_arm_v5.h @@ -0,0 +1,446 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_arm_v5.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_ARM_V5 +#define FXP_MUL32_ARM_V5 + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + + +#if defined(PV_ARM_V5) + +//#undef EXTENDED_ASM +#define EXTENDED_ASM +#define _ARM_V5_ + + + static inline Int32 shft_lft_1(Int32 L_var1) + { + __asm + { + qadd L_var1, L_var1, L_var1 + } + + return L_var1; + } + + + static inline Int32 fxp_mul_16_by_16(Int32 L_var1, Int32 L_var2) + { + __asm + { + smulbb L_var1, L_var1, L_var2 + } + return L_var1; + } + + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) + { + __asm + { + smulbb L_var1, L_var1, L_var2 + } + return L_var1; + } + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) + { + __asm + { + smultb L_var1, L_var1, L_var2 + } + return L_var1; + } + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) + { + __asm + { + smultt L_var1, L_var1, L_var2 + } + return L_var1; + } + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) + { + __asm + { + smulbt L_var1, L_var1, L_var2 + } + return L_var1; + } + + + + static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + __asm + { + smlabb L_add, L_var1, L_var2, L_add + } + return (L_add); + } + + static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + smlabb L_add, L_var1, L_var2, L_add + } + return L_add; + } + + static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + smlabt L_add, L_var1, L_var2, L_add + } + return L_add; + } + + + static inline Int32 fxp_mac_16_by_16_tb(const Int32 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + smlatb L_add, L_var1, L_var2, L_add + } + return L_add; + } + + static inline Int32 fxp_mac_16_by_16_tt(const Int32 L_var1, Int32 L_var2, Int32 L_add) + { + __asm + { + smlatt L_add, L_var1, L_var2, L_add + } + return L_add; + } + + static inline Int32 fxp_mac32_by_16(Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + __asm + { + smlawb L_add, L_var1, L_var2, L_add + } + return (L_add); + } + + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) + { + uint32 b = (UInt32)(sum); + int32 c = Int32(sum >> 32); + __asm + { + smlal b, c, L_var1, L_var2 + } + return (((Int64(c)) << 32) | b); + } + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2) + { + __asm + { + smlal L_var1, L_add, L_var2, L_var1 + } + return L_add; + } + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2) + { + __asm + { + rsb L_var1, L_var1, #0 + smlal L_var1, L_sub, L_var2, L_var1 + } + return L_sub; + } + + static inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + __asm + { + smull L_var1, result64_hi, L_var2, L_var1 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #2 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #30 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #30 +#endif + } + return (result64_hi); + } + + + static inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + add L_add, L_add, result64_hi, asl #2 + add L_add, L_add, result64_lo, lsr #30 + } + return (L_add); + } + + + static inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #3 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #29 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #29 +#endif + } + return (result64_hi); + } + + + + static inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + add L_add, L_add, result64_hi, asl #3 + add L_add, L_add, result64_lo, lsr #29 + } + return (L_add); + } + + + static inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + sub L_sub, L_sub, result64_hi, asl #3 + sub L_sub, L_sub, result64_lo, lsr #29 + } + return (L_sub); + } + + + static inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #4 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #28 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #28 +#endif + + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #5 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #27 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #27 +#endif + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #6 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #26 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #26 +#endif + + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #12 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #20 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #20 +#endif + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + __asm + { + smulwb result64_hi, L_var1, L_var2 + } + return (result64_hi); + } + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16(a, b) + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + __asm + { + smulwt result64_hi, L_var1, L_var2 + } + return (result64_hi); + } + + static inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #17 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #15 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #15 +#endif + } + return (result64_hi); + } + + + static inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx) + { + Int32 result64_hi; + + __asm + { + smulwt result64_hi, L_var1, cmplx + smlawb result64_hi, L_var2, cmplx, result64_hi + } + return (result64_hi); + + } + + static inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2) + { + Int32 result64_hi; + Int32 result64_lo; + __asm + { + smull result64_lo, result64_hi, L_var2, L_var1 + mov result64_hi, result64_hi, asl #18 +#ifdef EXTENDED_ASM + mov result64_lo, result64_lo, lsr #14 + orr result64_hi, result64_lo, result64_hi +#else + orr result64_hi, result64_hi, result64_lo, lsr #14 +#endif + } + return (result64_hi); + } + + +#define preload_cache( a) + + + + +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_equivalent.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_equivalent.h new file mode 100644 index 00000000..89ec8c44 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_equivalent.h @@ -0,0 +1,281 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_c_equivalent.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_C_EQUIVALENT +#define FXP_MUL32_C_EQUIVALENT + + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#include +#include "config.h" +#include "pv_audio_type_defs.h" + +#if defined(C_EQUIVALENT) + +#define preload_cache( a) + + static inline Int32 shft_lft_1(Int32 L_var1) + { + if (((L_var1 << 1) >> 1) == L_var1) + L_var1 <<= 1; + else + L_var1 = ((L_var1 >> 31) ^ INT32_MAX); + + return (L_var1); + + } + + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = (L_var1 << 16) >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = L_var1 >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = (L_var1 << 16) >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = L_var1 >> 16; + + L_var1 *= L_var2; + + return L_var1; + + } + + static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add) + { + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + + + + static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = (L_var2 << 16) >> 16; + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = L_var2 >> 16; + + L_add += L_var1 * L_var2; + + return L_add; + + } + + + + + + static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) + { + Int32 rTmp0 = (Int16)(exp_jw >> 16); + Int32 iTmp0 = exp_jw; + Int32 z; + + z = (Int32)(((Int64)x * (rTmp0 << 16)) >> 32); + z += (Int32)(((Int64)y * (iTmp0 << 16)) >> 32); + + return (z); + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) + { + Int32 z; + + z = (Int32)(((Int64) L_var1 * (L_var2 << 16)) >> 32); + return(z); + } + + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) + { + Int32 rTmp0 = (Int16)(L_var2 >> 16); + Int32 z; + + z = (Int32)(((Int64) L_var1 * (rTmp0 << 16)) >> 32); + + return(z); + } + + + static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + Int32 rTmp0 = L_var2 << 16; + + L_add += (Int32)(((Int64) L_var1 * rTmp0) >> 32); + + return(L_add); + } + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) + { + sum += (Int64)L_var1 * L_var2; + return (sum); + } + + static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 32); + } + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 32)); + } + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - (Int32)(((Int64)(a) * b) >> 32)); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 30); + } + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 30)); + } + + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 29); + } + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 29)); + } + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) + { + return (L_sub - (Int32)(((Int64)(a) * b) >> 29)); + } + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 28); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 27); + } + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 26); + } + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 20); + } + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 15); + } + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 14); + } + + + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc.h new file mode 100644 index 00000000..cea15a86 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc.h @@ -0,0 +1,249 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_c_msc_evc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + + +#ifndef FXP_MUL32_MSC_EVC +#define FXP_MUL32_MSC_EVC + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + +#if defined(PV_ARM_MSC_EVC_V4) + +#include "cmnintrin.h" + +#define preload_cache( a) + + static inline Int32 shft_lft_1(Int32 L_var1) + { + if (((L_var1 << 1) >> 1) == L_var1) + L_var1 <<= 1; + else + L_var1 = ((L_var1 >> 31) ^ INT32_MAX); + + return L_var1; + + } + + static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = (L_var1 << 16) >> 16; + + return (L_var1*L_var2); + + } + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + + static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2) + { + L_var2 = (L_var2 << 16) >> 16; + L_var1 = L_var1 >> 16; + + return (L_var1*L_var2); + + } + + + static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = (L_var1 << 16) >> 16; + + return (L_var1*L_var2); + + } + + + static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2) + { + L_var2 = L_var2 >> 16; + L_var1 = L_var1 >> 16; + + return (L_var1*L_var2); + + } + + static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add) + { + return (L_add + (L_var1*L_var2)); + } + + + + static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = (L_var2 << 16) >> 16; + + return (L_add + (L_var1*L_var2)); + + } + + + static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add) + { + L_var2 = L_var2 >> 16; + + return (L_add + (L_var1*L_var2)); + + } + + + static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw) + { + Int32 rTmp0 = (exp_jw >> 16) << 16; + Int32 iTmp0 = exp_jw << 16; + Int32 z; + + + z = _MulHigh(rTmp0, x); + z += _MulHigh(iTmp0, y); + + return (z); + } + + + static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2) + { + Int32 rTmp0 = L_var2 << 16; + + return(_MulHigh(rTmp0, L_var1)); + } + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + + + static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2) + { + Int32 rTmp0 = (Int16)(L_var2 >> 16); + + return(_MulHigh((rTmp0 << 16), L_var1)); + } + + + static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add) + { + + Int32 rTmp0 = (L_var2 << 16); + + return(L_add + _MulHigh(rTmp0, L_var1)); + } + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) + { + sum += (Int64)L_var1 * L_var2; + return (sum); + } + +#define fxp_mul32_Q31( a, b) _MulHigh( b, a) + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + _MulHigh(b, a)); + } + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - _MulHigh(b, a)); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 30); + } + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 30)); + } + + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 29); + } + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 29)); + } + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) + { + return (L_sub - (Int32)(((Int64)(a) * b) >> 29)); + } + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 28); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 27); + } + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 26); + } + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 20); + } + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 15); + } + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 14); + } + + + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc_armv5.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc_armv5.h new file mode 100644 index 00000000..2e8e3cee --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_c_msc_evc_armv5.h @@ -0,0 +1,173 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_c_msc_evc_armv5.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_MSC_EVC_ARMV5 +#define FXP_MUL32_MSC_EVC_ARMV5 + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + +#if defined(PV_ARM_MSC_EVC_V5) + +#include "armintr.h" +#include "cmnintrin.h" + +#define preload_cache( a) + +#define shft_lft_1( L_var1) _AddSatInt( L_var1, L_var1) + +#define fxp_mul_16_by_16bb( L_var1, L_var2) _SmulLo_SW_SL( L_var1, L_var2) + +#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b) + +#define fxp_mul_16_by_16tb( L_var1, L_var2) _SmulHiLo_SW_SL( L_var1, L_var2) + +#define fxp_mul_16_by_16bt( L_var1, L_var2) _SmulLoHi_SW_SL( L_var1, L_var2) + +#define fxp_mul_16_by_16tt( L_var1, L_var2) _SmulHi_SW_SL( L_var1, L_var2) + +#define fxp_mac_16_by_16( L_var1, L_var2, L_add) _SmulAddLo_SW_SL( L_add, L_var1, L_var2) + +#define fxp_mac_16_by_16_bb(a, b, c) fxp_mac_16_by_16( a, b, c) + +#define fxp_mac_16_by_16_bt( L_var1, L_var2, L_add) _SmulAddLoHi_SW_SL( L_add, L_var1, L_var2) + + + static inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx) + { + Int32 result64_hi; + + result64_hi = _SmulWHi_SW_SL(L_var1, cmplx); + result64_hi = _SmulAddWLo_SW_SL(result64_hi, L_var2, cmplx); + + return (result64_hi); + } + +#define fxp_mul32_by_16( L_var1, L_var2) _SmulWLo_SW_SL( L_var1, L_var2) + +#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b) + +#define fxp_mul32_by_16t( L_var1, L_var2) _SmulWHi_SW_SL( L_var1, L_var2) + +#define fxp_mac32_by_16( L_var1, L_var2, L_add) _SmulAddWLo_SW_SL( L_add, L_var1, L_var2) + + + static inline Int64 fxp_mac64_Q31(Int64 sum, const Int32 L_var1, const Int32 L_var2) + { + sum += (Int64)L_var1 * L_var2; + return (sum); + } + +#define fxp_mul32_Q31( a, b) _MulHigh( b, a) + + + static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b) + { + return (L_add + _MulHigh(b, a)); + } + + + static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b) + { + return (L_sub - _MulHigh(b, a)); + } + + + static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 30); + } + + static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 30)); + } + + + static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 29); + } + + static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add) + { + return (L_add + (Int32)(((Int64)(a) * b) >> 29)); + } + + static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub) + { + return (L_sub - (Int32)(((Int64)(a) * b) >> 29)); + } + + + static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 28); + } + + static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 27); + } + + static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 26); + } + + static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 20); + } + + static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 15); + } + + static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b) + { + return (Int32)(((Int64)(a) * b) >> 14); + } + + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_pentium.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_pentium.h new file mode 100644 index 00000000..13dccd18 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/fxp_mul32_pentium.h @@ -0,0 +1,50 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: fxp_mul32_pentium.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef FXP_MUL32_PENTIUM +#define FXP_MUL32_PENTIUM + + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "config.h" +#include "pv_audio_type_defs.h" + + + + + +#ifdef __cplusplus +} +#endif + + +#endif /* FXP_MUL32 */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.c new file mode 100644 index 00000000..3c4217e6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.c @@ -0,0 +1,456 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Description: +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: random_array[] = Array for storage of the power-scaled + random values of length "band_length" + Int32 + + band_length = Length of random_array[] + const Int + + pSeed = seed for random number generator + Int32* + + power_scale = scale factor for this particular band + const Int + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: Function returns the q-format the random vector is stored in. + + Pointers and Buffers Modified: + random_array[] = filled with random numbers scaled + to the correct power as defined by the input value power_scale. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function generates a vector of uniformly distributed random numbers for + the PNS block. The random numbers are each scaled by a scale_factor, + defined in Ref(2) as + + 2^(scale_factor/4) + ------------------ + sqrt(N*MEAN_NRG) + + where N == band_length, and MEAN_NRG is defined as... + + N-1 + ___ + 1 \ + --- > x(i)^2 + N /__ + i=0 + + And x is the unscaled vector from the random number generator. + + This function takes advantage of the fact that the portion of the + scale_factor that is divisible by 4 can be simply accounted for by varying + the q-format. + + The scaling of the random numbers is thus broken into the + equivalent equation below. + + 2^(scale_factor%4) 2^(floor(scale_factor/4)) + ------------------ * + sqrt(N*MEAN_NRG) + + + 2^(scale_factor%4) is stored in a simple 4-element table. + 2^(floor(scale_factor/4) is accounted for by adjusting the q-format. + sqrt(N*MEAN_NRG) is calculated and implemented via a polynomial approximation. +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall produce uniformly distributed random 32-bit integers, + with signed random values of average energy equal to the results of the ISO + code's multiplying factor discussed in the FUNCTION DESCRIPTION section. + + Please see Ref (2) for a detailed description of the requirements. +------------------------------------------------------------------------------ + REFERENCES + + (1) Numerical Recipes in C Second Edition + William H. Press Saul A. Teukolsky + William T. Vetterling Brian P. Flannery + Page 284 + + (2) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.12 (Perceptual Noise Substitution) + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + power_adj = scale_mod_4[power_scale & 3]; + + power = 0; + + FOR (k=band_length; k > 0; k--) + + *(pSeed) = *(pSeed) * 1664525L; + *(pSeed) = *(pSeed) + 1013904223L; + + temp = (Int)(*(pSeed) >> 16); + + power = power + ((temp*temp) >> 6); + + *(pArray) = (Int32)temp; + + pArray = pArray + 1; + + ENDFOR + + k = 0; + q_adjust = 30; + + IF (power) + THEN + + WHILE ( power > 32767) + + power = power >> 1; + k = k + 1; + + ENDWHILE + + k = k - 13; + + IF (k < 0) + THEN + k = -k; + IF ( k & 1 ) + THEN + power_adj = (power_adj*SQRT_OF_2)>>14; + ENDIF + q_adjust = q_adjust - ( k >> 1); + + ELSE IF (k > 0) + THEN + IF ( k & 1 ) + THEN + power_adj = (power_adj*INV_SQRT_OF_2)>>14; + ENDIF + q_adjust = q_adjust + ( k >> 1); + ENDIF + + pInvSqrtCoeff = inv_sqrt_coeff; + + inv_sqrt_power = (*(pInvSqrtCoeff)* power) >>15; + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff); + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + FOR ( k=INV_SQRT_POLY_ORDER - 1; k>0; k--) + + inv_sqrt_power = ( inv_sqrt_power * power)>>15; + + inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff); + + pInvSqrtCoeff = pInvSqrtCoeff + 1; + + ENDFOR + + inv_sqrt_power = (inv_sqrt_power*power_adj)>>13; + + FOR (k=band_length; k > 0; k--) + + pArray = pArray - 1; + + *(pArray) = *(pArray)*inv_sqrt_power; + + ENDFOR + + ENDIF + + q_adjust = q_adjust - (power_scale >> 2); + + return q_adjust; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "gen_rand_vector.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define SQRT_OF_2 23170 /* sqrt(2) in Q14 */ +#define INV_SQRT_OF_2 11585 /* 1/sqrt(2) in Q14 */ +#define INV_SQRT_POLY_ORDER 4 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +/* + * 2^([0:3]/4) = 1.0000 1.1892 1.4142 1.6818 + */ +const UInt scale_mod_4[4] = { 16384, 19484, 23170, 27554}; + +/* + * polynomial approx. in Q12 (type Int) + */ + +const Int inv_sqrt_coeff[INV_SQRT_POLY_ORDER+1] = + { 4680, -17935, 27697, -22326, 11980}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int gen_rand_vector( + Int32 random_array[], + const Int band_length, + Int32* pSeed, + const Int power_scale) +{ + + Int k; + UInt power_adj; + Int q_adjust = 30; + + Int32 temp; + Int32 seed; + Int32 power; + + Int32* pArray = &random_array[0]; + + Int32 inv_sqrt_power; + const Int *pInvSqrtCoeff; + + /* + * The out of the random number generator is scaled is such a way + * that is independent of the band length. + * The output is computed as: + * + * x(i) + * output = ------------------ * 2^(power_scale%4) 2^(floor(power_scale/4)) + * bl + * sqrt( SUM x(i)^2 ) + * 0 + * + * bl == band length + */ + + + /* + * get 2^(power_scale%4) + */ + + + power = 0; + + seed = *pSeed; + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + if (band_length < 0 || band_length > LONG_WINDOW) + { + return q_adjust; /* avoid any processing on error condition */ + } + + for (k = (band_length >> 1); k != 0; k--) + { + /*------------------------------------------------ + Numerical Recipes in C + Page 284 + ------------------------------------------------*/ + seed *= 1664525L; + seed += 1013904223L; + + temp = seed >> 16; + + seed *= 1664525L; + seed += 1013904223L; + + /* shift by 6 make room for band length accumulation */ + power += ((temp * temp) >> 6); + *pArray++ = temp; + + temp = seed >> 16; + power += ((temp * temp) >> 6); + *pArray++ = temp; + + } /* END for (k=half_band_length; k > 0; k--) */ + + + *pSeed = seed; + + /* + * If the distribution is uniform, the power is expected to use between + * 28 and 27 bits, by shifting down by 13 bits the power will be a + * Q15 number. + * For different band lengths, the power uses between 20 and 29 bits + */ + + + k = 0; + + if (power) + { + /* + * approximation requires power between 0.5 < power < 1 in Q15. + */ + + while (power > 32767) + { + power >>= 1; + k++; + } + + /* + * expected power bit usage == 27 bits + */ + + k -= 13; + + power_adj = scale_mod_4[power_scale & 3]; + + if (k < 0) + { + k = -k; + if (k & 1) + { /* multiply by sqrt(2) */ + power_adj = (UInt)(((UInt32) power_adj * SQRT_OF_2) >> 14); + } + q_adjust -= (k >> 1); /* adjust Q instead of shifting up */ + } + else if (k > 0) + { + if (k & 1) + { /* multiply by 1/sqrt(2) */ + power_adj = (UInt)(((UInt32) power_adj * INV_SQRT_OF_2) >> 14); + } + q_adjust += (k >> 1); /* adjust Q instead of shifting down */ + } + + /* + * Compute 1/sqrt(power), where 0.5 < power < 1.0 is approximated + * using a polynomial order INV_SQRT_POLY_ORDER + */ + + pInvSqrtCoeff = inv_sqrt_coeff; + + inv_sqrt_power = (*(pInvSqrtCoeff++) * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff++); + inv_sqrt_power = (inv_sqrt_power * power) >> 15; + inv_sqrt_power += *(pInvSqrtCoeff); + + inv_sqrt_power = (inv_sqrt_power * power_adj) >> 13; + + pArray = &random_array[0]; + + for (k = (band_length >> 1); k != 0; k--) + { + temp = *(pArray) * inv_sqrt_power; + *(pArray++) = temp; + temp = *(pArray) * inv_sqrt_power; + *(pArray++) = temp; + } /* END for (k=half_band_length; k > 0; k--) */ + + } /* if(power) */ + + /* + * Adjust Q with the value corresponding to 2^(floor(power_scale/4)) + */ + + q_adjust -= (power_scale >> 2); + + return (q_adjust); + +} /* gen_rand_vector */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.h new file mode 100644 index 00000000..3ac55495 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/gen_rand_vector.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: gen_rand_vector.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for gen_rand_vector. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef gen_rand_vector_H +#define gen_rand_vector_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int gen_rand_vector( + Int32 random_array[], + const Int band_length, + Int32 *pSeed, + const Int power_scale); +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.c new file mode 100644 index 00000000..67a958ea --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.c @@ -0,0 +1,396 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adif_header.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that contains the current state + of this instance of the library, of data type pointer to + tDec_Int_File + + pScratchPCE = pointer to a ProgConfig structure used as scratch in the + the function get_prog_config. of data type pointer to + ProgConfig + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + The function returns 0 if no error occurred, non-zero otherwise. + + Pointers and Buffers Modified: + pVars->adif_header contents are updated with the some of the ADIF header + contents + pVars->tempProgConfig contents are overwritten with last PCE found, + which is most likely the first one found. + pVars->prog_config contents are updated with the first PCE found. + pVars->inputStream contents are modify in such a way that the + stream is moved further along in the buffer. + pVars->SFBWidth128 contents may be updated. + pVars->winSeqInfo contents may be updated. + pScratchPCE contents may be updated. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads in the ADIF Header found at the front of ADIF streams. + If the header is not found an error is returned. An ADIF header can contain + from zero to sixteen program configuration elements (PCE). This function, and + the rest of the library, saves and uses the first PCE found. +------------------------------------------------------------------------------ + REQUIREMENTS + + Function shall not use static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits( + neededBits = 2 * LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( theIDFromFile ) + + CALL getbits( + neededBits = 2 * LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp ) + + theIDFromFile = (theIDFromFile << (2*LEN_BYTE)) | temp; + + IF (theIDFromFile != ADIF_ID) + THEN + + pInputStream->usedBits -= (4 * LEN_BYTE); + + status = -1; + ELSE + CALL getbits( + neededBits = LEN_COPYRT_PRES, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp ) + + IF (temp != FALSE) THEN + FOR (i = LEN_COPYRT_ID; i > 0; i--) + CALL getbits( + neededBits = LEN_BYTE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + + END FOR + END IF + + CALL getbits( + neededBits = LEN_ORIG + LEN_HOME, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + + CALL getbits( + neededBits = LEN_BS_TYPE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( bitStreamType ) + + CALL getbits( + neededBits = LEN_BIT_RATE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( pHeader->bitrate ) + + CALL getbits( + neededBits = LEN_NUM_PCE, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( numConfigElementsMinus1 ) + + FOR ( i = numConfigElementsMinus1; + (i >= 0) && (status == SUCCESS); + i--) + + IF (bitStreamType == CONSTANT_RATE_BITSTREAM) THEN + CALL getbits( + neededBits = LEN_ADIF_BF, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + END IF + + CALL get_prog_config( + pVars = pVars) + MODIFYING( pVars->prog_config ) + RETURNING( status ) + + END FOR + END IF + + RETURN (status) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_adif_const.h" + +#include "s_progconfig.h" +#include "s_adif_header.h" +#include "s_bits.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" +#include "s_tdec_int_file.h" + +#include "get_prog_config.h" +#include "ibstream.h" + +#include "get_adif_header.h" +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/* + * This constant is simply the characters 'A' 'D' 'I' 'F' compressed into + * a UInt32. Any possible endian problems that exist must be solved by + * the function that fills the buffer and getbits(), or this constant and + * the rest of the bit stream will not work. + */ +#define ADIF_ID (0x41444946) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int get_adif_header( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE) +{ + Int i; + UInt32 temp; + Int numConfigElementsMinus1; + Int bitStreamType; + UInt32 theIDFromFile; + + BITS *pInputStream = &pVars->inputStream; + ADIF_Header *pHeader = &pVars->scratch.adif_header; + Int status = SUCCESS; + + /* + * The ADIF_ID field is 32 bits long, one more than what getbits() can + * do, so read the field in two parts. There is no point in saving the + * string - it either matches or it does not. If it matches, it must + * have been 'ADIF' + */ + + theIDFromFile = get17_n_lessbits((2 * LEN_BYTE), pInputStream); + + temp = get17_n_lessbits((2 * LEN_BYTE), pInputStream); + + theIDFromFile = (theIDFromFile << (2 * LEN_BYTE)) | temp; + + + if (theIDFromFile != ADIF_ID) + { + /* + * Rewind the bit stream pointer so a search for ADTS header + * can start at the beginning. + */ + + pInputStream->usedBits -= (4 * LEN_BYTE); + + /* + * The constant in the next line needs to be updated when + * error handling method is determined. + */ + status = -1; + } + else + { + /* + * To save space, the unused fields are read in, but not saved. + */ + + /* copyright string */ + temp = + get1bits(/* LEN_COPYRT_PRES,*/ + pInputStream); + + if (temp != FALSE) + { + /* + * Read in and ignore the copyright string. If restoring + * watch out for count down loop. + */ + + for (i = LEN_COPYRT_ID; i > 0; i--) + { + get9_n_lessbits(LEN_BYTE, + pInputStream); + } /* end for */ + + /* + * Make sure to terminate the string with '\0' if restoring + * the the copyright string. + */ + + } /* end if */ + + /* Combine the original/copy and fields into one call */ + get9_n_lessbits( + LEN_ORIG + LEN_HOME, + pInputStream); + + bitStreamType = + get1bits(/* LEN_BS_TYPE,*/ + pInputStream); + + pHeader->bitrate = + getbits( + LEN_BIT_RATE, + pInputStream); + + /* + * Read in all the Program Configuration Elements. + * For this library, only one of the up to 16 possible PCE's will be + * saved. Since each PCE must be read, a temporary PCE structure is + * used, and if that PCE is the one to use, it is copied into the + * single PCE. This is done inside of get_prog_config() + */ + + numConfigElementsMinus1 = get9_n_lessbits(LEN_NUM_PCE, + pInputStream); + + for (i = numConfigElementsMinus1; + (i >= 0) && (status == SUCCESS); + i--) + { + /* + * For ADIF contant bit rate streams, the _encoder_ buffer + * fullness is transmitted. This version of an AAC decoder has + * no use for this variable; yet it must be read in to move + * the bitstream pointers. + */ + + if (bitStreamType == CONSTANT_RATE_BITSTREAM) + { + getbits( + LEN_ADIF_BF, + pInputStream); + } /* end if */ + + pVars->adif_test = 1; + /* Get one program configuration element */ + status = + get_prog_config( + pVars, + pScratchPCE); + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE) && + pVars->mc_info.audioObjectType == MP4AUDIO_AAC_LC) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = UPSAMPLING; + pVars->sbrDecoderData.SbrChannel[1].syncState = UPSAMPLING; + } +#endif + + + + } /* end for */ + + + } /* end 'else' of --> if (theIDFromFile != ADIF_ID) */ + + return status; + +} /* end get_adif_header */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.h new file mode 100644 index 00000000..0f8ecec0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adif_header.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adif_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_adif_header.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ADIF_HEADER_H +#define GET_ADIF_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CONSTANT_RATE_BITSTREAM (0) +#define VARIABLE_RATE_BITSTREAM (1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_adif_header( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.c new file mode 100644 index 00000000..0e3fc058 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.c @@ -0,0 +1,636 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adts_header.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = Pointer to structure that holds file-scope variables. + [ tDec_Int_File * ] + + pSyncword = Pointer to variable that holds the 28-bit fixed + header upon the exit of this function. [ UInt32 * ] + + pInvoke = Pointer to variable that keeps track of how many + "short" (14 bit) headers have been successfully + parsed from the bitstream. [ Int * ] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + Status = SUCCESS or ERROR CODE + + Pointers and Buffers Modified: + pVars->prog_config Updated with program information data as read from + the ADTS header. + + pSyncword Value pointed to is updated with the contents of + the 28-bit fixed header. + + pInvoke Value pointed to is updated to reflect the number + of successful "short" (14 bit) headers that have + been successfully parsed from the bitstream. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Acronym Definitions + ADTS Audio Data Transport Stream + CRC Cyclic Redundancy Code + + This function calls find_adts_syncword to find the next ADTS header. Until + three consistent headers have been read, the syncword used for detection + consists of the 12-bit syncword and the 2-bit Layer. After three consistent + headers are read, the entire fixed header is used for a robust 28-bit + syncword. + + Configuration information is then extracted from the bitstream. + + The bitstream information is packed as follows. + Comments about the correct interpretation of these bits are contained within + the code. + + CRC_absent sampling_rate_idx + \ / \ + \ / \ + \ Profile / \ UNUSED + \ / \ / \ / +|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25| + \ _______________ / | \ / \ / + \-------|0xFFF syncword |-------/ | Layer == '00' for AAC \ / + \-------------/ | \ / + | \/ + ID == '1' for MPEG-2 AAC channel_config + copyright_id_bit == '0' for MPEG-4 AAC + / + home / + / / +|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42| + | \ \ _____________ / + | \ \--------|frame length |---------/ + orig_copy \ \-----------/ + \ ______________________________ + copyright_id_start | TOTAL HEADER LENGTH: 56 bits| + |-----------------------------| +|43|44|45|46|47|48|49|50|51|52|53|54|55| | FIXED HEADER BITS 00-27 | + \ _______________ / | | | VARIABLE HEADER BITS 28-55 | + \-----|buffer_fullness|----/ \ / |_____________________________| + \-------------/ | + headerless_frames + + In addition to the bits displayed above, if the value CRC_absent is '0' an + additional 16 bits corresponding to a CRC word are read from the bitstream, + following the header. +------------------------------------------------------------------------------ + REQUIREMENTS + + After the ADTS syncword is detected, this function shall parse the + information residing behind the syncword in the bitstream. +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 13818-7:1997(E) + Part 7 + Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS) + + (2) ISO/IEC 11172-3:1993(E) + Part 3 + Subpart 2.4.3 The audio decoding process + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those UIntending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (*(pInvoke) > 3) + + CALL find_adts_syncword( + pSyncword, + &(pVars->inputStream), + LENGTH_FIXED_HEADER, + MASK_28BITS); + RETURNING status + ELSE + + *(pSyncword) = SYNCWORD_15BITS; + + CALL find_adts_syncword( + pSyncword, + &(pVars->inputStream), + LENGTH_SYNCWORD, + ID_BIT_FILTER); + + MODIFYING *(pSyncword) = 28-bit fixed header (long syncword) + RETURNING status + + CALL getbits( + (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD), + &(pVars->inputStream)); + + MODIFYING pVars->inputStream + RETURNING adts_header = remaining bits in the fixed header + + *(pSyncword) <<= 13; + *(pSyncword) = *(pSyncword) OR adts_header; + + pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) AND 0x0001; + + lower_16 = (UInt)adts_header; + + pVars->prog_config.profile = (lower_16 >> 10) AND 0x3; + + pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) AND 0xF; + + channel_configuration = (lower_16 >> 2) AND 0x7; + + channel_configuration = channel_configuration - 1; + pVars->prog_config.front.ele_is_cpe[0] = channel_configuration; + + pVars->prog_config.front.num_ele = 1; + + pVars->prog_config.front.ele_tag[0] = 0; + + pVars->prog_config.mono_mix.present = 0; + pVars->prog_config.stereo_mix.present = 0; + pVars->prog_config.matrix_mix.present = 0; + + CALL set_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + &(pVars->prog_config), + pVars->pWinSeqInfo, + pVars->SFBWidth128); + MODIFYING pVars->mc_info = multi-channel configuration information + RETURNING status = SUCCESS/FAILURE + + IF ( (*pInvoke) != 0) + CALL check_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + FALSE); + RETURNING status = SUCCESS/FAILURE + ELSE + CALL check_mc_info( + &(pVars->mc_info), + &(pVars->savedMCInfo), + TRUE); + MODIFYING pVars->savedMCInfo = pVars->mc_info + RETURNING status = SUCCESS/FAILURE + ENDIF + + IF (status == SUCCESS) + (*pInvoke) = (*pInvoke) + 1; + ELSE + (*pInvoke) = 0; + ENDIF + + ENDIF + + CALL getbits( + LENGTH_VARIABLE_HEADER, + &(pVars->inputStream)); + RETURNING adts_header = 28-bits (the contents of the variable header.) + + pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) AND 0x1FFF; + + lower_16 = (UInt)adts_header; + + pVars->prog_config.buffer_fullness = (lower_16 >> 2) AND 0x7FF; + + pVars->prog_config.headerless_frames = (lower_16 AND 0x0003); + + IF (pVars->prog_config.CRC_absent == 0) + + CALL getbits( + LENGTH_CRC, + &(pVars->inputStream) ); + RETURNING pVars->prog_config.CRC_check = 16-bit CRC + + ENDIF + + pVars->default_config = 0; + + IF (byte_align_offset > 7) + status = 1; + ENDIF + + return (status); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" +#include "set_mc_info.h" +#include "find_adts_syncword.h" +#include "get_adts_header.h" +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LENGTH_VARIABLE_HEADER 28 +#define LENGTH_FIXED_HEADER 28 +#define LENGTH_SYNCWORD 15 +#define LENGTH_CRC 16 + +#define ID_BIT_FILTER 0x7FFB +#define SYNCWORD_15BITS 0x7FF8 +#define MASK_28BITS 0x0FFFFFFFL + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_adts_header( + tDec_Int_File *pVars, + UInt32 *pSyncword, + Int *pInvoke, + Int CorrectlyReadFramesCount) +{ + UInt32 adts_header; + UInt lower_16; + Int status = SUCCESS; + UInt channel_configuration; + + /* + * Search for the LONG ADTS syncword (comprised of the entire fixed header) + * if the number of CorrectlyReadFrames is > CorrectlyReadFramesCount + * + * Otherwise, search for just the short syncword. + */ + if (*(pInvoke) > CorrectlyReadFramesCount) + { + /* + * Find the long ADTS syncword + * (comprised of the entire ADTS fixed header) + */ + + status = find_adts_syncword(pSyncword, + &(pVars->inputStream), + LENGTH_FIXED_HEADER, + MASK_28BITS); + } + else + { + + *(pSyncword) = SYNCWORD_15BITS; + + status = find_adts_syncword(pSyncword, + &(pVars->inputStream), + LENGTH_SYNCWORD, + ID_BIT_FILTER); + + /* + * Extract the data from the header following the syncword + */ + adts_header = getbits((LENGTH_FIXED_HEADER - LENGTH_SYNCWORD), + &(pVars->inputStream)); + + *(pSyncword) <<= (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD); + *(pSyncword) |= adts_header; + + /* Denotes whether a CRC check should be performed */ + pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) & 0x0001; + + /* + * All the unread bits in adts_header reside in the lower + * 16-bits at this point. Perform a typecast for faster + * execution on 16-bit processors. + */ + lower_16 = (UInt)adts_header; + + /* + * Profile consists of 2 bits, which indicate + * the profile used. + * + * '00' AAC_MAIN profile + * '01' AAC_LC (Low Complexity) profile + * '10' AAC_SSR (Scaleable Sampling Rate) profile + * '11' AAC_LTP (Long Term Prediction) profile + */ + pVars->prog_config.profile = (lower_16 >> 10) & 0x3; + + if (pVars->prog_config.profile == MP4AUDIO_AAC_SSR) + { + status = 1; /* Not supported */ + } + + /* + * Sampling_rate_idx consists of 4 bits + * see Ref #1 for their interpretation. + */ + pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) & 0xF; + + /* + * private_bit is a bit for private use. ISO/IEC will not make + * use of this bit in the future. + * + * We currently make no use of it, but parsing the information + * from the bitstream could be easily implemented with the + * following instruction... + * + * private_bit = (lower_16 & 0x0400) >> 10; + */ + + /* + * These 3 bits indicate the channel configuration used. + * + * If '0' then the channel configuration is unspecified here, + * and must be given by a program configuration element in + * the raw data block. + * + * If '1' then the channel configuration is MONO. + * If '2' then the channel configuration is STEREO + * + * 3-7 represent channel configurations which this library + * will not support in the forseeable future. + */ + channel_configuration = (lower_16 >> 2) & 0x7; + /* do not support more than 2 channels */ + if (channel_configuration > 2) + { + status = 1; + } + + /* + * The following 2 bits encode copyright information. + * original_copy is '0' if there is no copyright in the bitstream. + * '1' if the bitstream is copyright protected. + * + * home is '0' for a copy, '1' for an original. + * + * PacketVideo currently does nothing with this information, + * however, parsing the data from the bitstream could be easily + * implemented with the following instructions... + * + * original_copy = (lower_16 >> 1) & 0x1; + * + * home = (lower_16 & 0x1); + * + */ + + /* Set up based on information extracted from the ADTS FIXED header */ + + /* This equals 1 for STEREO, 0 for MONO */ + if (channel_configuration) + { + channel_configuration--; + } + pVars->prog_config.front.ele_is_cpe[0] = channel_configuration; + + /* This value is constant for both MONO and STEREO */ + pVars->prog_config.front.num_ele = 1; + + /* ADTS does not specify this tag value - do we even use it? */ + pVars->prog_config.front.ele_tag[0] = 0; + + /* Disable all mix related variables */ + pVars->prog_config.mono_mix.present = 0; + pVars->prog_config.stereo_mix.present = 0; + pVars->prog_config.matrix_mix.present = 0; + + /* enter configuration into MC_Info structure */ + if (status == SUCCESS) + { + /* profile + 1 == audioObjectType */ + status = + set_mc_info( + &(pVars->mc_info), + (tMP4AudioObjectType)(pVars->prog_config.profile + 1), + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /* changed from pVars->pWinSeqInfo, */ + pVars->SFBWidth128); + + } /* if (status == SUCCESS) */ + + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE)) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_ACTIVE; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_ACTIVE; + } +#endif + + + /* + * The tag and is_cpe will be checked in huffdecode, + * remove this check routine. + */ + /*if (status == SUCCESS) + *{ + * if ( (*pInvoke) != 0) + * { + * status = + * check_mc_info( + * &(pVars->mc_info), + * &(pVars->savedMCInfo), + * FALSE); + * } + * else + * { + * status = + * check_mc_info( + * &(pVars->mc_info), + * &(pVars->savedMCInfo), + * TRUE); + * } + * + *}*/ /* if (status == SUCCESS) */ + + /* + * This keeps track of how many headers have been read in the file. + * After the three successful headers with the same configuration + * are read in, the entire ADTS fixed header is used as the syncword + * for a more robust 28-bit long syncword + */ + + if (status == SUCCESS) + { + (*pInvoke)++; + } + else + { + (*pInvoke) = 0; + } + + } /* END if (*(pInvoke) > 3) */ + + /* Grab the bits in the ADTS variable header */ + adts_header = getbits( + LENGTH_VARIABLE_HEADER, + &(pVars->inputStream)); + /* + * copyright_identification bit is a single bit of the 72-bit + * copyright_id field. This consists of a 8-bit copyright identifier + * and a 64-bit copyright_number. 72 headers must be decoded + * to reconstruct the entire copyright_id field. + * + * copyright_identification_start is a single bit flagging + * the beginning bit of the copyright_id field. '1' for start of + * copyright_id, '0' otherwise. + * + * + * PacketVideo currently does nothing with this information, + * however, parsing the data from the bitstream could be easily + * implemented with the following instructions... + * + * copyright_id_bit = ((UInt)(adts_header >> 27)) & 0x1; + * + * copyright_id_start = ((UInt)(adts_header >> 26)) & 0x1; + */ + + /* + * frame_length is a 13-bit field which indicates the length, + * in bytes, of the frame including error_check and headers. + * This information can theoretically be used to help verify syncwords. + */ + pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) & 0x1FFF; + + /* + * All the unread bits in adts_header reside in the lower + * 16-bits at this point. Perform a typecast for faster + * execution on 16-bit processors. + */ + lower_16 = (UInt)adts_header; + + /* + * Indicates the number of 32-bit words remaining in the + * encoder buffer after the encoding of the first raw + * data block. This value is 0x7ff for variable bit + * rate encoders, since buffer fullness does not apply + * to Variable Bit Rate (VBR) encoders. + */ + pVars->prog_config.buffer_fullness = (lower_16 >> 2) & 0x7FF; + + /* + * headerless_frames indicates the number of + * frames with no headers to be processed before the reading + * in of the next header. + * + * In ADTS, up to 4 "no header frames" can exist between + * syncwords. + * + * EXAMPLES: + * + * Legend: (Sync words denoted by X, frames + * deonted by FRAME_#) + * + * Example(1): The ADTS sequence below packs 5 + * frames per header. + * Here, headerless_frames would always be read in as "4" + * + * |X||FRAME_0||FRAME_1||FRAME_2||FRAME_3||FRAME_4||X||FRAME_0| + * + * Example(2): The ADTS sequence below packs 1 frame per header. + * Here, headerless_frames would always be read in as "0" + * + * |X||FRAME_0||X||FRAME_1||X||FRAME_2| + * + */ + pVars->prog_config.headerless_frames = (lower_16 & 0x0003); + + if (pVars->prog_config.CRC_absent == 0) + { + pVars->prog_config.CRC_check = (UInt)getbits( + LENGTH_CRC, + &(pVars->inputStream)); + } + + /* pVars->current_program = 0; */ /* shall be set after PCE is read */ + + return (status); + +} /* END get_adts_header */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.h new file mode 100644 index 00000000..0bf711ff --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_adts_header.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_adts_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file has the function declaration for get_adts_header(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ADTS_HEADER_H +#define GET_ADTS_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_adts_header( + tDec_Int_File *pVars, + UInt32 *pSyncword, + Int *pInvoke, + Int CorrectlyReadFramesCount); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.c new file mode 100644 index 00000000..f4e26dd2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.c @@ -0,0 +1,644 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_audio_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, + pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly + for calling set_mc_info. Data type pointer to tDec_Int_File + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if successfully decoded AudioSpecificConfig + 1 if un-supported config is used for this release + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the information read in. + pVars->mc_info contents are updated with channel information. + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the bitstream for the structure "AudioSpecificConfig", + and sets the decoder configuration that is needed by the decoder to be able + to decode the media properly. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + temp = CALL getbits( + neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream = pInputStream) + MODIFYING (pInputStream) + RETURNING (temp) + + audioObjectType = (temp & 0x1f0) >> 4; + + pVars->prog_config.profile = audioObjectType; + + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + IF (pVars->prog_config.sampling_rate_idx == 0xf) + THEN + sampling_rate = CALL getbits( + neededBits = LEN_SAMP_RATE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (sampling_rate) + ENDIF + + channel_config = CALL getbits( + neededBits = LEN_CHAN_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (channel_config) + + IF (channel_config > 2) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_AAC_MAIN) OR + (audioObjectType == MP4AUDIO_AAC_LC) OR + (audioObjectType == MP4AUDIO_AAC_SSR) OR + (audioObjectType == MP4AUDIO_LTP) OR + (audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1)) + THEN + status = CALL get_GA_specific_config( + pVars = pVars, + channel_config = channel_config, + audioObjectType = audioObjectType, + pInputStream = pInputStream); + MODIFYING (pVars->mc_info,channel_config,pInputStream) + RETURNING (status) + + ENDIF + + IF (audioObjectType == MP4AUDIO_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_HVXC) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_TTSI) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == 13) OR (audioObjectType == 14) OR + (audioObjectType == 15) OR (audioObjectType == 16)) + THEN + status = 1; + ENDIF + + IF (((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1)) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_CELP) + THEN + status = 1; + ENDIF + + IF (audioObjectType == MP4AUDIO_ER_HVXC) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + status = 1; + ENDIF + + IF ((audioObjectType == MP4AUDIO_ER_AAC_LC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_TWINVQ) OR + (audioObjectType == MP4AUDIO_ER_BSAC) OR + (audioObjectType == MP4AUDIO_ER_AAC_LD) OR + (audioObjectType == MP4AUDIO_ER_CELP) OR + (audioObjectType == MP4AUDIO_ER_HVXC) OR + (audioObjectType == MP4AUDIO_ER_HILN) OR + (audioObjectType == MP4AUDIO_PARAMETRIC)) + THEN + epConfig = CALL getbits( + neededBits = LEN_EP_CONFIG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (epConfig) + + IF (epConfig == 2) + THEN + status = 1; + ENDIF + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "get_audio_specific_config.h" +#include "get_ga_specific_config.h" +#include "ibstream.h" +#include "sfb.h" /* Where samp_rate_info[] is declared */ +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_audio_specific_config(tDec_Int_File * const pVars) +{ + + UInt temp; + tMP4AudioObjectType audioObjectType; + //UInt32 sampling_rate; + UInt channel_config; + UInt syncExtensionType; + UInt extensionAudioObjectType = 0; + UInt extensionSamplingFrequencyIndex = 0; + BITS *pInputStream; + Int status; + + status = SUCCESS; + + pInputStream = &(pVars->inputStream); + + pVars->mc_info.upsamplingFactor = 1; /* default to regular AAC */ + + temp = get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX, + pInputStream); + + /* + * The following code can directly set the values of elements in + * MC_Info, rather than first setting the values in pVars->prog_config + * and then copy these values to MC_Info by calling set_mc_info. + * In order to keep consistent with get_prog_config (ADIF) and + * get_adts_header (ADTS), the code here is still copying + * the info, and set the pVars->current_program = 0 + */ + + /* AudioObjectType */ + audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4); + + pVars->mc_info.ExtendedAudioObjectType = audioObjectType; /* default */ + /* saving an audioObjectType into a profile field */ + /* pVars->prog_config.profile = audioObjectType; */ + + /* sampling rate index */ + pVars->prog_config.sampling_rate_idx = temp & 0xf; + + if (pVars->prog_config.sampling_rate_idx > 0xb) + { + /* + * Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp) + * 7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape + */ + if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */ + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); /* future use */ + } + + status = 1; + } + + channel_config = get9_n_lessbits(LEN_CHAN_CONFIG, + pInputStream); + + if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled)) + { + /* + * AAC lib does not support more than two channels + * signal error when in decoder mode + * do not test when in utility mode + */ + status = 1; + + } + + if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS) + { + /* to disable explicit backward compatiblity check */ + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + pVars->mc_info.sbrPresentFlag = 1; + + if (audioObjectType == MP4AUDIO_PS) + { + pVars->mc_info.psPresentFlag = 1; + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + } + + extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */ + get9_n_lessbits(LEN_SAMP_RATE_IDX, + pInputStream); + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + + audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE , + pInputStream); + } + + + if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN) ||*/ + (audioObjectType == MP4AUDIO_AAC_LC) || + /*(audioObjectType == MP4AUDIO_AAC_SSR) ||*/ + (audioObjectType == MP4AUDIO_LTP) /*||*/ + /*(audioObjectType == MP4AUDIO_AAC_SCALABLE) ||*/ + /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS)) + { + status = get_GA_specific_config(pVars, + pInputStream, + channel_config, + audioObjectType); + + /* + * verify that Program config returned a supported audio object type + */ + + if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) && + (pVars->mc_info.audioObjectType != MP4AUDIO_LTP)) + { + return 1; /* status != SUCCESS invalid aot */ + } + } + else + { + return 1; /* status != SUCCESS invalid aot or invalid parameter */ + } + + /* + * SBR tool explicit signaling ( backward compatible ) + */ + if (extensionAudioObjectType != MP4AUDIO_SBR) + { + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + + if (syncExtensionType == 0x2b7) + { + extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */ + LEN_OBJ_TYPE, + pInputStream); + + if (extensionAudioObjectType == MP4AUDIO_SBR) + { + pVars->mc_info.sbrPresentFlag = get1bits(pInputStream); /* sbrPresentFlag */ + if (pVars->mc_info.sbrPresentFlag == 1) + { + extensionSamplingFrequencyIndex = + get9_n_lessbits( /* extensionSamplingFrequencyIndex */ + LEN_SAMP_RATE_IDX, + pInputStream); + if (pVars->aacPlusEnabled == TRUE) + { +#ifdef AAC_PLUS + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = FALSE; + } + + pVars->mc_info.bDownSampledSbr = TRUE; + } + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + +#endif + } + + if (extensionSamplingFrequencyIndex == 0x0f) + { + /* + * sampling rate not listed in Table 1.6.2, + * this release does not support this + */ + /*sampling_rate = getbits( LEN_SAMP_RATE, + pInputStream);*/ + getbits(LEN_SAMP_RATE, pInputStream); + } + /* syncExtensionType */ + syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE, + pInputStream); + if (syncExtensionType == 0x548) + { + pVars->mc_info.psPresentFlag = get1bits(pInputStream); /* psPresentFlag */ + if (pVars->mc_info.psPresentFlag) + { + extensionAudioObjectType = MP4AUDIO_PS; + } + } + else + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + } + + pVars->mc_info.ExtendedAudioObjectType = (/*eMP4AudioObjectType*/ tMP4AudioObjectType)extensionAudioObjectType; + } + } + } + else if (!status) + { + /* + * Rewind bitstream pointer so that the syncExtensionType reading has no + * effect when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE; + +#ifdef AAC_PLUS + + /* + * For implicit signalling, no hint that sbr or ps is used, so we need to + * check the sampling frequency of the aac content, if lesser or equal to + * 24 KHz, by defualt upsample, otherwise, do nothing + */ + if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE) && + audioObjectType == MP4AUDIO_AAC_LC) + { + pVars->mc_info.upsamplingFactor = 2; + pVars->prog_config.sampling_rate_idx -= 3; + pVars->mc_info.sbrPresentFlag = 1; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + } +#endif + + } + } + else /* MP4AUDIO_SBR was detected */ + { + /* + * Set the real output frequency use by the SBR tool, define tentative upsample ratio + */ + if (pVars->aacPlusEnabled == TRUE) + { +#ifdef AAC_PLUS + pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) == + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1; + + if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx) + { + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = FALSE; + } + pVars->mc_info.bDownSampledSbr = TRUE; + } + pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex; + + + +#endif + + + + + } + + } /* if ( extensionAudioObjectType != MP4AUDIO_SBR ) */ + + /* + * The following object types are not supported in this release, + * however, keep these interfaces for future implementation + */ + + /* + *if (audioObjectType == MP4AUDIO_CELP) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_TTSI) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == 13) || (audioObjectType == 14) || + * (audioObjectType == 15) || (audioObjectType == 16)) + *{ + * status = 1; + *} + */ + + /* The following objects are Amendment 1 objects */ + /* + *if (((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1)) + *{ + */ + /* + * should call get_GA_specific_config + * for this release, do not support Error Resilience + * temporary solution is set status flag and exit decoding + */ + /* status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_CELP) + * { + * status = 1; + *} + */ + + /* + *if (audioObjectType == MP4AUDIO_ER_HVXC) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + * status = 1; + *} + */ + + /* + *if ((audioObjectType == MP4AUDIO_ER_AAC_LC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LTP) || + * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) || + * (audioObjectType == MP4AUDIO_ER_TWINVQ) || + * (audioObjectType == MP4AUDIO_ER_BSAC) || + * (audioObjectType == MP4AUDIO_ER_AAC_LD) || + * (audioObjectType == MP4AUDIO_ER_CELP) || + * (audioObjectType == MP4AUDIO_ER_HVXC) || + * (audioObjectType == MP4AUDIO_ER_HILN) || + * (audioObjectType == MP4AUDIO_PARAMETRIC)) + *{ + */ + /* error protection config */ + /* + * epConfig = + * getbits( + * LEN_EP_CONFIG, + * pInputStream); + * + * if (epConfig == 2) + * { + */ + /* should call ErrorProtectionSpecificConfig() */ + /* + * status = 1; + * } + * + *} + */ + + return status; + +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.h new file mode 100644 index 00000000..a8980ea1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_audio_specific_config.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_audio_specific_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function declaration for get_audio_specific_config + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_AUDIO_SPECIFIC_CONFIG_H +#define GET_AUDIO_SPECIFIC_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_audio_specific_config( + tDec_Int_File * const pVars +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.c new file mode 100644 index 00000000..647e8512 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.c @@ -0,0 +1,202 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is rounded up to a number that represents the next + byte boundary. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Adquire Data Stream element (DSE) from raw bitstream + At this time this function just drops the information. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +void byte_align( + BITS *pInputStream) + + MODIFYING(pInputStream->usedBits = pInputStream->usedBits + + (pInputStream->usedBits + 7) % 8) + + RETURN(nothing) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "get_dse.h" +#include "ibstream.h" +#include "getbits.h" +#include "s_bits.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void get_dse( + Char *DataStreamBytes, + BITS *pInputStream) +{ + Int i; + Int data_byte_align_flag; + UInt count; + Int esc_count; + Char *pDataStreamBytes; + + pDataStreamBytes = DataStreamBytes; + + /* + * Get element instance tag ( 4 bits) + * ( max of 16 per raw data block) + */ + get9_n_lessbits(LEN_TAG, pInputStream); + + /* + * get data_byte_align_flag ( 1 bit0 to see if byte alignment is + * performed within the DSE + */ + data_byte_align_flag = get1bits(pInputStream); + + /* + * get count ( 8 bits) + */ + count = get9_n_lessbits(LEN_D_CNT, pInputStream); + + /* + * if count == 255, its value it is incremented by a + * second 8 bit value, esc_count. This final value represents + * the number of bytes in the DSE + */ + if (count == (1 << LEN_D_CNT) - 1) + { + esc_count = (Int)get9_n_lessbits(LEN_D_ESC, pInputStream); /* 8 bits */ + count += esc_count; + } + + /* + * Align if flag is set + */ + if (data_byte_align_flag) + { + byte_align(pInputStream); + } + + for (i = count; i != 0; i--) + { + *(pDataStreamBytes++) = (Char) get9_n_lessbits( + LEN_BYTE, + pInputStream); + } + + return; + +} /* end get_dse */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.h new file mode 100644 index 00000000..6bd16fc5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_dse.h @@ -0,0 +1,81 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_dse.h + Funtions: + get_dse + + +------------------------------------------------------------------------------ + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_DSE_H +#define GET_DSE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void get_dse( + Char *DataStreamBytes, + BITS *pInputStream); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.c new file mode 100644 index 00000000..20778bfc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.c @@ -0,0 +1,194 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ele_list.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pElementList = pointer to an EleList structure - only the field num_ele + needs to be set. Data type pointer to EleList. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. Data type pointer to BITS + + enableCPE = boolean value indicating the area to be read contains + a channel pair element field. Data type Bool + + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: + pElementList contents are updated with information pertaining to channel + configuration. + + pInputBuffer contents are updated to the next location to be read from + the input stream. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is called several times by get_prog_config() to read in part of + the program configuration data related to channel setup. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not have static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + elementCount = pElementList->num_ele; + + FOR (index = 0; index < elementCount; index++) + IF (enableCPE != FALSE) THEN + pElementList->ele_is_cpe[index] = + getbits(LEN_ELE_IS_CPE, pInputStream); + ELSE + pElementList->ele_is_cpe[index] = 0; + END IF + + pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream); + + END FOR + + RETURNS nothing + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void get_ele_list( + EleList *pElementList, + BITS *pInputStream, + const Bool enableCPE) +{ + Int index; + Int *pEleIsCPE; + Int *pEleTag; + + pEleIsCPE = &pElementList->ele_is_cpe[0]; + pEleTag = &pElementList->ele_tag[0]; + + for (index = pElementList->num_ele; index > 0; index--) + { + if (enableCPE != FALSE) + { + *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream); + } + else + { + *pEleIsCPE++ = FALSE; + } + + *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream); + + } /* end for (index) */ + + return; + +} /* end get_ele_list */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.h new file mode 100644 index 00000000..48f131e3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ele_list.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ele_list.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_ele_list.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ELE_LIST_H +#define GET_ELE_LIST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_elelist.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void get_ele_list( + EleList *pElementList, + BITS *pInputStream, + const Bool enableCPE); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.c new file mode 100644 index 00000000..2837a655 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.c @@ -0,0 +1,431 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ga_specific_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config + pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128 + are needed for calling set_mc_info. + Data type pointer to tDec_Int_File + + channel_config = variable that indicates the channel configuration + information, in this decoder library, only values + 0, 1, and 2 are allowed. + Data type UInt + + audioObjectType = variable that indicates the Audio Object Type. + Data type UInt. + + pInputStream = pointer to a BITS structure that holds information + regarding the input stream. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + 1 otherwise + + Pointers and Buffers Modified: + pVars->mc_info contents are updated with channel information. + if infoinit is called within set_mc_info, then + pVars->pWinSeqInfo contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function takes the sampling_rate_idx, channel_config, and + audioObjectType from AudioSpecificConfig() and set the decoder configuration + necessary for the decoder to decode properly. + It also reads the bitstream for frame length, scalable bitstream information + and extension information to General Audio defined in MPEG-4 phase 1 + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global variables + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Part 3 + Subpart 1 p18 1.6 Interface to MPEG-4 Systems + Subpart 4 p13 4.4.1 GA Specific Configuration + Amendment p10 6.2.1 AudioSpecificInfo + Amendment p78 8.2 Decoder configuration (GASpecificConfig) + + (2) AAC DecoderSpecificInfo Information + PacketVideo descriptions - San Diego + +------------------------------------------------------------------------------ + PSEUDO-CODE + + frameLenFlag = CALL getbits( + neededBits = LEN_FRAME_LEN_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (frameLenFlag) + + dependsOnCoreCoder = CALL getbits( + neededBits = LEN_DEPEND_ON_CORE, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (dependsOnCoreCoder) + + IF (dependsOnCoreCoder != FALSE) + THEN + coreCoderDelay = CALL getbits( + neededBits = LEN_CORE_DELAY, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (coreCoderDelay) + ENDIF + + extFlag = CALL getbits( + neededBits = LEN_EXT_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (extFlag) + + IF (channel_config == 0) + THEN + status = CALL get_prog_config( + pVars = pVars, + pScratchPCE = &pVars->scratch_prog_config); + MODIFYING (pVars, pScratchPCE) + RETURNING (status) + + ELSE + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + + status = CALL set_mc_info( + pMC_Info = &(pVars->mc_info), + audioObjectType = audioObjectType, + sampling_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->pWinSeqInfo, + sfbwidth128 = pVars->SFBWidth128); + MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128) + RETURNING (SUCCESS) + ENDIF + + IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + THEN + layer_num = CALL getbits( + neededBits = LEN_LAYER_NUM, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_num) + + status = 1; + ENDIF + + IF (extFlag != FALSE) + THEN + IF (audioObjectType == MP4AUDIO_ER_BSAC) + THEN + numOfSubFrame = CALL getbits( + neededBits = LEN_SUB_FRAME, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (numOfSubFrame) + + layer_len = CALL getbits( + neededBits = LEN_LAYER_LEN, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (layer_len) + + ENDIF + + IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR + (audioObjectType == 23)) + THEN + aacSectionDataResilienceFlag = + CALL getbits( + neededBits = LEN_SECT_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSectionDataResilienceFlag) + + aacScalefactorDataResilienceFlag = + CALL getbits( + neededBits = LEN_SFB_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacScalefactorDataResilienceFlag) + + aacSpectralDataResilienceFlag = + CALL getbits( + neededBits = LEN_SPEC_RES_FLAG, + pInputStream = pInputStream); + MODIFYING (pInputStream) + RETURNING (aacSpectralDataResilienceFlag) + ENDIF + + status = 1; + + ENDIF + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_mp4ff_const.h" +#include "e_tmp4audioobjecttype.h" +#include "s_tdec_int_file.h" +#include "get_ga_specific_config.h" +#include "set_mc_info.h" +#include "get_prog_config.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_GA_specific_config( + tDec_Int_File * const pVars, + BITS *pInputStream, + UInt channel_config, + const tMP4AudioObjectType audioObjectType +) +{ + + Int status = SUCCESS; + UInt dependsOnCoreCoder; + /* Int coreCoderDelay; */ + UInt extFlag; + + /* These variables are left for future implementation */ + /* UInt layer_num; */ + /* UInt numOfSubFrame; */ + /* UInt layer_len; */ + /* UInt aacSectionDataResilienceFlag; */ + /* UInt aacScalefactorDataResilienceFlag; */ + /* UInt aacSpectralDataResilienceFlag; */ + Int extFlag3; + + /* + * frame length flag == 0, 1024 samples/frame + * frame length flag == 1, 960 samples/frame + */ + get1bits(/* LEN_FRAME_LEN_FLAG,*/ + pInputStream); + + /* + * dependsOnCoreCoder == 1, core coder has different sampling rate + * in a scalable bitstream + */ + dependsOnCoreCoder = + get1bits(/* LEN_DEPEND_ON_CORE,*/ + pInputStream); + + if (dependsOnCoreCoder != FALSE) + { + /*coreCoderDelay = + * getbits( + * LEN_CORE_DELAY, + * pInputStream); + */ + + status = 1; /* do not support scalable coding in this release */ + } + + /* + * extension flag indicates if Amendment 1 objects are used or not + * extension flag == 0 objects = 1, 2, 3, 4, 6, 7 + * extension flag == 1 objects = 17, 19, 20, 21, 22, 23 + */ + extFlag = get1bits(pInputStream); /* LEN_EXT_FLAG,*/ + + + /* Force checks for implicit channel configuration */ + pVars->mc_info.implicit_channeling = 1; + + if (status == SUCCESS) + { + + if (channel_config == 0) + { + status = get_prog_config(pVars, + &pVars->scratch.scratch_prog_config); + + if (status != SUCCESS) + { + pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono */ + pVars->mc_info.nch = 1; + pVars->prog_config.front.ele_tag[0] = 0; + + status = SUCCESS; + } + } + else + { + /* + * dummy tag = 0 and + * set up decoding configurations + */ + channel_config--; + pVars->prog_config.front.ele_is_cpe[0] = channel_config; + pVars->prog_config.front.ele_tag[0] = 0; + + status = + set_mc_info( + &(pVars->mc_info), + audioObjectType, /* previously profile */ + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + + } /* if (channel_config) */ + + } /* if(status) */ + + /* + * This layer_num is not found in ISO/IEC specs, + * but it is defined in San Diego spec for scalable bitstream + */ + if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) || + (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE)) + { + /*layer_num = + * getbits( + * LEN_LAYER_NUM, + * pInputStream); + */ + + status = 1; /* for this release only */ + } + + if (extFlag) + { + /* + * currently do not implement these functionalities + * defined in Amendment 1 + * keep it here for future release + */ + if (audioObjectType == MP4AUDIO_ER_BSAC) + { + status = 1; /* NOT SUPPORTED */ + /* + numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream); + + layer_len = getbits( LEN_LAYER_LEN, pInputStream); + */ + } + + /* + * The following code is equivalent to + * if ((audioObjectType == 17) || (audioObjectType == 18) || + * (audioObjectType == 19) || (audioObjectType == 20) || + * (audioObjectType == 21) || (audioObjectType == 23)) + */ + + if (((audioObjectType > 16) && (audioObjectType < 22)) || + (audioObjectType == 23)) + { + status = 1; /* NOT SUPPORTED */ + /* + aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG, + pInputStream); + + aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG, + pInputStream); + + aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG, + pInputStream); + */ + } + /* + * this flag is tbd in version 3 of ISO/IEC spec + * if the encoder generates this bit, then it has to be read + * current adif2mp4ff does not write this bit. If this bit is to + * be read, it can be done by the following code: + */ + + extFlag3 = get1bits(pInputStream); /* LEN_EXT_FLAG3 */ + + if (extFlag3) + { + status = 1; /* NOT SUPPORTED */ + } + + } + + return status; +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.h new file mode 100644 index 00000000..bee73d1b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ga_specific_config.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ga_specific_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for get_GA_specific_config.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_GA_SPECIFIC_CONFIG_H +#define GET_GA_SPECIFIC_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_GA_specific_config( + tDec_Int_File * const pVars, + BITS *pInputStream, + UInt channel_config, + const tMP4AudioObjectType audioObjectType +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.c new file mode 100644 index 00000000..d2de5d44 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.c @@ -0,0 +1,561 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ics_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + audioObjectType = MP4 Audio Object Type for the current song. Only if + this is set to LTP (MP4AUDIO_LTP) will long term + prediction bits be retrieved. Data type + tMP4AudioObjectType, which is an enumeration, which in + turn is an Int. + + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. This is the second parameter to this + function to match its position in getbits(). + Data type pointer to BITS structure + + common_window = field read in huffdecode, which tells whether information + is shared between the left and right channel. Long term + prediction (LTP) data is NOT shared even if its a common + window, so this flag is needed to see if another set of + LTP possibly needs to be read. If this flag is false, + pSecondLTPStatus is not touched, it could be NULL if + need be. Data type Bool, which is Int. + + pWindowSequence = pointer to where the the window type of the current + frame and channel should be placed, of data type + WINDOW_SEQUENCE, which is Int. It can take on one + of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, + EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE, + + pWindowShape = pointer to where the window shape for the current frame + and channel should be placed, of data type WINDOW_SHAPE, + which is Int. It can take on the one of these two values: + SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the + "filterbank" section of decoding. + + group = array that holds the index of the first window in each + group. Data type array of Int, eight elements. + + p_max_sfb = pointer to where the maximum number of scale factor bands + for the current frame and channel will be placed. Data + type of pointer to Int. + + p_winmap = array of pointers to all of the possible four window + configurations. This parameter did not need to be pointers, + and could be changed in the future. Data type array of pointers + to FrameInfo structures, length 4. + + pFirstLTPStatus = pointer to a structure where the first LTP + information will be stored. It would be confusing and wrong + to call this left LTP status since if common_window = FALSE, + this function will be called twice - once for the left, once + for the right. It could be done, but extra conditional code + would need to be done. + Data type pointer to LT_PRED_STATUS structure. + + pSecondLTPStatus = pointer to where the right channel of LTP + information will be stored only if common_window is non-zero. + Data type pointer to LT_PRED_STATUS structure. + + Local Stores/Buffers/Pointers Needed: None. + + Global Stores/Buffers/Pointers Needed: None. + + Outputs: + status = 0 implies no error occurred, non-zero otherwise. + + Pointers and Buffers Modified: + pInputStream contents are modified in such a way that the number of bits + read increases. + pWindowSequence contents are updated with the current window for this + frame and channel + group[] contents will be modified to grouping information. See getgroup + source code for a better description of what this is. + p_max_sfb contents will be updated with the maximum scale factor bands + for this frame and channel. + pFirstLTPStatus contents may be updated if the stream has long term + prediction information. + pSecondLTPStatus contents may be updated if common_window != 0 and LTP data + is present. + + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function retrieves the individual channel stream (ICS) information + from the bitstream. The information read for the current + frame and channel is: + - window sequence + - window shape for use in the filter bank + - number of scale factor bands + - long term predication (LTP) information + - grouping information + + This function does NOT support MPEG2 style AAC Frequency Domain Predictor, + not to be confused with LTP (Long Term Prediction). If such data is found + to be on the file an error is generated. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function is not to use static or global data. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding + of audio-visual objects Part 3: Audio Subpart 4:" + Table 4.4.6 - Syntax of ics_info(), page 16. + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = 0; + first_ltp_data_present = FALSE; + second_ltp_data_present = FALSE; + + + CALL getbits( + neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream = pInputStream) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + windowSequence = (temp >> LEN_WIN_SH) & ((0x1<> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1)); + + IF (local_max_sfb > allowed_max_sfb) + THEN + status = 1 + ELSEIF (audioObjectType == MP4AUDIO_LTP) + THEN + IF (predictor_data_present != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(first_ltp_data_present = returnValue) + + IF (ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pFirstLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pFirstLTPStatus) + RETURNING(nothing) + + ENDIF + + IF (common_window != FALSE) + THEN + CALL getbits( + neededBits = LEN_LTP_DATA_PRESENT, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(second_ltp_data_present = returnValue) + + IF (second_ltp_data_present != FALSE) + THEN + + CALL lt_decode( + win_type = windowSequence, + pInputStream = pInputStream, + max_sfb = local_max_sfb, + pLt_pred = pSecondLTPStatus) + MODIFYING(pInputStream) + MODIFYING(pSecondLTPStatus) + RETURNING(nothing) + ENDIF + ENDIF + ENDIF + ELSE + IF (predictor_data_present != FALSE) + THEN + status = 1 + ENDIF + END IF + ENDIF + + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + + IF (common_window != FALSE) + THEN + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + ENDIF + + pFrameInfo = p_winmap[*p_wnd]; + IF (local_max_sfb > pFrameInfo->sfb_per_frame) + THEN + status = 1; + ENDIF + + *(p_max_sfb) = local_max_sfb; + + MODIFY(*(pWindowSequence)) + MODIFY(*(pWinShape)) + MODIFY(*(p_max_sfb)) + MODIFY(group[]) + MODIFY(*pInputStream) + MODIFY(*pFirstLTPStatus) + MODIFY(*pSecondLTPStatus) + RETURN (status); + + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#include "e_rawbitstreamconst.h" +#include "e_tmp4audioobjecttype.h" + +#include "s_bits.h" +#include "s_frameinfo.h" +#include "s_lt_pred_status.h" + +#include "ibstream.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */ + +#include "get_ics_info.h" +#include "huffman.h" /* For the declaration of getgroup */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define LEN_PREDICTOR_DATA_PRESENT (1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int get_ics_info( + const tMP4AudioObjectType audioObjectType, + BITS *pInputStream, + const Bool common_window, + WINDOW_SEQUENCE *pWindowSequence, + WINDOW_SHAPE *pWindowShape, + Int group[], + Int *p_max_sfb, + FrameInfo *p_winmap[], + LT_PRED_STATUS *pFirstLTPStatus, + LT_PRED_STATUS *pSecondLTPStatus) +{ + WINDOW_SEQUENCE windowSequence; + UInt temp; + Bool predictor_data_present; + UInt local_max_sfb; + UInt allowed_max_sfb; + Int status = SUCCESS; + Bool first_ltp_data_present = FALSE; + Bool second_ltp_data_present = FALSE; + + /* + * The following three calls to getbits have been replaced with one + * call for speed: + * + * getbits(LEN_ICS_RESERV, pInputStream); + * windowSequence = getbits(LEN_WIN_SEQ, pInputStream); + * *pWindowShape = getbits(LEN_WIN_SH, pInputStream); + * + */ + + temp = + get9_n_lessbits( + LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH, + pInputStream); + + + windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1)); + + *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1)); + + /* + * This pointer should not be NULL as long as the initialization code + * has been run, so the test for NULL has been removed. + */ + allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0]; + + if (windowSequence == EIGHT_SHORT_SEQUENCE) + { + local_max_sfb = get9_n_lessbits(LEN_MAX_SFBS, + pInputStream); + + getgroup( + group, + pInputStream); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + + } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */ + else + { + /* There is only one group for long windows. */ + group[0] = 1; + + /* + * The window is long, get the maximum scale factor bands, + * and get long term prediction info. + * + * Reference [1] states that the audioObjectType is first tested, + * then the predictor_data_present is read on either branch of the + * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines + * the two calls on both branches into one before the + * if, and then in turn combines with another call to getbits, all + * in the name of speed. + * + * This would be the individual calls, without checking the number + * of scale factor bands: + * + * local_max_sfb = + * (Int) getbits( + * LEN_MAX_SFBL, + * pInputStream); + * + * if (audioObjectType == MP4AUDIO_LTP) + * { + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (read LTP data) + * + * } + * else + * { + * + * predictor_data_present = + * (Bool) getbits( + * LEN_PREDICTOR_DATA_PRESENT, + * pInputStream); + * + * ..... (its an error for this library) + * } + */ + temp = + get9_n_lessbits( + LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT, + pInputStream); + + local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT); + + predictor_data_present = + (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1)); + + if (local_max_sfb > allowed_max_sfb) + { + status = 1; /* ERROR CODE - needs to be updated */ + } + else if (audioObjectType == MP4AUDIO_LTP) + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * If the object type is LTP, the predictor data is + * LTP. If the object type is not LTP, the predictor data + * is so called "frequency predictor data", which is not + * supported by this implementation. Refer to (1) + */ + if (predictor_data_present != FALSE) + { + first_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (first_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pFirstLTPStatus); + } + if (common_window != FALSE) + { + second_ltp_data_present = + (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/ + pInputStream); + + if (second_ltp_data_present != FALSE) + { + lt_decode( + windowSequence, + pInputStream, + local_max_sfb, + pSecondLTPStatus); + } + } /* if (common_window != FALSE) */ + + } /* if (predictor_data_present != FALSE) */ + + } /* else if (audioObjectType == MP4AUDIO_LTP) */ + else + { + /* + * Note that the predictor data bit has already been + * read. + */ + + /* + * The object type is not LTP. If there is data, its + * frequency predictor data, not supported by this + * implementation. + */ + if (predictor_data_present != FALSE) + { + status = 1; /* ERROR CODE UPDATE LATER */ + } /* if (predictor_data_present != FALSE) */ + + } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */ + + } /* if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */ + + + /* + * Save all local copies. + */ + pFirstLTPStatus->ltp_data_present = first_ltp_data_present; + if (common_window != FALSE) + { + pSecondLTPStatus->ltp_data_present = second_ltp_data_present; + } + + *p_max_sfb = local_max_sfb; + + *pWindowSequence = windowSequence; + + return (status); + +} /* get_ics_info */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.h new file mode 100644 index 00000000..dc5d4ad6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_ics_info.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_ics_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the declaration for the function get_ics_info() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_ICS_INFO_H +#define GET_ICS_INFO_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_tmp4audioobjecttype.h" +#include "s_bits.h" +#include "e_window_sequence.h" +#include "e_window_shape.h" +#include "s_frameinfo.h" +#include "s_lt_pred_status.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int get_ics_info( + const tMP4AudioObjectType audioObjectType, + BITS *pInputStream, + const Bool common_window, + WINDOW_SEQUENCE *p_wnd, + WINDOW_SHAPE *pWindowShape, + Int group[], + Int *p_max_sfb, + FrameInfo *p_winmap[], + LT_PRED_STATUS *pFirstLTPStatus, + LT_PRED_STATUS *pSecondLTPStatus); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_ICS_INFO_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.c new file mode 100644 index 00000000..f4a43b7c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.c @@ -0,0 +1,688 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_prog_config.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pVars = pointer to the structure that holds all information for + this instance of the library. pVars->prog_config is directly + used, and pVars->mc_info, pVars->prog_config, pVars->winmap, + pVars->SFBWidth128 are needed indirectly for calling + set_mc_info. Data type pointer to tDec_Int_File structure. + + pScratchPCE = pointer to a temporary ProgConfig structure to be used + to read in the program configuration element. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = zero if no error was found, non-zero otherwise. + + Pointers and Buffers Modified: + pVars->prog_config contents are updated with the PCE read in. + pVars->mc_info contents are updated with channel information. + pVars->winmap contents are updated with window information. + pVars->SFBWidth128 contents are updated with scale factor band width data. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads from the input stream to memory for a temporary + program configuration element (PCE). If the PCE read is the first + encountered it is saved. Or, if the tag of the PCE read matches the tag of + the first PCE encounted, it is saved as well. This is a mechanism for + changing the sampling rate. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use static or global variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(), + page 16, and section 8.5 "Program Config Element (PCE)", page 30. + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + pInputStream = &(pVars->inputStream); + + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( tag = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->profile = returnValue ) + + CALL getbits( + neededBits = LEN_PROFILE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( pScratchPCE->sampling_rate_idx = returnValue ) + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->front.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->side.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_ELE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->back.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_LFE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->lfe.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_DAT, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->data.num_ele = temp; + + CALL getbits( + neededBits = LEN_NUM_CCE, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->coupling.num_ele = temp; + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->mono_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->mono_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + pScratchPCE->stereo_mix.present = flag; + + IF (flag != FALSE) + THEN + + CALL getbits( + neededBits = LEN_TAG, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->stereo_mix.ele_tag = temp; + + ENDIF + + CALL getbits( + neededBits = LEN_MIX_PRES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( flag = returnValue ) + + flag = + getbits( + LEN_MIX_PRES, + pInputStream); + + pScratchPCE->matrix_mix.present = flag; + + IF (flag != FALSE) + THEN + CALL getbits( + neededBits = LEN_MMIX_IDX, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.ele_tag = temp; + + CALL getbits( + neededBits = LEN_PSUR_ENAB, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( temp = returnValue ) + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + ENDIF + + + CALL get_ele_list( + pElementList = &pScratchPCE->front, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->front ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->side, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->side ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->back, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->back ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->lfe, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->lfe ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->data, + pInputStream = pInputStream, + enableCPE = FALSE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->data ) + RETURNING( nothing ) + + CALL get_ele_list( + pElementList = &pScratchPCE->coupling, + pInputStream = pInputStream, + enableCPE = TRUE ) + MODIFYING( pInputStream ) + MODIFYING( pScratchPCE->coupling ) + RETURNING( nothing ) + + + CALL byte_align( + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( numChars = returnValue ) + + FOR (i = numChars; i > 0; i--) + + CALL getbits( + neededBits = LEN_COMMENT_BYTES, + pInputStream = pInputStream ) + MODIFYING( pInputStream ) + RETURNING( nothing ) + + ENDFOR + + IF (pVars->current_program < 0) + THEN + pVars->current_program = tag; + ENDIF + + + IF (tag == pVars->current_program) + THEN + + CALL pv_memcpy( + to = &pVars->prog_config, + from = pScratchPCE, + n = sizeof(ProgConfig)) + MODIFYING( pVars->prog_config ) + RETURNING( nothing ) + + CALL set_mc_info( + pMC_Info = &pVars->mc_info, + objectType = pVars->prog_config.profile + 1, + samplin_rate_idx = pVars->prog_config.sampling_rate_idx, + tag = pVars->prog_config.front.ele_tag[0], + is_cpe = pVars->prog_config.front.ele_is_cpe[0], + pWinSeqInfo = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING( pVars->mc_info ) + MODIFYING( pVars->winmap ) + MODIFYING( pVars->SFBWidth128 ) + RETURN( status = return_value ) + + ENDIF + + MODIFY( pVars->mc_info ) + MODIFY( pVars->winmap ) + MODIFY( pVars->SFBWidth128 ) + RETURN (status) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "s_elelist.h" +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "e_progconfigconst.h" +#include "ibstream.h" +#include "get_ele_list.h" +#include "aac_mem_funcs.h" +#include "set_mc_info.h" +#include "get_prog_config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +Int get_prog_config( + tDec_Int_File *pVars, + ProgConfig *pScratchPCE) +{ + Int i; + UInt tag; + Int numChars; + UInt temp; + Bool flag; + Int status = SUCCESS; + BITS *pInputStream = &(pVars->inputStream); + + + /* + * The tag is used at the very end to see if this PCE is + * the one to be used. Otherwise it does not need to be saved for the + * the simple configurations to be used in this version of an AAC + * decoder. + * + * All of the bits of this PCE must be read even if this PCE will not + * be used. They are read into a temporary PCE, then later it is decided + * whether to keep this PCE. + * + * To allow quick removal of the fields from the ProgConfig structure + * that will probably not be used at a later date, + * while still advancing the bitstream pointer,the return value of + * getbits is saved into a temporary variable, then transfered to + * the structure item. + */ + tag = + get9_n_lessbits( + LEN_TAG, + pInputStream); + + pScratchPCE->profile = + get9_n_lessbits( + LEN_PROFILE, + pInputStream); + + pScratchPCE->sampling_rate_idx = + get9_n_lessbits( + LEN_SAMP_IDX, + pInputStream); + + if (!pVars->adif_test && pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx) + { + /* rewind the pointer as implicit channel configuration maybe the case */ + pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX); + + return (1); /* mismatch cannot happen */ + } + + + /* + * Retrieve the number of element lists for each of + * front, side, back, lfe, data, and coupling. + * + * For two-channel stereo or mono, only the data in the front needs + * to be saved. However, ALL fields need to be skipped over in some + * fashion. Also, the number of elements needs to be temporarily saved + * to call get_ele_list(). If that function was changed to pass in + * the number of points to be read, the memory set aside inside the + * ProgConfig structure could be removed. + */ + + /* + * The next six function calls could be combined into one, then use + * shifts and masks to retrieve the individual fields. + */ + temp = + get9_n_lessbits( + LEN_NUM_ELE, + pInputStream); + + pScratchPCE->front.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = + get9_n_lessbits( + LEN_NUM_ELE, + pInputStream); + + pScratchPCE->side.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = + get9_n_lessbits( + LEN_NUM_ELE, + pInputStream); + + pScratchPCE->back.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = + get9_n_lessbits( + LEN_NUM_LFE, + pInputStream); + + pScratchPCE->lfe.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = + get9_n_lessbits( + LEN_NUM_DAT, + pInputStream); + pScratchPCE->data.num_ele = temp; + + /* Needed only to read in the element list. */ + temp = + get9_n_lessbits( + LEN_NUM_CCE, + pInputStream); + + pScratchPCE->coupling.num_ele = temp; + + /* + * Read in mix down data. + * + * Whether these fields can be removed and have proper operation + * will be determined at a later date. + */ + + /* Read presence of mono_mix */ + flag = + get1bits(/* LEN_MIX_PRES,*/ + pInputStream); + + pScratchPCE->mono_mix.present = flag; + + if (flag != FALSE) + { + temp = + get9_n_lessbits( + LEN_TAG, + pInputStream); + + pScratchPCE->mono_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of stereo mix */ + flag = + get1bits(/* LEN_MIX_PRES,*/ + pInputStream); + + pScratchPCE->stereo_mix.present = flag; + + if (flag != FALSE) + { + temp = + get9_n_lessbits( + LEN_TAG, + pInputStream); + + pScratchPCE->stereo_mix.ele_tag = temp; + + } /* end if (flag != FALSE) */ + + /* Read presence of matrix mix */ + flag = + get1bits(/* LEN_MIX_PRES,*/ + pInputStream); + + pScratchPCE->matrix_mix.present = flag; + + if (flag != FALSE) + { + temp = + get9_n_lessbits( + LEN_MMIX_IDX, + pInputStream); + + pScratchPCE->matrix_mix.ele_tag = temp; + + temp = + get1bits(/* LEN_PSUR_ENAB,*/ + pInputStream); + + pScratchPCE->matrix_mix.pseudo_enab = temp; + + } /* end if (flag != FALSE) */ + + /* + * Get each of the element lists. Only the front information will be + * used for the PV decoder, but the usedBits field of pInputStream must + * be advanced appropriately. + * + * This could be optimized by advancing the bit stream for the + * elements that do not need to be read. + */ + get_ele_list( + &pScratchPCE->front, + pInputStream, + TRUE); + + get_ele_list( + &pScratchPCE->side, + pInputStream, + TRUE); + + get_ele_list( + &pScratchPCE->back, + pInputStream, + TRUE); + + get_ele_list( + &pScratchPCE->lfe, + pInputStream, + FALSE); + + get_ele_list( + &pScratchPCE->data, + pInputStream, + FALSE); + + get_ele_list( + &pScratchPCE->coupling, + pInputStream, + TRUE); + + /* + * The standard requests a byte alignment before reading in the + * comment. This can be done because LEN_COMMENT_BYTES == 8. + */ + byte_align(pInputStream); + + numChars = + get9_n_lessbits( + LEN_COMMENT_BYTES, pInputStream); + + /* + * Ignore the comment - it requires 65 bytes to store (or worse on DSP). + * If this field is restored, make sure to append a trailing '\0' + */ + for (i = numChars; i > 0; i--) + { + pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE, + pInputStream); + + } /* end for */ + + if (pVars->current_program < 0) + { + /* + * If this is the first PCE, it becomes the current, regardless of + * its tag number. + */ + pVars->current_program = tag; + + } /* end if (pVars->current_program < 0) */ + + + if (tag == (UInt)pVars->current_program) + { + /* + * This branch is reached under two conditions: + * 1) This is the first PCE found, it was selected in the above if + * block. In all encoders found thus far, the tag value has been + * zero. + * 2) A PCE has been sent by the encoder with a tag that matches the + * the first one sent. It will then be re-read. No encoder found + * thus far re-sends a PCE, when looking at ADIF files. + * + * Regardless, the temporary PCE will now be copied into the + * the one official program configuration. + */ + pv_memcpy( + &pVars->prog_config, + pScratchPCE, + sizeof(ProgConfig)); + + /* enter configuration into MC_Info structure */ + status = + set_mc_info( + &pVars->mc_info, + (tMP4AudioObjectType)(pVars->prog_config.profile + 1), + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, + pVars->SFBWidth128); + + } /* end if (tag == pVars->current_program) */ + + return (status); +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.h new file mode 100644 index 00000000..6444df67 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_prog_config.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_prog_config.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_prog_config.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_PROG_CONFIG_H +#define GET_PROG_CONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_progconfig.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int get_prog_config( + tDec_Int_File *pVars, + ProgConfig *pTempPCE); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.c new file mode 100644 index 00000000..79230759 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.c @@ -0,0 +1,239 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_pulse_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to a BITS structure, used by the function getbits + to provide data. Data type pointer to BITS structure + + pPulseInfo = pointer to pulse data structure to be filled with data + concerning pulses in the frequency domain. + Data type pointer to PulseInfo + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = return value, zero signifies success, non-zero otherwise. + Presently this function only returns a success, error + checking may be added later. + Data type Int. + + Pointers and Buffers Modified: + + pPulseInfo contents are updated with pulse information. Specifically, + pPulseInfo->number_pulse with the number of pulses found, and + pPulseInfo->pulse_start_sfb is set to the first scale factor band. + Then pPulseInfo->pulse_offset and pPulseInfo->pulse_amp are filled + with data. For these array, only the number of pulses defined will be + set, those values beyond the number of pulses will retain their previous + value and should not be read from. + Note: The value in pPulseInfo->number_pulse is different by a value of + one from the original ISO code. + + pInputBuffer contents are updated to the next location to be read from + the input stream. + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function fills in the pulse data structure with information to be used + later for restoring pulses in the spectrum. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall not use global or static variables. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Table 6.17 - Syntax of pulse_data(), + page 15, and section 9.3 "Decoding process", starting on page 41. + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + CALL getbits(neededBits = LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB, + pInputStream = pInputStream) + MODIFYING(*pInputStream) + RETURNING(temp) + + pPulseInfo->number_pulse = 1 + (temp >> LEN_PULSE_ST_SFB); + pPulseInfo->pulse_start_sfb = temp & ((1 << LEN_PULSE_ST_SFB) - 1); + + pPulseOffset = &pPulseInfo->pulse_offset[0]; + pPulseAmp = &pPulseInfo->pulse_amp[0]; + + FOR (i = PulseInfo->number_pulse; i > 0; i--) + CALL getbits(neededBits = LEN_PULSE_POFF + LEN_PULSE_PAMP, + pInputStream = pInputStream) + MODIFYING(*pInputStream) + RETURNING(temp) + + *pPulseOffset++ = temp >> LEN_PULSE_PAMP; + *pPulseAmp++ = temp & ((1 << LEN_PULSE_PAMP) - 1); + END FOR + + MODIFYING (*pInputStream) + MODIFYING (*pPulseInfo) + + RETURN status + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "ibstream.h" +#include "s_pulseinfo.h" +#include "s_bits.h" +#include "e_rawbitstreamconst.h" +#include "get_pulse_data.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int get_pulse_data( + PulseInfo *pPulseInfo, + BITS *pInputStream) +{ + Int i; + Int *pPulseOffset; + Int *pPulseAmp; + Int status = SUCCESS; + UInt temp; + + /* + * Read in both field fields at once to save cycles. These are the + * original lines of code: + * pPulseInfo->number_pulse = getbits(LEN_PULSE_NPULSE, pInputStream); + * pPulseInfo->pulse_start_sfb = getbits(LEN_PULSE_ST_SFB, pInputStream); + */ + + temp = + get9_n_lessbits( + LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB, + pInputStream); + + pPulseInfo->number_pulse = (Int)(1 + (temp >> LEN_PULSE_ST_SFB)); + pPulseInfo->pulse_start_sfb = (Int)(temp & ((1 << LEN_PULSE_ST_SFB) - 1)); + + pPulseOffset = &pPulseInfo->pulse_offset[0]; + pPulseAmp = &pPulseInfo->pulse_amp[0]; + + /* + * This loop needs to count one more than the number read in from + * the bitstream - look at reference [1]. + */ + + for (i = pPulseInfo->number_pulse; i > 0; i--) + { + /* + * Read in both fields. Original lines: + * *pPulseOffset++ = getbits(LEN_PULSE_POFF, pInputStream); + * *pPulseAmp++ = getbits(LEN_PULSE_PAMP, pInputStream); + */ + + temp = + get9_n_lessbits( + LEN_PULSE_POFF + LEN_PULSE_PAMP, + pInputStream); + + *pPulseOffset++ = (Int)(temp >> LEN_PULSE_PAMP); + + *pPulseAmp++ = (Int)(temp & ((1 << LEN_PULSE_PAMP) - 1)); + } + + return (status); +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.h new file mode 100644 index 00000000..e3d890b7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_pulse_data.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_pulse_data.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for get_pulse_data.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_PULSE_DATA_H +#define GET_PULSE_DATA_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_pulseinfo.h" +#include "s_bits.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int get_pulse_data( + PulseInfo *pPulseInfo, + BITS *pInputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_PULSE_DATA_H */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.c new file mode 100644 index 00000000..e7b6067e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.c @@ -0,0 +1,179 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_bitstream.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "get_sbr_bitstream.h" +#include "pv_audio_type_defs.h" +#include "sbr_crc_check.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, BITS *pInputStream) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int32 count; + Int32 esc_count; + Int32 Extention_Type; + Int32 i; + + count = get9_n_lessbits(LEN_F_CNT, pInputStream); + if (count == 15) + { + esc_count = get9_n_lessbits(LEN_F_ESC, pInputStream); + count = esc_count + 14; + } + + + + Extention_Type = get9_n_lessbits(LEN_F_CNT, pInputStream); + + + if (((Extention_Type == SBR_EXTENSION) || (Extention_Type == SBR_EXTENSION_CRC)) + && (count < MAXSBRBYTES) && (count) && (sbrBitStream->NrElements < MAXNRELEMENTS)) + { + + sbrBitStream->sbrElement[sbrBitStream->NrElements].ExtensionType = Extention_Type; + sbrBitStream->sbrElement[sbrBitStream->NrElements].Payload = count; + sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[0] = (UChar) get9_n_lessbits(LEN_F_CNT, pInputStream); + for (i = 1 ; i < count ; i++) + { + sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[i] = (UChar) get9_n_lessbits(8, pInputStream); + } + + sbrBitStream->NrElements += 1; + + } + else + { + pInputStream->usedBits += (count - 1) * LEN_BYTE; + pInputStream->usedBits += 4; /* compenste for LEN_F_CNT (=4) bits read for Extention_Type */ + + } +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.h new file mode 100644 index 00000000..43fc2383 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_bitstream.h @@ -0,0 +1,120 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_bitstream.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_BITSTREAM_H +#define GET_SBR_BITSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" +#include "ibstream.h" +#include "e_rawbitstreamconst.h" +#include "s_sbrbitstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, + BITS *pInputStream); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.c new file mode 100644 index 00000000..1c806e2f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.c @@ -0,0 +1,176 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_startfreq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "get_sbr_startfreq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int v_offset[7][16] = +{ + { -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, + { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, + { -5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + { -6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, + { -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, + { -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, + { 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24, 28, 33} +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int get_sbr_startfreq(const Int32 fs, + const Int32 start_freq) +{ + Int k0_min = 0; + Int32 index; + + + switch (fs) + { + case 16000: + index = 0; + k0_min = 24; + break; + case 22050: + index = 1; + k0_min = 17; + break; + case 24000: + index = 2; + k0_min = 16; + break; + case 32000: + index = 3; + k0_min = 16; + break; + case 44100: + index = 4; + k0_min = 12; + break; + case 48000: + index = 4; + k0_min = 11; + break; + case 64000: + index = 4; + k0_min = 10; + break; + case 88200: + case 96000: + index = 5; + k0_min = 7; + break; + + default: + index = 6; + } + return (k0_min + v_offset[index][start_freq]); + +} + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.h new file mode 100644 index 00000000..044a97f1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_startfreq.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_startfreq.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_STARTFREQ_H +#define GET_SBR_STARTFREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_sbr_startfreq(const Int32 fs, + const Int32 start_freq); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.c new file mode 100644 index 00000000..95b9ff7c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.c @@ -0,0 +1,185 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_stopfreq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + if(fs < 32000) + { + k1_min = (Int) ( ( (float) (6000 * 2 * 64) / fs ) + 0.5 ); + } + else + { + if (fs < 64000) + { + k1_min = (Int) ( ( (float) (8000 * 2 * 64) / fs ) + 0.5 ); + } + else + { + k1_min = (Int) ( ((float) (10000 * 2 * 64) / fs ) + 0.5); + } + } + + return((Int)( k1_min * pow( 64.0 / k1_min,(stop_freq)/13.0) + 0.5)); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "get_sbr_stopfreq.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +const UChar sbr_stopfreq_tbl[6][13] = +{ + + { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59}, /* 48000 */ + { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59}, /* 44100 */ + { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61}, /* 32000 and 24000 */ + { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61}, /* 22050 */ + { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62} /* 16000 */ + +}; + +Int get_sbr_stopfreq(const Int32 fs, + const Int32 stop_freq) +{ + + Int i; + + switch (fs) + { + case 48000: + i = 0; + break; + + case 32000: + case 24000: + i = 2; + break; + + case 22050: + i = 3; + break; + + case 16000: + i = 4; + break; + + case 44100: + default: + i = 1; + break; + } + + return((Int)sbr_stopfreq_tbl[i][stop_freq]); + +} + + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.h new file mode 100644 index 00000000..fceb534d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sbr_stopfreq.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sbr_stopfreq.h + Funtions: + get_dse + +------------------------------------------------------------------------------ + + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SBR_STOPFREQ_H +#define GET_SBR_STOPFREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int get_sbr_stopfreq(const Int32 fs, + const Int32 stop_freq); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sign_bits.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sign_bits.h new file mode 100644 index 00000000..0cbaad8f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_sign_bits.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_sign_bits.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for the function get_sign_bits() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_SIGN_BITS_H +#define GET_SIGN_BITS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void get_sign_bits( + Int q[], + BITS *pInputStream, + const Int q_len +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GET_SIGN_BITS_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.c new file mode 100644 index 00000000..437e0bf9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.c @@ -0,0 +1,514 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_tns.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + FrameInfo *pFrameInfo + Pointer to structure that holds information about each block. + (long block flag, + number of subblocks, + scalefactor bands per subblock, etc.) + + BITS *pInputStream + Pointer to a BITS structure that is + passed on to function getbits to pull information from the bitstream. + + TNS_Frame_info *pTnsFrameInfo + Pointer to filter data structure - to be populated by this function. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + TNS_frame_info *pTnsFrameInfo + + pTnsFrameInfo->n_filt = Number of tns filters to be applied to the data. + + pTnsFrameInfo->filt[]->order = The order of each individual TNS filter. + + pTnsFrameInfo->filt[]->coef_res = The resolution of the filter coefficients + + pTnsFrameInfo->filt[]->start_band = start of spectral band + + pTnsFrameInfo->filt[]->stop_band = end of spectral band + + pTnsFrameInfo->filt[]->coef[] = Each filter's coefficients are filled with + data read from the input bitstream. + + pTnsFrameInfo->filt[]->direction = A flag is set for each TNS filter. + + If the direction flag (on the bitstream) = 0, then the filter + is applied to the block of spectral data in normal (upward) fashion. + + If the direction flag (on the bitstream) = 1, then the filter + is applied in a reverse (downward) fashion. + (Starting with the last element in the block of data.) + + The value stored in filt[]->direction maps the values [0,1] to [1,-1] for + a more intuitive storage of this flag's meaning. + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the TNS filter information from the bitstream, and stores + the filter order, LPC coefficients, and the number of TNS filters to + be applied in the structure TNS_frame_info. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This code should match the ISO code in functionality, with the exception + that coef_res has range of [0,1] (PV code) instead of [3,4] (ISO code) + + coef_res is only used by tns_decode_coef. + +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "get_tns.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" +#include "s_tnsfilt.h" +#include "s_tns_frame_info.h" +#include "s_bits.h" +#include "ibstream.h" +#include "e_window_sequence.h" +#include "e_progconfigconst.h" + +#include "tns_decode_coef.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#define SCALE_FACTOR_BAND_OFFSET(x) ( ((x) > 0) ? pSFB_top[(x)-1] : 0 ) +#define MINIMUM(x,y) ( ((x) < (y)) ? (x) : (y) ) + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/* + * The entries in the ensuing tables provide the maximum permissable + * number of scalefactor bands for each TNS filter. This value is effected + * by the sampling rate, and window type. + */ + +const Int tns_max_bands_tbl_long_wndw[(1<win_sfb_top[0]; + + Int f; + Int t; + Int win; + UInt tempInt; + + Int num_filt_bits; + Int num_order_bits; + Int num_start_band_bits; + + Int top; + Int res; + Int res_index; + Int compress; + + Int sfb_per_win; + + Int32 *pLpcCoef; + Int32 *pStartLpcCoef; + Int s_mask; + Int n_mask; + + Int tns_bands; + UInt max_order; + Int coef_res; + + + TNSfilt *pFilt; + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + num_filt_bits = 2; + num_order_bits = 5; + num_start_band_bits = 6; + + tns_bands = tns_max_bands_tbl_long_wndw[pMC_Info->sampling_rate_idx]; + + /* + * Definition from 14496-3:1999 doc. Our first encoder follows this rule, + * later encoders don't + */ + + if (pMC_Info->sampling_rate_idx > 4) /* if (sampling_rate <= 32000 */ + { + max_order = 20; + } + else + { + max_order = 12; + } + } + else + { + num_filt_bits = 1; + num_order_bits = 3; + num_start_band_bits = 4; + + tns_bands = tns_max_bands_tbl_short_wndw[pMC_Info->sampling_rate_idx]; + + max_order = 7; + } + + /* + * After this branch, tns_bands will be equal to the minimum of + * the passed in variable, nbands, and the result from the + * tns_max_bands_tbl + */ + + if (max_bands < tns_bands) + { + tns_bands = max_bands; + } + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + win = 0; + + pLpcCoef = pTnsFrameInfo->lpc_coef; + + pFilt = pTnsFrameInfo->filt; + + do + { + tempInt = get9_n_lessbits(num_filt_bits, + pInputStream); + + pTnsFrameInfo->n_filt[win] = tempInt; + + if (tempInt != 0) + { + /* + * coef_res = [0, 1] + * Switch between a resolution of 3 and 4 bits respectively + * + * if coef_res = 0, the coefficients have a range of + * + * -4 -3 -2 -1 0 1 2 3 + * + * if coef_res = 1, the coefficients have a range of + * + * -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 + * + * The arrays in ./src/tns_tab.c are completely based on + * the value of coef_res. + */ + res = get1bits( + pInputStream); + + /* res is post-incremented for correct calculation of res_index */ + coef_res = res++; + + top = sfb_per_win; + + for (f = pTnsFrameInfo->n_filt[win]; f > 0; f--) + { + tempInt = MINIMUM(top, tns_bands); + + pFilt->stop_coef = SCALE_FACTOR_BAND_OFFSET(tempInt); + + pFilt->stop_band = tempInt; + + top -= get9_n_lessbits(num_start_band_bits, + pInputStream); + + tempInt = MINIMUM(top, tns_bands); + + pFilt->start_coef = SCALE_FACTOR_BAND_OFFSET(tempInt); + + pFilt->start_band = tempInt; + + tempInt = get9_n_lessbits(num_order_bits, + pInputStream); + + pFilt->order = tempInt; + + if (tempInt != 0) + { + if (tempInt > max_order) + { + pFilt->order = max_order; + } + + /* + * This maps the bitstream's [0,1] to + * pFilt->direction = [1,-1] + */ + + tempInt = get1bits(pInputStream); + + pFilt->direction = (-(Int)tempInt) | 0x1; + + /* + * compress = [0,1] + * If compress is true, the MSB has + * been omitted from transmission (Ref. 1) + * + * For coef_res = 0, this limits the range of + * transmitted coefficients to... + * + * -2 -1 0 1 + * + * For coef_res = 1, the coefficients have + * a range of... + * + * -4 -3 -2 -1 0 1 2 3 + */ + compress = get1bits(pInputStream); + + /* + * res has a range of [1,2] + * compress has a range of [0,1] + * So (res - compress) has range [0,2]; + */ + res_index = res - compress; + + s_mask = 2 << res_index; + + /* + * If res_index = 0, grab 2 bits of data + * If res_index = 1, grab 3 bits of data + * If res_index = 2, grab 4 bits of data + */ + res_index += 2; + + pStartLpcCoef = pLpcCoef; + + for (t = pFilt->order; t > 0; t--) + { + /* + * These are the encoded coefficients, which will + * later be decoded into LPC coefficients by + * the function tns_decode_coef() + */ + tempInt = get9_n_lessbits(res_index, + pInputStream); + + n_mask = -((Int)tempInt & s_mask); + + /* + * n_mask is used to sign_extend the + * value, if it is negative. + * + */ + *(pLpcCoef++) = tempInt | n_mask; + } + + /* Decode the TNS coefficients */ + + tempInt = pFilt->stop_coef - pFilt->start_coef; + + if (tempInt > 0) + { + pFilt->q_lpc = + tns_decode_coef( + pFilt->order, + coef_res, + pStartLpcCoef, + scratchTnsDecCoefMem); + } + + } /* if (pTnsFilt->order != 0) */ + + pFilt++; + + } /* END for (f=pTnsInfo->n_filt; f>0; f--, pTnsFilt++) */ + + } /* if (pTnsInfo->n_filt != 0) */ + + win++; + + } + while (win < pFrameInfo->num_win); + + return; + +} /* get_tns */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.h new file mode 100644 index 00000000..8b5b16f3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/get_tns.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: get_tns.h + + Author: + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function definition for get_tns.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GET_TNS_H +#define GET_TNS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_mc_info.h" +#include "s_tns_frame_info.h" +#include "s_bits.h" +#include "e_window_sequence.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + void get_tns( + const Int max_bands, + BITS * const pInputStream, + const WINDOW_SEQUENCE wnd_seq, + const FrameInfo * const pFrameInfo, + const MC_Info * const pMC_Info, + TNS_frame_info * const pTnsFrameInfo, + Int32 scratchTnsDecCoefMem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* GET_TNS_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getactualaacconfig.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/getactualaacconfig.c new file mode 100644 index 00000000..937293c4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getactualaacconfig.c @@ -0,0 +1,301 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getactualaacconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + aStream = pointer to a UChar* stream that holds the input stream. + + aProperty = pointer to a structure DecodeProperties (define in include file) + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "getactualaacconfig.h" +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + +#include "oscl_mem.h" +#include "e_elementid.h" +#include "e_sbr_element_id.h" +#include "get_dse.h" +#include "get_sbr_bitstream.h" +#include "get_prog_config.h" +#include "huffman.h" /* where huffdecode is declared */ +#include "e_sbr_error.h" +#include "sbr_read_data.h" +#include "sbr_open.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define ERROR_BUFFER_OVERRUN (-2) +#define KCODEC_INIT_FAILURE (-1) +#define LEFT (0) +#define RIGHT (1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +OSCL_EXPORT_REF Int32 GetActualAacConfig(UInt8* aConfigHeader, + UInt8* aAudioObjectType, + Int32* aConfigHeaderSize, + UInt8* SamplingRateIndex, + UInt32* NumChannels) +{ + + tPVMP4AudioDecoderExternal * iAACDecExt = NULL; + UInt initialUsedBits; /* Unsigned for C55x */ + tDec_Int_File *pVars; /* Helper pointer */ + MC_Info *pMC_Info; /* Helper pointer */ + + + Int status = ERROR_BUFFER_OVERRUN; + + + /* + * Allocate memory to decode one AAC frame + */ + + + iAACDecExt = malloc(sizeof(tPVMP4AudioDecoderExternal)); + if (!iAACDecExt) + { + return 1; + } + iAACDecExt->inputBufferCurrentLength = 0; + + + iAACDecExt->pInputBuffer = aConfigHeader; + iAACDecExt->inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE; + + + iAACDecExt->inputBufferUsedLength = 0; + iAACDecExt->remainderBits = 0; + + Int32 memreq = PVMP4AudioDecoderGetMemRequirements(); + + UInt8 *pMem = calloc(memreq, sizeof(UInt8)); + + if (pMem == 0) + { + return KCODEC_INIT_FAILURE; + } + + if (PVMP4AudioDecoderInitLibrary(iAACDecExt, pMem) != 0) + { + return KCODEC_INIT_FAILURE; + } + + iAACDecExt->inputBufferCurrentLength = *aConfigHeaderSize; + + + /* + * Initialize "helper" pointers to existing memory. + */ + + pVars = (tDec_Int_File *)pMem; + + + pMC_Info = &pVars->mc_info; + + + + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = iAACDecExt->pInputBuffer; + + pVars->inputStream.availableBits = + (UInt)(iAACDecExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((iAACDecExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + iAACDecExt->remainderBits); + + pVars->inputStream.inputBufferCurrentLength = + (UInt)iAACDecExt->inputBufferCurrentLength; + + pVars->inputStream.usedBits = initialUsedBits; + + pVars->aacPlusEnabled = TRUE; /* Always enable aacplus decoding */ + + + if (initialUsedBits <= pVars->inputStream.availableBits) + { + /* + * Buffer is not overrun, then + * decode the AudioSpecificConfig() structure + */ + pVars->aacConfigUtilityEnabled = TRUE; /* set aac utility mode */ + + status = get_audio_specific_config(pVars); + + } + + + byte_align(&pVars->inputStream); + + *aConfigHeaderSize = (Int32)((pVars->inputStream.usedBits) >> 3); + + + *SamplingRateIndex = pVars->prog_config.sampling_rate_idx; + + *NumChannels = pVars->mc_info.nch; + + /* + * Set the audio object type to the extended type, only if this is different + * from the baseline object type (this only applies to explicit signaling) + */ + if (pVars->mc_info.audioObjectType != pVars->mc_info.ExtendedAudioObjectType) + { + *aAudioObjectType = pVars->mc_info.ExtendedAudioObjectType; + } + else + { + *aAudioObjectType = pVars->mc_info.audioObjectType; + } + + /* + * Set parameters based on the explicit information from the + * audio specific config + */ + + if (pVars->mc_info.sbrPresentFlag) + { + if (pVars->mc_info.psPresentFlag) + { + *NumChannels += 1; + } + } + + pVars->status = status; + + /* + * Clear allocated memory + */ + if (pMem != NULL) + { + free(pMem); + pMem = NULL; + } + + + free(iAACDecExt); + iAACDecExt = NULL; + + return status; +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getbits.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/getbits.h new file mode 100644 index 00000000..0a56ea0e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getbits.h @@ -0,0 +1,335 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getbits.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for the function getbits(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GETBITS_H +#define GETBITS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ibstream.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + +#define MAX_GETBITS (25) + +#define CHECK_INPUT_BUFFER_LIMITS 1 + + static inline UInt32 getbits( + const UInt neededBits, + BITS *pInputStream) + { + UInt32 returnValue = 0; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + if (offset > 3) + { + returnValue = (((UInt32) * (pElem)) << 24) | + (((UInt32) * (pElem + 1)) << 16) | + (((UInt32) * (pElem + 2)) << 8) | + ((UInt32) * (pElem + 3)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp. + */ + switch (offset) + { + case 3: + returnValue = (((UInt32) * (pElem + 2)) << 8); + case 2: + returnValue |= (((UInt32) * (pElem + 1)) << 16); + case 1: + returnValue |= (((UInt32) * (pElem)) << 24); + default: + break; + } + } + + +#else + + returnValue = (((UInt32) * (pElem)) << 24) | + (((UInt32) * (pElem + 1)) << 16) | + (((UInt32) * (pElem + 2)) << 8) | + ((UInt32) * (pElem + 3)); +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = returnValue << (bitIndex); + + /* Move the field down. */ + returnValue = returnValue >> (32 - neededBits); + + pInputStream->usedBits += neededBits; + + return (returnValue); + + } + + + + static inline UInt get1bits( + BITS *pInputStream) + { + UInt returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + returnValue = (offset < pInputStream->inputBufferCurrentLength) ? ((UInt) * (pElem)) : 0; +#else + returnValue = ((UInt32) * (pElem)); +#endif + + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits++) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return ((UInt)(returnValue >> 7)); + + } + + + + static inline UInt get9_n_lessbits( + const UInt neededBits, + BITS *pInputStream) + + { + UInt returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + if (offset > 1) + { + returnValue = (((UInt32) * (pElem)) << 8) | + ((UInt32) * (pElem + 1)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp + */ + switch (offset) + { + case 1: + returnValue = (((UInt32) * (pElem)) << 8); + break; + default: + returnValue = 0; + break; + } + } + + +#else + returnValue = (((UInt32) * (pElem)) << 8) | + ((UInt32) * (pElem + 1)) ; +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + pInputStream->usedBits += neededBits; + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + + return (UInt)(returnValue >> (16 - neededBits)); + + } + + static inline UInt32 get17_n_lessbits( + const UInt neededBits, + BITS *pInputStream) + { + UInt32 returnValue; + UInt offset; + UInt bitIndex; + UChar *pElem; /* Needs to be same type as pInput->pBuffer */ + + offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT; + + pElem = pInputStream->pBuffer + offset; + +#if CHECK_INPUT_BUFFER_LIMITS + + offset = pInputStream->inputBufferCurrentLength - offset; + /* check if access to input buffer does not go beyond boundaries */ + + if (offset > 2) + { + returnValue = (((UInt32) * (pElem)) << 16) | + (((UInt32) * (pElem + 1)) << 8) | + ((UInt32) * (pElem + 2)); + } + else /* then access only available bytes */ + { + /* Access to the bitstream beyond frame boundaries are not allowed, + * Here, only what was available before the end of the frame will + * be processed. Non-accessible bytes will be filled in with zeros. + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. + * Overrun is detected on file pvmp4audiodecodeframe.cpp + */ + returnValue = 0; + switch (offset) + { + case 2: + returnValue = (((UInt32) * (pElem + 1)) << 8); + case 1: + returnValue |= (((UInt32) * (pElem)) << 16); + default: + break; + } + } + +#else + + returnValue = (((UInt32) * (pElem)) << 16) | + (((UInt32) * (pElem + 1)) << 8) | + ((UInt32) * (pElem + 2)); +#endif + + /* Remove extra high bits by shifting up */ + bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK); + + /* This line is faster way to mask off the high bits. */ + returnValue = 0xFFFFFF & (returnValue << (bitIndex)); + + /* Move the field down. */ + returnValue = returnValue >> (24 - neededBits); + + pInputStream->usedBits += neededBits; + + return (returnValue); + + } + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* GETBITS_H*/ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.c new file mode 100644 index 00000000..ddeb9ecd --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.c @@ -0,0 +1,200 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getfill.cpp + Funtions: getfill + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure BITS containing input stream + information. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pInputStream->usedBits is updated to the newly calculated value. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function passes over fill bits in the raw data block to adjust the + instantaneous bit rate when the bitstream is to be transmitted over a + constant rate channel. + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p15 (Table 4.4.11) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits( + LEN_F_CNT, + pInputStream); + MODIFYING (pInputStream) + RETURNING (cnt) + + IF ( cnt == (1<usedBits += cnt * LEN_BYTE; + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "ibstream.h" +#include "e_rawbitstreamconst.h" +#include "getfill.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void getfill(BITS *pInputStream) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int cnt; + Int esc_cnt; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + cnt = get9_n_lessbits( + LEN_F_CNT, + pInputStream); + + if (cnt == (1 << LEN_F_CNT) - 1) /* if (cnt == 15) */ + { + esc_cnt = get9_n_lessbits( + LEN_F_ESC, + pInputStream); + + cnt += esc_cnt - 1; + } + + /* + * The following codes are replaced by directly updating usedBits + * in BITS structure. This will save one call for getbits(). + * + * for (i=0; iusedBits += cnt * LEN_BYTE; + + /*---------------------------------------------------------------------------- + ; Return nothing or data or data pointer + ----------------------------------------------------------------------------*/ + +} /* getfill */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.h new file mode 100644 index 00000000..a20c3bf2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getfill.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getfill.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file contains prototype declaration for getfill function. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef GETFILL_H +#define GETFILL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void getfill(BITS *pInputStream); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getgroup.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/getgroup.c new file mode 100644 index 00000000..51fab4fb --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getgroup.c @@ -0,0 +1,214 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getgroup.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure that holds input bitstream + information. Type BITS + + group[] = array that holds the index of the first window in each + group. Type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + group contains the index of first windows in each group + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the window grouping information associated with an + Individual Channel Stream (ICS). If the window sequence is + EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a + set of short windows form a group then they share scalefactors, intensity + positions and PNS information. The first short window is always a new group + so no grouping bit is transmitted. Subsequent short windows are in the same + group if the associated grouping bit is 1. A new group is started if the + associated grouping bit is 0. + The pointer pGroup points to an array that stores the first window index + of next group. For example, if the window grouping is: + + window index: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | + grouping : |<- 0 ->| 1 |<- 2 ->|<- 3 ->| + + Then: + + group[] : | 2 | 3 | 6 | 8 | + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the contents of the array pointed to by pGroup + with the first window indexes of groups starting from the second group. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 + p16 (Table 4.4.6) + p55 (Recovering ics_info) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (pFrameInfo->coef_per_win[0] > SN2) + + *pGroup++ = 1; + *pGroup = 1; + + ELSE + + FOR (win = 1; win < pFrameInfo->num_win; win++) + + IF (getbits(1,pInputStream) == 0) + + *pGroup++ = win; + + ENDIF + + ENDFOR (win) + + *pGroup = win; + + ENDIF(pFrameInfo) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define SEVEN 7 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void getgroup( + Int group[], + BITS *pInputStream) +{ + Int win; + Int *pGroup; + UInt mask; + UInt groupBits; + + pGroup = group; + + mask = 0x40; + + /* only short-window sequences are grouped! + * first short window is always a new group, + * start reading bitstream from the second + * window, a new group is indicated by an + * "0" bit in the input stream + */ + groupBits = + get9_n_lessbits( + SEVEN, + pInputStream); + + for (win = 1; win < NUM_SHORT_WINDOWS; win++) + { + if ((groupBits & mask) == 0) + { + *pGroup++ = win; + + } /* if (groupBits) */ + + mask >>= 1; + + } /* for (win) */ + + *pGroup = win; + +} /* getgroup */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getics.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/getics.c new file mode 100644 index 00000000..93627489 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getics.c @@ -0,0 +1,624 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getics.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pInputStream = pointer to structure that holds input stream, + Type BITS + + common_window = flag that indicates whether left and right channel + share the same window sequence & shape, Type Int + + pVars = pointer to structure that holds decoder information + Type tDec_Int_File + + pChVarsCh = pointer to structure that holds channel related + decoding information, Type tDec_Int_Chan + + group[] = pointer to array that contains window grouping + information of current frame, Type UChar + + pMax_sfb = pointer to variable that stores maximum active + scalefactor bands of current frame, Type UChar + + pCodebookMap = pointer to array that holds the indexes of all + Huffman codebooks used for current frame, ordered + from section 0 to last section. Type UChar + + pTnsFrameInfo = pointer to structure that holds TNS information. + Type TNS_frame_info + + pWinMap = array of pointers which points to structures that + hold information of long and short window sequences + Type FrameInfo + + pPulseInfo = pointer to structure that holds pulse data decoding + information, Type Nec_info + + sect[] = array of structures that hold section codebook and + section length in current frame, Type SectInfo + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + 1 otherwise + + Pointers and Buffers Modified: + pCodebookMap contents are replaced by the indexes of all the huffman + codebooks used for current frame + + pWinMap For short windows, the contents of frame_sfb_top are + modified by calc_gsfb_table, with the top coefficient + index of each scalefactor band. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes individual channel stream by calling other Huffman + decoding functions. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function replaces the contents of pCodebookMap with the decoded + codebook indexes. By calling hufffac, it decodes scale factor data. Call + huffspec_fxp to decode spectral coefficients of current frame. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p24 (Table 4.4.24) + p54 (4.5.2.3.2) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pGroup = group; + + global_gain = CALL getbits( + neededBits = LEN_SCL_PCM, + pInputStream = pInputStream) + MODIFYING(pInputStream) + ReTURNING(global_gain) + + IF (common_window == FALSE) + THEN + status = CALL get_ics_info( + pVars->mc_info.audioObjectType, + pInputStream, + common_window, + &pChVars->wnd, + &pChVars->wnd_shape_this_bk, + group, + pMax_sfb, + pWinMap, + &pChVars->lt_status, + NULL) + MODIFYING(pInputStream,pChVars,group,max_sfb,lt_status) + RETURNING(status) + ENDIF + + memcpy(pFrameInfo, pWinMap[pChVars->wnd], sizeof(FrameInfo)) + + IF (*pMax_sfb > 0) + THEN + + i = 0; + totSfb = 0; + + DO + + totSfb++; + + WHILE( *pGroup++ < pFrameInfo->num_win); + + totSfb *= pFrameInfo->sfb_per_win[0]; + + nsect = CALL huffcb( + sect, + pInputStream, + pFrameInfo->sectbits, + totSfb, + pFrameInfo->sfb_per_win[0], + *pMax_sfb) + MODIFYING(sect,pInputStream,sectbits) + RETURNING(nsect) + + IF (nsect == 0) + THEN + status = 1 + + ENDIF + + sectStart = 0; + FOR (i = 0; i < nsect; i++) + + cb = sect[i].sect_cb; + sectWidth = sect[i].sect_end - sectStart; + sectStart += sectWidth; + + WHILE (sectWidth > 0) + + *pCodebookMap++ = cb + sectWidth-- + ENDWHILE + + ENDFOR (i) + + ELSE + + memset(pCodebookMap,ZERO_HCB,MAXBANDS*sizeof(*pCodebookMap)); + + ENDIF (*pMax_sfb) + + IF (pFrameInfo->islong == FALSE) + THEN + CALL calc_gsfb_table( + pFramInfo = pFrameInfo, + group[] = group) + MODIFYING(pFrameInfo->frame_sfb_top) + RETURNING(void) + ENDIF + + IF (status == SUCCESS) + THEN + status = CALL hufffac( + pFrameInfo, + pInputStream, + group, + nsect, + sect, + global_gain, + pChVars->factors, + pVars->huffBookUsed) + MODIFYING(pInputStream,factors) + RETURNING(status) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_PULSE_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + pPulseInfo->pulse_data_present = present; + + IF (present != FALSE) + THEN + IF (pFrameInfo->islong == 1) + THEN + CALL get_pulse_data( + pPulseInfo = pPulseInfo, + pInputStream = pInputStream) + MODIFYING(pInputStream,pPulseInfo) + RETURNING(void) + + ELSE + + status = 1; + + ENDIF (pFrameInfo) + ENDIF (present) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_TNS_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + pTnsFrameInfo->tns_data_present = present; + + IF (present != FALSE) + THEN + CALL get_tns( + pFrameInfo = pFrameInfo, + pTnsFrameInfo = pTnsFrameInfo, + pInputStream = pInputStream) + MODIFYING(pInputStream, pTnsFrameInfo) + RETURNING(void) + ELSE + + FOR (i = pTnsFrameInfo->n_subblocks - 1; i >= 0 ; i--) + + pTnsFrameInfo->info[i].n_filt = 0; + ENDFOR + + ENDIF(present) + + ENDIF (status) + + IF (status == SUCCESS) + THEN + present = CALL getbits( + neededBits = LEN_GAIN_PRES, + pInputStream = pInputStream) + MODIFYING(pInputStream) + RETURNING(present) + + IF (present != FALSE) + THEN + status = 1; + ENDIF + ENDIF (status) + + IF (status == SUCCESS) + THEN + status = CALL huffspec_fxp( + pFrameInfo, + pInputStream, + nsect, + sect, + pChVars->factors, + pChVars->fxpCoef, + pVars->quantSpec, + pVars->tmp_spec, + pWinMap[ONLY_LONG_WINDOW], + pPulseInfo, + pChVars->qFormat) + MODIFYING(pInputStream,fxpCoef,quantSpec,tmp_spec,qFormat) + RETURNING(status) + ENDIF + + RETURN status + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_huffmanconst.h" +#include "huffman.h" +#include "aac_mem_funcs.h" +#include "get_tns.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int getics( + BITS *pInputStream, + Int common_window, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars, + Int group[], + Int *pMax_sfb, + Int *pCodebookMap, + TNS_frame_info *pTnsFrameInfo, + FrameInfo **pWinMap, + PulseInfo *pPulseInfo, + SectInfo sect[]) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int status = SUCCESS; + + Int nsect = 0; + Int i; + Int cb; + Int sectWidth; + Int sectStart; + Int totSfb; + Int *pGroup; + + FrameInfo *pFrameInfo; + + Int global_gain; /* originally passed in from huffdecode */ + Bool present; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + pGroup = group; + + /* read global gain from Input bitstream */ + global_gain = + get9_n_lessbits( + LEN_SCL_PCM, + pInputStream); + + if (common_window == FALSE) + { + status = get_ics_info( + pVars->mc_info.audioObjectType, + pInputStream, + common_window, + &pChVars->wnd, + &pChVars->wnd_shape_this_bk, + group, + pMax_sfb, + pWinMap, + &pChVars->pShareWfxpCoef->lt_status, + NULL); + } + + pFrameInfo = pWinMap[pChVars->wnd]; + + /* First, calculate total number of scalefactor bands + * for this grouping. Then, decode section data + */ + if (*pMax_sfb > 0) + { + + /* calculate total number of sfb */ + i = 0; + totSfb = 0; + + do + { + totSfb++; + + } + while (*pGroup++ < pFrameInfo->num_win); + + totSfb *= pFrameInfo->sfb_per_win[0]; + + /* decode section data */ + nsect = + huffcb( + sect, + pInputStream, + pFrameInfo->sectbits, + totSfb, + pFrameInfo->sfb_per_win[0], + *pMax_sfb); + + if (nsect == 0) + { + status = 1; /* decode section data error */ + + }/* if (nsect) */ + + /* generate "linear" description from section info + * stored as codebook for each scalefactor band and group + * when nsect == 0, for-loop does not execute + */ + sectStart = 0; + for (i = 0; i < nsect; i++) + { + cb = sect[i].sect_cb; + sectWidth = sect[i].sect_end - sectStart; + sectStart += sectWidth; + + while (sectWidth > 0) + { + *pCodebookMap++ = cb; /* cannot use memset for Int */ + sectWidth--; + } + + } /* for (i) */ + + } + else + { + /* set all sections with ZERO_HCB */ + pv_memset( + pCodebookMap, + ZERO_HCB, + MAXBANDS*sizeof(*pCodebookMap)); + /* + for (i=MAXBANDS; i>0; i--) + { + *(pCodebookMap++) = ZERO_HCB; + } + */ + + } /* if (*pMax_sfb) */ + + /* calculate band offsets + * (because of grouping and interleaving this cannot be + * a constant: store it in pFrameInfo->frame_sfb_top) + */ + if (pFrameInfo->islong == FALSE) + { + calc_gsfb_table( + pFrameInfo, + group); + } + + /* decode scale factor data */ + if (status == SUCCESS) + { + status = + hufffac( + pFrameInfo, + pInputStream, + group, + nsect, + sect, + global_gain, + pChVars->pShareWfxpCoef->factors, + pVars->scratch.huffbook_used); + + } /* if (status) */ + + /* noiseless coding */ + if (status == SUCCESS) + { + present = + get1bits(pInputStream); + + pPulseInfo->pulse_data_present = present; + + if (present != FALSE) + { + if (pFrameInfo->islong == 1) + { + status = get_pulse_data( + pPulseInfo, + pInputStream); + } + else + { + /* CommonExit(1,"Pulse data not allowed for short blocks"); */ + status = 1; + + } /* if (pFrameInfo) */ + } /* if (present) */ + + } /* if (status) */ + + + /* decode tns data */ + if (status == SUCCESS) + { + present = + get1bits(pInputStream); + + pTnsFrameInfo->tns_data_present = present; + + if (present != FALSE) + { + get_tns( + pChVars->pShareWfxpCoef->max_sfb, + pInputStream, + pChVars->wnd, + pFrameInfo, + &pVars->mc_info, + pTnsFrameInfo, + pVars->scratch.tns_decode_coef); + } + else + { + for (i = pFrameInfo->num_win - 1; i >= 0 ; i--) + { + pTnsFrameInfo->n_filt[i] = 0; + } + + } /* if(present) */ + + } /* if (status) */ + + /* gain control */ + if (status == SUCCESS) + { + present = + get1bits(pInputStream); + + if (present != FALSE) + { + /* CommonExit(1, "Gain control not implemented"); */ + status = 1; + } + } /* if (status) */ + + if (status == SUCCESS) + { + status = + huffspec_fxp( + pFrameInfo, + pInputStream, + nsect, + sect, + pChVars->pShareWfxpCoef->factors, + pChVars->fxpCoef, + pVars->share.a.quantSpec, + pVars->scratch.tmp_spec, + pWinMap[ONLY_LONG_WINDOW], + pPulseInfo, + pChVars->pShareWfxpCoef->qFormat); + } + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + + return status; + +} /* getics */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/getmask.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/getmask.c new file mode 100644 index 00000000..38b471c2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/getmask.c @@ -0,0 +1,356 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: getmask.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = pointer to structure that holds information for current + frame, Type FrameInfo + + pInputStream= pointer to structure that holds input stream information + Type BITS + + pGroup = pointer to array that holds the stop window index for + each group in current frame, Type Int + + max_sfb = number of active sfbs for each window, Type Int + + mask[] = array that holds the MS_mask information + Type Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + mask_present = 0 (no Mid/Side mixed) + 2 (Mid/Side mixed present for entire frame) + 1 (Mid/Side mixed information read from bitstream) + -1 (invalid mask_present read from bitstream) + + Pointers and Buffers Modified: + pMask contents replaced by MS information of each scalefactor band + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function reads the Mid/Side(MS) mask information from the input + bitstream. If the mask_present field is equal to 2, the mask bits is set to + 1 for the entire frame. If mask_present has a value of 0, the function + returns 0, If mask_present is set to 1, the Mid/Side(MS) information is + read from the input stream. When mask_present is 3, an error code (-1) is + generated. + The Mid/Side(MS) information is later used for mixing the left and right + channel sounds. Each scalefactor band has its own MS information. + + (ISO comments: read a synthesis mask, read a synthesis mask uses + EXTENDED_MS_MASK and grouped mask ) + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall replace the contents of pMask with the MS information + of each scalefactor band + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 + p15 (Table 4.4.5 getmask) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + CALL getbits(LEN_MASK_PRES, pInputStream) + MODIFYING (pInputStream) + RETURNING (mask present information) + mask_present = mask present information + + SWITCH (mask_present) + + CASE (0): + BREAK; + + CASE (2): + nwin = pFrameInfo->num_win; + FOR(win = 0; win < nwin; win = *(pGroup++)) + + FOR(sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--) + *(pMask++) = 1; + ENDFOR + + ENDFOR + + BREAK; + + CASE(1): + + nwin = pFrameInfo->num_win; + + nToDo = max_sfb; + + WHILE (nToDo > 0) + nCall = nToDo; + + IF (nCall > MAX_GETBITS) + THEN + nCall = MAX_GETBITS; + ENDIF + + tempMask = + getbits( + nCall, + pInputStream); + + bitmask = 1 << (nCall - 1); + FOR (sfb = nCall; sfb > 0; sfb--) + *(pMask++) = (tempMask & bitmask) >> (sfb - 1); + bitmask >>= 1; + ENDFOR + + nToDo -= nCall; + END WHILE + + pv_memset( + pMask, + 0, + (pFrameInfo->sfb_per_win[win]-max_sfb)*sizeof(*pMask)); + + ENDFOR (win) + + BREAK + + DEFAULT: + mask_present = -1 + + ENDSWITCH + + RETURN mask_present + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" +#include "aac_mem_funcs.h" +#include "e_maskstatus.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int getmask( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int group[], + Int max_sfb, + Int mask[]) +{ + + Int win; /* window index */ + Int sfb; + Int mask_present; + Int *pMask; + Int *pGroup; + Int nwin; + Int nCall; + Int nToDo; + UInt32 tempMask; + UInt32 bitmask; + + pMask = mask; + pGroup = group; + + mask_present = + get9_n_lessbits( + LEN_MASK_PRES, + pInputStream); + + switch (mask_present) + { + case(MASK_NOT_PRESENT): + /* special EXTENDED_MS_MASK cases */ + /* no ms at all */ + break; + + case(MASK_ALL_FRAME): + /* MS for whole spectrum on, mask bits set to 1 */ + nwin = pFrameInfo->num_win; + for (win = 0; win < nwin; win = *(pGroup++)) + { + for (sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--) + { + *(pMask++) = 1; /* cannot use memset for Int type */ + } + + } + + break; + + case(MASK_FROM_BITSTREAM): + /* MS_mask_present==1, get mask information*/ + nwin = pFrameInfo->num_win; + for (win = 0; win < nwin; win = *(pGroup++)) + { + /* + * the following code is equivalent to + * + * for(sfb = max_sfb; sfb > 0; sfb--) + * { + * *(pMask++) = + * getbits( + * LEN_MASK, + * pInputStream); + * } + * + * in order to save the calls to getbits, the above + * for-loop is broken into two parts + */ + + nToDo = max_sfb; + + while (nToDo > 0) + { + nCall = nToDo; + + if (nCall > MAX_GETBITS) + { + nCall = MAX_GETBITS; + } + + tempMask = + getbits( + nCall, + pInputStream); + + bitmask = (UInt32) 1 << (nCall - 1); + for (sfb = nCall; sfb > 0; sfb--) + { + *(pMask++) = (Int)((tempMask & bitmask) >> (sfb - 1)); + bitmask >>= 1; + } + + nToDo -= nCall; + } + + /* + * set remaining sfbs to zero + * re-use nCall to save one variable on stack + */ + + nCall = pFrameInfo->sfb_per_win[win] - max_sfb; + + + if (nCall >= 0) + { + pv_memset(pMask, + 0, + nCall*sizeof(*pMask)); + + pMask += nCall; + } + else + { + mask_present = MASK_ERROR; + break; + } + + + } /* for (win) */ + + break; + + default: + /* error */ + break; + + } /* switch (mask_present) */ + + return mask_present; + +} /* getmask */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables.h new file mode 100644 index 00000000..cea34cf0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hcbtables.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Declare the structure array for Huffman Codebooks information. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef _HCBTABLES_H +#define _HCBTABLES_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "s_hcb.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /* ISO: Hcb book[NSPECBOOKS + 2]; */ + + extern const Hcb hcbbook_binary[13]; + extern const Int32 huff_tab1[88]; + extern const Int32 huff_tab2[90]; + extern const Int32 huff_tab3[151]; + extern const Int32 huff_tab4[119]; + extern const Int32 huff_tab5[110]; + extern const Int32 huff_tab6[113]; + extern const Int32 huff_tab7[107]; + extern const Int32 huff_tab8[90]; + extern const Int32 huff_tab9[204]; + extern const Int32 huff_tab10[186]; + extern const Int32 huff_tab11[301]; + extern const UInt32 huff_tab_scl[188]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables_binary.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables_binary.c new file mode 100644 index 00000000..fc39be82 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/hcbtables_binary.c @@ -0,0 +1,1896 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hcbtables_binary.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: None + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This file defines the 12 packed Huffman Tables and a structure that reference + to these tables. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + ISO/IEC 14496-3: 1999(E) + Subpart 4 p78 (Table 4.6.1 and Table 4.6.2) + p77 (pseudo code) + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "s_hcb.h" +#include "hcbtables.h" + +/* This file store packed Huffman tables for binary tree search */ + +/* + * all tables are packed in the following way: + * right pointer (7 bits) idx (9 bits) + */ + + +const Hcb hcbbook_binary[13] = +{ + + { 0, -1, -1, -1, -1 }, /* ZERO_HCB */ + { 1, 4, 3, 1, 1 }, /* codebook 1 */ + { 2, 4, 3, 1, 1 }, /* codebook 2 */ + { 3, 4, 3, 0, 0 }, /* codebook 3 */ + { 4, 4, 3, 0, 0 }, /* codebook 4 */ + { 5, 2, 9, 4, 1 }, + { 6, 2, 9, 4, 1 }, + { 7, 2, 8, 0, 0 }, + { 8, 2, 8, 0, 0 }, + { 9, 2, 13, 0, 0 }, + {10, 2, 13, 0, 0 }, + {11, 2, 17, 0, 0 }, /* codebook 11 ESC book */ + {12, -1, -1, -1, -1 } /* scalefactor codebook */ + + +}; + + +/* New look-up table for huffman decoding + Created by ordering the codeword in the table according to their + normalized shifted binary value, i.e., all the codewords are left + shifted to meet the maximum codelength. Example, max codelength is + 10, the codeword with lenth 3 will left shift by 7. + The binary values of after the shift are sorted. + Then the sorted table is divided into several partition. + At the VLC decoding period, input is read in at max codelenght. + The partition is decided using if-else logic. + Inside each partition, a look-up table is used to map the input value + to a correct symbol. Table entries can appear to be repeated according + to the humming distance between adjacent codewords. +*/ + +const Int32 huff_tab1[88] = +{ + 0x430005, + 0xd0005, + 0x270005, + 0x310005, + 0x290005, + 0x250005, + 0x2b0005, + 0x1f0005, + 0x3a0007, + 0x160007, + 0x260007, + 0x2e0007, + 0x220007, + 0x2a0007, + 0x4c0007, + 0x240007, + 0x40007, + 0x1c0007, + 0x400007, + 0x300007, + 0x100007, + 0x2c0007, + 0x460007, + 0x200007, + 0x340007, + 0x320007, + 0xa0007, + 0x440007, + 0xc0007, + 0x420007, + 0xe0007, + 0x1e0007, + 0x490009, + 0x130009, + 0x3d0009, + 0x330009, + 0x2f0009, + 0x230009, + 0x210009, + 0x370009, + 0x410009, + 0x2d0009, + 0x190009, + 0xf0009, + 0x70009, + 0x1d0009, + 0x3b0009, + 0x390009, + 0x150009, + 0x10009, + 0x1b0009, + 0x350009, + 0x450009, + 0x4d0009, + 0x170009, + 0x4f0009, + 0x5000a, + 0x5000a, + 0x9000a, + 0x9000a, + 0x4b000a, + 0x4b000a, + 0x3f000a, + 0x3f000a, + 0xb000a, + 0xb000a, + 0x3000a, + 0x3000a, + 0x11000a, + 0x11000a, + 0x47000a, + 0x47000a, + 0x3c000b, + 0x14000b, + 0x18000b, + 0x38000b, + 0x50000b, + 0x8000b, + 0x48000b, + 0x6000b, + 0xb, + 0x4a000b, + 0x3e000b, + 0x1a000b, + 0x12000b, + 0x2000b, + 0x36000b, + 0x4e000b +}; + +const Int32 huff_tab2[90] = +{ + 0x430004, + 0x430004, + 0x430004, + 0x430004, + 0xd0005, + 0xd0005, + 0x290005, + 0x290005, + 0x250005, + 0x250005, + 0x270005, + 0x270005, + 0x1f0005, + 0x1f0005, + 0x2b0005, + 0x2b0005, + 0x310005, + 0x310005, + 0x220006, + 0x160006, + 0x2e0006, + 0x2a0006, + 0x300006, + 0x260006, + 0xc0006, + 0x3a0006, + 0x400006, + 0x40006, + 0x240006, + 0x460006, + 0x440006, + 0x200006, + 0x100006, + 0x320006, + 0x1c0006, + 0xe0006, + 0x1e0006, + 0xa0006, + 0x4c0006, + 0x340006, + 0x2c0006, + 0x420006, + 0x2f0007, + 0x410007, + 0x130007, + 0x210007, + 0x3d0007, + 0x4b0007, + 0x470007, + 0x190007, + 0x1d0007, + 0x4f0007, + 0xf0007, + 0x10007, + 0xb0007, + 0x370007, + 0x490007, + 0x3b0008, + 0x150008, + 0x70008, + 0x110008, + 0x50008, + 0x30008, + 0x1b0008, + 0x450008, + 0x3f0008, + 0x2d0008, + 0x350008, + 0x170008, + 0x90008, + 0x330008, + 0x390008, + 0x230008, + 0x4d0008, + 0x3c0008, + 0x140008, + 0x380009, + 0x9, + 0x180009, + 0x1a0009, + 0x500009, + 0x60009, + 0x3e0009, + 0x120009, + 0x80009, + 0x480009, + 0x360009, + 0x20009, + 0x4a0009, + 0x4e0009 +}; + +const Int32 huff_tab3[151] = +{ + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x10004, + 0x10004, + 0x10004, + 0x10004, + 0x90004, + 0x90004, + 0x90004, + 0x90004, + 0x30004, + 0x30004, + 0x30004, + 0x30004, + 0x240005, + 0x240005, + 0x40005, + 0x40005, + 0xc0006, + 0xa0006, + 0x1e0006, + 0xd0006, + 0x1c0006, + 0x270006, + 0x280007, + 0x280007, + 0x280007, + 0x280007, + 0x1f0007, + 0x1f0007, + 0x1f0007, + 0x1f0007, + 0x250007, + 0x250007, + 0x250007, + 0x250007, + 0x360008, + 0x360008, + 0x20008, + 0x20008, + 0x50008, + 0x50008, + 0x3f0008, + 0x3f0008, + 0x300008, + 0x300008, + 0x70009, + 0x100009, + 0x2d0009, + 0xe0009, + 0x420009, + 0x60009, + 0x150009, + 0xf0009, + 0x120009, + 0xb0009, + 0x390009, + 0x310009, + 0x160009, + 0x2a0009, + 0x2b0009, + 0x2e000a, + 0x21000a, + 0x22000a, + 0x13000a, + 0x43000a, + 0x29000a, + 0x40000a, + 0x20000a, + 0x8000a, + 0x11000a, + 0x4b000a, + 0x33000a, + 0x1d000a, + 0x37000a, + 0x19000a, + 0x48000b, + 0x48000b, + 0x34000b, + 0x34000b, + 0x26000b, + 0x26000b, + 0x3a000b, + 0x3a000b, + 0x2c000b, + 0x2c000b, + 0x4c000b, + 0x4c000b, + 0x18000b, + 0x18000b, + 0x17000b, + 0x17000b, + 0x23000c, + 0x49000c, + 0x45000c, + 0x4e000c, + 0x1a000c, + 0x4f000c, + 0x46000c, + 0x32000c, + 0x35000c, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x14000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x3c000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x2f000d, + 0x3d000e, + 0x3d000e, + 0x3d000e, + 0x3d000e, + 0x44000e, + 0x44000e, + 0x44000e, + 0x44000e, + 0x41000e, + 0x41000e, + 0x41000e, + 0x41000e, + 0x50000f, + 0x50000f, + 0x4d000f, + 0x4d000f, + 0x47000f, + 0x47000f, + 0x3b000f, + 0x3b000f, + 0x38000f, + 0x38000f, + 0x4a0010, + 0x3e0010 +}; + +const Int32 huff_tab4[119] = +{ + 0x280004, + 0x280004, + 0xd0004, + 0xd0004, + 0x250004, + 0x250004, + 0x270004, + 0x270004, + 0x1f0004, + 0x1f0004, + 0x1b0004, + 0x1b0004, + 0x240004, + 0x240004, + 0x4, + 0x4, + 0x40004, + 0x40004, + 0x1e0004, + 0x1e0004, + 0x1c0005, + 0xc0005, + 0x10005, + 0xa0005, + 0x30005, + 0x90005, + 0x430007, + 0x430007, + 0x2b0007, + 0x2b0007, + 0x310007, + 0x310007, + 0x290007, + 0x290007, + 0x420007, + 0x420007, + 0x400007, + 0x400007, + 0x300007, + 0x300007, + 0x3a0007, + 0x3a0007, + 0x100007, + 0x100007, + 0xe0008, + 0x2a0008, + 0x160008, + 0x200008, + 0x2e0008, + 0x260008, + 0x220008, + 0x3f0008, + 0x390008, + 0x2d0008, + 0x370008, + 0xb0008, + 0x150008, + 0x50008, + 0xf0008, + 0x130008, + 0x1d0008, + 0x70008, + 0x210008, + 0x360008, + 0x20008, + 0x120009, + 0x120009, + 0x60009, + 0x60009, + 0x340009, + 0x340009, + 0x4c0009, + 0x4c0009, + 0x460009, + 0x460009, + 0x2c0009, + 0x2c0009, + 0x320009, + 0x320009, + 0x440009, + 0x440009, + 0x33000a, + 0x4b000a, + 0x45000a, + 0x19000a, + 0x11000a, + 0x49000a, + 0x17000a, + 0x3d000a, + 0x23000a, + 0x4f000a, + 0x2f000a, + 0x3b000a, + 0x41000a, + 0x35000a, + 0x47000b, + 0x47000b, + 0x4d000b, + 0x4d000b, + 0x18000b, + 0x18000b, + 0x48000b, + 0x48000b, + 0x8000b, + 0x8000b, + 0x3c000b, + 0x3c000b, + 0x14000b, + 0x14000b, + 0x38000b, + 0x38000b, + 0x50000b, + 0x50000b, + 0x1a000b, + 0x1a000b, + 0x4e000b, + 0x4e000b, + 0x4a000c, + 0x3e000c +}; + +const Int32 huff_tab5[110] = +{ + 0x1f0004, + 0x1f0004, + 0x310004, + 0x310004, + 0x290004, + 0x290004, + 0x270004, + 0x270004, + 0x300005, + 0x200005, + 0x1e0005, + 0x320005, + 0x160007, + 0x160007, + 0x2a0007, + 0x2a0007, + 0x3a0007, + 0x3a0007, + 0x260007, + 0x260007, + 0x150008, + 0x3b0008, + 0x1d0008, + 0x330008, + 0x170008, + 0x390008, + 0x210008, + 0x2f0008, + 0xd0008, + 0x430008, + 0x250008, + 0x2b0008, + 0xc0009, + 0xc0009, + 0x340009, + 0x340009, + 0x440009, + 0x440009, + 0x1c0009, + 0x1c0009, + 0xe0009, + 0xe0009, + 0x420009, + 0x420009, + 0x2e0009, + 0x2e0009, + 0x220009, + 0x220009, + 0x180009, + 0x180009, + 0x3c0009, + 0x3c0009, + 0x140009, + 0x140009, + 0x380009, + 0x380009, + 0xb000a, + 0x41000a, + 0x19000a, + 0x37000a, + 0x45000a, + 0x3d000a, + 0xf000a, + 0x13000a, + 0x24000a, + 0x4000a, + 0x4d000a, + 0x4c000a, + 0x3000b, + 0x2c000b, + 0x4b000b, + 0x1b000b, + 0x35000b, + 0x23000b, + 0x5000b, + 0x2d000b, + 0x40000b, + 0xa000b, + 0x10000b, + 0x1a000b, + 0x2000b, + 0x4e000b, + 0x36000b, + 0x3e000b, + 0x46000b, + 0x6000b, + 0x12000c, + 0x12000c, + 0x4a000c, + 0x4a000c, + 0x3f000c, + 0x3f000c, + 0x1000c, + 0x1000c, + 0x7000c, + 0x7000c, + 0x47000c, + 0x47000c, + 0x11000c, + 0x11000c, + 0x4f000c, + 0x4f000c, + 0x49000c, + 0x49000c, + 0x9000c, + 0x9000c, + 0x48000d, + 0x8000d, + 0x50000d, + 0xd +}; +const Int32 huff_tab6[113] = +{ + 0x280004, + 0x310004, + 0x270004, + 0x290004, + 0x1f0004, + 0x320004, + 0x200004, + 0x300004, + 0x1e0004, + 0x390006, + 0x390006, + 0x3b0006, + 0x3b0006, + 0x170006, + 0x170006, + 0x150006, + 0x150006, + 0x160006, + 0x160006, + 0x210006, + 0x210006, + 0x3a0006, + 0x3a0006, + 0x2f0006, + 0x2f0006, + 0x330006, + 0x330006, + 0x260006, + 0x260006, + 0x1d0006, + 0x1d0006, + 0x2a0006, + 0x2a0006, + 0x380006, + 0x380006, + 0x180006, + 0x180006, + 0x140006, + 0x140006, + 0x3c0006, + 0x3c0006, + 0xe0007, + 0x440007, + 0x420007, + 0x220007, + 0xc0007, + 0x340007, + 0x2e0007, + 0x1c0007, + 0x430007, + 0xd0007, + 0x250007, + 0x2b0007, + 0x450007, + 0xb0008, + 0xb0008, + 0x190008, + 0x190008, + 0x3d0008, + 0x3d0008, + 0x410008, + 0x410008, + 0x370008, + 0x370008, + 0x130008, + 0x130008, + 0xf0008, + 0xf0008, + 0x460008, + 0x460008, + 0x400009, + 0xa0009, + 0x100009, + 0x2d0009, + 0x1b0009, + 0x4d0009, + 0x50009, + 0x30009, + 0x350009, + 0x4b0009, + 0x230009, + 0x240009, + 0x60009, + 0x20009, + 0x3e0009, + 0x120009, + 0x40009, + 0x4e0009, + 0x4a0009, + 0x1a0009, + 0x4c0009, + 0x360009, + 0x2c0009, + 0x9000a, + 0x9000a, + 0x11000a, + 0x11000a, + 0x3f000a, + 0x3f000a, + 0x49000a, + 0x49000a, + 0x47000a, + 0x47000a, + 0x4f000a, + 0x4f000a, + 0x7000a, + 0x7000a, + 0x1000a, + 0x1000a, + 0x50000b, + 0x8000b, + 0xb, + 0x48000b +}; + +const Int32 huff_tab7[107] = +{ + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x80003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x10003, + 0x90004, + 0x90004, + 0x90004, + 0x90004, + 0x110006, + 0xa0006, + 0x100006, + 0x20006, + 0x190007, + 0x190007, + 0xb0007, + 0xb0007, + 0x120007, + 0x120007, + 0x180007, + 0x180007, + 0x30007, + 0x30007, + 0x130008, + 0x1a0008, + 0xc0008, + 0x210008, + 0xd0008, + 0x290008, + 0x1b0008, + 0x140008, + 0x40008, + 0x200008, + 0x220009, + 0x220009, + 0x150009, + 0x150009, + 0x2a0009, + 0x2a0009, + 0x50009, + 0x50009, + 0x310009, + 0x310009, + 0x280009, + 0x280009, + 0xe0009, + 0xe0009, + 0x230009, + 0x230009, + 0x1d0009, + 0x1d0009, + 0x1c0009, + 0x1c0009, + 0x2b0009, + 0x2b0009, + 0x160009, + 0x160009, + 0x320009, + 0x320009, + 0xf0009, + 0xf0009, + 0x1e000a, + 0x6000a, + 0x30000a, + 0x24000a, + 0x39000a, + 0x25000a, + 0x3a000a, + 0x2c000a, + 0x33000a, + 0x17000a, + 0x3b000a, + 0x34000a, + 0x2d000a, + 0x26000a, + 0x1f000a, + 0x38000b, + 0x38000b, + 0x7000b, + 0x7000b, + 0x35000b, + 0x35000b, + 0x2e000b, + 0x2e000b, + 0x3c000b, + 0x3c000b, + 0x27000b, + 0x27000b, + 0x2f000b, + 0x2f000b, + 0x3d000b, + 0x3d000b, + 0x3e000c, + 0x36000c, + 0x37000c, + 0x3f000c +}; +const Int32 huff_tab8[90] = +{ + 0x90003, + 0x90003, + 0x90003, + 0x90003, + 0x110004, + 0x110004, + 0x80004, + 0x80004, + 0xa0004, + 0xa0004, + 0x10004, + 0x10004, + 0x120004, + 0x120004, + 0x5, + 0x100005, + 0x20005, + 0x190005, + 0xb0005, + 0x1a0005, + 0x130005, + 0x1b0006, + 0x1b0006, + 0x210006, + 0x210006, + 0xc0006, + 0xc0006, + 0x220006, + 0x220006, + 0x140006, + 0x140006, + 0x180006, + 0x180006, + 0x30006, + 0x30006, + 0x230006, + 0x230006, + 0x1c0006, + 0x1c0006, + 0x2a0006, + 0x2a0006, + 0x290007, + 0x150007, + 0xd0007, + 0x2b0007, + 0x1d0007, + 0x240007, + 0x2c0007, + 0x40007, + 0x250007, + 0x200007, + 0x160007, + 0x320007, + 0x310007, + 0xe0007, + 0x1e0008, + 0x330008, + 0x2d0008, + 0x280008, + 0x340008, + 0x50008, + 0x260008, + 0x390008, + 0x3a0008, + 0x170008, + 0x350008, + 0x3b0008, + 0xf0008, + 0x2e0008, + 0x1f0008, + 0x360009, + 0x360009, + 0x3c0009, + 0x3c0009, + 0x300009, + 0x300009, + 0x270009, + 0x270009, + 0x60009, + 0x60009, + 0x3d0009, + 0x3d0009, + 0x3e0009, + 0x3e0009, + 0x370009, + 0x370009, + 0x2f000a, + 0x38000a, + 0x7000a, + 0x3f000a +}; +const Int32 huff_tab9[204] = +{ + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0x1, + 0xd0003, + 0xd0003, + 0x10003, + 0x10003, + 0xe0004, + 0x1b0006, + 0x1b0006, + 0xf0006, + 0xf0006, + 0x1a0006, + 0x1a0006, + 0x20006, + 0x20006, + 0x280007, + 0x1c0007, + 0x100007, + 0x270008, + 0x270008, + 0x30008, + 0x30008, + 0x1d0008, + 0x1d0008, + 0x290008, + 0x290008, + 0x110008, + 0x110008, + 0x350008, + 0x350008, + 0x1e0008, + 0x1e0008, + 0x120008, + 0x120008, + 0x360009, + 0x2a0009, + 0x40009, + 0x340009, + 0x420009, + 0x1f0009, + 0x130009, + 0x2b0009, + 0x430009, + 0x4f0009, + 0x370009, + 0x5000a, + 0x20000a, + 0x41000a, + 0x14000a, + 0x2c000a, + 0x15000a, + 0x69000a, + 0x38000a, + 0x44000a, + 0x50000a, + 0x5c000a, + 0x6000a, + 0x6a000a, + 0x22000a, + 0x2d000a, + 0x21000a, + 0x39000a, + 0x76000a, + 0x16000a, + 0x5d000a, + 0x4e000b, + 0x45000b, + 0x51000b, + 0x6b000b, + 0x7000b, + 0x77000b, + 0x2f000b, + 0x3a000b, + 0x2e000b, + 0x8000b, + 0x83000b, + 0x52000b, + 0x23000b, + 0x46000b, + 0x68000b, + 0x5b000b, + 0x5e000b, + 0x84000b, + 0x78000b, + 0x6c000b, + 0x17000b, + 0x5f000b, + 0x53000b, + 0x47000b, + 0x3c000b, + 0x3b000b, + 0x30000b, + 0x90000b, + 0x49000b, + 0x75000b, + 0x6d000b, + 0x85000c, + 0x24000c, + 0x9000c, + 0x91000c, + 0x79000c, + 0x54000c, + 0x9d000c, + 0x3d000c, + 0x6e000c, + 0x18000c, + 0x7a000c, + 0x86000c, + 0x48000c, + 0x60000c, + 0x25000c, + 0x19000c, + 0x9e000c, + 0x92000c, + 0x31000c, + 0x4a000c, + 0x55000c, + 0x6f000c, + 0x93000c, + 0xa000c, + 0x61000c, + 0x9f000c, + 0x82000c, + 0x87000c, + 0x3e000c, + 0x56000c, + 0x26000c, + 0x7b000c, + 0x7c000c, + 0x3f000c, + 0x8f000c, + 0x57000c, + 0x32000c, + 0x4b000c, + 0x70000d, + 0x63000d, + 0xa1000d, + 0x33000d, + 0x94000d, + 0x62000d, + 0xa0000d, + 0x95000d, + 0x88000d, + 0x40000d, + 0x64000d, + 0x4c000d, + 0xb000d, + 0xa2000d, + 0x58000d, + 0x9c000d, + 0x89000d, + 0x4d000d, + 0x65000d, + 0x7d000d, + 0xc000d, + 0x96000d, + 0x71000d, + 0x7e000d, + 0x8a000d, + 0x66000d, + 0xa3000d, + 0x59000d, + 0x73000d, + 0x97000d, + 0x67000d, + 0x5a000d, + 0x72000e, + 0x72000e, + 0x8b000e, + 0x8b000e, + 0x74000e, + 0x74000e, + 0x7f000e, + 0x7f000e, + 0x80000e, + 0x80000e, + 0x81000e, + 0x81000e, + 0x8d000e, + 0x8d000e, + 0xa5000e, + 0xa5000e, + 0x8c000e, + 0x8c000e, + 0x98000e, + 0x98000e, + 0xa4000e, + 0xa4000e, + 0x99000e, + 0x99000e, + 0xa6000e, + 0xa6000e, + 0xa7000e, + 0xa7000e, + 0x8e000f, + 0x9a000f, + 0x9b000f, + 0xa8000f +}; +const Int32 huff_tab10[186] = +{ + 0xe0004, + 0xe0004, + 0xe0004, + 0xe0004, + 0xf0004, + 0xf0004, + 0xf0004, + 0xf0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1b0004, + 0x1c0005, + 0x1c0005, + 0xd0005, + 0xd0005, + 0x10005, + 0x10005, + 0x100005, + 0x100005, + 0x290005, + 0x290005, + 0x280005, + 0x280005, + 0x1d0005, + 0x1d0005, + 0x2a0005, + 0x2a0005, + 0x1a0006, + 0x20006, + 0x1e0006, + 0x360006, + 0x110006, + 0x350006, + 0x6, + 0x370006, + 0x2b0006, + 0x270006, + 0x30006, + 0x380006, + 0x1f0006, + 0x430006, + 0x120007, + 0x420007, + 0x440007, + 0x2c0007, + 0x450007, + 0x390007, + 0x500007, + 0x200007, + 0x510007, + 0x340007, + 0x4f0007, + 0x40007, + 0x130007, + 0x2d0007, + 0x460007, + 0x520007, + 0x3a0007, + 0x530008, + 0x5d0008, + 0x2e0008, + 0x210008, + 0x470008, + 0x6a0008, + 0x5e0008, + 0x410008, + 0x5c0008, + 0x50008, + 0x690008, + 0x140008, + 0x6b0008, + 0x5f0008, + 0x3b0008, + 0x220008, + 0x540008, + 0x600008, + 0x150008, + 0x2f0008, + 0x6c0008, + 0x3c0008, + 0x480008, + 0x6d0008, + 0x490008, + 0x610009, + 0x550009, + 0x770009, + 0x4e0009, + 0x560009, + 0x780009, + 0x300009, + 0x760009, + 0x230009, + 0x60009, + 0x6e0009, + 0x790009, + 0x3d0009, + 0x840009, + 0x160009, + 0x620009, + 0x6f0009, + 0x7a0009, + 0x630009, + 0x850009, + 0x4a0009, + 0x860009, + 0x240009, + 0x830009, + 0x310009, + 0x7b0009, + 0x570009, + 0x680009, + 0x3e0009, + 0x5b0009, + 0x910009, + 0x64000a, + 0x92000a, + 0x88000a, + 0x17000a, + 0x90000a, + 0x7c000a, + 0x7000a, + 0x70000a, + 0x87000a, + 0x32000a, + 0x4b000a, + 0x71000a, + 0x94000a, + 0x8000a, + 0x93000a, + 0x25000a, + 0x65000a, + 0x58000a, + 0x89000a, + 0x3f000a, + 0x18000a, + 0x9e000a, + 0x7d000a, + 0x9f000a, + 0x95000a, + 0x4c000a, + 0xa0000a, + 0x96000a, + 0xa1000a, + 0x33000a, + 0x59000a, + 0x75000a, + 0x8a000a, + 0x82000a, + 0x9d000a, + 0x9000a, + 0x40000a, + 0x7e000a, + 0xa2000a, + 0x26000a, + 0x72000a, + 0x7f000b, + 0x19000b, + 0x97000b, + 0xa3000b, + 0x66000b, + 0x4d000b, + 0x5a000b, + 0x8b000b, + 0x73000b, + 0xa4000b, + 0xa000b, + 0x67000b, + 0x8f000b, + 0x8c000b, + 0x98000b, + 0x99000b, + 0xb000b, + 0x9a000b, + 0x80000b, + 0x8d000b, + 0x9c000b, + 0x74000b, + 0xa5000c, + 0x8e000c, + 0x81000c, + 0x9b000c, + 0xa7000c, + 0xc000c, + 0xa6000c, + 0xa8000c +}; +const Int32 huff_tab11[301] = +{ + 0x4, + 0x4, + 0x4, + 0x4, + 0x120004, + 0x120004, + 0x120004, + 0x120004, + 0x1200005, + 0x1200005, + 0x110005, + 0x110005, + 0x10005, + 0x10005, + 0x230005, + 0x230005, + 0x130005, + 0x130005, + 0x240005, + 0x240005, + 0x140006, + 0x340006, + 0x350006, + 0x220006, + 0x250006, + 0x20006, + 0x360006, + 0x450007, + 0x150007, + 0x460007, + 0x260007, + 0x470007, + 0x370007, + 0x330007, + 0x30007, + 0x560007, + 0x570007, + 0x270007, + 0x480007, + 0x160007, + 0x580007, + 0x380007, + 0x590007, + 0x490008, + 0x680008, + 0x280008, + 0x670008, + 0x690008, + 0x390008, + 0x170008, + 0x540008, + 0x430008, + 0x1150008, + 0x1130008, + 0x1140008, + 0x6a0008, + 0x1160008, + 0x440008, + 0x4a0008, + 0x40008, + 0x320008, + 0x5a0008, + 0x650008, + 0x1170008, + 0x1120008, + 0x1180008, + 0x290008, + 0x790008, + 0x3a0008, + 0x6b0008, + 0x5b0008, + 0x760008, + 0x11a0008, + 0x7a0008, + 0x780008, + 0x1190008, + 0x870008, + 0x210008, + 0x180008, + 0x4b0008, + 0x11b0008, + 0x7b0008, + 0x11c0008, + 0x980008, + 0x1110008, + 0x6c0008, + 0xa90008, + 0x2a0008, + 0x5c0008, + 0xba0008, + 0x11d0008, + 0x8b0008, + 0x8a0008, + 0x3b0008, + 0x550008, + 0x11e0008, + 0xcb0008, + 0x7c0008, + 0x4c0008, + 0x6d0008, + 0x7d0008, + 0x50008, + 0x8c0009, + 0x11f0009, + 0xdc0009, + 0x190009, + 0x890009, + 0xfe0009, + 0x5d0009, + 0xed0009, + 0x3c0009, + 0x8d0009, + 0x7e0009, + 0x2b0009, + 0x8e0009, + 0x9b0009, + 0x9c0009, + 0x10f0009, + 0x4d0009, + 0x6e0009, + 0x660009, + 0x9d0009, + 0x5e0009, + 0x8f0009, + 0x7f0009, + 0x1a0009, + 0xad0009, + 0x60009, + 0xac0009, + 0x9a0009, + 0x9e0009, + 0x4e0009, + 0x2c0009, + 0x9f0009, + 0x3d0009, + 0x6f0009, + 0xae0009, + 0x900009, + 0xaf0009, + 0xa00009, + 0xbe0009, + 0x1b0009, + 0x770009, + 0xb00009, + 0x800009, + 0x3e0009, + 0x5f0009, + 0xab0009, + 0x4f0009, + 0xbd0009, + 0xdf0009, + 0x700009, + 0xe00009, + 0x2d0009, + 0x1100009, + 0x600009, + 0xc00009, + 0xbf000a, + 0xa1000a, + 0x81000a, + 0x91000a, + 0x10000a, + 0x51000a, + 0x7000a, + 0x40000a, + 0xc1000a, + 0xde000a, + 0xe1000a, + 0xcf000a, + 0x2f000a, + 0xe2000a, + 0x92000a, + 0x71000a, + 0xb2000a, + 0xb1000a, + 0xf0000a, + 0xd0000a, + 0x1c000a, + 0x50000a, + 0xbc000a, + 0x3f000a, + 0x1e000a, + 0xce000a, + 0x82000a, + 0x41000a, + 0x61000a, + 0x62000a, + 0xf2000a, + 0x52000a, + 0xc2000a, + 0xf1000a, + 0xd1000a, + 0xe3000a, + 0xd2000a, + 0x88000a, + 0xc3000a, + 0x2e000a, + 0xa2000a, + 0xf3000a, + 0x73000a, + 0xb4000a, + 0x101000a, + 0x93000a, + 0xa3000a, + 0xf4000a, + 0xb3000a, + 0x63000a, + 0xc4000a, + 0xef000a, + 0x30000a, + 0x72000a, + 0x1d000a, + 0xe5000a, + 0x8000a, + 0xe4000a, + 0x83000a, + 0xd3000a, + 0x84000a, + 0x102000a, + 0xcd000a, + 0x74000a, + 0x31000a, + 0x104000a, + 0x103000a, + 0x1f000a, + 0xa4000a, + 0x53000a, + 0xf5000a, + 0x95000a, + 0xe6000a, + 0x94000a, + 0x64000a, + 0x42000a, + 0xb5000a, + 0xc5000a, + 0xd4000a, + 0x105000a, + 0x106000a, + 0x96000a, + 0x100000a, + 0x85000a, + 0x99000a, + 0x9000a, + 0xa6000a, + 0xa5000a, + 0xd5000a, + 0xf6000a, + 0xb7000a, + 0xf7000a, + 0xd6000a, + 0x75000a, + 0x86000a, + 0xa7000b, + 0x107000b, + 0xc6000b, + 0xc9000b, + 0x20000b, + 0xb6000b, + 0xb8000b, + 0xe8000b, + 0xe7000b, + 0xc8000b, + 0xc7000b, + 0x97000b, + 0xf9000b, + 0xe9000b, + 0xd9000b, + 0x108000b, + 0xf8000b, + 0xaa000b, + 0xd7000b, + 0xa8000b, + 0xa000b, + 0xd8000b, + 0xbb000b, + 0xda000b, + 0xb9000b, + 0xea000b, + 0xd000b, + 0xfa000b, + 0x109000b, + 0x10a000b, + 0xca000b, + 0xfb000b, + 0xdd000b, + 0xb000b, + 0xeb000b, + 0x10b000b, + 0x10c000b, + 0xdb000b, + 0xee000b, + 0xfc000b, + 0xec000b, + 0xcc000b, + 0xfd000b, + 0xe000c, + 0xc000c, + 0x10d000c, + 0xff000c, + 0xf000c, + 0x10e000c +}; + +const UInt32 huff_tab_scl[188] = +{ + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3b0003, + 0x3d0004, + 0x3d0004, + 0x3d0004, + 0x3d0004, + 0x3a0004, + 0x3a0004, + 0x3a0004, + 0x3a0004, + 0x3e0004, + 0x3e0004, + 0x3e0004, + 0x3e0004, + 0x390005, + 0x390005, + 0x3f0005, + 0x3f0005, + 0x380006, + 0x400006, + 0x370006, + 0x410006, + 0x420007, + 0x420007, + 0x420007, + 0x420007, + 0x360007, + 0x360007, + 0x360007, + 0x360007, + 0x430007, + 0x430007, + 0x430007, + 0x430007, + 0x350008, + 0x350008, + 0x440008, + 0x440008, + 0x340008, + 0x340008, + 0x450008, + 0x450008, + 0x330008, + 0x330008, + 0x460009, + 0x320009, + 0x310009, + 0x470009, + 0x48000a, + 0x48000a, + 0x48000a, + 0x48000a, + 0x30000a, + 0x30000a, + 0x30000a, + 0x30000a, + 0x49000a, + 0x49000a, + 0x49000a, + 0x49000a, + 0x2f000a, + 0x2f000a, + 0x2f000a, + 0x2f000a, + 0x4a000a, + 0x4a000a, + 0x4a000a, + 0x4a000a, + 0x2e000a, + 0x2e000a, + 0x2e000a, + 0x2e000a, + 0x4c000b, + 0x4c000b, + 0x4b000b, + 0x4b000b, + 0x4d000b, + 0x4d000b, + 0x4e000b, + 0x4e000b, + 0x2d000b, + 0x2d000b, + 0x2b000b, + 0x2b000b, + 0x2c000c, + 0x4f000c, + 0x2a000c, + 0x29000c, + 0x50000c, + 0x28000c, + 0x51000d, + 0x51000d, + 0x27000d, + 0x27000d, + 0x52000d, + 0x52000d, + 0x26000d, + 0x26000d, + 0x53000d, + 0x53000d, + 0x25000e, + 0x23000e, + 0x55000e, + 0x21000e, + 0x24000e, + 0x22000e, + 0x54000e, + 0x20000e, + 0x57000f, + 0x57000f, + 0x59000f, + 0x59000f, + 0x1e000f, + 0x1e000f, + 0x1f000f, + 0x1f000f, + 0x560010, + 0x1d0010, + 0x1a0010, + 0x1b0010, + 0x1c0010, + 0x180010, + 0x580010, + 0x190011, + 0x190011, + 0x160011, + 0x160011, + 0x170011, + 0x170011, + 0x5a0012, + 0x150012, + 0x130012, + 0x30012, + 0x10012, + 0x20012, + 0x12, + 0x620013, + 0x630013, + 0x640013, + 0x650013, + 0x660013, + 0x750013, + 0x610013, + 0x5b0013, + 0x5c0013, + 0x5d0013, + 0x5e0013, + 0x5f0013, + 0x600013, + 0x680013, + 0x6f0013, + 0x700013, + 0x710013, + 0x720013, + 0x730013, + 0x740013, + 0x6e0013, + 0x690013, + 0x6a0013, + 0x6b0013, + 0x6c0013, + 0x6d0013, + 0x760013, + 0x60013, + 0x80013, + 0x90013, + 0xa0013, + 0x50013, + 0x670013, + 0x780013, + 0x770013, + 0x40013, + 0x70013, + 0xf0013, + 0x100013, + 0x120013, + 0x140013, + 0x110013, + 0xb0013, + 0xc0013, + 0xe0013, + 0xd0013 +}; diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/huffcb.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffcb.c new file mode 100644 index 00000000..0c040899 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffcb.c @@ -0,0 +1,324 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffcb.cpp + Funtions: + huffcb + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + UChar *pSect = pointer to array that contains the interleaved + information of huffman codebook index and section + length. Array contains: + [codebook index] + [section boundary] + [codebook index] + [section boundary] + ... + + Int sectbits = array that defines the number of bits + used for expressing the escape value of + section length + + Int tot_sfb = total number of sfb in one Frame + + Int sfb_per_win = number of sfb in each sub-block (window) + + UChar max_sfb = 1 + number of active sfbs - see reference (2) p56 + + BITS *pInputStream = pointer to input stream + + + Local Stores/Buffers/Pointers Needed: + + UChar base = number of sfb in already detected sections + + UChar sect_len_inc = section length increment in number of sfbs' + + UChar esc_val = escape value for section length + + Int bits = number of bits needed for expressing section length + + + Global Stores/Buffers/Pointers Needed: + + + Outputs: + + num_sect = total number of sections in one frame + + + Pointers and Buffers Modified: + + UChar *pSect = pointer to array where huffman codebook index and + section length are stored + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Background knowledge: 1024(960) coef's are separated into several sections, + each section is encoded with one single Huffman codebook, and each section + has a length of multiples of sfb. + + max_sfb <= sfb_per_win <= tot_sfb + tot_sfb = total number of scalefactor bands in one frame (1024 coefs) + + This function reads the codebook index and section boundaries (expressed + in number of sfb) from the input bitstream, store these information in + *pSect, and return the number of sections been detected. Returns 0 if there + is an error. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should fill the array *pSect with section Huffman codebook + indexes and section boundaries + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3 1999(E) + Subpart 4 p55 (Recovering section_data()) + p24-25 (Syntax of section_data()) + + (3) M. Bosi, K. Brandenburg, etc., "ISO/IEC MPEG-2 Advanced Audio Coding," + J. Audio Eng. Soc., Vol.45, No.10, 1997 October + +------------------------------------------------------------------------------ + PSEUDO-CODE + + bits_needed_for_ESC = sectbits[0]; + ESC_value = (1< max_sfb) + break; + ENDIF + + } + ENDFOR + + IF (base != total_sfb OR num_of_section>total_sfb) + return 0; + ENDIF + + return num_sect; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int huffcb( + SectInfo *pSect, + BITS *pInputStream, + Int sectbits[], + Int tot_sfb, + Int sfb_per_win, + Int max_sfb) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int base; /* section boundary */ + Int sect_len_incr; + Int esc_val; /* ESC of section length = 31(long), =7 (short) */ + Int bits; /* # of bits used to express esc_val */ + Int num_sect; + Int active_sfb; + Int group_base; + + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + bits = sectbits[0]; /* 3 for SHORT_WIN, 5 for LONG_WIN */ + esc_val = (1 << bits) - 1; /* ESC_value for section length */ + num_sect = 0; + base = 0; + group_base = 0; + + /* read until the end of one frame */ + while ((base < tot_sfb) && (num_sect < tot_sfb)) + { + + pSect->sect_cb = get9_n_lessbits( + LEN_CB, + pInputStream); /* section codebook */ + + sect_len_incr = get9_n_lessbits( + bits, + pInputStream); /* length_incr */ + + + /* read until non-ESC value, see p55 reference 2 */ + while ((sect_len_incr == esc_val) && (base < tot_sfb)) + { + base += esc_val; + + sect_len_incr = get9_n_lessbits( + bits, + pInputStream); + } + + base += sect_len_incr; + pSect->sect_end = base; /* total # of sfb until current section */ + pSect++; + num_sect++; + + /* active_sfb = base % sfb_per_win; */ + active_sfb = base - group_base; + + /* + * insert a zero section for regions above max_sfb for each group + * Make sure that active_sfb is also lesser than tot_sfb + */ + + if ((active_sfb == max_sfb) && (active_sfb < tot_sfb)) + { + base += (sfb_per_win - max_sfb); + pSect->sect_cb = 0; /* huffman codebook 0 */ + pSect->sect_end = base; + num_sect++; + pSect++; + group_base = base; + } + else if (active_sfb > max_sfb) + { + /* within each group, the sections must delineate the sfb + * from zero to max_sfb so that the 1st section within each + * group starts at sfb0 and the last section ends at max_sfb + * see p55 reference 2 + */ + break; + } + + } /* while (base=0) */ + + + if (base != tot_sfb || num_sect > tot_sfb) + { + num_sect = 0; /* error */ + } + + return num_sect; + +} /* huffcb */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/huffdecode.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffdecode.c new file mode 100644 index 00000000..17261c6c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffdecode.c @@ -0,0 +1,440 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffdecode.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + id_syn_ele = identification flag for channel syntactic element, Int + + pInputStream= pointer to input bitstream, BITS. + + pVars = pointer to structure that holds information for decoding, + tDec_Int_File + + pChVars[] = pointer to structure that holds channel information, + tDec_Int_Chan + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + status = 0 if success + non-zero otherwise + + Pointers and Buffers Modified: + pChVars->sect contents updated by newly decoded section information + of current frame + + pChVars->factors contents updated by newly decoded scalefactors + + pChVars->ch_coef contents updated by newly decoded spectral coefficients + + PChVars->tns contents updated by newly decoded TNS information + + pVars->hasmask contents updated by newly decoded Mid/Side mask + information + + pVars->pulseInfo contents updated by newly decoded pulse data information + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function offers a framework for decoding the data of the next 1024 + samples. It maps the channel configuration according to the id_syn_ele flag, + configures the channel information, and calls getics to do huffman decoding + The function returns 1 if there was an error + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should set up the channel configuration for huffman decoding + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p15 (single_channel_element, channel_pair_element) + p15 (Table 4.4.5 getmask) + p16 (Table 4.4.6 get_ics_info) + p24 (Table 4.4.24 getics) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + tag = CALL getbits(LEN_TAG,pInputStream) + MODIFYING(pInputStream) + RETURNING(tag) + + common_window = 0; + + IF (id_syn_ele == ID_CPE) + THEN + common_window = CALL getbits(LEN_COM_WIN,pInputStream); + MODIFYING(pInputStream) + RETURNING(common_window) + ENDIF + + pMcInfo = &pVars->mc_info; + + IF ( (pMcInfo->ch_info[0].cpe != id_syn_ele) OR + (pMcInfo->ch_info[0].tag != tag) ) + THEN + status = 1; + ENDIF + + + IF (status == SUCCESS) + THEN + IF (id_syn_ele == ID_SCE) + THEN + + leftCh = 0; + RIGHT = 0; + pChVars[leftCh]->hasmask = 0; + ELSEIF (id_syn_ele == ID_CPE) + + leftCh = 0; + rightCh = 1; + + IF (common_window != FALSE) + THEN + + CALL get_ics_info( + audioObjectType = pVars->mc_info.audioObjectType, + pInputStream = pInputStream, + common_window = common_window, + pWindowSequence = &pChVars[leftCh]->wnd, + &pChVars[leftCh]->wnd_shape_this_bk, + pChVars[leftCh]->group, + &pChVars[leftCh]->max_sfb, + pVars->winmap, + &pChVars[leftCh]->lt_status, + &pChVars[rightCh]->lt_status); + MODIFYING(pInputStream, wnd, wnd_shape_this_bk,group, + max_sfb, lt_status) + RETURNING(status) + + IF (status == SUCCESS) + THEN + + pChVars[rightCh]->wnd = pChVars[leftCh]->wnd; + pChVars[rightCh]->wnd_shape_this_bk = + pChVars[leftCh]->wnd_shape_this_bk; + pChVars[rightCh]->max_sfb = pChVars[leftCh]->max_sfb; + pv_memcpy( + pChVars[rightCh]->group, + pChVars[leftCh]->group, + NSHORT*sizeof(pChVars[leftCh]->group[0])); + + hasmask = CALL getmask( + pVars->winmap[pChVars[leftCh]->wnd], + pInputStream, + pChVars[leftCh]->group, + pChVars[leftCh]->max_sfb, + pChVars[leftCh]->mask); + MODIFYING(pInputStream, mask) + RETURNING(hasmask) + + IF (hasmask == MASK_ERROR) + THEN + status = 1; + ENDIF + pChVars[leftCh]->hasmask = hasmask; + pChVars[rightCh]->hasmask = hasmask; + + ENDIF + + ELSE + + pChVars[leftCh]->hasmask = 0; + pChVars[rightCh]->hasmask = 0; + ENDIF(common_window) + + ENDIF(id_syn_ele) + + ENDIF (status) + + ch = leftCh; + + WHILE((ch <= rightCh) AND (status == SUCCESS)) + + status = CALL getics( + pInputStream, + common_window, + pVars, + pChVars[ch], + pChVars[ch]->group, + &pChVars[ch]->max_sfb, + pChVars[ch]->cb_map, + &pChVars[ch]->tns, + pVars->winmap, + &pVars->pulseInfo, + pChVars[ch]->sect); + MODIFYING(pInputStream,pVarsp,ChVars[ch],group, + max_sfb,tns,pulseInfo,sect) + RETURNING(status) + + ch++; + + ENDWHILE + + RETURN status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "huffman.h" +#include "e_maskstatus.h" +#include "e_elementid.h" +#include "get_ics_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LEFT (0) +#define RIGHT (1) +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int huffdecode( + Int id_syn_ele, + BITS *pInputStream, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars[]) + +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int ch; + Int common_window; + Int hasmask; + Int status = SUCCESS; + Int num_channels = 0; + MC_Info *pMcInfo; + + per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */ + per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */ + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + get9_n_lessbits( + LEN_TAG, + pInputStream); + + /* suppose an un-supported id_syn_ele will never be passed */ + + common_window = 0; + + if (id_syn_ele == ID_CPE) + { + common_window = + get1bits(pInputStream); + } + + pMcInfo = &pVars->mc_info; + + /* + * check if provided info (num of channels) on audio config, + * matches read bitstream data, if not, allow update only once. + * In almost all cases it should match. + */ + if ((pMcInfo->ch_info[0].cpe != id_syn_ele)) + { + if (pVars->mc_info.implicit_channeling) /* check done only once */ + { + pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /* collect info from bitstream + * implicit_channeling flag is locked + * after 1st frame, to avoid toggling + * parameter in the middle of the clip + */ + pMcInfo->nch = (id_syn_ele & 1) + 1; /* update number of channels */ + } + else + { + status = 1; /* ERROR break if syntax error persist */ + } + } + + if (status == SUCCESS) + { + if (id_syn_ele == ID_SCE) + { + + num_channels = 1; + pVars->hasmask = 0; + } + else if (id_syn_ele == ID_CPE) + { + pChLeftShare = pChVars[LEFT]->pShareWfxpCoef; + pChRightShare = pChVars[RIGHT]->pShareWfxpCoef; + num_channels = 2; + + if (common_window != FALSE) + { + + status = get_ics_info( + (tMP4AudioObjectType) pVars->mc_info.audioObjectType, + pInputStream, + (Bool)common_window, + (WINDOW_SEQUENCE *) & pChVars[LEFT]->wnd, + (WINDOW_SHAPE *) & pChVars[LEFT]->wnd_shape_this_bk, + pChLeftShare->group, + (Int *) & pChLeftShare->max_sfb, + pVars->winmap, + (LT_PRED_STATUS *) & pChLeftShare->lt_status, + (LT_PRED_STATUS *) & pChRightShare->lt_status); + + if (status == SUCCESS) + { + /* copy left channel info to right channel */ + pChVars[RIGHT]->wnd = pChVars[LEFT]->wnd; + pChVars[RIGHT]->wnd_shape_this_bk = + pChVars[LEFT]->wnd_shape_this_bk; + pChRightShare->max_sfb = pChLeftShare->max_sfb; + pv_memcpy( + pChRightShare->group, + pChLeftShare->group, + NSHORT*sizeof(pChLeftShare->group[0])); + + hasmask = getmask( + pVars->winmap[pChVars[LEFT]->wnd], + pInputStream, + pChLeftShare->group, + pChLeftShare->max_sfb, + pVars->mask); + + if (hasmask == MASK_ERROR) + { + status = 1; /* ERROR code */ + } + pVars->hasmask = hasmask; + + } /* if (status == 0) */ + } + else + { + pVars->hasmask = 0; + } /* if (common_window) */ + + } /* if (id_syn_ele) */ + + } /* if (status) */ + + ch = 0; + while ((ch < num_channels) && (status == SUCCESS)) + { + pChLeftShare = pChVars[ch]->pShareWfxpCoef; + + status = getics( + pInputStream, + common_window, + pVars, + pChVars[ch], + pChLeftShare->group, + &pChLeftShare->max_sfb, + pChLeftShare->cb_map, + &pChLeftShare->tns, + pVars->winmap, + &pVars->share.a.pulseInfo, + pVars->share.a.sect); + + ch++; + + } /* while (ch) */ + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + + return status; + +} /* huffdecode */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/hufffac.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/hufffac.c new file mode 100644 index 00000000..c5ba6689 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/hufffac.c @@ -0,0 +1,499 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: hufffac.cpp + Funtions: + hufffac + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + *pFrameInfo = pointer to structure that holds information + of each Frame. type FrameInfo + + *pInputStream = pointer to input bitstream. type BITS + + *pGroup = pointer to array that contains the index of the first + window in each group, type UChar + + nsect = number of sections to be decoded. type Int + + *pSect = pointer to structure array that contains the huffman + codebook index and section boundary for each section, + type SectInfo + + global_gain = initial value for "DPCM encoded" scalefactors and noise + energy, type Int + + *pFactors = pointer to array that stores the decoded scalefactors, + intensity position or noise energy, type Int + + huffBookUsed = array that will hold the huffman codebook index for + each sfb, type Int + + *pBook = pointer to structure that contains the huffman codebook + information, such as dimension, Largest Absolute Value + (LAV) of each huffman codebook, etc. type Hcb + + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + 0 if success + 1 if error + + Pointers and Buffers Modified: + + Int *pFactors contains the newly decoded scalefactors and/or + intensity position and/or noise energy level + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function first reads the Huffman codebook index of all sections within + one Frame. Then, depending on the huffman codebook index of each section, + the function decodes the scalefactors, and/or intensity positions + (INTENSITY_HCB, INTENSITY_HCB2), and/or noise energy (NOISE_HCB) + for every scalefactor band in each section. + The function returns 0 upon successful decoding, returns 1 if error. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should replace the content of the array pFactors with the + decoded scalefactors and/or intensity positions and/or noise energy + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p72-73 (scalefactors) + p76 (decoding) + p78 (Table 4.6.1, Table 4.6.2) + p93-94 (INTENSITY_HCB) + p123 (NOISE_HCB) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + status = SUCCESS; + + CALL pv_memset(pHuffBookUsed, ZERO_HCB, MAXBANDS*sizeof(*pHuffBookUsed)); + + CALL pv_memset(pFactors, ZERO_HCB, MAXBANDS*sizeof(*pFactors)); + + sect_start = 0; + + FOR(sect_idx = nsect; sect_idx > 0; sect_idx--) + { + sect_cb = pSect->sect_cb; + sect_end = pSect->sect_end; + pSect++; + + CALL pv_memset( + &pHuffBookUsed[sect_start], + sect_cb, + (sect_end - sect_start)); + + } + ENDFOR + + fac = global_gain; + is_pos = 0; + noise_nrg = global_gain - NOISE_OFFSET; + + pTable = pBook[BOOKSCL].pTable; + group_win = 0; + group_end = 0; + + WHILE((group_end < pFrameInfo->num_win)&&(status == SUCCESS)) + { + nsfb_win = pFrameInfo->sfb_per_win[group_end]; + group_end = *pGroup++; + + FOR(sfb = 0; sfb < nsfb_win; sfb++) + { + IF ((pHuffBookUsed[sfb] > 0)&&(pHuffBookUsed[sfb] < BOOKSCL)) + { + cw_index = CALL decode_huff_cw_binary(pTable, pInputStream); + + fac += cw_index - MIDFAC; + + IF((fac >= 2*TEXP) || (fac < 0)) + { + status = 1; + } + ELSE + { + pFactors[sfb] = fac; + } + ENDIF (fac) + + } + ELSE IF (pHuffBookUsed[sfb] == ZERO_HCB) + { + do nothing; + } + + ELSE IF ((pHuffBookUsed[sfb] == INTENSITY_HCB)|| + (pHuffBookUsed[sfb] == INTENSITY_HCB2)) + { + cw_index = CALL decode_huff_cw_binary(pTable, pInputStream); + + is_pos += cw_index - MIDFAC; + pFactors[sfb] = is_pos; + } + + ELSE IF (pHuffBookUsed[sfb] == NOISE_HCB) + { + IF (noise_pcm_flag == TRUE) + { + noise_pcm_flag = FALSE; + dpcm_noise_nrg = CALL getbits( + NOISE_PCM_BITS, + pInputStream); + + dpcm_noise_nrg -= NOISE_PCM_OFFSET; + } + ELSE + { + dpcm_noise_nrg = CALL decode_huff_cw_binary( + pTable, + pInputStream); + + dpcm_noise_nrg -= MIDFAC; + } + ENDIF (noise_pcm_flag) + + noise_nrg += dpcm_noise_nrg; + pFactors[sfb] = noise_nrg; + } + + ELSE IF (pHuffBookUsed[sfb] == BOOKSCL) + { + status = 1; + } + ENDIF (pHuffBookUsed[sfb]) + + } + ENDFOR (sfb) + + IF (pFrameInfo->islong == FALSE) + { + + FOR(group_win++; group_win < group_end; group_win++) + { + FOR (sfb=0; sfb < nsfb_win; sfb++) + { + pFactors[sfb + nsfb_win] = pFactors[sfb]; + } + ENDFOR + + pFactors += nsfb_win; + } + ENDFOR + + } + ENDIF (pFrameInfo) + + pHuffBookUsed += nsfb_win; + pFactors += nsfb_win; + + } + ENDWHILE (group_end) + + return status; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" /* pv_memset */ +#include "s_frameinfo.h" +#include "s_bits.h" +#include "s_sectinfo.h" +#include "s_huffman.h" +#include "ibstream.h" + +#include "hcbtables.h" +#include "e_huffmanconst.h" +#include "e_infoinitconst.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int hufffac( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, /* may be changed to Int */ + Int nsect, + SectInfo *pSect, /* may be changed to Int */ + Int global_gain, + Int *pFactors, + Int huffBookUsed[]) +{ + Int sect_idx; + Int group_end; /* index of 1st window in next group */ + Int group_win; /* window index within group */ + Int cw_index; /* huff codeword index */ + Int nsfb_win; /* # of scfbands per window */ + Int sfb; /* scalefactor band index */ + Int sect_cb; /* huff codebook # for each section */ + Int fac; /* decoded scf */ + Int is_pos; /* intensity stereo position */ + Int noise_pcm_flag = TRUE; /* first PNS sfb */ + Int dpcm_noise_nrg; /* dpcm noise energy */ + Int noise_nrg; /* noise energy */ + Int status = SUCCESS; /* status of decoding */ + Int *pHuffBookUsed = &huffBookUsed[0]; + + + pv_memset(pFactors, + ZERO_HCB, + MAXBANDS*sizeof(*pFactors)); + + + if (nsect) + { + /* read section length and codebook */ + + if (nsect == 1) /* long window */ + { + sect_cb = pSect->sect_cb; /* codebook for this section */ + + /* all sfbs in one section share the same codebook */ + + for (sfb = pSect->sect_end >> 2; sfb != 0; sfb--) + { + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + *(pHuffBookUsed++) = sect_cb; + } + for (sfb = pSect->sect_end & 3; sfb != 0; sfb--) + { + *(pHuffBookUsed++) = sect_cb; + } + + } + else /* short */ + { + Int sect_start = 0; /* start index of sfb for each section */ + for (sect_idx = nsect; sect_idx > 0; sect_idx--) + { + sect_cb = pSect->sect_cb; /* codebook for this section */ + + /* all sfbs in one section share the same codebook */ + for (sfb = sect_start; sfb < pSect->sect_end; sfb++) + { + pHuffBookUsed[sfb] = sect_cb; + } + + pSect++; + sect_start = sfb; + + } /* for (sect_idx) */ + } + } + else + { + /* clear array for the case of max_sfb == 0 */ + pv_memset(pHuffBookUsed, + ZERO_HCB, + MAXBANDS*sizeof(*pHuffBookUsed)); + } + + pHuffBookUsed = &huffBookUsed[0]; + + /* scale factors and noise energy are dpcm relative to global gain + * intensity positions are dpcm relative to zero + */ + fac = global_gain; + is_pos = 0; + noise_nrg = global_gain - NOISE_OFFSET; + + /* get scale factors, + * use reserved Table entry = 12, see reference (2) p78 Table 4.6.2 + */ + group_win = 0; + group_end = 0; + + + /* group by group decoding scalefactors and/or noise energy + * and/or intensity position + */ + while ((group_end < pFrameInfo->num_win) && (status == SUCCESS)) + { + nsfb_win = pFrameInfo->sfb_per_win[group_end]; + group_end = *pGroup++; /* index of 1st window in next group */ + + /* decode scf in first window of each group */ + + for (sfb = 0; sfb < nsfb_win; sfb++) + { + + switch (pHuffBookUsed[sfb]) + { + case ZERO_HCB: + break; + case INTENSITY_HCB: + case INTENSITY_HCB2: + /* intensity books */ + /* decode intensity position */ + cw_index = decode_huff_scl(pInputStream); + + is_pos += cw_index - MIDFAC; + pFactors[sfb] = is_pos; + break; + case NOISE_HCB: + /* noise books */ + /* decode noise energy */ + if (noise_pcm_flag == TRUE) + { + noise_pcm_flag = FALSE; + dpcm_noise_nrg = get9_n_lessbits(NOISE_PCM_BITS, + pInputStream); + + dpcm_noise_nrg -= NOISE_PCM_OFFSET; + } + else + { + dpcm_noise_nrg = decode_huff_scl(pInputStream); + + dpcm_noise_nrg -= MIDFAC; + } /* if (noise_pcm_flag) */ + + noise_nrg += dpcm_noise_nrg; + pFactors[sfb] = noise_nrg; + break; + case BOOKSCL: + status = 1; /* invalid books */ + sfb = nsfb_win; /* force out */ + break; + default: + /* spectral books */ + /* decode scale factors */ + cw_index = decode_huff_scl(pInputStream); + + fac += cw_index - MIDFAC; /* 1.5 dB */ + if ((fac >= 2*TEXP) || (fac < 0)) + { + status = 1; /* error, MUST 0<=scf<256, Ref. p73 */ + } + else + { + pFactors[sfb] = fac; /* store scf */ + } /* if (fac) */ + } + + } /* for (sfb=0), first window decode ends */ + + /* expand scf to other windows in the same group */ + if (pFrameInfo->islong == FALSE) + { + + for (group_win++; group_win < group_end; group_win++) + { + for (sfb = 0; sfb < nsfb_win; sfb++) + { + pFactors[sfb + nsfb_win] = pFactors[sfb]; + } + pFactors += nsfb_win; + } + + } /* if (pFrameInfo->islong), one group decode ends */ + + + /* points to next group */ + pHuffBookUsed += nsfb_win; + pFactors += nsfb_win; + + } /* while (group_end), all groups decode end */ + + return status; + +} /* hufffac */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/huffman.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffman.h new file mode 100644 index 00000000..23484e90 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffman.h @@ -0,0 +1,211 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffman.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + include function prototype definitions for Huffman decoding module + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef HUFFMAN_H +#define HUFFMAN_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_sectinfo.h" +#include "s_pulseinfo.h" +#include "s_tdec_int_file.h" +#include "s_tdec_int_chan.h" +#include "ibstream.h" + +#include "s_hcb.h" +#include "hcbtables.h" + +#include "get_pulse_data.h" +#include "get_ics_info.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define DIMENSION_4 4 +#define DIMENSION_2 2 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int decode_huff_cw_tab1( + BITS *pInputStream); + + Int decode_huff_cw_tab2( + BITS *pInputStream); + + Int decode_huff_cw_tab3( + BITS *pInputStream); + + Int decode_huff_cw_tab4( + BITS *pInputStream); + + Int decode_huff_cw_tab5( + BITS *pInputStream); + + Int decode_huff_cw_tab6( + BITS *pInputStream); + + Int decode_huff_cw_tab7( + BITS *pInputStream); + + Int decode_huff_cw_tab8( + BITS *pInputStream); + + Int decode_huff_cw_tab9( + BITS *pInputStream); + + Int decode_huff_cw_tab10( + BITS *pInputStream); + + Int decode_huff_cw_tab11( + BITS *pInputStream); + + Int decode_huff_scl( + BITS *pInputStream); + + Int infoinit( + const Int sampling_rate_idx, + FrameInfo **ppWin_seq_info, + Int *pSfbwidth128); + + Int huffcb( + SectInfo *pSect, + BITS *pInputStream, + Int *pSectbits, + Int tot_sfb, + Int sfb_per_sbk, + Int max_sfb); + + Int hufffac( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, + Int nsect, + SectInfo *pSect, + Int global_gain, + Int *pFactors, + Int huffBookUsed[]); + + Int huffspec_fxp( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int nsect, + SectInfo *pSectInfo, + Int factors[], + Int32 coef[], + Int16 quantSpec[], + Int16 tmp_spec[], + const FrameInfo *pLongFrameInfo, + PulseInfo *pPulseInfo, + Int qFormat[]); + + Int huffdecode( + Int id_syn_ele, + BITS *pInputStream, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars[]); + + void deinterleave( + Int16 interleaved[], + Int16 deinterleaved[], + FrameInfo *pFrameInfo); + + Int getics( + + BITS *pInputStream, + Int common_window, + tDec_Int_File *pVars, + tDec_Int_Chan *pChVars, + Int group[], + Int *pMax_sfb, + Int *pCodebookMap, + TNS_frame_info *pTnsInfo, + FrameInfo **pWinMap, + PulseInfo *pPulseInfo, + SectInfo sect[]); + + void calc_gsfb_table( + FrameInfo *pFrameInfo, + Int group[]); + + Int getmask( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int *pGroup, + Int max_sfb, + Int *pMask); + + void getgroup( + Int group[], + BITS *pInputStream); + + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/huffspec_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffspec_fxp.c new file mode 100644 index 00000000..5b70f428 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/huffspec_fxp.c @@ -0,0 +1,583 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: huffspec_fxp.cpp + Funtions: + huffspec_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pFrameInfo = ptr to structure that holds Information of current Frame, + type FrameInfo + + pInputStream = ptr to structure of bitstream, type BITS + + nsect = number of sections in current Frame, at fs = 44.1 kHz, + range [0, 49] long block, [0,112] short blocks. type Int + + pSect = ptr to structure that holds section codebook and boundary + type SectInfo + + factors[] = array that contains scalefactors for each sfb, type Int16 + + coef[] = array that holds inverse quantized coefs, Int32 QFormat. + + quantSpec[] = array that holds quantized spectral coefs, type Int + + tmp_spec[] = temporary buffer to hold the de-interleaved coefs. + + pLongFrameInfo = ptr to structure that holds long frame info + + Local Stores/Buffers/Pointers Needed: + exptable = array contains the Q15 format data for 2^0, 2^0.25, 2^0.5, + and 2^0.75, type const Int. + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + + return 0 if decoding properly. + + Pointers and Buffers Modified: + + pInputStream read codeword index and/or sign bits and/or ESC value + + coef contains the newly inverse quantized 1024 spec coefs, + type Int32 Q-format from esc_iquant() + + quantSpec contains decoded quantized 1024 spec coefs, type Int + + tmp_spec contains the de-interleaved version of quantSpec + + qFormat contains Q-Format for each scalefactor band + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function first reads the section info (codebook and boundary), then + decode the spectral coefficients if a spectral codebook is used. + If necessary, get the sign bits, ESC value or the NEC_pulse data. In case of + short window sequences, the decoded data is de-interleaved before + multiplied by scalefactors. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should set the content of the array 'coef' with the inverse + quantized and rescaled value of spectral coefficients. + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart (4) p56 (spectral_data() parsing and decoding) + p26 (Syntax of spectral_data()) + p74-78 (decoding: unpack_idx, get_sign_bits, + getescape, pulse_nc, deinterleave) + p72 (inverse quantization: esc_iquant) + +------------------------------------------------------------------------------ + PSEUDO-CODE + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "esc_iquant_scaling.h" +#include "huffman.h" +#include "unpack_idx.h" +#include "pulse_nc.h" +#include "iquant_table.h" +#include "e_huffmanconst.h" + + +#include "pv_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ORDER (3) + +/* + * Format the table is stored in. + */ +#define QTABLE (27) + +/* + * Number of bits for data in a signed 32 bit integer. + */ +#define SIGNED32BITS (31) + +/* + * Round up value for intermediate values obtained from the table + */ +#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const UInt16 exptable[4] = +{ + 0, /* (2^0.00)<<15 (Q10), use zero to signal no scaling required! */ + 19485, /* (2^0.25)<<15 */ + 23171, /* (2^0.50)<<15 */ + 27555 /* (2^0.75)<<15 */ + +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int huffspec_fxp( + FrameInfo *pFrameInfo, + BITS *pInputStream, + Int nsect, + SectInfo *pSectInfo, + Int factors[], + Int32 coef[], + Int16 quantSpec[], + Int16 tmp_spec[], + const FrameInfo *pLongFrameInfo, + PulseInfo *pPulseInfo, + Int qFormat[]) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + const Hcb *pHcb; + Int i; + Int sfb; + Int idx_count; + Int sect_cb; /* section codebook */ + Int dim; + Int idx; + Int stop_idx; /* index of 1st coef in next sfb */ + Int sect_start; /* start index of sfb in one section*/ + Int sect_end; /* index of 1st sfb in next section */ + Int *pSfbStart; + Int *pSfb; + Int16 *pQuantSpec; /* probably could be short */ + Int max = 0; + /* rescaling parameters */ + Int nsfb; + Int tot_sfb; + Int fac; + + Int32 *pCoef; /* ptr to coef[], inverse quantized coefs */ + UInt16 scale; + + Int power_scale_div_4; + Int sfbWidth; + + void (*pUnpack_idx)( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + + Int(*pDec_huff_tab)(BITS *) = NULL; + + UInt32 temp; + Int binaryDigits, QFormat; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + sect_start = 0; + stop_idx = 0; + + /* pSfb: ptr to array that holds stop index of each sfb */ + pSfbStart = pFrameInfo->frame_sfb_top; + + if (pSfbStart == NULL) + { + return (-1); /* error condition */ + } + + pSfb = pSfbStart; + + /* decoding spectral values section by section */ + for (i = nsect; i > 0; i--) + { + /* read the codebook and section length */ + sect_cb = pSectInfo->sect_cb; /* codebook */ + if ((sect_cb > 15) || (sect_cb < 0)) + { + return (-1); /* error condition */ + } + sect_end = pSectInfo->sect_end; /* # of sfbs */ + + if (sect_end < 0) + { + return (-1); /* error condition */ + } + + pSectInfo++; + + /* sect_cb sect_cb - 1 + * ZERO_HCB 1111b + * 1 0000b + * 2 0001b + * 3 0010b + * 4 0011b + * 5 0100b + * 6 0101b + * 7 0110b + * 8 0111b + * 9 1000b + * 10 1001b + * 11 1010b + * 12 1011b + * NOISE_HCB 1100b + * INTENSITY_HCB2 1101b + * INTENSITY_HCB 1110b + * if ( ((sect_cb - 1) & 0xC) == 0xC ) is identical to + * if !((sect_cb == ZERO_HCB) || (sect_cb == NOISE_HCB) || + * (sec_cb == INTENSITY_HCB) || (sect_cb==INTENSITY_HCB2) ) + * use this compare scheme to speed up the execution + */ + + if (((sect_cb - 1) & 0xC) != 0xC) + { + /* decode spec in one section */ + if (sect_cb > BY4BOOKS) + { + dim = DIMENSION_2; /* set codebook dimension */ + } + else + { + dim = DIMENSION_4; + } + + pHcb = &hcbbook_binary[sect_cb]; + + if (sect_cb == ESCBOOK) + { + pUnpack_idx = &unpack_idx_esc; + } + else if (pHcb->signed_cb == FALSE) + { + pUnpack_idx = &unpack_idx_sgn; + } + else + { + pUnpack_idx = &unpack_idx; + } + + + switch (sect_cb) + { + case 1: + pDec_huff_tab = decode_huff_cw_tab1; + break; + case 2: + pDec_huff_tab = decode_huff_cw_tab2; + break; + case 3: + pDec_huff_tab = decode_huff_cw_tab3; + break; + case 4: + pDec_huff_tab = decode_huff_cw_tab4; + break; + case 5: + pDec_huff_tab = decode_huff_cw_tab5; + break; + case 6: + pDec_huff_tab = decode_huff_cw_tab6; + break; + case 7: + pDec_huff_tab = decode_huff_cw_tab7; + break; + case 8: + pDec_huff_tab = decode_huff_cw_tab8; + break; + case 9: + pDec_huff_tab = decode_huff_cw_tab9; + break; + case 10: + pDec_huff_tab = decode_huff_cw_tab10; + break; + case 11: + pDec_huff_tab = decode_huff_cw_tab11; + break; + default: + return (-1); /* error condition */ + } + + /* move ptr to first sfb of current section */ + pQuantSpec = quantSpec + stop_idx; + + /* step through all sfbs in current section */ + for (sfb = sect_start; sfb < sect_end; sfb++) + { + idx_count = *pSfb - stop_idx; + stop_idx = *pSfb++; + + /* decode all coefs for one sfb */ + while ((idx_count > 0) && (idx_count < 1024)) + { + + idx = (*pDec_huff_tab)(pInputStream); + + (*pUnpack_idx)(pQuantSpec, + idx, + pHcb, + pInputStream, + &max); /* unpack idx -> coefs */ + + pQuantSpec += dim; + idx_count -= dim; + + } /* while(idx_count) */ + + } /* for (sfb=sect_start) */ + } + else + { + + /* current section uses ZERO_HCB, NOISE_HCB, etc */ + + /* move sfb pointer to the start sfb of next section */ + pSfb = pSfbStart + sect_end; + /* number of coefs in current section */ + idx_count = *(pSfb - 1) - stop_idx; + + if ((idx_count > 1024) || (idx_count < 0)) + { + return (-1); /* error condition */ + } + + /* + * This memset is necessary in terms of (1) net savings in total + * MIPS and (2) accurate Q-Formats for fft_rx2 + * In case a scalefactor band uses ZERO_HCB, all coefficients of + * that sfb should be zeros. Without this call to memset, the + * coefficients for a ZERO_HCB sfb are the "leftovers" of the + * previous frame, which may not have all zero values. This leads + * to a drastical increase in the cycles consumed by esc_iquant_fxp + * and fft_rx2, which is the most "expensive" function of the + * library. + * This memset also guarantees the Q_Format for sfbs with all zero + * coefficients will be set properly. + * Profiling data on ARM and TMS320C55x proves that there is a net + * gain in total MIPS if a memset is called here. + */ + pv_memset(&quantSpec[stop_idx], + 0, + idx_count * sizeof(quantSpec[0])); + + /* + * This memset is called because pQuantSpec points to tmp_spec + * after deinterleaving + */ + + pv_memset(&tmp_spec[stop_idx], + 0, + idx_count * sizeof(tmp_spec[0])); + + + /* stop_idx is the index of the 1st coef of next section */ + stop_idx = *(pSfb - 1); + + }/* if (sect_cb) */ + + sect_start = sect_end; + + } /* for (i=nsect) */ + + /* noisless coding reconstruction */ + if (pFrameInfo->islong != FALSE) + { + if (pPulseInfo->pulse_data_present == 1) + { + pulse_nc(quantSpec, + pPulseInfo, + pLongFrameInfo, + &max); /* add pulse data */ + } + + pQuantSpec = quantSpec; + + } + else + { + deinterleave(quantSpec, + tmp_spec, + pFrameInfo); + + pQuantSpec = tmp_spec; + } + + + /* inverse quantization, Q_format: Int32 */ + /* rescaling */ + + /* what we can do here is assuming that we already know maxInput for each band, we have to go + though each one of them for re-quant and scaling, and pick the right qFormat to apply to + all spectral coeffs.*/ + + if ((max < 0) || (max > 8192)) /* (8192>>ORDER) == 1024 is the inverseQuantTable size */ + { + return (-1); /* error condition */ + } + else + { + /* Get (max/SPACING) ^ (1/3), in Q Format */ + temp = inverseQuantTable[(max >> ORDER) + 1]; + } + + + /* Round up before shifting down to Q0 */ + temp += ROUND_UP; + + /* shift down to Q0 and multiply by 2 (FACTOR) in one step */ + temp >>= (QTABLE - 1); + + /* Now get max ^ (4/3) in Q0 */ + temp *= max; + + + binaryDigits = 31 - pv_normalize(temp); + + + /* Prevent negative shifts caused by low maximums. */ + if (binaryDigits < (SIGNED32BITS - QTABLE)) + { + binaryDigits = SIGNED32BITS - QTABLE; + } + + QFormat = SIGNED32BITS - binaryDigits; + + /********************/ + tot_sfb = 0; + nsfb = pFrameInfo->sfb_per_win[0]; + pCoef = coef; + + for (i = pFrameInfo->num_win; i > 0; i--) + { + stop_idx = 0; + + for (sfb = 0; sfb < nsfb; sfb++) + { + sfbWidth = pFrameInfo->win_sfb_top[0][sfb] - stop_idx; + + if ((sfbWidth < 0) || (sfbWidth > 1024)) + { + return (-1); /* error condition */ + } + + stop_idx += sfbWidth; + + fac = factors[tot_sfb] - SF_OFFSET; + scale = exptable[fac & 0x3]; + + power_scale_div_4 = fac >> 2; + + power_scale_div_4++; + + qFormat[tot_sfb] = QFormat; + + esc_iquant_scaling(pQuantSpec, + pCoef, + sfbWidth, + QFormat, + scale, + max); + + pQuantSpec += sfbWidth; + qFormat[tot_sfb] -= power_scale_div_4; + pCoef += sfbWidth; + + tot_sfb++; + + } /* for (sfb) */ + } /* for (i) */ + + + /*---------------------------------------------------------------------------- + ; Return status + ----------------------------------------------------------------------------*/ + return SUCCESS; + +} /* huffspec_fxp */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ibstream.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ibstream.h new file mode 100644 index 00000000..34877968 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ibstream.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ibstream.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains defines, structures, and function definitions for the + input bit stream used in the AAC Decoder. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IBSTREAM_H +#define IBSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bits.h" +#include "getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define INBUF_ARRAY_INDEX_SHIFT (3) +#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT)) +#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1) + +#define MAX_GETBITS (25) +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void byte_align( + BITS *pInputStream); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* IBSTREAM_H */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.c new file mode 100644 index 00000000..802ab699 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.c @@ -0,0 +1,199 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct16.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 16 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 16 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "idct16.h" +#include "idct8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 28 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Qfmt31(x) (Int32)(x*(0x7FFFFFFF) + (x>=0?0.5F:-0.5F)) + +const Int32 CosTable_8i[8] = +{ + Qfmt31(0.50241928618816F), Qfmt31(0.52249861493969F), + Qfmt31(0.56694403481636F), Qfmt31(0.64682178335999F), + Qfmt(0.78815462345125F), Qfmt(1.06067768599035F), + Qfmt(1.72244709823833F), Qfmt(5.10114861868916F) +}; + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void idct_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = CosTable_8i; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + + Int32 tmp3; + Int32 *pt_vecN_1; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + *(pt_odd++) = tmp1; + + for (i = 2; i != 0; i--) + { + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + tmp1 = tmp3; + } + + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + tmp3 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + *(pt_odd++) = tmp3 + tmp2; + + + *(pt_even) = *(pt_vec++); + *(pt_odd++) = *(pt_vec) + tmp3; + + + idct_8(temp_even); + idct_8(vec); + + + pt_cos = &CosTable_8i[7]; + + pt_vec = &vec[7]; + + pt_even = &temp_even[7]; + pt_vecN_1 = &vec[8]; + + tmp1 = *(pt_even--); + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } + + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos)) << 1; + *(pt_vecN_1) = tmp2 - tmp3; + *(pt_vec) = tmp2 + tmp3; + +} + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.h new file mode 100644 index 00000000..b554376e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct16.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct16.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT16_H +#define IDCT16_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void idct_16(Int32 vec[], Int32 scratch_mem[]); + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT16_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.c new file mode 100644 index 00000000..1a65e5d7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.c @@ -0,0 +1,191 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct32.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 32 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 32 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "idct32.h" +#include "dst32.h" +#include "idct16.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + + +#define R_SHIFT1 29 +#define Qfmt1(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt3(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void idct_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */ +{ + Int32 *temp_even = scratch_mem; + + Int32 i; + const Int32 *pt_cos = CosTable_16; + Int32 tmp1, tmp2; + Int32 *pt_even = temp_even; + Int32 *pt_odd = vec; + Int32 *pt_vec = vec; + Int32 *pt_vecN_1; + Int32 tmp3; + + + *(pt_even++) = *(pt_vec++); + tmp1 = *(pt_vec++); + tmp2 = 0; + + for (i = 7; i != 0; i--) + { + *(pt_odd++) = tmp2 + tmp1; + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_even++) = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + tmp1 = *(pt_vec++); + } + + *(pt_odd++) = tmp2 + tmp1; + *(pt_even++) = *(pt_vec++); + tmp2 = *(pt_vec++); + *(pt_odd++) = tmp2 + tmp1; + + + idct_16(temp_even, &scratch_mem[16]); + idct_16(vec, &scratch_mem[24]); + + + pt_cos = &CosTable_16[13]; + + pt_vec = &vec[15]; + + pt_even = &temp_even[15]; + pt_vecN_1 = &vec[16]; + + tmp1 = *(pt_even--); + + + tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.63687550772175F)) << 2; + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.85190210461718F)); + + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + + for (i = 2; i != 0; i--) + { + tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } + + for (i = 5; i != 0; i--) + { + tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--)); + tmp2 = *(pt_even--); + *(pt_vecN_1++) = tmp1 - tmp3; + *(pt_vec--) = tmp1 + tmp3; + tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--)); + tmp1 = *(pt_even--); + *(pt_vecN_1++) = tmp2 - tmp3; + *(pt_vec--) = tmp2 + tmp3; + } +} + + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.h new file mode 100644 index 00000000..53d7ef9a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct32.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct32.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT32_H +#define IDCT32_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void idct_32(Int32 vec[], Int32 scratch_mem[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT32_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.c new file mode 100644 index 00000000..ed634f4d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.c @@ -0,0 +1,163 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct8.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 8 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement inverse discrete cosine transform of lenght 8 + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + +#include "config.h" + +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "idct8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void idct_8(Int32 vec[]) +{ + + Int32 tmp0; + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + Int32 tmp5; + Int32 tmp6; + Int32 tmp7; + Int32 tmp8; + + + tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F)); + + tmp1 = vec[0] + tmp5; + tmp5 = vec[0] - tmp5; + + tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/ + tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi)));*/ + + tmp0 = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F)); /* (1/(2*cos(2*phi))); */ + tmp7 = (tmp3 + tmp7) + tmp0; + + vec[0] = tmp1 + tmp7; + tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/ + vec[1] = tmp5 + tmp0; + vec[2] = tmp5 - tmp0; + tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/ + vec[3] = tmp1 - tmp7; + + tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/ + tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F)); /* (1/(2*cos(7*phi)));*/ + + tmp7 = tmp2 + tmp8; + tmp5 = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F)); + tmp8 = tmp4 + tmp6; + tmp6 = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F)); + + tmp0 = tmp7 + tmp8; + tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F)); + + tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F)); + tmp1 = (tmp5 + tmp6) + tmp3; + + tmp5 = tmp0 + tmp1; + tmp6 = tmp1 + tmp2; + tmp7 = tmp2 + tmp3; + + vec[7] = vec[0] - tmp5; + vec[0] += tmp5; + vec[6] = vec[1] - tmp6; + vec[1] += tmp6; + vec[5] = vec[2] - tmp7; + vec[2] += tmp7; + vec[4] = vec[3] - tmp3; + vec[3] += tmp3; + +} + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.h new file mode 100644 index 00000000..4e371752 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/idct8.h @@ -0,0 +1,64 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: idct8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef IDCT8_H +#define IDCT8_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + void idct_8(Int32 vec[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* IDCT8_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.c new file mode 100644 index 00000000..626ae15c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.c @@ -0,0 +1,454 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: imdct_fxp.cpp + Funtions: imdct_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + data_quant = Input vector, with quantized spectral lines: + type Int32 + + freq_2_time_buffer = Scratch memory used for in-place FFT calculation, + min size required 1024, + type Int32 + + n = Length of input vector "data_quant". Currently 256 or 2048 + type const Int + + Q_format = Q_format of the input vector "data_quant" + type Int + + max = Maximum value inside input vector "data_quant" + type Int32 + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + shift = shift factor to reflect scaling introduced by IFFT and imdct_fxp, + + Pointers and Buffers Modified: + Results are return in "Data_Int_precision" + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The IMDCT is a linear orthogonal lapped transform, based on the idea of + time domain aliasing cancellation (TDAC). + IMDCT is critically sampled, which means that though it is 50% overlapped, + a sequence data after IMDCT has the same number of coefficients as samples + before the transform (after overlap-and-add). This means, that a single + block of IMDCT data does not correspond to the original block on which the + IMDCT was performed. When subsequent blocks of inverse transformed data + are added (still using 50% overlap), the errors introduced by the + transform cancels out.Thanks to the overlapping feature, the IMDCT is very + useful for quantization. It effectively removes the otherwise easily + detectable blocking artifact between transform blocks. + + N = twice the length of input vector X + y = vector of length N, will hold fixed point IDCT + p = 0:1:N-1 + + 2 N/2-1 + y(p) = --- SUM X(m)*cos(pi/(2*N)*(2*p+1+N/2)*(2*m+1)) + N m=0 + + The window that completes the TDAC is applied before calling this function. + The IMDCT can be calculated using an IFFT, for this, the IMDCT need be + rewritten as an odd-time odd-frequency discrete Fourier transform. Thus, + the IMDCT can be calculated using only one n/4 point FFT and some pre and + post-rotation of the sample points. + + + where X(k) is the input with N frequency lines + + X(k) ---------------------------- + | + | + Pre-rotation by exp(j(2pi/N)(k+1/8)) + | + | + N/4- point IFFT + | + | + Post-rotation by exp(j(2pi/N)(n+1/8)) + | + | + ------------- x(n) In the time domain + + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point IMDCT with an average + quantization error less than 1 % (variance and mean). + +------------------------------------------------------------------------------ + REFERENCES + + [1] Analysis/Synthesis Filter Bank design based on time domain + aliasing cancellation + Jhon Princen, et. al. + IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986 + Pg 1153 - 1161 + + [2] Regular FFT-related transform kernels for DCT/DST based + polyphase filterbanks + Rolf Gluth + Proc. ICASSP 1991, pg. 2205 - 2208 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + Cx, Cy are complex number + + + exp = log2(n)-1 + + FOR ( k=0; k< n/2; k +=2) + + Cx = - data_quant[k] + j data_quant[n/2-1 - k] + + freq_2_time_buffer = Cx * exp(j(2pi/n)(k+1/8)) + + ENDFOR + + CALL IFFT( freq_2_time_buffer, n/4) + + MODIFYING( freq_2_time_buffer ) + + RETURNING( shift ) + + FOR ( k=0; k< n/4; k +=2) + + Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1] + + Cy = Cx * exp(j(2pi/n)(k+1/8)) + + data_quant[3n/4-1 - k ] = Real(Cy) + data_quant[ n/4-1 - k ] = - Imag(Cy) + data_quant[3n/4 + k ] = Real(Cy) + data_quant[ n/4 + k ] = Imag(Cy) + + ENDFOR + + FOR ( k=n/4; k< n/2; k +=2) + + Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1] + + Cy = Cx * exp(j(2pi/n)(k+1/8)) + + data_quant[3n/4-1 - k ] = Real(Cy) + data_quant[ n/4 + k ] = - Real(Cy) + data_quant[5n/4 - k ] = Imag(Cy) + data_quant[ n/4 + k ] = Imag(Cy) + + ENDFOR + + MODIFIED data_quant[] + + RETURN (exp - shift) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "imdct_fxp.h" + + +#include "mix_radix_fft.h" +#include "digit_reversal_tables.h" +#include "fft_rx4.h" +#include "inv_short_complex_rot.h" +#include "inv_long_complex_rot.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ERROR_IN_FRAME_SIZE 10 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int imdct_fxp(Int32 data_quant[], + Int32 freq_2_time_buffer[], + const Int n, + Int Q_format, + Int32 max) +{ + + Int32 exp_jw; + Int shift = 0; + + const Int32 *p_rotate; + const Int32 *p_rotate_2; + + Int32 *p_data_1; + Int32 *p_data_2; + + Int32 temp_re32; + Int32 temp_im32; + + Int shift1 = 0; + Int32 temp1; + Int32 temp2; + + Int k; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + + + + if (max != 0) + { + + switch (n) + { + case SHORT_WINDOW_TYPE: + p_rotate = exp_rotation_N_256; + shift = 21; /* log2(n)-1 + 14 acomodates 2/N factor */ + break; + + case LONG_WINDOW_TYPE: + p_rotate = exp_rotation_N_2048; + shift = 24; /* log2(n)-1 +14 acomodates 2/N factor */ + break; + + default: + /* + * There is no defined behavior for a non supported frame + * size. By returning a fixed scaling factor, the input will + * scaled down and the will be heard as a low level noise + */ + return(ERROR_IN_FRAME_SIZE); + + } + + /* + * p_data_1 p_data_2 + * | | + * RIRIRIRIRIRIRIRIRIRIRIRIRIRIRI....RIRIRIRIRIRI + * | | + * + */ + + p_data_1 = data_quant; /* uses first half of buffer */ + p_data_2 = &data_quant[n_2 - 1]; /* uses second half of buffer */ + + p_rotate_2 = &p_rotate[n_4-1]; + + shift1 = pv_normalize(max) - 1; /* -1 to leave room for addition */ + Q_format -= (16 - shift1); + max = 0; + + + if (shift1 >= 0) + { + temp_re32 = *(p_data_1++) << shift1; + temp_im32 = *(p_data_2--) << shift1; + + for (k = n_4 >> 1; k != 0; k--) + { + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate++; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_im32 = *(p_data_1--) << shift1; + temp_re32 = *(p_data_2--) << shift1; + *(p_data_1++) = temp1; + *(p_data_1++) = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate_2--; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + + temp_re32 = *(p_data_1++) << shift1; + temp_im32 = *(p_data_2--) << shift1; + + *(p_data_2 + 2) = temp1; + *(p_data_2 + 3) = temp2; + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } + } + else + { + temp_re32 = *(p_data_1++) >> 1; + temp_im32 = *(p_data_2--) >> 1; + + for (k = n_4 >> 1; k != 0; k--) + { + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate++; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_im32 = *(p_data_1--) >> 1; + temp_re32 = *(p_data_2--) >> 1; + *(p_data_1++) = temp1; + *(p_data_1++) = temp2; + + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + + /* + * Real and Imag parts have been swaped to use FFT as IFFT + */ + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate_2--; + + temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw); + temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw); + + temp_re32 = *(p_data_1++) >> 1; + temp_im32 = *(p_data_2--) >> 1; + + *(p_data_2 + 3) = temp2; + *(p_data_2 + 2) = temp1; + + max |= (temp1 >> 31) ^ temp1; + max |= (temp2 >> 31) ^ temp2; + + } + } + + + if (n != SHORT_WINDOW_TYPE) + { + + shift -= mix_radix_fft(data_quant, + &max); + + shift -= inv_long_complex_rot(data_quant, + max); + + } + else /* n_4 is 64 */ + { + + shift -= fft_rx4_short(data_quant, &max); + + + shift -= inv_short_complex_rot(data_quant, + freq_2_time_buffer, + max); + + pv_memcpy(data_quant, + freq_2_time_buffer, + SHORT_WINDOW*sizeof(*data_quant)); + } + + } + else + { + Q_format = ALL_ZEROS_BUFFER; + } + + return(shift + Q_format); + +} /* imdct_fxp */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.h new file mode 100644 index 00000000..4cf7cbed --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/imdct_fxp.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: imdct_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function imdct_fxp() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IMDCT_FXP_H +#define IMDCT_FXP_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + +#define LONG_WINDOW_TYPE 2048 +#define SHORT_WINDOW_TYPE 256 + +#define ALL_ZEROS_BUFFER 31 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + extern const Int32 exp_rotation_N_256[64]; + extern const Int32 exp_rotation_N_2048[512]; + /* + extern const Int exp_rotation_N_256[128]; + extern const Int exp_rotation_N_2048[1024]; + */ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int imdct_fxp( + Int32 data_quant[], + Int32 freq_2_time_buffer[], + const Int n, + Int Q_format, + Int32 max + ); + + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* IMDCT_FXP_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/infoinit.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/infoinit.c new file mode 100644 index 00000000..1a5544fc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/infoinit.c @@ -0,0 +1,308 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: infoinit.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pSi = pointer to sampling rate info + ppWin_seq_info = pointer array to window sequence Info struct + pSfbwidth128 = pointer to sfb bandwidth array of short window + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values + ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function sets the values of 'Info' structure for blocks containing long + and short window sequences, the following structures are being set: + + win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW], + only_long_info and eight_short_info + +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) +------------------------------------------------------------------------------ + PSEUDO-CODE + + pFrameInfo = pointer to only_long_info; + win_seq_info[ONLY_LONG_WINDOW] = pFrameInfo; + pFrameInfo{all structure members} = setup values; + + + pFrameInfo = pointer to eight_short_info; + win_seq_info[EIGHT_SHORT_WINDOW] = pFrameInfo; + pFrameInfo{all structure.members} = setup values; + + + FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++) + + win_seq_info[window_seq].members = setup values; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sr_info.h" +#include "s_frameinfo.h" +#include "e_blockswitching.h" +#include "e_huffmanconst.h" +#include "sfb.h" +#include "huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int infoinit( + const Int samp_rate_idx, + FrameInfo **ppWin_seq_info, + Int *pSfbwidth128) + +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + + Int i; + Int sfb_idx, sfb_sbk; + Int bins_sbk; + Int win_seq; + Int start_idx, end_idx; + Int nsfb_short; + Int16 *sfbands; + FrameInfo *pFrameInfo; + + const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]); + + const Int16 * pt_SFbands1024 = NULL; + const Int16 * pt_SFbands128 = NULL; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + + switch (pSi->samp_rate) + { + case 96000: + case 88200: + pt_SFbands1024 = sfb_96_1024; + pt_SFbands128 = sfb_64_128; /* equal to table sfb_96_128, (eliminated) */ + break; + case 64000: + pt_SFbands1024 = sfb_64_1024; + pt_SFbands128 = sfb_64_128; + break; + case 48000: + case 44100: + pt_SFbands1024 = sfb_48_1024; + pt_SFbands128 = sfb_48_128; + break; + case 32000: + pt_SFbands1024 = sfb_32_1024; + pt_SFbands128 = sfb_48_128; + break; + case 24000: + case 22050: + pt_SFbands1024 = sfb_24_1024; + pt_SFbands128 = sfb_24_128; + break; + case 16000: + case 12000: + case 11025: + pt_SFbands1024 = sfb_16_1024; + pt_SFbands128 = sfb_16_128; + break; + case 8000: + pt_SFbands1024 = sfb_8_1024; + pt_SFbands128 = sfb_8_128; + break; + default: + // sampling rate not supported + return -1; + } + + /* long block info */ + + pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW]; + pFrameInfo->islong = 1; + pFrameInfo->num_win = 1; + pFrameInfo->coef_per_frame = LN2; /* = 1024 */ + + pFrameInfo->sfb_per_win[0] = pSi->nsfb1024; + pFrameInfo->sectbits[0] = LONG_SECT_BITS; + pFrameInfo->win_sfb_top[0] = (Int16 *)pt_SFbands1024; + + pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */ + pFrameInfo->num_groups = 1; /* long block, one group */ + pFrameInfo->group_len[0] = 1; /* only one window */ + + /* short block info */ + pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW]; + pFrameInfo->islong = 0; + pFrameInfo->num_win = NSHORT; + pFrameInfo->coef_per_frame = LN2; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + pFrameInfo->sfb_per_win[i] = pSi->nsfb128; + pFrameInfo->sectbits[i] = SHORT_SECT_BITS; + pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128; + } + + /* construct sfb width table */ + pFrameInfo->sfb_width_128 = pSfbwidth128; + for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++) + { + end_idx = pt_SFbands128[i]; + pSfbwidth128[i] = end_idx - start_idx; + start_idx = end_idx; + } + + + /* common to long and short */ + for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++) + { + + if (ppWin_seq_info[win_seq] != NULL) + { + pFrameInfo = ppWin_seq_info[win_seq]; + pFrameInfo->sfb_per_frame = 0; + sfb_sbk = 0; + bins_sbk = 0; + + for (i = 0; i < pFrameInfo->num_win; i++) + { + + /* compute coef_per_win */ + pFrameInfo->coef_per_win[i] = + pFrameInfo->coef_per_frame / pFrameInfo->num_win; + + /* compute sfb_per_frame */ + pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i]; + + /* construct default (non-interleaved) bk_sfb_top[] */ + sfbands = pFrameInfo->win_sfb_top[i]; + for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i]; + sfb_idx++) + { + pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] = + sfbands[sfb_idx] + bins_sbk; + } + + bins_sbk += pFrameInfo->coef_per_win[i]; + sfb_sbk += pFrameInfo->sfb_per_win[i]; + } /* for i = sbk ends */ + } + + } /* for win_seq ends */ + + return SUCCESS; + +} /* infoinit */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.c new file mode 100644 index 00000000..3ed82cdb --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.c @@ -0,0 +1,187 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: init_sbr_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + initializes sbr decoder structure +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "init_sbr_dec.h" +#include "aac_mem_funcs.h" +#include "extractframeinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 init_sbr_dec(Int32 codecSampleRate, + Int upsampleFac, + SBR_DEC *sbrDec, + SBR_FRAME_DATA *hFrameData) +{ + Int32 outFrameSize; + Int32 coreCodecFrameSize = 1024; +#ifdef HQ_SBR + Int32 i; +#endif + + + sbrDec->sbStopCodec = upsampleFac << 5; + sbrDec->prevLowSubband = upsampleFac << 5; + + + /* set sbr sampling frequency */ + sbrDec->outSampleRate = 2 * codecSampleRate; + outFrameSize = upsampleFac * coreCodecFrameSize; + + hFrameData->nSfb[LO] = 0; /* number of scale factor bands for high resp.low frequency resolution */ + hFrameData->nSfb[HI] = 0; + hFrameData->offset = 0; + + hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands; + hFrameData->prevEnvIsShort = -1; + + /* Initializes pointers */ +#ifdef HQ_SBR + for (i = 0; i < 5; i++) + { + hFrameData->fBuf_man[i] = hFrameData->fBuffer_man[i]; + hFrameData->fBufN_man[i] = hFrameData->fBufferN_man[i]; + hFrameData->fBuf_exp[i] = hFrameData->fBuffer_exp[i]; + hFrameData->fBufN_exp[i] = hFrameData->fBufferN_exp[i]; + } +#endif + + + pv_memset((void *)hFrameData->sbr_invf_mode_prev, + 0, + MAX_NUM_NOISE_VALUES*sizeof(INVF_MODE)); + + /* Direct assignments */ + + sbrDec->noCols = 32; + + sbrDec->bufWriteOffs = 6 + 2; + sbrDec->bufReadOffs = 2; + sbrDec->qmfBufLen = sbrDec->noCols + sbrDec->bufWriteOffs; + + sbrDec->lowBandAddSamples = 288; + + sbrDec->startIndexCodecQmf = 0; + + sbrDec->lowSubband = 32; + + + return outFrameSize; +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.h new file mode 100644 index 00000000..304f6ea2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/init_sbr_dec.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: init_sbr_dec.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INIT_SBR_DEC_H +#define INIT_SBR_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "sbr_dec.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int32 init_sbr_dec(Int32 codecSampleRate, + Int upsampleFac, + SBR_DEC *sbrDec, + SBR_FRAME_DATA *hFrameData); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.c new file mode 100644 index 00000000..07a53317 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.c @@ -0,0 +1,418 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: intensity_right.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + scalefactor = Multiplier used to scale the data extracted from the left + channel for use on the right. + [const Int] + + coef_per_win = Number of coefficients per window. + (128 for short, 1024 for long) + [const Int] + + sfb_per_win = Number of scalefactor bands per window. This should be + a number divisible by four. + [const Int] + + wins_in_group = The number of windows in the group being decoded. + This number falls within the range 1-8. + [const Int] + + band_length = The length of the scalefactor band being decoded. + This value is divisible by 4. + [const Int] + + codebook = Value that denotes which Huffman codebook was used for + the encoding of this grouped scalefactor band. + [const Int] + + ms_used = Flag that denotes whether M/S is active for this band. + [const Bool] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [const Int *, length MAXBANDS] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAXBANDS] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [const Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + Local Stores/Buffers/Pointers Needed: + intensity_factor = Table which stores the values of + 0.5^(0), 0.5^(1/4), 0.5^(2/4) and 0.5^(3/4) + [UInt, length 4] + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefRight[] Contains the new spectral information + + q_formatRight[] Q-format may be updated with changed fixed-point + data in coefRight. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function applies Intensity Stereo, generating data on the right channel + that is derived from data on the Left. A scalefactor is applied using the + following formula... + + RightCh = LeftCh*0.5^(scalefactor/4) + + This function works for one scalefactor band, which may belong to a group. + (i.e. the same scalefactor band repeated across multiple windows belonging + to one group.) + +------------------------------------------------------------------------------ + REQUIREMENTS + + codebook must be either INTENSITY_HCB or INTENSITY_HCB2 when this function + is called. + + ms_used must be 1 when TRUE, 0 when FALSE. + + wins_in_group falls within the range [1-8] + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + multiplier = codebook AND 0x1; + + multiplier = multiplier XOR ms_used; + + multiplier = multiplier << 1; + + multiplier = multiplier - 1; + + multiplier = multiplier * intensity_factor[scalefactor & 0x3]; + + scf_div_4 = (scalefactor >> 2); + + nextWinPtrUpdate = (coef_per_win - band_length); + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + *(pQformatRight) = scf_div_4 + *(pQformatLeft) - 1; + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + tempInt2 = (Int)(*(pCoefLeft) >> 16); + + *(pCoefRight) = tempInt2 * multiplier; + + pCoefRight = pCoefRight + 1; + pCoefLeft = pCoefLeft + 1; + + ENDFOR + + pCoefRight = pCoefRight + nextWinPtrUpdate; + pCoefLeft = pCoefLeft + nextWinPtrUpdate; + + pQformatRight = pQformatRight + sfb_per_win; + pQformatLeft = pQformatLeft + sfb_per_win; + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "intensity_right.h" +#include "e_huffmanconst.h" + +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int16 intensity_factor[4] = +{ + 32767, /* (0.5^0.00)*2^15 - 1 (minus 1 for storage as type Int) */ + 27554, /* (0.5^0.25)*2^15 */ + 23170, /* (0.5^0.50)*2^15 */ + 19484 +}; /* (0.5^0.75)*2^15 */ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void intensity_right( + const Int scalefactor, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int codebook, + const Bool ms_used, + const Int q_formatLeft[], + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]) + +{ + const Int32 *pCoefLeft = coefLeft; + Int32 *pCoefRight = coefRight; + + const Int *pQformatLeft = q_formatLeft; + Int *pQformatRight = q_formatRight; + + Int multiplier; + Int scf_div_4; + Int nextWinPtrUpdate; + Int win_indx; + Int tempInt; + + /* + * The sign of the intensity multiplier obeys the following table... + * + * codebook | ms_used | multiplier + * -------------------------------------- + * INTENSITY_HCB | TRUE | -1 + * INTENSITY_HCB | FALSE | +1 + * INTENSITY_HCB2 | TRUE | +1 + * INTENSITY_HCB2 | FALSE | -1 + * + * In binary, the above table is represented as... + * + * codebook | ms_used | multiplier + * -------------------------------------- + * 1111b | 1 | -1 + * 1111b | 0 | +1 + * 1110b | 1 | +1 + * 1110b | 0 | -1 + * + */ + + /* + * Deriving the correct value for "multiplier" is illustrated + * below for all 4 possible combinations of codebook and ms_used + */ + + /* + * 1111b AND 0x1 = 1b + * 1111b AND 0x1 = 1b + * 1110b AND 0x1 = 0b + * 1110b AND 0x1 = 0b + */ + multiplier = (codebook & 0x1); + + /* + * 1b XOR 1 = 0b + * 1b XOR 0 = 1b + * 0b XOR 1 = 1b + * 0b XOR 0 = 0b + */ + multiplier ^= ms_used; + + /* + * 0b << 1 = 0 + * 1b << 1 = 2 + * 1b << 1 = 2 + * 0b << 1 = 0 + */ + multiplier <<= 1; + + /* + * 0 - 1 = -1 + * 2 - 1 = +1 + * 2 - 1 = +1 + * 0 - 1 = -1 + */ + multiplier--; + + multiplier *= intensity_factor[scalefactor & 0x3]; + + scf_div_4 = (scalefactor >> 2); + + /* + * Step through all the windows in this group, replacing this + * band in each window's spectrum with + * left-channel correlated data + */ + + nextWinPtrUpdate = (coef_per_win - band_length); + + for (win_indx = wins_in_group; win_indx > 0; win_indx--) + { + + /* + * Calculate q_formatRight + * + * q_formatLeft must be included, since the values + * on the right-channel are derived from the values + * on the left-channel. + * + * scalefactor/4 is included, since the intensity + * formula is RightCh = LeftCh*0.5^(scalefactor/4) + * + * powers of 0.5 increase the q_format by 1. + * (Another way to multiply something by 0.5^(x) + * is to increase its q-format by x.) + * + * Finally the q-format must be decreased by 1. + * The reason for this is because the table is stored + * in q-15 format, but we are shifting by 16 to do + * a 16 x 16 multiply. + */ + + *(pQformatRight) = scf_div_4 + *(pQformatLeft); + + /* + * reconstruct right intensity values + * + * to make things faster, this for loop + * can be partially unrolled, since band_length is a multiple + * of four. + */ + + + if (multiplier == 32767) + { + Int32 tempInt2 = *(pCoefLeft++); + Int32 tempInt22 = *(pCoefLeft++); + + for (tempInt = band_length >> 1; tempInt > 0; tempInt--) + { + *(pCoefRight++) = tempInt2; + *(pCoefRight++) = tempInt22; + tempInt2 = *(pCoefLeft++); + tempInt22 = *(pCoefLeft++); + } + + } + else + { + + Int32 tempInt2 = *(pCoefLeft++); + Int32 tempInt22 = *(pCoefLeft++); + for (tempInt = band_length >> 1; tempInt > 0; tempInt--) + { + *(pCoefRight++) = fxp_mul32_by_16(tempInt2, multiplier) << 1; + *(pCoefRight++) = fxp_mul32_by_16(tempInt22, multiplier) << 1; + tempInt2 = *(pCoefLeft++); + tempInt22 = *(pCoefLeft++); + } + } + + /* + * Set pCoefRight and pCoefLeft to the beginning of + * this sfb in the next window in the group. + */ + + pCoefRight += nextWinPtrUpdate; + pCoefLeft += (nextWinPtrUpdate - 2); + + /* + * Update pQformatRight and pQformatLeft to this sfb in + * in the next window in the group. + */ + + pQformatRight += sfb_per_win; + pQformatLeft += sfb_per_win; + + } /* for (win_indx) */ + + +} /* void intensity_right */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.h new file mode 100644 index 00000000..0b347260 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/intensity_right.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: intensity_right.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function definitions for intensity_right +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INTENSITY_RIGHT_H +#define INTENSITY_RIGHT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void intensity_right( + const Int scalefactor, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int codebook, + const Bool ms_used, + const Int q_formatLeft[], + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.c new file mode 100644 index 00000000..b4ebfd2a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.c @@ -0,0 +1,367 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_long_complex_rot.cpp + Funtions: inv_long_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for long windows + TWICE_INV_LONG_CX_ROT_LENGTH), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)), + (sized for long windows TWICE_INV_LONG_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + inv_long_complex_rot() performs the complex rotation for the inverse MDCT + for the case of long windows. It also performs digit reverse ordering of + the first and second halves of the input vector "Data_in", as well as + reordering of the two half vectors (following radix-2 decomposition) + Word normalization is also done to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + inv_long_complex_rot() should execute a post-rotation by + exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "inv_long_complex_rot.h" +#include "imdct_fxp.h" +#include "inv_long_complex_rot.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + + +Int inv_long_complex_rot( + Int32 *Data, + Int32 max) +{ + Int i; + Int16 I; + const Int32 *p_rotate; + Int32 temp_re; + Int32 temp_im; + + Int32 exp_jw; + Int32 *pData_in_1; + Int32 *pData_in_2; + Int exp; + Int32 *pData_in_ref1; + Int32 *pData_in_ref2; + + + Int16 temp_re_0; + Int16 temp_im_0; + Int16 temp_re_1; + Int16 temp_im_1; + Int16 *p_Data_Int_precision; + Int n = 2048; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_3_4 = n_2 + n_4; + + Int16 *px_1; + Int16 *px_2; + Int16 *px_3; + Int16 *px_4; + + Int16 J; + const Int32 *p_rotate2; + + + + + p_rotate = &exp_rotation_N_2048[255]; + p_rotate2 = &exp_rotation_N_2048[256]; + + pData_in_ref1 = Data; + pData_in_ref2 = &Data[TWICE_INV_LONG_CX_ROT_LENGTH]; + + + /* + * Apply A/2^(diff) + B + */ + + p_Data_Int_precision = (Int16 *)Data; + + exp = 16 - pv_normalize(max); + + + /* + * px2--> <--px1 px4--> <--px3 + * + * | | | + * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++| + * | | | | + * n/4 n/2 3n/4 + */ + + I = 255; + J = 256; + + pData_in_1 = pData_in_ref2 + I; + + px_1 = (Int16 *)pData_in_1; + px_1++; + + pData_in_2 = pData_in_ref2 + J; + + px_4 = (Int16 *)pData_in_2; + + + + exp -= 1; + + + for (i = INV_LONG_CX_ROT_LENGTH >> 1; i != 0; i--) + { + + pData_in_2 = pData_in_ref1 + J; + + temp_im = *(pData_in_2++); + temp_re = *(pData_in_2); + + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate2++; + + /* + * Post-rotation + */ + + + + temp_re_0 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + temp_im_0 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + pData_in_1 = pData_in_ref2 + I; + + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_re = *(pData_in_1--); + temp_im = *(pData_in_1); + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + exp_jw = *p_rotate--; + + + /* + * Post-rotation + */ + + temp_re_1 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + temp_im_1 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + /* + * Repeat procedure for odd index at the output + */ + + pData_in_2 = pData_in_ref2 + J; + J += 2; + + temp_im = *(pData_in_2++); + temp_re = *(pData_in_2); + + + *(px_1--) = temp_re_0; + *(px_1--) = temp_im_1; + *(px_4++) = temp_im_0; + *(px_4++) = temp_re_1; + + + exp_jw = *p_rotate2++; + + + *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + + + /* + * Repeat procedure for odd index at the output + */ + + pData_in_1 = pData_in_ref1 + I; + I -= 2; + + temp_re = *(pData_in_1--); + temp_im = *(pData_in_1); + + + exp_jw = *p_rotate--; + + + *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + + } + + /* + * <--px1 px4--> + * + * | | | + * |-------------|-------------|/////////////|\\\\\\\\\\\\\| + * | | | | + * n/4 n/2 3n/4 + */ + + + px_1 = p_Data_Int_precision + n_2 - 1; + px_2 = p_Data_Int_precision; + + px_4 = p_Data_Int_precision + n_3_4 - 1; + + for (i = 0; i> 1; i++) + { + + Int16 temp_re_0 = *(px_4--); + Int16 temp_im_1 = *(px_4--); + Int16 temp_re_2 = *(px_4--); + Int16 temp_im_3 = *(px_4--); + *(px_1--) = temp_re_0; + *(px_1--) = temp_im_1; + *(px_1--) = temp_re_2; + *(px_1--) = temp_im_3; + + *(px_2++) = (-temp_re_0); + *(px_2++) = (-temp_im_1); + *(px_2++) = (-temp_re_2); + *(px_2++) = (-temp_im_3); + + } + + + px_4 = p_Data_Int_precision + n_2; + + + pv_memcpy(px_4, pData_in_ref2 + 256, TWICE_INV_LONG_CX_ROT_LENGTH*sizeof(*px_4)); + + + + /* + * px2--> <--px1 px4--> <--px3 + * + * | | | + * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++| + * | | | | + * n/4 n/2 3n/4 + */ + px_3 = p_Data_Int_precision + n - 1; + + + for (i = 0; i> 1; i++) + { + + Int16 temp_im_0 = *(px_4++); + Int16 temp_re_1 = *(px_4++); + Int16 temp_im_2 = *(px_4++); + Int16 temp_re_3 = *(px_4++); + *(px_3--) = temp_im_0; + *(px_3--) = temp_re_1; + *(px_3--) = temp_im_2; + *(px_3--) = temp_re_3; + + } + + + return (exp + 1); +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.h new file mode 100644 index 00000000..6981e103 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_long_complex_rot.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_long_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function inv_long_complex_rot() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INV_LONG_COMPLEX_ROT_H +#define INV_LONG_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INV_LONG_CX_ROT_LENGTH 256 +#define TWICE_INV_LONG_CX_ROT_LENGTH (INV_LONG_CX_ROT_LENGTH<<1) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int inv_long_complex_rot( + Int32 *Data, + Int32 max); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* INV_LONG_COMPLEX_ROT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.c new file mode 100644 index 00000000..302ef17f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.c @@ -0,0 +1,266 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_short_complex_rot.cpp + Funtions: inv_short_complex_rot + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Data_in = Input vector (sized for short windows + 2*INV_SHORT_CX_ROT_LENGTH elements), with time domain samples + type Int32 * + + Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)), + (sized for short windows 2*INV_SHORT_CX_ROT_LENGTH) + type Int32 * + + max = Input, carries the maximum value of the input vector + "Data_in" + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exp = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data_out" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + inv_short_complex_rot() performs the complex rotation for the inverse MDCT + for the case of short windows. It performs digit reverse ordering as well + word normalization to ensure 16 by 16 bit multiplications. + +------------------------------------------------------------------------------ + REQUIREMENTS + + inv_short_complex_rot() should execute a post-rotation by + exp( j(2pi/N)(k+1/8)), digit reverse ordering and word normalization + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "digit_reversal_tables.h" +#include "imdct_fxp.h" +#include "inv_short_complex_rot.h" +#include "pv_normalize.h" +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +Int inv_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max) + +{ + Int i; + Int16 I; + const Int16 *pTable; + const Int32 *p_rotate; + + Int32 *pData_in_1; + Int exp; + Int32 temp_re; + Int32 temp_im; + + Int32 exp_jw; + Int16 *pData_re; + Int16 *pData_im; + Int32 *pData_in_ref; + + Int16 temp_re_0; + Int16 temp_im_0; + Int16 temp_re_1; + Int16 temp_im_1; + Int16 *p_data_1; + Int16 *p_data_2; + Int16 *p_Data_Int_precision; + Int16 *p_Data_Int_precision_1; + Int16 *p_Data_Int_precision_2; + + Int n = 256; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_8 = n >> 3; + Int n_3_4 = n_2 + n_4; + + + p_data_1 = (Int16 *)Data_out; + p_data_1 += n; + pData_re = p_data_1; + pData_im = p_data_1 + n_4; + + + p_rotate = exp_rotation_N_256; + pTable = digit_reverse_64; + + pData_in_ref = Data_in; + + exp = 16 - pv_normalize(max); + + + if (exp < 0) + { + exp = 0; + } + + exp -= 1; + + for (i = INV_SHORT_CX_ROT_LENGTH; i != 0; i--) + { + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + /* + * Perform digit reversal by accessing index I from table + */ + + I = *pTable++; + pData_in_1 = pData_in_ref + I; + /* + * Use auxiliary variables to avoid double accesses to memory. + * Data in is scaled to use only lower 16 bits. + */ + + temp_im = *(pData_in_1++); + temp_re = *(pData_in_1); + + exp_jw = *p_rotate++; + + /* + * Post-rotation + */ + + *(pData_re++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp); + *(pData_im++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp); + } + + + p_data_2 = pData_im - 1; + + + p_Data_Int_precision = (Int16 *)Data_out; + p_Data_Int_precision_1 = p_Data_Int_precision + n_3_4 - 1; + p_Data_Int_precision_2 = p_Data_Int_precision + n_3_4; + + for (i = n_8 >> 1; i != 0; i--) + { + temp_re_0 = (*(p_data_1++)); + temp_re_1 = (*(p_data_1++)); + temp_im_0 = (*(p_data_2--)); + temp_im_1 = (*(p_data_2--)); + + *(p_Data_Int_precision_1--) = temp_re_0; + *(p_Data_Int_precision_1--) = temp_im_0; + *(p_Data_Int_precision_1--) = temp_re_1; + *(p_Data_Int_precision_1--) = temp_im_1; + + *(p_Data_Int_precision_2++) = temp_re_0; + *(p_Data_Int_precision_2++) = temp_im_0; + *(p_Data_Int_precision_2++) = temp_re_1; + *(p_Data_Int_precision_2++) = temp_im_1; + + } + + + /* + * loop is split to avoid conditional testing inside loop + */ + + p_Data_Int_precision_2 = p_Data_Int_precision; + + for (i = n_8 >> 1; i != 0; i--) + { + + temp_re_0 = (*(p_data_1++)); + temp_re_1 = (*(p_data_1++)); + temp_im_0 = (*(p_data_2--)); + temp_im_1 = (*(p_data_2--)); + + *(p_Data_Int_precision_1--) = temp_re_0; + *(p_Data_Int_precision_1--) = temp_im_0; + *(p_Data_Int_precision_1--) = temp_re_1; + *(p_Data_Int_precision_1--) = temp_im_1; + + *(p_Data_Int_precision_2++) = (Int16)(-temp_re_0); + *(p_Data_Int_precision_2++) = (Int16)(-temp_im_0); + *(p_Data_Int_precision_2++) = (Int16)(-temp_re_1); + *(p_Data_Int_precision_2++) = (Int16)(-temp_im_1); + + } + + return (exp + 1); +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.h new file mode 100644 index 00000000..46f7f64b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/inv_short_complex_rot.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: inv_short_complex_rot.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions inv_short_complex_rot() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef INV_SHORT_COMPLEX_ROT_H +#define INV_SHORT_COMPLEX_ROT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define INV_SHORT_CX_ROT_LENGTH 64 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +Int inv_short_complex_rot( + Int32 *Data_in, + Int32 *Data_out, + Int32 max); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* INV_SHORT_COMPLEX_ROT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.c new file mode 100644 index 00000000..27515586 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.c @@ -0,0 +1,1122 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: iquant_table.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + None, just contains tables. +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Holds a table used for esc_iquant, containing the values of x^1/3 in + Q format. +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding + of moving pictures and associated audio information - Part 7: Advanced + Audio Coding (AAC)", Section 10.3, "Decoding process", page 43. + + +------------------------------------------------------------------------------ + PSEUDO-CODE + None. + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "iquant_table.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/* + This table contains the value of x ^ (1/3) where x is in the range of + [0..1024], in Q27 format. + Note that the length of the table is 1025, and not 1024 - this is because + the function esc_iquant may need to do an interpolation for numbers near + 8191, which in that case it needs to get 8192 ^(1/3). + */ +const UInt32 inverseQuantTable[] = +{ + 0x00000000, /* 0 */ + 0x08000000, /* 1 */ + 0x0a14517d, /* 2 */ + 0x0b89ba25, /* 3 */ + 0x0cb2ff53, /* 4 */ + 0x0dae07de, /* 5 */ + 0x0e897685, /* 6 */ + 0x0f4daedd, /* 7 */ + 0x10000000, /* 8 */ + 0x10a402fd, /* 9 */ + 0x113c4841, /* 10 */ + 0x11cab613, /* 11 */ + 0x1250bfe2, /* 12 */ + 0x12cf8890, /* 13 */ + 0x1347f8ab, /* 14 */ + 0x13bacd65, /* 15 */ + 0x1428a2fa, /* 16 */ + 0x1491fc15, /* 17 */ + 0x14f74744, /* 18 */ + 0x1558e2f7, /* 19 */ + 0x15b72095, /* 20 */ + 0x161246d7, /* 21 */ + 0x166a9399, /* 22 */ + 0x16c03d55, /* 23 */ + 0x17137449, /* 24 */ + 0x17646369, /* 25 */ + 0x17b33124, /* 26 */ + 0x18000000, /* 27 */ + 0x184aef29, /* 28 */ + 0x18941ad8, /* 29 */ + 0x18db9cb7, /* 30 */ + 0x19218c2e, /* 31 */ + 0x1965fea5, /* 32 */ + 0x19a907c2, /* 33 */ + 0x19eab998, /* 34 */ + 0x1a2b24d0, /* 35 */ + 0x1a6a58d5, /* 36 */ + 0x1aa863ee, /* 37 */ + 0x1ae5535d, /* 38 */ + 0x1b213377, /* 39 */ + 0x1b5c0fbd, /* 40 */ + 0x1b95f2ec, /* 41 */ + 0x1bcee70f, /* 42 */ + 0x1c06f590, /* 43 */ + 0x1c3e2745, /* 44 */ + 0x1c74847a, /* 45 */ + 0x1caa1501, /* 46 */ + 0x1cdee035, /* 47 */ + 0x1d12ed0b, /* 48 */ + 0x1d464212, /* 49 */ + 0x1d78e582, /* 50 */ + 0x1daadd3a, /* 51 */ + 0x1ddc2ecf, /* 52 */ + 0x1e0cdf8c, /* 53 */ + 0x1e3cf476, /* 54 */ + 0x1e6c7257, /* 55 */ + 0x1e9b5dba, /* 56 */ + 0x1ec9baf6, /* 57 */ + 0x1ef78e2c, /* 58 */ + 0x1f24db4e, /* 59 */ + 0x1f51a620, /* 60 */ + 0x1f7df23c, /* 61 */ + 0x1fa9c314, /* 62 */ + 0x1fd51bf2, /* 63 */ + 0x20000000, /* 64 */ + 0x202a7244, /* 65 */ + 0x205475a6, /* 66 */ + 0x207e0cee, /* 67 */ + 0x20a73aca, /* 68 */ + 0x20d001cc, /* 69 */ + 0x20f8646d, /* 70 */ + 0x2120650e, /* 71 */ + 0x214805fa, /* 72 */ + 0x216f4963, /* 73 */ + 0x2196316c, /* 74 */ + 0x21bcc020, /* 75 */ + 0x21e2f77a, /* 76 */ + 0x2208d961, /* 77 */ + 0x222e67ad, /* 78 */ + 0x2253a425, /* 79 */ + 0x22789082, /* 80 */ + 0x229d2e6e, /* 81 */ + 0x22c17f82, /* 82 */ + 0x22e5854f, /* 83 */ + 0x23094155, /* 84 */ + 0x232cb509, /* 85 */ + 0x234fe1d5, /* 86 */ + 0x2372c918, /* 87 */ + 0x23956c26, /* 88 */ + 0x23b7cc47, /* 89 */ + 0x23d9eabb, /* 90 */ + 0x23fbc8b9, /* 91 */ + 0x241d676e, /* 92 */ + 0x243ec7ff, /* 93 */ + 0x245feb86, /* 94 */ + 0x2480d319, /* 95 */ + 0x24a17fc3, /* 96 */ + 0x24c1f28b, /* 97 */ + 0x24e22c6c, /* 98 */ + 0x25022e5f, /* 99 */ + 0x2521f954, /* 100 */ + 0x25418e33, /* 101 */ + 0x2560ede2, /* 102 */ + 0x2580193e, /* 103 */ + 0x259f111f, /* 104 */ + 0x25bdd657, /* 105 */ + 0x25dc69b4, /* 106 */ + 0x25facbfe, /* 107 */ + 0x2618fdf8, /* 108 */ + 0x26370060, /* 109 */ + 0x2654d3ef, /* 110 */ + 0x2672795c, /* 111 */ + 0x268ff156, /* 112 */ + 0x26ad3c8a, /* 113 */ + 0x26ca5ba2, /* 114 */ + 0x26e74f41, /* 115 */ + 0x27041808, /* 116 */ + 0x2720b695, /* 117 */ + 0x273d2b81, /* 118 */ + 0x27597762, /* 119 */ + 0x27759acb, /* 120 */ + 0x2791964b, /* 121 */ + 0x27ad6a6f, /* 122 */ + 0x27c917c0, /* 123 */ + 0x27e49ec5, /* 124 */ + 0x28000000, /* 125 */ + 0x281b3bf3, /* 126 */ + 0x2836531b, /* 127 */ + 0x285145f3, /* 128 */ + 0x286c14f5, /* 129 */ + 0x2886c096, /* 130 */ + 0x28a1494b, /* 131 */ + 0x28bbaf85, /* 132 */ + 0x28d5f3b3, /* 133 */ + 0x28f01641, /* 134 */ + 0x290a179b, /* 135 */ + 0x2923f82a, /* 136 */ + 0x293db854, /* 137 */ + 0x2957587e, /* 138 */ + 0x2970d90a, /* 139 */ + 0x298a3a59, /* 140 */ + 0x29a37cca, /* 141 */ + 0x29bca0bb, /* 142 */ + 0x29d5a687, /* 143 */ + 0x29ee8e87, /* 144 */ + 0x2a075914, /* 145 */ + 0x2a200684, /* 146 */ + 0x2a38972c, /* 147 */ + 0x2a510b5f, /* 148 */ + 0x2a696370, /* 149 */ + 0x2a819fae, /* 150 */ + 0x2a99c069, /* 151 */ + 0x2ab1c5ed, /* 152 */ + 0x2ac9b088, /* 153 */ + 0x2ae18085, /* 154 */ + 0x2af9362c, /* 155 */ + 0x2b10d1c6, /* 156 */ + 0x2b28539b, /* 157 */ + 0x2b3fbbef, /* 158 */ + 0x2b570b09, /* 159 */ + 0x2b6e412b, /* 160 */ + 0x2b855e97, /* 161 */ + 0x2b9c6390, /* 162 */ + 0x2bb35056, /* 163 */ + 0x2bca2527, /* 164 */ + 0x2be0e242, /* 165 */ + 0x2bf787e4, /* 166 */ + 0x2c0e1649, /* 167 */ + 0x2c248dad, /* 168 */ + 0x2c3aee4a, /* 169 */ + 0x2c513859, /* 170 */ + 0x2c676c13, /* 171 */ + 0x2c7d89af, /* 172 */ + 0x2c939164, /* 173 */ + 0x2ca98368, /* 174 */ + 0x2cbf5ff1, /* 175 */ + 0x2cd52731, /* 176 */ + 0x2cead95e, /* 177 */ + 0x2d0076a9, /* 178 */ + 0x2d15ff45, /* 179 */ + 0x2d2b7363, /* 180 */ + 0x2d40d332, /* 181 */ + 0x2d561ee4, /* 182 */ + 0x2d6b56a7, /* 183 */ + 0x2d807aaa, /* 184 */ + 0x2d958b19, /* 185 */ + 0x2daa8823, /* 186 */ + 0x2dbf71f4, /* 187 */ + 0x2dd448b7, /* 188 */ + 0x2de90c98, /* 189 */ + 0x2dfdbdc0, /* 190 */ + 0x2e125c5c, /* 191 */ + 0x2e26e892, /* 192 */ + 0x2e3b628d, /* 193 */ + 0x2e4fca75, /* 194 */ + 0x2e642070, /* 195 */ + 0x2e7864a8, /* 196 */ + 0x2e8c9741, /* 197 */ + 0x2ea0b862, /* 198 */ + 0x2eb4c831, /* 199 */ + 0x2ec8c6d3, /* 200 */ + 0x2edcb46c, /* 201 */ + 0x2ef09121, /* 202 */ + 0x2f045d14, /* 203 */ + 0x2f18186a, /* 204 */ + 0x2f2bc345, /* 205 */ + 0x2f3f5dc7, /* 206 */ + 0x2f52e812, /* 207 */ + 0x2f666247, /* 208 */ + 0x2f79cc88, /* 209 */ + 0x2f8d26f4, /* 210 */ + 0x2fa071ac, /* 211 */ + 0x2fb3acd0, /* 212 */ + 0x2fc6d87f, /* 213 */ + 0x2fd9f4d7, /* 214 */ + 0x2fed01f8, /* 215 */ + 0x30000000, /* 216 */ + 0x3012ef0c, /* 217 */ + 0x3025cf39, /* 218 */ + 0x3038a0a6, /* 219 */ + 0x304b636d, /* 220 */ + 0x305e17ad, /* 221 */ + 0x3070bd81, /* 222 */ + 0x30835504, /* 223 */ + 0x3095de51, /* 224 */ + 0x30a85985, /* 225 */ + 0x30bac6b9, /* 226 */ + 0x30cd2609, /* 227 */ + 0x30df778d, /* 228 */ + 0x30f1bb60, /* 229 */ + 0x3103f19c, /* 230 */ + 0x31161a59, /* 231 */ + 0x312835b0, /* 232 */ + 0x313a43ba, /* 233 */ + 0x314c4490, /* 234 */ + 0x315e3849, /* 235 */ + 0x31701efd, /* 236 */ + 0x3181f8c4, /* 237 */ + 0x3193c5b4, /* 238 */ + 0x31a585e6, /* 239 */ + 0x31b7396f, /* 240 */ + 0x31c8e066, /* 241 */ + 0x31da7ae1, /* 242 */ + 0x31ec08f6, /* 243 */ + 0x31fd8abc, /* 244 */ + 0x320f0047, /* 245 */ + 0x322069ac, /* 246 */ + 0x3231c702, /* 247 */ + 0x3243185c, /* 248 */ + 0x32545dcf, /* 249 */ + 0x32659770, /* 250 */ + 0x3276c552, /* 251 */ + 0x3287e78a, /* 252 */ + 0x3298fe2c, /* 253 */ + 0x32aa094a, /* 254 */ + 0x32bb08f9, /* 255 */ + 0x32cbfd4a, /* 256 */ + 0x32dce652, /* 257 */ + 0x32edc423, /* 258 */ + 0x32fe96d0, /* 259 */ + 0x330f5e6a, /* 260 */ + 0x33201b04, /* 261 */ + 0x3330ccb0, /* 262 */ + 0x33417380, /* 263 */ + 0x33520f85, /* 264 */ + 0x3362a0d0, /* 265 */ + 0x33732774, /* 266 */ + 0x3383a380, /* 267 */ + 0x33941506, /* 268 */ + 0x33a47c17, /* 269 */ + 0x33b4d8c4, /* 270 */ + 0x33c52b1b, /* 271 */ + 0x33d5732f, /* 272 */ + 0x33e5b10f, /* 273 */ + 0x33f5e4ca, /* 274 */ + 0x34060e71, /* 275 */ + 0x34162e14, /* 276 */ + 0x342643c1, /* 277 */ + 0x34364f88, /* 278 */ + 0x34465178, /* 279 */ + 0x345649a1, /* 280 */ + 0x34663810, /* 281 */ + 0x34761cd6, /* 282 */ + 0x3485f800, /* 283 */ + 0x3495c99d, /* 284 */ + 0x34a591bb, /* 285 */ + 0x34b55069, /* 286 */ + 0x34c505b4, /* 287 */ + 0x34d4b1ab, /* 288 */ + 0x34e4545b, /* 289 */ + 0x34f3edd2, /* 290 */ + 0x35037e1d, /* 291 */ + 0x3513054b, /* 292 */ + 0x35228367, /* 293 */ + 0x3531f881, /* 294 */ + 0x354164a3, /* 295 */ + 0x3550c7dc, /* 296 */ + 0x35602239, /* 297 */ + 0x356f73c5, /* 298 */ + 0x357ebc8e, /* 299 */ + 0x358dfca0, /* 300 */ + 0x359d3408, /* 301 */ + 0x35ac62d1, /* 302 */ + 0x35bb8908, /* 303 */ + 0x35caa6b9, /* 304 */ + 0x35d9bbf0, /* 305 */ + 0x35e8c8b9, /* 306 */ + 0x35f7cd20, /* 307 */ + 0x3606c92f, /* 308 */ + 0x3615bcf3, /* 309 */ + 0x3624a878, /* 310 */ + 0x36338bc8, /* 311 */ + 0x364266ee, /* 312 */ + 0x365139f6, /* 313 */ + 0x366004ec, /* 314 */ + 0x366ec7d9, /* 315 */ + 0x367d82c9, /* 316 */ + 0x368c35c6, /* 317 */ + 0x369ae0dc, /* 318 */ + 0x36a98414, /* 319 */ + 0x36b81f7a, /* 320 */ + 0x36c6b317, /* 321 */ + 0x36d53ef7, /* 322 */ + 0x36e3c323, /* 323 */ + 0x36f23fa5, /* 324 */ + 0x3700b488, /* 325 */ + 0x370f21d5, /* 326 */ + 0x371d8797, /* 327 */ + 0x372be5d7, /* 328 */ + 0x373a3ca0, /* 329 */ + 0x37488bf9, /* 330 */ + 0x3756d3ef, /* 331 */ + 0x37651489, /* 332 */ + 0x37734dd1, /* 333 */ + 0x37817fd1, /* 334 */ + 0x378faa92, /* 335 */ + 0x379dce1d, /* 336 */ + 0x37abea7c, /* 337 */ + 0x37b9ffb7, /* 338 */ + 0x37c80dd7, /* 339 */ + 0x37d614e6, /* 340 */ + 0x37e414ec, /* 341 */ + 0x37f20df1, /* 342 */ + 0x38000000, /* 343 */ + 0x380deb20, /* 344 */ + 0x381bcf5a, /* 345 */ + 0x3829acb6, /* 346 */ + 0x3837833d, /* 347 */ + 0x384552f8, /* 348 */ + 0x38531bee, /* 349 */ + 0x3860de28, /* 350 */ + 0x386e99af, /* 351 */ + 0x387c4e89, /* 352 */ + 0x3889fcc0, /* 353 */ + 0x3897a45b, /* 354 */ + 0x38a54563, /* 355 */ + 0x38b2dfdf, /* 356 */ + 0x38c073d7, /* 357 */ + 0x38ce0152, /* 358 */ + 0x38db885a, /* 359 */ + 0x38e908f4, /* 360 */ + 0x38f68329, /* 361 */ + 0x3903f701, /* 362 */ + 0x39116483, /* 363 */ + 0x391ecbb6, /* 364 */ + 0x392c2ca1, /* 365 */ + 0x3939874d, /* 366 */ + 0x3946dbc0, /* 367 */ + 0x39542a01, /* 368 */ + 0x39617218, /* 369 */ + 0x396eb40c, /* 370 */ + 0x397befe4, /* 371 */ + 0x398925a7, /* 372 */ + 0x3996555c, /* 373 */ + 0x39a37f09, /* 374 */ + 0x39b0a2b7, /* 375 */ + 0x39bdc06a, /* 376 */ + 0x39cad82b, /* 377 */ + 0x39d7ea01, /* 378 */ + 0x39e4f5f0, /* 379 */ + 0x39f1fc01, /* 380 */ + 0x39fefc3a, /* 381 */ + 0x3a0bf6a2, /* 382 */ + 0x3a18eb3e, /* 383 */ + 0x3a25da16, /* 384 */ + 0x3a32c32f, /* 385 */ + 0x3a3fa691, /* 386 */ + 0x3a4c8441, /* 387 */ + 0x3a595c46, /* 388 */ + 0x3a662ea6, /* 389 */ + 0x3a72fb67, /* 390 */ + 0x3a7fc28f, /* 391 */ + 0x3a8c8425, /* 392 */ + 0x3a99402e, /* 393 */ + 0x3aa5f6b1, /* 394 */ + 0x3ab2a7b3, /* 395 */ + 0x3abf533a, /* 396 */ + 0x3acbf94d, /* 397 */ + 0x3ad899f1, /* 398 */ + 0x3ae5352c, /* 399 */ + 0x3af1cb03, /* 400 */ + 0x3afe5b7d, /* 401 */ + 0x3b0ae6a0, /* 402 */ + 0x3b176c70, /* 403 */ + 0x3b23ecf3, /* 404 */ + 0x3b306830, /* 405 */ + 0x3b3cde2c, /* 406 */ + 0x3b494eeb, /* 407 */ + 0x3b55ba74, /* 408 */ + 0x3b6220cc, /* 409 */ + 0x3b6e81f9, /* 410 */ + 0x3b7ade00, /* 411 */ + 0x3b8734e5, /* 412 */ + 0x3b9386b0, /* 413 */ + 0x3b9fd364, /* 414 */ + 0x3bac1b07, /* 415 */ + 0x3bb85d9e, /* 416 */ + 0x3bc49b2f, /* 417 */ + 0x3bd0d3be, /* 418 */ + 0x3bdd0751, /* 419 */ + 0x3be935ed, /* 420 */ + 0x3bf55f97, /* 421 */ + 0x3c018453, /* 422 */ + 0x3c0da427, /* 423 */ + 0x3c19bf17, /* 424 */ + 0x3c25d52a, /* 425 */ + 0x3c31e662, /* 426 */ + 0x3c3df2c6, /* 427 */ + 0x3c49fa5b, /* 428 */ + 0x3c55fd24, /* 429 */ + 0x3c61fb27, /* 430 */ + 0x3c6df468, /* 431 */ + 0x3c79e8ed, /* 432 */ + 0x3c85d8b9, /* 433 */ + 0x3c91c3d2, /* 434 */ + 0x3c9daa3c, /* 435 */ + 0x3ca98bfc, /* 436 */ + 0x3cb56915, /* 437 */ + 0x3cc1418e, /* 438 */ + 0x3ccd156a, /* 439 */ + 0x3cd8e4ae, /* 440 */ + 0x3ce4af5e, /* 441 */ + 0x3cf0757f, /* 442 */ + 0x3cfc3714, /* 443 */ + 0x3d07f423, /* 444 */ + 0x3d13acb0, /* 445 */ + 0x3d1f60bf, /* 446 */ + 0x3d2b1055, /* 447 */ + 0x3d36bb75, /* 448 */ + 0x3d426224, /* 449 */ + 0x3d4e0466, /* 450 */ + 0x3d59a23f, /* 451 */ + 0x3d653bb4, /* 452 */ + 0x3d70d0c8, /* 453 */ + 0x3d7c6180, /* 454 */ + 0x3d87ede0, /* 455 */ + 0x3d9375ec, /* 456 */ + 0x3d9ef9a8, /* 457 */ + 0x3daa7918, /* 458 */ + 0x3db5f43f, /* 459 */ + 0x3dc16b23, /* 460 */ + 0x3dccddc7, /* 461 */ + 0x3dd84c2e, /* 462 */ + 0x3de3b65d, /* 463 */ + 0x3def1c58, /* 464 */ + 0x3dfa7e22, /* 465 */ + 0x3e05dbc0, /* 466 */ + 0x3e113535, /* 467 */ + 0x3e1c8a85, /* 468 */ + 0x3e27dbb3, /* 469 */ + 0x3e3328c4, /* 470 */ + 0x3e3e71bb, /* 471 */ + 0x3e49b69c, /* 472 */ + 0x3e54f76b, /* 473 */ + 0x3e60342b, /* 474 */ + 0x3e6b6ce0, /* 475 */ + 0x3e76a18d, /* 476 */ + 0x3e81d237, /* 477 */ + 0x3e8cfee0, /* 478 */ + 0x3e98278d, /* 479 */ + 0x3ea34c40, /* 480 */ + 0x3eae6cfe, /* 481 */ + 0x3eb989ca, /* 482 */ + 0x3ec4a2a8, /* 483 */ + 0x3ecfb79a, /* 484 */ + 0x3edac8a5, /* 485 */ + 0x3ee5d5cb, /* 486 */ + 0x3ef0df10, /* 487 */ + 0x3efbe478, /* 488 */ + 0x3f06e606, /* 489 */ + 0x3f11e3be, /* 490 */ + 0x3f1cdda2, /* 491 */ + 0x3f27d3b6, /* 492 */ + 0x3f32c5fd, /* 493 */ + 0x3f3db47b, /* 494 */ + 0x3f489f32, /* 495 */ + 0x3f538627, /* 496 */ + 0x3f5e695c, /* 497 */ + 0x3f6948d5, /* 498 */ + 0x3f742494, /* 499 */ + 0x3f7efc9d, /* 500 */ + 0x3f89d0f3, /* 501 */ + 0x3f94a19a, /* 502 */ + 0x3f9f6e94, /* 503 */ + 0x3faa37e4, /* 504 */ + 0x3fb4fd8e, /* 505 */ + 0x3fbfbf94, /* 506 */ + 0x3fca7dfb, /* 507 */ + 0x3fd538c4, /* 508 */ + 0x3fdfeff3, /* 509 */ + 0x3feaa38a, /* 510 */ + 0x3ff5538e, /* 511 */ + 0x40000000, /* 512 */ + 0x400aa8e4, /* 513 */ + 0x40154e3d, /* 514 */ + 0x401ff00d, /* 515 */ + 0x402a8e58, /* 516 */ + 0x40352921, /* 517 */ + 0x403fc06a, /* 518 */ + 0x404a5436, /* 519 */ + 0x4054e488, /* 520 */ + 0x405f7164, /* 521 */ + 0x4069facb, /* 522 */ + 0x407480c1, /* 523 */ + 0x407f0348, /* 524 */ + 0x40898264, /* 525 */ + 0x4093fe16, /* 526 */ + 0x409e7663, /* 527 */ + 0x40a8eb4c, /* 528 */ + 0x40b35cd4, /* 529 */ + 0x40bdcafe, /* 530 */ + 0x40c835cd, /* 531 */ + 0x40d29d43, /* 532 */ + 0x40dd0164, /* 533 */ + 0x40e76231, /* 534 */ + 0x40f1bfae, /* 535 */ + 0x40fc19dc, /* 536 */ + 0x410670c0, /* 537 */ + 0x4110c45a, /* 538 */ + 0x411b14af, /* 539 */ + 0x412561c0, /* 540 */ + 0x412fab90, /* 541 */ + 0x4139f222, /* 542 */ + 0x41443578, /* 543 */ + 0x414e7595, /* 544 */ + 0x4158b27a, /* 545 */ + 0x4162ec2c, /* 546 */ + 0x416d22ac, /* 547 */ + 0x417755fd, /* 548 */ + 0x41818621, /* 549 */ + 0x418bb31a, /* 550 */ + 0x4195dcec, /* 551 */ + 0x41a00399, /* 552 */ + 0x41aa2722, /* 553 */ + 0x41b4478b, /* 554 */ + 0x41be64d6, /* 555 */ + 0x41c87f05, /* 556 */ + 0x41d2961a, /* 557 */ + 0x41dcaa19, /* 558 */ + 0x41e6bb03, /* 559 */ + 0x41f0c8db, /* 560 */ + 0x41fad3a3, /* 561 */ + 0x4204db5d, /* 562 */ + 0x420ee00c, /* 563 */ + 0x4218e1b1, /* 564 */ + 0x4222e051, /* 565 */ + 0x422cdbeb, /* 566 */ + 0x4236d484, /* 567 */ + 0x4240ca1d, /* 568 */ + 0x424abcb8, /* 569 */ + 0x4254ac58, /* 570 */ + 0x425e98fe, /* 571 */ + 0x426882ae, /* 572 */ + 0x42726969, /* 573 */ + 0x427c4d31, /* 574 */ + 0x42862e09, /* 575 */ + 0x42900bf3, /* 576 */ + 0x4299e6f1, /* 577 */ + 0x42a3bf05, /* 578 */ + 0x42ad9432, /* 579 */ + 0x42b76678, /* 580 */ + 0x42c135dc, /* 581 */ + 0x42cb025e, /* 582 */ + 0x42d4cc01, /* 583 */ + 0x42de92c7, /* 584 */ + 0x42e856b2, /* 585 */ + 0x42f217c4, /* 586 */ + 0x42fbd5ff, /* 587 */ + 0x43059166, /* 588 */ + 0x430f49f9, /* 589 */ + 0x4318ffbc, /* 590 */ + 0x4322b2b1, /* 591 */ + 0x432c62d8, /* 592 */ + 0x43361036, /* 593 */ + 0x433fbaca, /* 594 */ + 0x43496298, /* 595 */ + 0x435307a2, /* 596 */ + 0x435ca9e8, /* 597 */ + 0x4366496e, /* 598 */ + 0x436fe636, /* 599 */ + 0x43798041, /* 600 */ + 0x43831790, /* 601 */ + 0x438cac28, /* 602 */ + 0x43963e08, /* 603 */ + 0x439fcd33, /* 604 */ + 0x43a959ab, /* 605 */ + 0x43b2e372, /* 606 */ + 0x43bc6a89, /* 607 */ + 0x43c5eef3, /* 608 */ + 0x43cf70b2, /* 609 */ + 0x43d8efc7, /* 610 */ + 0x43e26c34, /* 611 */ + 0x43ebe5fb, /* 612 */ + 0x43f55d1e, /* 613 */ + 0x43fed19f, /* 614 */ + 0x44084380, /* 615 */ + 0x4411b2c1, /* 616 */ + 0x441b1f66, /* 617 */ + 0x44248970, /* 618 */ + 0x442df0e1, /* 619 */ + 0x443755bb, /* 620 */ + 0x4440b7fe, /* 621 */ + 0x444a17ae, /* 622 */ + 0x445374cc, /* 623 */ + 0x445ccf5a, /* 624 */ + 0x44662758, /* 625 */ + 0x446f7ccb, /* 626 */ + 0x4478cfb2, /* 627 */ + 0x4482200f, /* 628 */ + 0x448b6de5, /* 629 */ + 0x4494b935, /* 630 */ + 0x449e0201, /* 631 */ + 0x44a7484b, /* 632 */ + 0x44b08c13, /* 633 */ + 0x44b9cd5d, /* 634 */ + 0x44c30c29, /* 635 */ + 0x44cc4879, /* 636 */ + 0x44d5824f, /* 637 */ + 0x44deb9ac, /* 638 */ + 0x44e7ee93, /* 639 */ + 0x44f12105, /* 640 */ + 0x44fa5103, /* 641 */ + 0x45037e8f, /* 642 */ + 0x450ca9ab, /* 643 */ + 0x4515d258, /* 644 */ + 0x451ef899, /* 645 */ + 0x45281c6e, /* 646 */ + 0x45313dd8, /* 647 */ + 0x453a5cdb, /* 648 */ + 0x45437977, /* 649 */ + 0x454c93ae, /* 650 */ + 0x4555ab82, /* 651 */ + 0x455ec0f3, /* 652 */ + 0x4567d404, /* 653 */ + 0x4570e4b7, /* 654 */ + 0x4579f30c, /* 655 */ + 0x4582ff05, /* 656 */ + 0x458c08a4, /* 657 */ + 0x45950fea, /* 658 */ + 0x459e14d9, /* 659 */ + 0x45a71773, /* 660 */ + 0x45b017b8, /* 661 */ + 0x45b915aa, /* 662 */ + 0x45c2114c, /* 663 */ + 0x45cb0a9e, /* 664 */ + 0x45d401a1, /* 665 */ + 0x45dcf658, /* 666 */ + 0x45e5e8c4, /* 667 */ + 0x45eed8e6, /* 668 */ + 0x45f7c6c0, /* 669 */ + 0x4600b253, /* 670 */ + 0x46099ba0, /* 671 */ + 0x461282a9, /* 672 */ + 0x461b6770, /* 673 */ + 0x462449f6, /* 674 */ + 0x462d2a3c, /* 675 */ + 0x46360844, /* 676 */ + 0x463ee40f, /* 677 */ + 0x4647bd9f, /* 678 */ + 0x465094f5, /* 679 */ + 0x46596a12, /* 680 */ + 0x46623cf8, /* 681 */ + 0x466b0da8, /* 682 */ + 0x4673dc24, /* 683 */ + 0x467ca86c, /* 684 */ + 0x46857283, /* 685 */ + 0x468e3a69, /* 686 */ + 0x46970021, /* 687 */ + 0x469fc3ab, /* 688 */ + 0x46a88509, /* 689 */ + 0x46b1443b, /* 690 */ + 0x46ba0144, /* 691 */ + 0x46c2bc25, /* 692 */ + 0x46cb74df, /* 693 */ + 0x46d42b74, /* 694 */ + 0x46dcdfe4, /* 695 */ + 0x46e59231, /* 696 */ + 0x46ee425c, /* 697 */ + 0x46f6f068, /* 698 */ + 0x46ff9c54, /* 699 */ + 0x47084622, /* 700 */ + 0x4710edd4, /* 701 */ + 0x4719936b, /* 702 */ + 0x472236e7, /* 703 */ + 0x472ad84b, /* 704 */ + 0x47337798, /* 705 */ + 0x473c14cf, /* 706 */ + 0x4744aff1, /* 707 */ + 0x474d48ff, /* 708 */ + 0x4755dffb, /* 709 */ + 0x475e74e6, /* 710 */ + 0x476707c1, /* 711 */ + 0x476f988e, /* 712 */ + 0x4778274d, /* 713 */ + 0x4780b400, /* 714 */ + 0x47893ea8, /* 715 */ + 0x4791c746, /* 716 */ + 0x479a4ddc, /* 717 */ + 0x47a2d26b, /* 718 */ + 0x47ab54f3, /* 719 */ + 0x47b3d577, /* 720 */ + 0x47bc53f7, /* 721 */ + 0x47c4d074, /* 722 */ + 0x47cd4af0, /* 723 */ + 0x47d5c36c, /* 724 */ + 0x47de39e9, /* 725 */ + 0x47e6ae69, /* 726 */ + 0x47ef20ec, /* 727 */ + 0x47f79173, /* 728 */ + 0x48000000, /* 729 */ + 0x48086c94, /* 730 */ + 0x4810d730, /* 731 */ + 0x48193fd5, /* 732 */ + 0x4821a685, /* 733 */ + 0x482a0b40, /* 734 */ + 0x48326e07, /* 735 */ + 0x483acedd, /* 736 */ + 0x48432dc1, /* 737 */ + 0x484b8ab5, /* 738 */ + 0x4853e5bb, /* 739 */ + 0x485c3ed2, /* 740 */ + 0x486495fd, /* 741 */ + 0x486ceb3c, /* 742 */ + 0x48753e91, /* 743 */ + 0x487d8ffd, /* 744 */ + 0x4885df80, /* 745 */ + 0x488e2d1d, /* 746 */ + 0x489678d3, /* 747 */ + 0x489ec2a4, /* 748 */ + 0x48a70a91, /* 749 */ + 0x48af509b, /* 750 */ + 0x48b794c4, /* 751 */ + 0x48bfd70c, /* 752 */ + 0x48c81774, /* 753 */ + 0x48d055fe, /* 754 */ + 0x48d892aa, /* 755 */ + 0x48e0cd7a, /* 756 */ + 0x48e9066e, /* 757 */ + 0x48f13d88, /* 758 */ + 0x48f972c9, /* 759 */ + 0x4901a632, /* 760 */ + 0x4909d7c3, /* 761 */ + 0x4912077e, /* 762 */ + 0x491a3564, /* 763 */ + 0x49226175, /* 764 */ + 0x492a8bb4, /* 765 */ + 0x4932b420, /* 766 */ + 0x493adabc, /* 767 */ + 0x4942ff87, /* 768 */ + 0x494b2283, /* 769 */ + 0x495343b1, /* 770 */ + 0x495b6312, /* 771 */ + 0x496380a7, /* 772 */ + 0x496b9c71, /* 773 */ + 0x4973b670, /* 774 */ + 0x497bcea7, /* 775 */ + 0x4983e515, /* 776 */ + 0x498bf9bc, /* 777 */ + 0x49940c9e, /* 778 */ + 0x499c1db9, /* 779 */ + 0x49a42d11, /* 780 */ + 0x49ac3aa5, /* 781 */ + 0x49b44677, /* 782 */ + 0x49bc5088, /* 783 */ + 0x49c458d8, /* 784 */ + 0x49cc5f69, /* 785 */ + 0x49d4643c, /* 786 */ + 0x49dc6750, /* 787 */ + 0x49e468a9, /* 788 */ + 0x49ec6845, /* 789 */ + 0x49f46627, /* 790 */ + 0x49fc624f, /* 791 */ + 0x4a045cbe, /* 792 */ + 0x4a0c5575, /* 793 */ + 0x4a144c76, /* 794 */ + 0x4a1c41c0, /* 795 */ + 0x4a243555, /* 796 */ + 0x4a2c2735, /* 797 */ + 0x4a341763, /* 798 */ + 0x4a3c05de, /* 799 */ + 0x4a43f2a7, /* 800 */ + 0x4a4bddc0, /* 801 */ + 0x4a53c729, /* 802 */ + 0x4a5baee3, /* 803 */ + 0x4a6394ef, /* 804 */ + 0x4a6b794f, /* 805 */ + 0x4a735c02, /* 806 */ + 0x4a7b3d09, /* 807 */ + 0x4a831c67, /* 808 */ + 0x4a8afa1b, /* 809 */ + 0x4a92d626, /* 810 */ + 0x4a9ab089, /* 811 */ + 0x4aa28946, /* 812 */ + 0x4aaa605d, /* 813 */ + 0x4ab235ce, /* 814 */ + 0x4aba099b, /* 815 */ + 0x4ac1dbc5, /* 816 */ + 0x4ac9ac4c, /* 817 */ + 0x4ad17b31, /* 818 */ + 0x4ad94876, /* 819 */ + 0x4ae1141a, /* 820 */ + 0x4ae8de1f, /* 821 */ + 0x4af0a686, /* 822 */ + 0x4af86d50, /* 823 */ + 0x4b00327d, /* 824 */ + 0x4b07f60d, /* 825 */ + 0x4b0fb803, /* 826 */ + 0x4b17785f, /* 827 */ + 0x4b1f3722, /* 828 */ + 0x4b26f44b, /* 829 */ + 0x4b2eafde, /* 830 */ + 0x4b3669d9, /* 831 */ + 0x4b3e223e, /* 832 */ + 0x4b45d90e, /* 833 */ + 0x4b4d8e4a, /* 834 */ + 0x4b5541f2, /* 835 */ + 0x4b5cf407, /* 836 */ + 0x4b64a48a, /* 837 */ + 0x4b6c537c, /* 838 */ + 0x4b7400dd, /* 839 */ + 0x4b7bacaf, /* 840 */ + 0x4b8356f2, /* 841 */ + 0x4b8affa7, /* 842 */ + 0x4b92a6ce, /* 843 */ + 0x4b9a4c69, /* 844 */ + 0x4ba1f079, /* 845 */ + 0x4ba992fd, /* 846 */ + 0x4bb133f8, /* 847 */ + 0x4bb8d369, /* 848 */ + 0x4bc07151, /* 849 */ + 0x4bc80db2, /* 850 */ + 0x4bcfa88c, /* 851 */ + 0x4bd741df, /* 852 */ + 0x4bded9ad, /* 853 */ + 0x4be66ff6, /* 854 */ + 0x4bee04bb, /* 855 */ + 0x4bf597fc, /* 856 */ + 0x4bfd29bc, /* 857 */ + 0x4c04b9f9, /* 858 */ + 0x4c0c48b6, /* 859 */ + 0x4c13d5f2, /* 860 */ + 0x4c1b61af, /* 861 */ + 0x4c22ebed, /* 862 */ + 0x4c2a74ad, /* 863 */ + 0x4c31fbf0, /* 864 */ + 0x4c3981b6, /* 865 */ + 0x4c410600, /* 866 */ + 0x4c4888d0, /* 867 */ + 0x4c500a25, /* 868 */ + 0x4c578a00, /* 869 */ + 0x4c5f0862, /* 870 */ + 0x4c66854c, /* 871 */ + 0x4c6e00bf, /* 872 */ + 0x4c757abb, /* 873 */ + 0x4c7cf341, /* 874 */ + 0x4c846a52, /* 875 */ + 0x4c8bdfee, /* 876 */ + 0x4c935416, /* 877 */ + 0x4c9ac6cb, /* 878 */ + 0x4ca2380e, /* 879 */ + 0x4ca9a7de, /* 880 */ + 0x4cb1163e, /* 881 */ + 0x4cb8832d, /* 882 */ + 0x4cbfeead, /* 883 */ + 0x4cc758bd, /* 884 */ + 0x4ccec15f, /* 885 */ + 0x4cd62894, /* 886 */ + 0x4cdd8e5c, /* 887 */ + 0x4ce4f2b7, /* 888 */ + 0x4cec55a7, /* 889 */ + 0x4cf3b72c, /* 890 */ + 0x4cfb1747, /* 891 */ + 0x4d0275f8, /* 892 */ + 0x4d09d340, /* 893 */ + 0x4d112f21, /* 894 */ + 0x4d188999, /* 895 */ + 0x4d1fe2ab, /* 896 */ + 0x4d273a57, /* 897 */ + 0x4d2e909d, /* 898 */ + 0x4d35e57f, /* 899 */ + 0x4d3d38fc, /* 900 */ + 0x4d448b16, /* 901 */ + 0x4d4bdbcd, /* 902 */ + 0x4d532b21, /* 903 */ + 0x4d5a7914, /* 904 */ + 0x4d61c5a7, /* 905 */ + 0x4d6910d9, /* 906 */ + 0x4d705aab, /* 907 */ + 0x4d77a31e, /* 908 */ + 0x4d7eea34, /* 909 */ + 0x4d862feb, /* 910 */ + 0x4d8d7445, /* 911 */ + 0x4d94b743, /* 912 */ + 0x4d9bf8e6, /* 913 */ + 0x4da3392d, /* 914 */ + 0x4daa7819, /* 915 */ + 0x4db1b5ac, /* 916 */ + 0x4db8f1e6, /* 917 */ + 0x4dc02cc7, /* 918 */ + 0x4dc76650, /* 919 */ + 0x4dce9e81, /* 920 */ + 0x4dd5d55c, /* 921 */ + 0x4ddd0ae1, /* 922 */ + 0x4de43f10, /* 923 */ + 0x4deb71eb, /* 924 */ + 0x4df2a371, /* 925 */ + 0x4df9d3a3, /* 926 */ + 0x4e010283, /* 927 */ + 0x4e083010, /* 928 */ + 0x4e0f5c4b, /* 929 */ + 0x4e168735, /* 930 */ + 0x4e1db0cf, /* 931 */ + 0x4e24d918, /* 932 */ + 0x4e2c0012, /* 933 */ + 0x4e3325bd, /* 934 */ + 0x4e3a4a1a, /* 935 */ + 0x4e416d2a, /* 936 */ + 0x4e488eec, /* 937 */ + 0x4e4faf62, /* 938 */ + 0x4e56ce8c, /* 939 */ + 0x4e5dec6b, /* 940 */ + 0x4e6508ff, /* 941 */ + 0x4e6c2449, /* 942 */ + 0x4e733e4a, /* 943 */ + 0x4e7a5702, /* 944 */ + 0x4e816e71, /* 945 */ + 0x4e888498, /* 946 */ + 0x4e8f9979, /* 947 */ + 0x4e96ad13, /* 948 */ + 0x4e9dbf67, /* 949 */ + 0x4ea4d075, /* 950 */ + 0x4eabe03e, /* 951 */ + 0x4eb2eec4, /* 952 */ + 0x4eb9fc05, /* 953 */ + 0x4ec10803, /* 954 */ + 0x4ec812bf, /* 955 */ + 0x4ecf1c39, /* 956 */ + 0x4ed62471, /* 957 */ + 0x4edd2b68, /* 958 */ + 0x4ee4311f, /* 959 */ + 0x4eeb3596, /* 960 */ + 0x4ef238cd, /* 961 */ + 0x4ef93ac6, /* 962 */ + 0x4f003b81, /* 963 */ + 0x4f073afe, /* 964 */ + 0x4f0e393f, /* 965 */ + 0x4f153642, /* 966 */ + 0x4f1c320a, /* 967 */ + 0x4f232c96, /* 968 */ + 0x4f2a25e8, /* 969 */ + 0x4f311dff, /* 970 */ + 0x4f3814dc, /* 971 */ + 0x4f3f0a80, /* 972 */ + 0x4f45feeb, /* 973 */ + 0x4f4cf21f, /* 974 */ + 0x4f53e41a, /* 975 */ + 0x4f5ad4de, /* 976 */ + 0x4f61c46c, /* 977 */ + 0x4f68b2c4, /* 978 */ + 0x4f6f9fe6, /* 979 */ + 0x4f768bd3, /* 980 */ + 0x4f7d768c, /* 981 */ + 0x4f846011, /* 982 */ + 0x4f8b4862, /* 983 */ + 0x4f922f81, /* 984 */ + 0x4f99156d, /* 985 */ + 0x4f9ffa27, /* 986 */ + 0x4fa6ddb0, /* 987 */ + 0x4fadc008, /* 988 */ + 0x4fb4a12f, /* 989 */ + 0x4fbb8127, /* 990 */ + 0x4fc25ff0, /* 991 */ + 0x4fc93d8a, /* 992 */ + 0x4fd019f5, /* 993 */ + 0x4fd6f533, /* 994 */ + 0x4fddcf43, /* 995 */ + 0x4fe4a827, /* 996 */ + 0x4feb7fde, /* 997 */ + 0x4ff2566a, /* 998 */ + 0x4ff92bca, /* 999 */ + 0x50000000, /* 1000 */ + 0x5006d30b, /* 1001 */ + 0x500da4ed, /* 1002 */ + 0x501475a5, /* 1003 */ + 0x501b4535, /* 1004 */ + 0x5022139c, /* 1005 */ + 0x5028e0dc, /* 1006 */ + 0x502facf4, /* 1007 */ + 0x503677e5, /* 1008 */ + 0x503d41b0, /* 1009 */ + 0x50440a55, /* 1010 */ + 0x504ad1d5, /* 1011 */ + 0x50519830, /* 1012 */ + 0x50585d67, /* 1013 */ + 0x505f217a, /* 1014 */ + 0x5065e469, /* 1015 */ + 0x506ca635, /* 1016 */ + 0x507366df, /* 1017 */ + 0x507a2667, /* 1018 */ + 0x5080e4cd, /* 1019 */ + 0x5087a212, /* 1020 */ + 0x508e5e37, /* 1021 */ + 0x5095193c, /* 1022 */ + 0x509bd320, /* 1023 */ + 0x50a28be6, /* 1024 */ +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.h new file mode 100644 index 00000000..9f14afb7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/iquant_table.h @@ -0,0 +1,79 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: iquant_table.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for iquant_table.c, which contains a table used with + esc_iquant.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef IQUANT_TABLE_H +#define IQUANT_TABLE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const UInt32 inverseQuantTable[]; +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.c new file mode 100644 index 00000000..bfd8e069 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.c @@ -0,0 +1,587 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_prediction.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + win_seq = type of window sequence (WINDOW_SEQUENCE). + + weight_index = index (Int) of LTP coefficient table for all windows in + current frame. + + delay = buffer (Int) containing delays for each window. + + buffer = history buffer (Int16) containing the reconstructed time domain + signals of previous frames. + + buffer_offset = value (Int) that indicates the location of the first + element in the LTP circular buffer. (Either 0 or 1024) + + time_quant = filterbank buffer (Int32) This buffer is used by the + filterbank, but it's first 1024 elements are equivalent + to the last 1024 elements in the conventionally + implemented LTP buffer. Using this buffer directly avoids + costly duplication of memory. + + predicted_samples = buffer (Int32) with length of 2048 to hold + predicted time domain signals. + + buffer_index = index into buffer where the first sample of data from + the frame (t-2) (two frames ago) resides. (Int) + + frame_length = length of one frame, type of Int. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + Amount of shifting needed to grab the top 16 MSB from teh predicted buffer + + Pointers and Buffers Modified: + predicted_samples contents are the newly calculated predicted time + domain signals + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Long term prediction (LTP) is used to reduce the redundancy of a signal + between successive coding frames. This function performs prediction by + applying 1-tap IIR filtering to calculate the predicted time domain + signals of current frame from previous reconstructed frames stored in + time domain history buffer. + + The equation used for IIR filter is as following. + + y(n) = weight * x(n - delay) + + where y(n) ----- predicted time domain signals + x(n) ----- reconstructed time domain signals + weight ----- LTP coefficient + delay ----- optimal delay from 0 to 2047 + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3: Audio + Subpart 4.6.6 Long Term Prediction (LTP) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia in the course + of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7, + 14496-1, 2 and 3. This software module is an implementation of a part + of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2 + aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4 + Audio standards free license to this software module or modifications + thereof for use in hardware or software products claiming conformance + to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this + software module in hardware or software products are advised that this + use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications + thereof in an implementation. Copyright is not released for non MPEG-2 + aac/MPEG-4 Audio conforming products. The original developer retains + full right to use the code for the developer's own purpose, assign or + donate the code to a third party and to inhibit third party from using + the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This + copyright notice must be included in all copies or derivative works. + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pPredicted_samples = &predicted_samples[0]; + + weight = codebook[weight_index]; + + IF (win_seq != EIGHT_SHORT_SEQUENCE) + THEN + + block_length = frame_length << 1; + + lag = delay[0]; + + j = block_length - lag; + + IF (lag < frame_length) + THEN + + num_samples = frame_length + lag; + + ELSE + + num_samples = block_length; + + ENDIF + + pBuffer = &buffer[j]; + + FOR (i = num_samples; i>0; i--) + + *pPredicted_samples = weight * (*pBuffer); + pPredicted_samples = pPredicted_samples + 1; + pBuffer = pBuffer + 1; + + ENDFOR + + FOR (i = block_length - num_samples; i>0; i--) + + *pPredicted_samples = 0; + pPredicted_samples = pPredicted_samples + 1; + + ENDFOR + + ELSE + + FOR (wnd = 0; wnd < short_window_num; wnd++) + + IF (win_prediction_used[wnd] != FALSE) + THEN + + delay[wnd] = delay[0] + ltp_short_lag[wnd]; + + lag = delay[wnd]; + + j = wnd*short_block_length - lag; + + IF (lag < short_frame_length) + THEN + + num_samples = short_frame_length + lag; + + ELSE + + num_samples = short_block_length; + + ENDIF + + pBuffer = &buffer[j]; + + FOR (i = num_samples; i>0; i--) + + *pPredicted_samples = weight * (*pBuffer); + pPredicted_samples = pPredicted_samples + 1; + pBuffer = pBuffer + 1; + + ENDFOR + + FOR (i = short_block_length - num_samples; i>0; i--) + + *pPredicted_samples = 0; + pPredicted_samples = pPredicted_samples + 1; + + ENDFOR + + ELSE + + CALL pv_memset( + pPredicted_samples, + 0, + sizeof(*pPredicted_samples)*short_block_length); + MODIFYING (predicted_samples[]); + + pPredicted_samples = pPredicted_samples + short_block_length; + + ENDIF [ IF (win_prediction_used[wnd] != FALSE) ] + + ENDFOR [ FOR (wnd=0; wnd 0) + { + pBuffer = &(buffer[ltp_buffer_index + buffer_offset]); + + for (k = jump_point; k > 0; k--) + { + /* Q15 = Q15 * Q0 */ + test = (Int32) weight * (*(pBuffer++)); + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + } + + num_samples -= jump_point; + + ltp_buffer_index += jump_point; + } + + /* + * This section of the code handles the t == -1 + * buffer, which corresponds to 1024 <= ltp_buffer_index < 2048 + * + * BUFFER t == -1 + * + * [1024][][][][][][][][][][][...][][][][][][][][][][][][2047] + * + */ + + jump_point = 2 * frame_length - ltp_buffer_index; + + pBuffer = &(buffer[ltp_buffer_index - buffer_offset]); + + if (num_samples < jump_point) + { + jump_point = num_samples; + } + + for (k = jump_point; k > 0; k--) + { + /* Q15 = Q15 * Q0 */ + test = (Int32) weight * (*(pBuffer++)); + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + } + + num_samples -= jump_point; + + ltp_buffer_index += jump_point; + + /* + * This section of the code handles the t == 0 + * buffer, which corresponds to 2048 <= ltp_buffer_index < 3072 + * + * BUFFER t == 0 + * + * [2048][][][][][][][][][][][...][][][][][][][][][][][][3071] + * + */ + for (k = num_samples; k > 0; k--) + { + + datum = *(pTimeQuant++) >> SCALING; + + /* + * Limit the values in the 32-bit filterbank's buffer to + * 16-bit resolution. + * + * Value's greater than 32767 or less than -32768 are saturated + * to 32767 and -32768, respectively. + */ + + test = (Int32)datum * weight; + *(pPredicted_samples++) = test; + max |= (test >> 31) ^ test; + + } + + /* Set any remaining samples in the block to 0. */ + + pv_memset( + pPredicted_samples, + 0, + block_length*sizeof(*pPredicted_samples)); + + } /* if (win_seq != EIGHT_SHORT_SEQUENCE) */ + + + /*****************************************/ + /* LTP decoding process for short window */ + /*****************************************/ + + /* + * For short window LTP, since there is no "ltp_short_lag" + * information being passed, the following code for short + * window LTP will be applied in the future when those + * information are available. + */ + + /* + *---------------------------------------------------------------------------- + * else + * { + * for (wnd = 0; wnd < short_window_num; wnd++) + * { + * if (win_prediction_used[wnd] != FALSE) + * { + * delay[wnd] = delay[0] + ltp_short_lag[wnd]; + * + * lag = delay[wnd]; + * + * j = wnd*short_block_length - lag; + * + * if (lag < short_frame_length) + * { + * num_samples = short_frame_length + lag; + * } + * else + * { + * num_samples = short_block_length; + * } + * + * pBuffer = &buffer[j]; + * + * for(i = num_samples; i>0; i--) + * { + * *(pPredicted_samples++) = weight * (*(pBuffer++)); + * } + * + * for(i = short_block_length - num_samples; i>0; i--) + * { + * *(pPredicted_samples++) = 0; + * } + * } + * else + * { + * pv_memset( + * pPredicted_samples, + * 0, + * sizeof(*pPredicted_samples)*short_block_length); + * + * pPredicted_samples += short_block_length; + * } + * } + * } + *---------------------------------------------------------------------------- + */ + + shift = 16 - pv_normalize(max); + + if (shift < 0) + { + shift = 0; + } + + /*---------------------------------------------------------------------------- + ; Return nothing or data or data pointer + ----------------------------------------------------------------------------*/ + return (shift); +} /* long_term_prediction */ + + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.h new file mode 100644 index 00000000..2c039b9a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_prediction.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_prediction.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function prototype declaration for long_term_prediction(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef LONG_TERM_PREDICTION_H +#define LONG_TERM_PREDICTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_sequence.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define LTP_Q_FORMAT (15) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + Int long_term_prediction( + WINDOW_SEQUENCE win_seq, + const Int weight_index, + const Int delay[], + const Int16 buffer[], + const Int buffer_offset, + const Int32 time_quant[], + Int32 predicted_samples[], /* Q15 */ + const Int frame_length); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_synthesis.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_synthesis.c new file mode 100644 index 00000000..cdf05324 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/long_term_synthesis.c @@ -0,0 +1,1080 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: long_term_synthesis.cpp + + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + win_seq = type of window sequence (WINDOW_SEQUENCE). + sfb_per_win = number of scalefactor bands for each window, 1024 for + long window, 128 for short window, type of Int. + win_sfb_top = buffer (Int16) containing the top coefficient per + scalefactor band for each window. + win_prediction_used = buffer (Int) containing the prediction flag + information for short windows. Each item in the + buffer toggles prediction on(1)/off(0) for each + window separately. + sfb_prediction_used = buffer (Int) containing the prediction flag + information for scalefactor band(sfb). Each item + toggle prediction on(1)/off(0) on each scalefactor + band of every window. + current_frame = channel buffer (Int32) containing the dequantized + spectral coefficients or errors of current frame. + q_format = buffer (Int) containing Q format for each scalefactor band of + input current_frame. + predicted_spectral = buffer (Int32) containing predicted spectral + components of current frame. + pred_q_format = Q format (Int) for predicted spectral components of + current frame. + coef_per_win = number of coefficients per window for short windows. + type of Int. + short_window_num = number of short windows, type of Int. + reconstruct_sfb_num = number of scalefactor bands used for reconstruction + for short windows, type of Int. + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + current_frame contents are the dequantized spectrum with a prediction + vector added when prediction is turned on. + + q_format contents are updated with the new Q format (Int) for each + scalefactor band of output current_frame buffer. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function performs long term synthesis using transmitted spectral + coeffients or errors and predicted spectral components. + + Long term synthesis is part of long term prediction (LTP) which is used to + reduce the redundancy of a signal between successive coding frames. The + functionality of long term synthesis is to reconstruct the frequency domain + spectral by adding the predicted spectral components and the transmitted + spectral error when prediction is turned on. + +------------------------------------------------------------------------------ + REQUIREMENTS + + None + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3: Audio + Subpart 4.6.6 Long Term Prediction (LTP) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia in the course + of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7, + 14496-1, 2 and 3. This software module is an implementation of a part + of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2 + aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4 + Audio standards free license to this software module or modifications + thereof for use in hardware or software products claiming conformance + to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this + software module in hardware or software products are advised that this + use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications + thereof in an implementation. Copyright is not released for non MPEG-2 + aac/MPEG-4 Audio conforming products. The original developer retains + full right to use the code for the developer's own purpose, assign or + donate the code to a third party and to inhibit third party from using + the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This + copyright notice must be included in all copies or derivative works. + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pPredicted_spectral = &predicted_spectral[0]; + pPredicted_spectral_start = pPredicted_spectral; + pSfb_prediction_used = &sfb_prediction_used[0]; + + IF (win_seq != EIGHT_SHORT_SEQUENCE) + THEN + + sfb_offset = 0; + + pWinSfbTop = &pWin_sfb_top[0]; + + pQ_format = &q_format[0]; + + FOR (i = sfb_per_frame; i>0; i--) + + IF (*(pSfb_prediction_used++) != FALSE) + THEN + + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = ¤t_frame[sfb_offset]; + + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + max = 0; + + pPredicted_spectral = pPredicted_offset; + + FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--) + + tmpInt32 = *(pPredicted_spectral++); + + IF (tmpInt32 < 0) + THEN + + tmpInt32 = -tmpInt32; + + ENDIF + + max |= tmpInt32; + + ENDFOR + + tmpInt = 0; + + IF (max != 0) + THEN + + WHILE (max < 0x40000000L) + + max <<= 1; + tmpInt++; + + ENDWHILE + + pPredicted_spectral = pPredicted_offset; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + + ENDFOR + + adjusted_pred_q = pred_q_format + tmpInt; + + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + IF ((shift_factor >= 0) && (shift_factor < 31)) + THEN + + shift_factor = shift_factor + 1; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + + ENDFOR + + *(pQ_format) = adjusted_pred_q - 1; + + ELSEIF (shift_factor >= 31) + THEN + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + + ENDFOR + + *(pQ_format) = adjusted_pred_q; + + ELSEIF ((shift_factor < 0) && (shift_factor > -31)) + THEN + + shift_factor = 1 - shift_factor; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + + ENDFOR + + *(pQ_format) = *(pQ_format) - 1; + + ENDIF + + ENDIF + + ENDIF [ IF (*(pSfb_prediction_used++) != FALSE) ] + + sfb_offset = *pWinSfbTop; + pWinSfbTop = pWinSfbTop + 1; + pQ_format = pQ_format + 1; + + ENDFOR [ FOR (i = sfb_per_frame; i>0; i--) ] + + ELSE + + pCurrent_frame_start = ¤t_frame[0]; + + pQ_format_start = &q_format[0]; + + num_sfb = sfb_per_win[0]; + + FOR (wnd=0; wnd 0; i--) + + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = pCurrent_frame_start + sfb_offset; + + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + max = 0; + + pPredicted_spectral = pPredicted_offset; + + FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--) + + tmpInt32 = *(pPredicted_spectral++); + + IF (tmpInt32 < 0) + THEN + + tmpInt32 = -tmpInt32; + + ENDIF + + max |= tmpInt32; + + ENDFOR + + tmpInt = 0; + + IF (max != 0) + THEN + + WHILE (max < 0x40000000L) + + max <<= 1; + tmpInt++; + + ENDWHILE + + + pPredicted_spectral = pPredicted_offset; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + *(pPredicted_spectral++) <<= tmpInt; + + ENDFOR + + adjusted_pred_q = pred_q_format + tmpInt; + + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + IF ((shift_factor >= 0) && (shift_factor < 31)) + THEN + + shift_factor = shift_factor + 1; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + *(pCurrent_frame++) = + (*pCurrent_frame>>shift_factor) + + (*(pPredicted_spectral++)>>1); + + ENDFOR + + *(pQ_format) = adjusted_pred_q - 1; + + ELSEIF (shift_factor >= 31) + THEN + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + *(pCurrent_frame++) = *(pPredicted_spectral++); + + ENDFOR + + *(pQ_format) = adjusted_pred_q; + + ELSEIF ((shift_factor < 0) && (shift_factor > -31)) + THEN + + shift_factor = 1 - shift_factor; + + FOR (j = quarter_sfb_width; j>0 ; j--) + + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + *(pCurrent_frame++) = (*pCurrent_frame>>1) + + (*(pPredicted_spectral++)>>shift_factor); + + ENDFOR + + *(pQ_format) = *(pQ_format) - 1; + + ENDIF + + ENDIF + + sfb_offset = *pWinSfbTop; + pWinSfbTop = pWinSfbTop + 1; + pQ_format = pQ_format + 1; + + ENDFOR [ FOR (i = reconstruct_sfb_num; i > 0; i--) ] + + ENDIF [ IF (win_prediction_used[wnd] != FALSE) ] + + pPredicted_spectral_start = pPredicted_spectral_start + num_sfb; + pCurrent_frame_start = pCurrent_frame_start + num_sfb; + wnd_offset = wnd_offset + num_sfb; + pQ_format_start = pQ_format_start + num_sfb; + + ENDFOR [ FOR (wnd=0; wnd 0; i--) + { + /* Check prediction flag for each scalefactor band. */ + if (*(pSfb_prediction_used++) != FALSE) + { + /* + * Prediction is on. Do reconstruction routine. + * Reconstruct spectral component of current + * frame by adding the predicted spectral + * components and the quantized prediction + * errors that reconstructed from transmitted + * data when prediction is turned on. + */ + + /* Set pointers to the offset of scalefactor bands */ + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = ¤t_frame[sfb_offset]; + + /* + * (*pWinSfbTop - sfb_offset) is number of coefficients + * of the scalefactor band. + * ">>2" is used to set up for later unrolling the loop. + */ + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + /* + * Adjust pred_q_format and predicted_spectral() to + * maximum resolution. + */ + max = 0; + + pPredicted_spectral = pPredicted_offset; + + /* Find the maximum absolute value */ + for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--) + { + tmpInt32 = *(pPredicted_spectral++); + + /* + * Note: overflow is protected here even though + * tmpInt32 = 0x80000000 is very rare case. + * + * if (tmpInt32 == LONG_MIN) + * { + * tmpInt32 = LONG_MAX; + * } + * if (tmpInt32 < 0) + * { + * tmpInt32 = -tmpInt32; + * } + */ + + max |= tmpInt32 ^(tmpInt32 >> 31); + } + + /* + * IF the LTP data is all zeros + * (max == 0) - do nothing for this sfb. + */ + + if (max != 0) + { + /* Find the number of bits to reach the max resolution */ + tmpInt = 0; + + while (max < 0x40000000L) + { + max <<= 1; + tmpInt++; + } + + /* + * The following codes are combinded into shift factor + * adjusting and reconstruction section. + * + * pPredicted_spectral = pPredicted_offset; + * for(j = quarter_sfb_width; j>0 ; j--) + * { + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * } + * + */ + + /* Adjust Q format for predicted_spectral() */ + adjusted_pred_q = pred_q_format + tmpInt; + + /* + * Adjust Q format to prevent overflow that may occur during + * frequency domain reconstruction. + * + */ + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + if ((shift_factor >= 0) && (shift_factor < 31)) + { + shift_factor = shift_factor + 1; + pred_shift = tmpInt - 1; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + } + } + else + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + } + } + + /* Updated new Q format for current scalefactor band */ + *(pQ_format) = adjusted_pred_q - 1; + } + else if (shift_factor >= 31) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + } + + /* Updated new Q format for current scalefactor band */ + *(pQ_format) = adjusted_pred_q ; + } + else if ((shift_factor < 0) && (shift_factor > -31)) + { + shift_factor = 1 - shift_factor; + pred_shift = tmpInt - shift_factor; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + } + } + else + { + pred_shift = -pred_shift; + + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + } + } + + /* + * Updated new Q format for current scalefactor band + * + * This is NOT a pointer decrement + */ + (*pQ_format)--; + } + + } /* if (max != 0) */ + + /* + * For case (shift_factor <= -31), *pCurrent_frame and + * *pQ_format do not need to be updated. + */ + + } /* if (*(pSfb_prediction_used++) != FALSE) */ + + /* Updated to next scalefactor band. */ + sfb_offset = *(pWinSfbTop++); + + /* Updated pointer to next scalefactor band's Q-format */ + pQ_format++; + + } /* for (i = sfb_per_frame; i>0; i--) */ + + } /* if (win_seq!=EIGHT_SHORT_SEQUENCE) */ + + /**********************************/ + /* LTP synthesis for short window */ + /**********************************/ + else + { + /******************************************************/ + /*Reconstruction of current frequency domain spectrum */ + /******************************************************/ + pCurrent_frame_start = ¤t_frame[0]; + + pQ_format_start = &q_format[0]; + + num_sfb = sfb_per_win; + + /* Reconstruction is processed on window basis */ + for (wnd = 0; wnd < short_window_num; wnd++) + { + pWinSfbTop = &win_sfb_top[0]; + + pQ_format = pQ_format_start; + + /* Check if prediction flag is on for each window */ + if (win_prediction_used[wnd] != FALSE) + { + /* Initialize scalefactor band offset */ + sfb_offset = 0; + + /* + * Reconstruction is processed on scalefactor band basis. + * 1. When prediction is turned on, all the predicted + * spectral components will be used for reconstruction. + * 2. When prediction is turned off, reconstruction is + * not needed. Spectral components of current frame + * will directly come from the transmitted data. + */ + + /* + * According to ISO/IEC 14496-3 pg.91 + * Only the spectral components in first eight scalefactor + * bands are added to the quantized prediction error. + */ + for (i = reconstruct_sfb_num; i > 0; i--) + { + /* Set pointer to the offset of scalefactor bands */ + pPredicted_offset = pPredicted_spectral_start + + sfb_offset; + pCurrent_frame = pCurrent_frame_start + sfb_offset; + + /* + * Prediction is on. Do reconstruction routine. + * Reconstruct spectral component of + * current frame by adding the predicted + * spectral components and the quantized + * prediction errors that reconstructed + * from transmitted data when prediction + * is turned on. + */ + + /* + * (*pWinSfbTop - sfb_offset) is number of coefficients + * of the scalefactor band. + * ">>2" is used to set up for later unrolling the loop. + */ + quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2; + + /* + * Adjust pred_q_format and predicted_spectral() to + * maximum resolution. + */ + max = 0; + pPredicted_spectral = pPredicted_offset; + + /* Find the maximum absolute value */ + for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--) + { + tmpInt32 = *(pPredicted_spectral++); + + + /* + * Note: overflow is protected here even though + * tmpInt32 = 0x80000000 is very rare case. + * + * if (tmpInt32 == LONG_MIN) + * { + * tmpInt32 = LONG_MAX; + * } + * if (tmpInt32 < 0) + * { + * tmpInt32 = -tmpInt32; + * } + */ + + max |= tmpInt32 ^(tmpInt32 >> 31); + } + + if (max != 0) + { + /* Find the number of bits to reach + * the max resolution + */ + tmpInt = 0; + + while (max < 0x40000000L) + { + max <<= 1; + tmpInt++; + } + /* + * The following codes are combined into shift factor + * adjusting and reconstruction section. + * + * pPredicted_spectral = pPredicted_offset; + * for(j = quarter_sfb_width; j>0 ; j--) + * { + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * *(pPredicted_spectral++) <<= tmpInt; + * } + * + */ + + /* Adjust Q format for predicted_spectral() */ + adjusted_pred_q = pred_q_format + tmpInt; + + /* + * Adjust Q format to prevent overflow that may occur + * during frequency domain reconstruction. + */ + pPredicted_spectral = pPredicted_offset; + + shift_factor = *(pQ_format) - adjusted_pred_q; + + if ((shift_factor >= 0) && (shift_factor < 31)) + { + shift_factor = shift_factor + 1; + + pred_shift = tmpInt - 1; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + + } + } + else + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + temp = *pCurrent_frame >> shift_factor; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> 1); + } + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = adjusted_pred_q - 1; + } + else if (shift_factor >= 31) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + *(pCurrent_frame++) = + *(pPredicted_spectral++) << tmpInt; + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = adjusted_pred_q; + } + else if ((shift_factor < 0) && (shift_factor > -31)) + { + shift_factor = 1 - shift_factor; + + pred_shift = tmpInt - shift_factor; + + if (pred_shift >= 0) + { + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) << pred_shift); + + } + } + else + { + pred_shift = -pred_shift; + + for (j = quarter_sfb_width; j > 0 ; j--) + { + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + temp = *pCurrent_frame >> 1; + *(pCurrent_frame++) = temp + + (*(pPredicted_spectral++) >> pred_shift); + } + } + + /* Updated new Q format for current scalefactor band*/ + *(pQ_format) = *(pQ_format) - 1; + } + + /* + * For case (shift_factor <= -31), *pCurrent_frame and + * *pQ_format do not need to be updated. + */ + + } /* if (max != 0) */ + + /* Updated to next scalefactor band. */ + sfb_offset = *(pWinSfbTop++); + + /* Updated pointer to next scalefactor band's Q-format */ + pQ_format++; + + } /* for (i = reconstruct_sfb_num; i > 0; i--) */ + + } /* if (win_prediction_used[wnd] != FALSE) */ + + /* Updated to next window */ + pPredicted_spectral_start += coef_per_win; + pCurrent_frame_start += coef_per_win; + pQ_format_start += num_sfb; + + } /* for (wnd=0; wndweight_index - updated with index into weight table for LTP. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes the bitstream elements for long term prediction + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by Nokia + in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard + ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an implementation + of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the + MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the + MPEG-2aac/MPEG-4 Audio standards free license to this software module or + modifications thereof for use in hardware or software products claiming + conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to + use this software module in hardware or software products are advised that + this use may infringe existing patents. The original developer of this + software module, the subsequent editors and their companies, and ISO/IEC + have no liability for use of this software module or modifications thereof + in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 + Audio conforming products. The original developer retains full right to use + the code for the developer's own purpose, assign or donate the code to a + third party and to inhibit third party from using the code for non + MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice + must be included in all copies or derivative works." + Copyright (c)1997. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pDelay[0] = (Int) getbits( + LEN_LTP_LAG, + pInputStream); + + temp_reg = (Int) getbits( + LEN_LTP_COEF, + pInputStream); + + pLt_pred->weight = codebook[temp_reg]; + + last_band = max_sfb; + + IF (win_type != EIGHT_SHORT_SEQUENCE) + + IF (last_band > MAX_LT_PRED_LONG_SFB) + + last_band = MAX_LT_PRED_LONG_SFB; + + ENDIF + + FOR (m = last_band; m > 0; m--) + + *(pSfbPredictionUsed++) = (Int) getbits( + LEN_LTP_LONG_USED, + pInputStream); + ENDFOR + + FOR (m = (max_sfb - last_band); m > 0; m--) + + *(pSfbPredictionUsed++) = 0; + + ENDFOR + + ELSE + + IF (last_band > MAX_LT_PRED_SHORT_SFB) + + last_band = MAX_LT_PRED_SHORT_SFB; + + ENDIF + + prev_subblock = pDelay[0]; + + pWinPredictionUsed++; + + pTempPtr = &pSfbPredictionUsed[0]; + + FOR (m = NUM_SHORT_WINDOWS; m > 0;) + + m--; + temp_reg = (Int) getbits( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock; + + FOR (k = last_band; k > 0; k--) + { + *(pTempPtr++) = 1; + } + break; + ELSE + { + pDelay++; + pTempPtr += last_band; + } + + ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;) + + prev_subblock += LTP_LAG_OFFSET; + + FOR (; m > 0; m--) + + temp_reg = (Int) getbits ( + LEN_LTP_SHORT_USED, + pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + IF (temp_reg != FALSE) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG_PRESENT, + pInputStream); + IF (temp_reg != 0) + + temp_reg = (Int) getbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + + ELSE + + *(pDelay++) = prev_subblock - LTP_LAG_OFFSET; + + ENDIF + + FOR (k = last_band; k > 0; k--) + *(pTempPtr++) = 1; + ENDFOR + + ELSE + + pDelay++; + pTempPtr += last_band; + + ENDIF + + ENDFOR (; m > 0; m--) + + ENDIF (win_type != EIGHT_SHORT_SEQUENCE) + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "lt_decode.h" +#include "ltp_common_internal.h" +#include "window_block_fxp.h" +#include "e_window_sequence.h" +#include "s_lt_pred_status.h" +#include "s_bits.h" +#include "ibstream.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void lt_decode( + const WINDOW_SEQUENCE win_type, + BITS *pInputStream, + const Int max_sfb, + LT_PRED_STATUS *pLt_pred) +{ + Int wnd_num; + Int k; + Int last_band; + Int prev_subblock; + Int prev_subblock_nonzero; + Int temp_reg; + + Bool *pWinPredictionUsed = pLt_pred->win_prediction_used; + Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used; + Int *pTempPtr; + Int *pDelay = pLt_pred->delay; + + pDelay[0] = (Int) get17_n_lessbits( + LEN_LTP_LAG, /* 11 bits */ + pInputStream); + + pLt_pred->weight_index = (Int) get9_n_lessbits( + LEN_LTP_COEF, /* 3 bits */ + pInputStream); + + last_band = max_sfb; + + if (win_type != EIGHT_SHORT_SEQUENCE) + { + + /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */ + if (last_band > MAX_LT_PRED_LONG_SFB) + { + last_band = MAX_LT_PRED_LONG_SFB; + } + + for (k = last_band; k > 0; k--) + { + *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream); + } + + /* + * This is not a call to memset, because + * (max_sfb - last_band) should typically be a small value. + */ + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pSfbPredictionUsed++) = FALSE; + } + } + else /* (win_type == EIGHT_SHORT_SEQUENCE) */ + { + /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */ + + if (last_band > MAX_LT_PRED_SHORT_SFB) + { + last_band = MAX_LT_PRED_SHORT_SFB; + } + + /* + * The following two coding constructs are equivalent... + * + * first_time == 1 + * for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--) + * { + * if (condition) + * { + * if (first_time == 1) + * { + * CODE SECTION A + * first_time = 0; + * } + * else + * { + * CODE SECTION B + * } + * } + * } + * + * -----------------------------------EQUIVALENT TO------------ + * + * wnd_num=NUM_SHORT_WINDOWS; + * + * do + * { + * wnd_num--; + * if (condition) + * { + * CODE SECTION A + * break; + * } + * } while( wnd_num > 0) + * + * while (wnd_num > 0) + * { + * if (condition) + * { + * CODE SECTION B + * } + * wnd_num--; + * } + * + */ + + prev_subblock = pDelay[0]; + + pTempPtr = &pSfbPredictionUsed[0]; + + wnd_num = NUM_SHORT_WINDOWS; + + prev_subblock_nonzero = prev_subblock; + prev_subblock += LTP_LAG_OFFSET; + + do + { + /* + * Place decrement of wnd_num here, to insure + * that the decrement occurs before the + * break out of the do-while loop. + */ + wnd_num--; + + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + *(pDelay++) = prev_subblock_nonzero; + + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + break; + + } /* if(pWinPredictionUsed) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + } + while (wnd_num > 0); + + /* + * This while loop picks up where the previous one left off. + * Notice that the code functions differently inside the loop + */ + + while (wnd_num > 0) + { + temp_reg = (Int) get1bits(pInputStream); + + *(pWinPredictionUsed++) = temp_reg; + + if (temp_reg != FALSE) + { + temp_reg = (Int) get1bits(pInputStream); + if (temp_reg != 0) + { + temp_reg = (Int) get9_n_lessbits( + LEN_LTP_SHORT_LAG, + pInputStream); + + *(pDelay++) = prev_subblock - temp_reg; + } + else + { + *(pDelay++) = prev_subblock_nonzero; + } + for (k = last_band; k > 0; k--) + { + *(pTempPtr++) = TRUE; + } + for (k = (max_sfb - last_band); k > 0; k--) + { + *(pTempPtr++) = FALSE; + } + + } /* if (temp_reg) */ + else + { + pDelay++; + pTempPtr += max_sfb; + } + + wnd_num--; + + } /* while(wnd_num) */ + + } /* else (win_type == EIGHT_SHORT_SEQUENCE) */ + +} /* lt_decode */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_decode.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_decode.h new file mode 100644 index 00000000..bf956627 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_decode.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: lt_decode.h + + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the global function declaration for lt_decode + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef LT_DECODE_H +#define LT_DECODE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_sequence.h" +#include "s_lt_pred_status.h" +#include "s_bits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void lt_decode( + const WINDOW_SEQUENCE win_type, + BITS *pInputStream, + const Int max_sfb, + LT_PRED_STATUS *pLt_pred); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_prediction.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_prediction.h new file mode 100644 index 00000000..e52a1e85 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/lt_prediction.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/************************************************************************** + +This software module was originally developed by +Nokia in the course of development of the MPEG-2 AAC/MPEG-4 +Audio standard ISO/IEC13818-7, 14496-1, 2 and 3. +This software module is an implementation of a part +of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the +MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the +MPEG-2aac/MPEG-4 Audio standards free license to this software module +or modifications thereof for use in hardware or software products +claiming conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those +intending to use this software module in hardware or software products +are advised that this use may infringe existing patents. The original +developer of this software module, the subsequent +editors and their companies, and ISO/IEC have no liability for use of +this software module or modifications thereof in an +implementation. Copyright is not released for non MPEG-2 aac/MPEG-4 +Audio conforming products. The original developer retains full right to +use the code for the developer's own purpose, assign or donate the code to a +third party and to inhibit third party from using the code for non +MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice +must be included in all copies or derivative works. +Copyright (c)1997. + +***************************************************************************/ + +#ifndef _LT_PREDICTION_H +#define _LT_PREDICTION_H + +#include "block.h" +#include "ltp_common.h" +#include "ibstream.h" +#include "lt_decode.h" +#include "s_frameinfo.h" +#include "window_block.h" + +void init_lt_pred(LT_PRED_STATUS * lt_status); + +void lt_predict( + Int object, + FrameInfo *pFrameInfo, + WINDOW_SEQUENCE win_seq, + Wnd_Shape *pWin_shape, + LT_PRED_STATUS *pLt_status, + Real *pPredicted_samples, + Real *pOverlap_buffer, + Real *pCurrent_frame_copy, + Real current_frame[]); + +short double_to_int(double sig_in); + +#endif /* not defined _LT_PREDICTION_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ltp_common_internal.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ltp_common_internal.h new file mode 100644 index 00000000..d76ac756 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ltp_common_internal.h @@ -0,0 +1,115 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/************************************************************************** + +This software module was originally developed by + +Mikko Suonio (Nokia) + +in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard +ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an +implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools +as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives +users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this +software module or modifications thereof for use in hardware or +software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio +standards. Those intending to use this software module in hardware or +software products are advised that this use may infringe existing +patents. The original developer of this software module and his/her +company, the subsequent editors and their companies, and ISO/IEC have +no liability for use of this software module or modifications thereof +in an implementation. Copyright is not released for non MPEG-2 +NBC/MPEG-4 Audio conforming products. The original developer retains +full right to use the code for his/her own purpose, assign or donate +the code to a third party and to inhibit third party from using the +code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This +copyright notice must be included in all copies or derivative works. + +Copyright (c) 1997. + +***************************************************************************/ + +#ifndef _LTP_COMMON_INTERNAL_H +#define _LTP_COMMON_INTERNAL_H + + +/* + Purpose: Number of LTP coefficients. */ +#define LPC 1 + +/* + Purpose: Maximum LTP lag. */ +#define DELAY 2048 + +/* + Purpose: Length of the bitstream element ltp_data_present. */ +#define LEN_LTP_DATA_PRESENT 1 + +/* + Purpose: Length of the bitstream element ltp_lag. */ +#define LEN_LTP_LAG 11 + +/* + Purpose: Length of the bitstream element ltp_coef. */ +#define LEN_LTP_COEF 3 + +/* + Purpose: Length of the bitstream element ltp_short_used. */ +#define LEN_LTP_SHORT_USED 1 + +/* + Purpose: Length of the bitstream element ltp_short_lag_present. */ +#define LEN_LTP_SHORT_LAG_PRESENT 1 + +/* + Purpose: Length of the bitstream element ltp_short_lag. */ +#define LEN_LTP_SHORT_LAG 5 + +/* + Purpose: Offset of the lags written in the bitstream. */ +#define LTP_LAG_OFFSET 16 + +/* + Purpose: Length of the bitstream element ltp_long_used. */ +#define LEN_LTP_LONG_USED 1 + +/* + Purpose: Upper limit for the number of scalefactor bands + which can use lt prediction with long windows. + Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */ +#define MAX_LT_PRED_LONG_SFB 40 + +/* + Purpose: Upper limit for the number of scalefactor bands + which can use lt prediction with short windows. + Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */ +#define MAX_LT_PRED_SHORT_SFB 13 + +/* + Purpose: Buffer offset to maintain block alignment. + Explanation: This is only used for a short window sequence. */ +#define SHORT_SQ_OFFSET (BLOCK_LEN_LONG-(BLOCK_LEN_SHORT*4+BLOCK_LEN_SHORT/2)) + +/* + Purpose: Number of codes for LTP weight. */ +#define CODESIZE 8 + +/* number of scalefactor bands used for reconstruction for short windows */ +#define NUM_RECONSTRUCTED_SFB (8) + +#endif /* _LTP_COMMON_INTERNAL_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.c new file mode 100644 index 00000000..d94700a5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.c @@ -0,0 +1,428 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_fxp.cpp + Funtions: fft_rx2 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + data_quant = Input vector, with quantized Q15 spectral lines: + type Int32 + + Q_FFTarray = Scratch memory used for in-place IFFT calculation, + min size required 1024, type Int32 + + n = Length of input vector "data_quant". Currently 256 or 2048. + type const Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + shift = shift factor to reflect scaling introduced by FFT and mdct_fxp, + + Pointers and Buffers Modified: + calculation are done in-place and returned in "data_quant" + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The MDCT is a linear orthogonal lapped transform, based on the idea of + time domain aliasing cancellation (TDAC). + MDCT is critically sampled, which means that though it is 50% overlapped, + a sequence data after MDCT has the same number of coefficients as samples + before the transform (after overlap-and-add). This means, that a single + block of MDCT data does not correspond to the original block on which the + MDCT was performed. When subsequent blocks of data are added (still using + 50% overlap), the errors introduced by the transform cancels out. + Thanks to the overlapping feature, the MDCT is very useful for + quantization. It effectively removes the otherwise easily detectable + blocking artifact between transform blocks. + N = length of input vector X + X = vector of length N/2, will hold fixed point DCT + k = 0:1:N-1 + + N-1 + X(m) = 2 SUM x(k)*cos(pi/(2*N)*(2*k+1+N/2)*(2*m+1)) + k=0 + + + The window that completes the TDAC is applied before calling this function. + The MDCT can be calculated using an FFT, for this, the MDCT needs to be + rewritten as an odd-time odd-frequency discrete Fourier transform. Thus, + the MDCT can be calculated using only one n/4 point FFT and some pre and + post-rotation of the sample points. + + Computation of the MDCT implies computing + + x = ( y - y ) + j( y + y ) + n 2n N/2-1-2n N-1-2n N/2+2n + + using the Fast discrete cosine transform as described in [2] + + where x(n) is an input with N points + + x(n) ---------------------------- + | + | + Pre-rotation by exp(j(2pi/N)(n+1/8)) + | + | + N/4- point FFT + | + | + Post-rotation by exp(j(2pi/N)(k+1/8)) + | + | + ------------- DCT + + By considering the N/2 overlap, a relation between successive input blocks + is found: + + x (2n) = x (N/2 + 2n) + m+1 m +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point MDCT with an average + quantization error less than 1 %. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Analysis/Synthesis Filter Bank design based on time domain + aliasing cancellation + Jhon Princen, et. al. + IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986 + Pg 1153 - 1161 + + [2] Regular FFT-related transform kernels for DCT/DST based + polyphase filterbanks + Rolf Gluth + Proc. ICASSP 1991, pg. 2205 - 2208 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + Cx, Cy are complex number + + + exp = log2(n)-1 + + FOR ( k=0; k< n/4; k +=2) + + Cx = (data_quant[3n/4 + k] + data_quant[3n/4 - 1 - k]) + + j (data_quant[ n/4 + k] - data_quant[ n/4 - 1 - k]) + + Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8)) + + ENDFOR + + FOR ( k=n/4; k< n/2; k +=2) + + Cx = (data_quant[3n/4 - 1 - k] + data_quant[ - n/4 + k]) + + j (data_quant[5n/4 - 1 - k] - data_quant[ n/4 + k]) + + Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8)) + + ENDFOR + + CALL FFT( Q_FFTarray, n/4) + + MODIFYING( Q_FFTarray ) + + RETURNING( shift ) + + FOR ( k=0; k< n/2; k +=2) + + Cx = Q_FFTarray[ k] + j Q_FFTarray[ k+1] + + Cy = 2 * Cx * exp(-j(2pi/n)(k+1/8)) + + data_quant[ k ] = - Real(Cy) + data_quant[ n/2 - 1 - k ] = Imag(Cy) + data_quant[ n/2 + k ] = - Imag(Cy) + data_quant[ n - k ] = Real(Cy) + + ENDFOR + + MODIFIED data_quant[] + + RETURN (-shift-1) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "mdct_fxp.h" +#include "fft_rx4.h" +#include "mix_radix_fft.h" +#include "fwd_long_complex_rot.h" +#include "fwd_short_complex_rot.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define ERROR_IN_FRAME_SIZE 10 + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int mdct_fxp( + Int32 data_quant[], + Int32 Q_FFTarray[], + Int n) +{ + + Int32 temp_re; + Int32 temp_im; + + Int32 temp_re_32; + Int32 temp_im_32; + + Int16 cos_n; + Int16 sin_n; + Int32 exp_jw; + Int shift; + + + const Int32 *p_rotate; + + + Int32 *p_data_1; + Int32 *p_data_2; + Int32 *p_data_3; + Int32 *p_data_4; + + Int32 *p_Q_FFTarray; + + Int32 max1; + + Int k; + Int n_2 = n >> 1; + Int n_4 = n >> 2; + Int n_8 = n >> 3; + Int n_3_4 = 3 * n_4; + + switch (n) + { + case SHORT_WINDOW_TYPE: + p_rotate = (Int32 *)exp_rotation_N_256; + break; + + case LONG_WINDOW_TYPE: + p_rotate = (Int32 *)exp_rotation_N_2048; + break; + + default: + /* + * There is no defined behavior for a non supported frame + * size. By returning a fixed scaling factor, the input will + * scaled down and this will be heard as a low level noise + */ + return(ERROR_IN_FRAME_SIZE); + + } + + /*--- Reordering and Pre-rotation by exp(-j(2pi/N)(r+1/8)) */ + p_data_1 = &data_quant[n_3_4]; + p_data_2 = &data_quant[n_3_4 - 1]; + p_data_3 = &data_quant[n_4]; + p_data_4 = &data_quant[n_4 - 1]; + + p_Q_FFTarray = Q_FFTarray; + + max1 = 0; + + for (k = n_8; k > 0; k--) + { + /* + * scale down to ensure numbers are Q15 + * temp_re and temp_im are 32-bit but + * only the lower 16 bits are used + */ + + temp_re = (*(p_data_1++) + *(p_data_2--)) >> 1; + temp_im = (*(p_data_3++) - *(p_data_4--)) >> 1; + + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + cos_n = (Int16)(exp_jw >> 16); + sin_n = (Int16)(exp_jw & 0xFFFF); + + temp_re_32 = temp_re * cos_n + temp_im * sin_n; + temp_im_32 = temp_im * cos_n - temp_re * sin_n; + *(p_Q_FFTarray++) = temp_re_32; + *(p_Q_FFTarray++) = temp_im_32; + max1 |= (temp_re_32 >> 31) ^ temp_re_32; + max1 |= (temp_im_32 >> 31) ^ temp_im_32; + + + p_data_1++; + p_data_2--; + p_data_4--; + p_data_3++; + } + + + p_data_1 = &data_quant[n - 1]; + p_data_2 = &data_quant[n_2 - 1]; + p_data_3 = &data_quant[n_2]; + p_data_4 = data_quant; + + for (k = n_8; k > 0; k--) + { + /* + * scale down to ensure numbers are Q15 + */ + temp_re = (*(p_data_2--) - *(p_data_4++)) >> 1; + temp_im = (*(p_data_1--) + *(p_data_3++)) >> 1; + + p_data_2--; + p_data_1--; + p_data_4++; + p_data_3++; + + /* + * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8)) + */ + + exp_jw = *p_rotate++; + + cos_n = (Int16)(exp_jw >> 16); + sin_n = (Int16)(exp_jw & 0xFFFF); + + temp_re_32 = temp_re * cos_n + temp_im * sin_n; + temp_im_32 = temp_im * cos_n - temp_re * sin_n; + + *(p_Q_FFTarray++) = temp_re_32; + *(p_Q_FFTarray++) = temp_im_32; + max1 |= (temp_re_32 >> 31) ^ temp_re_32; + max1 |= (temp_im_32 >> 31) ^ temp_im_32; + + + } /* for(k) */ + + + + p_Q_FFTarray = Q_FFTarray; + + if (max1) + { + + if (n != SHORT_WINDOW_TYPE) + { + + shift = mix_radix_fft( + Q_FFTarray, + &max1); + + shift += fwd_long_complex_rot( + Q_FFTarray, + data_quant, + max1); + + } + else /* n_4 is 64 */ + { + + shift = fft_rx4_short( + Q_FFTarray, + &max1); + + shift += fwd_short_complex_rot( + Q_FFTarray, + data_quant, + max1); + } + + } + else + { + shift = -31; + } + + /* + * returns shift introduced by FFT and mdct_fxp, 12 accounts for + * regular downshift (14) and MDCT scale factor (-2) + * number are returned as 16 bits + */ + return (12 - shift); + +} /* mdct_fxp */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.h new file mode 100644 index 00000000..854523a6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_fxp.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function mdct_fxp() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MDCT_FXP_H +#define MDCT_FXP_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define LONG_WINDOW_TYPE 2048 +#define SHORT_WINDOW_TYPE 256 + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + extern const Int exp_rotation_N_256[128]; + extern const Int exp_rotation_N_2048[1024]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int mdct_fxp( + Int32 data_quant[], + Int32 Q_FFTarray[], + Int n); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* MDCT_FXP_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_tables_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_tables_fxp.c new file mode 100644 index 00000000..ac345217 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdct_tables_fxp.c @@ -0,0 +1,243 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdct_tables_fxp.cpp + Funtions: + +------------------------------------------------------------------------------ + MODULE DESCRIPTION + + MDCT rotation tables fixpoint tables + + For a table with N complex points: + + cos_n + j*sin_n == exp(j(2pi/N)(n+1/8)) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. Include conditional + ; compile variables also. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL VARIABLE DEFINITIONS + ; Variable declaration - defined here and used outside this module + ----------------------------------------------------------------------------*/ + + + /*---------------------------------------------------------------------------- + ; EXTERNAL FUNCTION REFERENCES + ; Declare functions defined elsewhere and referenced in this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + + + + extern const Int32 exp_rotation_N_256[64] = + { + + 0x5A820047, 0x5A7A0280, 0x5A6304B8, 0x5A3E06EF, + 0x5A0C0926, 0x59CB0B5B, 0x597D0D8E, 0x59210FBF, + 0x58B711EE, 0x5840141A, 0x57BB1643, 0x57281868, + 0x56881A8A, 0x55DB1CA8, 0x55201EC1, 0x545820D5, + 0x538322E5, 0x52A224EF, 0x51B326F3, 0x50B828F1, + 0x4FB12AE9, 0x4E9D2CDA, 0x4D7D2EC5, 0x4C5230A8, + 0x4B1A3284, 0x49D73458, 0x48883624, 0x472F37E7, + 0x45CA39A2, 0x445A3B54, 0x42E03CFD, 0x415C3E9C, + 0x3FCE4032, 0x3E3541BE, 0x3C944340, 0x3AE844B7, + 0x39344624, 0x37774786, 0x35B148DD, 0x33E44A29, + 0x320E4B69, 0x30304C9E, 0x2E4B4DC6, 0x2C5F4EE3, + 0x2A6C4FF4, 0x287250F8, 0x267251F0, 0x246D52DB, + 0x226153BA, 0x2051548B, 0x1E3B5550, 0x1C215607, + 0x1A0256B1, 0x17DF574E, 0x15B957DD, 0x138F585F, + 0x116358D3, 0x0F335939, 0x0D015992, 0x0ACE59DD, + 0x08985A1A, 0x06625A49, 0x042A5A6A, 0x01F25A7D + }; + + + + + + + extern const Int32 exp_rotation_N_2048[512] = + { + + 0x5A820009, 0x5A820050, 0x5A820097, 0x5A8100DE, + 0x5A810125, 0x5A80016C, 0x5A7E01B3, 0x5A7D01FA, + 0x5A7B0242, 0x5A790289, 0x5A7702D0, 0x5A750317, + 0x5A72035E, 0x5A7003A5, 0x5A6D03EC, 0x5A6A0433, + 0x5A66047A, 0x5A6304C1, 0x5A5F0508, 0x5A5B054F, + 0x5A560596, 0x5A5205DD, 0x5A4D0624, 0x5A48066A, + 0x5A4306B1, 0x5A3E06F8, 0x5A38073F, 0x5A320786, + 0x5A2C07CD, 0x5A260814, 0x5A20085A, 0x5A1908A1, + 0x5A1208E8, 0x5A0B092F, 0x5A040975, 0x59FC09BC, + 0x59F40A03, 0x59EC0A49, 0x59E40A90, 0x59DC0AD7, + 0x59D30B1D, 0x59CA0B64, 0x59C10BAA, 0x59B80BF1, + 0x59AE0C37, 0x59A50C7E, 0x599B0CC4, 0x59910D0A, + 0x59860D51, 0x597C0D97, 0x59710DDD, 0x59660E23, + 0x595B0E6A, 0x594F0EB0, 0x59440EF6, 0x59380F3C, + 0x592C0F82, 0x59200FC8, 0x5913100E, 0x59061054, + 0x58F9109A, 0x58EC10E0, 0x58DF1126, 0x58D1116B, + 0x58C411B1, 0x58B611F7, 0x58A7123C, 0x58991282, + 0x588A12C8, 0x587B130D, 0x586C1353, 0x585D1398, + 0x584E13DD, 0x583E1423, 0x582E1468, 0x581E14AD, + 0x580D14F2, 0x57FD1538, 0x57EC157D, 0x57DB15C2, + 0x57CA1607, 0x57B9164C, 0x57A71690, 0x579516D5, + 0x5783171A, 0x5771175F, 0x575E17A3, 0x574C17E8, + 0x5739182C, 0x57261871, 0x571218B5, 0x56FF18FA, + 0x56EB193E, 0x56D71982, 0x56C319C6, 0x56AF1A0A, + 0x569A1A4F, 0x56851A93, 0x56701AD6, 0x565B1B1A, + 0x56461B5E, 0x56301BA2, 0x561A1BE5, 0x56041C29, + 0x55EE1C6D, 0x55D81CB0, 0x55C11CF3, 0x55AA1D37, + 0x55931D7A, 0x557C1DBD, 0x55651E00, 0x554D1E43, + 0x55351E86, 0x551D1EC9, 0x55051F0C, 0x54EC1F4F, + 0x54D31F91, 0x54BB1FD4, 0x54A12016, 0x54882059, + 0x546F209B, 0x545520DE, 0x543B2120, 0x54212162, + 0x540721A4, 0x53EC21E6, 0x53D12228, 0x53B62269, + 0x539B22AB, 0x538022ED, 0x5364232E, 0x53492370, + 0x532D23B1, 0x531123F2, 0x52F42434, 0x52D82475, + 0x52BB24B6, 0x529E24F7, 0x52812538, 0x52642578, + 0x524625B9, 0x522825FA, 0x520B263A, 0x51EC267A, + 0x51CE26BB, 0x51B026FB, 0x5191273B, 0x5172277B, + 0x515327BB, 0x513427FB, 0x5114283A, 0x50F4287A, + 0x50D428BA, 0x50B428F9, 0x50942938, 0x50742978, + 0x505329B7, 0x503229F6, 0x50112A35, 0x4FF02A74, + 0x4FCE2AB2, 0x4FAD2AF1, 0x4F8B2B2F, 0x4F692B6E, + 0x4F472BAC, 0x4F242BEA, 0x4F022C29, 0x4EDF2C67, + 0x4EBC2CA4, 0x4E992CE2, 0x4E752D20, 0x4E522D5D, + 0x4E2E2D9B, 0x4E0A2DD8, 0x4DE62E15, 0x4DC22E53, + 0x4D9D2E90, 0x4D792ECD, 0x4D542F09, 0x4D2F2F46, + 0x4D0A2F83, 0x4CE42FBF, 0x4CBF2FFB, 0x4C993038, + 0x4C733074, 0x4C4D30B0, 0x4C2630EC, 0x4C003127, + 0x4BD93163, 0x4BB2319E, 0x4B8B31DA, 0x4B643215, + 0x4B3D3250, 0x4B15328B, 0x4AED32C6, 0x4AC53301, + 0x4A9D333C, 0x4A753376, 0x4A4C33B1, 0x4A2433EB, + 0x49FB3425, 0x49D2345F, 0x49A83499, 0x497F34D3, + 0x4955350C, 0x492C3546, 0x4902357F, 0x48D835B9, + 0x48AD35F2, 0x4883362B, 0x48583664, 0x482E369C, + 0x480336D5, 0x47D7370E, 0x47AC3746, 0x4781377E, + 0x475537B6, 0x472937EE, 0x46FD3826, 0x46D1385E, + 0x46A43895, 0x467838CD, 0x464B3904, 0x461E393B, + 0x45F13972, 0x45C439A9, 0x459739E0, 0x45693A16, + 0x453C3A4D, 0x450E3A83, 0x44E03AB9, 0x44B13AEF, + 0x44833B25, 0x44553B5B, 0x44263B90, 0x43F73BC6, + 0x43C83BFB, 0x43993C30, 0x43693C65, 0x433A3C9A, + 0x430A3CCF, 0x42DA3D04, 0x42AA3D38, 0x427A3D6C, + 0x424A3DA0, 0x42193DD4, 0x41E93E08, 0x41B83E3C, + 0x41873E6F, 0x41563EA3, 0x41253ED6, 0x40F33F09, + 0x40C23F3C, 0x40903F6F, 0x405E3FA1, 0x402C3FD4, + 0x3FFA4006, 0x3FC74038, 0x3F95406A, 0x3F62409C, + 0x3F2F40CE, 0x3EFC4100, 0x3EC94131, 0x3E964162, + 0x3E634193, 0x3E2F41C4, 0x3DFB41F5, 0x3DC74226, + 0x3D934256, 0x3D5F4286, 0x3D2B42B6, 0x3CF642E6, + 0x3CC24316, 0x3C8D4346, 0x3C584375, 0x3C2343A5, + 0x3BEE43D4, 0x3BB84403, 0x3B834432, 0x3B4D4460, + 0x3B18448F, 0x3AE244BD, 0x3AAC44EB, 0x3A754519, + 0x3A3F4547, 0x3A094575, 0x39D245A2, 0x399B45CF, + 0x396445FD, 0x392D462A, 0x38F64656, 0x38BF4683, + 0x388746B0, 0x385046DC, 0x38184708, 0x37E04734, + 0x37A84760, 0x3770478B, 0x373847B7, 0x36FF47E2, + 0x36C7480D, 0x368E4838, 0x36554863, 0x361D488E, + 0x35E348B8, 0x35AA48E2, 0x3571490C, 0x35384936, + 0x34FE4960, 0x34C44989, 0x348B49B3, 0x345149DC, + 0x34164A05, 0x33DC4A2E, 0x33A24A56, 0x33684A7F, + 0x332D4AA7, 0x32F24ACF, 0x32B74AF7, 0x327C4B1F, + 0x32414B46, 0x32064B6E, 0x31CB4B95, 0x31904BBC, + 0x31544BE3, 0x31184C0A, 0x30DD4C30, 0x30A14C56, + 0x30654C7C, 0x30294CA2, 0x2FEC4CC8, 0x2FB04CEE, + 0x2F734D13, 0x2F374D38, 0x2EFA4D5D, 0x2EBD4D82, + 0x2E804DA7, 0x2E434DCB, 0x2E064DEF, 0x2DC94E13, + 0x2D8C4E37, 0x2D4E4E5B, 0x2D104E7E, 0x2CD34EA2, + 0x2C954EC5, 0x2C574EE8, 0x2C194F0A, 0x2BDB4F2D, + 0x2B9D4F4F, 0x2B5E4F71, 0x2B204F93, 0x2AE14FB5, + 0x2AA34FD7, 0x2A644FF8, 0x2A255019, 0x29E6503A, + 0x29A7505B, 0x2968507C, 0x2929509C, 0x28E950BC, + 0x28AA50DC, 0x286A50FC, 0x282B511C, 0x27EB513B, + 0x27AB515B, 0x276B517A, 0x272B5199, 0x26EB51B7, + 0x26AB51D6, 0x266A51F4, 0x262A5212, 0x25E95230, + 0x25A9524E, 0x2568526B, 0x25275288, 0x24E652A5, + 0x24A652C2, 0x246452DF, 0x242352FB, 0x23E25318, + 0x23A15334, 0x235F5350, 0x231E536B, 0x22DC5387, + 0x229B53A2, 0x225953BD, 0x221753D8, 0x21D553F3, + 0x2193540D, 0x21515427, 0x210F5442, 0x20CD545B, + 0x208B5475, 0x2048548F, 0x200654A8, 0x1FC354C1, + 0x1F8154DA, 0x1F3E54F2, 0x1EFB550B, 0x1EB85523, + 0x1E76553B, 0x1E335553, 0x1DF0556A, 0x1DAC5582, + 0x1D695599, 0x1D2655B0, 0x1CE355C7, 0x1C9F55DD, + 0x1C5C55F4, 0x1C18560A, 0x1BD55620, 0x1B915636, + 0x1B4D564B, 0x1B095661, 0x1AC55676, 0x1A82568B, + 0x1A3E569F, 0x19F956B4, 0x19B556C8, 0x197156DC, + 0x192D56F0, 0x18E95704, 0x18A45717, 0x1860572A, + 0x181B573E, 0x17D75750, 0x17925763, 0x174D5775, + 0x17095788, 0x16C4579A, 0x167F57AB, 0x163A57BD, + 0x15F557CE, 0x15B057DF, 0x156B57F0, 0x15265801, + 0x14E15812, 0x149C5822, 0x14575832, 0x14115842, + 0x13CC5851, 0x13875861, 0x13415870, 0x12FC587F, + 0x12B6588E, 0x1271589D, 0x122B58AB, 0x11E558B9, + 0x11A058C7, 0x115A58D5, 0x111458E2, 0x10CE58F0, + 0x108858FD, 0x1042590A, 0x0FFD5916, 0x0FB75923, + 0x0F71592F, 0x0F2A593B, 0x0EE45947, 0x0E9E5952, + 0x0E58595E, 0x0E125969, 0x0DCC5974, 0x0D85597E, + 0x0D3F5989, 0x0CF95993, 0x0CB2599D, 0x0C6C59A7, + 0x0C2559B1, 0x0BDF59BA, 0x0B9959C4, 0x0B5259CD, + 0x0B0B59D5, 0x0AC559DE, 0x0A7E59E6, 0x0A3859EE, + 0x09F159F6, 0x09AA59FE, 0x09645A05, 0x091D5A0D, + 0x08D65A14, 0x08905A1B, 0x08495A21, 0x08025A28, + 0x07BB5A2E, 0x07745A34, 0x072D5A3A, 0x06E75A3F, + 0x06A05A44, 0x06595A49, 0x06125A4E, 0x05CB5A53, + 0x05845A57, 0x053D5A5C, 0x04F65A60, 0x04AF5A63, + 0x04685A67, 0x04215A6A, 0x03DA5A6D, 0x03935A70, + 0x034C5A73, 0x03055A76, 0x02BE5A78, 0x02775A7A, + 0x02305A7C, 0x01E95A7D, 0x01A25A7F, 0x015B5A80, + 0x01135A81, 0x00CC5A82, 0x00855A82, 0x003E5A82 + }; + + +#ifdef __cplusplus +} +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.c new file mode 100644 index 00000000..ac6558a4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.c @@ -0,0 +1,289 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdst.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input length 64 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + mdst + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#include "pv_audio_type_defs.h" +#include "synthesis_sub_band.h" +#include "dct16.h" +#include "dct64.h" +#include "mdst.h" + +#ifdef HQ_SBR + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#include "fxp_mul32.h" +#include "dst32.h" + + +#define Qfmt1(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F)) +#define Qfmt(a) (Int32)(a*((Int32)1<<27) + (a>=0?0.5F:-0.5F)) + +const Int32 CosTable_32[32] = +{ + Qfmt1(0.50015063602065F), Qfmt1(0.50135845244641F), + Qfmt1(0.50378872568104F), Qfmt1(0.50747117207256F), + Qfmt1(0.51245147940822F), Qfmt1(0.51879271310533F), + Qfmt1(0.52657731515427F), Qfmt1(0.53590981690799F), + Qfmt1(0.54692043798551F), Qfmt1(0.55976981294708F), + Qfmt1(0.57465518403266F), Qfmt1(0.59181853585742F), + Qfmt1(0.61155734788251F), Qfmt1(0.63423893668840F), + Qfmt1(0.66031980781371F), Qfmt1(0.69037212820021F), + Qfmt1(0.72512052237720F), Qfmt1(0.76549416497309F), + Qfmt1(0.81270209081449F), Qfmt1(0.86834471522335F), + Qfmt(0.93458359703641F), Qfmt(1.01440826499705F), + Qfmt(1.11207162057972F), Qfmt(1.23383273797657F), + Qfmt(1.38929395863283F), Qfmt(1.59397228338563F), + Qfmt(1.87467598000841F), Qfmt(2.28205006800516F), + Qfmt(2.92462842815822F), Qfmt(4.08461107812925F), + Qfmt(6.79675071167363F), Qfmt(10.18693908361573F) +}; + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; mdst_32 +----------------------------------------------------------------------------*/ + +void mdst_32(Int32 vec[], Int32 scratch_mem[]) +{ + + Int i; + const Int32 *pt_cos = CosTable_32; + Int32 *pt_vec = vec; + Int32 tmp1; + Int32 tmp2; + + + + Int32 tmp3; + + tmp3 = *(pt_vec++); + tmp2 = *(pt_vec); + + for (i = 5; i != 0; i--) + { + *(pt_vec++) += tmp3; + tmp1 = *(pt_vec); + *(pt_vec++) += tmp2; + tmp3 = *(pt_vec); + *(pt_vec++) += tmp1; + tmp2 = *(pt_vec); + *(pt_vec++) += tmp3; + tmp1 = *(pt_vec); + *(pt_vec++) += tmp2; + tmp3 = *(pt_vec); + *(pt_vec++) += tmp1; + tmp2 = *(pt_vec); + } + + *(pt_vec) += tmp3; + + dst_32(vec, scratch_mem); + + pt_vec = vec; + + for (i = 5; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++)); + pt_vec++; + } + + tmp2 >>= 1; + for (i = 3; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++)); + pt_vec++; + } + + *(pt_vec - 1) <<= 1; + +} + + + +/*---------------------------------------------------------------------------- +; mdct_32 +----------------------------------------------------------------------------*/ + +void mdct_32(Int32 vec[]) +{ + Int i; + Int32 *pt_vec = vec; + Int32 tmp1, tmp2; + + + const Int32 *pt_CosTable = CosTable_32; + + + for (i = 5; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++)); + pt_vec++; + } + for (i = 3; i != 0; i--) + { + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++)); + pt_vec++; + } + *(pt_vec - 1) <<= 1; + + + dct_32(vec); + + + pt_vec = &vec[31]; + + tmp1 = *(pt_vec--); + + for (i = 5; i != 0; i--) + { + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + tmp2 = *(pt_vec); + *(pt_vec--) += tmp1; + tmp1 = *(pt_vec); + *(pt_vec--) += tmp2; + } + + *(pt_vec) += tmp1; + +} + +#endif /* HQ_SBR */ + + +/*---------------------------------------------------------------------------- +; dct_32 +----------------------------------------------------------------------------*/ + + +void dct_32(Int32 vec[]) +{ + + pv_split(&vec[16]); + + dct_16(&vec[16], 0); + dct_16(vec, 1); // Even terms + + pv_merge_in_place_N32(vec); +} + +#endif /* AAC_PLUS */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.h new file mode 100644 index 00000000..17bcc8cc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mdst.h @@ -0,0 +1,68 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mdst.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef MDST_H +#define MDST_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void mdst_32(Int32 vec[], Int32 scratch_mem[]); + + void dct_32(Int32 vec[]); + + void mdct_32(Int32 vec[]); + + + +#ifdef __cplusplus +} +#endif + +#endif /* MDST_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.c new file mode 100644 index 00000000..4c5f275d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.c @@ -0,0 +1,277 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mix_radix_fft.cpp + Funtions: mix_radix_fft + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Data = Input vector, with quantized spectral with a pre-rotation + by exp(j(2pi/N)(k+1/8)) + type Int32 * + + peak_value = Input, carries the maximum value in input vector "Data" + Output, maximum value computed in the first FFT, used + to set precision on next stages + type Int32 * + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + exponent = shift factor to reflect signal scaling + + Pointers and Buffers Modified: + Results are return in "Data" + + Local Stores Modified: + None + + Global Stores Modified: + None +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + mix_radix_fft() mixes radix-2 and radix-4 FFT. This is needed to be able + to use power of 4 length when the input length sequence is a power of 2. +------------------------------------------------------------------------------ + REQUIREMENTS + + mix_radix_fft() should support only the FFT for the long window case of + the inverse modified cosine transform (IMDCT) +------------------------------------------------------------------------------ + REFERENCES + + ------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "fft_rx4.h" +#include "mix_radix_fft.h" +#include "pv_normalize.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void digit_reversal_swapping(Int32 *y, Int32 *x); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int mix_radix_fft( + Int32 *Data, + Int32 *peak_value +) + +{ + + const Int32 *p_w; + Int32 *pData_1; + Int32 *pData_2; + + Int32 *pData_3; + Int32 *pData_4; + + Int32 exp_jw; + Int32 max1; + Int32 max2; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 diff1; + Int32 diff2; + Int i; + Int exp; + + max1 = *peak_value; + p_w = w_512rx2; + + pData_1 = Data; + pData_3 = Data + HALF_FFT_RX4_LENGTH_FOR_LONG; + + + /* + * normalization to 0.9999 (0x7FFF) guarantees proper operation + */ + + exp = 8 - pv_normalize(max1); /* use 24 bits for mix radix fft */ + + if (exp < 4) + { + exp = 4; + } + + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + + + diff1 = (temp1 - temp2) >> exp; + *pData_3++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_3); + temp4 = (*pData_4); + + *pData_4-- = -diff1; + *pData_3++ = (temp3 + temp4) >> exp; + *pData_4 = (temp3 - temp4) >> exp; + + temp1 = (*pData_1); + pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_2++); + temp4 = (*pData_2); + + *pData_1++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_1); + diff1 = (temp1 - temp2) >> exp ; + + *pData_1++ = (temp3 + temp4) >> exp; + *pData_2-- = (temp3 - temp4) >> exp; + *pData_2 = diff1; + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + + for (i = ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG - 1; i != 0; i--) + { + /* + * radix 2 Butterfly + */ + + diff1 = (temp1 - temp2) >> (exp - 4); + *pData_3++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_3); + temp4 = (*pData_4); + + exp_jw = *p_w++; + + + diff2 = (temp3 - temp4) >> (exp - 4); + *pData_3++ = (temp3 + temp4) >> exp; + + *pData_4-- = -cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3; + *pData_4 = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3; + + + temp1 = (*pData_1); + pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_2++); + temp4 = (*pData_2); + + *pData_1++ = (temp1 + temp2) >> exp; + + temp3 = (*pData_1); + diff1 = (temp1 - temp2) >> (exp - 4); + + diff2 = (temp3 - temp4) >> (exp - 4); + *pData_1++ = (temp3 + temp4) >> exp; + + *pData_2-- = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3; + *pData_2 = cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3; + + temp1 = (*pData_3); + pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG; + temp2 = (*pData_4++); + + }/* for i */ + + + fft_rx4_long( + Data, + &max1); + + + fft_rx4_long( + &Data[FFT_RX4_LENGTH_FOR_LONG], + &max2); + + digit_reversal_swapping(Data, &Data[FFT_RX4_LENGTH_FOR_LONG]); + + *peak_value = max1 | max2; + + return(exp); +} + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.h new file mode 100644 index 00000000..bf162055 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/mix_radix_fft.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: mix_radix_fft.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions mix_radix_fft + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MIX_RADIX_FFT_H +#define MIX_RADIX_FFT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define FFT_RX4_LENGTH_FOR_LONG 512 +#define HALF_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>1) +#define ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int mix_radix_fft( + Int32 *Data, + Int32 *peak_value); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* MIX_RADIX_FFT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_map_mask.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_map_mask.h new file mode 100644 index 00000000..a45669b1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_map_mask.h @@ -0,0 +1,71 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MS_MAP_MASK_H +#define MS_MAP_MASK_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void MS_map_mask( + FrameInfo *info, + Int *group, + Int *mask, + Int *cb_map); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.c new file mode 100644 index 00000000..4bd7e825 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.c @@ -0,0 +1,365 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ms_synt.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + wins_in_group = Number of windows in the current group. + [const Int] + + coef_per_win = Number of coefficients per window. + [const Int] + + num_bands = Number of scalefactor bands. + [const Int] + + band_length = Number of coefficients per scalefactor band. + [const Int] + + pFirst_Window_CoefsL = Array containing the spectral coefficients for + the left channel. + [Int32 *, length LN] + pFirst_Window_CoefsR = Array containing the spectral coefficients for + the right channel. + [Int32 *, length LN] + q_formatLeft = Array containing the q-format used to encode each + scalefactor band's data on the left channel. + [Int *, length MAXBANDS] + q_formatRight = Array containing the q-format used to encode each + scalefactor band's data on the right channel. + [Int *, length MAXBANDS] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + pFirst_Window_CoefsL The coefficients in the group will be modified per the + formula for M/S stereo on each scalefactor band where + M/S stereo is active. + + pFirst_Window_CoefsR The coefficients in the group will be modified per the + formula for M/S stereo on each scalefactor band where + M/S stereo is active. + + q_formatLeft The q_format may be modified on scalefactor bands + where M/S stereo is active. + + q_formatRight The q_format may be modified on scalefactor bands + where M/S stereo is active. + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This module applies the formula for M/S coding to one grouped scalefactor + band. The ISO code has a similar function which applies M/S coding to an + entire frame. + + It is the calling function's responsibility to check the map_mask array, which + is filled by the function getmask. If a scalefactor band is identified as + using M/S stereo, the coefficients in that array are calculated using + the following formula... + + TempLeft = LeftCoefficient; + + LeftCoefficient = LeftCoefficient + RightCoefficient; + RightCoefficient = TempLeft - RightCoefficient; + + This function should be inlined if the compiler supports C99 inlining, + as this short function is only called by sfb_tools_ms(). + Therefore, inlining will not increase the code size. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + start_indx = 0; + + pCoefR = coefLeft; + pCoefL = coefRight; + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + + tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx]; + + IF (tempInt > 0) + THEN + + shift_left_chan = 1 + tempInt; + shift_right_chan = 1; + + q_formatLeft[start_indx] = (q_formatRight[start_indx] - 1); + q_formatRight[start_indx] = (q_formatRight[start_indx] - 1); + + ELSE + shift_left_chan = 1; + shift_right_chan = 1 - tempInt; + + q_formatRight[start_indx] = (q_formatLeft[start_indx] - 1); + q_formatLeft[start_indx] = (q_formatLeft[start_indx] - 1); + + ENDIF + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + + temp_left = *(pCoefL) >> shift_left_chan; + temp_right = *(pCoefR) >> shift_right_chan; + + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + + ENDFOR + + tempInt = (coef_per_win - band_length); + + pCoefR = pCoefR + tempInt; + pCoefL = pCoefL + tempInt; + + start_indx = start_indx + num_bands; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "ms_synt.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ms_synt( + const Int wins_in_group, + const Int coef_per_win, + const Int num_bands, + const Int band_length, + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[], + Int q_formatRight[]) +{ + + Int32 *pCoefL = coefLeft; + Int32 *pCoefR = coefRight; + Int start_indx = 0; + Int win_indx; + Int i; + + + if (band_length < 0 || band_length > LONG_WINDOW) + { + return; /* avoid any processing on error condition */ + } + + + Int nextWinPtrUpdate = (coef_per_win - band_length); + + for (win_indx = wins_in_group; win_indx > 0; win_indx--) + { + + if (q_formatRight[start_indx] < 31) + { + Int tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx]; + + /* Normalize the left and right channel to the same q-format */ + if (tempInt > 0) + { + /* + * shift_left_chan and shift_right_chan each have an offset + * of 1. Even if the left and right channel share the same + * q-format, we must shift each by 1 to guard against + * overflow. + */ + Int shift_left_chan = 1 + tempInt; + + /* + * Following code line is equivalent to... + * q_formatLeft = q_formatRight - 1; + * q_formatRight = q_formatRight - 1; + */ + q_formatLeft[start_indx] = --(q_formatRight[start_indx]); + + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + + Int32 temp_left = *(pCoefL) >> shift_left_chan; + Int32 temp_right = *(pCoefR) >> 1; + + + + for (i = band_length; i != 0; i--) + { + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + temp_left = *(pCoefL) >> shift_left_chan; + temp_right = *(pCoefR) >> 1; + + } + + } + else + { + /* + * shift_left_chan and shift_right_chan each have an offset + * of 1. Even if the left and right channel share the same + * q-format, we must shift each by 1 to guard against + * overflow. + */ + Int shift_right_chan = 1 - tempInt; + + /* + * Following code line is equivalent to... + * q_formatRight = q_formatLeft - 1; + * q_formatLeft = q_formatLeft - 1; + */ + q_formatRight[start_indx] = --(q_formatLeft[start_indx]); + + /* + * band_length is always an even number (check tables in pg.66 IS0 14496-3) + */ + + Int32 temp_left = *(pCoefL) >> 1; + Int32 temp_right = *(pCoefR) >> shift_right_chan; + + for (i = band_length; i != 0; i--) + { + *(pCoefL++) = temp_left + temp_right; + *(pCoefR++) = temp_left - temp_right; + + temp_left = *(pCoefL) >> 1; + temp_right = *(pCoefR) >> shift_right_chan; + + } + } + + } + else + { + /* + * Nothing on right channel, just copy left into right + */ + q_formatRight[start_indx] = (q_formatLeft[start_indx]); + + pv_memcpy(pCoefR, pCoefL, band_length*sizeof(*pCoefR)); + pCoefR += band_length; + pCoefL += band_length; + } + + /* + * Increment the window pointers so they point + * to the next window in the group + */ + pCoefL += nextWinPtrUpdate; + pCoefR += nextWinPtrUpdate; + + start_indx += num_bands; + + } /* for (win_indx) */ + + return; + +} /* MS_synt */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.h new file mode 100644 index 00000000..e770d728 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ms_synt.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ms_synt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function declaration for ms_synt(). + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef MS_SYNT_H +#define MS_SYNT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void ms_synt( + const Int wins_in_group, + const Int coef_per_win, + const Int num_bands, + const Int band_length, + Int32 spectralCoefLeft[], + Int32 spectralCoefRight[], + Int q_formatLeft[], + Int q_formatRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.c new file mode 100644 index 00000000..0b8dacf2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.c @@ -0,0 +1,307 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_corr.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + scale = Multiplier used to scale the noise extracted from the left + channel for use on the right. + [const Int] + + coef_per_win = Number of coefficients per window. + (128 for short, 1024 for long) + [const Int] + + sfb_per_win = Number of scalefactors per window. + [const Int] + + wins_in_group = The number of windows in the group being decoded. + [const Int] + + band_length = The length of the scalefactor band being decoded. + [const Int] + + sfb_prediction_used = Flag that denotes the activation of long term + prediction on a per-scalefactor band, + non-grouped basis. + [const Int *, length MAX_SFB] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [const Int] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [const Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + pcoefRight Contains the new spectral information + + q_formatRight Q-format may be updated with changed to fixed-point + data in coefRight. + + sfb_prediction_used LTP may be disabled by presence of PNS tool on the + same scalefactor band. + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function derives noise from the left channel. The PNS tool is assumed + to have been used on the same scalefactor band on the left channel. The + noise on the left/right channels are not necessarily of the same amplitude, + and therefore have separate scalefactors. The noise is thus scaled by the + difference between the two transmitted scalefactors. This scaling is done + in fixed-point using a constant 4-element table. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.12.3 Decoding Process (PNS) + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + q_format = q_formatLeft - (scale >> 2); + q_format = q_format - 1; + q_formatRight = q_format; + + multiplier = hcb2_scale_mod_4[scale & 0x3]; + + pCoefLeft = coefLeft; + pCoefRight = coefRight; + + start_indx = 0; + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + q_formatRight[start_indx] = q_format; + + sfb_prediction_used[start_indx] = FALSE; + + start_indx = start_indx + sfb_per_win; + + FOR (tempInt = band_length; tempInt > 0; tempInt--) + + *(pCoefRight) = (*(pCoefLeft) >> 9) * multiplier; + pCoefRight = pCoefRight + 1; + pCoefLeft = pCoefLeft + 1; + + ENDFOR + + tempInt = (coef_per_win - band_length); + pCoefRight = pCoefRight + tempInt; + pCoefLeft = pCoefLeft + tempInt; + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_corr.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const UInt hcb2_scale_mod_4[4] = +{ + 32768, /* (2.0^0.00)*2^15 */ + 38968, /* (2.0^0.25)*2^15 */ + 46341, /* (2.0^0.50)*2^15 */ + 55109 +}; /* (2.0^0.75)*2^15 */ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_corr( + const Int scale, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int q_formatLeft, + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]) +{ + Int tempInt; + Int nextWinPtrUpdate; + + Int q_format; + + Int start_indx; + Int win_indx; + + const Int32 *pCoefLeft; + Int32 *pCoefRight; + + UInt multiplier; + + /* + * Generate noise correlated with the noise on the left channel + * + */ + + /* + * scale is interpreted as 2^(scale/4) + * Therefore, we can adjust the q-format by floor(scale/4) + * and save some complexity in the multiplier. + */ + q_format = q_formatLeft - (scale >> 2); + + /* + * Reduce the q-format by 1 to guard against overflow. + * This must be done because the hcb2_scale_mod_4 table + * must be stored in a common q-format, and we must shift + * by 16 to get *pCoefLeft into a 16-bit value, but we + * cannot store 2^0*2^16 and 2^0.75*2^16 in a table. + */ + q_format--; + + multiplier = hcb2_scale_mod_4[scale & 0x3]; + + pCoefLeft = coefLeft; + pCoefRight = coefRight; + + nextWinPtrUpdate = (coef_per_win - band_length); + + /* + * Step through all the windows in this group, replacing this + * band in each window's spectrum with correlated random noise + */ + + start_indx = 0; + + for (win_indx = wins_in_group; win_indx > 0; win_indx--) + { + /* + * Set the q-format for all scalefactor bands in the group. + * Normally, we could not assume that grouped scalefactors + * share the same q-format. + * However, here we can make this assumption. The reason + * being -- if this function is called, it is assumed + * PNS was used on the left channel. When PNS is used, + * all scalefactors in a group share the same q-format. + * + */ + q_formatRight[start_indx] = q_format; + + start_indx += sfb_per_win; + + /* reconstruct right noise values */ + for (tempInt = band_length; tempInt > 0; tempInt--) + { + *(pCoefRight++) = (Int32)(*(pCoefLeft++) >> 16) * multiplier; + } + + pCoefRight += nextWinPtrUpdate; + pCoefLeft += nextWinPtrUpdate; + + } /* for (win_indx) */ + + return; + +} /* void pns_corr */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.h new file mode 100644 index 00000000..f5cde3c0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_corr.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_corr.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function declaration for pns_corr.c +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_CORR_H +#define PNS_CORR_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void pns_corr( + const Int scale, + const Int coef_per_win, + const Int sfb_per_win, + const Int wins_in_group, + const Int band_length, + const Int q_formatLeft, + Int q_formatRight[], + const Int32 coefLeft[], + Int32 coefRight[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.c new file mode 100644 index 00000000..a4a6fc76 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.c @@ -0,0 +1,631 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_intensity_right.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + hasmask = mask status for the frame. Enumerated. + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands + per group, etc.) + [const pFrameInfo * const] + + group = Array that contains indexes of the + first window in the next group. + [const Int *, length num_win] + + mask_map = Array that denotes whether M/S stereo is turned on for + each grouped scalefactor band. + [const Int *, length MAX_SFB] + + codebook_map = Array that denotes which Huffman codebook was used for + the encoding of each grouped scalefactor band. + [const Int *, length MAX_SFB] + + factorsL = Array of grouped scalefactors for left chan. + [const Int *, length MAX_SFB] + + factorsR = Array of scalefactors for right chan. + [const Int *, length MAX_SFB] + + sfb_prediction_used = Flag that denotes the activation of long term prediction + on a per-scalefactor band, non-grouped basis. + [const Int *, length MAX_SFB] + + ltp_data_present = Flag that indicates whether LTP is enbaled for this frame. + [const Bool] + + coefLeft = Array containing the fixed-point spectral coefficients + for the left channel. + [Int32 *, length 1024] + + coefRight = Array containing the fixed-point spectral coefficients + for the right channel. + [Int32 *, length 1024] + + q_formatLeft = The Q-format for the left channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + q_formatRight = The Q-format for the right channel's fixed-point spectral + coefficients, on a per-scalefactor band, non-grouped basis. + [Int *, length MAX_SFB] + + pCurrentSeed = Pointer to the current seed for the random number + generator in the function gen_rand_vector(). + [Int32 * const] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coefLeft = Contains the new spectral information. + + coefRight = Contains the new spectral information. + + q_formatLeft = Q-format may be updated with changed to fixed-point + data in coefLeft. + + q_formatRight = Q-format may be updated with changed to fixed-point + data in coefRight. + + pCurrentSeed = Value pointed to by pCurrentSeed updated by calls + to gen_rand_vector(). + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function steps through all of the scalefactor bands, looking for + either PNS or IS to be enabled on the right channel. + + If the codebook used is >= NOISE_HCB, the code then checks for the use + of Huffman codebooks NOISE_HCB, INTENSITY_HCB, or INTENSITY_HCB2. + + When a SFB utilizing the codebook NOISE_HCB is detected, a check is made to + see if M/S has also been enabled for that SFB. + + If M/S is not enabled, the band's spectral information is filled with + scaled random data. The scaled random data is generated by the function + gen_rand_vector. This is done across all windows in the group. + + If M/S is enabled, the band's spectral information is derived from the data + residing in the same band on the left channel. The information on the right + channel has independent scaling, so this is a bit more involved than a + direct copy of the information on the left channel. This is done by calling + the inline function pns_corr(). + + When a SFB utilizing an intensity codebook is detected, the band's spectral + information is generated from the information on the left channel. + This is done across all windows in the group. M/S being enabled has the + effect of reversing the sign of the data on the right channel. This code + resides in the inline function intensity_right(). + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.7.1 M/S stereo + Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo) + Subpart 4.6.12.3 Decoding Process (PNS) + Subpart 4.6.2 ScaleFactors + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + start_indx = 0; + + coef_per_win = pFrameInfo->coef_per_win[0]; + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + DO + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *pGroup; + pGroup = pGroup + 1; + + band_start = 0; + + wins_in_group = (partition - window_start); + + FOR (sfb = sfb_per_win; sfb > 0; sfb--) + + band_stop = *(pBand); + pBand = pBand + 1; + + codebook = *(pCodebookMap); + pCodebookMap = pCodebookMap + 1; + + mask_enabled = *(pMaskMap); + pMaskMap = pMaskMap + 1; + + band_length = band_stop - band_start; + + IF (codebook == NOISE_HCB) + + sfb_prediction_used[tot_sfb] &= ltp_data_present; + + IF (sfb_prediction_used[tot_sfb] == FALSE) + + mask_enabled = mask_enabled AND hasmask; + + IF (mask_enabled == FALSE) + + pWindow_CoefR = &(pCoefRight[band_start]); + + start_indx = tot_sfb; + + FOR (win_indx = wins_in_group; + win_indx > 0; + win_indx--) + + CALL + q_formatRight[start_indx] = + gen_rand_vector( + pWindow_CoefR, + band_length, + pCurrentSeed, + *(pFactorsRight)); + MODIFYING + pCoefRight[band_start] + RETURNING + q_formatRight[start_indx] + + pWindow_CoefR += coef_per_win; + + start_indx = start_indx + sfb_per_win; + + ENDFOR + + ELSE + CALL + pns_corr( + (*(pFactorsRight) - + *(pFactorsLeft) ), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + q_formatLeft[tot_sfb], + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + MODIFYING + pCoefRightt[band_start] + q_formatRight[tot_sfb] + RETURNING + NONE + ENDIF + + ENDIF + + ELSE IF (codebook >= INTENSITY_HCB2) + + mask_enabled = mask_enabled AND hasmask; + + CALL + intensity_right( + *(pFactorsRight), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + codebook, + mask_enabled, + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + MODIFYING + pCoefRightt[band_start] + q_formatRight[tot_sfb] + RETURNING + NONE + + ENDIF + + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + ENDFOR + + coef_per_win = coef_per_win * (wins_in_group); + + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + sfb_per_win * wins_in_group; + pFactorsRight = pFactorsRight + sfb_per_win * wins_in_group; + pFactorsLeft = pFactorsLeft + sfb_per_win * wins_in_group; + + pCoefRight = pCoefRight + coef_per_win; + pCoefLeft = pCoefLeft + coef_per_win; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + + return; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_intensity_right.h" +#include "e_huffmanconst.h" +#include "gen_rand_vector.h" +#include "intensity_right.h" +#include "pns_corr.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_intensity_right( + const Int hasmask, + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + const Int factorsL[], + const Int factorsR[], + Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 coefLeft[], + Int32 coefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS], + Int32 * const pCurrentSeed) +{ + + Int32 *pCoefRight; + Int32 *pWindow_CoefR; + + Int32 *pCoefLeft; + + Int tot_sfb; + Int start_indx; + Int sfb; + + Int band_length; + Int band_start; + Int band_stop; + Int coef_per_win; + + Int codebook; + Int partition; + Int window_start; + + Int sfb_per_win; + Int wins_in_group; + Int win_indx; + + const Int16 *pBand; + const Int *pFactorsLeft = factorsL; + const Int *pFactorsRight = factorsR; + const Int *pCodebookMap = codebook_map; + const Int *pGroup = group; + const Bool *pMaskMap = mask_map; + + Bool mask_enabled; + + pCoefRight = coefRight; + pCoefLeft = coefLeft; + + window_start = 0; + tot_sfb = 0; + start_indx = 0; + + /* + * Each window in the frame should have the same number of coef's, + * so coef_per_win is constant in all the loops + */ + coef_per_win = pFrameInfo->coef_per_win[0]; + + /* + * Because the number of scalefactor bands per window should be + * constant for each frame, sfb_per_win can be determined outside + * of the loop. + * + * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows + * sfb_per_win = 49 for long windows + */ + + sfb_per_win = pFrameInfo->sfb_per_win[0]; + + do + { + pBand = pFrameInfo->win_sfb_top[window_start]; + + /*---------------------------------------------------------- + Partition is equal to the first window in the next group + + { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + + pGroup[0] = 2 + pGroup[1] = 5 + pGroup[2] = 7 + pGroup[3] = 8 + -----------------------------------------------------------*/ + partition = *(pGroup++); + + band_start = 0; + + wins_in_group = (partition - window_start); + + for (sfb = sfb_per_win; sfb > 0; sfb--) + { + /* band is offset table, band_stop is last coef in band */ + band_stop = *(pBand++); + + codebook = *(pCodebookMap++); + + mask_enabled = *(pMaskMap++); + + /* + * When a tool utilizing sfb is found, apply the correct tool + * to that sfb in each window in the group + * + * Example... sfb[3] == NOISE_HCB + * + * [ Group 1 ] + * [win 0 ][win 1 ] + * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7] + * + * The for(sfb) steps through the sfb's 0-7 in win 0. + * + * Finding sfb[3]'s codebook == NOISE_HCB, the code + * steps through all the windows in the group (they share + * the same scalefactors) and replaces that sfb with noise. + */ + + /* + * Experimental results suggest that ms_synt is the most + * commonly used tool, so check for it first. + * + */ + + band_length = band_stop - band_start; + + if (codebook == NOISE_HCB) + { + sfb_prediction_used[tot_sfb] &= ltp_data_present; + + if (sfb_prediction_used[tot_sfb] == FALSE) + { + /* + * The branch and the logical AND interact in the + * following manner... + * + * mask_enabled == 0 hasmask == X -- gen_rand_vector + * mask_enabled == 1 hasmask == 1 -- pns_corr + * mask_enabled == 0 hasmask == 1 -- gen_rand_vector + * mask_enabled == 1 hasmask == 2 -- gen_rand_vector + * mask_enabled == 0 hasmask == 2 -- gen_rand_vector + */ + + mask_enabled &= hasmask; + + if (mask_enabled == FALSE) + { + pWindow_CoefR = &(pCoefRight[band_start]); + + /* + * Step through all the windows in this group, + * replacing this band in each window's + * spectrum with random noise + */ + start_indx = tot_sfb; + + for (win_indx = wins_in_group; + win_indx > 0; + win_indx--) + { + + /* generate random noise */ + q_formatRight[start_indx] = + gen_rand_vector( + pWindow_CoefR, + band_length, + pCurrentSeed, + *(pFactorsRight)); + + pWindow_CoefR += coef_per_win; + + start_indx += sfb_per_win; + } + + } + else + { + pns_corr( + (*(pFactorsRight) - + *(pFactorsLeft)), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + q_formatLeft[tot_sfb], + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + } /* if (mask_map == FALSE) */ + + } /* if (sfb_prediction_used[tot_sfb] == FALSE) */ + + } /* if (codebook == 0) */ + else if (codebook >= INTENSITY_HCB2) + { + /* + * The logical AND flags the inversion of intensity + * in the following manner. + * + * mask_enabled == X hasmask == 0 -- DO NOT INVERT + * mask_enabled == 0 hasmask == X -- DO NOT INVERT + * mask_enabled == 1 hasmask == 1 -- DO INVERT + * mask_enabled == 0 hasmask == 1 -- DO NOT INVERT + * mask_enabled == 1 hasmask == 2 -- DO NOT INVERT + * mask_enabled == 0 hasmask == 2 -- DO NOT INVERT + */ + + mask_enabled &= hasmask; + + intensity_right( + *(pFactorsRight), + coef_per_win, + sfb_per_win, + wins_in_group, + band_length, + codebook, + mask_enabled, + &(q_formatLeft[tot_sfb]), + &(q_formatRight[tot_sfb]), + &(pCoefLeft[band_start]), + &(pCoefRight[band_start])); + + } /* END else codebook must be INTENSITY_HCB or ... */ + + band_start = band_stop; + + tot_sfb++; + + pFactorsLeft++; + pFactorsRight++; + + } /* for (sfb) */ + + /* + * Increment pCoefRight and pCoefLeft by + * coef_per_win * the number of windows + */ + + pCoefRight += coef_per_win * wins_in_group; + pCoefLeft += coef_per_win * wins_in_group--; + + /* + * Increase tot_sfb by sfb_per_win times the number of windows minus 1. + * The minus 1 comes from the fact that tot_sfb is already pointing + * to the first sfb in the 2nd window of the group. + */ + tot_sfb += sfb_per_win * wins_in_group; + + pFactorsRight += sfb_per_win * wins_in_group; + pFactorsLeft += sfb_per_win * wins_in_group; + + window_start = partition; + + } + while (partition < pFrameInfo->num_win); + + /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */ + + return; + +} /* pns_intensity_right() */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.h new file mode 100644 index 00000000..869367c1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_intensity_right.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_intensity_right.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + pns_intensity_right.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_INTENSITY_RIGHT_H +#define PNS_INTENSITY_RIGHT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void pns_intensity_right( + const Int hasmask, + const FrameInfo * const pFrameInfo, + const Int group[], + const Bool mask_map[], + const Int codebook_map[], + const Int factorsL[], + const Int factorsR[], + Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectralCoefLeft[], + Int32 spectralCoefRight[], + Int q_formatLeft[MAXBANDS], + Int q_formatRight[MAXBANDS], + Int32 * const pCurrentSeed); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.c new file mode 100644 index 00000000..cb042613 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.c @@ -0,0 +1,373 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: pns_left.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + const FrameInfo *pFrameInfo = Pointer to structure that holds + information about each group. + (long block flag, + number of windows, + scalefactor bands per group, etc.) + + const Int group[] = Array that contains indexes of the + the first window in the next group. + + const Int codebook_map[] = Array that denotes which Huffman + codebook was used for the encoding + of each scalefactor band. + + const Int factors[] = Array of scalefactors + + Int sfb_prediction_used[] = Flag that denotes the activation + of long term prediction on a sfb + basis. + + Bool ltp_data_present = Flag that denotes whether LTP + is active for the entire frame. If + this flag is FALSE, + sfb_prediction_used is garbage. + + Int32 spectral_coef[] = Array of pointers pointing to the + spectral coef's for the LEFT channel. + + Int q_format[] = Q-format for the information + pointed to by spectral_coef. + Indexed by scalefactor band. + + Int32 *pCurrentSeed = Pointer to the current seed for the + random number generator. + (gen_rand_vector) + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + Int32 spectral_coef[] = Contains the new spectral information + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + The function steps through each scalefactor band in the group, and + checks for the use of Huffman codebook NOISE_HCB. + + When a SFB utilizing NOISE_HCB is detected, the band in every window in the + group has its spectral information filled with scaled random data. + + The scaled random data is generated by the function gen_rand_vector. + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall replace bands that were encoded with the Huffman codebook + NOISE_HCB with random noise as returned from gen_rand_vector(). The result + shall be perceptually indistinguishable from the result obtained by the + ISO decoder. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.5.5 Figures + Subpart 4.6.2 ScaleFactors + Subpart 4.6.12 Perceptual Noise Substituion (PNS) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pFirst_Window_Coefs = spectral_coef; + + window_start = 0; + + tot_sfb = 0; + + DO + + num_bands = pFrameInfo->sfb_per_win[window_start]; + pBand = pFrameInfo->win_sfb_top[window_start]; + + partition = *(pGroup); + pGroup = pGroup + 1; + + band_start = 0; + + coef_per_win = pFrameInfo->coef_per_win[window_start]; + + wins_in_group = (partition - window_start); + + FOR (sfb = num_bands; sfb > 0; sfb--) + + band_stop = *pBand; + pBand = pBand + 1; + + IF (*(pCodebookMap++) == NOISE_HCB ) + + tempInt = sfb_prediction_used[tot_sfb] AND ltp_data_present; + + IF (tempInt == FALSE) + + pWindow_Coef = pFirst_Window_Coefs + band_start; + + band_length = (band_stop - band_start); + + start_indx = tot_sfb; + + tempInt = *(pFactors); + + FOR (win_indx = wins_in_group; win_indx > 0; win_indx--) + + CALL gen_rand_vector( pWindow_CoefR, + band_length, + pCurrentSeed, + tempInt); + + MODIFYING pWindow_CoefR = scaled random noise + pCurrentSeed = current state of the random + noise generator. + + RETURNING q_format[start_indx] = q-format for this sfb. + + pWindow_Coef = pWindow_Coef + coef_per_win; + + start_indx = start_indx + + pFrameInfo->sfb_per_win[win_indx]; + + ENDFOR + + ENDIF + + ENDIF + + band_start = band_stop; + + tot_sfb = tot_sfb + 1; + + pFactors = pFactors + 1; + + ENDFOR + + coef_per_win = coef_per_win * wins_in_group; + wins_in_group = wins_in_group - 1; + + tot_sfb = tot_sfb + num_bands * wins_in_group; + pFactors = pFactors + num_bands * wins_in_group; + + pFirst_Window_Coefs = pFirst_Window_Coefs + coef_per_win; + + window_start = partition; + + WHILE (partition < pFrameInfo->num_win); + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "pns_left.h" +#include "e_huffmanconst.h" +#include "gen_rand_vector.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pns_left( + const FrameInfo *pFrameInfo, + const Int group[], + const Int codebook_map[], + const Int factors[], + const Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectral_coef[], + Int q_format[], + Int32 *pCurrentSeed) +{ + + Int tot_sfb; + Int start_indx; + + Int sfb; + Int band_stop; + + const Int16 *pBand; + + const Int *pCodebookMap = &(codebook_map[0]); + const Int *pGroup = &(group[0]); + const Int *pFactors = &(factors[0]); + + Int tempInt; + Int32 *pWindow_Coef; + + + Int32 *spec; + + Int partition; + Int win_indx; + + tot_sfb = 0; + + spec = spectral_coef; + + /* PNS goes by group */ + win_indx = 0; + partition = 0; + do + { + Int num_bands = pFrameInfo->sfb_per_win[partition]; + pBand = pFrameInfo->win_sfb_top[partition]; + + /*---------------------------------------------------------- + Partition is equal to the first window in the next group + + { Group 0 }{ Group 1 }{ Group 2 }{Group 3} + [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7] + + pGroup[0] = 2 + pGroup[1] = 5 + pGroup[2] = 7 + pGroup[3] = 8 + -----------------------------------------------------------*/ + + partition = *pGroup++; /* partition = index of last sbk in group */ + + do + { + Int band_start = 0; + for (sfb = 0; sfb < num_bands; sfb++) + { + band_stop = pBand[sfb]; /* band is offset table, band_stop is last coef in band */ + + Int band_length = band_stop - band_start; + if (pCodebookMap[sfb] == NOISE_HCB) + { + + tempInt = sfb_prediction_used[tot_sfb] & ltp_data_present; + + if (tempInt == FALSE) + { + /* generate random noise */ + pWindow_Coef = spec + band_start; + + tempInt = pFactors[sfb]; + + start_indx = tot_sfb++; + + /* reconstruct noise substituted values */ + /* generate random noise */ + + q_format[start_indx] = gen_rand_vector(pWindow_Coef, + band_length, + pCurrentSeed, + tempInt); + + } /* if (sfb_prediction_used[tot_sfb] == FALSE) */ + + } /* if (*(pCodebookMap++) == NOISE_HCB) */ + else + { + tot_sfb ++; /* update absolute sfb counter */ + } + + band_start = band_stop; + + } /* for (sfb) */ + + spec += pFrameInfo->coef_per_win[win_indx++]; + pFactors += num_bands; + + } + while (win_indx < partition); + + pCodebookMap += pFrameInfo->sfb_per_win[win_indx-1]; + + } + while (partition < pFrameInfo->num_win); + + + return; + +} /* pns */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.h new file mode 100644 index 00000000..a8c6c3ce --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pns_left.h @@ -0,0 +1,105 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pns_left.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Contains the function definition for pns_left.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PNS_LEFT_H +#define PNS_LEFT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pns_left( + const FrameInfo *pFrameInfo, + const Int group[], + const Int codebook_map[], + const Int factors[], + const Int sfb_prediction_used[], + const Bool ltp_data_present, + Int32 spectral_coef[], + Int q_format[], + Int32 *pCurrentSeed); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + + + + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.c new file mode 100644 index 00000000..08ee9913 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.c @@ -0,0 +1,306 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_filter_coeff.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation is achieved by means of all-pass filtering + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_all_pass_fract_delay_filter.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS] = +{ + + + { Qfmt15(0.74915491616071f), Qfmt15(0.64942584030892f), Qfmt15(0.56297290849050f) }, + { Qfmt15(0.71658296328416f), Qfmt15(0.62118993420853f), Qfmt15(0.53849582551265f) }, + { Qfmt15(0.68401101040761f), Qfmt15(0.59295402810815f), Qfmt15(0.51401874253480f) }, + { Qfmt15(0.65143905753106f), Qfmt15(0.56471812200776f), Qfmt15(0.97908331911390f) }, /* 3 */ + { Qfmt15(0.61886710465450f), Qfmt15(0.53648221590737f), Qfmt15(0.93012915315822f) }, + { Qfmt15(0.58629515177795f), Qfmt15(0.50824630980698f), Qfmt15(0.88117498720252f) }, + { Qfmt15(0.55372319890140f), Qfmt15(0.48001040370660f), Qfmt15(0.83222082124682f) }, + { Qfmt15(0.52115124602484f), Qfmt15(0.45177449760621f), Qfmt15(0.78326665529112f) }, + { Qfmt15(0.48857929314829f), Qfmt15(0.42353859150582f), Qfmt15(0.73431248933542f) }, + { Qfmt15(0.45600734027174f), Qfmt15(0.39530268540543f), Qfmt15(0.68535832337974f) }, + { Qfmt15(0.42343538739519f), Qfmt15(0.36706677930504f), Qfmt15(0.63640415742404f) }, + { Qfmt15(0.39086343451863f), Qfmt15(0.33883087320466f), Qfmt15(0.58744999146834f) }, + { Qfmt15(0.35829148164208f), Qfmt15(0.31059496710427f), Qfmt15(0.53849582551265f) }, + { Qfmt15(0.32571952876553f), Qfmt15(0.28235906100388f), Qfmt15(0.48954165955695f) }, + { Qfmt15(0.29314757588898f), Qfmt15(0.25412315490349f), Qfmt15(0.44058749360126f) }, + { Qfmt15(0.26057562301242f), Qfmt15(0.22588724880310f), Qfmt15(0.39163332764556f) }, + { Qfmt15(0.22800367013587f), Qfmt15(0.19765134270272f), Qfmt15(0.34267916168986f) }, + { Qfmt15(0.19543171725932f), Qfmt15(0.16941543660233f), Qfmt15(0.29372499573418f) }, + { Qfmt15(0.16285976438276f), Qfmt15(0.14117953050194f), Qfmt15(0.24477082977848f) }, + { Qfmt15(0.13028781150621f), Qfmt15(0.11294362440155f), Qfmt15(0.19581666382278f) }, + { Qfmt15(0.09771585862966f), Qfmt15(0.08470771830116f), Qfmt15(0.14686249786708f) }, + { Qfmt15(0.06514390575311f), Qfmt15(0.05647181220078f), Qfmt15(0.09790833191140f) }, + { Qfmt15(0.03257195287655f), Qfmt15(0.02823590610039f), Qfmt15(0.04895416595570f) } + +}; + + + + + +const Char groupBorders[NO_IID_GROUPS + 1] = +{ + 4, 5, 0, 1, 2, 3, 7, 6, 8, 9, 3, 4, + 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64 +}; + +const Char bins2groupMap[NO_IID_GROUPS] = +{ + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 +}; + + + + +/* + * q_phi = 0.39 + * + * cos(pi*([3:22]+0.5)*q_phi) + */ + + +/* + * sin(-pi*([3:22]+0.5)*q_phi) + */ + + +const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS] = +{ + 0xCB5474A9, 0x5BEC5914, 0x72F3C7B0, 0xF1F480C6, 0x8389E21E, + 0xB9BA6AFC, 0x4CDB665C, 0x7A57DA5D, 0x06088024, 0x89BECF04, + 0xA9DB5EAC, 0x3BE5711F, 0x7EB9EDF7, 0x19F582A9, 0x92DDBD1F, + 0x9C1B5008, 0x29767919, 0x7FFC0203, 0x2D3F8843, 0x9EABACDF +}; + +/* + * q(m) = { 0.43, 0.75, 0.347 } + * + * cos(pi*([3:22]+0.5)*q(m)) cos(pi*([3:22]+0.5)'*q) + * + * sin(-pi*([3:22]+0.5)*q(m)) + * + */ + + +const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3] = +{ + { 0x02037FFC, 0xCF0489BE, 0x9BFB4FE0 }, + { 0x7D5719F5, 0xCF047642, 0x18947D9E }, + { 0x34AD8B57, 0x7642CF04, 0x7ABF244A }, + { 0x99A4B325, 0x89BECF04, 0x58EFA3F1 }, + { 0x9EAB5321, 0x30FC7642, 0xD77E8694 }, + { 0x3BE5711F, 0x30FC89BE, 0x819CEBC7 }, + { 0x7B77DE39, 0x89BE30FC, 0xB3A166B8 }, + { 0xF9F88024, 0x764230FC, 0x37C57336 }, + { 0x81E8E9FE, 0xCF0489BE, 0x7FF103D2 }, + { 0xCF047642, 0xCF047642, 0x3E8B9052 }, + { 0x68B9499A, 0x7642CF04, 0xB9E594E8 }, + { 0x5EACA9DB, 0x89BECF04, 0x80A00CA5 }, + { 0xC09590D1, 0x30FC7642, 0xD05276CA }, + { 0x85A925A3, 0x30FC89BE, 0x53486134 }, + { 0x0A0B7F9B, 0x89BE30FC, 0x7CB2E319 }, + { 0x7EB91209, 0x764230FC, 0x20078412 }, + { 0x2D3F8843, 0xCF0489BE, 0xA0ECAA4D }, + { 0x9504B9BA, 0xCF047642, 0x880D2CAE }, + { 0xA4145914, 0x7642CF04, 0xF0287F04 }, + { 0x42E16D23, 0x89BECF04, 0x694C48C7 } +}; + +/* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + * + * + * f_center(k) = {0.5/4, 1.5/4, 2.5/4, 3.5/4, + * -1.5/4, -0.5/4, + * 3.5/2, 2.5/2, 4.5/2, 5.5/2}; + */ + + + +const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS] = +{ + 0x7E80EC79, 0x72BAC73D, 0x5C45A749, 0x3D398F97, 0x72BA38C3, + 0x7E801387, 0xBA919478, 0x05068019, 0x895DCFF2, 0x834E1CE7, +}; + + + + + +/* + * Fractional delay length matrix + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) + * + * q(m) = { 0.43, 0.75, 0.347 } + * f_center(k) frequency vector + * + * + * f_center(k) = { 0.5/4, 1.5/4, 2.5/4, 3.5/4, + * -1.5/4, -0.5/4, + * 3.5/2, 2.5/2, 4.5/2, 5.5/2}; + */ + +const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3] = +{ + + { 0x7E2EEA7D, 0x7A7DDAD8, 0x7ED0EE9D }, + { 0x6FEDC1E5, 0x51349D0E, 0x7574CD1E }, + { 0x5506A052, 0x0C8C809E, 0x636CAF62 }, + { 0x3085898D, 0xC3A98F1D, 0x4A0D9799 }, + { 0x6FED3E1B, 0x513462F2, 0x757432E2 }, + { 0x7E2E1583, 0x7A7D2528, 0x7ED01163 }, + { 0xA4C8A634, 0xB8E36A6E, 0xD5AF8732 }, + { 0xF0F580E3, 0x8276E707, 0x1A7382C3 }, + { 0x80ABF2F4, 0x471D6A6E, 0x9D2FAEA4 }, + { 0x9478456F, 0x7D8AE707, 0x8152EDAB } +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.h new file mode 100644 index 00000000..b97ba0ca --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_filter_coeff.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_filter_coeff.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for all pass filter coefficients + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALL_PASS_FILTER_COEFF_H +#define PS_ALL_PASS_FILTER_COEFF_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +extern const Char groupBorders[NO_IID_GROUPS + 1]; +extern const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS]; +extern const Int32 aRevLinkDelaySer[]; +extern const Int16 aFractDelayPhaseFactorReQmf[NO_QMF_ALLPASS_CHANNELS]; +extern const Int16 aFractDelayPhaseFactorImQmf[NO_QMF_ALLPASS_CHANNELS]; +/* the old center frequencies (found in "else") were too small (factor 1/2) */ +extern const Int16 aFractDelayPhaseFactorReSubQmf[SUBQMF_GROUPS]; +extern const Int16 aFractDelayPhaseFactorImSubQmf[SUBQMF_GROUPS]; +extern const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS]; +extern const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS]; +extern const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3]; +extern const Char bins2groupMap[NO_IID_GROUPS]; +extern const Int32 aaFractDelayPhaseFactorSerReQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerImQmf[NO_QMF_ALLPASS_CHANNELS][3]; +extern const Int32 aaFractDelayPhaseFactorSerReSubQmf[SUBQMF_GROUPS][3]; +extern const Int32 aaFractDelayPhaseFactorSerImSubQmf[SUBQMF_GROUPS][3]; + + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALL_PASS_FILTER_COEFF_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.c new file mode 100644 index 00000000..d7dd1915 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.c @@ -0,0 +1,386 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_fract_delay_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + Delay is introduced to compensate QMF bands not passed through Hybrid + Analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "ps_decorrelate.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" +#include "ps_all_pass_fract_delay_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +/* + * For lower subbands + * Apply all-pass filtering + * + */ + + +void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn) +{ + + Int32 cmplx; + Int16 rTmp0; + Int32 rTmp; + Int32 iTmp; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + + + + /* + * All pass filters + * 2 + * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k) + * z^(-2)*phi_fract(k)* | | ------------------------------------------------ + * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m)) + * + * + * Fractional delay matrix: + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * Vectors: a(m), q(m), d(m) are constants + * + * m m 0 1 2 + * ------------------------------- + * delay length d(m) == 3 4 5 (Fs > 32 KHz) + * fractional delay length q(m) == 0.43 0.75 0.347 + * filter coefficient a(m) == 0.65144 0.56472 0.48954 + * + * g_decay_slope(k) is given + */ + + + Int32 tmp_r; + Int32 tmp_i; + + pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay]; + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.65143905753106f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay]; + + + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.56471812200776f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = Qfmt15(0.97908331911390f); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp << 2; + + rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn); + *rIn = rTmp << 2; +} + + +void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn, + Int32 decayScaleFactor) +{ + + Int32 cmplx; + Int16 rTmp0; + Int32 rTmp; + Int32 iTmp; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + const Int16 *pt_delay; + + + + /* + * All pass filters + * 2 + * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k) + * z^(-2)*phi_fract(k)* | | ------------------------------------------------ + * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m)) + * + * + * Fractional delay matrix: + * + * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * Vectors: a(m), q(m), d(m) are constants + * + * m m 0 1 2 + * ------------------------------- + * delay length d(m) == 3 4 5 (Fs > 32 KHz) + * fractional delay length q(m) == 0.43 0.75 0.347 + * filter coefficient a(m) == 0.65144 0.56472 0.48954 + * + * g_decay_slope(k) is given + */ + + + Int32 tmp_r; + Int32 tmp_i; + + pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay]; + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + pt_delay = aRevLinkDecaySerCoeff[decayScaleFactor]; + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay++); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay++); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp; + + rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn); + *rIn = rTmp; + + pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay]; + + + cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */ + tmp_r = *pt_rTmp << 1; + tmp_i = *pt_iTmp << 1; + + rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx); + rTmp0 = *(pt_delay); + iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx); + + + iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */ + *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */ + *iIn = iTmp << 2; + + rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp); + *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn); + *rIn = rTmp << 2; + +} + + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.h new file mode 100644 index 00000000..30feccf3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_all_pass_fract_delay_filter.h @@ -0,0 +1,111 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_all_pass_fract_delay_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_all_pass_fract_delay_filter() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALL_PASS_FRACT_DELAY_FILTER_H +#define PS_ALL_PASS_FRACT_DELAY_FILTER_H + + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn); + + + void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex, + Int32 sb_delay, + const Int32 *ppFractDelayPhaseFactorSer, + Int32 ***pppRealDelayRBufferSer, + Int32 ***pppImagDelayRBufferSer, + Int32 *rIn, + Int32 *iIn, + Int32 decayScaleFactor); + +#ifdef __cplusplus +} +#endif + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALL_PASS_FRACT_DELAY_FILTER_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.c new file mode 100644 index 00000000..659a3c5e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.c @@ -0,0 +1,336 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_allocate_decoder.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reuses AAC+ HQ right channel, which is not used when PS is enabled + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef HQ_SBR + +#ifdef PARAMETRICSTEREO + +#include "s_sbr_channel.h" +#include "aac_mem_funcs.h" +#include "ps_hybrid_filter_bank_allocation.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_allocate_decoder.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 +#define Q30_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int32 aRevLinkDelaySer[] = {3, 4, 5}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_allocate_decoder(SBRDECODER_DATA *self, + UInt32 noSubSamples) +{ + Int32 i, j; + Int32 status; + + Int32 *ptr1; + Int32 *ptr2; + Int32 *ptr3; + Int32 *ptr4; + Int32 *ptr5; + Int32 *ptr6; + Int32 *ptr7; + + const Int32 pHybridResolution[] = { HYBRID_8_CPLX, + HYBRID_2_REAL, + HYBRID_2_REAL + }; + + STRUCT_PS_DEC *h_ps_dec = self->hParametricStereoDec; + + /* initialisation */ + h_ps_dec->noSubSamples = noSubSamples; + + h_ps_dec->invNoSubSamples = Q30_fmt(1.0f) / noSubSamples; + + /* + * Reuse AAC+ HQ right channel, which is not used when PS is enabled + */ + ptr1 = (Int32 *)(self->SbrChannel[1].frameData.codecQmfBufferReal[0]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + + ptr2 = (&ptr1[658]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + /* 1162 - 658 = 504 + * = NO_QMF_ALLPASS_CHANNELS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im) + */ + + ptr3 = (&ptr1[1162]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */ + /* 1426 - 1162 = 264 + * = SUBQMF_GROUPS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im) + */ + + ptr4 = (&ptr1[1426]); /* high freq generation buffers */ + + ptr5 = (&ptr1[1490]); /* high freq generation buffers */ + + ptr6 = (&ptr1[1618]); /* high freq generation buffers */ + + ptr7 = (&ptr1[1810]); /* high freq generation buffers */ + + /* whole allocation requires 1871 words, sbrQmfBufferImag has 1920 words */ + + + h_ps_dec->aPeakDecayFast = ptr1; + ptr1 += NO_BINS; + + h_ps_dec->aPrevNrg = ptr1; + ptr1 += NO_BINS; + + h_ps_dec->aPrevPeakDiff = ptr1; + ptr1 += NO_BINS; + + + + status = ps_hybrid_filter_bank_allocation(&h_ps_dec->hHybrid, + NO_QMF_CHANNELS_IN_HYBRID, + pHybridResolution, + &ptr1); + h_ps_dec->mHybridRealLeft = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridImagLeft = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridRealRight = ptr1; + ptr1 += SUBQMF_GROUPS; + + h_ps_dec->mHybridImagRight = ptr1; + ptr1 += SUBQMF_GROUPS; + + + h_ps_dec->delayBufIndex = 0; + + + + for (i = 0 ; i < NO_DELAY_CHANNELS ; i++) /* 41 */ + { + if (i < SHORT_DELAY_START) /* 12 */ + { + h_ps_dec->aNoSampleDelay[i] = LONG_DELAY; + } + else + { + h_ps_dec->aNoSampleDelay[i] = SHORT_DELAY; + } + } + + + h_ps_dec->aaRealDelayBufferQmf = (Int32 **)ptr6; + ptr6 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaImagDelayBufferQmf = (Int32 **)ptr7; + ptr7 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaRealDelayBufferSubQmf = (Int32 **)ptr1; + ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32); + + h_ps_dec->aaImagDelayBufferSubQmf = (Int32 **)ptr1; + ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32); + + for (i = 0; i < NO_QMF_ICC_CHANNELS; i++) /* 61 */ + { + int delay; + + if (i < NO_QMF_ALLPASS_CHANNELS) /* 20 */ + { + delay = 2; + h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr4; + ptr4 += delay; + + h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr5; + ptr5 += delay; + } + else + { + + if (i >= (NO_QMF_ALLPASS_CHANNELS + SHORT_DELAY_START)) + { + delay = SHORT_DELAY; + } + else + { + delay = LONG_DELAY; + } + + h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr1; + ptr1 += delay; + + h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr1; + ptr1 += delay; + } + } + + for (i = 0; i < SUBQMF_GROUPS; i++) + { + h_ps_dec->aaRealDelayBufferSubQmf[i] = (Int32 *)ptr1; + ptr1 += DELAY_ALLPASS; + + h_ps_dec->aaImagDelayBufferSubQmf[i] = (Int32 *)ptr1; + ptr1 += DELAY_ALLPASS; + + } + + for (i = 0 ; i < NO_SERIAL_ALLPASS_LINKS ; i++) /* NO_SERIAL_ALLPASS_LINKS == 3 */ + { + + h_ps_dec->aDelayRBufIndexSer[i] = 0; + + h_ps_dec->aaaRealDelayRBufferSerQmf[i] = (Int32 **)ptr2; + ptr2 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaImagDelayRBufferSerQmf[i] = (Int32 **)ptr2; + ptr2 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaRealDelayRBufferSerSubQmf[i] = (Int32 **)ptr3; + ptr3 += aRevLinkDelaySer[i]; + + h_ps_dec->aaaImagDelayRBufferSerSubQmf[i] = (Int32 **)ptr3; + ptr3 += aRevLinkDelaySer[i]; + + for (j = 0; j < aRevLinkDelaySer[i]; j++) + { + h_ps_dec->aaaRealDelayRBufferSerQmf[i][j] = ptr2; + ptr2 += NO_QMF_ALLPASS_CHANNELS; /* NO_QMF_ALLPASS_CHANNELS == 20 */ + + h_ps_dec->aaaImagDelayRBufferSerQmf[i][j] = ptr2; + ptr2 += NO_QMF_ALLPASS_CHANNELS; + + h_ps_dec->aaaRealDelayRBufferSerSubQmf[i][j] = ptr3; + ptr3 += SUBQMF_GROUPS; + + h_ps_dec->aaaImagDelayRBufferSerSubQmf[i][j] = ptr3; + ptr3 += SUBQMF_GROUPS; + + } + } + + + for (i = 0; i < NO_IID_GROUPS; i++) /* NO_IID_GROUPS == 22 */ + { + h_ps_dec->h11Prev[i] = Q30_fmt(1.0f); + h_ps_dec->h12Prev[i] = Q30_fmt(1.0f); + } + + + + return status; +} /*END CreatePsDec*/ +#endif + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.h new file mode 100644 index 00000000..db3f470b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_allocate_decoder.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_allocate_decoder.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_allocate_decoder() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_ALLOCATE_DECODER_H +#define PS_ALLOCATE_DECODER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_allocate_decoder(SBRDECODER_DATA *self, + UInt32 noSubSamples); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_ALLOCATE_DECODER_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.c new file mode 100644 index 00000000..c0e16d2b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.c @@ -0,0 +1,211 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_applied.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Applies Parametric Stereo Tool to a QMF-analized mono signal + providing a stereo image as output + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "aac_mem_funcs.h" +#include "ps_stereo_processing.h" +#include "ps_decorrelate.h" +#include "ps_hybrid_synthesis.h" +#include "ps_hybrid_analysis.h" +#include "ps_applied.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_applied(STRUCT_PS_DEC *h_ps_dec, + Int32 rIntBufferLeft[][64], + Int32 iIntBufferLeft[][64], + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[], + Int32 band) + +{ + + /* + * Get higher frequency resolution in the lower QMF subbands + * creating sub-subbands + */ + ps_hybrid_analysis(rIntBufferLeft, + iIntBufferLeft, + h_ps_dec->mHybridRealLeft, + h_ps_dec->mHybridImagLeft, + h_ps_dec->hHybrid, + scratch_mem, + band); + + /* + * By means of delaying and all-pass filtering, sub-subbands of + * left ch. are decorrelate to creates right ch. sub-subbands + */ + + ps_decorrelate(h_ps_dec, + *rIntBufferLeft, + *iIntBufferLeft, + rIntBufferRight, + iIntBufferRight, + scratch_mem); + + /* + * sub-subbands of left and right ch. are processed according to + * stereo clues. + */ + + ps_stereo_processing(h_ps_dec, + *rIntBufferLeft, + *iIntBufferLeft, + rIntBufferRight, + iIntBufferRight); + + /* + * Reconstruct stereo signals + */ + + ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealLeft, + (const Int32*)h_ps_dec->mHybridImagLeft, + *rIntBufferLeft, + *iIntBufferLeft, + h_ps_dec->hHybrid); + + ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealRight, + (const Int32*)h_ps_dec->mHybridImagRight, + rIntBufferRight, + iIntBufferRight, + h_ps_dec->hHybrid); + +}/* END ps_applied */ +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.h new file mode 100644 index 00000000..66e5d6c8 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_applied.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_applied.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_applied() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_APPLIED_H +#define PS_APPLIED_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_applied(STRUCT_PS_DEC *h_ps_dec, + Int32 rIntBufferLeft[][64], + Int32 iIntBufferLeft[][64], + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[], + Int32 band); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_APPLIED_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.c new file mode 100644 index 00000000..6585086f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.c @@ -0,0 +1,299 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_bstr_decoding.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes parametric stereo + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "aac_mem_funcs.h" +#include "ps_bstr_decoding.h" +#include "ps_decode_bs_utils.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const Int32 aNoIidBins[3] = {NO_LOW_RES_IID_BINS, NO_IID_BINS, NO_HI_RES_BINS}; +const Int32 aNoIccBins[3] = {NO_LOW_RES_ICC_BINS, NO_ICC_BINS, NO_HI_RES_BINS}; +const Int32 aFixNoEnvDecode[4] = {0, 1, 2, 4}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_bstr_decoding(STRUCT_PS_DEC *ps_dec) +{ + UInt32 env; + Int32 noIidSteps; + + if (!ps_dec->bPsDataAvail) + { + ps_dec->noEnv = 0; + } + + noIidSteps = ps_dec->bFineIidQ ? NO_IID_STEPS_FINE : NO_IID_STEPS; + + for (env = 0; env < ps_dec->noEnv; env++) + { + Int32 *aPrevIidIndex; + Int32 *aPrevIccIndex; + if (env == 0) + { + aPrevIidIndex = ps_dec->aIidPrevFrameIndex; + aPrevIccIndex = ps_dec->aIccPrevFrameIndex; + } + else + { + aPrevIidIndex = ps_dec->aaIidIndex[env-1]; + aPrevIccIndex = ps_dec->aaIccIndex[env-1]; + } + + /* + * Differential Decoding of IID parameters over time/frequency + */ + differential_Decoding(ps_dec->bEnableIid, + ps_dec->aaIidIndex[env], + aPrevIidIndex, + ps_dec->abIidDtFlag[env], + aNoIidBins[ps_dec->freqResIid], + (ps_dec->freqResIid) ? 1 : 2, + -noIidSteps, + noIidSteps); + + /* + * Differential Decoding of ICC parameters over time/frequency + */ + differential_Decoding(ps_dec->bEnableIcc, + ps_dec->aaIccIndex[env], + aPrevIccIndex, + ps_dec->abIccDtFlag[env], + aNoIccBins[ps_dec->freqResIcc], + (ps_dec->freqResIcc) ? 1 : 2, + 0, + NO_ICC_STEPS - 1); + + + } /* for (env=0; envnoEnv; env++) */ + + if (ps_dec->noEnv == 0) + { + ps_dec->noEnv = 1; + + if (ps_dec->bEnableIid) + { /* NO_HI_RES_BINS == 34 */ + pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv-1], + ps_dec->aIidPrevFrameIndex, + NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex)); + + } + else + { + pv_memset((void *)ps_dec->aaIidIndex[ps_dec->noEnv-1], + 0, + NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex)); + } + if (ps_dec->bEnableIcc) + { + pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv-1], + ps_dec->aIccPrevFrameIndex, + NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex)); + } + else + { + pv_memset((void *)ps_dec->aaIccIndex[ps_dec->noEnv-1], + 0, + NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex)); + } + } + + pv_memmove(ps_dec->aIidPrevFrameIndex, + ps_dec->aaIidIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex)); + + pv_memmove(ps_dec->aIccPrevFrameIndex, + ps_dec->aaIccIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex)); + + ps_dec->bPsDataAvail = 0; + + if (ps_dec->bFrameClass == 0) + { + Int32 shift; + + shift = ps_dec->noEnv >> 1; + + ps_dec->aEnvStartStop[0] = 0; + + for (env = 1; env < ps_dec->noEnv; env++) + { + ps_dec->aEnvStartStop[env] = + (env * ps_dec->noSubSamples) >> shift; + } + + ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples; + } + else + { /* if (ps_dec->bFrameClass != 0) */ + ps_dec->aEnvStartStop[0] = 0; + + if (ps_dec->aEnvStartStop[ps_dec->noEnv] < ps_dec->noSubSamples) + { + ps_dec->noEnv++; + ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples; + + pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv], + ps_dec->aaIidIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex)); + + pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv], + ps_dec->aaIccIndex[ps_dec->noEnv-1], + NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex)); + } + + for (env = 1; env < ps_dec->noEnv; env++) + { + UInt32 thr; + thr = ps_dec->noSubSamples - ps_dec->noEnv + env; + + if (ps_dec->aEnvStartStop[env] > thr) + { + ps_dec->aEnvStartStop[env] = thr; + } + else + { + thr = ps_dec->aEnvStartStop[env-1] + 1; + + if (ps_dec->aEnvStartStop[env] < thr) + { + ps_dec->aEnvStartStop[env] = thr; + } + } + } + } /* if (ps_dec->bFrameClass == 0) ... else */ + + for (env = 0; env < ps_dec->noEnv; env++) + { + if (ps_dec->freqResIid == 2) + { + map34IndexTo20(ps_dec->aaIidIndex[env]); + } + if (ps_dec->freqResIcc == 2) + { + map34IndexTo20(ps_dec->aaIccIndex[env]); + } + } + + +} + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.h new file mode 100644 index 00000000..e68ace9e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_bstr_decoding.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_bstr_decoding.h +j +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_bstr_decoding() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_BSTR_DECODING_H +#define PS_BSTR_DECODING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int32 aNoIidBins[3]; +extern const Int32 aNoIccBins[3]; + +extern const Int32 aFixNoEnvDecode[4]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_bstr_decoding(STRUCT_PS_DEC *h_ps_dec); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_BSTR_DECODING_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.c new file mode 100644 index 00000000..44326216 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.c @@ -0,0 +1,276 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_channel_filtering.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "aac_mem_funcs.h" +#include "ps_fft_rx8.h" +#include "ps_channel_filtering.h" +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) + (a>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void two_ch_filtering(const Int32 *pQmf_r, + const Int32 *pQmf_i, + Int32 *mHybrid_r, + Int32 *mHybrid_i) +{ + + Int32 cum0; + Int32 cum1; + Int32 cum2; + Int32 tmp1; + Int32 tmp2; + + tmp1 = pQmf_r[ 1] + pQmf_r[11]; + tmp2 = pQmf_i[ 1] + pQmf_i[11]; + cum1 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp1); + cum2 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp2); + tmp1 = pQmf_r[ 3] + pQmf_r[ 9]; + tmp2 = pQmf_i[ 3] + pQmf_i[ 9]; + cum1 = fxp_msu32_Q31(cum1, Qfmt31(0.14586278335076f), tmp1); + cum2 = fxp_msu32_Q31(cum2, Qfmt31(0.14586278335076f), tmp2); + tmp1 = pQmf_r[ 5] + pQmf_r[ 7]; + tmp2 = pQmf_i[ 5] + pQmf_i[ 7]; + cum1 = fxp_mac32_Q31(cum1, Qfmt31(0.61193261090336f), tmp1); + cum2 = fxp_mac32_Q31(cum2, Qfmt31(0.61193261090336f), tmp2); + + cum0 = pQmf_r[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ + + mHybrid_r[0] = (cum0 + cum1); + mHybrid_r[1] = (cum0 - cum1); + + cum0 = pQmf_i[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */ + + mHybrid_i[0] = (cum0 + cum2); + mHybrid_i[1] = (cum0 - cum2); + +} + + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void eight_ch_filtering(const Int32 *pQmfReal, + const Int32 *pQmfImag, + Int32 *mHybridReal, + Int32 *mHybridImag, + Int32 scratch_mem[]) + +{ + + Int32 real; + Int32 imag; + Int32 tmp1; + Int32 tmp2; + + real = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfReal[ 4]); + + real = fxp_mac32_Q31(real, Qfmt31(0.01055120626280f), pQmfReal[12]); + imag = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfImag[ 4]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.01055120626280f), pQmfImag[12]); + + mHybridReal[2] = (imag - real); + mHybridImag[2] = -(imag + real); + + real = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfReal[ 3]); + + real = fxp_mac32_Q31(real, Qfmt31(0.04540841899650f), pQmfReal[11]); + imag = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfImag[ 3]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.04540841899650f), pQmfImag[11]); + + tmp1 = fxp_mul32_Q29(Q29_fmt(-0.38268343236509f), real); + mHybridReal[3] = fxp_mac32_Q29(Q29_fmt(0.92387953251129f), imag, tmp1); + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); + mHybridImag[3] = fxp_mac32_Q29(Q29_fmt(-0.38268343236509f), imag, tmp2); + + + mHybridImag[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfReal[ 2] - pQmfReal[10])); + mHybridReal[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfImag[10] - pQmfImag[ 2])); + + + real = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfReal[ 1]); + + real = fxp_mac32_Q31(real, Qfmt31(0.14532227859182f), pQmfReal[ 9]); + imag = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfImag[ 1]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.14532227859182f), pQmfImag[ 9]); + + tmp1 = fxp_mul32_Q29(Q29_fmt(0.92387953251129f), imag); + + mHybridReal[5] = fxp_mac32_Q31(tmp1, Qfmt31(0.76536686473018f), real); + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real); + + mHybridImag[5] = fxp_mac32_Q31(tmp2, Qfmt31(0.76536686473018f), imag); + + real = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfReal[ 0]); + + real = fxp_mac32_Q31(real, Qfmt31(0.13979654612668f), pQmfReal[ 8]); + imag = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfImag[ 0]); + + imag = fxp_mac32_Q31(imag, Qfmt31(0.13979654612668f), pQmfImag[ 8]); + + mHybridReal[6] = (imag + real); + mHybridImag[6] = (imag - real); + + + tmp1 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfReal[ 7]); + mHybridReal[7] = fxp_mac32_Q31(tmp1, Qfmt31(0.09026515280366f), pQmfImag[ 7]); + + tmp2 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfReal[ 7]); + + mHybridImag[7] = fxp_mac32_Q31(tmp2, Qfmt31(0.21791935610828f), pQmfImag[ 7]); + + mHybridReal[0] = pQmfReal[HYBRID_FILTER_DELAY] >> 3; + mHybridImag[0] = pQmfImag[HYBRID_FILTER_DELAY] >> 3; + + tmp1 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfImag[ 5]); + + mHybridReal[1] = fxp_mac32_Q31(tmp1, Qfmt31(0.21791935610828f), pQmfReal[ 5]); + + + tmp2 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfImag[ 5]); + mHybridImag[1] = fxp_mac32_Q31(tmp2, Qfmt31(0.09026515280366f), pQmfReal[ 5]); + + /* + * 8*ifft + */ + + ps_fft_rx8(mHybridReal, mHybridImag, scratch_mem); + +} + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.h new file mode 100644 index 00000000..94c3615b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_channel_filtering.h @@ -0,0 +1,98 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_channel_filtering.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions two_ch_filtering() + and eight_ch_filtering() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_CHANNEL_FILTERING_H +#define PS_CHANNEL_FILTERING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void two_ch_filtering(const Int32 *pQmf_r, + const Int32 *pQmf_i, + Int32 *mHybrid_r, + Int32 *mHybrid_i); + + + void eight_ch_filtering(const Int32 *pQmfReal, + const Int32 *pQmfImag, + Int32 *mHybridReal, + Int32 *mHybridImag, + Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_CHANNEL_FILTERING_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_constants.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_constants.h new file mode 100644 index 00000000..d5b2ad4b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_constants.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/**************************************************************************** +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. +*******************************************************************************/ +/* +*/ +#ifndef PS_CONSTANTS_H +#define PS_CONSTANTS_H + + +#define NO_SUB_QMF_CHANNELS 12 +#define NO_QMF_CHANNELS_IN_HYBRID 3 +#define NO_QMF_CHANNELS 64 +#define NO_ALLPASS_CHANNELS 23 +#define NO_DELAY_CHANNELS (NO_QMF_CHANNELS-NO_ALLPASS_CHANNELS) +#define DELAY_ALLPASS 2 +#define SHORT_DELAY_START 12 +#define SHORT_DELAY 1 +#define LONG_DELAY 14 +#define NO_QMF_ALLPASS_CHANNELS (NO_ALLPASS_CHANNELS-NO_QMF_CHANNELS_IN_HYBRID) +#define NO_QMF_ICC_CHANNELS (NO_QMF_ALLPASS_CHANNELS+NO_DELAY_CHANNELS) +#define HYBRIDGROUPS 8 +#define DECAY_CUTOFF 3 +#define NO_SERIAL_ALLPASS_LINKS 3 +#define MAX_NO_PS_ENV 5 +#define NEGATE_IPD_MASK ( 0x00001000 ) +#define NO_BINS ( 20 ) +#define NO_HI_RES_BINS ( 34 ) +#define NO_LOW_RES_BINS ( NO_IID_BINS / 2 ) +#define NO_IID_BINS ( NO_BINS ) +#define NO_ICC_BINS ( NO_BINS ) +#define NO_LOW_RES_IID_BINS ( NO_LOW_RES_BINS ) +#define NO_LOW_RES_ICC_BINS ( NO_LOW_RES_BINS ) +#define SUBQMF_GROUPS ( 10 ) +#define QMF_GROUPS ( 12 ) +#define NO_IID_GROUPS ( SUBQMF_GROUPS + QMF_GROUPS ) +#define NO_IID_STEPS ( 7 ) +#define NO_IID_STEPS_FINE ( 15 ) +#define NO_ICC_STEPS ( 8 ) +#define NO_IID_LEVELS ( 2 * NO_IID_STEPS + 1 ) +#define NO_IID_LEVELS_FINE ( 2 * NO_IID_STEPS_FINE + 1 ) +#define NO_ICC_LEVELS ( NO_ICC_STEPS ) + + + +#endif /* PS_CONSTANTS_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.c new file mode 100644 index 00000000..4694e84e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.c @@ -0,0 +1,269 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decode_bs_utils.cpp + + Functions: + GetNrBitsAvailable + differential_Decoding + map34IndexTo20 + limitMinMax + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decode bitstream parametric stereo's utilities + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "aac_mem_funcs.h" +#include "s_ps_dec.h" +#include "ps_decode_bs_utils.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf) +{ + + return (hBitBuf->bufferLen - hBitBuf->nrBitsRead); +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +; +; Differential Decoding of parameters over time/frequency +----------------------------------------------------------------------------*/ + +void differential_Decoding(Int32 enable, + Int32 *aIndex, + Int32 *aPrevFrameIndex, + Int32 DtDf, + Int32 nrElements, + Int32 stride, + Int32 minIdx, + Int32 maxIdx) +{ + Int32 i; + Int32 *ptr_aIndex; + + if (enable == 1) + { + ptr_aIndex = aIndex; + + if (DtDf == 0) + { + *(ptr_aIndex) = limitMinMax(*ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + + for (i = 1; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aIndex[i-1] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + else + { + if (stride == 1) + { + for (i = 0; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[i] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + else + { + for (i = 0; i < nrElements; i++) + { + *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[(i<<1)] + *ptr_aIndex, minIdx, maxIdx); + ptr_aIndex++; + } + } + } + } + else + { + pv_memset((void *)aIndex, 0, nrElements*sizeof(*aIndex)); + } + if (stride == 2) + { + for (i = (nrElements << 1) - 1; i > 0; i--) + { + aIndex[i] = aIndex[(i>>1)]; + } + } +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE + map34IndexTo20 +----------------------------------------------------------------------------*/ + +void map34IndexTo20(Int32 *aIndex) +{ + + aIndex[ 0] = ((aIndex[0] << 1) + aIndex[1]) / 3; + aIndex[ 1] = (aIndex[1] + (aIndex[2] << 1)) / 3; + aIndex[ 2] = ((aIndex[3] << 1) + aIndex[4]) / 3; + aIndex[ 3] = (aIndex[4] + (aIndex[5] << 1)) / 3; + aIndex[ 4] = (aIndex[ 6] + aIndex[7]) >> 1; + aIndex[ 5] = (aIndex[ 8] + aIndex[9]) >> 1; + aIndex[ 6] = aIndex[10]; + aIndex[ 7] = aIndex[11]; + aIndex[ 8] = (aIndex[12] + aIndex[13]) >> 1; + aIndex[ 9] = (aIndex[14] + aIndex[15]) >> 1; + aIndex[10] = aIndex[16]; + aIndex[11] = aIndex[17]; + aIndex[12] = aIndex[18]; + aIndex[13] = aIndex[19]; + aIndex[14] = (aIndex[20] + aIndex[21]) >> 1; + aIndex[15] = (aIndex[22] + aIndex[23]) >> 1; + aIndex[16] = (aIndex[24] + aIndex[25]) >> 1; + aIndex[17] = (aIndex[26] + aIndex[27]) >> 1; + aIndex[18] = (aIndex[28] + aIndex[29] + aIndex[30] + aIndex[31]) >> 2; + aIndex[19] = (aIndex[32] + aIndex[33]) >> 1; +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE + limitMinMax +----------------------------------------------------------------------------*/ + + +Int32 limitMinMax(Int32 i, + Int32 min, + Int32 max) +{ + if (i < max) + { + if (i > min) + { + return i; + } + else + { + return min; + } + } + else + { + return max; + } +} + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.h new file mode 100644 index 00000000..188d9a95 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decode_bs_utils.h @@ -0,0 +1,106 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decode_bs_utils.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions differential_Decoding(), limitMinMax(), + GetNrBitsAvailable(), map34IndexTo20() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_DECODE_BS_UTILS_H +#define PS_DECODE_BS_UTILS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "s_bit_buffer.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void differential_Decoding(Int32 enable, + Int32 *aIndex, + Int32 *aPrevFrameIndex, + Int32 DtDf, + Int32 nrElements, + Int32 stride, + Int32 minIdx, + Int32 maxIdx); + + Int32 limitMinMax(Int32 i, + Int32 min, + Int32 max); + + Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf); + + void map34IndexTo20(Int32 *aIndex); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_DECODE_BS_UTILS_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.c new file mode 100644 index 00000000..e8ce926c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.c @@ -0,0 +1,494 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decorrelate.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + Delay is introduced to compensate QMF bands not passed through Hybrid + Analysis + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "pv_audio_type_defs.h" +#include "ps_decorrelate.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" +#include "ps_all_pass_fract_delay_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[]) +{ + Int32 sb; + Int32 maxsb; + Int32 gr; + Int32 sb_delay; + Int32 bin; + + + + + Int32 *aLeftReal; + Int32 *aLeftImag; + Int32 *aRightReal; + Int32 *aRightImag; + + Int32 *aTransRatio = scratch_mem; /* use NO_BINS == 20 */ + + + Int32 ***pppRealDelayRBufferSer; + Int32 ***pppImagDelayRBufferSer; + + Int32 **ppRealDelayBuffer; + Int32 **ppImagDelayBuffer; + + const Int32(*ppFractDelayPhaseFactorSer)[3]; + /* + * Power transient estimation and detection + */ + + + ps_pwr_transient_detection(h_ps_dec, + rIntBufferLeft, + iIntBufferLeft, + aTransRatio); + + + aLeftReal = h_ps_dec->mHybridRealLeft; + aLeftImag = h_ps_dec->mHybridImagLeft; + aRightReal = h_ps_dec->mHybridRealRight; + aRightImag = h_ps_dec->mHybridImagRight; + + pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerSubQmf; + pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerSubQmf; + + ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferSubQmf; + ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferSubQmf; + + + + ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerSubQmf; + + + /* + * NO_IID_GROUPS (SUBQMF_GROUPS (12) + QMF_GROUPS (10)) == 22 + */ + + for (gr = 0; gr < SUBQMF_GROUPS; gr++) /* 0 to 9 */ + { + Int32 rIn; + Int32 iIn; + Int32 *pt_rTmp; + Int32 *pt_iTmp; + Int32 rTmp; + Int32 cmplx; + Int32 tmp1, tmp2; + + /* sb = subQMF/QMF subband */ + + sb = groupBorders[gr]; + + /* + * For lower subbands + * Apply all-pass filtering + * + */ + pt_rTmp = &ppRealDelayBuffer[sb][h_ps_dec->delayBufIndex]; + pt_iTmp = &ppImagDelayBuffer[sb][h_ps_dec->delayBufIndex]; + + tmp1 = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + rIn = *pt_rTmp >> 1; + iIn = *pt_iTmp >> 1; + + + *pt_rTmp = tmp1; + *pt_iTmp = tmp2; + + /* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + */ + + cmplx = aFractDelayPhaseFactorSubQmf[sb]; + + aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx); + aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx); + + ps_all_pass_fract_delay_filter_type_I(h_ps_dec->aDelayRBufIndexSer, + sb, + ppFractDelayPhaseFactorSer[sb], + pppRealDelayRBufferSer, + pppImagDelayRBufferSer, + &aRightReal[sb], + &aRightImag[sb]); + + bin = bins2groupMap[gr]; + rTmp = aTransRatio[bin]; + + if (rTmp != 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1; + } + + + } /* gr */ + + aLeftReal = rIntBufferLeft; + aLeftImag = iIntBufferLeft; + aRightReal = rIntBufferRight; + aRightImag = iIntBufferRight; + + pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerQmf; + pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerQmf; + + ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferQmf; + ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferQmf; + + + + ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerQmf; + + + for (gr = SUBQMF_GROUPS; gr < NO_BINS; gr++) /* 10 to 20 */ + { + + maxsb = min(h_ps_dec->usb, groupBorders[gr+1]); + + /* sb = subQMF/QMF subband */ + + for (sb = groupBorders[gr]; sb < maxsb; sb++) + { + + Int32 rIn, iIn; + Int32 *pt_rTmp, *pt_iTmp; + Int32 cmplx; + Int32 tmp1, tmp2; + Int32 rTmp; + + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* NO_QMF_CHANNELS_IN_HYBRID == 3 */ + + /* + * For lower subbands + * Apply all-pass filtering + * + */ + pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->delayBufIndex]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->delayBufIndex]; + + rIn = *pt_rTmp >> 1; + iIn = *pt_iTmp >> 1; + + tmp1 = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + *pt_rTmp = tmp1; + *pt_iTmp = tmp2; + + /* + * Fractional delay vector + * + * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS + * + * q_phi = 0.39 + * f_center(k) frequency vector + */ + + cmplx = aFractDelayPhaseFactor[sb_delay]; + aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx); + aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx); + + ps_all_pass_fract_delay_filter_type_II(h_ps_dec->aDelayRBufIndexSer, + sb_delay, + ppFractDelayPhaseFactorSer[sb_delay], + pppRealDelayRBufferSer, + pppImagDelayRBufferSer, + &aRightReal[sb], + &aRightImag[sb], + sb); + + rTmp = aTransRatio[gr-2]; + if (rTmp != 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1; + } + + + } /* sb */ + + } + + + maxsb = min(h_ps_dec->usb, 35); /* 35 == groupBorders[NO_BINS + 1] */ + + /* sb = subQMF/QMF subband */ + { + Int32 factor = aTransRatio[NO_BINS-2]; + + for (sb = 23; sb < maxsb; sb++) /* 23 == groupBorders[NO_BINS] */ + { + + Int32 tmp, tmp2; + Int32 *pt_rTmp, *pt_iTmp; + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */ + + /* + * For the Upper Bands apply delay only + * -D(k) + * Apply Delay H_k(z) = z , D(k) == 1 or 14 + * + */ + Int32 k = sb - NO_ALLPASS_CHANNELS; /* == 23 */ + + + pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]]; + + if (++h_ps_dec->aDelayBufIndex[ k] >= LONG_DELAY) /* == 14 */ + { + h_ps_dec->aDelayBufIndex[ k] = 0; + } + + + tmp = *pt_rTmp; + tmp2 = *pt_iTmp; + + if (aTransRatio[NO_BINS-2] < 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(factor, tmp) << 1; + aRightImag[sb] = fxp_mul32_Q31(factor, tmp2) << 1; + } + else + { + aRightReal[sb] = tmp; + aRightImag[sb] = tmp2; + } + + + tmp = aLeftReal[sb]; + tmp2 = aLeftImag[sb]; + *pt_rTmp = tmp; + *pt_iTmp = tmp2; + + + } /* sb */ + } + + + maxsb = min(h_ps_dec->usb, 64); /* 64 == groupBorders[NO_BINS+2] */ + + /* sb = subQMF/QMF subband */ + + { + + for (sb = 35; sb < maxsb; sb++) /* 35 == groupBorders[NO_BINS+1] */ + { + + Int32 *pt_rTmp, *pt_iTmp; + + sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */ + + /* + * For the Upper Bands apply delay only + * -D(k) + * Apply Delay H_k(z) = z , D(k) == 1 or 14 + * + */ + + pt_rTmp = &ppRealDelayBuffer[sb_delay][0]; + pt_iTmp = &ppImagDelayBuffer[sb_delay][0]; + + aRightReal[sb] = *pt_rTmp; + aRightImag[sb] = *pt_iTmp; + + + if (aTransRatio[NO_BINS-1] < 0x7FFFFFFF) + { + aRightReal[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightReal[sb]) << 1; + aRightImag[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightImag[sb]) << 1; + } + + *pt_rTmp = aLeftReal[sb]; + *pt_iTmp = aLeftImag[sb]; + + + } /* sb */ + } + + + if (++h_ps_dec->delayBufIndex >= DELAY_ALLPASS) + { + h_ps_dec->delayBufIndex = 0; + } + + if (++h_ps_dec->aDelayRBufIndexSer[0] >= 3) + { + h_ps_dec->aDelayRBufIndexSer[0] = 0; + } + if (++h_ps_dec->aDelayRBufIndexSer[1] >= 4) + { + h_ps_dec->aDelayRBufIndexSer[1] = 0; + } + if (++h_ps_dec->aDelayRBufIndexSer[2] >= 5) + { + h_ps_dec->aDelayRBufIndexSer[2] = 0; + } + + +} /* END deCorrelate */ +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.h new file mode 100644 index 00000000..550195ba --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_decorrelate.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_decorrelate.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_decorrelate() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_DECORRELATE_H +#define PS_DECORRELATE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 *rIntBufferRight, + Int32 *iIntBufferRight, + Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_DECORRELATE_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.c new file mode 100644 index 00000000..6fc4818e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.c @@ -0,0 +1,290 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_fft_rx8.cpp + Functions: ps_fft_rx8 + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Real Vector of Real components size 8 + + Imag Vector of Imag components size 8 + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + scratch_mem size 32 + + Outputs: + In-place calculation of a 8-point FFT (radix-8) + + Pointers and Buffers Modified: + calculation are done in-place and returned in Data + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + 8-point DFT, radix 8 with Decimation in Frequency + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should provide a fixed point FFT for any input array + of size power of 8. + +------------------------------------------------------------------------------ + REFERENCES + + [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling, + C. Nikias, Macmillan Pub. Co. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + MODIFY( x[] ) + RETURN( exponent ) + +------------------------------------------------------------------------------ +*/ +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#ifdef PARAMETRICSTEREO + + +#include "pv_audio_type_defs.h" +#include "ps_fft_rx8.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]) + +/* scratch_mem size 32 */ +{ + + Int i; + Int32 *Q = &scratch_mem[0]; + Int32 *Z = &scratch_mem[16]; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp4; + Int32 aux_r[2]; + Int32 aux_i[2]; + Int32 *pt_r1 = &Re[0]; + Int32 *pt_r2 = &Re[4]; + Int32 *pt_i1 = &Im[0]; + Int32 *pt_i2 = &Im[4]; + + Int32 *pt_Q = Q; + Int32 *pt_Z = Z; + + + temp1 = *(pt_r1++); /* Real */ + temp2 = *(pt_r2++); /* Real */ + temp3 = *(pt_i1++); /* Imag */ + temp4 = *(pt_i2++); /* Imag */ + /* + * Vector Q stores data as Real, Imag, Real, Imag,.... + */ + + *(pt_Q++) = temp1 + temp2; /* Q(0) = v(0) + v(4) */ + *(pt_Q++) = temp3 + temp4; + *(pt_Q++) = temp1 - temp2; /* Q(1) = v(0) - v(4) */ + *(pt_Q++) = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + *(pt_Q++) = temp1 + temp2; /* Q(2) = v(1) + v(5) */ + *(pt_Q++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; /* aux[0] = v(1) - v(5) */ + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + *(pt_Q++) = temp1 + temp2; /* Q(3) = v(2) + v(6) */ + *(pt_Q++) = temp3 + temp4; + *(pt_Q++) = temp4 - temp3; /* Q(4) = (v(2) - v(6))*j */ + *(pt_Q++) = temp1 - temp2; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_i1++); + temp4 = *(pt_i2++); + + + *(pt_Q++) = temp1 + temp2; /* Q(5) = v(3) + v(7) */ + *(pt_Q++) = temp3 + temp4; + aux_r[1] = temp1 - temp2; /* aux[1] = v(3) - v(7) */ + aux_i[1] = temp3 - temp4; + /* Q(6) = (aux[0] - aux[1])/sqrt(2); */ + *(pt_Q++) = fxp_mul32_Q29((aux_r[0] - aux_r[1]), Q29_fmt(0.70710678118655f)); + *(pt_Q++) = fxp_mul32_Q29((aux_i[0] - aux_i[1]), Q29_fmt(0.70710678118655f)); + + /* Q(7) = (aux[0] + aux[1])*j/sqrt(2); */ + *(pt_Q++) = fxp_mul32_Q29((aux_i[0] + aux_i[1]), Q29_fmt(-0.70710678118655f)); + *(pt_Q) = fxp_mul32_Q29((aux_r[0] + aux_r[1]), Q29_fmt(0.70710678118655f)); + + pt_r1 = &Q[0]; /* reset pointer */ + pt_r2 = &Q[6]; /* reset pointer */ + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1++); + temp4 = *(pt_r2++); + + /* + * Vector Z stores data as Real, Imag, Real, Imag,.... + */ + + *(pt_Z++) = temp1 + temp2; /* Q(0) + Q(3) */ + *(pt_Z++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1++); + temp4 = *(pt_r2++); + + *(pt_Z++) = temp1 + temp2; /* Q(1) + Q(4) */ + *(pt_Z++) = temp3 + temp4; + *(pt_Z++) = aux_r[0]; /* Q(0) - Q(3) */ + *(pt_Z++) = aux_i[0]; + *(pt_Z++) = temp1 - temp2; /* Q(1) - Q(4) */ + *(pt_Z++) = temp3 - temp4; + + temp1 = *(pt_r1++); + temp2 = *(pt_r2++); + temp3 = *(pt_r1); + temp4 = *(pt_r2++); + + *(pt_Z++) = temp1 + temp2; /* Q(2) + Q(5) */ + *(pt_Z++) = temp3 + temp4; + aux_r[0] = temp1 - temp2; + aux_i[0] = temp3 - temp4; + + temp1 = *(pt_r2++); + temp3 = *(pt_r2++); + temp2 = *(pt_r2++); + temp4 = *(pt_r2); + + *(pt_Z++) = temp1 + temp2; /* Q(6) + Q(7) */ + *(pt_Z++) = temp3 + temp4; + + *(pt_Z++) = -aux_i[0]; /* (Q(2) - Q(5))*j */ + *(pt_Z++) = aux_r[0]; + + *(pt_Z++) = temp2 - temp1; /* -Q(6) + Q(7) */ + *(pt_Z) = temp4 - temp3; + + pt_Z = &Z[0]; /* reset pointer */ + pt_Q = &Z[8]; /* reset pointer */ + + pt_r1 = &Re[0]; + pt_r2 = &Re[4]; + pt_i1 = &Im[0]; + pt_i2 = &Im[4]; + + + for (i = 4; i != 0; i--) + { + temp1 = *(pt_Z++); + temp2 = *(pt_Q++); + temp3 = *(pt_Z++); + temp4 = *(pt_Q++); + + *(pt_r1++) = temp1 + temp2; /* Z(n) + Z(n+4) */ + *(pt_i1++) = temp3 + temp4; + *(pt_r2++) = temp1 - temp2; /* Z(n) - Z(n+4) */ + *(pt_i2++) = temp3 - temp4; + } + +} + +#endif /* PARAMETRICSTEREO */ + + +#endif /* AAC_PLUS */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.h new file mode 100644 index 00000000..616c216b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_fft_rx8.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_fft_rx8.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_fft_rx8() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_FFT_RX8_H +#define PS_FFT_RX8_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_FFT_RX4_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.c new file mode 100644 index 00000000..91d45986 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.c @@ -0,0 +1,279 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_analysis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid analysis: + + Get higher frequency resolution in the lower QMF subbands + creating sub-subbands. This is done by low frequency filtering. + Lower QMF subbands are further split in order to obtain a higher + frequency resolution, enabling a proper stereo analysis and synthesis + for the lower frequencies. + Two hybrid are defined. Both filters have length 13 and a delay of 6. + In this implementation, the symmetry of the filters helps to simplify + the design. + + + Increase Freq. Resolution + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + + subband k QMF channel + 0 ................. 0 ----------- + 1 ................. 0 + 2 ................. 0 + 3 ................. 0 + 4 ................. 0 + 5 ................. 0 Sub-QMF ( Increase Freq. Resolution) + 6 ................. 1 + 7 ................. 1 + 8 ................. 2 + 9 ................. 2 + 10 ................. 3 ----------- + 11 ................. 4 + 12 ................. 5 + 13 ................. 6 + 14 ................. 7 + 15 ................. 8 QMF + 16-17 ................. 9-10 + 18-20 ................. 11-13 + 21-24 ................. 14-17 + 25-29 ................. 18-22 + 30-41 ................. 23-34 + 42-70 ................. 35-63 ----------- + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "aac_mem_funcs.h" +#include "ps_channel_filtering.h" +#include "ps_hybrid_analysis.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_hybrid_analysis(const Int32 mQmfReal[][64], + const Int32 mQmfImag[][64], + Int32 *mHybridReal, + Int32 *mHybridImag, + HYBRID *pHybrid, + Int32 scratch_mem[], + Int32 i) + +{ + + Int32 band; + HYBRID_RES hybridRes; + Int32 chOffset = 0; + + Int32 *ptr_mHybrid_Re; + Int32 *ptr_mHybrid_Im; + + Int32 *pt_mQmfBufferReal; + Int32 *pt_mQmfBufferImag; + + pt_mQmfBufferReal = &scratch_mem[32 + i]; + + for (band = 0; band < pHybrid->nQmfBands; band++) + { + pt_mQmfBufferImag = pt_mQmfBufferReal + 44; + + + pt_mQmfBufferReal[HYBRID_FILTER_LENGTH_m_1] = mQmfReal[HYBRID_FILTER_DELAY][band]; + pt_mQmfBufferImag[HYBRID_FILTER_LENGTH_m_1] = mQmfImag[HYBRID_FILTER_DELAY][band]; + + + ptr_mHybrid_Re = &mHybridReal[ chOffset]; + ptr_mHybrid_Im = &mHybridImag[ chOffset]; + + hybridRes = (HYBRID_RES)pHybrid->pResolution[band]; + switch (hybridRes) + { + /* + * For QMF band = 1 and 2 + */ + + case HYBRID_2_REAL: + + two_ch_filtering(pt_mQmfBufferReal, + pt_mQmfBufferImag, + ptr_mHybrid_Re, + ptr_mHybrid_Im); + chOffset += 2; + + break; + + /* + * For QMF band = 0 + */ + + case HYBRID_8_CPLX: + + eight_ch_filtering(pt_mQmfBufferReal, + pt_mQmfBufferImag, + pHybrid->mTempReal, + pHybrid->mTempImag, + scratch_mem); + + pv_memmove(ptr_mHybrid_Re, pHybrid->mTempReal, 4*sizeof(*pHybrid->mTempReal)); + + ptr_mHybrid_Re += 2; + + *(ptr_mHybrid_Re++) += pHybrid->mTempReal[5]; + *(ptr_mHybrid_Re++) += pHybrid->mTempReal[4]; + *(ptr_mHybrid_Re++) = pHybrid->mTempReal[6]; + *(ptr_mHybrid_Re) = pHybrid->mTempReal[7]; + + pv_memmove(ptr_mHybrid_Im, pHybrid->mTempImag, 4*sizeof(*pHybrid->mTempImag)); + ptr_mHybrid_Im += 2; + + *(ptr_mHybrid_Im++) += pHybrid->mTempImag[5]; + *(ptr_mHybrid_Im++) += pHybrid->mTempImag[4]; + *(ptr_mHybrid_Im++) = pHybrid->mTempImag[6]; + *(ptr_mHybrid_Im) = pHybrid->mTempImag[7]; + + chOffset += 6; + + break; + + default: + ; + } + + pt_mQmfBufferReal = pt_mQmfBufferImag + 44; + + } + + +} +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.h new file mode 100644 index 00000000..0964d30e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_analysis.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_analysis.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_hybrid_analysis() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_ANALYSIS_H +#define PS_HYBRID_ANALYSIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_hybrid_analysis(const Int32 mQmfReal[][64], + const Int32 mQmfImag[][64], + Int32 *mHybridReal, + Int32 *mHybridImag, + HYBRID *pHybrid, + Int32 scratch_mem[], + Int32 band); +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_ANALYSIS_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.c new file mode 100644 index 00000000..89a3c5cb --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.c @@ -0,0 +1,208 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_filter_bank_allocation.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Does Hybrid filter bank memory allocation + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "aac_mem_funcs.h" +#include "ps_hybrid_filter_bank_allocation.h" +#include "ps_all_pass_filter_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid, + Int32 noBands, + const Int32 *pResolution, + Int32 **pPtr) +{ + Int32 i; + Int32 tmp; + Int32 maxNoChannels = 0; + HYBRID *hs; + Int32 *ptr = *pPtr; + + + *phHybrid = (HYBRID *)NULL; + + hs = (HYBRID *)ptr; + + ptr += sizeof(HYBRID) / sizeof(*ptr); + + hs->pResolution = (Int32*)ptr; + + ptr += noBands * sizeof(Int32) / sizeof(*ptr); + + for (i = 0; i < noBands; i++) + { + + hs->pResolution[i] = pResolution[i]; + + if (pResolution[i] != HYBRID_8_CPLX && + pResolution[i] != HYBRID_2_REAL && + pResolution[i] != HYBRID_4_CPLX) + { + return 1; + } + + if (pResolution[i] > maxNoChannels) + { + maxNoChannels = pResolution[i]; + } + } + + hs->nQmfBands = noBands; + hs->qmfBufferMove = HYBRID_FILTER_LENGTH - 1; + + hs->mQmfBufferReal = (Int32 **)ptr; + ptr += noBands * sizeof(ptr) / sizeof(*ptr); + + hs->mQmfBufferImag = (Int32 **)ptr; + ptr += noBands * sizeof(ptr) / sizeof(*ptr); + + tmp = hs->qmfBufferMove; /* HYBRID_FILTER_LENGTH == 13 */ + + for (i = 0; i < noBands; i++) + { + hs->mQmfBufferReal[i] = ptr; + ptr += tmp; + + hs->mQmfBufferImag[i] = ptr; + ptr += tmp; + + } + + hs->mTempReal = ptr; + ptr += maxNoChannels; + + + hs->mTempImag = ptr; + ptr += maxNoChannels; + + + *phHybrid = hs; + *pPtr = ptr; + + return 0; +} + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.h new file mode 100644 index 00000000..41691ec3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_filter_bank_allocation.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_filter_bank_allocation.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for ps_hybrid_filter_bank_allocation + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_FILTER_BANK_ALLOCATION_H +#define PS_HYBRID_FILTER_BANK_ALLOCATION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid, + Int32 noBands, + const Int32 *pResolution, + Int32 **pPtr); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_FILTER_BANK_ALLOCATION_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.c new file mode 100644 index 00000000..21e83d5a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.c @@ -0,0 +1,187 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_synthesis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Hybrid synthesis + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "s_hybrid.h" +#include "ps_hybrid_synthesis.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void ps_hybrid_synthesis(const Int32 *mHybridReal, + const Int32 *mHybridImag, + Int32 *mQmfReal, + Int32 *mQmfImag, + HYBRID *hHybrid) +{ + Int32 k; + Int32 band; + HYBRID_RES hybridRes; + + Int32 real; + Int32 imag; + Int32 *ptr_mQmfReal = mQmfReal; + Int32 *ptr_mQmfImag = mQmfImag; + const Int32 *ptr_mHybrid_Re = mHybridReal; + const Int32 *ptr_mHybrid_Im = mHybridImag; + + for (band = 0; band < hHybrid->nQmfBands; band++) + { + hybridRes = (HYBRID_RES)(min(hHybrid->pResolution[band], 6) - 2); + + real = *(ptr_mHybrid_Re++); + real += *(ptr_mHybrid_Re++); + imag = *(ptr_mHybrid_Im++); + imag += *(ptr_mHybrid_Im++); + + for (k = (hybridRes >> 1); k != 0; k--) /* hybridRes = { 2,4,6 } */ + { + real += *(ptr_mHybrid_Re++); + real += *(ptr_mHybrid_Re++); + imag += *(ptr_mHybrid_Im++); + imag += *(ptr_mHybrid_Im++); + } + + *(ptr_mQmfReal++) = real; + *(ptr_mQmfImag++) = imag; + } +} + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.h new file mode 100644 index 00000000..921ce944 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_hybrid_synthesis.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_hybrid_synthesis.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_hybrid_synthesis() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_HYBRID_SYNTHESIS_H +#define PS_HYBRID_SYNTHESIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hybrid.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_hybrid_synthesis(const Int32 *mHybridReal, + const Int32 *mHybridImag, + Int32 *mQmfReal, + Int32 *mQmfImag, + HYBRID *hHybrid); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_HYBRID_SYNTHESIS_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.c new file mode 100644 index 00000000..fe4416b4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.c @@ -0,0 +1,491 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_init_stereo_mixing.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + initialize mixing procedure type Ra, type Rb is not supported + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + +#include "aac_mem_funcs.h" +#include "pv_sine.h" +#include "s_ps_dec.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_init_stereo_mixing.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/* +; +; c(b) = 10^(iid(b)/20) +; +; Intensity differences +; +; sqrt(2) +; c_1(b) = ---------------- +; sqrt( 1 + c^2(b)) +; +; sqrt(2)*c(b) +; c_2(b) = ---------------- +; sqrt( 1 + c^2(b)) +; +*/ + + + +#define R_SHIFT 30 +#define Q30_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 scaleFactors[NO_IID_LEVELS] = +{ + Q30_fmt(1.411983f), Q30_fmt(1.403138f), Q30_fmt(1.386877f), + Q30_fmt(1.348400f), Q30_fmt(1.291249f), Q30_fmt(1.196037f), + Q30_fmt(1.107372f), Q30_fmt(1.000000f), Q30_fmt(0.879617f), + Q30_fmt(0.754649f), Q30_fmt(0.576780f), Q30_fmt(0.426401f), + Q30_fmt(0.276718f), Q30_fmt(0.176645f), Q30_fmt(0.079402f) +}; + +const Int32 scaleFactorsFine[NO_IID_LEVELS_FINE] = +{ + Q30_fmt(1.414207f), Q30_fmt(1.414191f), Q30_fmt(1.414143f), + Q30_fmt(1.413990f), Q30_fmt(1.413507f), Q30_fmt(1.411983f), + Q30_fmt(1.409773f), Q30_fmt(1.405395f), Q30_fmt(1.396780f), + Q30_fmt(1.380053f), Q30_fmt(1.348400f), Q30_fmt(1.313920f), + Q30_fmt(1.264310f), Q30_fmt(1.196037f), Q30_fmt(1.107372f), + Q30_fmt(1.000000f), Q30_fmt(0.879617f), Q30_fmt(0.754649f), + Q30_fmt(0.633656f), Q30_fmt(0.523081f), Q30_fmt(0.426401f), + Q30_fmt(0.308955f), Q30_fmt(0.221375f), Q30_fmt(0.157688f), + Q30_fmt(0.111982f), Q30_fmt(0.079402f), Q30_fmt(0.044699f), + Q30_fmt(0.025145f), Q30_fmt(0.014141f), Q30_fmt(0.007953f), + Q30_fmt(0.004472f) +}; + + +/* + * alphas ranged between 0 and pi/2 + * alpha(b) = (1/2)*arccos( gamma(b)) + * + * b 0 1 2 3 4 5 6 7 + * gamma 1 0.937 0.84118 0.60092 0.36764 0 -0.589 -1 + * + */ + + + +const Int32 scaled_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(0.00000000000000f), Q30_fmt(0.12616764875355f), + Q30_fmt(0.20199707286122f), Q30_fmt(0.32744135137762f), + Q30_fmt(0.42225800677370f), Q30_fmt(0.55536025173035f), + Q30_fmt(0.77803595530059f), Q30_fmt(1.11072050346071f) +}; + +const Int32 cos_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(1.00000000000000f), Q30_fmt(0.98412391153249f), + Q30_fmt(0.95947390717984f), Q30_fmt(0.89468446298319f), + Q30_fmt(0.82693418207478f), Q30_fmt(0.70710689672598f), + Q30_fmt(0.45332071670080f), Q30_fmt(0.00000032679490f) +}; + +const Int32 sin_alphas[NO_ICC_LEVELS] = +{ + Q30_fmt(0.00000000000000f), Q30_fmt(0.17748275057029f), + Q30_fmt(0.28179748302823f), Q30_fmt(0.44669868110000f), + Q30_fmt(0.56229872711603f), Q30_fmt(0.70710666564709f), + Q30_fmt(0.89134747871404f), Q30_fmt(1.00000000000000f) +}; + + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms, + Int32 env, + Int32 usb) +{ + Int32 group; + Int32 bin; + Int32 noIidSteps; + Int32 tmp; + + Int32 invEnvLength; + const Int32 *pScaleFactors; + Int32 scaleR; + Int32 scaleL; + Int32 cos_alpha; + Int32 sin_alpha; + Int32 beta; + Int32 cos_beta; + Int32 sin_beta; + Int32 temp1; + Int32 temp2; + Int32 *ptr_tmp; + Int32 h11; + Int32 h12; + Int32 h21; + Int32 h22; + + if (pms->bFineIidQ) + { + noIidSteps = NO_IID_STEPS_FINE; /* NO_IID_STEPS_FINE == 15 */ + pScaleFactors = scaleFactorsFine; + } + else + { + noIidSteps = NO_IID_STEPS; /* NO_IID_STEPS == 7 */ + pScaleFactors = scaleFactors; + } + + if (env == 0) + { + pms->lastUsb = pms->usb; + pms->usb = usb; + if (usb != pms->lastUsb && pms->lastUsb != 0) + { + return(-1); + + } + } + + invEnvLength = pms->aEnvStartStop[env + 1] - pms->aEnvStartStop[env]; + + if (invEnvLength == (Int32) pms->noSubSamples) + { + invEnvLength = pms->invNoSubSamples; + } + else + { + invEnvLength = Q30_fmt(1.0f) / invEnvLength; + } + + if (invEnvLength == 32) /* more likely value */ + { + for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */ + { + bin = bins2groupMap[group]; + + /* + * c(b) = 10^(iid(b)/20) + */ + + tmp = pms->aaIidIndex[env][bin]; + + /* + * Intensity differences + * + * sqrt(2) + * c_1(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + scaleR = pScaleFactors[noIidSteps + tmp]; + + /* + * sqrt(2)*c(b) + * c_2(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + + scaleL = pScaleFactors[noIidSteps - tmp]; + + + /* + * alpha(b) = (1/2)*arccos( gamma(b)) + */ + tmp = pms->aaIccIndex[env][bin]; + + cos_alpha = cos_alphas[ tmp]; + sin_alpha = sin_alphas[ tmp]; + + /* + * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b)) + */ + + beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL)); + + cos_beta = pv_cosine(beta); + sin_beta = pv_sine(beta); + + temp1 = fxp_mul32_Q30(cos_beta, cos_alpha); + temp2 = fxp_mul32_Q30(sin_beta, sin_alpha); + + + /* + * h11(b) = cos( alpha(b) + beta(b))* c_2(b) + * h12(b) = cos( beta(b) - alpha(b))* c_1(b) + */ + + h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2)); + h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2)); + + temp1 = fxp_mul32_Q30(sin_beta, cos_alpha); + temp2 = fxp_mul32_Q30(cos_beta, sin_alpha); + + /* + * h21(b) = sin( alpha(b) + beta(b))* c_2(b) + * h22(b) = sin( beta(b) - alpha(b))* c_1(b) + */ + + h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2)); + h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2)); + + + /* + * Linear interpolation + * + * Hij(k, n_e+1) - Hij(k, n_e) + * Hij(k,n) = Hij(k, n_e) + (n - n_e)*--------------------------- + * n_e+1 - n_e + */ + + ptr_tmp = &pms->h11Prev[group]; + pms->H11[group] = *ptr_tmp; + pms->deltaH11[group] = (h11 - *ptr_tmp) >> 5; + *ptr_tmp = h11; + + ptr_tmp = &pms->h12Prev[group]; + pms->H12[group] = *ptr_tmp; + pms->deltaH12[group] = (h12 - *ptr_tmp) >> 5; + *ptr_tmp = h12; + + ptr_tmp = &pms->h21Prev[group]; + pms->H21[group] = *ptr_tmp; + pms->deltaH21[group] = (h21 - *ptr_tmp) >> 5; + *ptr_tmp = h21; + + ptr_tmp = &pms->h22Prev[group]; + pms->H22[group] = *ptr_tmp; + pms->deltaH22[group] = (h22 - *ptr_tmp) >> 5; + *ptr_tmp = h22; + + + } /* groups loop */ + } + else + { + + for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */ + { + bin = bins2groupMap[group]; + + /* + * c(b) = 10^(iid(b)/20) + */ + + tmp = pms->aaIidIndex[env][bin]; + + /* + * Intensity differences + * + * sqrt(2) + * c_1(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + scaleR = pScaleFactors[noIidSteps + tmp]; + + /* + * sqrt(2)*c(b) + * c_2(b) = ---------------- + * sqrt( 1 + c^2(b)) + * + */ + + scaleL = pScaleFactors[noIidSteps - tmp]; + + + /* + * alpha(b) = (1/2)*arccos( gamma(b)) + */ + tmp = pms->aaIccIndex[env][bin]; + + cos_alpha = cos_alphas[ tmp]; + sin_alpha = sin_alphas[ tmp]; + + /* + * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b)) + */ + + beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL)); + + cos_beta = pv_cosine(beta); + sin_beta = pv_sine(beta); + + temp1 = fxp_mul32_Q30(cos_beta, cos_alpha); + temp2 = fxp_mul32_Q30(sin_beta, sin_alpha); + + + /* + * h11(b) = cos( alpha(b) + beta(b))* c_2(b) + * h12(b) = cos( beta(b) - alpha(b))* c_1(b) + */ + + h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2)); + h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2)); + + temp1 = fxp_mul32_Q30(sin_beta, cos_alpha); + temp2 = fxp_mul32_Q30(cos_beta, sin_alpha); + + /* + * h21(b) = sin( alpha(b) + beta(b))* c_2(b) + * h22(b) = sin( beta(b) - alpha(b))* c_1(b) + */ + + h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2)); + h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2)); + + + /* + * Linear interpolation + * + * Hij(k, n_e+1) - Hij(k, n_e) + * Hij(k,n) = Hij(k, n_e) + (n - n_e)*--------------------------- + * n_e+1 - n_e + */ + + ptr_tmp = &pms->h11Prev[group]; + pms->deltaH11[group] = fxp_mul32_Q30((h11 - *ptr_tmp), invEnvLength); + pms->H11[group] = *ptr_tmp; + *ptr_tmp = h11; + + ptr_tmp = &pms->h12Prev[group]; + pms->deltaH12[group] = fxp_mul32_Q30((h12 - *ptr_tmp), invEnvLength); + pms->H12[group] = *ptr_tmp; + *ptr_tmp = h12; + + ptr_tmp = &pms->h21Prev[group]; + pms->deltaH21[group] = fxp_mul32_Q30((h21 - *ptr_tmp), invEnvLength); + pms->H21[group] = *ptr_tmp; + *ptr_tmp = h21; + + ptr_tmp = &pms->h22Prev[group]; + pms->deltaH22[group] = fxp_mul32_Q30((h22 - *ptr_tmp), invEnvLength); + pms->H22[group] = *ptr_tmp; + *ptr_tmp = h22; + + + } /* groups loop */ + } + + + return (0); + +} /* END ps_init_stereo_mixing */ + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.h new file mode 100644 index 00000000..52c0b66d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_init_stereo_mixing.h @@ -0,0 +1,91 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_init_stereo_mixing.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_init_stereo_mixing() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_INIT_STEREO_MIXING_H +#define PS_INIT_STEREO_MIXING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms, + Int32 env, + Int32 usb); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_INIT_STEREO_MIXING_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.c new file mode 100644 index 00000000..7ceeb4f0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.c @@ -0,0 +1,335 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_pwr_transient_detection.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decorrelation + Decorrelation is achieved by means of all-pass filtering and delaying + Sub-band samples s_k(n) are converted into de-correlated sub-bands samples + d_k(n). k index for frequency, n time index + + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + + To handle transients and other fast time-envelopes, the output of the all + pass filters has to be attenuated at those signals. + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" +#include "aac_mem_funcs.h" +#include "ps_all_pass_filter_coeff.h" +#include "ps_pwr_transient_detection.h" + +#include "fxp_mul32.h" +#include "pv_div.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define R_SHIFT 29 +#define Q29_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) - 1 + (a>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 aTransRatio[]) +{ + + Int32 sb; + Int32 maxsb; + Int32 gr; + Int32 bin; + + + + Int32 *aLeftReal; + Int32 *aLeftImag; + Int32 temp_r; + Int32 temp_i; + Int32 accu; + Int32 *aPower = aTransRatio; + Quotient result; + + Int32 nrg; + Int32 *ptr_aPrevNrg; + Int32 peakDiff; + Int32 *ptr_PrevPeakDiff; + + + aLeftReal = rIntBufferLeft; + aLeftImag = iIntBufferLeft; + + /* + * Input Power Matrix + * 2 + * Power(i,n) = SUM | s_k(n)| + * i + */ + + for (gr = SUBQMF_GROUPS; gr < NO_IID_GROUPS; gr++) /* 10 to 22 */ + { + maxsb = min(h_ps_dec->usb, groupBorders[ gr+1]); + + accu = 0; + + for (sb = groupBorders[gr]; sb < maxsb; sb++) + { + + temp_r = aLeftReal[sb]; + temp_i = aLeftImag[sb]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + + } /* sb */ + aPower[gr - 2] = accu >> 1; + } /* gr */ + + aLeftReal = h_ps_dec->mHybridRealLeft; + aLeftImag = h_ps_dec->mHybridImagLeft; + + + temp_r = aLeftReal[0]; + temp_i = aLeftImag[0]; + accu = fxp_mul32_Q31(temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + temp_r = aLeftReal[5]; + temp_i = aLeftImag[5]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + aPower[0] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[1]; + temp_i = aLeftImag[1]; + accu = fxp_mul32_Q31(temp_r, temp_r); + accu = fxp_mac32_Q31(accu, temp_i, temp_i); + temp_r = aLeftReal[4]; + temp_i = aLeftImag[4]; + accu = fxp_mac32_Q31(accu, temp_r, temp_r); + aPower[1] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[2]; + temp_i = aLeftImag[2]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[2] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[3]; + temp_i = aLeftImag[3]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[3] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + + + temp_r = aLeftReal[6]; + temp_i = aLeftImag[6]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[5] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[7]; + temp_i = aLeftImag[7]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[4] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[8]; + temp_i = aLeftImag[8]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[6] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + temp_r = aLeftReal[9]; + temp_i = aLeftImag[9]; + accu = fxp_mul32_Q31(temp_r, temp_r); + aPower[7] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1; + + + /* + * Power transient detection + */ + + ptr_aPrevNrg = h_ps_dec->aPrevNrg; + + ptr_PrevPeakDiff = h_ps_dec->aPrevPeakDiff; + + for (bin = 0; bin < NO_BINS; bin++) /* NO_BINS = 20 */ + { + + peakDiff = *ptr_PrevPeakDiff; + + + /* PEAK_DECAY_FACTOR 0.765928338364649f @ 48 KHz for Fs > 32 Khz */ + accu = h_ps_dec->aPeakDecayFast[bin]; + peakDiff -= peakDiff >> 2; + + accu = fxp_mul32_Q31(accu, Qfmt31(0.765928338364649f)) << 1; + + if (accu < *aPower) + { + accu = *aPower; + } + else + { + peakDiff += ((accu - *aPower) >> 2); + } + + h_ps_dec->aPeakDecayFast[bin] = accu; + + *(ptr_PrevPeakDiff++) = peakDiff; + + nrg = *ptr_aPrevNrg + ((*aPower - *ptr_aPrevNrg) >> 2); + + *(ptr_aPrevNrg++) = nrg; + + peakDiff += peakDiff >> 1; /* transient impact factor == 1.5 */ + + if (peakDiff <= nrg) + { + *(aPower++) = 0x7FFFFFFF; /* in Q31 */ + } + else + { + pv_div(nrg, peakDiff, &result); + *(aPower++) = (result.quotient >> (result.shift_factor)) << 1; /* in Q31 */ + } + + } /* bin */ + +} + + +#endif + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.h new file mode 100644 index 00000000..57bf5f63 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_pwr_transient_detection.h @@ -0,0 +1,90 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_pwr_transient_detection.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_pwr_transient_detection() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_PWR_TRANSIENT_DETECTION_H +#define PS_PWR_TRANSIENT_DETECTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec, + Int32 *rIntBufferLeft, + Int32 *iIntBufferLeft, + Int32 aTransRatio[]); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_PWR_TRANSIENT_DETECTION_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.c new file mode 100644 index 00000000..c3802081 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.c @@ -0,0 +1,382 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_read_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes parametric stereo + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "buf_getbits.h" +#include "s_bit_buffer.h" +#include "s_huffman.h" +#include "aac_mem_funcs.h" +#include "s_ps_dec.h" +#include "sbr_decode_huff_cw.h" +#include "ps_decode_bs_utils.h" +#include "ps_bstr_decoding.h" +#include "ps_read_data.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/* IID & ICC Huffman codebooks */ +const Char aBookPsIidTimeDecode[28][2] = +{ + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, + { -60, 9 }, { -69, 10 }, { -59, 11 }, { -70, 12 }, + { -58, 13 }, { -57, 14 }, { -71, 15 }, { 16, 17 }, + { -56, -72 }, { 18, 21 }, { 19, 20 }, { -55, -78 }, + { -77, -76 }, { 22, 25 }, { 23, 24 }, { -75, -74 }, + { -73, -54 }, { 26, 27 }, { -53, -52 }, { -51, -50 } +}; + +const Char aBookPsIidFreqDecode[28][2] = +{ + { -64, 1 }, { 2, 3 }, { -63, -65 }, { 4, 5 }, + { -62, -66 }, { 6, 7 }, { -61, -67 }, { 8, 9 }, + { -68, -60 }, { -59, 10 }, { -69, 11 }, { -58, 12 }, + { -70, 13 }, { -71, 14 }, { -57, 15 }, { 16, 17 }, + { -56, -72 }, { 18, 19 }, { -55, -54 }, { 20, 21 }, + { -73, -53 }, { 22, 24 }, { -74, 23 }, { -75, -78 }, + { 25, 26 }, { -77, -76 }, { -52, 27 }, { -51, -50 } +}; + +const Char aBookPsIccTimeDecode[14][2] = +{ + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -68, 9 }, { -59, 10 }, { -69, 11 }, { -58, 12 }, + { -70, 13 }, { -71, -57 } +}; + +const Char aBookPsIccFreqDecode[14][2] = +{ + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -59, 9 }, { -68, 10 }, { -58, 11 }, { -69, 12 }, + { -57, 13 }, { -70, -71 } +}; + +const Char aBookPsIidFineTimeDecode[60][2] = +{ + { 1, -64 }, { -63, 2 }, { 3, -65 }, { 4, 59 }, + { 5, 7 }, { 6, -67 }, { -68, -60 }, { -61, 8 }, + { 9, 11 }, { -59, 10 }, { -70, -58 }, { 12, 41 }, + { 13, 20 }, { 14, -71 }, { -55, 15 }, { -53, 16 }, + { 17, -77 }, { 18, 19 }, { -85, -84 }, { -46, -45 }, + { -57, 21 }, { 22, 40 }, { 23, 29 }, { -51, 24 }, + { 25, 26 }, { -83, -82 }, { 27, 28 }, { -90, -38 }, + { -92, -91 }, { 30, 37 }, { 31, 34 }, { 32, 33 }, + { -35, -34 }, { -37, -36 }, { 35, 36 }, { -94, -93 }, + { -89, -39 }, { 38, -79 }, { 39, -81 }, { -88, -40 }, + { -74, -54 }, { 42, -69 }, { 43, 44 }, { -72, -56 }, + { 45, 52 }, { 46, 50 }, { 47, -76 }, { -49, 48 }, + { -47, 49 }, { -87, -41 }, { -52, 51 }, { -78, -50 }, + { 53, -73 }, { 54, -75 }, { 55, 57 }, { 56, -80 }, + { -86, -42 }, { -48, 58 }, { -44, -43 }, { -66, -62 } +}; + +const Char aBookPsIidFineFreqDecode[60][2] = +{ + { 1, -64 }, { 2, 4 }, { 3, -65 }, { -66, -62 }, + { -63, 5 }, { 6, 7 }, { -67, -61 }, { 8, 9 }, + { -68, -60 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, + { -70, -58 }, { 14, 18 }, { -57, 15 }, { 16, -72 }, + { -54, 17 }, { -75, -53 }, { 19, 37 }, { -56, 20 }, + { 21, -73 }, { 22, 29 }, { 23, -76 }, { 24, -78 }, + { 25, 28 }, { 26, 27 }, { -85, -43 }, { -83, -45 }, + { -81, -47 }, { -52, 30 }, { -50, 31 }, { 32, -79 }, + { 33, 34 }, { -82, -46 }, { 35, 36 }, { -90, -89 }, + { -92, -91 }, { 38, -71 }, { -55, 39 }, { 40, -74 }, + { 41, 50 }, { 42, -77 }, { -49, 43 }, { 44, 47 }, + { 45, 46 }, { -86, -42 }, { -88, -87 }, { 48, 49 }, + { -39, -38 }, { -41, -40 }, { -51, 51 }, { 52, 59 }, + { 53, 56 }, { 54, 55 }, { -35, -34 }, { -37, -36 }, + { 57, 58 }, { -94, -93 }, { -84, -44 }, { -80, -48 } +}; + + + + + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 ps_read_data(STRUCT_PS_DEC *ps_dec, + BIT_BUFFER * hBitBuf, + Int32 nBitsLeft) + +{ + Int gr; + UInt32 env; + UInt32 dtFlag; + Int32 startbits; + SbrHuffman CurrentTable; + + if (!ps_dec) + { + return 0; + } + + startbits = GetNrBitsAvailable(hBitBuf); + + if (buf_get_1bit(hBitBuf)) /* Enable Header */ + { + ps_dec->bEnableIid = buf_get_1bit(hBitBuf); + + if (ps_dec->bEnableIid) + { + ps_dec->freqResIid = buf_getbits(hBitBuf, 3); + + if (ps_dec->freqResIid > 2) + { + ps_dec->bFineIidQ = 1; + ps_dec->freqResIid -= 3; + } + else + { + ps_dec->bFineIidQ = 0; + } + } + + ps_dec->bEnableIcc = buf_get_1bit(hBitBuf); + if (ps_dec->bEnableIcc) + { + ps_dec->freqResIcc = buf_getbits(hBitBuf, 3); + + if (ps_dec->freqResIcc > 2) + { + ps_dec->freqResIcc -= 3; + } + } + ps_dec->bEnableExt = buf_get_1bit(hBitBuf); + } + + ps_dec->bFrameClass = buf_get_1bit(hBitBuf); + if (ps_dec->bFrameClass == 0) + { + ps_dec->noEnv = aFixNoEnvDecode[ buf_getbits(hBitBuf, 2)]; + } + else + { + ps_dec->noEnv = 1 + buf_getbits(hBitBuf, 2); + for (env = 1; env < ps_dec->noEnv + 1; env++) + { + ps_dec->aEnvStartStop[env] = (buf_getbits(hBitBuf, 5)) + 1; + } + } + + if ((ps_dec->freqResIid > 2) || (ps_dec->freqResIcc > 2)) + { + + ps_dec->bPsDataAvail = 0; + + nBitsLeft -= startbits - GetNrBitsAvailable(hBitBuf); + while (nBitsLeft) + { + int i = nBitsLeft; + if (i > 8) + { + i = 8; + } + buf_getbits(hBitBuf, i); + nBitsLeft -= i; + } + return (startbits - GetNrBitsAvailable(hBitBuf)); + } + + if (ps_dec->bEnableIid) + { + for (env = 0; env < ps_dec->noEnv; env++) + { + dtFlag = buf_get_1bit(hBitBuf); + + if (!dtFlag) + { + if (ps_dec->bFineIidQ) + { + CurrentTable = aBookPsIidFineFreqDecode; + } + else + { + CurrentTable = aBookPsIidFreqDecode; + } + } + else + { + if (ps_dec->bFineIidQ) + { + CurrentTable = aBookPsIidFineTimeDecode; + } + else + { + CurrentTable = aBookPsIidTimeDecode; + } + } + + for (gr = 0; gr < aNoIidBins[ps_dec->freqResIid]; gr++) + { + ps_dec->aaIidIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf); + } + + ps_dec->abIidDtFlag[env] = dtFlag; + } + } + + if (ps_dec->bEnableIcc) + { + for (env = 0; env < ps_dec->noEnv; env++) + { + dtFlag = buf_get_1bit(hBitBuf); + if (!dtFlag) + { + CurrentTable = aBookPsIccFreqDecode; + } + else + { + CurrentTable = aBookPsIccTimeDecode; + } + for (gr = 0; gr < aNoIccBins[ps_dec->freqResIcc]; gr++) + { + ps_dec->aaIccIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf); + } + + ps_dec->abIccDtFlag[env] = dtFlag; + } + } + + if (ps_dec->bEnableExt) + { + + int cnt; + + cnt = (int)buf_getbits(hBitBuf, 4); + + if (cnt == 15) + { + cnt += (int)buf_getbits(hBitBuf, 8); + } + + hBitBuf->nrBitsRead += (cnt << 3); + } + + ps_dec->bPsDataAvail = 1; + + return (startbits - GetNrBitsAvailable(hBitBuf)); +} + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.h new file mode 100644 index 00000000..c73f38b6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_read_data.h @@ -0,0 +1,94 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_read_data.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for functions ps_read_data() + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_READ_DATA_H +#define PS_READ_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define EXTENSION_ID_PS_CODING 2 + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 ps_read_data(STRUCT_PS_DEC *ps_dec, + BIT_BUFFER * hBitBuf, + Int32 nBitsLeft); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_READ_DATA_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.c new file mode 100644 index 00000000..5e6f7f08 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.c @@ -0,0 +1,367 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_stereo_processing.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Stereo Process or reconstruction + + l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + + r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + + _______ ________ + | | _______ | | + ->|Hybrid | LF ---- | |->| Hybrid |--> + | Anal. | | | | | Synth | QMF -> L + ------- o----------------------->| | -------- Synth +QMF | s_k(n) |Stereo |--------------> +Anal. -------------------------->| | + _______ | | | | ________ + | | HF --o | ----------- |Process| | | + ->| Delay | | ->| |-------->| |->| Hybrid |--> + ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R + ---->| |-------->| | -------- Synth + ----------- |_______|--------------> + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2003. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO +#include "pv_audio_type_defs.h" +#include "ps_stereo_processing.h" +#include "fxp_mul32.h" +#include "ps_all_pass_filter_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void ps_stereo_processing(STRUCT_PS_DEC *pms, + Int32 *qmfLeftReal, + Int32 *qmfLeftImag, + Int32 *qmfRightReal, + Int32 *qmfRightImag) +{ + Int32 group; + Int32 subband; + Int32 maxSubband; + Int32 usb; + Char index; + + + Int32 *hybrLeftReal; + Int32 *hybrLeftImag; + Int32 *hybrRightReal; + Int32 *hybrRightImag; + Int32 *ptr_hybrLeftReal; + Int32 *ptr_hybrLeftImag; + Int32 *ptr_hybrRightReal; + Int32 *ptr_hybrRightImag; + + + Int16 h11; + Int16 h12; + Int16 h21; + Int16 h22; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + + usb = pms->usb; + + /* + * Complete Linear interpolation + */ + + hybrLeftReal = pms->mHybridRealLeft; + hybrLeftImag = pms->mHybridImagLeft; + hybrRightReal = pms->mHybridRealRight; + hybrRightImag = pms->mHybridImagRight; + + for (group = 0; group < SUBQMF_GROUPS; group++) /* SUBQMF_GROUPS == 10 */ + { + + temp1 = pms->deltaH11[group]; + temp2 = pms->deltaH12[group]; + + pms->H11[group] += temp1; + h11 = (Int16)(pms->H11[group] >> 16); + pms->H12[group] += temp2; + h12 = (Int16)(pms->H12[group] >> 16); + + temp1 = pms->deltaH21[group]; + temp2 = pms->deltaH22[group]; + + pms->H21[group] += temp1; + h21 = (Int16)(pms->H21[group] >> 16); + pms->H22[group] += temp2; + h22 = (Int16)(pms->H22[group] >> 16); + + index = groupBorders[group]; + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + ptr_hybrLeftReal = &hybrLeftReal[ index]; + ptr_hybrRightReal = &hybrRightReal[ index]; + + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + ptr_hybrLeftImag = &hybrLeftImag[ index]; + ptr_hybrRightImag = &hybrRightImag[ index]; + + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + } /* groups loop */ + + temp1 = pms->deltaH11[SUBQMF_GROUPS]; + temp2 = pms->deltaH12[SUBQMF_GROUPS]; + + pms->H11[SUBQMF_GROUPS] += temp1; + h11 = (Int16)(pms->H11[SUBQMF_GROUPS] >> 16); + pms->H12[SUBQMF_GROUPS] += temp2; + h12 = (Int16)(pms->H12[SUBQMF_GROUPS] >> 16); + + temp1 = pms->deltaH21[SUBQMF_GROUPS]; + temp2 = pms->deltaH22[SUBQMF_GROUPS]; + + pms->H21[SUBQMF_GROUPS] += temp1; + h21 = (Int16)(pms->H21[SUBQMF_GROUPS] >> 16); + pms->H22[SUBQMF_GROUPS] += temp2; + h22 = (Int16)(pms->H22[SUBQMF_GROUPS] >> 16); + + + ptr_hybrLeftReal = &qmfLeftReal[ 3]; + ptr_hybrRightReal = &qmfRightReal[ 3]; + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + ptr_hybrLeftImag = &qmfLeftImag[ 3]; + ptr_hybrRightImag = &qmfRightImag[ 3]; + + + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + + for (group = SUBQMF_GROUPS + 1; group < NO_IID_GROUPS; group++) /* 11 to NO_IID_GROUPS == 22 */ + { + temp1 = pms->deltaH11[group]; + temp2 = pms->deltaH12[group]; + + pms->H11[group] += temp1; + h11 = (Int16)(pms->H11[group] >> 16); + pms->H12[group] += temp2; + h12 = (Int16)(pms->H12[group] >> 16); + + temp1 = pms->deltaH21[group]; + temp2 = pms->deltaH22[group]; + + pms->H21[group] += temp1; + h21 = (Int16)(pms->H21[group] >> 16); + pms->H22[group] += temp2; + h22 = (Int16)(pms->H22[group] >> 16); + + index = groupBorders[group]; + maxSubband = groupBorders[group + 1]; + maxSubband = min(usb, maxSubband); + + /* + * Reconstruction of Stereo sub-band signal + * + * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n) + * + * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n) + */ + + ptr_hybrLeftReal = &qmfLeftReal[ index]; + ptr_hybrRightReal = &qmfRightReal[ index]; + + for (subband = index; subband < maxSubband; subband++) + { + temp1 = *(ptr_hybrLeftReal) << 1; + temp2 = *(ptr_hybrRightReal) << 1; + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftReal++) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightReal++) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + } + + ptr_hybrLeftImag = &qmfLeftImag[ index]; + ptr_hybrRightImag = &qmfRightImag[ index]; + + for (subband = index; subband < maxSubband; subband++) + { + temp1 = *(ptr_hybrLeftImag) << 1; + temp2 = *(ptr_hybrRightImag) << 1; + temp3 = fxp_mul32_by_16(temp1, h11); + *(ptr_hybrLeftImag++) = fxp_mac32_by_16(temp2, h21, temp3) << 1; + + temp3 = fxp_mul32_by_16(temp1, h12); + *(ptr_hybrRightImag++) = fxp_mac32_by_16(temp2, h22, temp3) << 1; + + } /* subband loop */ + + } /* groups loop */ + +} /* END ps_stereo_processing */ + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.h new file mode 100644 index 00000000..c6988863 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/ps_stereo_processing.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: ps_stereo_processing.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for function ps_stereo_processing() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PS_STEREO_PROCESSING_H +#define PS_STEREO_PROCESSING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_ps_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void ps_stereo_processing(STRUCT_PS_DEC *pms, + Int32 *qmfLeftReal, + Int32 *qmfLeftImag, + Int32 *qmfRightReal, + Int32 *qmfRightImag); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif /* PS_STEREO_PROCESSING_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.c new file mode 100644 index 00000000..148e34e3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.c @@ -0,0 +1,259 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pulse_nc.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + coef[] = Array of quantized spectral coefficents. + (Int []) + + pPulseInfo = Pointer to structure which contains noiseless + encoding info, includes information about the pulse data, + pulse amplitude, etc. + (const PulseInfo *) + + pLongFrameInfo = Pointer to structure that holds information about + each group. (long block flag, number of windows, + scalefactor bands per group, etc.) + + Variable is named (pLongFrameInfo) because this function + is only used for LONG windows. + (FrameInfo *) + max = Pointer to the maximum value of coef[] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef[] = coefficient contents are modified by the encoded pulse + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function adds pulses to defined ranges of coefficients in the window, + for the case of LONG windows. The pulses are unsigned, so + negative coefficients subtract the pulse, and positive coefficients add it. + (The ampltiude of the coefficient is always increased by the pulse) + + A maximum of 4 coefficients may be modified by a pulse, and these + coefficients must all occur in the same scalefactor band. + + The number of pulse-encoded coefficients to be processed by this function + is communicated to this function via pPulseInfo->number_pulse + + This value is equal to the actual number of pulses - 1. + (e.g if pPulseInfo->number_pulse == 0, one pulse is assumed) + This function must not be called if no pulse encoded data exists. + The function assumes that at least one pulse exists. +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall correctly add transmitted pulse(s) to the correct + coefficients in a LONG window. + +------------------------------------------------------------------------------ + REFERENCES + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.3.3 Decoding Process + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb]; + + pPulseOffset = &(pPulseInfo->pulse_offset[0]); + + pPulseAmp = &(pPulseInfo->pulse_amp[0]); + + pCoef = &(Coef[index]); + + FOR (index = pPulseInfo->number_pulse; index >= 0; index--) + + pCoef = pCoef + *(pPulseOffset); + pPulseOffset = pPulseOffset + 1; + + IF (*pCoef > 0) + *(pCoef) = *(pCoef) + *(pPulseAmp); + pPulseAmp = pPulseAmp + 1; + ELSE + *(pCoef) = *(pCoef) - *(pPulseAmp); + pPulseAmp = pPulseAmp + 1; + ENDIF + + ENDFOR + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_pulseinfo.h" +#include "pulse_nc.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void pulse_nc( + Int16 coef[], + const PulseInfo *pPulseInfo, + const FrameInfo *pLongFrameInfo, + Int *max) +{ + Int index; + + Int16 *pCoef; + Int temp; + + const Int *pPulseOffset; + const Int *pPulseAmp; + + /*--- Find the scalefactor band where pulse-encoded data starts ---*/ + + if (pPulseInfo->pulse_start_sfb > 0) + { + index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb - 1]; + } + else + { + index = 0; + } + + /*------------------------------------------------------------------------- + Each pulse index is stored as an offset from the previous pulse + + Example - here we have a sfb that is 20 coefficients in length: + + [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19] + [ ][ ][ ][ ][ ][P][P][ ][ ][ ][ ][ ][ ][ ][ ][ P][ ][ ][ ][ P] + + The array pointed to by pPulseOffset == [5][1][9][4] + + pPulseAmp is of the same length as pPulseOffset, and contains + an individual pulse amplitude for each coefficient. + --------------------------------------------------------------------------*/ + + pCoef = &(coef[index]); + + pPulseOffset = &(pPulseInfo->pulse_offset[0]); + + pPulseAmp = &(pPulseInfo->pulse_amp[0]); + + for (index = pPulseInfo->number_pulse; index > 0; index--) + { + pCoef += *pPulseOffset++; + + temp = *pCoef; + + if (temp > 0) + { + temp += *(pPulseAmp++); + *pCoef = (Int16)temp; + if (temp > *max) + { + *max = temp; + } + } + else + { + temp -= *(pPulseAmp++); + *pCoef = (Int16)temp; + if (-temp > *max) + { + *max = -temp; + } + } + + } /* for() */ + + return; + +} /* pulse_nc */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.h new file mode 100644 index 00000000..16a7a52c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pulse_nc.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pulse_nc.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the global function declaration for pulse_nc + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef PULSE_NC_H +#define PULSE_NC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "s_pulseinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void pulse_nc( + Int16 coef[], + const PulseInfo *pPulseInfo, + const FrameInfo *pLongFrameInfo, + Int *max); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.c new file mode 100644 index 00000000..97ea05b3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.c @@ -0,0 +1,184 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_div.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer numerator + Int32 y 32-bit integer denominator + Quotient *result structure that hold result and shift factor + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement division of two Int32 numbers, provides back quotient and a + shift factor +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "pv_div.h" +#include "pv_normalize.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pv_div(Int32 x, Int32 y, Quotient *result) +{ + /*---------------------------------------------------------------------------- + ; Define all local variables + ----------------------------------------------------------------------------*/ + Int32 quotient; + Int32 i; + Int32 j; + Int32 y_ov_y_hi; + Int32 flag = 0; /* carries negative sign, if any */ + + + result->shift_factor = 0; /* default */ + + if (y == 0) + { + x = 0; /* this will return 0 for any div/0 */ + } + /* + * make sure x and y are both positive + */ + + if (y < 0) + { + y = -y; + flag ^= 1; + } + + + if (x < 0) + { + x = -x; + flag ^= 1; + } + + if (x != 0) + { + /*---------------------------------------------------------------------------- + ; Scale the input to get maximum precision for x + ----------------------------------------------------------------------------*/ + + i = pv_normalize(x); + + x <<= i; + + + /*---------------------------------------------------------------------------- + ; Scale the input to get maximum precision for y + ----------------------------------------------------------------------------*/ + + j = pv_normalize(y); + + y <<= j; + + result->shift_factor = i - j; + + /*---------------------------------------------------------------------------- + ; Function body here + ----------------------------------------------------------------------------*/ + /*--------------------------------------------------------------- + ; take the inverse of the 16 MSB of y + ---------------------------------------------------------------*/ + + quotient = (0x40000000 / (y >> 15)); + + y_ov_y_hi = fxp_mul32_Q15(y, quotient); /* y*(1/y_hi) */ + + y_ov_y_hi = 0x7FFFFFFF - y_ov_y_hi; /* 2 - y*(1/y_hi) */ + y_ov_y_hi = fxp_mul32_Q14(quotient, y_ov_y_hi); + i = fxp_mul32_Q31(y_ov_y_hi, x) << 1; + + result->quotient = flag ? -i : i; + } + else + { + result->quotient = 0; + } + + + +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.h new file mode 100644 index 00000000..fbdb0e90 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_div.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_div.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_DIV_H +#define PV_DIV_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + struct intg_div + { + Int32 quotient; + Int32 shift_factor; + }; + typedef struct intg_div Quotient; + + + void pv_div(Int32 x, Int32 y, Quotient *quotient); + +#ifdef __cplusplus +} +#endif + +#endif /* PV_DIV_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_log2.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_log2.c new file mode 100644 index 00000000..ec9126b7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_log2.c @@ -0,0 +1,163 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_log2.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer input + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement the logarithm base 2 of a number +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "pv_log2.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 20 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 log_table[9] = +{ + Q_fmt(-0.00879832091331F), Q_fmt(0.12022974263833F), + Q_fmt(-0.72883958314294F), Q_fmt(2.57909824242332F), + Q_fmt(-5.90041216630330F), Q_fmt(9.15023342527264F), + Q_fmt(-9.90616619500413F), Q_fmt(8.11228968755409F), + Q_fmt(-3.41763474309898F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +Int32 pv_log2(Int32 z) +{ + const Int32 *pt_table = log_table; + Int32 y; + Int32 i; + + Int32 int_log2 = 0; + + if (z > Q_fmt(2.0f)) + { + while (z > Q_fmt(2.0f)) + { + z >>= 1; + int_log2++; + } + } + else if (z < Q_fmt(1.0f)) + { + { + while (z < Q_fmt(1.0f)) + { + z <<= 1; + int_log2--; + } + } + } + + /* + * at this point, input limited to 1 0x0FFFFFFF) + { + i = 0; /* most likely case */ + } + else if (x > 0x00FFFFFF) + { + i = 3; /* second most likely case */ + } + else if (x > 0x0000FFFF) + { + i = x > 0x000FFFFF ? 7 : 11; + } + else + { + if (x > 0x000000FF) + { + i = x > 0x00000FFF ? 15 : 19; + } + else + { + i = x > 0x0000000F ? 23 : 27; + } + } + + + x <<= i; + + switch (x & 0x78000000) + { + case 0x08000000: + i += 3; + break; + + case 0x18000000: + case 0x10000000: + i += 2; + break; + case 0x28000000: + case 0x20000000: + case 0x38000000: + case 0x30000000: + i++; + + default: + ; + } + + return i; + +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_normalize.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_normalize.h new file mode 100644 index 00000000..46983473 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_normalize.h @@ -0,0 +1,100 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_normalize.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_NORMALIZE_H +#define PV_NORMALIZE_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES AND SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +#if defined(PV_ARM_V5) + +static inline Int pv_normalize(Int32 x) +{ + Int32 y; + __asm + { + clz y, x; + sub y, y, #1 + } + return (y); +} + + +#elif defined(PV_ARM_GCC_V5) + +static inline Int pv_normalize(Int32 x) +{ + register Int32 y; + register Int32 ra = x; + + + asm volatile( + "clz %0, %1\n\t" + "sub %0, %0, #1" + : "=&r*i"(y) + : "r"(ra)); + return (y); + +} + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int pv_normalize(Int32 x); + +#ifdef __cplusplus +} +#endif + +#endif + + + +#endif /* PV_NORMALIZE_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.c new file mode 100644 index 00000000..2309f1c4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.c @@ -0,0 +1,163 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_pow2.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + +Input + Int32 x 32-bit integer input Q27 + +Output + Int32 32-bit integer in Q25 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement the power base 2 for positive numbers lesser than 5.999999 +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ +#include "config.h" +#ifdef AAC_PLUS + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_pow2.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#define POW_2_TABLE_LENGTH 6 +#define POW_2_TABLE_LENGTH_m_2 (POW_2_TABLE_LENGTH - 2) + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 29 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +#define Q27fmt(x) (Int32)(x*((Int32)1<<27) + (x>=0?0.5F:-0.5F)) + +const Int32 pow2_table[6] = +{ + Q_fmt(0.00224510927441F), Q_fmt(0.00777943379416F), + Q_fmt(0.05737929218747F), Q_fmt(0.23918017179889F), + Q_fmt(0.69345251849351F), Q_fmt(0.99996347120248F) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +/* + * z in Q27 format + */ + +Int32 pv_pow2(Int32 z) +{ + const Int32 *pt_table = pow2_table; + Int32 multiplier = 0; + Int32 shift_factor; + Int32 i; + Int32 v_q; + Int32 y; + + + if (z > Q27fmt(1.0f)) + { + v_q = z - (z & 0xF8000000); + shift_factor = z >> 27; + } + else + { + v_q = z; + shift_factor = 0; + } + + if (v_q < Q27fmt(0.5f)) + { + v_q += Q27fmt(0.5f); + multiplier = Q_fmt(0.70710678118655F); + } + + v_q = v_q << 2; + + y = fxp_mul32_Q29(*(pt_table++), v_q); + + for (i = POW_2_TABLE_LENGTH_m_2; i != 0; i--) + { + y += *(pt_table++); + y = fxp_mul32_Q29(y, v_q); + } + y += *(pt_table++); + + if (multiplier) + { + y = fxp_mul32_Q29(y, multiplier); + } + + /* + * returns number on Q25 + */ + return (y >> (4 - shift_factor)); + +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.h new file mode 100644 index 00000000..65338409 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_pow2.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_pow2.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_POW2_H +#define PV_POW2_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + Int32 pv_pow2(Int32 z); + + +#ifdef __cplusplus +} +#endif + +#endif /* PV_POW2_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.c new file mode 100644 index 00000000..f979b936 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.c @@ -0,0 +1,177 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sine.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer angle (in Q30) between 0 and pi/2 + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Find the sine of a number between 0 and pi/2 +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + +#ifdef PARAMETRICSTEREO + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "pv_sine.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 + +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 sin_table[9] = +{ + Q_fmt(0.00001724684028), Q_fmt(-0.00024606242846), + Q_fmt(0.00007297328923), Q_fmt(0.00826706596417), + Q_fmt(0.00003585160465), Q_fmt(-0.16667772526248), + Q_fmt(0.00000174197440), Q_fmt(0.99999989138797), + Q_fmt(0.00000000110513) +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +Int32 pv_sine(Int32 z) +{ + Int32 sine; + Int32 i; + const Int32 *pt_table = sin_table; + Int32 sign = 0; + + if (z < 0) + { + z = -z; + sign = 1; + } + + if (z > Q_fmt(0.0015)) + { + sine = fxp_mul32_Q30(*(pt_table++), z); + + for (i = 7; i != 0; i--) + { + sine += *(pt_table++); + sine = fxp_mul32_Q30(sine, z); + } + + } + else + { + sine = z; /* better approximation in this range */ + } + + if (sign) + { + sine = -sine; + } + + return sine; +} + + + +Int32 pv_cosine(Int32 z) +{ + Int32 cosine; + + if (z < 0) + { + z = -z; /* sign does not play a role in cosine */ + } + + if (z > Q_fmt(0.0015)) + { + z = Q_fmt(1.57079632679490) - z; /* pi/2 - z */ + + cosine = pv_sine(z); + } + else + { /* better approximation in this range */ + cosine = Q_fmt(0.99999999906868) - (fxp_mul32_Q30(z, z) >> 1); + } + + return cosine; +} + +#endif + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.h new file mode 100644 index 00000000..14681d72 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sine.h @@ -0,0 +1,63 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sine.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_SINE_H +#define PV_SINE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + Int32 pv_sine(Int32 x); + Int32 pv_cosine(Int32 x); + +#ifdef __cplusplus +} +#endif + +#endif /* PV_SINE_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.c new file mode 100644 index 00000000..a4fd7ed1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.c @@ -0,0 +1,213 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sqrt.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 x 32-bit integer + + Int32 y 32-bit integer + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" + +#include "fxp_mul32.h" +#include "pv_sqrt.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#define R_SHIFT 28 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + + +const Int32 sqrt_table[9] = +{ + Q_fmt(-0.13829740941110F), Q_fmt(0.95383399963991F), + Q_fmt(-2.92784603873353F), Q_fmt(5.27429191920042F), + Q_fmt(-6.20272445821478F), Q_fmt(5.04717433019620F), + Q_fmt(-3.03362807640415F), Q_fmt(1.86178814410910F), + Q_fmt(0.16540758699193F) +}; + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache) +{ + + Int32 y; + Int32 xx; + Int32 nn; + Int32 i; + const Int32 *pt_table = sqrt_table; + + + if (sqrt_cache[0] == man && sqrt_cache[1] == exp) + { + result->root = sqrt_cache[2]; + result->shift_factor = (Int16)sqrt_cache[3]; + } + else + { + + sqrt_cache[0] = man; + sqrt_cache[1] = exp; + + + if (man > 0) + { + xx = man; + if (man >= Q_fmt(1.0f)) + { + nn = exp + 1; + while ((xx >>= 1) > Q_fmt(1.0f)) + { + nn++; + } + } + else if (man < Q_fmt(0.5f)) + { + nn = exp - 1; + while ((xx <<= 1) < Q_fmt(0.5f)) + { + nn--; + } + } + else + { + nn = exp; + } + + + y = fxp_mul32_Q28(*(pt_table++), xx); + + for (i = 3; i != 0; i--) + { + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx); + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx); + } + y += *(pt_table++); + y = fxp_mul32_Q28(y, xx) + *(pt_table++); + + if (nn >= 0) + { + if (nn&1) + { + y = fxp_mul32_Q29(y, Q_fmt(1.41421356237310F)); + result->shift_factor = (nn >> 1) - 28; + } + else + { + result->shift_factor = (nn >> 1) - 29; + } + } + else + { + if (nn&1) + { + y = fxp_mul32_Q28(y, Q_fmt(0.70710678118655F)); + } + + result->shift_factor = -((-nn) >> 1) - 29; + } + + result->root = y; + + } + else + { + result->root = 0; + result->shift_factor = 0; + } + + } + + sqrt_cache[2] = result->root; + sqrt_cache[3] = result->shift_factor; + +} + + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.h new file mode 100644 index 00000000..7c0a4cdc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pv_sqrt.h @@ -0,0 +1,69 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pv_sqrt.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef PV_SQRT_H +#define PV_SQRT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + struct intg_sqrt + { + Int32 root; + Int32 shift_factor; + }; + typedef struct intg_sqrt Root_sq; + + void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache); + + +#ifdef __cplusplus +} +#endif + +#endif /* PV_SQRT_H */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderconfig.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderconfig.c new file mode 100644 index 00000000..2fd6d718 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderconfig.c @@ -0,0 +1,250 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + subclause 1.6 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "config.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +OSCL_EXPORT_REF Int PVMP4AudioDecoderConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + + UInt initialUsedBits; /* Unsigned for C55x */ + tDec_Int_File *pVars; /* Helper pointer */ + + Int status = MP4AUDEC_INCOMPLETE_FRAME; + + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.inputBufferCurrentLength = + (UInt)pExt->inputBufferCurrentLength; + + pVars->inputStream.availableBits = + (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + pExt->remainderBits); + + pVars->inputStream.usedBits = initialUsedBits; + + if (initialUsedBits <= pVars->inputStream.availableBits) + { + + /* + * Buffer is not overrun, then + * decode the AudioSpecificConfig() structure + */ + + pVars->aacConfigUtilityEnabled = FALSE; /* set aac dec mode */ + + status = get_audio_specific_config(pVars); + + } + + byte_align(&pVars->inputStream); + + + if (status == SUCCESS) + { + + pVars->bno++; + + /* + * A possible improvement would be to set these values only + * when they change. + */ + pExt->samplingRate = + samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate; + + /* + * we default to 2 channel, even for mono files, (where channels have same content) + * this is done to ensure support for enhanced aac+ with implicit signalling + */ + pExt->aacPlusEnabled = pVars->aacPlusEnabled; + +// pExt->encodedChannels = pVars->mc_info.nch; + + pExt->encodedChannels = 2; + + pExt->frameLength = pVars->frameLength; +#ifdef AAC_PLUS + pExt->aacPlusUpsamplingFactor = pVars->mc_info.upsamplingFactor; +#endif + + } + else + { + /* + * Default to nonrecoverable error status unless there is a Buffer overrun + */ + status = MP4AUDEC_INVALID_FRAME; + + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + /* all bits were used but were not enough to complete parsing */ + pVars->inputStream.usedBits = pVars->inputStream.availableBits; + + status = MP4AUDEC_INCOMPLETE_FRAME; /* audio config too small */ + } + + } + + /* + * Translate from units of bits back into units of words. + */ + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->status = status; + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderframe.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderframe.c new file mode 100644 index 00000000..770f7c98 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderframe.c @@ -0,0 +1,1287 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderframe.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + bitRate - bit rate in bits per second, varies frame to frame. + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes one frame of an MPEG-2/MPEG-4 encoded audio bitstream. + + This function calls the various components of the decoder in the proper order. + + + Left Channel Right Channel + | | + | | + | | + \|/ \|/ + #1 ____________________ #2 ____________________ + | | | | + | Huffman Decoding | | Huffman Decoding | + |__________________| |__________________| + | | + | | + | | + \|/ | + #3 ____________________ | + | | | + | PNS LEFT | | + |__________________| | + | | + | | + | | + \|/ \|/ + #4 ______________________________________________________________________ + | | + | Apply MS_Synt | + |____________________________________________________________________| + | | + | | + \|/ | + #5 ____________________ | + | | W + | LTP | A + |__________________| I + | T + | | + | F + \|/ O + #6 ____________________ R + | | | + | Time -> Freq | L + |__________________| E + | F + | T + | | + \|/ C + #7 ____________________ H + | | A + | TNS Inverse | N + |__________________| N + | E + | L + | | + \|/ | + #8 ____________________ | + | | | + | Long Term Synth | | + |__________________| | + | | + | \|/ + | #9 ____________________ + | | | + |--DATA ON LEFT CHANNEL MAY BE USED----->| PNS/Intensity Rt | + | |__________________| + | | + | | + | \|/ + | #10 ____________________ + W | | + A | LTP | + I |__________________| + T | + | | + F | + O \|/ + R #11 ____________________ + | | | + R | Time -> Freq | + I |__________________| + G | + H | + T | + | \|/ + C #12 ____________________ + H | | + A | TNS Inverse | + N |__________________| + N | + E | + L | + | \|/ + | #13 ____________________ + | | | + | | Long Term Synth | + | |__________________| + | | + | | + | | + \|/ \|/ +#14 ____________________ #18 ____________________ + | | | | + | TNS | | TNS | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#15 ____________________ #19 ____________________ + | | | | + | qFormatNorm | | qFormatNorm | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#16 ____________________ #20 ____________________ + | | | | + | Freq / Time | | Freq / Time | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#17 ____________________ #21 ____________________ + | | | | + | Limit Buffer | | Limit Buffer | + |__________________| |__________________| + | | + | | + | | + \|/ \|/ +#22 ______________________________________________________________________ + | | + | Write Output | + |____________________________________________________________________| + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#include "s_tdec_int_chan.h" +#include "s_tdec_int_file.h" +#include "aac_mem_funcs.h" +#include "sfb.h" /* Where samp_rate_info[] is declared */ +#include "e_tmp4audioobjecttype.h" +#include "e_elementid.h" + + +#include "get_adif_header.h" +#include "get_adts_header.h" +#include "get_audio_specific_config.h" +#include "ibstream.h" /* where getbits is declared */ + +#include "huffman.h" /* where huffdecode is declared */ +#include "get_prog_config.h" +#include "getfill.h" +#include "pns_left.h" + +#include "apply_ms_synt.h" +#include "pns_intensity_right.h" +#include "q_normalize.h" +#include "long_term_prediction.h" +#include "long_term_synthesis.h" +#include "ltp_common_internal.h" +#include "apply_tns.h" + +#include "window_block_fxp.h" + +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "get_dse.h" + +#include "sbr_applied.h" +#include "sbr_open.h" +#include "get_sbr_bitstream.h" +#include "e_sbr_element_id.h" +#include "config.h" + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define LEFT (0) +#define RIGHT (1) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +void InitSbrSynFilterbank(Bool bDownSampleSBR); + + + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +OSCL_EXPORT_REF Int PVMP4AudioDecodeFrame( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + Int frameLength; /* Helper variable */ + Int ch; + Int id_syn_ele; + UInt initialUsedBits; /* Unsigned for C55x */ + Int qFormatNorm; + Int qPredictedSamples; + Bool leaveGetLoop; + MC_Info *pMC_Info; /* Helper pointer */ + FrameInfo *pFrameInfo; /* Helper pointer */ + tDec_Int_File *pVars; /* Helper pointer */ + tDec_Int_Chan *pChVars[Chans]; /* Helper pointer */ + + per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */ + per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */ + + Int status = MP4AUDEC_SUCCESS; + + + Bool empty_frame; + +#ifdef AAC_PLUS + + SBRDECODER_DATA *sbrDecoderData; + SBR_DEC *sbrDec; + SBRBITSTREAM *sbrBitStream; +#endif + Int32 i; + + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + + pMC_Info = &pVars->mc_info; + + pChVars[LEFT] = &pVars->perChan[LEFT]; + pChVars[RIGHT] = &pVars->perChan[RIGHT]; + + pChLeftShare = pChVars[LEFT]->pShareWfxpCoef; + pChRightShare = pChVars[RIGHT]->pShareWfxpCoef; + + +#ifdef AAC_PLUS + + sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData; + sbrDec = (SBR_DEC *) & pVars->sbrDec; + sbrBitStream = (SBRBITSTREAM *) & pVars->sbrBitStr; + +#ifdef PARAMETRICSTEREO + sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec; +#endif + +#endif + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.inputBufferCurrentLength = (UInt)pExt->inputBufferCurrentLength; + + pVars->inputStream.availableBits = + (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT); + + initialUsedBits = + (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) + + pExt->remainderBits); + + pVars->inputStream.usedBits = initialUsedBits; + + if (initialUsedBits > pVars->inputStream.availableBits) + { + status = MP4AUDEC_INVALID_FRAME; + } + else if (pVars->bno == 0) + { + /* + * Attempt to read in ADIF format first because it is easily identified. + * If its not an ADIF bitstream, get_adif_header rewinds the "pointer" + * (actually usedBits). + */ + status = + get_adif_header( + pVars, + &(pVars->scratch.scratch_prog_config)); + + byte_align(&pVars->inputStream); + + if (status == SUCCESS) + { + pVars->prog_config.file_is_adts = FALSE; + } + else /* we've tried simple audio config, adif, then it should be adts */ + { + pVars->prog_config.file_is_adts = TRUE; + } + } + else if ((pVars->bno == 1) && (pVars->prog_config.file_is_adts == FALSE)) + { + + /* + * There might be an ID_END element following immediately after the + * AudioSpecificConfig header. This syntactic element should be read + * and byte_aligned before proceeds to decode "real" AAC raw data. + */ + id_syn_ele = (Int)getbits(LEN_SE_ID, &pVars->inputStream) ; + + if (id_syn_ele == ID_END) + { + + byte_align(&pVars->inputStream); + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->bno++; + + return(status); + } + else + { + /* + * Rewind bitstream pointer so that the syntactic element can be + * read when decoding raw bitstream + */ + pVars->inputStream.usedBits -= LEN_SE_ID; + } + + } + + if (pVars->prog_config.file_is_adts == TRUE) + { + /* + * If file is adts format, let the decoder handle only on data raw + * block at the time, once the last (or only) data block has been + * processed, then synch on the next header + */ + if (pVars->prog_config.headerless_frames) + { + pVars->prog_config.headerless_frames--; /* raw data block counter */ + } + else + { + status = get_adts_header(pVars, + &(pVars->syncword), + &(pVars->invoke), + 3); /* CorrectlyReadFramesCount */ + + if (status != SUCCESS) + { + status = MP4AUDEC_LOST_FRAME_SYNC; /* we lost track of header */ + } + } + } + else + { + byte_align(&pVars->inputStream); + } + +#ifdef AAC_PLUS + sbrBitStream->NrElements = 0; + sbrBitStream->NrElementsCore = 0; + +#endif + + /* + * The variable leaveGetLoop is used to signal that the following + * loop can be left, which retrieves audio syntatic elements until + * an ID_END is found, or an error occurs. + */ + leaveGetLoop = FALSE; + empty_frame = TRUE; + + while ((leaveGetLoop == FALSE) && (status == SUCCESS)) + { + /* get audio syntactic element */ + id_syn_ele = (Int)get9_n_lessbits(LEN_SE_ID, &pVars->inputStream); + + /* + * As fractional frames are a possible input, check that parsing does not + * go beyond the available bits before parsing the syntax. + */ + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */ + id_syn_ele = ID_END; /* quit while-loop */ + } + + switch (id_syn_ele) + { + case ID_END: /* terminator field */ + leaveGetLoop = TRUE; + break; + + case ID_SCE: /* single channel */ + case ID_CPE: /* channel pair */ + empty_frame = FALSE; + status = + huffdecode( + id_syn_ele, + &(pVars->inputStream), + pVars, + pChVars); + +#ifdef AAC_PLUS + if (id_syn_ele == ID_SCE) + { + sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_SCE; + } + else if (id_syn_ele == ID_CPE) + { + sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_CPE; + } + sbrBitStream->NrElementsCore++; + + +#endif + + break; + + case ID_PCE: /* program config element */ + /* + * PCE are not accepted in the middle of a + * raw_data_block. If found, a possible error may happen + * If a PCE is encountered during the first 2 frames, + * it will be read and accepted + * if its tag matches the first, with no error checking + * (inside of get_prog_config) + */ + + if (pVars->bno <= 1) + { + status = get_prog_config(pVars, + &(pVars->scratch.scratch_prog_config)); + } + else + { + status = MP4AUDEC_INVALID_FRAME; + } + break; + + case ID_FIL: /* fill element */ +#ifdef AAC_PLUS + get_sbr_bitstream(sbrBitStream, &pVars->inputStream); + +#else + getfill(&pVars->inputStream); +#endif + + break; + + case ID_DSE: /* Data Streaming element */ + get_dse(pVars->share.data_stream_bytes, + &pVars->inputStream); + break; + + default: /* Unsupported element, including ID_LFE */ + status = -1; /* ERROR CODE needs to be updated */ + break; + + } /* end switch() */ + + } /* end while() */ + + byte_align(&pVars->inputStream); + + /* + * After parsing the first frame ( bno=0 (adif), bno=1 (raw)) + * verify if implicit signalling is forcing to upsample AAC with + * no AAC+/eAAC+ content. If so, disable upsampling + */ + +#ifdef AAC_PLUS + if (pVars->bno <= 1) + { + if ((pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC) && + (!sbrBitStream->NrElements)) + { + PVMP4AudioDecoderDisableAacPlus(pExt, pMem); + } + } +#endif + + /* + * There might be an empty raw data block with only a + * ID_END element or non audio ID_DSE, ID_FIL + * This is an "illegal" condition but this trap + * avoids any further processing + */ + + if (empty_frame == TRUE) + { + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK; + + pVars->bno++; + + return(status); + + } + +#ifdef AAC_PLUS + + if (sbrBitStream->NrElements) + { + /* for every core SCE or CPE there must be an SBR element, otherwise sths. wrong */ + if (sbrBitStream->NrElements != sbrBitStream->NrElementsCore) + { + status = MP4AUDEC_INVALID_FRAME; + } + + if (pExt->aacPlusEnabled == FALSE) + { + sbrBitStream->NrElements = 0; /* disable aac processing */ + } + } + else + { + /* + * This is AAC, but if aac+/eaac+ was declared in the stream, and there is not sbr content + * something is wrong + */ + if (pMC_Info->sbrPresentFlag || pMC_Info->psPresentFlag) + { + status = MP4AUDEC_INVALID_FRAME; + } + } +#endif + + + + + /* + * Signal processing section. + */ + frameLength = pVars->frameLength; + + if (status == SUCCESS) + { + /* + * PNS and INTENSITY STEREO and MS + */ + + pFrameInfo = pVars->winmap[pChVars[LEFT]->wnd]; + + pns_left( + pFrameInfo, + pChLeftShare->group, + pChLeftShare->cb_map, + pChLeftShare->factors, + pChLeftShare->lt_status.sfb_prediction_used, + pChLeftShare->lt_status.ltp_data_present, + pChVars[LEFT]->fxpCoef, + pChLeftShare->qFormat, + &(pVars->pns_cur_noise_state)); + + /* + * apply_ms_synt can only be ran for common windows. + * (where both the left and right channel share the + * same grouping, window length, etc. + * + * pVars->hasmask will be > 0 only if + * common windows are enabled for this frame. + */ + + if (pVars->hasmask > 0) + { + apply_ms_synt( + pFrameInfo, + pChLeftShare->group, + pVars->mask, + pChLeftShare->cb_map, + pChVars[LEFT]->fxpCoef, + pChVars[RIGHT]->fxpCoef, + pChLeftShare->qFormat, + pChRightShare->qFormat); + } + + for (ch = 0; (ch < pMC_Info->nch); ch++) + { + pFrameInfo = pVars->winmap[pChVars[ch]->wnd]; + + /* + * Note: This MP4 library assumes that if there are two channels, + * then the second channel is right AND it was a coupled channel, + * therefore there is no need to check the "is_cpe" flag. + */ + + if (ch > 0) + { + pns_intensity_right( + pVars->hasmask, + pFrameInfo, + pChRightShare->group, + pVars->mask, + pChRightShare->cb_map, + pChLeftShare->factors, + pChRightShare->factors, + pChRightShare->lt_status.sfb_prediction_used, + pChRightShare->lt_status.ltp_data_present, + pChVars[LEFT]->fxpCoef, + pChVars[RIGHT]->fxpCoef, + pChLeftShare->qFormat, + pChRightShare->qFormat, + &(pVars->pns_cur_noise_state)); + } + + if (pChVars[ch]->pShareWfxpCoef->lt_status.ltp_data_present != FALSE) + { + /* + * LTP - Long Term Prediction + */ + + qPredictedSamples = long_term_prediction( + pChVars[ch]->wnd, + pChVars[ch]->pShareWfxpCoef->lt_status. + weight_index, + pChVars[ch]->pShareWfxpCoef->lt_status. + delay, + pChVars[ch]->ltp_buffer, + pVars->ltp_buffer_state, + pChVars[ch]->time_quant, + pVars->share.predictedSamples, /* Scratch */ + frameLength); + + trans4m_time_2_freq_fxp( + pVars->share.predictedSamples, + pChVars[ch]->wnd, + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + &qPredictedSamples, + pVars->scratch.fft); /* scratch memory for FFT */ + + + /* + * To solve a potential problem where a pointer tied to + * the qFormat was being incremented, a pointer to + * pChVars[ch]->qFormat is passed in here rather than + * the address of qPredictedSamples. + * + * Neither values are actually needed in the case of + * inverse filtering, but the pointer was being + * passed (and incremented) regardless. + * + * So, the solution is to pass a space of memory + * that a pointer can happily point to. + */ + + /* This is the inverse filter */ + apply_tns( + pVars->share.predictedSamples, /* scratch re-used for each ch */ + pChVars[ch]->pShareWfxpCoef->qFormat, /* Not used by the inv_filter */ + pFrameInfo, + &(pChVars[ch]->pShareWfxpCoef->tns), + TRUE, /* TRUE is FIR */ + pVars->scratch.tns_inv_filter); + + /* + * For the next function long_term_synthesis, + * the third param win_sfb_top[], and + * the tenth param coef_per_win, + * are used differently that in the rest of the project. This + * is because originally the ISO code was going to have + * these parameters change as the "short window" changed. + * These are all now the same value for each of the eight + * windows. This is why there is a [0] at the + * end of each of theses parameters. + * Note in particular that win_sfb_top was originally an + * array of pointers to arrays, but inside long_term_synthesis + * it is now a simple array. + * When the rest of the project functions are changed, the + * structure FrameInfo changes, and the [0]'s are removed, + * this comment could go away. + */ + long_term_synthesis( + pChVars[ch]->wnd, + pChVars[ch]->pShareWfxpCoef->max_sfb, + pFrameInfo->win_sfb_top[0], /* Look above */ + pChVars[ch]->pShareWfxpCoef->lt_status.win_prediction_used, + pChVars[ch]->pShareWfxpCoef->lt_status.sfb_prediction_used, + pChVars[ch]->fxpCoef, /* input and output */ + pChVars[ch]->pShareWfxpCoef->qFormat, /* input and output */ + pVars->share.predictedSamples, + qPredictedSamples, /* q format for previous aray */ + pFrameInfo->coef_per_win[0], /* Look above */ + NUM_SHORT_WINDOWS, + NUM_RECONSTRUCTED_SFB); + + } /* end if (pChVars[ch]->lt_status.ltp_data_present != FALSE) */ + + } /* for(ch) */ + + for (ch = 0; (ch < pMC_Info->nch); ch++) + { + + pFrameInfo = pVars->winmap[pChVars[ch]->wnd]; + + /* + * TNS - Temporal Noise Shaping + */ + + /* This is the forward filter + * + * A special note: Scratch memory is not used by + * the forward filter, but is passed in to maintain + * common interface for inverse and forward filter + */ + apply_tns( + pChVars[ch]->fxpCoef, + pChVars[ch]->pShareWfxpCoef->qFormat, + pFrameInfo, + &(pChVars[ch]->pShareWfxpCoef->tns), + FALSE, /* FALSE is IIR */ + pVars->scratch.tns_inv_filter); + + /* + * Normalize the q format across all scale factor bands + * to one value. + */ + qFormatNorm = + q_normalize( + pChVars[ch]->pShareWfxpCoef->qFormat, + pFrameInfo, + pChVars[ch]->abs_max_per_window, + pChVars[ch]->fxpCoef); + + /* + * filterbank - converts frequency coeficients to time domain. + */ + +#ifdef AAC_PLUS + if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1) + { + trans4m_freq_2_time_fxp_2( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft, + &pExt->pOutputBuffer[ch]); + /* + * Update LTP buffers if needed + */ + + if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP) + { + Int16 * pt = &pExt->pOutputBuffer[ch]; + Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 x, y; + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + x = *pt; + pt += 2; + y = *pt; + pt += 2; + *(ptr++) = x; + *(ptr++) = y; + } + } + } + else + { + trans4m_freq_2_time_fxp_1( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state + 288]), + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft); + + } +#else + + trans4m_freq_2_time_fxp_2( + pChVars[ch]->fxpCoef, + pChVars[ch]->time_quant, + pChVars[ch]->wnd, /* window sequence */ + pChVars[ch]->wnd_shape_prev_bk, + pChVars[ch]->wnd_shape_this_bk, + qFormatNorm, + pChVars[ch]->abs_max_per_window, + pVars->scratch.fft, + &pExt->pOutputBuffer[ch]); + /* + * Update LTP buffers only if needed + */ + + if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP) + { + Int16 * pt = &pExt->pOutputBuffer[ch]; + Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 x, y; + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + x = *pt; + pt += 2; + y = *pt; + pt += 2; + *(ptr++) = x; + *(ptr++) = y; + } + + } + + +#endif + + + /* Update the window shape */ + pChVars[ch]->wnd_shape_prev_bk = pChVars[ch]->wnd_shape_this_bk; + + } /* end for() */ + + + /* + * Copy to the final output buffer, taking into account the desired + * channels from the calling environment, the actual channels, and + * whether the data should be interleaved or not. + * + * If the stream had only one channel, write_output will not use + * the right channel data. + * + */ + + + /* CONSIDER USE OF DMA OPTIMIZATIONS WITHIN THE write_output FUNCTION. + * + * It is presumed that the ltp_buffer will reside in internal (fast) + * memory, while the pExt->pOutputBuffer will reside in external + * (slow) memory. + * + */ + + +#ifdef AAC_PLUS + + if (sbrBitStream->NrElements || pMC_Info->upsamplingFactor == 2) + { + + if (pVars->bno <= 1) /* allows console to operate with ADIF and audio config */ + { + if (sbrDec->outSampleRate == 0) /* do it only once (disregarding of signaling type) */ + { + sbr_open(samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate, + sbrDec, + sbrDecoderData, + pVars->mc_info.bDownSampledSbr); + } + + } + pMC_Info->upsamplingFactor = + sbrDecoderData->SbrChannel[0].frameData.sbr_header.sampleRateMode; + + + /* reuse right aac spectrum channel */ + { + Int16 *pt_left = &(pChVars[LEFT ]->ltp_buffer[pVars->ltp_buffer_state]); + Int16 *pt_right = &(pChVars[RIGHT]->ltp_buffer[pVars->ltp_buffer_state]); + + if (sbr_applied(sbrDecoderData, + sbrBitStream, + pt_left, + pt_right, + pExt->pOutputBuffer, + sbrDec, + pVars, + pMC_Info->nch) != SBRDEC_OK) + { + status = MP4AUDEC_INVALID_FRAME; + } + } + + + } /* if( pExt->aacPlusEnabled == FALSE) */ +#endif + + /* + * Copied mono data in both channels or just leave it as mono, + * according with desiredChannels (default is 2) + */ + + if (pExt->desiredChannels == 2) + { + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1) +#else + if (pMC_Info->nch != 2) +#endif +#else + if (pMC_Info->nch != 2) +#endif + { + /* mono */ + + + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[1]; + Int i; + if (pMC_Info->upsamplingFactor == 2) + { + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + pt = &pExt->pOutputBuffer_plus[0]; + pt2 = &pExt->pOutputBuffer_plus[1]; + + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } + else + { + for (i = 0; i < 1024; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } + + } + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + + else if (pMC_Info->psPresentFlag == 1) + { + Int32 frameSize = 0; + if (pExt->aacPlusEnabled == FALSE) + { + /* + * Decoding eaac+ when only aac is enabled, copy L into R + */ + frameSize = 1024; + } + else if (sbrDecoderData->SbrChannel[0].syncState != SBR_ACTIVE) + { + /* + * Decoding eaac+ when no PS data was found, copy upsampled L into R + */ + frameSize = 2048; + } + + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[1]; + Int i; + for (i = 0; i < frameSize; i++) + { + *pt2 = *pt; + pt += 2; + pt2 += 2; + } + } +#endif +#endif + + } + else + { + +#if defined(AAC_PLUS) +#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR) + if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1) +#else + if (pMC_Info->nch != 2) +#endif +#else + if (pMC_Info->nch != 2) +#endif + { + /* mono */ + Int16 * pt = &pExt->pOutputBuffer[0]; + Int16 * pt2 = &pExt->pOutputBuffer[0]; + Int i; + + if (pMC_Info->upsamplingFactor == 2) + { + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + + pt = &pExt->pOutputBuffer_plus[0]; + pt2 = &pExt->pOutputBuffer_plus[0]; + + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + } + else + { + for (i = 0; i < 1024; i++) + { + *pt2++ = *pt; + pt += 2; + } + } + + } + + } + + + + + /* pVars->ltp_buffer_state cycles between 0 and 1024. The value + * indicates the location of the data corresponding to t == -2. + * + * | t == -2 | t == -1 | pVars->ltp_buffer_state == 0 + * + * | t == -1 | t == -2 | pVars->ltp_buffer_state == 1024 + * + */ + +#ifdef AAC_PLUS + if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1) + { + pVars->ltp_buffer_state ^= frameLength; + } + else + { + pVars->ltp_buffer_state ^= (frameLength + 288); + } +#else + pVars->ltp_buffer_state ^= frameLength; +#endif + + + if (pVars->bno <= 1) + { + /* + * to set these values only during the second call + * when they change. + */ + pVars->ltp_buffer_state = 0; + pExt->samplingRate = + samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate; + + pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed + * only the first time + */ + + +#ifdef AAC_PLUS + + if (pMC_Info->upsamplingFactor == 2) + { + pExt->samplingRate *= pMC_Info->upsamplingFactor; + pExt->aacPlusUpsamplingFactor = pMC_Info->upsamplingFactor; + } + +#endif + + pExt->extendedAudioObjectType = pMC_Info->ExtendedAudioObjectType; + pExt->audioObjectType = pMC_Info->audioObjectType; + + pExt->encodedChannels = pMC_Info->nch; + pExt->frameLength = pVars->frameLength; + } + + pVars->bno++; + + + /* + * Using unit analysis, the bitrate is a function of the sampling rate, bits, + * points in a frame + * + * bits samples frame + * ---- = --------- * bits * ------- + * sec sec sample + * + * To save a divide, a shift is used. Presently only the value of + * 1024 is used by this library, so make it the most accurate for that + * value. This may need to be updated later. + */ + + pExt->bitRate = (pExt->samplingRate * + (pVars->inputStream.usedBits - initialUsedBits)) >> 10; /* LONG_WINDOW 1024 */ + + pExt->bitRate >>= (pMC_Info->upsamplingFactor - 1); + + + } /* end if (status == SUCCESS) */ + + + if (status != MP4AUDEC_SUCCESS) + { + /* + * A non-SUCCESS decoding could be due to an error on the bitstream or + * an incomplete frame. As access to the bitstream beyond frame boundaries + * are not allowed, in those cases the bitstream reading routine return a 0 + * Zero values guarantees that the data structures are filled in with values + * that eventually will signal an error (like invalid parameters) or that allow + * completion of the parsing routine. Either way, the partial frame condition + * is verified at this time. + */ + if (pVars->prog_config.file_is_adts == TRUE) + { + status = MP4AUDEC_LOST_FRAME_SYNC; + pVars->prog_config.headerless_frames = 0; /* synchronization forced */ + } + else + { + /* + * Check if the decoding error was due to buffer overrun, if it was, + * update status + */ + if (pVars->inputStream.usedBits > pVars->inputStream.availableBits) + { + /* all bits were used but were not enough to complete decoding */ + pVars->inputStream.usedBits = pVars->inputStream.availableBits; + + status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */ + } + } + } + + /* + * Translate from units of bits back into units of words. + */ + + pExt->inputBufferUsedLength = + pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT; + + pExt->remainderBits = (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK); + + + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecodergetmemrequirements.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecodergetmemrequirements.c new file mode 100644 index 00000000..620c3101 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecodergetmemrequirements.c @@ -0,0 +1,118 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecodergetmemrequirements.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: None + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + size = amount of memory needed to be allocated by the calling + environment. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function returns the amount of internal memory needed by the library. + Presently this is a constant value, but could later be more sophisticated + by taking into account mono or stereo, and whether LTP is to be used. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + +------------------------------------------------------------------------------ + PSEUDO-CODE + + size = sizeof(tDec_Int_File); + + RETURN (size) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void) +{ + UInt32 size; + + size = (UInt32) sizeof(tDec_Int_File); + + return (size); + +} /* PVMP4AudioDecoderGetMemRequirements() */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderinitlibrary.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderinitlibrary.c new file mode 100644 index 00000000..a7dcc19a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderinitlibrary.c @@ -0,0 +1,362 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderinitlibrary.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Initializes the internal memory for the MP4 Audio Decoder library. + Also sets relevant values for the external interface structure, clears + the bit rate, channel count, sampling rate, and number of used buffer + elements. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. +------------------------------------------------------------------------------ + PSEUDO-CODE + + pVars = pMem; + + CALL pv_memset( + to = pVars, + c = 0, + n = sizeof(tDec_Int_File)) + MODIFYING(*pVars = 0) + RETURNING(nothing) + + pVars->current_program = -1 + pVars->mc_info.sampling_rate_idx = Fs_44 + pVars->frameLength = LONG_WINDOW + + + pVars->winmap[ONLY_LONG_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] = &pVars->longFrameInfo; + + CALL infoinit( + samp_rate_indx = pVars->mc_info.sampling_rate_idx, + ppWin_seq_info = pVars->winmap, + pSfbwidth128 = pVars->SFBWidth128) + MODIFYING(ppWinSeq_info) + MODIFYING(pSfbwidth128) + RETURNING(nothing) + + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->inputBufferUsedLength = 0; + + MODIFY(pExt) + MODIFY(pMem) + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "e_progconfigconst.h" + +#include "huffman.h" /* For the definition of infoinit */ +#include "aac_mem_funcs.h" /* For pv_memset */ +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "s_tdec_int_chan.h" +#include "sfb.h" /* samp_rate_info[] is declared here */ +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + /* + * Initialize all memory. The pointers to channel memory will be + * set to zero also. + */ + pv_memset( + pVars, + 0, + sizeof(tDec_Int_File)); + + /* + * Pick default values for the library. + */ + pVars->perChan[0].fxpCoef = pVars->fxpCoef[0]; + pVars->perChan[1].fxpCoef = pVars->fxpCoef[1]; + + /* Here, the "shared memory" pointer is set to point + * at the 1024th element of fxpCoef, because those spaces + * in memory are not used until the filterbank is called. + * + * Therefore, any variables that are only used before + * the filterbank can occupy this same space in memory. + */ + + pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[0].fxpCoef[1024]); + + pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *) + & (pVars->perChan[1].fxpCoef[1024]); + + /* + * This next line informs the function get_prog_config that no + * configuration has been found thus far, so it is a default + * configuration. + */ + + pVars->current_program = -1; + pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */ + + /* + * In the future, the frame length will change with MP4 file format. + * Presently this variable is used to simply the unit test for + * the function PVMP4AudioDecodeFrame() .. otherwise the test would + * have to pass around 1024 length arrays. + */ + pVars->frameLength = LONG_WINDOW; /* 1024*/ + + /* + * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and + * LONG_STOP_SEQUENCE share the same information. The only difference + * between the windows is accounted for in the "filterbank", in + * the function trans4m_freq_2_time_fxp() + */ + + pVars->winmap[ONLY_LONG_SEQUENCE] /* 0 */ = &pVars->longFrameInfo; + pVars->winmap[LONG_START_SEQUENCE] /* 1 */ = &pVars->longFrameInfo; + pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo; + pVars->winmap[LONG_STOP_SEQUENCE] /* 3 */ = &pVars->longFrameInfo; + + infoinit( + pVars->mc_info.sampling_rate_idx, + (FrameInfo **)pVars->winmap, + pVars->SFBWidth128); + + + /* + * Clear out external output values. These values are set later at the end + * of PVMP4AudioDecodeFrames() + */ + pExt->bitRate = 0; + pExt->encodedChannels = 0; + pExt->samplingRate = 0; + pExt->aacPlusUpsamplingFactor = 1; /* Default for regular AAC */ + pVars->aacPlusEnabled = pExt->aacPlusEnabled; + + +#if defined(AAC_PLUS) + pVars->sbrDecoderData.setStreamType = 1; /* Enable Lock for AAC stream type setting */ +#endif + + /* + * Initialize input buffer variable. + */ + + pExt->inputBufferUsedLength = 0; + + return (MP4AUDEC_SUCCESS); + +} /* PVMP4AudioDecoderInitLibrary */ + + +/* +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external application-program interface (API) + structure that a client program uses to communicate information + with this library. Among the items in this structure is a pointer + to the input and output buffers, data for handling the input buffer + and output information. Look in PVMP4AudioDecoder_API.h for all the + fields to this structure. Data type pointer to a + tPVMP4AudioDecoderExternal structure. + + pMem = pointer to allocated memory, of the size returned by the function + PVMP4AudioDecoderGetMemRequirements. This is a void pointer for + two reasons: + 1) So the external program does not need all of the header files + for all of the fields in the structure tDec_Int_File + 2) To hide data and the implementation of the program. Even knowing + how data is stored can help in reverse engineering software. + + Local Stores/Buffers/Pointers Needed: None + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 (SUCCESS). Presently there is no error checking in this + function. + + Pointers and Buffers Modified: None + + Local Stores Modified: None + + Global Stores Modified: None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Disable SBR decoding functionality and set parameters accordingly + +------------------------------------------------------------------------------ + REQUIREMENTS + + +---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus( + tPVMP4AudioDecoderExternal *pExt, + void *pMem) +{ + tDec_Int_File *pVars; + + pVars = (tDec_Int_File *)pMem; + + if ((pVars->aacPlusEnabled == TRUE) && (pExt->aacPlusEnabled == TRUE)) + { + // disable only when makes sense + pVars->aacPlusEnabled = FALSE; + pExt->aacPlusEnabled = FALSE; + +#if defined(AAC_PLUS) + pVars->mc_info.upsamplingFactor = 1; + pVars->mc_info.psPresentFlag = 0; + pVars->mc_info.sbrPresentFlag = 0; + pVars->prog_config.sampling_rate_idx += 3; + pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED; + pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED; + + + pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate; + pExt->aacPlusUpsamplingFactor = 1; +#endif + } +} /* PVMP4AudioDecoderDisableAacPlus */ + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderresetbuffer.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderresetbuffer.c new file mode 100644 index 00000000..76eff59f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4audiodecoderresetbuffer.c @@ -0,0 +1,323 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4audiodecoderresetbuffer.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + PVMP4AudioDecodeFrame + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: None + + Pointers and Buffers Modified: + pMem contents are modified. + pMem->perChan[0].time_quant[0-1023]: contents are set to zero + pMem->perChan[1].time_quant[0-1023]: contents are set to zero + pMem->bno = 1 + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function is called when the same audio clip will be played again from + the begining. This situation happens when the "stop" button is pressed or + the "loop-mode" is selected on PVPlayer. Since it is the same audio clip to + be played again, the decoder does not need to reset the audioSpecificInfo. + However, the overlap-and-add buffer of the filterbank output needs to be + cleared, so that the decoder can re-start properly from the begining of + the audio. The frame number counter, pVars->bno, is set to 1 because the + audioSpecificInfo is decoded on pVars->bno==0 + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + subclause 1.6 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "aac_mem_funcs.h" +#include "config.h" + + +#ifdef AAC_PLUS +#include "s_sbr_frame_data.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LEFT (0) +#define RIGHT (1) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +OSCL_EXPORT_REF void PVMP4AudioDecoderResetBuffer(void *pMem) +{ + + tDec_Int_File *pVars; /* Helper pointer */ + +#ifdef AAC_PLUS + SBR_FRAME_DATA * hFrameData_1; + SBR_FRAME_DATA * hFrameData_2; +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + SBRDECODER_DATA *sbrDecoderData; +#endif +#endif + +#endif + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + + /* + * Clear the overlap-and-add buffer of filterbank output. The audio + * clip will be played again from the beginning. + */ + pv_memset(pVars->perChan[LEFT].time_quant, + 0, + LONG_WINDOW*sizeof(pVars->perChan[LEFT].time_quant[0])); + + pv_memset(pVars->perChan[RIGHT].time_quant, + 0, + LONG_WINDOW*sizeof(pVars->perChan[RIGHT].time_quant[0])); + + +#ifdef AAC_PLUS + + if (!pVars->sbrDecoderData.setStreamType) /* reset only when stream type is defined */ + { + if (pVars->aacPlusEnabled == TRUE) /* clear buffer only if they were used */ + { + + hFrameData_1 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[LEFT].frameData; + hFrameData_2 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[RIGHT].frameData; +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData; + sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec; +#endif +#endif + + + pv_memset(&pVars->perChan[LEFT].ltp_buffer[0], + 0, + 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0])); + pv_memset(&pVars->perChan[LEFT].ltp_buffer[1024 + 288], + 0, + 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0])); + pv_memset(hFrameData_1->V, + 0, + 1152*sizeof(hFrameData_1->V[0])); + pv_memset(hFrameData_1->prevNoiseLevel_man, + 0, + MAX_NUM_NOISE_VALUES*sizeof(hFrameData_1->prevNoiseLevel_man[0])); + + + pv_memset(&pVars->perChan[RIGHT].ltp_buffer[0], + 0, + 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0])); + pv_memset(&pVars->perChan[RIGHT].ltp_buffer[1024 + 288], + 0, + 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0])); + pv_memset(hFrameData_2->V, + 0, + 1152*sizeof(hFrameData_2->V[0])); + + pv_memset(hFrameData_2->prevNoiseLevel_man, + 0, + MAX_NUM_NOISE_VALUES*sizeof(hFrameData_2->prevNoiseLevel_man[0])); + + + int i; + for (i = 0; i < 8; i++) + { + pv_memset((void *)&hFrameData_1->codecQmfBufferReal[i], + 0, + sizeof(**hFrameData_1->codecQmfBufferReal) << 5); + } + + + /* ---- */ + pv_memset((void *)hFrameData_1->BwVectorOld, + 0, + sizeof(*hFrameData_1->BwVectorOld)*MAX_NUM_PATCHES); + +#ifdef HQ_SBR + + for (i = 0; i < 5; i++) + { + pv_memset((void *)&hFrameData_1->fBuffer_man[i], + 0, + sizeof(**hFrameData_1->fBuffer_man)*64); + pv_memset((void *)&hFrameData_1->fBufferN_man[i], + 0, + sizeof(**hFrameData_1->fBufferN_man)*64); + } +#endif + + + /* ---- */ + + + + pv_memset((void *)hFrameData_1->HistsbrQmfBufferReal, + 0, + sizeof(*hFrameData_1->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS); + +#ifdef HQ_SBR + pv_memset((void *)hFrameData_1->HistsbrQmfBufferImag, + 0, + sizeof(*hFrameData_1->HistsbrQmfBufferImag)*6*SBR_NUM_BANDS); +#endif + + if (pVars->sbrDec.LC_aacP_DecoderFlag == 1) /* clear buffer only for LC decoding */ + { + + for (i = 0; i < 8; i++) + { + pv_memset((void *)&hFrameData_2->codecQmfBufferReal[i], + 0, + sizeof(**hFrameData_1->codecQmfBufferReal) << 5); + } + + pv_memset((void *)hFrameData_2->HistsbrQmfBufferReal, + 0, + sizeof(*hFrameData_2->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS); + + + pv_memset((void *)hFrameData_2->BwVectorOld, + 0, + sizeof(*hFrameData_2->BwVectorOld)*MAX_NUM_PATCHES); + +#ifdef HQ_SBR + + for (i = 0; i < 5; i++) + { + pv_memset((void *)&hFrameData_2->fBuffer_man[i], + 0, + sizeof(**hFrameData_2->fBuffer_man)*64); + pv_memset((void *)&hFrameData_2->fBufferN_man[i], + 0, + sizeof(**hFrameData_2->fBufferN_man)*64); + } +#endif + + } + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + else if (pVars->mc_info.psPresentFlag == 1) + { + for (i = 0; i < 3; i++) + { + pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal[i], + 0, + HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal)); + pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag[i], + 0, + HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag)); + } + } +#endif +#endif + + /* + * default to UPSAMPLING, as if the file is SBR_ACTIVE, this will be fine and will be + * fixed onced the new sbr header is found + * SBR headers contain SBT freq. range as well as control signals that do not require + * frequent changes. + * For streaming, the SBR header is sent twice per second. Also, an SBR header can be + * inserted at any time, if a change of parameters is needed. + */ + + pVars->sbrDecoderData.SbrChannel[LEFT].syncState = UPSAMPLING; + pVars->sbrDecoderData.SbrChannel[RIGHT].syncState = UPSAMPLING; + + } + } +#endif /* #ifdef AAC_PLUS */ + + /* reset frame count to 1 */ + pVars->bno = 1; + + return ; + +} /* PVMP4AudioDecoderDecodeFrame */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4setaudioconfig.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4setaudioconfig.c new file mode 100644 index 00000000..6dcc5ec2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/pvmp4setaudioconfig.c @@ -0,0 +1,342 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: pvmp4setaudioconfig.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pExt = pointer to the external interface structure. See the file + PVMP4AudioDecoder_API.h for a description of each field. + Data type of pointer to a tPVMP4AudioDecoderExternal + structure. + + pExt->pInputBuffer: pointer to input buffer containing input + bitstream + + pExt->inputBufferCurrentLength: number of bytes in the input buffer + + pExt->inputBufferUsedLength: number of bytes already consumed in + input buffer + + pExt->remainderBits: number of bits consumed in addition to + pExt->inputBufferUsedLength + + pMem = void pointer to hide the internal implementation of the library + It is cast back to a tDec_Int_File structure. This structure + contains information that needs to persist between calls to + this function, or is too big to be placed on the stack, even + though the data is only needed during execution of this function + Data type void pointer, internally pointer to a tDec_Int_File + structure. + + Local Stores/Buffers/Pointers Needed: None + (The memory set aside in pMem performs this task) + + Global Stores/Buffers/Pointers Needed: None + + Outputs: + status = 0 if no error occurred + MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred + MP4AUDEC_RECOVERABLE if a recoverable error occurred. + Presently a recoverable error does not exist, but this + was a requirement. + + + Pointers and Buffers Modified: + pMem contents are modified. + pExt: (more detail in the file PVMP4AudioDecoder_API.h) + inputBufferUsedLength - number of array elements used up by the stream. + remainderBits - remaining bits in the next UInt32 buffer + samplingRate - sampling rate in samples per sec + encodedChannels - channels found on the file (informative) + frameLength - length of the frame + + Local Stores Modified: None. + + Global Stores Modified: None. + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + PacketVideo Document # CCC-AUD-AAC-ERS-0003 + +------------------------------------------------------------------------------ + REFERENCES + + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" +#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */ +#include "sfb.h" /* Where samp_rate_info[] is declared */ + +#include "get_audio_specific_config.h" +#include "pvmp4audiodecoder_api.h" /* Where this function is declared */ +#include "set_mc_info.h" +#include "config.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int PVMP4SetAudioConfig( + tPVMP4AudioDecoderExternal *pExt, + void *pMem, + Int upsamplingFactor, + Int samp_rate, + Int num_ch, + tMP4AudioObjectType audioObjectType) + +{ + + tDec_Int_File *pVars; /* Helper pointer */ + + Int status = MP4AUDEC_INCOMPLETE_FRAME; + + /* + * Initialize "helper" pointers to existing memory. + */ + pVars = (tDec_Int_File *)pMem; + /* + * Translate input buffer variables. + */ + pVars->inputStream.pBuffer = pExt->pInputBuffer; + + pVars->inputStream.availableBits = 0; + + pVars->inputStream.usedBits = 0; + + + + /* + * get sampling rate index + */ + + switch (samp_rate) + { + case 96000: + pVars->prog_config.sampling_rate_idx = 0; + break; + case 88200: + pVars->prog_config.sampling_rate_idx = 1; + break; + case 64000: + pVars->prog_config.sampling_rate_idx = 2; + break; + case 48000: + pVars->prog_config.sampling_rate_idx = 3; + break; + case 44100: + pVars->prog_config.sampling_rate_idx = 4; + break; + case 32000: + pVars->prog_config.sampling_rate_idx = 5; + break; + case 24000: + pVars->prog_config.sampling_rate_idx = 6; + break; + case 22050: + pVars->prog_config.sampling_rate_idx = 7; + break; + case 16000: + pVars->prog_config.sampling_rate_idx = 8; + break; + case 12000: + pVars->prog_config.sampling_rate_idx = 9; + break; + case 11025: + pVars->prog_config.sampling_rate_idx = 10; + break; + case 8000: + pVars->prog_config.sampling_rate_idx = 11; + break; + case 7350: + pVars->prog_config.sampling_rate_idx = 12; + break; + default: + status = -1; + + break; + } + + pVars->mc_info.sbrPresentFlag = 0; + pVars->mc_info.psPresentFlag = 0; +#ifdef AAC_PLUS + pVars->mc_info.bDownSampledSbr = 0; +#endif + pVars->mc_info.implicit_channeling = 0; + pVars->mc_info.nch = num_ch; + pVars->mc_info.upsamplingFactor = upsamplingFactor; + + + /* + * Set number of channels + */ + + if (num_ch == 2) + { + pVars->prog_config.front.ele_is_cpe[0] = 1; + } + else if (num_ch == 1) + { + pVars->prog_config.front.ele_is_cpe[0] = 0; + } + else + { + status = -1; /* do not support more than two channels */ + pVars->status = status; + return (status); + } + + + /* + * Set AAC bitstream + */ + + if ((audioObjectType == MP4AUDIO_AAC_LC) || + (audioObjectType == MP4AUDIO_LTP)) + { + pVars->aacPlusEnabled = FALSE; + + status = set_mc_info(&(pVars->mc_info), + audioObjectType, /* previously profile */ + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + } + else if ((audioObjectType == MP4AUDIO_SBR) || + (audioObjectType == MP4AUDIO_PS)) + { + pVars->aacPlusEnabled = TRUE; + + + status = set_mc_info(&(pVars->mc_info), + MP4AUDIO_AAC_LC, + pVars->prog_config.sampling_rate_idx, + pVars->prog_config.front.ele_tag[0], + pVars->prog_config.front.ele_is_cpe[0], + pVars->winmap, /*pVars->pWinSeqInfo,*/ + pVars->SFBWidth128); + + pVars->mc_info.sbrPresentFlag = 1; + if (audioObjectType == MP4AUDIO_PS) + { + pVars->mc_info.psPresentFlag = 1; + } + + if (upsamplingFactor == 1) + { +#ifdef AAC_PLUS + pVars->mc_info.bDownSampledSbr = 1; +#endif + + /* + * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz + */ + if (pVars->prog_config.sampling_rate_idx < 6) + { + pVars->aacPlusEnabled = FALSE; + } + } + + } + else + { + status = -1; + } + + + /* + * Translate from units of bits back into units of words. + */ + pExt->inputBufferUsedLength = 0; + + pExt->remainderBits = 0; + + pVars->bno++; + + pExt->samplingRate = samp_rate * upsamplingFactor; + + pExt->aacPlusEnabled = pVars->aacPlusEnabled; + + /* + * we default to 2 channel, even for mono files, (where channels have same content) + * this is done to ensure support for enhanced aac+ with implicit signalling + */ + + pExt->encodedChannels = 2; + + pExt->frameLength = 1024; +#ifdef AAC_PLUS + pExt->aacPlusUpsamplingFactor = upsamplingFactor; +#endif + + pVars->status = status; + + return (status); + +} /* PVMP4AudioDecoderDecodeFrame */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.c new file mode 100644 index 00000000..2ae43001 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.c @@ -0,0 +1,332 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: q_normalize.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + qFormat[] = Array of qFormats, one per scalefactor band. [ Int ] + + pFrameInfo = Pointer to structure that holds information about each group. + (long block flag, number of windows, scalefactor bands, etc.) + [const FrameInfo] + + coef[] = Array of the spectral coefficients for one channel. [ Int32 ] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + min_q = The common q-format for the entire frame. [Int] + + Pointers and Buffers Modified: + coef[] = Array of spectral data, now normalized to one q-format. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This module first scans every scalefactor band for the frame, insuring that + at least one element in that scalefactor band is using all available bits. + If not, the elements in the scalefactor band are shifted up to use all 31 + data bits. The q-format is adjusted accordingly. + + This module then scans the q-formats for each scalefactor band. + Upon finding the minimum q-format in the frame, the coefficients in each + scalefactor band are normalized to the minimum q-format. + The minimum q-format is then returned to the calling function, which is now + the q-format for the entire frame. + +------------------------------------------------------------------------------ + REQUIREMENTS + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + + nwin = pFrameInfo->num_win; + + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + FOR (win = nwin; win > 0; win--) + + nsfb = *(pSfbPerWin++); + + FOR (sfb = nsfb; sfb > 0; sfb--) + + IF ( *(pQformat) < min_q) + min_q = *(pQformat); + ENDIF + + pQformat++; + + ENDFOR + + ENDFOR + + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + FOR (win = 0; win < nwin; win++) + + stop_idx = 0; + + nsfb = *(pSfbPerWin++); + + pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]); + + FOR (sfb = nsfb; sfb > 0; sfb--) + + sfbWidth = *(pWinSfbTop++) - stop_idx; + + stop_idx += sfbWidth; + + k = *(pQformat++) - min_q; + + IF (k < 32) + THEN + FOR (; sfbWidth > 0; sfbWidth--) + *(pCoef++) >>= k; + ENDFOR + ELSE + FOR (; sfbWidth > 0; sfbWidth--) + *(pCoef++) = 0; + ENDFOR + ENDIF + + ENDFOR + + ENDFOR + + return min_q; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" +#include "q_normalize.h" +#include "aac_mem_funcs.h" /* For pv_memset */ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int q_normalize( + Int qFormat[], + const FrameInfo *pFrameInfo, + Int32 abs_max_per_window[], + Int32 coef[]) +{ + Int sfb; + Int nsfb; + Int win; + Int nwin; + Int sfbWidth; + + Int shift_amt; + Int i; + + /* Initialize min_q to a very large value */ + Int min_q = 1000; + + Int stop_idx = 0; + + const Int *pSfbPerWin; + const Int16 *pWinSfbTop; + + Int *pQformat; + Int32 *pCoef; + + nwin = pFrameInfo->num_win; + + /* Find the minimum q format */ + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + + for (win = nwin; win != 0; win--) + { + + nsfb = *(pSfbPerWin++); + + if (nsfb < 0 || nsfb > MAXBANDS) + { + break; /* avoid any processing on error condition */ + } + + for (sfb = nsfb; sfb != 0; sfb--) + { + Int qformat = *(pQformat++); + if (qformat < min_q) + { + min_q = qformat; + } + } + + } /* for(win) */ + + /* Normalize the coefs in each scalefactor band to one q-format */ + pQformat = &(qFormat[0]); + pSfbPerWin = &(pFrameInfo->sfb_per_win[0]); + pCoef = &(coef[0]); + + for (win = 0; win < nwin; win++) + { + + Int32 max = 0; + stop_idx = 0; + + nsfb = *(pSfbPerWin++); + + if (nsfb < 0 || nsfb > MAXBANDS) + { + break; /* avoid any processing on error condition */ + } + + pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]); + + for (sfb = nsfb; sfb != 0; sfb--) + { + Int tmp1, tmp2; + tmp1 = *(pWinSfbTop++); + tmp2 = *(pQformat++); + sfbWidth = tmp1 - stop_idx; + + if (sfbWidth < 2) + { + break; /* will lead to error condition */ + } + + stop_idx += sfbWidth; + + shift_amt = tmp2 - min_q; + + if (shift_amt == 0) + { + Int32 tmp1, tmp2; + tmp1 = *(pCoef++); + tmp2 = *(pCoef++); + /* + * sfbWidth is always an even number + * (check tables in pg.66 IS0 14496-3) + */ + for (i = (sfbWidth >> 1) - 1; i != 0; i--) + { + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + tmp1 = *(pCoef++); + tmp2 = *(pCoef++); + } + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + + } + else + { + if (shift_amt < 31) + { + Int32 tmp1, tmp2; + tmp1 = *(pCoef++) >> shift_amt; + tmp2 = *(pCoef--) >> shift_amt; + /* + * sfbWidth is always an even number + * (check tables in pg.66 IS0 14496-3) + */ + for (i = (sfbWidth >> 1) - 1; i != 0; i--) + { + *(pCoef++) = tmp1; + *(pCoef++) = tmp2; + + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + tmp1 = *(pCoef++) >> shift_amt; + tmp2 = *(pCoef--) >> shift_amt; + + } + *(pCoef++) = tmp1; + *(pCoef++) = tmp2; + max |= (tmp1 >> 31) ^ tmp1; + max |= (tmp2 >> 31) ^ tmp2; + + } + else + { + pv_memset(pCoef, 0, sizeof(Int32)*sfbWidth); + pCoef += sfbWidth; + } + } + + abs_max_per_window[win] = max; + + } + + } /* for (win) */ + + return min_q; + +} /* normalize() */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.h new file mode 100644 index 00000000..305840a9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/q_normalize.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: q_normalize.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes the function definition for q_normalize.h +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef Q_NORMALIZE_H +#define Q_NORMALIZE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int q_normalize( + Int qFormat[], + const FrameInfo *pFrameInfo, + Int32 abs_max_per_window[], + Int32 coef[]); + +#ifdef __cplusplus +} +#endif + + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.c new file mode 100644 index 00000000..54195204 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.c @@ -0,0 +1,293 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: qmf_filterbank_coeff.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function defines the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "qmf_filterbank_coeff.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + + +const Int32 sbrDecoderFilterbankCoefficients[155] = +{ + /* 10/9*table */ + + 0xFFEA0066, 0x020C09CF, 0x34F67965, 0xCE380A2F, 0xFE43005A, + 0xFFEA006C, 0x02360998, 0x36907954, 0xCFCD0A57, 0xFE690054, + 0xFFEC0072, 0x0262095B, 0x382B7937, 0xD1600A7A, 0xFE8E004F, + 0xFFED0078, 0x028E0919, 0x39C6790F, 0xD2F00A98, 0xFEB20049, + 0xFFED007E, 0x02BB08D0, 0x3B6378DB, 0xD47D0AB1, 0xFED50043, + 0xFFEC0084, 0x02E90882, 0x3D00789B, 0xD6080AC6, 0xFEF6003E, + 0xFFEB0089, 0x0318082F, 0x3E9D7851, 0xD78F0AD6, 0xFF160039, + 0xFFEB008F, 0x034807D5, 0x403A77FB, 0xD9130AE2, 0xFF350033, + 0xFFEA0095, 0x03790775, 0x41D7779A, 0xDA930AEA, 0xFF53002E, + 0xFFE9009A, 0x03AB070E, 0x4373772D, 0xDC100AED, 0xFF6F0029, + 0xFFE800A0, 0x03DE06A2, 0x450D76B6, 0xDD890AED, 0xFF8A0024, + 0xFFE800A5, 0x0412062F, 0x46A77633, 0xDEFD0AE9, 0xFFA40020, + 0xFFE700AA, 0x044705B6, 0x483F75A6, 0xE06D0AE2, 0xFFBD001C, + 0xFFE600AF, 0x047B0537, 0x49D5750E, 0xE1D90AD7, 0xFFD40017, + 0xFFE500B3, 0x04B104B0, 0x4B69746B, 0xE3400AC8, 0xFFEB0013, + 0xFFE400B8, 0x04E70423, 0x4CFA73BE, 0xE4A20AB7, 0x0002000F, + 0xFFE400BC, 0x051E0390, 0x4E897306, 0xE5FF0AA2, 0x0016000B, + 0xFFE300BF, 0x055502F6, 0x50157244, 0xE7560A8A, 0x00280008, + 0xFFE300C3, 0x058D0254, 0x519D7178, 0xE8A80A6F, 0x003A0004, + 0xFFE300C6, 0x05C401AD, 0x532270A2, 0xE9F50A53, 0x004A0001, + 0xFFE200C8, 0x05FC00FE, 0x54A36FC3, 0xEB3C0A33, 0x005AFFFC, + 0xFFE200CA, 0x06340048, 0x56206EDA, 0xEC7D0A11, 0x0068FFF9, + 0xFFE200CC, 0x066CFF8A, 0x57986DE8, 0xEDB809EC, 0x0075FFF7, + 0xFFE200CD, 0x06A4FEC6, 0x590C6CEC, 0xEEED09C6, 0x0081FFF4, + 0xFFE200CE, 0x06DCFDFC, 0x5A7B6BE7, 0xF01C099E, 0x008DFFF2, + 0xFFE200CE, 0x0713FD2B, 0x5BE56ADA, 0xF1450973, 0x0097FFF0, + 0xFFE300CD, 0x074BFC52, 0x5D4869C4, 0xF2680947, 0x00A0FFEE, + 0xFFE300CC, 0x0781FB73, 0x5EA668A6, 0xF384091A, 0x00A8FFEC, + 0xFFE400CA, 0x07B7FA8D, 0x5FFF6780, 0xF49908EB, 0x00B0FFEA, + 0xFFE400C8, 0x07EDF9A0, 0x61506652, 0xF5A808BA, 0x00B6FFE9, + 0xFFE500C5, 0x0822F8AC, 0x629B651C, 0xF6B00888, 0x00BCFFE7 +}; + + +const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160] = +{ + 0x0000FFEE, 0xFFF0FFEF, 0xFFEEFFED, 0xFFEBFFEA, + 0xFFE9FFE8, 0xFFE7FFE6, 0xFFE6FFE7, 0xFFE7FFE8, + 0xFFEAFFED, 0xFFEFFFF3, 0xFFF7FFFB, 0x00000007, + 0x000D0014, 0x001C0025, 0x002E0037, 0x0041004B, + 0x00560061, 0x006B0076, 0x0080008A, 0x0094009D, + 0x00A500AC, 0x00B200B6, 0x00B800B9, 0x00B700B3, + 0x00AD00A3, 0x00970087, 0x0074005D, 0x00420024, + 0x0001FFDA, 0xFFAFFF7F, 0xFF4BFF12, 0xFED5FE93, + 0x01B301FD, 0x024C029E, 0x02F4034D, 0x03A90408, + 0x046904CC, 0x05300595, 0x05FA065E, 0x06C10722, + 0x078007DA, 0x08300881, 0x08CB090F, 0x094A097C, + 0x09A409C1, 0x09D209D5, 0x09CB09B2, 0x0988094D, + 0x090108A2, 0x082F07A8, 0x070C0659, 0x059104B1, + 0x03B902AA, 0x01810041, 0xFEE7FD74, 0xFBE9FA45, + 0xF887F6B2, 0xF4C4F2BF, 0xF0A4EE72, 0xEC2AE9CF, + 0xE760E4DE, 0xE24CDFA9, 0xDCF9DA3B, 0xD772D4A0, + 0x2E3A311B, 0x33FF36E7, 0x39CE3CB4, 0x3F964273, + 0x45484813, 0x4AD24D84, 0x502552B4, 0x55305795, + 0x59E35C17, 0x5E2F602B, 0x620863C4, 0x655F66D7, + 0x682B6959, 0x6A626B43, 0x6BFC6C8C, 0x6CF46D32, + 0x6D476D32, 0x6CF46C8C, 0x6BFC6B43, 0x6A626959, + 0x682B66D7, 0x655F63C4, 0x6208602B, 0x5E2F5C17, + 0x59E35795, 0x553052B4, 0x50254D84, 0x4AD24813, + 0x45484273, 0x3F963CB4, 0x39CE36E7, 0x33FF311B, + 0xD1C6D4A0, 0xD772DA3B, 0xDCF9DFA9, 0xE24CE4DE, + 0xE760E9CF, 0xEC2AEE72, 0xF0A4F2BF, 0xF4C4F6B2, + 0xF887FA45, 0xFBE9FD74, 0xFEE70041, 0x018102AA, + 0x03B904B1, 0x05910659, 0x070C07A8, 0x082F08A2, + 0x0901094D, 0x098809B2, 0x09CB09D5, 0x09D209C1, + 0x09A4097C, 0x094A090F, 0x08CB0881, 0x083007DA, + 0x07800722, 0x06C1065E, 0x05FA0595, 0x053004CC, + 0x04690408, 0x03A9034D, 0x02F4029E, 0x024C01FD, + 0xFE4DFE93, 0xFED5FF12, 0xFF4BFF7F, 0xFFAFFFDA, + 0x00010024, 0x0042005D, 0x00740087, 0x009700A3, + 0x00AD00B3, 0x00B700B9, 0x00B800B6, 0x00B200AC, + 0x00A5009D, 0x0094008A, 0x00800076, 0x006B0061, + 0x0056004B, 0x00410037, 0x002E0025, 0x001C0014, + 0x000D0007, 0x0000FFFB, 0xFFF7FFF3, 0xFFEFFFED, + 0xFFEAFFE8, 0xFFE7FFE7, 0xFFE6FFE6, 0xFFE7FFE8, + 0xFFE9FFEA, 0xFFEBFFED, 0xFFEEFFEF, 0xFFF0FFEE +}; + +const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155] = +{ + + Qfmt27(-0.00079446133872F), Qfmt27(0.02197766364781F), Qfmt27(0.54254182141522F), Qfmt27(-0.47923775873194F), + Qfmt27(-0.01574239605130F), Qfmt27(-0.00068946163857F), Qfmt27(0.02537571195384F), Qfmt27(0.57449847577240F), + Qfmt27(-0.44806230039026F), Qfmt27(-0.01291535202742F), Qfmt27(-0.00071286404460F), Qfmt27(0.02892516313544F), + Qfmt27(0.60657315615086F), Qfmt27(-0.41729436041451F), Qfmt27(-0.01026942774868F), Qfmt27(-0.00077308974337F), + Qfmt27(0.03262310249845F), Qfmt27(0.63865835544980F), Qfmt27(-0.38701849746199F), Qfmt27(-0.00782586328859F), + Qfmt27(-0.00083027488297F), Qfmt27(0.03646915244785F), Qfmt27(0.67068416485018F), Qfmt27(-0.35729827194706F), + Qfmt27(-0.00557215982767F), Qfmt27(-0.00089272089703F), Qfmt27(0.04045671426315F), Qfmt27(0.70254003810627F), + Qfmt27(-0.32819525024294F), Qfmt27(-0.00351102841332F), Qfmt27(-0.00095851011196F), Qfmt27(0.04455021764484F), + Qfmt27(0.73415149000395F), Qfmt27(-0.29977591877185F), Qfmt27(-0.00163598204794F), Qfmt27(-0.00101225729839F), + Qfmt27(0.04873676213679F), Qfmt27(0.76545064960593F), Qfmt27(-0.27208998714049F), Qfmt27(0.00003903936539F), + Qfmt27(-0.00105230782648F), Qfmt27(0.05300654158217F), Qfmt27(0.79631383686511F), Qfmt27(-0.24519750285673F), + Qfmt27(0.00154182229475F), Qfmt27(-0.00108630976316F), Qfmt27(0.05732502937107F), Qfmt27(0.82666485395476F), + Qfmt27(-0.21914753347432F), Qfmt27(0.00286720203220F), Qfmt27(-0.00110794157381F), Qfmt27(0.06167350555855F), + Qfmt27(0.85641712130638F), Qfmt27(-0.19396671004887F), Qfmt27(0.00402297937976F), Qfmt27(-0.00110360418081F), + Qfmt27(0.06602157445253F), Qfmt27(0.88547343436495F), Qfmt27(-0.16971665552213F), Qfmt27(0.00500649278750F), + Qfmt27(-0.00109714405326F), Qfmt27(0.07034096875232F), Qfmt27(0.91376152398903F), Qfmt27(-0.14641770628514F), + Qfmt27(0.00583386287581F), Qfmt27(-0.00106490281247F), Qfmt27(0.07461825625751F), Qfmt27(0.94117890777861F), + Qfmt27(-0.12410396326951F), Qfmt27(0.00651097277313F), Qfmt27(-0.00102041023958F), Qfmt27(0.07879625324269F), + Qfmt27(0.96765488212662F), Qfmt27(-0.10280530739363F), Qfmt27(0.00704839655425F), Qfmt27(-0.00094051141595F), + Qfmt27(0.08286099010631F), Qfmt27(0.99311573680798F), Qfmt27(-0.08254839941155F), Qfmt27(0.00745513427428F), + Qfmt27(-0.00084090835475F), Qfmt27(0.08675566213219F), Qfmt27(1.01745066253324F), Qfmt27(-0.06332944781672F), + Qfmt27(0.00774335382672F), Qfmt27(-0.00072769348801F), Qfmt27(0.09046949018457F), Qfmt27(1.04060828658052F), + Qfmt27(-0.04518854556363F), Qfmt27(0.00790787636150F), Qfmt27(-0.00057913742435F), Qfmt27(0.09395575430420F), + Qfmt27(1.06251808919053F), Qfmt27(-0.02811939233087F), Qfmt27(0.00797463714114F), Qfmt27(-0.00040969484059F), + Qfmt27(0.09716267023308F), Qfmt27(1.08310018709600F), Qfmt27(-0.01212147193047F), Qfmt27(0.00795079915733F), + Qfmt27(-0.00020454902123F), Qfmt27(0.10007381188066F), Qfmt27(1.10227871198194F), Qfmt27(0.00279527795884F), + Qfmt27(0.00784545014643F), Qfmt27(0.00001908481202F), Qfmt27(0.10262701466139F), Qfmt27(1.12001978353403F), + Qfmt27(0.01663452156443F), Qfmt27(0.00766458213130F), Qfmt27(0.00028892665922F), Qfmt27(0.10479373974558F), + Qfmt27(1.13624787143434F), Qfmt27(0.02941522773279F), Qfmt27(0.00741912981120F), Qfmt27(0.00056943874774F), + Qfmt27(0.10650970405576F), Qfmt27(1.15091404672203F), Qfmt27(0.04112872592057F), Qfmt27(0.00712664923329F), + Qfmt27(0.00088238158168F), Qfmt27(0.10776200996423F), Qfmt27(1.16395714324633F), Qfmt27(0.05181934748033F), + Qfmt27(0.00677868764313F), Qfmt27(0.00121741725989F), Qfmt27(0.10848340171661F), Qfmt27(1.17535833075364F), + Qfmt27(0.06148559051724F), Qfmt27(0.00639363830229F), Qfmt27(0.00159101288509F), Qfmt27(0.10864412991640F), + Qfmt27(1.18507099110810F), Qfmt27(0.07014197759039F), Qfmt27(0.00597707038378F), Qfmt27(0.00196610899088F), + Qfmt27(0.10819451041273F), Qfmt27(1.19306425909871F), Qfmt27(0.07784680399703F), Qfmt27(0.00554476792518F), + Qfmt27(0.00238550675072F), Qfmt27(0.10709920766553F), Qfmt27(1.19929775892826F), Qfmt27(0.08459352758522F), + Qfmt27(0.00509233837916F), Qfmt27(0.00280596092809F), Qfmt27(0.10531144797543F), Qfmt27(1.20377455661175F), + Qfmt27(0.09043115226911F), Qfmt27(0.00463008004888F), Qfmt27(0.00325513071185F), Qfmt27(0.10278145526768F), + Qfmt27(1.20646855283790F), Qfmt27(0.09539224314440F), Qfmt27(0.00416760958657F) +}; + + + +#ifdef HQ_SBR + + +const Int32 sbrDecoderFilterbankCoefficients_an_filt[155] = +{ + Qfmt27(-0.000561769F), Qfmt27(+ 0.015540555F), Qfmt27(+ 0.383635001F), Qfmt27(-0.338872269F), Qfmt27(-0.011131555F), + Qfmt27(-0.000487523F), Qfmt27(+ 0.017943338F), Qfmt27(+ 0.406231768F), Qfmt27(-0.316827891F), Qfmt27(-0.009132533F), + Qfmt27(-0.000504071F), Qfmt27(+ 0.020453179F), Qfmt27(+ 0.428911992F), Qfmt27(-0.295071672F), Qfmt27(-0.007261582F), + Qfmt27(-0.000546657F), Qfmt27(+ 0.023068017F), Qfmt27(+ 0.451599654F), Qfmt27(-0.273663404F), Qfmt27(-0.005533721F), + Qfmt27(-0.000587093F), Qfmt27(+ 0.025787585F), Qfmt27(+ 0.474245321F), Qfmt27(-0.252648031F), Qfmt27(-0.003940112F), + Qfmt27(-0.000631249F), Qfmt27(+ 0.028607217F), Qfmt27(+ 0.496770825F), Qfmt27(-0.232069087F), Qfmt27(-0.002482672F), + Qfmt27(-0.000677769F), Qfmt27(+ 0.031501761F), Qfmt27(+ 0.519123497F), Qfmt27(-0.211973585F), Qfmt27(-0.001156814F), + Qfmt27(-0.000715774F), Qfmt27(+ 0.034462095F), Qfmt27(+ 0.541255345F), Qfmt27(-0.192396675F), Qfmt27(+ 0.000027605F), + Qfmt27(-0.000744094F), Qfmt27(+ 0.037481285F), Qfmt27(+ 0.563078914F), Qfmt27(-0.173380817F), Qfmt27(+ 0.001090233F), + Qfmt27(-0.000768137F), Qfmt27(+ 0.040534917F), Qfmt27(+ 0.584540324F), Qfmt27(-0.154960707F), Qfmt27(+ 0.002027418F), + Qfmt27(-0.000783433F), Qfmt27(+ 0.043609754F), Qfmt27(+ 0.605578354F), Qfmt27(-0.137155176F), Qfmt27(+ 0.002844676F), + Qfmt27(-0.000780366F), Qfmt27(+ 0.046684303F), Qfmt27(+ 0.626124270F), Qfmt27(-0.120007798F), Qfmt27(+ 0.003540125F), + Qfmt27(-0.000775798F), Qfmt27(+ 0.049738576F), Qfmt27(+ 0.646126970F), Qfmt27(-0.103532953F), Qfmt27(+ 0.004125164F), + Qfmt27(-0.000753000F), Qfmt27(+ 0.052763075F), Qfmt27(+ 0.665513988F), Qfmt27(-0.087754754F), Qfmt27(+ 0.004603953F), + Qfmt27(-0.000721539F), Qfmt27(+ 0.055717365F), Qfmt27(+ 0.684235329F), Qfmt27(-0.072694330F), Qfmt27(+ 0.004983969F), + Qfmt27(-0.000665042F), Qfmt27(+ 0.058591568F), Qfmt27(+ 0.702238872F), Qfmt27(-0.058370533F), Qfmt27(+ 0.005271576F), + Qfmt27(-0.000594612F), Qfmt27(+ 0.061345517F), Qfmt27(+ 0.719446263F), Qfmt27(-0.044780682F), Qfmt27(+ 0.005475378F), + Qfmt27(-0.000514557F), Qfmt27(+ 0.063971590F), Qfmt27(+ 0.735821176F), Qfmt27(-0.031953127F), Qfmt27(+ 0.005591713F), + Qfmt27(-0.000409512F), Qfmt27(+ 0.066436751F), Qfmt27(+ 0.751313746F), Qfmt27(-0.019883413F), Qfmt27(+ 0.005638920F), + Qfmt27(-0.000289698F), Qfmt27(+ 0.068704383F), Qfmt27(+ 0.765867487F), Qfmt27(-0.008571175F), Qfmt27(+ 0.005622064F), + Qfmt27(-0.000144638F), Qfmt27(+ 0.070762871F), Qfmt27(+ 0.779428752F), Qfmt27(+ 0.001976560F), Qfmt27(+ 0.005547571F), + Qfmt27(+ 0.000013495F), Qfmt27(+ 0.072568258F), Qfmt27(+ 0.791973584F), Qfmt27(+ 0.011762383F), Qfmt27(+ 0.005419678F), + Qfmt27(+ 0.000204302F), Qfmt27(+ 0.074100364F), Qfmt27(+ 0.803448575F), Qfmt27(+ 0.020799707F), Qfmt27(+ 0.005246117F), + Qfmt27(+ 0.000402654F), Qfmt27(+ 0.075313734F), Qfmt27(+ 0.813819127F), Qfmt27(+ 0.029082401F), Qfmt27(+ 0.005039302F), + Qfmt27(+ 0.000623938F), Qfmt27(+ 0.076199248F), Qfmt27(+ 0.823041989F), Qfmt27(+ 0.036641812F), Qfmt27(+ 0.004793256F), + Qfmt27(+ 0.000860844F), Qfmt27(+ 0.076709349F), Qfmt27(+ 0.831103846F), Qfmt27(+ 0.043476878F), Qfmt27(+ 0.004520985F), + Qfmt27(+ 0.001125016F), Qfmt27(+ 0.076823001F), Qfmt27(+ 0.837971734F), Qfmt27(+ 0.049597868F), Qfmt27(+ 0.004226427F), + Qfmt27(+ 0.001390249F), Qfmt27(+ 0.076505072F), Qfmt27(+ 0.843623828F), Qfmt27(+ 0.055046003F), Qfmt27(+ 0.003920743F), + Qfmt27(+ 0.001686808F), Qfmt27(+ 0.075730576F), Qfmt27(+ 0.848031578F), Qfmt27(+ 0.059816657F), Qfmt27(+ 0.003600827F), + Qfmt27(+ 0.001984114F), Qfmt27(+ 0.074466439F), Qfmt27(+ 0.851197152F), Qfmt27(+ 0.063944481F), Qfmt27(+ 0.003273961F), + Qfmt27(+ 0.002301725F), Qfmt27(+ 0.072677464F), Qfmt27(+ 0.853102095F), Qfmt27(+ 0.067452502F), Qfmt27(+ 0.002946945F) +}; + + + +#endif /* HQ_SBR */ + + +#endif /* AAC_PLUS */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.h new file mode 100644 index 00000000..044d9ae2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/qmf_filterbank_coeff.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: qmf_filterbank_coeff.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef QMF_FILTERBANK_COEFF_H +#define QMF_FILTERBANK_COEFF_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +#define Qfmt(x) (Int16)(x*(((Int32)1<<15)*1.11111111111111111F) + (x>=0?0.5F:-0.5F)) + + +#define Qfmt30(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Qfmt27(x) (Int32)(x*(((Int32)1<<27)) + (x>=0?0.5F:-0.5F)) + +extern const Int32 sbrDecoderFilterbankCoefficients[155]; + + +extern const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160]; +extern const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155]; + +#ifdef HQ_SBR +extern const Int32 sbrDecoderFilterbankCoefficients_an_filt[155]; +#endif + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_adif_header.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_adif_header.h new file mode 100644 index 00000000..5294a877 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_adif_header.h @@ -0,0 +1,92 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_adif_header.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, ADIF_Header + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_ADIF_HEADER_H +#define S_ADIF_HEADER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_adif_const.h" +#include "e_rawbitstreamconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Char adif_id[LEN_ADIF_ID+1]; + Int copy_id_present; + Char copy_id[LEN_COPYRT_ID+1]; + Int original_copy; + Int home; + Int bitstream_type; + Int32 bitrate; + Int num_pce; + Int prog_tags[(1< 0) */ + /* int cch[CChans];*/ /* coupling channel idx */ + /* int cc_dom[CChans];*/ /* coupling channel domain */ + /* int cc_ind[CChans];*/ /* independently switched coupling channel flag */ + /* #endif */ + Char *fext; /* filename extension */ + +} Ch_Info; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_crc_buffer.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_crc_buffer.h new file mode 100644 index 00000000..40696e77 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_crc_buffer.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_crc_buffer.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_CRC_BUFFER_H +#define S_CRC_BUFFER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + unsigned short crcState; + unsigned short crcMask; + unsigned short crcPoly; +} +CRC_BUFFER; + +typedef CRC_BUFFER *HANDLE_CRC; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_elelist.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_elelist.h new file mode 100644 index 00000000..a1c4d692 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_elelist.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_elelist.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, EleList + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_ELELIST_H +#define S_ELELIST_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_rawbitstreamconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Int num_ele; + Int ele_is_cpe[(1<>2) + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +struct PATCH +{ + Int32 noOfPatches; + Int32 targetStartBand[MAX_NUM_PATCHES]; +}; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_progconfig.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_progconfig.h new file mode 100644 index 00000000..05b56c10 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_progconfig.h @@ -0,0 +1,102 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_progconfig.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, ProgConfig + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_PROGCONFIG_H +#define S_PROGCONFIG_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_mixdown.h" +#include "s_elelist.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int profile; + Int sampling_rate_idx; + EleList front; + EleList side; + EleList back; + EleList lfe; + EleList data; + EleList coupling; + MIXdown mono_mix; + MIXdown stereo_mix; + MIXdown matrix_mix; + + Char comments[(1<bufReadOffs (2) and + * sbrDec->noCols (32) + sbrDec->bufWriteOffs (6) + */ + Int32 codecQmfBufferReal[40][32]; + Int32 *sbrQmfBufferReal; + Int32 HistsbrQmfBufferReal[6*SBR_NUM_BANDS]; +#ifdef HQ_SBR + Int32 codecQmfBufferImag[40][32]; + Int32 *sbrQmfBufferImag; + Int32 HistsbrQmfBufferImag[6*SBR_NUM_BANDS]; +#endif + Int16 V[1152]; /* Used by calc_sbr_synfilterbank as freq. history buffer */ + + + Int32 degreeAlias[64]; + + +#ifdef HQ_SBR + + Int32 fBuffer_man[5][64]; /* smoothing history buffers */ + Int32 fBufferN_man[5][64]; + Int32 fBuffer_exp[5][64]; /* smoothing history buffers */ + Int32 fBufferN_exp[5][64]; + + Int32 *fBuf_man[64]; /* pointer to smoothing history buffers */ + Int32 *fBuf_exp[64]; /* pointer to smoothing history buffers */ + Int32 *fBufN_man[64]; + Int32 *fBufN_exp[64]; + + +#endif + +} +SBR_FRAME_DATA; + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbr_header_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbr_header_data.h new file mode 100644 index 00000000..3cd1bf27 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbr_header_data.h @@ -0,0 +1,103 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sbr_header_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SBR_HEADER_DATA_H +#define S_SBR_HEADER_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_sbr_header_status.h" +#include "e_sbr_master_status.h" +#include "e_sr_mode.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + SBR_HEADER_STATUS status; /* the current status of the header */ + SBR_MASTER_STATUS masterStatus;/* status of v_k_master freq table */ + + /* Changes in these variables indicates an error */ + Int32 crcEnable; + SR_MODE sampleRateMode; + Int32 ampResolution; + + /* Changes in these variables causes a reset of the decoder */ + Int32 startFreq; + Int32 stopFreq; + Int32 xover_band; + Int32 freqScale; + Int32 alterScale; + Int32 noise_bands; /* noise bands per octave, read from bitstream */ + + /* Helper variable*/ + Int32 noNoiseBands; /* actual number of noise bands to read from the bitstream */ + + Int32 limiterBands; + Int32 limiterGains; + Int32 interpolFreq; + Int32 smoothingLength; +} +SBR_HEADER_DATA; + +typedef SBR_HEADER_DATA *HANDLE_SBR_HEADER_DATA; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbrbitstream.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbrbitstream.h new file mode 100644 index 00000000..a8cd45ca --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sbrbitstream.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sbrbitstream.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SBRBITSTREAM_H +#define S_SBRBITSTREAM_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_element_stream.h" +#include "s_sbr_channel.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +typedef struct +{ + Int32 NrElements; + Int32 NrElementsCore; + SBR_ELEMENT_STREAM sbrElement[MAXNRELEMENTS]; +} +SBRBITSTREAM; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sectinfo.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sectinfo.h new file mode 100644 index 00000000..d96146ae --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sectinfo.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sectinfo.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + defines a structre that holds the Huffman codebook index and section + boundary information for each Frame. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SECTINFO_H +#define S_SECTINFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int sect_cb; + Int sect_end; +} SectInfo; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sr_info.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sr_info.h new file mode 100644 index 00000000..709a547e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_sr_info.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_sr_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, SR_Info + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_SR_INFO_H +#define S_SR_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ +typedef struct +{ + Int32 samp_rate; + Int nsfb1024; + Int nsfb128; +} SR_Info; + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_chan.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_chan.h new file mode 100644 index 00000000..93a29b6b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_chan.h @@ -0,0 +1,150 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_tdec_int_chan.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tDec_Int_Chan + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TDEC_INT_CHAN_H +#define S_TDEC_INT_CHAN_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_rawbitstreamconst.h" +#include "s_tns_frame_info.h" +#include "s_wnd_shape.h" +#include "s_lt_pred_status.h" +#include "s_sectinfo.h" +#include "s_frameinfo.h" +#include "e_window_shape.h" +#include "e_window_sequence.h" +#include "window_block_fxp.h" +#include "config.h" + + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /* This structure was created with the specific goal in mind of sharing memory + * with the last 1024 data elements in fxpCoef. + * + * The size of this structure must NOT exceed 4 kilobytes + * Also, the size of the fxpCoef array cannot be less than 8 kilobytes + * + * The fxpCoef array is declared as an Int32, so its size should not vary + * from platform to platform. + * + * The shared structure is 3,640 bytes (3.55 KB), on a 32-bit platform, + * which represents the worst case. + */ + typedef struct + { + TNS_frame_info tns; + + FrameInfo frameInfo; + + Int factors[MAXBANDS]; + Int cb_map[MAXBANDS]; + Int group[NSHORT]; + Int qFormat[MAXBANDS]; + + Int max_sfb; + LT_PRED_STATUS lt_status; + + } per_chan_share_w_fxpCoef; + + /* + * This structure contains one per channel. + */ + typedef struct + { +#ifdef AAC_PLUS + Int16 ltp_buffer[LT_BLEN + 2*288]; /* LT_BLEN = 2048 + 2*288 */ +#else + Int16 ltp_buffer[LT_BLEN]; /* LT_BLEN = 2048 */ +#endif + + + Int32 time_quant[LONG_WINDOW]; /* 1024 holds overlap&add */ + + Int32 *fxpCoef; /* Spectrum coeff.*/ + + per_chan_share_w_fxpCoef * pShareWfxpCoef; + + Int32 abs_max_per_window[NUM_SHORT_WINDOWS]; + + WINDOW_SEQUENCE wnd; + + + WINDOW_SHAPE wnd_shape_prev_bk; + WINDOW_SHAPE wnd_shape_this_bk; + + } tDec_Int_Chan; + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + +#endif /* S_TDEC_INT_CHAN_H */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_file.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_file.h new file mode 100644 index 00000000..2f4dfb8a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/s_tdec_int_file.h @@ -0,0 +1,232 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: s_tdec_int_file.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file defines the structure, tDec_Int_Chan + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef S_TDEC_INT_FILE_H +#define S_TDEC_INT_FILE_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_progconfig.h" +#include "s_frameinfo.h" +#include "s_mc_info.h" +#include "s_adif_header.h" +#include "s_tdec_int_chan.h" +#include "s_pulseinfo.h" +#include "s_bits.h" +#include "s_hcb.h" +#include "e_infoinitconst.h" + +#include "s_sbr_channel.h" +#include "s_sbr_dec.h" +#include "s_sbrbitstream.h" +#include "config.h" + + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + + + + /* + * Note: most of the names of the variables put into this structure were kept + * the same because the name is also used in called functions. + * + * bno - block number + * + */ + typedef struct + { + UInt32 bno; + Int status; /* save the status */ + + Bool aacPlusEnabled; + Bool aacConfigUtilityEnabled; + + Int current_program; + Int frameLength; + Int adif_test; + + BITS inputStream; + + ProgConfig prog_config; + + Int SFBWidth128[(1<=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +#include "pv_normalize.h" +#include "sbr_constants.h" + +/******************************************************************************* + Functionname: sbr_aliasing_reduction + ******************************************************************************* + Description: + Arguments: + + Return: none +*******************************************************************************/ +void sbr_aliasing_reduction(Int32 *degreeAlias, + Int32 * nrg_gain_man, + Int32 * nrg_gain_exp, + Int32 * nrg_est_man, + Int32 * nrg_est_exp, + Int32 * dontUseTheseGainValues, + Int32 noSubbands, + Int32 lowSubband, + Int32 sqrt_cache[][4], + Int32 * groupVector) +{ + + Int32 temp1; + Int32 est_total; + Int32 ref_total_man; + Int32 ref_total_exp; + Int32 tmp_q1; + Int32 tmp_q2; + Int32 tmp_q3; + Int32 tmp_q4; + Int32 bst_man; + Int32 bst_exp; + struct intg_div quotient; + struct intg_sqrt root_sq; + Int32 group; + Int32 grouping = 0; + Int32 index = 0; + Int32 noGroups; + Int32 k; + + + /* Calculate grouping*/ + for (k = 0; k < noSubbands - 1; k++) + { + if (degreeAlias[k + lowSubband + 1] && dontUseTheseGainValues[k] == 0) + { + if (grouping == 0) + { + groupVector[index] = k + lowSubband; + grouping = 1; + index++; + } + } + else + { + if (grouping) + { + groupVector[index] = k + lowSubband; + + if (! dontUseTheseGainValues[k]) + { + (groupVector[index])++; + } + grouping = 0; + index++; + } + } + } + + if (grouping) + { + groupVector[index] = noSubbands + lowSubband; + index++; + } + noGroups = (index >> 1); + + + + /*Calculate new gain*/ + for (group = 0; group < noGroups; group ++) + { + + int startGroup = groupVector[(group<<1)] - lowSubband; + int stopGroup = groupVector[(group<<1)+1] - lowSubband; + + + est_total = 0; + ref_total_man = 0; + + tmp_q1 = -100; + tmp_q2 = -100; + + for (k = startGroup; k < stopGroup; k++) + { + if (tmp_q1 < nrg_est_exp[k]) + { + tmp_q1 = nrg_est_exp[k]; /* max */ + } + if (tmp_q2 < (nrg_est_exp[k] + (nrg_gain_exp[k] << 1))) + { + tmp_q2 = (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)); /* max */ + } + } + + + k -= startGroup; /* number of element used in the addition */ + /* adjust Q format */ + tmp_q2 += 59 - pv_normalize(k); + + for (k = startGroup; k < stopGroup; k++) + { + /* + * est_total += nrg_est[k] + * ref_total += nrg_est[k]*nrg_gain[k]*nrg_gain[k + */ + est_total += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); + + if (tmp_q2 - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 60) + { + nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]); + nrg_gain_exp[k] = (nrg_gain_exp[k] << 1) + 28; + tmp_q3 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]); + ref_total_man += tmp_q3 >> (tmp_q2 - (nrg_est_exp[k] + nrg_gain_exp[k])); + } + } + + ref_total_exp = tmp_q2 + 28; + + pv_div(ref_total_man, est_total, "ient); + + tmp_q2 += - tmp_q1 - quotient.shift_factor - 2; + + + + for (k = startGroup; k < stopGroup; k++) + { + Int32 alpha; + temp1 = k + lowSubband; + if (k < noSubbands - 1) + { + alpha = degreeAlias[temp1 + 1] > degreeAlias[temp1 ] ? + degreeAlias[temp1 + 1] : degreeAlias[temp1 ]; + } + else + { + alpha = degreeAlias[temp1]; + } + + /* + * nrg_gain[k] = alpha*newGain + (1.0f-alpha)*nrg_gain[k]*nrg_gain[k]; + */ + + tmp_q1 = tmp_q2 > nrg_gain_exp[k] ? tmp_q2 : nrg_gain_exp[k]; + tmp_q1++; + + tmp_q3 = fxp_mul32_Q30(alpha, quotient.quotient); + tmp_q4 = fxp_mul32_Q30(Q30fmt(1.0f) - alpha, nrg_gain_man[k]); + + nrg_gain_man[k] = (tmp_q3 >> (tmp_q1 - tmp_q2)) + + (tmp_q4 >> (tmp_q1 - nrg_gain_exp[k])); + + nrg_gain_exp[k] = tmp_q1; + } + + + bst_exp = -100; + + for (k = startGroup; k < stopGroup; k++) + { + if (bst_exp < nrg_gain_exp[k] + nrg_est_exp[k]) + { + bst_exp = nrg_gain_exp[k] + nrg_est_exp[k]; /* max */ + } + } + + k -= startGroup; /* number of element used in the addition */ + + while (k != 0) /* bit guard protection depends on log2(k) */ + { + k >>= 1; + bst_exp++; /* add extra bit-overflow-guard */ + } + + bst_man = 0; + + for (k = startGroup; k < stopGroup; k++) + { + tmp_q2 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]); + bst_man += tmp_q2 >> (bst_exp - nrg_gain_exp[k] - nrg_est_exp[k]); + } + + bst_exp += 28; /* compensate for shift down */ + + if (bst_man) + { + /* + * bst = ref_total / bst + */ + + pv_div(ref_total_man, bst_man, "ient); + bst_exp = ref_total_exp - bst_exp - quotient.shift_factor - 30; + bst_man = quotient.quotient; /* Q30 */ + + for (k = startGroup; k < stopGroup; k++) + { + tmp_q1 = fxp_mul32_Q30(bst_man, nrg_gain_man[k]); + pv_sqrt(tmp_q1, (bst_exp + nrg_gain_exp[k] + 60), &root_sq, sqrt_cache[0]); + nrg_gain_man[k] = root_sq.root; + nrg_gain_exp[k] = root_sq.shift_factor; + } + } + else + { + pv_memset((void *)&nrg_gain_man[startGroup], + 0, + (stopGroup - startGroup)*sizeof(nrg_gain_man[0])); + + pv_memset((void *)&nrg_gain_exp[startGroup], + 0, + (stopGroup - startGroup)*sizeof(nrg_gain_exp[0])); + + } + + } +} + +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_aliasing_reduction.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_aliasing_reduction.h new file mode 100644 index 00000000..ca3d4893 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_aliasing_reduction.h @@ -0,0 +1,83 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_aliasing_reduction.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ALIASING_REDUCTION_H +#define SBR_ALIASING_REDUCTION_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_aliasing_reduction(Int32 *degreeAlias, + Int32 * nrg_gain_man, + Int32 * nrg_gain_exp, + Int32 * nrg_est_man, + Int32 * nrg_est_exp, + Int32 * dontUseTheseGainValues, + Int32 noSubbands, + Int32 lowSubband, + Int32 sqrt_cache[][4], + Int32 * groupVector); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.c new file mode 100644 index 00000000..00641c79 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.c @@ -0,0 +1,431 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_applied.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_applied.h" +#include "sbr_read_data.h" + +#include "sbr_decode_envelope.h" +#include "decode_noise_floorlevels.h" +#include "sbr_requantize_envelope_data.h" +#include "sbr_envelope_unmapping.h" +#include "sbr_dec.h" +#include "e_sbr_element_id.h" +#include "aac_mem_funcs.h" + +#ifdef PARAMETRICSTEREO +#include "ps_bstr_decoding.h" +#include "ps_allocate_decoder.h" + +#endif + +#include "init_sbr_dec.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define LEFT (0) +#define RIGHT (1) + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_applied(SBRDECODER_DATA * self, + SBRBITSTREAM * stream, + Int16 *ch_left, + Int16 *ch_right, + Int16 *timeData, + SBR_DEC *sbrDec, + tDec_Int_File *pVars, + Int32 numChannels) +{ + SBR_ERROR err = SBRDEC_OK ; + + Int32 eleChannels = 0; + + SBR_CHANNEL *SbrChannel = self->SbrChannel; + + /* Get SBR or PS Data only when available */ + if (stream->NrElements) + { + /* read frame data from bitstream */ + + err = sbr_read_data(self, + sbrDec, + stream); + + if (err != SBRDEC_OK) + { + /* + * This error condition disables any further SBR processing + */ + self->SbrChannel[LEFT].syncState = UPSAMPLING; + if (eleChannels == 2) + { + self->SbrChannel[RIGHT].syncState = UPSAMPLING; + } + } + + /* + * Setting bistream and decoding type is only done once, + */ + if (SbrChannel[LEFT].syncState == SBR_ACTIVE && self->setStreamType) + { + self->setStreamType = 0; /* Disable Lock for AAC stream type setting */ + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + Int sbrEnablePS = self->hParametricStereoDec->psDetected; + + pVars->mc_info.psPresentFlag = sbrEnablePS; + + if (sbrEnablePS) /* Initialize PS arrays */ + { + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS; + ps_allocate_decoder(self, 32); + + /* Disable LC (or Enable HQ) if PS is detected */ + sbrDec->LC_aacP_DecoderFlag = OFF; + } + else + { + /* + * Do not downgrade stream type from eaac+, if it has been explicitly declared + */ + if (pVars->mc_info.ExtendedAudioObjectType != MP4AUDIO_PS) + { + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } + } + else + { + sbrEnablePS = 1; /* Force this condition as it was explicititly declared */ + pVars->mc_info.psPresentFlag = sbrEnablePS; + + } + } +#else + + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } +#endif + +#else + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */ + +#endif + + } /* (SbrChannel[LEFT].syncState == SBR_ACTIVE && lock) */ + else + { + /* + * Default setting for upsampler + */ + if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC) + { + /* + * Change only in implicit signalling, otherwise keep original declaration + */ + pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR; + } + +#ifdef HQ_SBR + if (pVars->mc_info.nch > 1) + { + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */ + } + else + { + sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */ + } +#else + sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */ + +#endif + /* mask error and let upsampler run */ + err = SBRDEC_OK; + + } + + /* decoding */ + eleChannels = (stream->sbrElement [LEFT].ElementID == SBR_ID_CPE) ? 2 : 1; + + if (SbrChannel[LEFT].syncState == SBR_ACTIVE) + { + + sbr_decode_envelope(&(SbrChannel[LEFT].frameData)); + + decode_noise_floorlevels(&(SbrChannel[LEFT].frameData)); + + if (! SbrChannel[LEFT].frameData.coupling) + { + sbr_requantize_envelope_data(&(SbrChannel[LEFT].frameData)); + } + + if (eleChannels == 2) + { + + sbr_decode_envelope(&(SbrChannel[RIGHT].frameData)); + + decode_noise_floorlevels(&(SbrChannel[RIGHT].frameData)); + + if (SbrChannel[RIGHT].frameData.coupling) + { + sbr_envelope_unmapping(&(SbrChannel[ LEFT].frameData), + &(SbrChannel[RIGHT].frameData)); + } + else + { + sbr_requantize_envelope_data(&(SbrChannel[RIGHT].frameData)); + } + } + } + else /* enable upsampling until valid SBR is obtained */ + { + /* + * Incomplete sbr frame, or disabled SBR section + * Set the decoder to act as a regular upsampler + */ + + init_sbr_dec((sbrDec->outSampleRate >> 1), + pVars->mc_info.upsamplingFactor, + sbrDec, + &(self->SbrChannel[LEFT].frameData)); + + if ((eleChannels == 2) && (SbrChannel[RIGHT].syncState != SBR_ACTIVE)) + { + init_sbr_dec((sbrDec->outSampleRate >> 1), + pVars->mc_info.upsamplingFactor, + sbrDec, + &(self->SbrChannel[RIGHT].frameData)); + + } + + } + + } + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_PS) + { + ps_bstr_decoding(self->hParametricStereoDec); + /* allocate pointer for rigth channel qmf filter history */ + Int16 *tempInt16Ptr = (Int16 *)SbrChannel[RIGHT].frameData.V; + self->hParametricStereoDec->R_ch_qmf_filter_history = (Int32 *)tempInt16Ptr; + + + /* + * 1824 (48*38) Int32 needed by each matrix sbrQmfBufferReal, sbrQmfBufferImag + * pVars->share.predictedSamples has 2048 available + * pVars->fxpCoef[1] has 2048 available + */ + SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->share.predictedSamples; + SbrChannel[LEFT].frameData.sbrQmfBufferImag = &pVars->fxpCoef[0][920]; + + sbr_dec(ch_left, + timeData, + &(SbrChannel[LEFT].frameData), + (SbrChannel[LEFT].syncState == SBR_ACTIVE), + sbrDec, + &timeData[RIGHT], + self->hParametricStereoDec, + pVars); + } + else + { +#endif +#endif + + SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT]; +#ifdef HQ_SBR + SbrChannel[LEFT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT]; +#endif + + sbr_dec(ch_left, + timeData, + &(SbrChannel[LEFT].frameData), + (SbrChannel[LEFT].syncState == SBR_ACTIVE), + sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + NULL, + NULL, +#endif +#endif + pVars); + + if (numChannels == 2) + { + SbrChannel[RIGHT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT]; +#ifdef HQ_SBR + SbrChannel[RIGHT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT]; +#endif + + sbr_dec(ch_right, + &timeData[RIGHT], + &(SbrChannel[RIGHT].frameData), + (SbrChannel[RIGHT].syncState == SBR_ACTIVE), + sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + NULL, + NULL, +#endif +#endif + pVars); + + } + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + } +#endif +#endif + + return err; +} + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.h new file mode 100644 index 00000000..6cf15439 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_applied.h @@ -0,0 +1,130 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_applied.h + Funtions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_APPLIED_H +#define SBR_APPLIED_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_sbr_error.h" +#include "s_sbr_channel.h" +#include "s_sbrbitstream.h" +#include "sbr_dec.h" +#include "pv_audio_type_defs.h" +#include "s_tdec_int_file.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_FRAME_SIZE 1024 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + + SBR_ERROR sbr_applied(SBRDECODER_DATA * self, + SBRBITSTREAM * stream, + Int16 *ch_left, + Int16 *ch_right, + Int16 *timeData, + SBR_DEC *sbrDec, + tDec_Int_File *pVars, + Int32 numChannels); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.c new file mode 100644 index 00000000..80d930b1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.c @@ -0,0 +1,398 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_code_book_envlevel.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. Include conditional + ; compile variables also. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; LOCAL STORE/BUFFER/POINTER DEFINITIONS + ; Variable declaration - defined here and used outside this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL FUNCTION REFERENCES + ; Declare functions defined elsewhere and referenced in this module + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + /*******************************************************************************/ + /* table : envelope level, 1.5 dB */ + /* theor range : [-58,58], CODE_BOOK_SCF_LAV = 58 */ + /* implem range: [-60,60], CODE_BOOK_SCF_LAV10 = 60 */ + /* raw stats : envelopeLevel_00 (yes, wrong suffix in name) KK 01-03-09 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C2FIX.m/envelopeLevel_00T_cF.mat/m_hALC_cF + built by : FH 01-07-05 */ + + extern const Char bookSbrEnvLevel10T[120][2] = + { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -62, -67 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 18 }, { -73, -56 }, { 19, 21 }, { -74, 20 }, + { -55, -75 }, { 22, 26 }, { 23, 24 }, { -54, -76 }, + { -77, 25 }, { -53, -78 }, { 27, 34 }, { 28, 29 }, + { -52, -79 }, { 30, 31 }, { -80, -51 }, { 32, 33 }, + { -83, -82 }, { -81, -50 }, { 35, 57 }, { 36, 40 }, + { 37, 38 }, { -88, -84 }, { -48, 39 }, { -90, -85 }, + { 41, 46 }, { 42, 43 }, { -49, -87 }, { 44, 45 }, + { -89, -86 }, { -124, -123 }, { 47, 50 }, { 48, 49 }, + { -122, -121 }, { -120, -119 }, { 51, 54 }, { 52, 53 }, + { -118, -117 }, { -116, -115 }, { 55, 56 }, { -114, -113 }, + { -112, -111 }, { 58, 89 }, { 59, 74 }, { 60, 67 }, + { 61, 64 }, { 62, 63 }, { -110, -109 }, { -108, -107 }, + { 65, 66 }, { -106, -105 }, { -104, -103 }, { 68, 71 }, + { 69, 70 }, { -102, -101 }, { -100, -99 }, { 72, 73 }, + { -98, -97 }, { -96, -95 }, { 75, 82 }, { 76, 79 }, + { 77, 78 }, { -94, -93 }, { -92, -91 }, { 80, 81 }, + { -47, -46 }, { -45, -44 }, { 83, 86 }, { 84, 85 }, + { -43, -42 }, { -41, -40 }, { 87, 88 }, { -39, -38 }, + { -37, -36 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, { -35, -34 }, { -33, -32 }, { 96, 97 }, + { -31, -30 }, { -29, -28 }, { 99, 102 }, { 100, 101 }, + { -27, -26 }, { -25, -24 }, { 103, 104 }, { -23, -22 }, + { -21, -20 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -19, -18 }, { -17, -16 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } + }; + + /* direction: freq + raw table: HuffCode3C2FIX.m/envelopeLevel_00F_cF.mat/m_hALC_cF + built by : FH 01-07-05 */ + + extern const Char bookSbrEnvLevel10F[120][2] = + { + { 1, 2 }, { -64, -65 }, { 3, 4 }, { -63, -66 }, + { 5, 6 }, { -67, -62 }, { 7, 8 }, { -68, -61 }, + { 9, 10 }, { -69, -60 }, { 11, 13 }, { -70, 12 }, + { -59, -71 }, { 14, 16 }, { -58, 15 }, { -72, -57 }, + { 17, 19 }, { -73, 18 }, { -56, -74 }, { 20, 23 }, + { 21, 22 }, { -55, -75 }, { -54, -53 }, { 24, 27 }, + { 25, 26 }, { -76, -52 }, { -77, -51 }, { 28, 31 }, + { 29, 30 }, { -50, -78 }, { -79, -49 }, { 32, 36 }, + { 33, 34 }, { -48, -47 }, { -80, 35 }, { -81, -82 }, + { 37, 47 }, { 38, 41 }, { 39, 40 }, { -83, -46 }, + { -45, -84 }, { 42, 44 }, { -85, 43 }, { -44, -43 }, + { 45, 46 }, { -88, -87 }, { -86, -90 }, { 48, 66 }, + { 49, 56 }, { 50, 53 }, { 51, 52 }, { -92, -42 }, + { -41, -39 }, { 54, 55 }, { -105, -89 }, { -38, -37 }, + { 57, 60 }, { 58, 59 }, { -94, -91 }, { -40, -36 }, + { 61, 63 }, { -20, 62 }, { -115, -110 }, { 64, 65 }, + { -108, -107 }, { -101, -97 }, { 67, 89 }, { 68, 75 }, + { 69, 72 }, { 70, 71 }, { -95, -93 }, { -34, -27 }, + { 73, 74 }, { -22, -17 }, { -16, -124 }, { 76, 82 }, + { 77, 79 }, { -123, 78 }, { -122, -121 }, { 80, 81 }, + { -120, -119 }, { -118, -117 }, { 83, 86 }, { 84, 85 }, + { -116, -114 }, { -113, -112 }, { 87, 88 }, { -111, -109 }, + { -106, -104 }, { 90, 105 }, { 91, 98 }, { 92, 95 }, + { 93, 94 }, { -103, -102 }, { -100, -99 }, { 96, 97 }, + { -98, -96 }, { -35, -33 }, { 99, 102 }, { 100, 101 }, + { -32, -31 }, { -30, -29 }, { 103, 104 }, { -28, -26 }, + { -25, -24 }, { 106, 113 }, { 107, 110 }, { 108, 109 }, + { -23, -21 }, { -19, -18 }, { 111, 112 }, { -15, -14 }, + { -13, -12 }, { 114, 117 }, { 115, 116 }, { -11, -10 }, + { -9, -8 }, { 118, 119 }, { -7, -6 }, { -5, -4 } + }; + + /*******************************************************************************/ + /* table : envelope balance, 1.5 dB */ + /* theor range : [-48,48], CODE_BOOK_SCF_LAV = 48 */ + /* implem range: same but mapped to [-24,24], CODE_BOOK_SCF_LAV_BALANCE10 = 24 */ + /* raw stats : envelopePan_00 (yes, wrong suffix in name) KK 01-03-09 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance10T[48][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 }, + { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 }, + { -68, 9 }, { 10, 11 }, { -69, -59 }, { 12, 13 }, + { -70, -58 }, { 14, 28 }, { 15, 21 }, { 16, 18 }, + { -57, 17 }, { -71, -56 }, { 19, 20 }, { -88, -87 }, + { -86, -85 }, { 22, 25 }, { 23, 24 }, { -84, -83 }, + { -82, -81 }, { 26, 27 }, { -80, -79 }, { -78, -77 }, + { 29, 36 }, { 30, 33 }, { 31, 32 }, { -76, -75 }, + { -74, -73 }, { 34, 35 }, { -72, -55 }, { -54, -53 }, + { 37, 41 }, { 38, 39 }, { -52, -51 }, { -50, 40 }, + { -49, -48 }, { 42, 45 }, { 43, 44 }, { -47, -46 }, + { -45, -44 }, { 46, 47 }, { -43, -42 }, { -41, -40 } + }; + + /* direction: freq + raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance10F[48][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { -70, 12 }, + { -58, 13 }, { 14, 17 }, { -71, 15 }, { -57, 16 }, + { -56, -73 }, { 18, 32 }, { 19, 25 }, { 20, 22 }, + { -72, 21 }, { -88, -87 }, { 23, 24 }, { -86, -85 }, + { -84, -83 }, { 26, 29 }, { 27, 28 }, { -82, -81 }, + { -80, -79 }, { 30, 31 }, { -78, -77 }, { -76, -75 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -74, -55 }, + { -54, -53 }, { 38, 39 }, { -52, -51 }, { -50, -49 }, + { 41, 44 }, { 42, 43 }, { -48, -47 }, { -46, -45 }, + { 45, 46 }, { -44, -43 }, { -42, 47 }, { -41, -40 } + }; + + /*******************************************************************************/ + /* table : envelope level, 3.0 dB */ + /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */ + /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */ + /* raw stats : envelopeLevel_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrEnvLevel11T[62][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 11 }, { -69, -59 }, { 12, 14 }, + { -70, 13 }, { -71, -58 }, { 15, 18 }, { 16, 17 }, + { -72, -57 }, { -73, -74 }, { 19, 22 }, { -56, 20 }, + { -55, 21 }, { -54, -77 }, { 23, 31 }, { 24, 25 }, + { -75, -76 }, { 26, 27 }, { -78, -53 }, { 28, 29 }, + { -52, -95 }, { -94, 30 }, { -93, -92 }, { 32, 47 }, + { 33, 40 }, { 34, 37 }, { 35, 36 }, { -91, -90 }, + { -89, -88 }, { 38, 39 }, { -87, -86 }, { -85, -84 }, + { 41, 44 }, { 42, 43 }, { -83, -82 }, { -81, -80 }, + { 45, 46 }, { -79, -51 }, { -50, -49 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -48, -47 }, { -46, -45 }, + { 53, 54 }, { -44, -43 }, { -42, -41 }, { 56, 59 }, + { 57, 58 }, { -40, -39 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } + }; + + /* direction: freq + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrEnvLevel11F[62][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 10 }, { -60, -69 }, { 11, 12 }, { -59, -70 }, + { 13, 14 }, { -58, -71 }, { 15, 16 }, { -57, -72 }, + { 17, 19 }, { -56, 18 }, { -55, -73 }, { 20, 24 }, + { 21, 22 }, { -74, -54 }, { -53, 23 }, { -75, -76 }, + { 25, 30 }, { 26, 27 }, { -52, -51 }, { 28, 29 }, + { -77, -79 }, { -50, -49 }, { 31, 39 }, { 32, 35 }, + { 33, 34 }, { -78, -46 }, { -82, -88 }, { 36, 37 }, + { -83, -48 }, { -47, 38 }, { -86, -85 }, { 40, 47 }, + { 41, 44 }, { 42, 43 }, { -80, -44 }, { -43, -42 }, + { 45, 46 }, { -39, -87 }, { -84, -40 }, { 48, 55 }, + { 49, 52 }, { 50, 51 }, { -95, -94 }, { -93, -92 }, + { 53, 54 }, { -91, -90 }, { -89, -81 }, { 56, 59 }, + { 57, 58 }, { -45, -41 }, { -38, -37 }, { 60, 61 }, + { -36, -35 }, { -34, -33 } + }; + + /*******************************************************************************/ + /* table : envelope balance, 3.0 dB */ + /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */ + /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */ + /* raw stats : envelopeBalance_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance11T[24][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 16 }, { 11, 13 }, { -69, 12 }, + { -76, -75 }, { 14, 15 }, { -74, -73 }, { -72, -71 }, + { 17, 20 }, { 18, 19 }, { -70, -59 }, { -58, -57 }, + { 21, 22 }, { -56, -55 }, { -54, 23 }, { -53, -52 } + }; + + /* direction: time (?) + raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrEnvBalance11F[24][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 }, + { -62, 5 }, { -61, 6 }, { -67, 7 }, { -68, 8 }, + { -60, 9 }, { 10, 13 }, { -69, 11 }, { -59, 12 }, + { -58, -76 }, { 14, 17 }, { 15, 16 }, { -75, -74 }, + { -73, -72 }, { 18, 21 }, { 19, 20 }, { -71, -70 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } + }; + + /*******************************************************************************/ + /* table : noise level, 3.0 dB */ + /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */ + /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */ + /* raw stats : noiseLevel_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode2.m + built by : FH 00-02-04 */ + + extern const Char bookSbrNoiseLevel11T[62][2] = + { + { -64, 1 }, { -63, 2 }, { -65, 3 }, { -66, 4 }, + { -62, 5 }, { -67, 6 }, { 7, 8 }, { -61, -68 }, + { 9, 30 }, { 10, 15 }, { -60, 11 }, { -69, 12 }, + { 13, 14 }, { -59, -53 }, { -95, -94 }, { 16, 23 }, + { 17, 20 }, { 18, 19 }, { -93, -92 }, { -91, -90 }, + { 21, 22 }, { -89, -88 }, { -87, -86 }, { 24, 27 }, + { 25, 26 }, { -85, -84 }, { -83, -82 }, { 28, 29 }, + { -81, -80 }, { -79, -78 }, { 31, 46 }, { 32, 39 }, + { 33, 36 }, { 34, 35 }, { -77, -76 }, { -75, -74 }, + { 37, 38 }, { -73, -72 }, { -71, -70 }, { 40, 43 }, + { 41, 42 }, { -58, -57 }, { -56, -55 }, { 44, 45 }, + { -54, -52 }, { -51, -50 }, { 47, 54 }, { 48, 51 }, + { 49, 50 }, { -49, -48 }, { -47, -46 }, { 52, 53 }, + { -45, -44 }, { -43, -42 }, { 55, 58 }, { 56, 57 }, + { -41, -40 }, { -39, -38 }, { 59, 60 }, { -37, -36 }, + { -35, 61 }, { -34, -33 } + }; + + /*******************************************************************************/ + /* table : noise balance, 3.0 dB */ + /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */ + /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */ + /* raw stats : noiseBalance_11 KK 00-02-03 */ + /*******************************************************************************/ + + /* direction: time + raw table: HuffCode3C.m/noiseBalance_11.mat/v_hALB + built by : FH 01-05-15 */ + + extern const Char bookSbrNoiseBalance11T[24][2] = + { + { -64, 1 }, { -65, 2 }, { -63, 3 }, { 4, 9 }, + { -66, 5 }, { -62, 6 }, { 7, 8 }, { -76, -75 }, + { -74, -73 }, { 10, 17 }, { 11, 14 }, { 12, 13 }, + { -72, -71 }, { -70, -69 }, { 15, 16 }, { -68, -67 }, + { -61, -60 }, { 18, 21 }, { 19, 20 }, { -59, -58 }, + { -57, -56 }, { 22, 23 }, { -55, -54 }, { -53, -52 } + }; + +#ifdef __cplusplus +} +#endif + + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.h new file mode 100644 index 00000000..62503318 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_code_book_envlevel.h @@ -0,0 +1,99 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_code_book_envlevel.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CODE_BOOK_ENVLEVEL_H +#define SBR_CODE_BOOK_ENVLEVEL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + extern const Char bookSbrEnvLevel10T[120][2]; + extern const Char bookSbrEnvLevel10F[120][2]; + extern const Char bookSbrEnvBalance10T[48][2]; + extern const Char bookSbrEnvBalance10F[48][2]; + extern const Char bookSbrEnvLevel11T[62][2]; + extern const Char bookSbrEnvLevel11F[62][2]; + extern const Char bookSbrEnvBalance11T[24][2]; + extern const Char bookSbrEnvBalance11F[24][2]; + extern const Char bookSbrNoiseLevel11T[62][2]; + extern const Char bookSbrNoiseBalance11T[24][2]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif + + + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_constants.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_constants.h new file mode 100644 index 00000000..6312dd80 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_constants.h @@ -0,0 +1,202 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_constants.h + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CONSTANTS_H +#define SBR_CONSTANTS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + + +#define SBR_AMP_RES_1_5 0 +#define SBR_AMP_RES_3_0 1 + +#define MAX_NOISE_ENVELOPES 2 +#define MAX_NOISE_COEFFS 5 +#define MAX_NUM_NOISE_VALUES (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS) + +#define MAX_ENVELOPES 5 +#define MAX_FREQ_COEFFS 58 +#define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS) + +#define MAX_NUM_CHANNELS 2 +#define NOISE_FLOOR_OFFSET 6 +#define NOISE_FLOOR_OFFSET_PLUS_1 7 + +#define LOW_RES 0 +#define HIGH_RES 1 + +#define LO 0 +#define HI 1 + +#define TIME 1 +#define FREQ 0 + +#define LENGTH_FRAME_INFO 35 + +#define SI_SBR_CRC_BITS 10 + +#define SBR_FREQ_SCALE_DEFAULT 2 +#define SBR_ALTER_SCALE_DEFAULT 1 +#define SBR_NOISE_BANDS_DEFAULT 2 + +#define SBR_LIMITER_BANDS_DEFAULT 2 +#define SBR_LIMITER_GAINS_DEFAULT 2 +#define SBR_INTERPOL_FREQ_DEFAULT 1 +#define SBR_SMOOTHING_LENGTH_DEFAULT 1 + +/* header */ +#define SI_SBR_AMP_RES_BITS 1 +#define SI_SBR_START_FREQ_BITS 4 +#define SI_SBR_STOP_FREQ_BITS 4 +#define SI_SBR_XOVER_BAND_BITS 3 +#define SI_SBR_RESERVED_BITS_HDR 2 +#define SI_SBR_DATA_EXTRA_BITS 1 +#define SI_SBR_HEADER_EXTRA_1_BITS 1 +#define SI_SBR_HEADER_EXTRA_2_BITS 1 + +#define SI_SBR_FREQ_SCALE_BITS 2 +#define SI_SBR_ALTER_SCALE_BITS 1 +#define SI_SBR_NOISE_BANDS_BITS 2 + +#define SI_SBR_LIMITER_BANDS_BITS 2 +#define SI_SBR_LIMITER_GAINS_BITS 2 +#define SI_SBR_INTERPOL_FREQ_BITS 1 +#define SI_SBR_SMOOTHING_LENGTH_BITS 1 + + +/* data */ +#define SI_SBR_RESERVED_PRESENT 1 +#define SI_SBR_RESERVED_BITS_DATA 4 + +#define SI_SBR_COUPLING_BITS 1 + +#define SI_SBR_INVF_MODE_BITS 2 + +#define SI_SBR_EXTENDED_DATA_BITS 1 +#define SI_SBR_EXTENSION_SIZE_BITS 4 +#define SI_SBR_EXTENSION_ESC_COUNT_BITS 8 +#define SI_SBR_EXTENSION_ID_BITS 2 + +#define SI_SBR_NOISE_MODE_BITS 1 +#define SI_SBR_DOMAIN_BITS 1 + +#define SI_SBR_START_ENV_BITS_AMP_RES_3_0 6 +#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0 5 +#define SI_SBR_START_NOISE_BITS_AMP_RES_3_0 5 +#define SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0 5 + +#define SI_SBR_START_ENV_BITS_AMP_RES_1_5 7 +#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5 6 + + +#define SBR_CLA_BITS 2 +#define SBR_ABS_BITS 2 +#define SBR_RES_BITS 1 +#define SBR_REL_BITS 2 +#define SBR_ENV_BITS 2 +#define SBR_NUM_BITS 2 + + +#define FIXFIX 0 +#define FIXVAR 1 +#define VARFIX 2 +#define VARVAR 3 + + +#define LEN_EX_TYPE (4) +#define LEN_NIBBLE (4) + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.c new file mode 100644 index 00000000..1c20c4bf --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.c @@ -0,0 +1,186 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_crc_check.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_crc_check.h" +#include "s_crc_buffer.h" +#include "buf_getbits.h" +#include "sbr_constants.h" +#include "check_crc.h" + + + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const unsigned short MAXCRCSTEP = 16; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, UInt32 NrBits) +{ + Int32 crcResult = 1; + BIT_BUFFER BitBufferCRC; + UInt32 NrCrcBits; + + UInt32 crcCheckSum; + + Int32 i; + CRC_BUFFER CrcBuf; + UInt32 bValue; + Int32 CrcStep; + Int32 CrcNrBitsRest; + + crcCheckSum = buf_getbits(hBitBuf, SI_SBR_CRC_BITS); + + + /* + * Copy Bit buffer State + */ + + BitBufferCRC.char_ptr = hBitBuf->char_ptr; + BitBufferCRC.buffer_word = hBitBuf->buffer_word; + BitBufferCRC.buffered_bits = hBitBuf->buffered_bits; + BitBufferCRC.nrBitsRead = hBitBuf->nrBitsRead; + BitBufferCRC.bufferLen = hBitBuf->bufferLen; + + + NrCrcBits = min(NrBits, BitBufferCRC.bufferLen - BitBufferCRC.nrBitsRead); + + + CrcStep = NrCrcBits / MAXCRCSTEP; + CrcNrBitsRest = (NrCrcBits - CrcStep * MAXCRCSTEP); + + CrcBuf.crcState = CRCSTART; + CrcBuf.crcMask = CRCMASK; + CrcBuf.crcPoly = CRCPOLY; + + for (i = 0; i < CrcStep; i++) + { + bValue = buf_getbits(&BitBufferCRC, MAXCRCSTEP); + check_crc(&CrcBuf, bValue, MAXCRCSTEP); + } + + bValue = buf_getbits(&BitBufferCRC, CrcNrBitsRest); + check_crc(&CrcBuf, bValue, CrcNrBitsRest); + + if ((UInt32)(CrcBuf.crcState & CRCRANGE) != crcCheckSum) + { + crcResult = 0; + } + + return (crcResult); +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.h new file mode 100644 index 00000000..f0f338ef --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_crc_check.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_crc_check.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CRC_CHECK_H +#define SBR_CRC_CHECK_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define CRCPOLY 0x0233 +#define CRCMASK 0x0200 +#define CRCSTART 0x0000 +#define CRCRANGE 0x03FF + +#define SBR_EXTENSION 13 /* 1101 */ +#define SBR_EXTENSION_CRC 14 /* 1110 */ + + + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, + UInt32 NrBits); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.c new file mode 100644 index 00000000..33e2c01e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.c @@ -0,0 +1,248 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_create_limiter_bands.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_create_limiter_bands.h" +#include "shellsort.h" +#include "s_patch.h" +#include "pv_log2.h" + +#include "fxp_mul32.h" + +#define R_SHIFT 29 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_create_limiter_bands(Int32 limSbc[][13], + Int32 *gateMode, + Int *freqTable, + struct PATCH Patch, + const Int32 noBands) +{ + Int32 i; + Int32 j; + Int32 k; + Int isPatchBorder[2]; + Int32 patchBorders[MAX_NUM_PATCHES + 1]; + Int32 workLimiterBandTable[32 + MAX_NUM_PATCHES + 1]; + + Int32 nOctaves; + const Int32 limiterBandsPerOctave[4] = + {Q_fmt(0.0F), Q_fmt(1.2F), + Q_fmt(2.0F), Q_fmt(3.0F) + }; + + Int32 tmp_q1; + + Int32 noPatches = Patch.noOfPatches; + Int32 lowSubband = freqTable[0]; + Int32 highSubband = freqTable[noBands]; + + + for (i = 0; i < noPatches; i++) + { + patchBorders[i] = Patch.targetStartBand[i] - lowSubband; + } + patchBorders[i] = highSubband - lowSubband; + + /* First band: 1 limiter band. */ + limSbc[0][0] = freqTable[0] - lowSubband; + limSbc[0][1] = freqTable[noBands] - lowSubband; + gateMode[0] = 1; + + /* Next three bands: 1.2, 2, 3 limiter bands/octave plus bandborders at patchborders. */ + for (i = 1; i < 4; i++) + { + + for (k = 0; k <= noBands; k++) + { + workLimiterBandTable[k] = freqTable[k] - lowSubband; + } + + for (k = 1; k < noPatches; k++) + { + workLimiterBandTable[noBands+k] = patchBorders[k]; + } + + gateMode[i] = noBands + noPatches - 1; + shellsort(workLimiterBandTable, gateMode[i] + 1); + + for (j = 1; j <= gateMode[i]; j++) + { + tmp_q1 = ((workLimiterBandTable[j] + lowSubband) << 20) / (workLimiterBandTable[j-1] + lowSubband); + + nOctaves = pv_log2(tmp_q1); + + tmp_q1 = fxp_mul32_Q20(nOctaves, limiterBandsPerOctave[i]); + if (tmp_q1 < Q_fmt(0.49)) + { + if (workLimiterBandTable[j] == workLimiterBandTable[j-1]) + { + workLimiterBandTable[j] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + continue; + } + + isPatchBorder[0] = isPatchBorder[1] = 0; + + for (k = 0; k <= noPatches; k++) + { + if (workLimiterBandTable[j-1] == patchBorders[k]) + { + isPatchBorder[0] = 1; + break; + } + } + + for (k = 0; k <= noPatches; k++) + { + if (workLimiterBandTable[j] == patchBorders[k]) + { + isPatchBorder[1] = 1; + break; + } + } + + if (!isPatchBorder[1]) + { + workLimiterBandTable[j] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + } + else if (!isPatchBorder[0]) + { + workLimiterBandTable[j-1] = highSubband; + shellsort(workLimiterBandTable, gateMode[i] + 1); + gateMode[i]--; + j--; + } + } + } + for (k = 0; k <= gateMode[i]; k++) + { + limSbc[i][k] = workLimiterBandTable[k]; + } + } +} + + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.h new file mode 100644 index 00000000..acae11b6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_create_limiter_bands.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_create_limiter_bands.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_CREATE_LIMITER_BANDS_H +#define SBR_CREATE_LIMITER_BANDS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "sbr_generate_high_freq.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_create_limiter_bands(Int32 limSbc[4][12 + 1], + Int32 gateMode[4], + Int *freqTable, + struct PATCH Patch, + const Int32 noBands); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.c new file mode 100644 index 00000000..82f03dfa --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.c @@ -0,0 +1,938 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder core function + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "s_sbr_frame_data.h" +#include "calc_sbr_synfilterbank.h" +#include "calc_sbr_anafilterbank.h" +#include "calc_sbr_envelope.h" +#include "sbr_generate_high_freq.h" +#include "sbr_dec.h" +#include "decode_noise_floorlevels.h" +#include "aac_mem_funcs.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +#ifdef PARAMETRICSTEREO + +#include "ps_applied.h" +#include "ps_init_stereo_mixing.h" + +#endif + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_dec(Int16 *inPcmData, + Int16 *ftimeOutPtr, + SBR_FRAME_DATA * hFrameData, + Int32 applyProcessing, + SBR_DEC *sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + Int16 * ftimeOutPtrPS, + HANDLE_PS_DEC hParametricStereoDec, +#endif +#endif + tDec_Int_File *pVars) +{ + Int32 i; + Int32 j; + Int32 m; + + Int32 *frameInfo = hFrameData->frameInfo; + Int num_qmf_bands; + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + Int32 env; + + Int32 *qmf_PS_generated_Real; + Int32 *qmf_PS_generated_Imag; + + Int32 *Sr_x; + Int32 *Si_x; + + +#endif +#endif + + Int32(*scratch_mem)[64]; + Int16 *circular_buffer_s; + + Int32 k; + Int32 *Sr; + Int32 *Si; + Int32 *ptr_tmp1; + Int32 *ptr_tmp2; + scratch_mem = pVars->scratch.scratch_mem; + + + if (applyProcessing) + { + num_qmf_bands = sbrDec->lowSubband; + } + else + { + num_qmf_bands = 32; /* becomes a resampler by 2 */ + } + + /* -------------------------------------------------- */ + /* + * Re-Load Buffers + */ + pv_memmove(&hFrameData->sbrQmfBufferReal[0], + &hFrameData->HistsbrQmfBufferReal[0], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); +#ifdef HQ_SBR + + + if (sbrDec->LC_aacP_DecoderFlag == OFF) + { + pv_memmove(&hFrameData->sbrQmfBufferImag[0], + &hFrameData->HistsbrQmfBufferImag[0], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + } +#endif + /* -------------------------------------------------- */ + + + /* + * low band codec signal subband filtering + */ + + for (i = 0; i < 32; i++) + { + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + calc_sbr_anafilterbank_LC(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i], + &inPcmData[319] + (i << 5), + scratch_mem, + num_qmf_bands); + + } +#ifdef HQ_SBR + else + { + + calc_sbr_anafilterbank(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i], + hFrameData->codecQmfBufferImag[sbrDec->bufWriteOffs + i], + &inPcmData[319] + (i << 5), + scratch_mem, + num_qmf_bands); + } +#endif + + } + + if (pVars->ltp_buffer_state) + { + pv_memcpy(&inPcmData[-1024-288], &inPcmData[1024], 288*sizeof(*inPcmData)); + } + else + { + pv_memcpy(&inPcmData[1024 + 288], &inPcmData[1024], 288*sizeof(*inPcmData)); + } + + + if (applyProcessing) + { + + /* + * Inverse filtering of lowband + HF generation + */ + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + sbr_generate_high_freq((Int32(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs), + NULL, + (Int32 *)(hFrameData->sbrQmfBufferReal), + NULL, + hFrameData->sbr_invf_mode, + hFrameData->sbr_invf_mode_prev, + &(sbrDec->FreqBandTableNoise[1]), + sbrDec->NoNoiseBands, + sbrDec->lowSubband, + sbrDec->V_k_master, + sbrDec->Num_Master, + sbrDec->outSampleRate, + frameInfo, + hFrameData->degreeAlias, + scratch_mem, + hFrameData->BwVector,/* */ + hFrameData->BwVectorOld, + &(sbrDec->Patch), + sbrDec->LC_aacP_DecoderFlag, + &(sbrDec->highSubband)); + + + /* + * Adjust envelope of current frame. + */ + + calc_sbr_envelope(hFrameData, + (Int32 *)(hFrameData->sbrQmfBufferReal), + NULL, + sbrDec->FreqBandTable, + sbrDec->NSfb, + sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + hFrameData->reset_flag, + hFrameData->degreeAlias, + &(hFrameData->harm_index), + &(hFrameData->phase_index), + hFrameData->hFp, + &(hFrameData->sUp), + sbrDec->limSbc, + sbrDec->gateMode, +#ifdef HQ_SBR + NULL, + NULL, + NULL, + NULL, +#endif + scratch_mem, + sbrDec->Patch, + sbrDec->sqrt_cache, + sbrDec->LC_aacP_DecoderFlag); + } +#ifdef HQ_SBR + else + { + + sbr_generate_high_freq((Int32(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs), + (Int32(*)[32])(hFrameData->codecQmfBufferImag + sbrDec->bufReadOffs), + (Int32 *)(hFrameData->sbrQmfBufferReal), + (Int32 *)(hFrameData->sbrQmfBufferImag), + hFrameData->sbr_invf_mode, + hFrameData->sbr_invf_mode_prev, + &(sbrDec->FreqBandTableNoise[1]), + sbrDec->NoNoiseBands, + sbrDec->lowSubband, + sbrDec->V_k_master, + sbrDec->Num_Master, + sbrDec->outSampleRate, + frameInfo, + NULL, + scratch_mem, + hFrameData->BwVector, + hFrameData->BwVectorOld, + &(sbrDec->Patch), + sbrDec->LC_aacP_DecoderFlag, + &(sbrDec->highSubband)); + + /* + * Adjust envelope of current frame. + */ + + calc_sbr_envelope(hFrameData, + (Int32 *)(hFrameData->sbrQmfBufferReal), + (Int32 *)(hFrameData->sbrQmfBufferImag), + sbrDec->FreqBandTable, + sbrDec->NSfb, + sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + hFrameData->reset_flag, + NULL, + &(hFrameData->harm_index), + &(hFrameData->phase_index), + hFrameData->hFp, + &(hFrameData->sUp), + sbrDec->limSbc, + sbrDec->gateMode, + hFrameData->fBuf_man, + hFrameData->fBuf_exp, + hFrameData->fBufN_man, + hFrameData->fBufN_exp, + scratch_mem, + sbrDec->Patch, + sbrDec->sqrt_cache, + sbrDec->LC_aacP_DecoderFlag); + + } +#endif + + + } + else /* else for applyProcessing */ + { + /* no sbr, set high band buffers to zero */ + + for (i = 0; i < SBR_NUM_COLUMNS; i++) + { + pv_memset((void *)&hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS], + 0, + SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + +#ifdef HQ_SBR + pv_memset((void *)&hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS], + 0, + SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + +#endif + } + + } + + + /* + * Synthesis subband filtering. + */ + +#ifdef HQ_SBR + +#ifdef PARAMETRICSTEREO + + + /* + * psPresentFlag set implies hParametricStereoDec !=NULL, second condition is + * is just here to prevent CodeSonar warnings. + */ + if ((pVars->mc_info.psPresentFlag) && (applyProcessing) && + (hParametricStereoDec != NULL)) + { + + /* + * qmfBufferReal uses the rigth aac channel ( perChan[1] is not used) + * followed by the buffer fxpCoef[2][2048] which makes a total of + * 2349 + 2048*2 = 6445 + * These 2 matrices (qmfBufferReal & qmfBufferImag) are + * [2][38][64] == 4864 Int32 + */ + + + tDec_Int_Chan *tmpx = &pVars->perChan[1]; + /* + * dereferencing type-punned pointer avoid + * breaking strict-aliasing rules + */ + Int32 *tmp = (Int32 *)tmpx; + hParametricStereoDec->qmfBufferReal = (Int32(*)[64]) tmp; + + tmp = (Int32 *) & hParametricStereoDec->qmfBufferReal[38][0]; + hParametricStereoDec->qmfBufferImag = (Int32(*)[64]) tmp; + + for (i = 0; i < 32; i++) + { + Int xoverBand; + + if (i < ((hFrameData->frameInfo[1]) << 1)) + { + xoverBand = sbrDec->prevLowSubband; + } + else + { + xoverBand = sbrDec->lowSubband; + } + + if (xoverBand > sbrDec->highSubband) + { + xoverBand = 32; /* error condition, default to upsampling mode */ + } + + m = sbrDec->bufReadOffs + i; /* 2 + i */ + + Sr_x = hParametricStereoDec->qmfBufferReal[i]; + Si_x = hParametricStereoDec->qmfBufferImag[i]; + + + + for (j = 0; j < xoverBand; j++) + { + Sr_x[j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]); + Si_x[j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]); + } + + + + + pv_memcpy(&Sr_x[xoverBand], + &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS], + (sbrDec->highSubband - xoverBand)*sizeof(*Sr_x)); + + pv_memcpy(&Si_x[xoverBand], + &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS], + (sbrDec->highSubband - xoverBand)*sizeof(*Si_x)); + + pv_memset((void *)&Sr_x[sbrDec->highSubband], + 0, + (64 - sbrDec->highSubband)*sizeof(*Sr_x)); + + pv_memset((void *)&Si_x[sbrDec->highSubband], + 0, + (64 - sbrDec->highSubband)*sizeof(*Si_x)); + + + } + + for (i = 32; i < 32 + 6; i++) + { + m = sbrDec->bufReadOffs + i; /* 2 + i */ + + for (j = 0; j < 5; j++) + { + hParametricStereoDec->qmfBufferReal[i][j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]); + hParametricStereoDec->qmfBufferImag[i][j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]); + } + + } + + + /* + * Update Buffers + */ + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */ + hFrameData->codecQmfBufferReal[j], /* from */ + sizeof(*hFrameData->codecQmfBufferReal[i]) << 5); + + pv_memmove(hFrameData->codecQmfBufferImag[i], + hFrameData->codecQmfBufferImag[j], + sizeof(*hFrameData->codecQmfBufferImag[i]) << 5); + } + + + pv_memmove(&hFrameData->HistsbrQmfBufferReal[0], + &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + + pv_memmove(&hFrameData->HistsbrQmfBufferImag[0], + &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + + + /* + * Needs whole QMF matrix formed before applying + * Parametric stereo processing. + */ + + qmf_PS_generated_Real = scratch_mem[0]; + qmf_PS_generated_Imag = scratch_mem[1]; + env = 0; + + /* + * Set circular buffer for Left channel + */ + + circular_buffer_s = (Int16 *)scratch_mem[7]; + + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(&circular_buffer_s[2048], + hFrameData->V, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + hFrameData->V, + 1152*sizeof(*circular_buffer_s)); + + } + + + /* + * Set Circular buffer for PS hybrid analysis + */ + for (i = 0, j = 0; i < 3; i++) + { + + pv_memmove(&scratch_mem[2][32 + j ], + hParametricStereoDec->hHybrid->mQmfBufferReal[i], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal)); + pv_memmove(&scratch_mem[2][32 + j + 44], + hParametricStereoDec->hHybrid->mQmfBufferImag[i], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag)); + j += 88; + } + + pv_memset((void *)&qmf_PS_generated_Real[hParametricStereoDec->usb], + 0, + (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Real)); + + pv_memset((void *)&qmf_PS_generated_Imag[hParametricStereoDec->usb], + 0, + (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Imag)); + + + for (i = 0; i < 32; i++) + { + if (i == (Int)hParametricStereoDec-> aEnvStartStop[env]) + { + ps_init_stereo_mixing(hParametricStereoDec, env, sbrDec->highSubband); + env++; + } + + + ps_applied(hParametricStereoDec, + &hParametricStereoDec->qmfBufferReal[i], + &hParametricStereoDec->qmfBufferImag[i], + qmf_PS_generated_Real, + qmf_PS_generated_Imag, + scratch_mem[2], + i); + + /* Create time samples for regular mono channel */ + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + + } + + pv_memmove(hParametricStereoDec->qmfBufferReal[i], qmf_PS_generated_Real, 64*sizeof(*qmf_PS_generated_Real)); + pv_memmove(hParametricStereoDec->qmfBufferImag[i], qmf_PS_generated_Imag, 64*sizeof(*qmf_PS_generated_Real)); + + } + + + /* + * Save Circular buffer history used on PS hybrid analysis + */ + + for (i = 0, j = 0; i < 3; i++) + { + pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferReal[i], + &scratch_mem[2][ 64 + j ], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal)); + + pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferImag[i], + &scratch_mem[2][ 64 + j + 44], + HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag)); + + j += 88; + } + + pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + + /* + * Set circular buffer for Right channel + */ + + circular_buffer_s = (Int16 *)scratch_mem[5]; + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(&circular_buffer_s[2048], + (Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + (Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, + 1152*sizeof(*circular_buffer_s)); + + } + + + for (i = 0; i < 32; i++) + { + if (pVars->mc_info.bDownSampledSbr) + { + + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtrPS + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */ + hParametricStereoDec->qmfBufferImag[i], /* imagSamples */ + ftimeOutPtrPS + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + + } + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove((Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove((Int32 *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + } + + + + + + } + else /* else -- sbrEnablePS */ + { + +#endif /* PARAMETRICSTEREO */ +#endif /* HQ_SBR */ + + /* + * Use shared aac memory as continuous buffer + */ + + + Sr = scratch_mem[0]; + Si = scratch_mem[1]; + + circular_buffer_s = (Int16*)scratch_mem[2]; + + if (pVars->mc_info.bDownSampledSbr) + { + + pv_memmove(&circular_buffer_s[2048], + hFrameData->V, + 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(&circular_buffer_s[4096], + hFrameData->V, + 1152*sizeof(*circular_buffer_s)); + } + + for (i = 0; i < 32; i++) + { + Int xoverBand; + + if (applyProcessing) + { + if (i < ((hFrameData->frameInfo[1]) << 1)) + { + xoverBand = sbrDec->prevLowSubband; + + } + else + { + xoverBand = sbrDec->lowSubband; + } + + if (xoverBand > sbrDec->highSubband) + { + xoverBand = 32; /* error condition, default to upsampling mode */ + } + } + else + { + xoverBand = 32; + sbrDec->highSubband = 32; + } + + + m = sbrDec->bufReadOffs + i; /* sbrDec->bufReadOffs == 2 */ + + + ptr_tmp1 = (hFrameData->codecQmfBufferReal[m]); + ptr_tmp2 = Sr; + + if (sbrDec->LC_aacP_DecoderFlag == ON) + { + + for (k = (xoverBand >> 1); k != 0; k--) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9; + *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9; + } + if (xoverBand & 1) + { + *(ptr_tmp2++) = (*(ptr_tmp1)) >> 9; + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS]; + + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)) << 1; + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank_LC(Sr, /* realSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank_LC(Sr, /* realSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + } +#ifdef HQ_SBR + else + { + + for (k = xoverBand; k != 0; k--) + { + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS]; + ptr_tmp2 = &Sr[xoverBand]; + + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)); + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + ptr_tmp1 = (hFrameData->codecQmfBufferImag[m]); + ptr_tmp2 = Si; + + for (k = (xoverBand >> 1); k != 0; k--) + { + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++)); + } + if (xoverBand & 1) + { + *(ptr_tmp2) = shft_lft_1(*(ptr_tmp1)); + } + + ptr_tmp1 = &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS]; + ptr_tmp2 = &Si[xoverBand]; + + for (k = xoverBand; k < sbrDec->highSubband; k++) + { + *(ptr_tmp2++) = (*(ptr_tmp1++)); + } + + pv_memset((void *)ptr_tmp2, + 0, + (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2)); + + + if (pVars->mc_info.bDownSampledSbr) + { + calc_sbr_synfilterbank(Sr, /* realSamples */ + Si, /* imagSamples */ + ftimeOutPtr + (i << 6), + &circular_buffer_s[1984 - (i<<6)], + pVars->mc_info.bDownSampledSbr); + } + else + { + calc_sbr_synfilterbank(Sr, /* realSamples */ + Si, /* imagSamples */ + ftimeOutPtr + (i << 7), + &circular_buffer_s[3968 - (i<<7)], + pVars->mc_info.bDownSampledSbr); + } + } +#endif + + } + + if (pVars->mc_info.bDownSampledSbr) + { + pv_memmove(hFrameData->V, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s)); + } + else + { + pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s)); + } + + + + + /* + * Update Buffers + */ + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */ + hFrameData->codecQmfBufferReal[j], /* from */ + sizeof(*hFrameData->codecQmfBufferReal[i]) << 5); + } + + + pv_memmove(&hFrameData->HistsbrQmfBufferReal[0], + &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal)); + +#ifdef HQ_SBR + if (sbrDec->LC_aacP_DecoderFlag == OFF) + { + for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 6 and unchanged */ + { + j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */ + + + pv_memmove(hFrameData->codecQmfBufferImag[i], + hFrameData->codecQmfBufferImag[j], + sizeof(*hFrameData->codecQmfBufferImag[i]) << 5); + + } + + pv_memmove(&hFrameData->HistsbrQmfBufferImag[0], + &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS], + 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag)); + } +#endif + + +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + } +#endif +#endif + + + hFrameData->reset_flag = 0; + if (applyProcessing) + { + sbrDec->prevLowSubband = sbrDec->lowSubband; + } + +} + + +#endif /* AAC_PLUS */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.h new file mode 100644 index 00000000..53c0f10d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_dec.h @@ -0,0 +1,139 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_dec.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DEC_H +#define SBR_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_frame_data.h" +#include "pv_audio_type_defs.h" +#include "s_patch.h" +#include "e_blockswitching.h" +#include "s_sbr_dec.h" +#include "s_tdec_int_file.h" +#include "config.h" +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + + void sbr_dec(Int16 *inPcmData, + Int16 *ftimeOutPtr, + SBR_FRAME_DATA * hFrameData, + Int32 applyProcessing, + SBR_DEC *sbrDec, +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + Int16 * ftimeOutPtrPS, + HANDLE_PS_DEC hParametricStereoDec, +#endif +#endif + tDec_Int_File *pVars); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.c new file mode 100644 index 00000000..f8fa1756 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.c @@ -0,0 +1,281 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_decode_envelope.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void mapLowResEnergyVal( + Int32 currVal, + Int32 *prevData, + Int32 offset, + Int32 index, + Int32 res); + +Int32 indexLow2High(Int32 offset, + Int32 index, + Int32 res); + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData) + +{ + Int32 i; + Int32 no_of_bands; + Int32 band; + Int32 freqRes; + Int32 *iEnvelope = hFrameData->iEnvelope_man; + Int32 *sfb_nrg_prev = hFrameData->sfb_nrg_prev_man; + + Int32 offset = hFrameData->offset; + Int32 *nSfb = hFrameData->nSfb; + Int32 *domain_vec = hFrameData->domain_vec1; + Int32 *frameInfo = hFrameData->frameInfo; + + + + for (i = 0; i < frameInfo[0]; i++) + { + freqRes = frameInfo[frameInfo[0] + i + 2]; + no_of_bands = nSfb[freqRes]; + + if (domain_vec[i] == 0) + { + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + 0, + freqRes); + iEnvelope++; + + for (band = 1; band < no_of_bands; band++) + { + *iEnvelope += *(iEnvelope - 1); + + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + band, + freqRes); + iEnvelope++; + } + } + else + { + for (band = 0; band < no_of_bands; band++) + { + *iEnvelope += sfb_nrg_prev[ indexLow2High(offset, band, freqRes)]; + + mapLowResEnergyVal(*iEnvelope, + sfb_nrg_prev, + offset, + band, + freqRes); + iEnvelope++; + } + } + } +} + + + +void mapLowResEnergyVal( + Int32 currVal, + Int32 *prevData, + Int32 offset, + Int32 index, + Int32 res) +{ + Int32 tmp; + + if (res == LO) + { + if (offset >= 0) + { + if (index < offset) + { + prevData[index] = currVal; + } + else + { + tmp = (index << 1) - offset; + prevData[tmp ] = currVal; + prevData[tmp +1 ] = currVal; + } + } + else + { + offset = -offset; + if (index < offset) + { + tmp = (index << 1) + index; + prevData[tmp ] = currVal; + prevData[tmp + 1] = currVal; + prevData[tmp + 2] = currVal; + } + else + { + tmp = (index << 1) + offset; + prevData[tmp ] = currVal; + prevData[tmp + 1] = currVal; + } + } + } + else + { + prevData[index] = currVal; + } +} + + +Int32 indexLow2High(Int32 offset, + Int32 index, + Int32 res) +{ + if (res == LO) + { + if (offset >= 0) + { + if (index < offset) + { + return(index); + } + else + { + return((index << 1) - offset); + } + } + else + { + offset = -offset; + if (index < offset) + { + return((index << 1) + index); + } + else + { + return((index << 1) + offset); + } + } + } + else + { + return(index); + } +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.h new file mode 100644 index 00000000..a415e0e1 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_envelope.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_envelope.h + Funtions: + decodeEnvelope + +------------------------------------------------------------------------------ + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DECODE_ENVELOPE_H +#define SBR_DECODE_ENVELOPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.c new file mode 100644 index 00000000..41d5355d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.c @@ -0,0 +1,144 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_huff_cw.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + SbrHuffman h, pointer to huffman codebook table + BIT_BUFFER * hBitBuf pointer to Bitbuffer + + return decoded value +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Decodes one huffman code word + + Reads bits from the bitstream until a valid codeword is found. + The table entries are interpreted either as index to the next entry + or - if negative - as the codeword. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_decode_huff_cw.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int32 sbr_decode_huff_cw(SbrHuffman h, + BIT_BUFFER * hBitBuf) +{ + Int32 bits; + Char index = 0; + + while (index >= 0) + { + bits = buf_get_1bit(hBitBuf); + index = h[index][bits]; + } + + return((Int32)index + 64); /* Add offset */ +} + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.h new file mode 100644 index 00000000..c039cb7f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_decode_huff_cw.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_decode_huff_cw.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DECODE_HUFF_CW_H +#define SBR_DECODE_HUFF_CW_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_huffman.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int32 sbr_decode_huff_cw(SbrHuffman h, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.c new file mode 100644 index 00000000..37c09438 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.c @@ -0,0 +1,157 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_downsample_lo_res.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_downsample_lo_res.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_downsample_lo_res(Int32 v_result[], + Int32 num_result, + Int freqBandTableRef[], + Int32 num_Ref) +{ + Int32 step; + Int32 i, j; + Int32 org_length; + Int32 result_length; + Int32 v_index[MAX_FREQ_COEFFS/2]; + + /* init */ + org_length = num_Ref; + result_length = num_result; + + v_index[0] = 0; /* Always use left border */ + i = 0; + while (org_length > 0) /* Create downsample vector */ + { + i++; + step = org_length / result_length; /* floor; */ + org_length = org_length - step; + result_length--; + v_index[i] = v_index[i-1] + step; + } + + for (j = 0; j <= i; j++) /* Use downsample vector to index LoResolution vector. */ + { + v_result[j] = freqBandTableRef[ v_index[j]]; + } + +} /* End downSampleLoRes */ + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.h new file mode 100644 index 00000000..69f06041 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_downsample_lo_res.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_downsample_lo_res.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_DOWNSAMPLE_LO_RES_H +#define SBR_DOWNSAMPLE_LO_RES_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_downsample_lo_res(Int32 v_result[], + Int32 num_result, + Int freqBandTableRef[], + Int32 num_Ref); + +#ifdef __cplusplus +} +#endif + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.c new file mode 100644 index 00000000..85e32dad --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.c @@ -0,0 +1,418 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_calc_tbl.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_envelope_calc_tbl.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +#define Q30_fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F)) +#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F)) + + +const Int32 limGains[5] = { Q30_fmt(0.70795f), Q30_fmt(1.0f), + Q30_fmt(1.41254f), Q30_fmt(1.16415321826935f), 33 + }; + +const Int32 smoothLengths[2] = { 4, 0 }; + +const Int16 rP_LCx[512] = +{ + Qfmt15(-0.99948153278296f), Qfmt15(0.97113454393991f), Qfmt15(0.14130051758487f), Qfmt15(-0.47005496701697f), + Qfmt15(0.80705063769351f), Qfmt15(-0.38981478896926f), Qfmt15(-0.01053049862020f), Qfmt15(-0.91266367957293f), + Qfmt15(0.54840422910309f), Qfmt15(0.40009252867955f), Qfmt15(-0.99867974711855f), Qfmt15(-0.95531076805040f), + Qfmt15(-0.45725933317144f), Qfmt15(-0.72929675029275f), Qfmt15(0.75622801399036f), Qfmt15(0.07069442601050f), + Qfmt15(0.74496252926055f), Qfmt15(-0.96440182703856f), Qfmt15(0.30424629369539f), Qfmt15(0.66565033746925f), + Qfmt15(0.91697008020594f), Qfmt15(-0.70774918760427f), Qfmt15(-0.70051415345560f), Qfmt15(-0.99496513054797f), + Qfmt15(0.98164490790123f), Qfmt15(-0.54671580548181f), Qfmt15(-0.01689629065389f), Qfmt15(-0.86110349531986f), + Qfmt15(-0.98892980586032f), Qfmt15(0.51756627678691f), Qfmt15(-0.99635026409640f), Qfmt15(-0.99969370862163f), + Qfmt15(0.55266258627194f), Qfmt15(0.34581177741673f), Qfmt15(0.62664209577999f), Qfmt15(-0.77149701404973f), + Qfmt15(-0.91592244254432f), Qfmt15(-0.76285492357887f), Qfmt15(0.79788337195331f), Qfmt15(0.54473080610200f), + Qfmt15(-0.85639281671058f), Qfmt15(-0.92882402971423f), Qfmt15(-0.11708371046774f), Qfmt15(0.21356749817493f), + Qfmt15(-0.76191692573909f), Qfmt15(0.98111043100884f), Qfmt15(-0.85913269895572f), Qfmt15(-0.93307242253692f), + Qfmt15(0.30485754879632f), Qfmt15(0.85289650925190f), Qfmt15(0.91328082618125f), Qfmt15(-0.05890199924154f), + Qfmt15(0.28398686150148f), Qfmt15(0.95258164539612f), Qfmt15(-0.78566324168507f), Qfmt15(-0.95789495447877f), + Qfmt15(0.82411158711197f), Qfmt15(-0.65185446735885f), Qfmt15(-0.93643603134666f), Qfmt15(0.91427159529618f), + Qfmt15(-0.70395684036886f), Qfmt15(0.00563771969365f), Qfmt15(0.89065051931895f), Qfmt15(-0.68683707712762f), + Qfmt15(0.72165342518718f), Qfmt15(-0.62928247730667f), Qfmt15(0.29938434065514f), Qfmt15(-0.91781958879280f), + Qfmt15(0.99298717043688f), Qfmt15(0.82368298622748f), Qfmt15(-0.98512833386833f), Qfmt15(-0.95915368242257f), + Qfmt15(-0.21411126572790f), Qfmt15(-0.68821476106884f), Qfmt15(0.91851997982317f), Qfmt15(-0.96062769559127f), + Qfmt15(0.51646184922287f), Qfmt15(0.61130721139669f), Qfmt15(0.47336129371299f), Qfmt15(0.90998308703519f), + Qfmt15(0.44844799194357f), Qfmt15(0.66614891079092f), Qfmt15(0.74922239129237f), Qfmt15(-0.99571588506485f), + Qfmt15(0.97401082477563f), Qfmt15(0.72683747733879f), Qfmt15(0.95432193457128f), Qfmt15(-0.72962208425191f), + Qfmt15(-0.85359479233537f), Qfmt15(-0.81412430338535f), Qfmt15(-0.87930772356786f), Qfmt15(-0.71573331064977f), + Qfmt15(0.83524300028228f), Qfmt15(-0.48086065601423f), Qfmt15(0.97139128574778f), Qfmt15(0.51992825347895f), + Qfmt15(-0.00848591195325f), Qfmt15(-0.70294374303036f), Qfmt15(-0.95894428168140f), Qfmt15(0.97079252950321f), + Qfmt15(-0.92404293670797f), Qfmt15(-0.69506469500450f), Qfmt15(0.26559203620024f), Qfmt15(0.28038443336943f), + Qfmt15(-0.74138124825523f), Qfmt15(-0.01752795995444f), Qfmt15(-0.55126773094930f), Qfmt15(0.97960898850996f), + Qfmt15(-0.99196309146936f), Qfmt15(-0.67684928085260f), Qfmt15(0.09140039465500f), Qfmt15(-0.71658965751996f), + Qfmt15(0.81014640078925f), Qfmt15(0.40616991671205f), Qfmt15(-0.67680188682972f), Qfmt15(0.86849774348749f), + Qfmt15(-0.99500381284851f), Qfmt15(0.84329189340667f), Qfmt15(-0.09215968531446f), Qfmt15(0.99956173327206f), + Qfmt15(-0.79732779473535f), Qfmt15(0.96349973642406f), Qfmt15(-0.79942778496547f), Qfmt15(-0.11566039853896f), + Qfmt15(-0.39922954514662f), Qfmt15(0.99089197565987f), Qfmt15(0.28631285179909f), Qfmt15(-0.83302725605608f), + Qfmt15(0.95404443402072f), Qfmt15(-0.06449863579434f), Qfmt15(-0.99575054486311f), Qfmt15(-0.65501142790847f), + Qfmt15(-0.81254441908887f), Qfmt15(-0.99646369485481f), Qfmt15(0.00287840603348f), Qfmt15(0.70176989408455f), + Qfmt15(0.96361882270190f), Qfmt15(-0.68883758192426f), Qfmt15(-0.34875585502238f), Qfmt15(0.91980081243087f), + Qfmt15(-0.99009048343881f), Qfmt15(0.68865791458395f), Qfmt15(-0.99484402129368f), Qfmt15(0.94214511408023f), + Qfmt15(-0.67414626793544f), Qfmt15(-0.47339353684664f), Qfmt15(0.14323651387360f), Qfmt15(-0.29268293575672f), + Qfmt15(0.43793861458754f), Qfmt15(-0.36345126374441f), Qfmt15(-0.08750604656825f), Qfmt15(-0.96495267812511f), + Qfmt15(0.55526940659947f), Qfmt15(0.73538215752630f), Qfmt15(-0.30889773919437f), Qfmt15(0.03574995626194f), + Qfmt15(0.98720684660488f), Qfmt15(-0.81689296271203f), Qfmt15(0.67866860118215f), Qfmt15(-0.15808569732583f), + Qfmt15(0.80723395114371f), Qfmt15(0.47788757329038f), Qfmt15(0.96367554763201f), Qfmt15(-0.99143875716818f), + Qfmt15(0.83081876925833f), Qfmt15(-0.58753191905341f), Qfmt15(0.95538108220960f), Qfmt15(-0.96490920476211f), + Qfmt15(-0.97327101028521f), Qfmt15(0.91400366022124f), Qfmt15(-0.99925837363824f), Qfmt15(-0.86875903507313f), + Qfmt15(-0.26240034795124f), Qfmt15(-0.24664412953388f), Qfmt15(0.02416275806869f), Qfmt15(0.82068619590515f), + Qfmt15(0.88547373760759f), Qfmt15(-0.18173078152226f), Qfmt15(0.09355476558534f), Qfmt15(-0.54668414224090f), + Qfmt15(0.37050990604091f), Qfmt15(-0.70373594262891f), Qfmt15(-0.34600785879594f), Qfmt15(-0.68774481731008f), + Qfmt15(-0.26843291251234f), Qfmt15(0.49072334613242f), Qfmt15(0.38975993093975f), Qfmt15(-0.97757125224150f), + Qfmt15(-0.17325552859616f), Qfmt15(0.99948035025744f), Qfmt15(-0.64946246527458f), Qfmt15(-0.12016920576437f), + Qfmt15(-0.58947456517751f), Qfmt15(-0.41815140454465f), Qfmt15(0.99885650204884f), Qfmt15(-0.56649614128386f), + Qfmt15(0.94138021032330f), Qfmt15(-0.75725076534641f), Qfmt15(0.20541973692630f), Qfmt15(0.99980371023351f), + Qfmt15(0.29078277605775f), Qfmt15(-0.62858772103030f), Qfmt15(0.43440904467688f), Qfmt15(-0.98298583762390f), + Qfmt15(0.19513029146934f), Qfmt15(-0.95476662400101f), Qfmt15(0.93379635304810f), Qfmt15(-0.85235410573336f), + Qfmt15(-0.86425093011245f), Qfmt15(0.38879779059045f), Qfmt15(0.92045124735495f), Qfmt15(0.89162532251878f), + Qfmt15(-0.36834336949252f), Qfmt15(0.93891760988045f), Qfmt15(0.99267657565094f), Qfmt15(-0.94063471614176f), + Qfmt15(0.99740224117019f), Qfmt15(-0.35899413170555f), Qfmt15(0.05237237274947f), Qfmt15(0.36703583957424f), + Qfmt15(0.91653180367913f), Qfmt15(0.69000803499316f), Qfmt15(-0.38658751133527f), Qfmt15(-0.29250814029851f), + Qfmt15(-0.60182204677608f), Qfmt15(-0.97418588163217f), Qfmt15(0.88461574003963f), Qfmt15(0.05198933055162f), + Qfmt15(-0.53499621979720f), Qfmt15(-0.49429560226497f), Qfmt15(-0.98935142339139f), Qfmt15(-0.98081380091130f), + Qfmt15(-0.27338148835532f), Qfmt15(0.06310802338302f), Qfmt15(-0.20461677199539f), Qfmt15(0.66223843141647f), + Qfmt15(-0.84764345483665f), Qfmt15(-0.89039863483811f), Qfmt15(0.95903308477986f), Qfmt15(0.73504123909879f), + Qfmt15(-0.31744434966056f), Qfmt15(-0.34110827591623f), Qfmt15(0.47803883714199f), Qfmt15(0.98299195879514f), + Qfmt15(-0.30963073129751f), Qfmt15(0.99992588229018f), Qfmt15(-0.93149731080767f), Qfmt15(0.99923472302773f), + Qfmt15(-0.26024169633417f), Qfmt15(-0.35712514743563f), Qfmt15(-0.99899084509530f), Qfmt15(0.86557171579452f), + Qfmt15(0.33408042438752f), Qfmt15(0.99010736374716f), Qfmt15(-0.66694269691195f), Qfmt15(0.64016792079480f), + Qfmt15(0.99570534804836f), Qfmt15(-0.63431466947340f), Qfmt15(-0.07706847005931f), Qfmt15(0.98590090577724f), + Qfmt15(0.80099335254678f), Qfmt15(0.78368131392666f), Qfmt15(0.08707806671691f), Qfmt15(-0.86811883080712f), + Qfmt15(-0.39466529740375f), Qfmt15(0.97875325649683f), Qfmt15(-0.95038560288864f), Qfmt15(0.17005239424212f), + Qfmt15(-0.76910792026848f), Qfmt15(0.99743281016846f), Qfmt15(0.95437383549973f), Qfmt15(0.99578905365569f), + Qfmt15(0.28058259829990f), Qfmt15(0.85256524470573f), Qfmt15(-0.50608540105128f), Qfmt15(-0.97210735183243f), + Qfmt15(0.95424048234441f), Qfmt15(-0.96926570524023f), Qfmt15(0.30872163214726f), Qfmt15(-0.24523839572639f), + Qfmt15(-0.33813265086024f), Qfmt15(-0.05826828420146f), Qfmt15(-0.22898461455054f), Qfmt15(-0.18509915019881f), + Qfmt15(-0.10488238045009f), Qfmt15(-0.71886586182037f), Qfmt15(0.99793873738654f), Qfmt15(0.57563307626120f), + Qfmt15(0.28909646383717f), Qfmt15(0.42188998312520f), Qfmt15(0.93335049681047f), Qfmt15(-0.97087374418267f), + Qfmt15(0.36722871286923f), Qfmt15(-0.81093025665696f), Qfmt15(-0.26240603062237f), Qfmt15(0.83996497984604f), + Qfmt15(-0.99909615720225f), Qfmt15(0.74649464155061f), Qfmt15(-0.74774595569805f), Qfmt15(0.95781667469567f), + Qfmt15(0.95472308713099f), Qfmt15(0.48708332746299f), Qfmt15(0.46332038247497f), Qfmt15(-0.76497004940162f), + Qfmt15(0.57397389364339f), Qfmt15(0.75374316974495f), Qfmt15(-0.59174397685714f), Qfmt15(0.75087906691890f), + Qfmt15(-0.98607857336230f), Qfmt15(-0.40761056640505f), Qfmt15(0.66929266740477f), Qfmt15(-0.97463695257310f), + Qfmt15(0.90145509409859f), Qfmt15(-0.87259289048043f), Qfmt15(-0.91529461447692f), Qfmt15(-0.03305738840705f), + Qfmt15(0.07223051368337f), Qfmt15(0.99498012188353f), Qfmt15(-0.74904939500519f), Qfmt15(0.04585228574211f), + Qfmt15(-0.89054954257993f), Qfmt15(-0.83782144651251f), Qfmt15(0.33454804933804f), Qfmt15(-0.99707579362824f), + Qfmt15(-0.22827527843994f), Qfmt15(0.67248046289143f), Qfmt15(-0.05146538187944f), Qfmt15(0.99947295749905f), + Qfmt15(0.66951124390363f), Qfmt15(-0.99602956559179f), Qfmt15(0.82104905483590f), Qfmt15(0.99186510988782f), + Qfmt15(-0.65284592392918f), Qfmt15(0.93885443798188f), Qfmt15(0.96735248738388f), Qfmt15(-0.22225968841114f), + Qfmt15(-0.44132783753414f), Qfmt15(-0.85694974219574f), Qfmt15(0.91783042091762f), Qfmt15(0.72556974415690f), + Qfmt15(-0.99711581834508f), Qfmt15(0.77638976371966f), Qfmt15(0.07717324253925f), Qfmt15(-0.56049829194163f), + Qfmt15(0.98398893639988f), Qfmt15(0.47546946844938f), Qfmt15(0.65675089314631f), Qfmt15(0.03273375457980f), + Qfmt15(-0.38684144784738f), Qfmt15(-0.97346267944545f), Qfmt15(-0.53282156061942f), Qfmt15(0.99817310731176f), + Qfmt15(-0.50254500772635f), Qfmt15(0.01995873238855f), Qfmt15(0.99930381973804f), Qfmt15(0.82907767600783f), + Qfmt15(-0.58660709669728f), Qfmt15(-0.17573736667267f), Qfmt15(0.83434292401346f), Qfmt15(0.05946491307025f), + Qfmt15(0.81505484574602f), Qfmt15(-0.44976380954860f), Qfmt15(-0.89746474625671f), Qfmt15(0.39677256130792f), + Qfmt15(-0.07588948563079f), Qfmt15(0.76343198951445f), Qfmt15(-0.74490104699626f), Qfmt15(0.64880119792759f), + Qfmt15(0.62319537462542f), Qfmt15(0.42215817594807f), Qfmt15(0.02704554141885f), Qfmt15(0.80001773566818f), + Qfmt15(-0.79351832348816f), Qfmt15(0.63872359151636f), Qfmt15(0.52890520960295f), Qfmt15(0.74238552914587f), + Qfmt15(0.99096131449250f), Qfmt15(-0.80412329643109f), Qfmt15(-0.64612616129736f), Qfmt15(0.11657770663191f), + Qfmt15(-0.95053182488101f), Qfmt15(-0.62228872928622f), Qfmt15(0.03004475787316f), Qfmt15(-0.97987214341034f), + Qfmt15(-0.99986980746200f), Qfmt15(0.89110648599879f), Qfmt15(0.10407960510582f), Qfmt15(0.95964737821728f), + Qfmt15(0.50843233159162f), Qfmt15(0.17006334670615f), Qfmt15(0.25872675063360f), Qfmt15(-0.01115998681937f), + Qfmt15(-0.79598702973261f), Qfmt15(-0.99264708948101f), Qfmt15(-0.99829663752818f), Qfmt15(-0.70801016548184f), + Qfmt15(-0.70467057786826f), Qfmt15(0.99846021905254f), Qfmt15(-0.63364968534650f), Qfmt15(-0.16258217500792f), + Qfmt15(-0.43645594360633f), Qfmt15(-0.99848471702976f), Qfmt15(-0.16796458968998f), Qfmt15(-0.87979225745213f), + Qfmt15(0.44183099021786f), Qfmt15(0.93310180125532f), Qfmt15(-0.93941931782002f), Qfmt15(-0.88590003188677f), + Qfmt15(0.99971463703691f), Qfmt15(-0.75376385639978f), Qfmt15(0.93887685615875f), Qfmt15(0.85126435782309f), + Qfmt15(0.39701421446381f), Qfmt15(-0.37024464187437f), Qfmt15(-0.36024828242896f), Qfmt15(-0.93388812549209f), + Qfmt15(-0.65298804552119f), Qfmt15(0.11960319006843f), Qfmt15(0.94292565553160f), Qfmt15(0.75081145286948f), + Qfmt15(0.56721979748394f), Qfmt15(0.46857766746029f), Qfmt15(0.97312313923635f), Qfmt15(-0.38299976567017f), + Qfmt15(0.41025800019463f), Qfmt15(0.09638062008048f), Qfmt15(-0.85283249275397f), Qfmt15(0.88866808958124f), + Qfmt15(-0.48202429536989f), Qfmt15(0.27572582416567f), Qfmt15(-0.65889129659168f), Qfmt15(0.98838086953732f), + Qfmt15(-0.20651349620689f), Qfmt15(-0.62126416356920f), Qfmt15(0.20320105410437f), Qfmt15(-0.97790548600584f), + Qfmt15(0.11112534735126f), Qfmt15(-0.41368337314182f), Qfmt15(0.24133038992960f), Qfmt15(-0.66393410674885f), + Qfmt15(-0.53697829178752f), Qfmt15(-0.97224737889348f), Qfmt15(0.87392477144549f), Qfmt15(0.19050361015753f), + Qfmt15(-0.46353441212724f), Qfmt15(-0.07064096339021f), Qfmt15(-0.92444085484466f), Qfmt15(-0.83822593578728f), + Qfmt15(0.75214681811150f), Qfmt15(-0.42102998829339f), Qfmt15(-0.72094786237696f), Qfmt15(0.78843311019251f), + Qfmt15(0.97394027897442f), Qfmt15(0.99206463477946f), Qfmt15(0.76789609461795f), Qfmt15(-0.82002421836409f), + Qfmt15(0.81924990025724f), Qfmt15(-0.26719850873357f), Qfmt15(-0.43311260380975f), Qfmt15(0.99194979673836f), + Qfmt15(-0.80692001248487f), Qfmt15(0.43080003649976f), Qfmt15(0.67709491937357f), Qfmt15(0.56151770568316f), + Qfmt15(0.10831862810749f), Qfmt15(0.91229417540436f), Qfmt15(-0.48972893932274f), Qfmt15(-0.89033658689697f), + Qfmt15(0.65269447475094f), Qfmt15(0.67439478141121f), Qfmt15(-0.47770832416973f), Qfmt15(-0.99715979260878f), + Qfmt15(-0.90889593602546f), Qfmt15(-0.06618622548177f), Qfmt15(0.99430266919728f), Qfmt15(0.97686402381843f), + Qfmt15(0.94813650221268f), Qfmt15(-0.95434497492853f), Qfmt15(-0.49104783137150f), Qfmt15(0.99881175120751f), + Qfmt15(0.50449166760303f), Qfmt15(0.47162891065108f), Qfmt15(-0.62081581361840f), Qfmt15(-0.43867015250812f), + Qfmt15(0.98630563232075f), Qfmt15(-0.61510362277374f), Qfmt15(-0.03841517601843f), Qfmt15(-0.30102157304644f), + Qfmt15(0.41881284182683f), Qfmt15(-0.86135454941237f), Qfmt15(0.67226861393788f), Qfmt15(-0.70737398842068f), + Qfmt15(0.94044946687963f), Qfmt15(-0.82386352534327f), Qfmt15(-0.32070666698656f), Qfmt15(0.57593163224487f), + Qfmt15(-0.36326018419965f), Qfmt15(0.99979044674350f), Qfmt15(-0.92366023326932f), Qfmt15(-0.44607178518598f), + Qfmt15(0.44226800932956f), Qfmt15(0.03671907158312f), Qfmt15(0.52175424682195f), Qfmt15(-0.94701139690956f), + Qfmt15(-0.98759606946049f), Qfmt15(0.87434794743625f), Qfmt15(-0.93412041758744f), Qfmt15(0.96063943315511f), + Qfmt15(0.97534253457837f), Qfmt15(0.99642466504163f), Qfmt15(-0.94705089665984f), Qfmt15(0.91599807087376f) +}; + + +#ifdef HQ_SBR + + +const Int32 fir_table[5][5] = +{ + { Q30_fmt(1.0f)}, + { Q30_fmt(0.33333333333333f), Q30_fmt(0.66666666666666f)}, + { Q30_fmt(0.12500000000000f), Q30_fmt(0.37500000000000f), + Q30_fmt(0.50000000000000f)}, + { Q30_fmt(0.05857864376269f), Q30_fmt(0.20000000000000f), + Q30_fmt(0.34142135623731f), Q30_fmt(0.40000000000000f)}, + { Q30_fmt(0.03183050093751f), Q30_fmt(0.11516383427084f), + Q30_fmt(0.21816949906249f), Q30_fmt(0.30150283239582f), + Q30_fmt(0.33333333333333f)} +}; + + + +const Int32 rPxx[512] = +{ + + 0x8010B3DB, 0x7C4DA98F, 0x12168648, 0xC3D4D033, + 0x674D25F5, 0xCE1972A6, 0xFEA5AA4A, 0x8B2DF13E, + 0x46326048, 0x3336815E, 0x802A8F2B, 0x85B7745C, + 0xC577B766, 0xA2A5828C, 0x60CB1AD1, 0x090C9BD7, + 0x5F5A8B4D, 0x848D86BB, 0x26F1C0B7, 0x553352C1, + 0x755E166B, 0xA5674343, 0xA654C5F5, 0x80A48CB4, + 0x7DA69CD8, 0xBA04FCB4, 0xFDD4005E, 0x91C63676, + 0x816A8F82, 0x423F55AA, 0x8077B59E, 0x80097DE9, + 0x46BD4C18, 0x2C437971, 0x5035A0C2, 0x9D3ED49F, + 0x8AC204B8, 0x9E5A8B0A, 0x662088B9, 0x45B9F0BC, + 0x9261364F, 0x891B23AD, 0xF1028040, 0x1B568BE1, + 0x9E787FB3, 0x7D94854D, 0x92077A94, 0x88903F45, + 0x2705A5B4, 0x6D2B3BDC, 0x74E58034, 0xF8745A8C, + 0x24592C54, 0x79EDB9BB, 0x9B6E9F44, 0x8563E5DA, + 0x697C7BB7, 0xAC8F8E6A, 0x88227FD5, 0x7506822F, + 0xA5E34B42, 0x00B94F10, 0x72004390, 0xA814676E, + 0x5C5EA758, 0xAF721171, 0x2652C50C, 0x8A84A142, + 0x7F19343E, 0x696EA13B, 0x81E68008, 0x853980F9, + 0xE4968869, 0xA7E7DD92, 0x75910BFA, 0x85092E35, + 0x421BA4A3, 0x4E3F3C18, 0x3C97DD02, 0x74797BCB, + 0x39667EFD, 0x55447BA2, 0x5FE68CF3, 0x808B4390, + 0x7CABEA6B, 0x5D08C27A, 0x7A265820, 0xA29A9DF0, + 0x92BC7195, 0x97CA8338, 0x8F725FAD, 0xA46281D3, + 0x6AE86B23, 0xC2728178, 0x7C566684, 0x428C66B7, + 0xFEE89DDB, 0xA60546DC, 0x8540C89D, 0x7C420BF0, + 0x89B86D72, 0xA7077E3F, 0x21FF5DD7, 0x23E3129C, + 0xA1197F1D, 0xFDC0963F, 0xB96F8168, 0x7D6387A6, + 0x810655C8, 0xA95C102B, 0x0BB3E5B4, 0xA44682D4, + 0x67B244C3, 0x33FDDE1D, 0xA95D78F5, 0x6F2AE887, + 0x80A3FC9F, 0x6BF00D52, 0xF4325902, 0x7FF1F02C, + 0x99F08AC5, 0x7B537BB2, 0x99AB5255, 0xF1302497, + 0xCCE4787B, 0x7ED58A28, 0x24A68B79, 0x955EA9D0, + 0x7A1D3EED, 0xF7BD0429, 0x808A3642, 0xAC2769A8, + 0x97FDBDE9, 0x80736C25, 0x005E52E7, 0x59D3E5D0, + 0x7B57341A, 0xA7D374E9, 0xD35A5B7B, 0x75BB5520, + 0x81446DE8, 0x5825473E, 0x80A8E653, 0x78978062, + 0xA9B43F6B, 0xC366920A, 0x1255877D, 0xDA88075F, + 0x380E9AFF, 0xD1795309, 0xF4CB7D09, 0x847BBAED, + 0x471364FA, 0x5E207B74, 0xD87498BF, 0x0493836B, + 0x7E5C3DF6, 0x976F8BBC, 0x56DE680A, 0xEBC26D28, + 0x6753E05B, 0x3D2BC4B0, 0x7B593143, 0x8118E010, + 0x6A5786AD, 0xB4CA01A7, 0x7A49927C, 0x847DAE0C, + 0x836B0FD8, 0x74FD4A34, 0x80175AFC, 0x90CBE605, + 0xDE68A89E, 0xE06C8FD0, 0x031822CE, 0x690B9315, + 0x71568D43, 0xE8BBDE85, 0x0BFA4633, 0xBA057ADA, + 0x2F6CB34F, 0xA5EB74C5, 0xD3B480B6, 0xA7F7D94A, + 0xDDA26A63, 0x3ED0C5EF, 0x31E37A42, 0x82DE06CB, + 0xE9D18940, 0x7FEE4A9A, 0xACDD57DD, 0xF09CB6D9, + 0xB48BD364, 0xCA7814D5, 0x7FDA0E41, 0xB77C8C2A, + 0x787E2D29, 0x9F1144AC, 0x1A4B871E, 0x7FF96630, + 0x25382D4D, 0xAF89319E, 0x379A81DB, 0x822D1AE8, + 0x18FA875E, 0x85C97DE7, 0x7786A544, 0x92E5F550, + 0x915FC560, 0x31C47C82, 0x75D0B014, 0x72204656, + 0xD0D87B76, 0x782E8CD6, 0x7F0FFB2F, 0x879834E7, + 0x7FAAEA73, 0xD20BC44E, 0x06B4DF2C, 0x2EFBCE84, + 0x7550D8D7, 0x5851746A, 0xCE837F5C, 0xDA8D2FEE, + 0xB2F66F13, 0x834D7B7A, 0x713A499C, 0x06A81B39, + 0xBB847C77, 0xC0B97DAC, 0x815CCC7A, 0x8274A2BD, + 0xDD007FEF, 0x0814BA2F, 0xE5CDEDCE, 0x54C45CD5, + 0x937F0309, 0x8E0671BF, 0x7AC1623B, 0x5E15FB32, + 0xD75CD0D9, 0xD4553378, 0x3D30CD88, 0x7DD2028C, + 0xD85CE8DB, 0x7FFDDE5A, 0x88C48228, 0x7FE6996A, + 0xDEAF9EB7, 0xD24818B4, 0x80205F8B, 0x6ECA4728, + 0x2AC36E51, 0x7EBB05E4, 0xAAA08AB1, 0x51F01408, + 0x7F723AAE, 0xAECD1AFB, 0xF6218D55, 0x7E3170F2, + 0x6686D0D3, 0x644F3A3F, 0x0B256799, 0x90E0325D, + 0xCD7AAA7B, 0x7D47A33C, 0x865972A3, 0x15C445FE, + 0x9D8D84D3, 0x7FAB36A7, 0x7A287C29, 0x7F75BABD, + 0x23EA92BC, 0x6D20AD59, 0xBF37ABB6, 0x8391E26E, + 0x7A2480F8, 0x83EE5E6E, 0x27843523, 0xE09A50E7, + 0xD4B6CE82, 0xF889F71C, 0xE2AF7C3A, 0xE84D3CE2, + 0xF2918FA6, 0xA3FB63E0, 0x7FBB7340, 0x49AE8B79, + 0x25017B45, 0x36003DA1, 0x7777C844, 0x83B96EE4, + 0x2F015392, 0x98320B3C, 0xDE68893F, 0x6B834779, + 0x801D8516, 0x5F8C0F8C, 0xA049DD90, 0x7A999AD0, + 0x7A33F500, 0x3E587FFF, 0x3B4E0E09, 0x9E147230, + 0x49772D2B, 0x607A7BC7, 0xB4408D8F, 0x601CDA17, + 0x81C7200B, 0xCBD28CBD, 0x55AB7E3E, 0x833EFFC0, + 0x73627FB7, 0x904E7F04, 0x8AD7EBE6, 0xFBC3D05F, + 0x093F8E53, 0x7F5B7C47, 0xA01E7FFA, 0x05DE7FC2, + 0x8E01D74D, 0x94C17CF9, 0x2AD2919F, 0x805F7757, + 0xE2C61829, 0x5613FB53, 0xF9688978, 0x7FEE77D6, + 0x55B27E98, 0x8081C6D6, 0x69177F69, 0x7EF45C30, + 0xAC6E42CC, 0x782BA021, 0x7BD17457, 0xE38B491E, + 0xC781895B, 0x924E71B8, 0x757BC4A8, 0x5CDF8020, + 0x805E4A82, 0x636078BA, 0x09E14B0E, 0xB84069A0, + 0x7DF23284, 0x3CDC57D2, 0x54101777, 0x0431A015, + 0xCE7A41B6, 0x8365846A, 0xBBCB8AF9, 0x7FC34E40, + 0xBFAB8E4B, 0x028E6D15, 0x7FE8790F, 0x6A1EF7E6, + 0xB4E97BF4, 0xE980C257, 0x6ACBEF53, 0x079C1A41, + 0x685386CC, 0xC66D3458, 0x8D1F7FCD, 0x32C9A02E, + 0xF6475ED7, 0x61B7356F, 0xA0A6793F, 0x530B34E9, + 0x4FC488D4, 0x3609F61F, 0x0376F90F, 0x6666752C, + 0x9A6DD1A5, 0x51C10A67, 0x43B34CDC, 0x5F0605C0, + 0x7ED7E718, 0x99118EB3, 0xAD4A5C69, 0x0EEC94E8, + 0x865483EA, 0xB05769F0, 0x03D88055, 0x82932EC1, + 0x8003D1E3, 0x720F82B1, 0x0D526304, 0x7AD5D2A3, + 0x41147B04, 0x15C49D9F, 0x211E7FDC, 0xFE907E12, + 0x9A1C7C55, 0x80F08095, 0x80370267, 0xA55F2B1C, + 0xA5CC7763, 0x7FCD81A1, 0xAEE3EAE8, 0xEB2F8532, + 0xC82186A5, 0x80317B31, 0xEA7E814B, 0x8F62A430, + 0x388D883A, 0x776F801B, 0x87C0B7CA, 0x8E9A3CF5, + 0x7FF6949E, 0x9F83010B, 0x782CF18C, 0x6CF54301, + 0x32D168AD, 0xD09A908B, 0xD1E22C5C, 0x887593DE, + 0xAC6AE864, 0x0F4F7FDE, 0x78B16A72, 0x601AD283, + 0x489AE12D, 0x3BFAD96A, 0x7C8E8093, 0xCEF87E19, + 0x348302B6, 0x0C5605A6, 0x92D57516, 0x71BF8056, + 0xC24C8416, 0x234B4B0D, 0xABA84B4F, 0x7E827FFD, + 0xE58F45E1, 0xB079B355, 0x1A0290CA, 0x82D37B40, + 0x0E391B80, 0xCB0B241E, 0x1EE441A8, 0xAB03F56F, + 0xBB438301, 0x838C1C43, 0x6FDCEF9D, 0x1862020D, + 0xC4A98614, 0xF6F38710, 0x89ABF29B, 0x94B4FDD3, + 0x6046800E, 0xCA1A7FA4, 0xA3B7D32F, 0x64EB43A6, + 0x7CA9DDD3, 0x7EFBB705, 0x624A9E0D, 0x9708A1E0, + 0x68DC7F9C, 0xDDCB5832, 0xC88E6D35, 0x7EF77599, + 0x98B6D63B, 0x3724E3F0, 0x56AA85C9, 0x47DFA582, + 0x0DDDF4F3, 0x74C5AB88, 0xC14F480C, 0x8E08A446, + 0x538B545F, 0x56529770, 0xC2D9EA81, 0x805C883B, + 0x8BA84F67, 0xF785E183, 0x7F441814, 0x7D09DB4D, + 0x795C8330, 0x85D79A19, 0xC1242A1B, 0x7FD871E9, + 0x409391EC, 0x3C5EE815, 0xB0885FFF, 0xC7D87FFE, + 0x7E3EBB6A, 0xB1438D6B, 0xFB13A68A, 0xD976F62D, + 0x359B02CD, 0x91BE7EA6, 0x560CEEB8, 0xA5739E04, + 0x78600B8E, 0x968A0B6C, 0xD6F1402E, 0x49B88152, + 0xD17F0986, 0x7FF8EDE8, 0x89C48295, 0xC6E6BA93, + 0x389C5B4C, 0x04B3516A, 0x42C892B0, 0x86C7FDA8, + 0x81956954, 0x6FEA726E, 0x886E34F5, 0x7AF57730, + 0x7CD76E45, 0x7F8A59D7, 0x86C6DA22, 0x753F825E +}; + + +#endif + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.h new file mode 100644 index 00000000..aacf2eed --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_calc_tbl.h @@ -0,0 +1,88 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_calc_tbl.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ENVELOPE_CALC_TBL_H +#define SBR_ENVELOPE_CALC_TBL_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +extern const Int32 limGains[5]; + +extern const Int32 smoothLengths[2]; + +extern const Int16 rP_LCx[512]; + +#ifdef HQ_SBR + + +extern const Int32 fir_table[5][5]; + +extern const Int32 rPxx[512]; + +#endif + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.c new file mode 100644 index 00000000..dedcf83d --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.c @@ -0,0 +1,421 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_unmapping.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_envelope_unmapping.h" +#include "sbr_constants.h" + +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +#define R_SHIFT 30 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +/* + * 1./(1+2.^-[0:10]) + */ +const Int32 one_over_one_plus_two_to_n[11] = +{ + Qfmt(0.50000000000000F), Qfmt(0.66666666666667F), Qfmt(0.80000000000000F), + Qfmt(0.88888888888889F), Qfmt(0.94117647058824F), Qfmt(0.96969696969697F), + Qfmt(0.98461538461538F), Qfmt(0.99224806201550F), Qfmt(0.99610894941634F), + Qfmt(0.99805068226121F), Qfmt(0.99902439024390F) +}; + +/* + * 1./(1+2.^[0.5:-1:-10.5]) + */ +const Int32 one_over_one_plus_sq_2_by_two_to_n[12] = +{ + Qfmt(0.41421356237310F), Qfmt(0.58578643762690F), Qfmt(0.73879612503626F), + Qfmt(0.84977889517767F), Qfmt(0.91878969685839F), Qfmt(0.95767628767521F), + Qfmt(0.97838063800882F), Qfmt(0.98907219289563F), Qfmt(0.99450607818892F), + Qfmt(0.99724547251514F), Qfmt(0.99862083678608F), Qfmt(0.99930994254211F) +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1, + SBR_FRAME_DATA * hFrameData2) + +{ + Int32 i; + Int32 tempLeft; + Int32 tempRight; + + Int32 tmp; + Int32 *iEnvelopeLeft_man = hFrameData1->iEnvelope_man; + Int32 *iEnvelopeLeft_exp = hFrameData1->iEnvelope_exp; + Int32 *noiseFloorLeft_man = hFrameData1->sbrNoiseFloorLevel_man; + Int32 *noiseFloorLeft_exp = hFrameData1->sbrNoiseFloorLevel_exp; + + Int32 *iEnvelopeRight_man = hFrameData2->iEnvelope_man; + Int32 *iEnvelopeRight_exp = hFrameData2->iEnvelope_exp; + Int32 *noiseFloorRight_man = hFrameData2->sbrNoiseFloorLevel_man; + Int32 *noiseFloorRight_exp = hFrameData2->sbrNoiseFloorLevel_exp; + + + if (hFrameData2->ampRes) + { + for (i = 0; i < hFrameData1->nScaleFactors; i++) + { + tempRight = iEnvelopeRight_man[i]; + tempLeft = iEnvelopeLeft_man[i]; + /* iEnvelope[i] always positive 6 bits max */ + + iEnvelopeLeft_exp[i] = tempLeft + 7; + + iEnvelopeRight_exp[i] = tempRight - 12; + iEnvelopeRight_man[i] = Qfmt(1.000F); + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m); + * where k = 1 or sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 11) + { + iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + } + else + { + if (iEnvelopeRight_exp[i] > -11) + { + iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]]; + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i]; + iEnvelopeLeft_exp[i] = 0; + } + } + + iEnvelopeLeft_man[i] = iEnvelopeRight_man[i]; + } + } + else + { + for (i = 0; i < hFrameData1->nScaleFactors; i++) + { + /* iEnvelope[i] always positive 7 bits max */ + tempRight = iEnvelopeRight_man[i]; + tempLeft = iEnvelopeLeft_man[i]; + + iEnvelopeLeft_exp[i] = (tempLeft >> 1) + 7; + if (tempLeft & 0x1) /* odd */ + { + iEnvelopeLeft_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelopeLeft_man[i] = Qfmt(1.000F); + } + + iEnvelopeRight_exp[i] = (tempRight >> 1) - 12; + if (tempRight & 0x1) /* odd */ + { + if (iEnvelopeRight_exp[i] > 0) + { + iEnvelopeRight_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelopeRight_man[i] = Qfmt(0.7071067811865F); + } + } + else + { + iEnvelopeRight_man[i] = Qfmt(1.000F); + } + + if (iEnvelopeRight_man[i] == Qfmt(1.000F)) + { + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m); + * where k = 1 or sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 11) + { + iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + } + else + { + if (iEnvelopeRight_exp[i] > -11) + { + iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]]; + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i]; + iEnvelopeLeft_exp[i] = 0; + } + } + + /* + * apply "k" factor 1 or sqrt(2) + * + * (2^m)*2*k*2^n/(1+2^m) = k*2^(n+1)/(1 + 2^-m); + * + */ + if (iEnvelopeLeft_man[i] != Qfmt(1.000F)) + { + iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]); + } + + iEnvelopeLeft_man[i] = iEnvelopeRight_man[i]; + + } + else + { + + /* + * iEnvelopeRight[i] = tempLeft / (1 + tempRight); + * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i]; + * + * + * iEnvelopeRight[i] = k*2^n/(1+q2^m) = k*2^(n-m)/(1 + q2^-m); + * where k = 1 or sqrt(2) + * and q = sqrt(2) + */ + if (iEnvelopeRight_exp[i] >= 0) + { + if (iEnvelopeRight_exp[i] < 12) + { + iEnvelopeRight_man[i] = one_over_one_plus_sq_2_by_two_to_n[ iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 11 */ + { + iEnvelopeRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> iEnvelopeRight_exp[i]); + } + } + else + { + if (iEnvelopeRight_exp[i] > -12) + { + iEnvelopeRight_man[i] = Qfmt(1.000F) - one_over_one_plus_sq_2_by_two_to_n[ -iEnvelopeRight_exp[i]]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 11 */ + { + iEnvelopeRight_man[i] = Qfmt(1.000F); + iEnvelopeRight_exp[i] = 0; + } + } + + iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i]; + + /* + * apply "k" factor 1 or sqrt(2) + * + * Right == k*2^(n-m)/(1 + q2^-m) + * Left == (q2^m)*k*2^n/(1 + q2^m) = qk*2^n/(1 + q2^-m); + */ + if (iEnvelopeLeft_man[i] != Qfmt(1.000F)) + { + /* + * k/(1 + q2^-m); + */ + tmp = iEnvelopeRight_man[i]; + iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]); + iEnvelopeLeft_man[i] = tmp; + iEnvelopeLeft_exp[i] += 1; /* extra one due to sqrt(2)^2 */ + } + else + { + iEnvelopeLeft_man[i] = fxp_mul32_Q30(iEnvelopeRight_man[i], Qfmt(1.41421356237310F)); + } + + } /* end of if (iEnvelopeRight_man[i] == Qfmt( 1.000F) ) */ + } /* end of for loop */ + } /* end if (hFrameData2->ampRes) */ + + + for (i = 0; i < hFrameData1->nNoiseFactors; i++) + { + + noiseFloorLeft_exp[i] = NOISE_FLOOR_OFFSET_PLUS_1 - noiseFloorLeft_man[i]; + noiseFloorRight_exp[i] = noiseFloorRight_man[i] - SBR_ENERGY_PAN_OFFSET_INT; + + + /* + * noiseFloorRight[i] = tempLeft / (1.0f + tempRight); + * noiseFloorLeft[i] = tempRight*noiseFloorRight[i]; + * + * + * noiseFloorRight[i] = 2^n/(1+2^m) = 2^(n-m)/(1 + 2^-m); + */ + if (noiseFloorRight_exp[i] >= 0) + { + if (noiseFloorRight_exp[i] < 11) + { + noiseFloorRight_man[i] = one_over_one_plus_two_to_n[ noiseFloorRight_exp[i]]; + } + else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */ + { + noiseFloorRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> noiseFloorRight_exp[i]); + } + } + else + { + if (noiseFloorRight_exp[i] > -11) + { + noiseFloorRight_man[i] = Qfmt(1.000F) - one_over_one_plus_two_to_n[ -noiseFloorRight_exp[i]]; + } + else /* 1/(1+2^m) == 2^-m ; for m >= 10 */ + { + noiseFloorRight_man[i] = Qfmt(1.000F); + noiseFloorRight_exp[i] = 0; + } + } + + noiseFloorRight_exp[i] = noiseFloorLeft_exp[i] - noiseFloorRight_exp[i]; + + /* + * (2^m)*2^n/(1+2^m) = 2^n/(1 + 2^-m); + */ + + noiseFloorLeft_man[i] = noiseFloorRight_man[i]; + noiseFloorLeft_exp[i] = noiseFloorLeft_exp[i]; + + } +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.h new file mode 100644 index 00000000..4ae8e2ed --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_envelope_unmapping.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_envelope_unmapping.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_ENVELOPE_UNMAPPING_H +#define SBR_ENVELOPE_UNMAPPING_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +#define UNMAPPING_SCALE_INT (-18) /* factor's 2-exponent */ +#define SBR_ENERGY_PAN_OFFSET_INT 12 + + + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1, + SBR_FRAME_DATA * hFrameData2); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.c new file mode 100644 index 00000000..9e4d61be --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.c @@ -0,0 +1,217 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_extract_extended_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + SBR_FRAME_DATA *hFrameData, Destination for extracted data of left channel + SBR_FRAME_DATA *hFrameDataRight Destination for extracted data of right channel + BIT_BUFFER hBitBuf pointer to bit buffer + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads extension data from the bitstream + + The bitstream format allows up to 4 kinds of extended data element. + Extended data may contain several elements, each identified by a 2-bit-ID. + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_extract_extended_data.h" +#include "buf_getbits.h" + +#ifdef PARAMETRICSTEREO +#include "ps_read_data.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_extract_extended_data(BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */ + , HANDLE_PS_DEC hParametricStereoDec +#endif + ) +{ + Int32 extended_data; + Int32 i; + Int32 nBitsLeft; + Int32 extension_id; + + extended_data = buf_get_1bit(hBitBuf); /* SI_SBR_EXTENDED_DATA_BITS */ + + if (extended_data) + { + Int32 cnt; + + cnt = buf_getbits(hBitBuf, SI_SBR_EXTENSION_SIZE_BITS); + if (cnt == (1 << SI_SBR_EXTENSION_SIZE_BITS) - 1) + { + cnt += buf_getbits(hBitBuf, SI_SBR_EXTENSION_ESC_COUNT_BITS); + } + + nBitsLeft = (cnt << 3); + while (nBitsLeft > 7) + { + extension_id = buf_getbits(hBitBuf, SI_SBR_EXTENSION_ID_BITS); + nBitsLeft -= SI_SBR_EXTENSION_ID_BITS; + + switch (extension_id) + { +#ifdef HQ_SBR +#ifdef PARAMETRICSTEREO + + /* + * Parametric Coding supports the Transient, Sinusoidal, Noise, and + * Parametric Stereo tools (MPEG4). + * 3GPP use aac+ hq along with ps for enhanced aac+ + * The PS tool uses complex-value QMF data, therefore can not be used + * with low power version of aac+ + */ + case EXTENSION_ID_PS_CODING: + + if (hParametricStereoDec != NULL) + { + if (!hParametricStereoDec->psDetected) + { + /* parametric stereo detected */ + hParametricStereoDec->psDetected = 1; + } + + nBitsLeft -= ps_read_data(hParametricStereoDec, + hBitBuf, + nBitsLeft); + + } + + break; +#endif +#endif + case 0: + + default: + /* An unknown extension id causes the remaining extension data + * to be skipped + */ + cnt = nBitsLeft >> 3; /* number of remaining bytes */ + + for (i = 0; i < cnt; i++) + { + buf_getbits(hBitBuf, 8); + } + + nBitsLeft -= (cnt << 3); + } + } + /* read fill bits for byte alignment */ + buf_getbits(hBitBuf, nBitsLeft); + } +} + + +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.h new file mode 100644 index 00000000..e27d1fc7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_extract_extended_data.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_extract_extended_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_EXTRACT_EXTENDED_DATA_H +#define SBR_EXTRACT_EXTENDED_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "config.h" +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_extract_extended_data(BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */ + , HANDLE_PS_DEC hParametricStereoDec +#endif + ); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.c new file mode 100644 index 00000000..de7039b0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.c @@ -0,0 +1,192 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_find_start_andstop_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_find_start_andstop_band.h" +#include "get_sbr_startfreq.h" +#include "get_sbr_stopfreq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq, + const Int32 startFreq, + const Int32 stopFreq, + Int *lsbM, + Int *usb) +{ + /* Update startFreq struct */ + *lsbM = get_sbr_startfreq(samplingFreq, startFreq); + + if (*lsbM == 0) + { + return(SBRDEC_ILLEGAL_SCFACTORS); + } + + /*Update stopFreq struct */ + if (stopFreq < 13) + { + *usb = get_sbr_stopfreq(samplingFreq, stopFreq); + } + else if (stopFreq == 13) + { + *usb = 64; + } + else if (stopFreq == 14) + { + *usb = (*lsbM) << 1; + } + else + { + *usb = 3 * *lsbM; + } + + /* limit to Nyqvist */ + if (*usb > 64) + { + *usb = 64; + } + + /* test for invalid lsb, usb combinations */ + if ((*usb - *lsbM) > 48) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + if ((samplingFreq == 44100) && ((*usb - *lsbM) > 35)) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + if ((samplingFreq >= 48000) && ((*usb - *lsbM) > 32)) + { + /* + * invalid SBR bitstream ? + */ + return(SBRDEC_INVALID_BITSTREAM); + } + + return(SBRDEC_OK); + +} + +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.h new file mode 100644 index 00000000..6169fa1e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_find_start_andstop_band.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + Filename: sbr_find_start_andstop_band.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_FIND_START_ANDSTOP_BAND_H +#define SBR_FIND_START_ANDSTOP_BAND_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq, + const Int32 startFreq, + const Int32 stopFreq, + Int *lsbM, + Int *usb); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.c new file mode 100644 index 00000000..b0e969d2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.c @@ -0,0 +1,1034 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_generate_high_freq.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + HF generator with built-in QMF bank inverse filtering function + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" +#ifdef AAC_PLUS + + + +#include "sbr_generate_high_freq.h" +#include "calc_auto_corr.h" +#include "sbr_inv_filt_levelemphasis.h" +#include "pv_div.h" +#include "fxp_mul32.h" +#include "aac_mem_funcs.h" +#include "sbr_constants.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void high_freq_coeff_LC(Int32 sourceBufferReal[][32], + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *v_k_master, + Int32 *scratch_mem); + + + void high_freq_generation_LC(Int32 sourceBufferReal[][32], + Int32 *targetBufferReal, + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset); + + +#ifdef HQ_SBR + + void high_freq_coeff(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *v_k_master); + + void high_freq_generation(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset); + + +#endif + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_generate_high_freq(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 *invFiltBandTable, + Int32 noInvFiltBands, + Int32 highBandStartSb, + Int32 *v_k_master, + Int32 numMaster, + Int32 fs, + Int32 *frameInfo, + Int32 *degreeAlias, + Int32 scratch_mem[][64], + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES], + struct PATCH *Patch, + Int32 LC_flag, + Int32 *highBandStopSb) +{ + Int32 i; + Int32 patch; + Int32 startSample; + Int32 stopSample; + Int32 goalSb; + Int32 targetStopBand; + Int32 sourceStartBand; + Int32 patchDistance; + Int32 numBandsInPatch; + Int32 sbrStartFreqOffset; + + Int32 *alphar[2]; + Int32 *alphai[2]; + + Int32 lsb = v_k_master[0]; /* Lowest subband related to the synthesis filterbank */ + Int32 usb = v_k_master[numMaster]; /* Stop subband related to the synthesis filterbank */ + Int32 xoverOffset = highBandStartSb - v_k_master[0]; /* Calculate distance in subbands between k0 and kx */ + + + + Int slopeLength = 0; + + Int32 firstSlotOffs = frameInfo[1]; + Int32 lastSlotOffs = frameInfo[frameInfo[0] + 1] - 16; + + + alphar[0] = scratch_mem[0]; + alphar[1] = scratch_mem[1]; + alphai[0] = scratch_mem[2]; + alphai[1] = scratch_mem[3]; + + + startSample = (firstSlotOffs << 1); + stopSample = (lastSlotOffs << 1) + 32; + + + sbr_inv_filt_levelemphasis(invFiltMode, + prevInvFiltMode, + noInvFiltBands, + BwVector, + BwVectorOld); + + + if (LC_flag == ON) + { + /* Set subbands to zero */ + + pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0])); + + high_freq_coeff_LC(sourceBufferReal, + alphar, + degreeAlias, + v_k_master, + scratch_mem[4]); + } +#ifdef HQ_SBR + else + { + /* Set subbands to zero */ + + pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0])); + pv_memset((void *)&targetBufferImag[startSample*SBR_NUM_BANDS], + 0, + (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferImag[0])); + + high_freq_coeff(sourceBufferReal, + sourceBufferImag, + alphar, + alphai, + v_k_master); + + } +#endif /* #ifdef HQ_SBR */ + + + + + /* + * Initialize the patching parameter + */ + switch (fs) + + { + /* + * goalSb = (int)( 2.048e6f / fs + 0.5f ); + */ + case 48000: + goalSb = 43; /* 16 kHz band */ + break; + case 32000: + goalSb = 64; /* 16 kHz band */ + break; + case 24000: + goalSb = 85; /* 16 kHz band */ + break; + case 22050: + goalSb = 93; /* 16 kHz band */ + break; + case 16000: + goalSb = 128; /* 16 kHz band */ + break; + case 44100: + default: + goalSb = 46; /* 16 kHz band */ + break; + } + + i = 0; + + if (goalSb > v_k_master[0]) + { + if (goalSb < v_k_master[numMaster]) + { + while (v_k_master[i] < goalSb) + { + i++; + } + } + else + { + i = numMaster; + } + } + + goalSb = v_k_master[i]; + + /* First patch */ + sourceStartBand = xoverOffset + 1; + targetStopBand = lsb + xoverOffset; + + /* even (odd) numbered channel must be patched to even (odd) numbered channel */ + patch = 0; + + + sbrStartFreqOffset = targetStopBand; + + while (targetStopBand < usb) + { + Patch->targetStartBand[patch] = targetStopBand; + + numBandsInPatch = goalSb - targetStopBand; /* get the desired range of the patch */ + + if (numBandsInPatch >= lsb - sourceStartBand) + { + /* desired number bands are not available -> patch whole source range */ + patchDistance = targetStopBand - sourceStartBand; /* get the targetOffset */ + patchDistance = patchDistance & ~1; /* rounding off odd numbers and make all even */ + numBandsInPatch = lsb - (targetStopBand - patchDistance); + + if (targetStopBand + numBandsInPatch > v_k_master[0]) + { + i = numMaster; + if (targetStopBand + numBandsInPatch < v_k_master[numMaster]) + { + while (v_k_master[i] > targetStopBand + numBandsInPatch) + { + i--; + } + } + } + else + { + i = 0; + } + numBandsInPatch = v_k_master[i] - targetStopBand; + } + + /* desired number bands are available -> get the minimal even patching distance */ + patchDistance = numBandsInPatch + targetStopBand - lsb; /* get minimal distance */ + patchDistance = (patchDistance + 1) & ~1; /* rounding up odd numbers and make all even */ + + /* All patches but first */ + sourceStartBand = 1; + + /* Check if we are close to goalSb */ + if (goalSb - (targetStopBand + numBandsInPatch) < 3) + { /* MPEG doc */ + goalSb = usb; + } + + + if ((numBandsInPatch < 3) && (patch > 0)) + { + if (LC_flag == ON) + { + + pv_memset((void *) °reeAlias[targetStopBand], 0, numBandsInPatch*sizeof(*degreeAlias)); + } + break; + } + + if (numBandsInPatch <= 0) + { + continue; + } + + + /* + * High Frequency generation + */ + + if (LC_flag == ON) + { + + high_freq_generation_LC(sourceBufferReal, + (Int32 *)targetBufferReal, + alphar, + degreeAlias, + invFiltBandTable, + targetStopBand, + patchDistance, + numBandsInPatch, + startSample, + slopeLength, + stopSample, + BwVector, + sbrStartFreqOffset); + + } +#ifdef HQ_SBR + else + { + + high_freq_generation(sourceBufferReal, + sourceBufferImag, + (Int32 *)targetBufferReal, + (Int32 *)targetBufferImag, + alphar, + alphai, + invFiltBandTable, + targetStopBand, + patchDistance, + numBandsInPatch, + startSample, + slopeLength, + stopSample, + BwVector, + sbrStartFreqOffset); + + } +#endif + + targetStopBand += numBandsInPatch; + + patch++; + + } /* targetStopBand */ + + Patch->noOfPatches = patch; + + pv_memmove(BwVectorOld, BwVector, noInvFiltBands*sizeof(BwVector[0])); + + *highBandStopSb = goalSb; + + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void high_freq_coeff_LC(Int32 sourceBufferReal[][32], + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *v_k_master, + Int32 *scratch_mem) +{ + + Int32 fac; + Int32 *k1; + struct ACORR_COEFS ac; + struct intg_div quotient; + + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 autoCorrLength; + Int32 loBand; + + k1 = scratch_mem; + + + autoCorrLength = 38; + + for (loBand = 1; loBand < v_k_master[0]; loBand++) + { + + calc_auto_corr_LC(&ac, + sourceBufferReal, + loBand, + autoCorrLength); + + if (ac.r11r && ac.det) + { + + pv_div(ac.r01r, ac.r11r, "ient); + + fac = -(quotient.quotient >> 2); /* Q28 */ + + if (quotient.shift_factor > 0) + { + fac >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) + { + if (quotient.shift_factor > -4) /* |fac| < 8 */ + { + fac <<= (-quotient.shift_factor); /* Q28 */ + } + else + { + fac = 0x80000000; /* overshoot possible fac = -8 */ + } + } + + /* + * prevent for overflow of reflection coefficients + */ + if (quotient.shift_factor > 0) + { + k1[loBand] = - quotient.quotient >> quotient.shift_factor; + } + else if (quotient.shift_factor == 0) + { + if (quotient.quotient >= 0x40000000) + { + k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */ + } + else if (quotient.quotient <= (Int32)0xC0000000) + { + k1[loBand] = 0x40000000; /* 1.0 in Q30 */ + } + else + { + k1[loBand] = -quotient.quotient; + } + } + else + { + if (quotient.quotient > 0) + { + k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */ + } + else + { + k1[loBand] = 0x40000000; /* 1.0 in Q30 */ + } + } + /* + * alphar[1][loBand] = ( ac.r01r * ac.r12r - ac.r02r * ac.r11r ) / ac.det; + */ + + temp1 = -fxp_mul32_Q30(ac.r02r, ac.r11r); + temp1 = fxp_mac32_Q30(ac.r01r, ac.r12r, temp1); + + temp2 = ac.det; + temp3 = temp1 > 0 ? temp1 : -temp1; + temp2 = temp2 > 0 ? temp2 : -temp2; + + /* prevent for shootovers */ + if ((temp3 >> 2) >= temp2 || fac == (Int32)0x80000000) + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + } + else + { + pv_div(temp1, ac.det, "ient); + /* + * alphar[1][loBand] is lesser than 4.0 + */ + alphar[1][loBand] = quotient.quotient; + quotient.shift_factor += 2; /* Q28 */ + + if (quotient.shift_factor > 0) + { + alphar[1][loBand] >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) /* at this point can only be -1 */ + { + alphar[1][loBand] <<= (-quotient.shift_factor); /* Q28 */ + } + + /* + * alphar[0][loBand] = - ( ac.r01r + alphar[1][loBand] * ac.r12r ) / ac.r11r; + */ + + pv_div(ac.r12r, ac.r11r, "ient); + + temp3 = (quotient.quotient >> 2); /* Q28 */ + + if (quotient.shift_factor > 0) + { + temp3 >>= quotient.shift_factor; /* Q28 */ + } + else if (quotient.shift_factor < 0) + { + temp3 <<= (-quotient.shift_factor); /* Q28 */ + } + + alphar[0][loBand] = fac - fxp_mul32_Q28(alphar[1][loBand], temp3) ; /* Q28 */ + + if ((alphar[0][loBand] >= 0x40000000) || (alphar[0][loBand] <= (Int32)0xC0000000)) + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + } + + } + + } + else + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + + k1[loBand] = 0; + } + + } + + k1[0] = 0; + degreeAlias[1] = 0; + for (loBand = 2; loBand < v_k_master[0]; loBand++) + { + degreeAlias[loBand] = 0; + if ((!(loBand & 1)) && (k1[loBand] < 0)) + { + if (k1[loBand-1] < 0) + { // 2-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000; + if (k1[loBand-2] > 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + + } + } + else if (k1[loBand-2] > 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + if ((loBand & 1) && (k1[loBand] > 0)) + { + if (k1[loBand-1] > 0) + { // 2-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000; + if (k1[loBand-2] < 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + else if (k1[loBand-2] < 0) + { // 3-CH Aliasing Detection + degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]); + } + } + } + +} + + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void high_freq_generation_LC(Int32 sourceBufferReal[][32], + Int32 *targetBufferReal, + Int32 *alphar[2], + Int32 *degreeAlias, + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset) +{ + + Int32 temp1; + Int32 temp2; + Int32 temp3; + + + Int32 a0r; + Int32 a1r; + Int32 i; + Int32 bw; + Int32 hiBand; + Int32 bwIndex; + Int32 loBand; + Int32 j; + + bwIndex = 0; + + for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++) + { + loBand = hiBand - patchDistance; + + if (hiBand != targetStopBand) + { + degreeAlias[hiBand] = degreeAlias[loBand]; + } + else + { + degreeAlias[hiBand] = 0; + } + + while (hiBand >= invFiltBandTable[bwIndex]) + { + bwIndex++; + } + + bw = BwVector[bwIndex]; + + /* + * Inverse Filtering + */ + + + j = hiBand - sbrStartFreqOffset; + + if (bw > 0 && (alphar[0][loBand] | alphar[1][loBand])) + { + /* Apply current bandwidth expansion factor */ + a0r = fxp_mul32_Q29(bw, alphar[0][loBand]); + + bw = fxp_mul32_Q31(bw, bw) << 2; + + a1r = fxp_mul32_Q28(bw, alphar[1][loBand]); + + i = startSample + slopeLength; + + temp1 = sourceBufferReal[i ][loBand]; + temp2 = sourceBufferReal[i - 1][loBand]; + temp3 = sourceBufferReal[i - 2][loBand]; + + for (; i < stopSample + slopeLength - 1; i++) + { + + + targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) + + fxp_mul32_Q28(a1r, temp3); + + + temp3 = temp2; + temp2 = temp1; + temp1 = sourceBufferReal[i + 1][loBand]; + } + targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) + + fxp_mul32_Q28(a1r, temp3); + + } + else + { + + for (i = startSample + slopeLength; i < stopSample + slopeLength; i++) + { + targetBufferReal[i*SBR_NUM_BANDS + j] = sourceBufferReal[i][loBand]; + } + } + + + } /* hiBand */ + +} + + +#ifdef HQ_SBR + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void high_freq_coeff(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *v_k_master) +{ + + Int32 overflow_flag; + + Int32 temp1r; + Int32 temp1i; + Int32 temp0r; + Int32 temp0i; + Int32 loBand; + + struct ACORR_COEFS ac; + struct intg_div quotient; + + Int32 autoCorrLength; + + autoCorrLength = 38; + + for (loBand = 1; loBand < v_k_master[0]; loBand++) + { + + calc_auto_corr(&ac, + sourceBufferReal, + sourceBufferImag, + loBand, + autoCorrLength); + + + overflow_flag = 0; + + if (ac.det < 1) + { + /* --- */ + temp1r = 0; + temp1i = 0; + alphar[1][loBand] = 0; + alphai[1][loBand] = 0; + + } + else + { + + temp1r = fxp_mul32_Q29(ac.r01r, ac.r12r); + temp1r = fxp_msu32_Q29(ac.r01i, ac.r12i, temp1r); + temp1r = fxp_msu32_Q29(ac.r02r, ac.r11r, temp1r); + + temp1i = fxp_mul32_Q29(ac.r01r, ac.r12i); + temp1i = fxp_msu32_Q29(ac.r02i, ac.r11r, temp1i); + temp1i = fxp_mac32_Q29(ac.r01i, ac.r12r, temp1i); + + pv_div(temp1r, ac.det, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp1r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + pv_div(temp1i, ac.det, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp1i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + + alphar[1][loBand] = temp1r; + alphai[1][loBand] = temp1i; + + } + + if (ac.r11r == 0) + { + temp0r = 0; + temp0i = 0; + alphar[0][loBand] = 0; + alphai[0][loBand] = 0; + + } + else + { + temp0r = - (ac.r01r + fxp_mul32_Q28(temp1r, ac.r12r) + fxp_mul32_Q28(temp1i, ac.r12i)); + temp0i = - (ac.r01i + fxp_mul32_Q28(temp1i, ac.r12r) - fxp_mul32_Q28(temp1r, ac.r12i)); + + pv_div(temp0r, ac.r11r, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp0r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + pv_div(temp0i, ac.r11r, "ient); + overflow_flag = (quotient.shift_factor < -2) ? 1 : 0; + temp0i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */ + + alphar[0][loBand] = temp0r; + alphai[0][loBand] = temp0i; + + } + + /* prevent for shootovers */ + + if (fxp_mul32_Q28((temp0r >> 2), (temp0r >> 2)) + fxp_mul32_Q28((temp0i >> 2), (temp0i >> 2)) >= 0x10000000 || + fxp_mul32_Q28((temp1r >> 2), (temp1r >> 2)) + fxp_mul32_Q28((temp1i >> 2), (temp1i >> 2)) >= 0x10000000 || + overflow_flag) /* 0x10000000 == 1 in Q28 */ + + { + alphar[0][loBand] = 0; + alphar[1][loBand] = 0; + alphai[0][loBand] = 0; + alphai[1][loBand] = 0; + + } + } +} + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void high_freq_generation(Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + Int32 *alphar[2], + Int32 *alphai[2], + Int32 *invFiltBandTable, + Int32 targetStopBand, + Int32 patchDistance, + Int32 numBandsInPatch, + Int32 startSample, + Int32 slopeLength, + Int32 stopSample, + Int32 *BwVector, + Int32 sbrStartFreqOffset) +{ + Int32 temp1_r; + Int32 temp2_r; + Int32 temp3_r; + Int32 temp1_i; + Int32 temp2_i; + Int32 temp3_i; + + + Int32 a0i; + Int32 a1i; + Int32 a0r; + Int32 a1r; + Int32 i; + Int32 bw; + Int32 hiBand; + Int32 bwIndex; + Int32 loBand; + Int32 j; + + + + Int64 tmp; + + bwIndex = 0; + + for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++) + { + + loBand = hiBand - patchDistance; + + while (hiBand >= invFiltBandTable[bwIndex]) + { + bwIndex++; + } + + bw = BwVector[bwIndex]; + + /* + * Inverse Filtering + */ + + + j = hiBand - sbrStartFreqOffset; + + if (bw >= 0 && (alphar[0][loBand] | alphar[1][loBand] | + alphai[0][loBand] | alphai[1][loBand])) + { + /* Apply current bandwidth expansion factor */ + a0r = fxp_mul32_Q29(bw, alphar[0][loBand]); + a0i = fxp_mul32_Q29(bw, alphai[0][loBand]); + + + bw = fxp_mul32_Q30(bw, bw); + + + a1r = fxp_mul32_Q28(bw, alphar[1][loBand]); + a1i = fxp_mul32_Q28(bw, alphai[1][loBand]); + + + i = startSample + slopeLength; + j += i * SBR_NUM_BANDS; + + temp1_r = sourceBufferReal[i ][loBand]; + temp2_r = sourceBufferReal[i - 1][loBand]; + temp3_r = sourceBufferReal[i - 2][loBand]; + + temp1_i = sourceBufferImag[i ][loBand]; + temp2_i = sourceBufferImag[i - 1][loBand]; + temp3_i = sourceBufferImag[i - 2][loBand]; + + while (i < stopSample + slopeLength) + { + tmp = fxp_mac64_Q31(((Int64)temp1_r << 28), a0r, temp2_r); + tmp = fxp_mac64_Q31(tmp, -a0i, temp2_i); + tmp = fxp_mac64_Q31(tmp, a1r, temp3_r); + targetBufferReal[j] = (Int32)(fxp_mac64_Q31(tmp, -a1i, temp3_i) >> 28); + + tmp = fxp_mac64_Q31(((Int64)temp1_i << 28), a0i, temp2_r); + tmp = fxp_mac64_Q31(tmp, a0r, temp2_i); + tmp = fxp_mac64_Q31(tmp, a1i, temp3_r); + targetBufferImag[j] = (Int32)(fxp_mac64_Q31(tmp, a1r, temp3_i) >> 28); + + i++; + j += SBR_NUM_BANDS; + + temp3_r = temp2_r; + temp2_r = temp1_r; + temp1_r = sourceBufferReal[i ][loBand]; + + temp3_i = temp2_i; + temp2_i = temp1_i; + temp1_i = sourceBufferImag[i ][loBand]; + + } + + } + + + + else + { + i = startSample + slopeLength; + j += i * SBR_NUM_BANDS; + + for (; i < stopSample + slopeLength; i++) + { + targetBufferReal[j] = sourceBufferReal[i][loBand]; + targetBufferImag[j] = sourceBufferImag[i][loBand]; + j += SBR_NUM_BANDS; + } + } + } +} + +#endif + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.h new file mode 100644 index 00000000..b7d6012b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_generate_high_freq.h @@ -0,0 +1,137 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_generate_high_freq.h + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GENERATE_HIGH_FREQ_H +#define SBR_GENERATE_HIGH_FREQ_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "e_invf_mode.h" +#include "s_patch.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + + + + void sbr_generate_high_freq( + Int32 sourceBufferReal[][32], + Int32 sourceBufferImag[][32], + Int32 *targetBufferReal, + Int32 *targetBufferImag, + INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 *invFiltBandTable, + Int32 noInvFiltBands, + Int32 highBandStartSb, + Int32 *v_k_master, + Int32 numMaster, + Int32 fs, + Int32 *frameInfo, + Int32 *degreeAlias, + Int32 scratch_mem[][64], + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES], + struct PATCH * Patch, + Int32 LC_flag, + Int32 *highBandStopSb); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.c new file mode 100644 index 00000000..0e7f1d17 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.c @@ -0,0 +1,139 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_additional_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_additional_data.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + + Int32 flag = buf_getbits(hBitBuf, 1); + + if (flag) + { + for (i = 0; i < hFrameData->nSfb[HI]; i++) + { + hFrameData->addHarmonics[i] = buf_getbits(hBitBuf, 1); + } + } +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.h new file mode 100644 index 00000000..a34bd5f6 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_additional_data.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_additional_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_ADDITIONAL_DATA_H +#define SBR_GET_ADDITIONAL_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_header_data.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.c new file mode 100644 index 00000000..8fe510f2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.c @@ -0,0 +1,260 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_cpe.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hFrameDataLeft - handle to struct SBR_FRAME_DATA for first channel + hFrameDataRight - handle to struct SBR_FRAME_DATA for first channel + hBitBuf - handle to struct BIT_BUF + + Return: SbrFrameOK + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_cpe.h" +#include "buf_getbits.h" +#include "extractframeinfo.h" +#include "sbr_get_dir_control_data.h" +#include "sbr_get_envelope.h" +#include "sbr_get_noise_floor_data.h" +#include "sbr_get_additional_data.h" +#include "sbr_extract_extended_data.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft, + SBR_FRAME_DATA * hFrameDataRight, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 bits; + SBR_ERROR err = SBRDEC_OK; + + /* reserved bits */ + bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT); + + if (bits) + { + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + } + + /* Read coupling flag */ + bits = buf_getbits(hBitBuf, SI_SBR_COUPLING_BITS); + + if (bits) + { + hFrameDataLeft->coupling = COUPLING_LEVEL; + hFrameDataRight->coupling = COUPLING_BAL; + } + else + { + hFrameDataLeft->coupling = COUPLING_OFF; + hFrameDataRight->coupling = COUPLING_OFF; + } + + + err = extractFrameInfo(hBitBuf, hFrameDataLeft); + + if (err != SBRDEC_OK) + { + return err; + } + + if (hFrameDataLeft->coupling) + { + + pv_memcpy(hFrameDataRight->frameInfo, + hFrameDataLeft->frameInfo, + LENGTH_FRAME_INFO * sizeof(Int32)); + + hFrameDataRight->nNoiseFloorEnvelopes = hFrameDataLeft->nNoiseFloorEnvelopes; + hFrameDataRight->frameClass = hFrameDataLeft->frameClass; + + + sbr_get_dir_control_data(hFrameDataLeft, hBitBuf); + sbr_get_dir_control_data(hFrameDataRight, hBitBuf); + + for (i = 0; i < hFrameDataLeft->nNfb; i++) + { + hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i]; + hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i]; + + hFrameDataLeft->sbr_invf_mode[i] = (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + hFrameDataRight->sbr_invf_mode[i] = hFrameDataLeft->sbr_invf_mode[i]; + } + + sbr_get_envelope(hFrameDataLeft, hBitBuf); + sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf); + sbr_get_envelope(hFrameDataRight, hBitBuf); + + } + else + { + err = extractFrameInfo(hBitBuf, hFrameDataRight); + + if (err != SBRDEC_OK) + { + return err; + } + + + sbr_get_dir_control_data(hFrameDataLeft, hBitBuf); + sbr_get_dir_control_data(hFrameDataRight, hBitBuf); + + for (i = 0; i < hFrameDataLeft->nNfb; i++) + { + hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i]; + hFrameDataLeft->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + + for (i = 0; i < hFrameDataRight->nNfb; i++) + { + hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i]; + + hFrameDataRight->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + sbr_get_envelope(hFrameDataLeft, hBitBuf); + sbr_get_envelope(hFrameDataRight, hBitBuf); + + sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf); + + } + + sbr_get_noise_floor_data(hFrameDataRight, hBitBuf); + + pv_memset((void *)hFrameDataLeft->addHarmonics, + 0, + hFrameDataLeft->nSfb[HI]*sizeof(Int32)); + + pv_memset((void *)hFrameDataRight->addHarmonics, + 0, + hFrameDataRight->nSfb[HI]*sizeof(Int32)); + + sbr_get_additional_data(hFrameDataLeft, hBitBuf); + sbr_get_additional_data(hFrameDataRight, hBitBuf); + + sbr_extract_extended_data(hBitBuf +#ifdef PARAMETRICSTEREO + , NULL +#endif + ); + + return SBRDEC_OK; + +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.h new file mode 100644 index 00000000..7ecddd5c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_cpe.h @@ -0,0 +1,78 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_cpe.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_CPE_H +#define SBR_GET_CPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft, + SBR_FRAME_DATA * hFrameDataRight, + BIT_BUFFER * hBitBuf); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.c new file mode 100644 index 00000000..56b8a7a5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.c @@ -0,0 +1,147 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_dir_control_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads direction control data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_dir_control_data.h" +#include "buf_getbits.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + + h_frame_data->nNoiseFloorEnvelopes = h_frame_data->frameInfo[0] > 1 ? 2 : 1; + + + for (i = 0; i < h_frame_data->frameInfo[0]; i++) + { + h_frame_data->domain_vec1[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS); + } + + for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++) + { + h_frame_data->domain_vec2[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS); + } +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.h new file mode 100644 index 00000000..b201e4d5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_dir_control_data.h @@ -0,0 +1,76 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_dir_control_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_DIR_CONTROL_DATA_H +#define SBR_GET_DIR_CONTROL_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.c new file mode 100644 index 00000000..4879461e --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.c @@ -0,0 +1,259 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_envelope.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + channel - channel number + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads envelope data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_envelope.h" +#include "s_huffman.h" +#include "e_coupling_mode.h" +#include "sbr_code_book_envlevel.h" +#include "buf_getbits.h" +#include "sbr_decode_huff_cw.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 j; + Int32 tmp; + Int32 no_band[MAX_ENVELOPES]; + Int32 delta = 0; + Int32 offset = 0; + Int32 ampRes; + Int32 envDataTableCompFactor; + Int32 start_bits; + Int32 start_bits_balance; + SbrHuffman hcb_t; + SbrHuffman hcb_f; + COUPLING_MODE coupling = h_frame_data->coupling; + + h_frame_data->nScaleFactors = 0; + + if ((h_frame_data->frameClass == FIXFIX) && + (h_frame_data->frameInfo[0] == 1)) + { + h_frame_data->ampRes = SBR_AMP_RES_1_5; + } + else + { + h_frame_data->ampRes = h_frame_data->sbr_header.ampResolution; + } + + ampRes = h_frame_data->ampRes; + + /* + * Set number of bits for first value depending on amplitude resolution + */ + if (ampRes == SBR_AMP_RES_3_0) + { + start_bits = SI_SBR_START_ENV_BITS_AMP_RES_3_0; + start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0; + } + else + { + start_bits = SI_SBR_START_ENV_BITS_AMP_RES_1_5; + start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5; + } + + /* + * Calculate number of values for each envelope and alltogether + */ + for (i = 0; i < h_frame_data->frameInfo[0]; i++) + { + no_band[i] = + h_frame_data->nSfb[h_frame_data->frameInfo[h_frame_data->frameInfo[0] + 2 + i]]; + h_frame_data->nScaleFactors += no_band[i]; + } + + + /* + * Select huffman codebook depending on coupling mode and amplitude resolution + */ + if (coupling == COUPLING_BAL) + { + envDataTableCompFactor = 1; + if (ampRes == SBR_AMP_RES_1_5) + { + hcb_t = bookSbrEnvBalance10T; + hcb_f = bookSbrEnvBalance10F; + } + else + { + hcb_t = bookSbrEnvBalance11T; + hcb_f = bookSbrEnvBalance11F; + } + } + else + { + envDataTableCompFactor = 0; + if (ampRes == SBR_AMP_RES_1_5) + { + hcb_t = bookSbrEnvLevel10T; + hcb_f = bookSbrEnvLevel10F; + } + else + { + hcb_t = bookSbrEnvLevel11T; + hcb_f = bookSbrEnvLevel11F; + } + } + + /* + * Now read raw envelope data + */ + for (j = 0; j < h_frame_data->frameInfo[0]; j++) + { + if (h_frame_data->domain_vec1[j] == FREQ) + { + if (coupling == COUPLING_BAL) + { + tmp = buf_getbits(hBitBuf, start_bits_balance); + h_frame_data->iEnvelope_man[offset] = tmp << envDataTableCompFactor; + } + else + { + tmp = buf_getbits(hBitBuf, start_bits); + h_frame_data->iEnvelope_man[offset] = tmp; + } + } + + for (i = (1 - h_frame_data->domain_vec1[j]); i < no_band[j]; i++) + { + + if (h_frame_data->domain_vec1[j] == FREQ) + { + delta = sbr_decode_huff_cw(hcb_f, hBitBuf); + } + else + { + delta = sbr_decode_huff_cw(hcb_t, hBitBuf); + } + + h_frame_data->iEnvelope_man[offset + i] = delta << envDataTableCompFactor; + } + offset += no_band[j]; + } + +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.h new file mode 100644 index 00000000..873212d0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_envelope.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_envelope.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_ENVELOPE_H +#define SBR_GET_ENVELOPE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.c new file mode 100644 index 00000000..88f9e77f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.c @@ -0,0 +1,215 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_header_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_sbr_header - handle to struct SBR_HEADER_DATA + hBitBuf - handle to struct BIT_BUFFER + id_sbr - SBR_ELEMENT_ID + + Return: error status - 0 if ok + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads header data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_header_data.h" +#include "sbr_constants.h" +#include "buf_getbits.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA * h_sbr_header, + BIT_BUFFER * hBitBuf, + SBR_SYNC_STATE syncState) +{ + SBR_HEADER_DATA lastHeader; + Int32 headerExtra1, headerExtra2; + + + /* Copy header to temporary header */ + if (syncState == SBR_ACTIVE) + { + pv_memcpy(&lastHeader, h_sbr_header, sizeof(SBR_HEADER_DATA)); + } + else + { + pv_memset((void *)&lastHeader, 0, sizeof(SBR_HEADER_DATA)); + } + + + /* Read new header from bitstream */ + h_sbr_header->ampResolution = buf_getbits(hBitBuf, SI_SBR_AMP_RES_BITS); + h_sbr_header->startFreq = buf_getbits(hBitBuf, SI_SBR_START_FREQ_BITS); + h_sbr_header->stopFreq = buf_getbits(hBitBuf, SI_SBR_STOP_FREQ_BITS); + h_sbr_header->xover_band = buf_getbits(hBitBuf, SI_SBR_XOVER_BAND_BITS); + + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_HDR); + + headerExtra1 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_1_BITS); + headerExtra2 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_2_BITS); + + /* handle extra header information */ + if (headerExtra1) + { + h_sbr_header->freqScale = buf_getbits(hBitBuf, SI_SBR_FREQ_SCALE_BITS); + h_sbr_header->alterScale = buf_getbits(hBitBuf, SI_SBR_ALTER_SCALE_BITS); + h_sbr_header->noise_bands = buf_getbits(hBitBuf, SI_SBR_NOISE_BANDS_BITS); + } + else + { /* Set default values.*/ + h_sbr_header->freqScale = SBR_FREQ_SCALE_DEFAULT; + h_sbr_header->alterScale = SBR_ALTER_SCALE_DEFAULT; + h_sbr_header->noise_bands = SBR_NOISE_BANDS_DEFAULT; + } + + + if (headerExtra2) + { + h_sbr_header->limiterBands = buf_getbits(hBitBuf, SI_SBR_LIMITER_BANDS_BITS); + h_sbr_header->limiterGains = buf_getbits(hBitBuf, SI_SBR_LIMITER_GAINS_BITS); + h_sbr_header->interpolFreq = buf_getbits(hBitBuf, SI_SBR_INTERPOL_FREQ_BITS); + h_sbr_header->smoothingLength = buf_getbits(hBitBuf, SI_SBR_SMOOTHING_LENGTH_BITS); + } + else + { /* Set default values.*/ + h_sbr_header->limiterBands = SBR_LIMITER_BANDS_DEFAULT; + h_sbr_header->limiterGains = SBR_LIMITER_GAINS_DEFAULT; + h_sbr_header->interpolFreq = SBR_INTERPOL_FREQ_DEFAULT; + h_sbr_header->smoothingLength = SBR_SMOOTHING_LENGTH_DEFAULT; + } + + if (syncState == SBR_ACTIVE) + { + h_sbr_header->status = HEADER_OK; + + /* look for new settings */ + if (lastHeader.startFreq != h_sbr_header->startFreq || + lastHeader.stopFreq != h_sbr_header->stopFreq || + lastHeader.xover_band != h_sbr_header->xover_band || + lastHeader.freqScale != h_sbr_header->freqScale || + lastHeader.alterScale != h_sbr_header->alterScale || + lastHeader.noise_bands != h_sbr_header->noise_bands) + { + h_sbr_header->status = HEADER_RESET; + } + } + else + { + h_sbr_header->status = HEADER_RESET; + } + + return h_sbr_header->status; +} + +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.h new file mode 100644 index 00000000..1b299f91 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_header_data.h @@ -0,0 +1,80 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_header_data.h + Functions: + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_HEADER_DATA_H +#define SBR_GET_HEADER_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_header_data.h" +#include "e_sbr_element_id.h" +#include "e_sbr_sync_state.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA *h_sbr_header, + BIT_BUFFER * hBitBuf, + SBR_SYNC_STATE syncState); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.c new file mode 100644 index 00000000..81fbbb16 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.c @@ -0,0 +1,211 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_noise_floor_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: h_frame_data - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: void + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Reads noise-floor-level data from bitstream + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_get_noise_floor_data.h" +#include "e_coupling_mode.h" +#include "buf_getbits.h" +#include "sbr_code_book_envlevel.h" +#include "s_huffman.h" +#include "sbr_decode_huff_cw.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf) +{ + Int32 i; + Int32 j; + Int32 k; + Int32 tmp; + Int32 delta; + Int32 noNoiseBands = h_frame_data->nNfb; + Int32 envDataTableCompFactor; + + COUPLING_MODE coupling = h_frame_data->coupling; + + SbrHuffman hcb_noiseF; + SbrHuffman hcb_noise; + + + if (coupling == COUPLING_BAL) + { + hcb_noise = bookSbrNoiseBalance11T; + hcb_noiseF = bookSbrEnvBalance11F; /* "bookSbrNoiseBalance11F" */ + envDataTableCompFactor = 1; + } + else + { + hcb_noise = bookSbrNoiseLevel11T; + hcb_noiseF = bookSbrEnvLevel11F; /* "bookSbrNoiseLevel11F" */ + envDataTableCompFactor = 0; + } + + /* + * Calculate number of values alltogether + */ + h_frame_data->nNoiseFactors = h_frame_data->frameInfo[((h_frame_data->frameInfo[0]) << 1) + 3] * noNoiseBands; + + + for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++) + { + k = i * noNoiseBands; + if (h_frame_data->domain_vec2[i] == FREQ) + { + if (coupling == COUPLING_BAL) + { + tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0) << 1; /* max. 62 */ + h_frame_data->sbrNoiseFloorLevel_man[k] = tmp; + h_frame_data->sbrNoiseFloorLevel_exp[k] = 0; + } + else + { + tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_AMP_RES_3_0); /* max. 31 */ + h_frame_data->sbrNoiseFloorLevel_man[k] = tmp; + h_frame_data->sbrNoiseFloorLevel_exp[k] = 0; + } + + for (j = 1; j < noNoiseBands; j++) + { + delta = sbr_decode_huff_cw(hcb_noiseF, hBitBuf); /* + * -31 < delta < 31 + * -24 < delta < 24 COUPLING_BAL (incl. <<1) + */ + h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor; + h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0; + } + } + else + { + for (j = 0; j < noNoiseBands; j++) + { + delta = sbr_decode_huff_cw(hcb_noise, hBitBuf); /* + * -31 < delta < 31 + * -24 < delta < 24 COUPLING_BAL (incl. <<1) + */ + h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor; + h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0; + } + } + } +} + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.h new file mode 100644 index 00000000..fe7262f7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_noise_floor_data.h @@ -0,0 +1,84 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_noise_floor_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_NOISE_FLOOR_DATA_H +#define SBR_GET_NOISE_FLOOR_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data, + BIT_BUFFER * hBitBuf); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.c new file mode 100644 index 00000000..69359ca5 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.c @@ -0,0 +1,196 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_sce.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Arguments: hFrameData - handle to struct SBR_FRAME_DATA + hBitBuf - handle to struct BIT_BUF + + Return: SbrFrameOK + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + + +#include "sbr_get_sce.h" +#include "sbr_get_additional_data.h" +#include "sbr_extract_extended_data.h" +#include "buf_getbits.h" +#include "sbr_get_envelope.h" +#include "sbr_get_noise_floor_data.h" +#include "extractframeinfo.h" +#include "sbr_get_dir_control_data.h" +#include "e_invf_mode.h" +#include "aac_mem_funcs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO + , HANDLE_PS_DEC hParametricStereoDec +#endif + ) +{ + Int32 i; + Int32 bits; + SBR_ERROR err = SBRDEC_OK; + + /* reserved bits */ + bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT); + + if (bits) + { + buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA); + } + + /* side info */ + err = extractFrameInfo(hBitBuf, hFrameData); + + if (err != SBRDEC_OK) + { + return err; + } + + + sbr_get_dir_control_data(hFrameData, hBitBuf); + + for (i = 0; i < hFrameData->nNfb; i++) + { + hFrameData->sbr_invf_mode_prev[i] = hFrameData->sbr_invf_mode[i]; + hFrameData->sbr_invf_mode[i] = + (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS); + } + + + /* raw data */ + sbr_get_envelope(hFrameData, hBitBuf); + + sbr_get_noise_floor_data(hFrameData, hBitBuf); + + pv_memset((void *)hFrameData->addHarmonics, + 0, + hFrameData->nSfb[HI]*sizeof(Int32)); + + sbr_get_additional_data(hFrameData, hBitBuf); + + sbr_extract_extended_data(hBitBuf +#ifdef PARAMETRICSTEREO + , hParametricStereoDec +#endif + ); + + hFrameData->coupling = COUPLING_OFF; + + return SBRDEC_OK; + +} + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.h new file mode 100644 index 00000000..7d991acc --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_get_sce.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_get_sce.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_GET_SCE_H +#define SBR_GET_SCE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_bit_buffer.h" +#include "s_sbr_frame_data.h" +#include "e_sbr_error.h" +#include "config.h" +#ifdef PARAMETRICSTEREO +#include "s_ps_dec.h" +#endif + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData, + BIT_BUFFER * hBitBuf +#ifdef PARAMETRICSTEREO + , HANDLE_PS_DEC hParametricStereoDec +#endif + ); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.c new file mode 100644 index 00000000..6e1dd344 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.c @@ -0,0 +1,208 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_inv_filt_levelemphasis.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_inv_filt_levelemphasis.h" +#include "sbr_generate_high_freq.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" + +#define R_SHIFT 29 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) + +const Int32 InvFiltFactors[5] = {Qfmt(0.00f), /* OFF_LEVEL */ + Qfmt(0.60f), /* TRANSITION_LEVEL */ + Qfmt(0.75f), /* LOW_LEVEL */ + Qfmt(0.90f), /* MID_LEVEL */ + Qfmt(0.98f) + }; /* HIGH_LEVEL */ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 nNfb, + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES]) +{ + Int32 i; + Int32 j; + Int32 tmp; + + for (i = 0; i < nNfb; i++) + { + switch (invFiltMode[i]) + { + case INVF_LOW_LEVEL: + if (prevInvFiltMode[i] == INVF_OFF) + { + j = 1; + } + else + { + j = 2; + } + break; + + case INVF_MID_LEVEL: + j = 3; + break; + + case INVF_HIGH_LEVEL: + j = 4; + break; + + default: + if (prevInvFiltMode[i] == INVF_LOW_LEVEL) + { + j = 1; + } + else + { + j = 0; + } + } + + tmp = InvFiltFactors[j]; + + if (tmp < BwVectorOld[i]) + { + tmp = ((tmp << 1) + tmp + BwVectorOld[i]) >> 2; + } + else + { + tmp = fxp_mul32_Q29(Qfmt(0.90625f), tmp); + tmp = fxp_mac32_Q29(Qfmt(0.09375f), BwVectorOld[i], tmp); + } + + if (tmp < Qfmt(0.015625F)) + { + tmp = 0; + } + + if (tmp >= Qfmt(0.99609375f)) + { + tmp = Qfmt(0.99609375f); + } + + BwVector[i] = tmp; + } +} + + +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.h new file mode 100644 index 00000000..7c1524d0 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_inv_filt_levelemphasis.h @@ -0,0 +1,82 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_inv_filt_levelemphasis.h + Functions: + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_INV_FILT_LEVELEMPHASIS_H +#define SBR_INV_FILT_LEVELEMPHASIS_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_invf_mode.h" +#include "sbr_generate_high_freq.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode, + INVF_MODE *prevInvFiltMode, + Int32 nNfb, + Int32 BwVector[MAX_NUM_PATCHES], + Int32 BwVectorOld[MAX_NUM_PATCHES]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.c new file mode 100644 index 00000000..49bd76a2 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.c @@ -0,0 +1,189 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_open.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_open.h" +#include "s_sbr_header_data.h" +#include "init_sbr_dec.h" +#include "e_sbr_error.h" +#include "aac_mem_funcs.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const SBR_HEADER_DATA defaultHeader = +{ + HEADER_NOT_INITIALIZED, /* status */ + MASTER_RESET, /* masterStatus */ + 0, /* crcEnable */ + UP_BY_2, /* sampleRateMode */ + SBR_AMP_RES_3_0, /* ampResolution */ + 5, /* startFreq */ + 0, /* stopFreq */ + 0, /* xover_band */ + SBR_FREQ_SCALE_DEFAULT, /* freqScale */ + SBR_ALTER_SCALE_DEFAULT, /* alterScale */ + SBR_NOISE_BANDS_DEFAULT, /* noise_bands */ + 0, /* noNoiseBands */ + SBR_LIMITER_BANDS_DEFAULT, + SBR_LIMITER_GAINS_DEFAULT, + SBR_INTERPOL_FREQ_DEFAULT, + SBR_SMOOTHING_LENGTH_DEFAULT +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_open(Int32 sampleRate, + SBR_DEC *sbrDec, + SBRDECODER_DATA * self, + Bool bDownSampledSbr) + +{ + Int16 i ; + + SBR_CHANNEL *SbrChannel; + + + SbrChannel = self->SbrChannel; + + for (i = 0; i < MAX_NUM_CHANNELS; i++) + { + pv_memset((void *)&(SbrChannel[i]), + 0, + sizeof(SBR_CHANNEL)); + + /* init a default header such that we can at least do upsampling later */ + + pv_memcpy(&(SbrChannel[i].frameData.sbr_header), + &defaultHeader, + sizeof(SBR_HEADER_DATA)); + + /* should be handled by sample rate mode bit */ + if (sampleRate > 24000 || bDownSampledSbr) + { + SbrChannel[i].frameData.sbr_header.sampleRateMode = SINGLE_RATE; + } + + + SbrChannel[i].outFrameSize = + init_sbr_dec(sampleRate, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode, + sbrDec, + &(SbrChannel[i].frameData)); + + SbrChannel[i].syncState = UPSAMPLING; + + SbrChannel[i].frameData.sUp = 1; /* reset mode */ + } +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.h new file mode 100644 index 00000000..c625d7fb --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_open.h @@ -0,0 +1,109 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_open.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_OPEN_H +#define SBR_OPEN_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "s_sbr_channel.h" +#include "sbr_dec.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void sbr_open(Int32 sampleRate, + SBR_DEC *sbrDec, + SBRDECODER_DATA * self, + Bool bDownSampledSbr); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.c new file mode 100644 index 00000000..fb1adf5c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.c @@ -0,0 +1,319 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_read_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + INPUT + + SBRDECODER self, + SBRBITSTREAM * stream, + float *timeData, + int numChannels + + OUTPUT + + errorCode, noError if successful + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + sbr decoder processing, set up SBR decoder phase 2 in case of + different cotrol data + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_read_data.h" +#include "s_bit_buffer.h" +#include "buf_getbits.h" +#include "sbr_get_sce.h" +#include "sbr_get_cpe.h" +#include "sbr_reset_dec.h" +#include "sbr_get_header_data.h" +#include "sbr_crc_check.h" +#include "aac_mem_funcs.h" + + +#include "init_sbr_dec.h" /* !!! */ + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_read_data(SBRDECODER_DATA * self, + SBR_DEC * sbrDec, + SBRBITSTREAM *stream) +{ + SBR_ERROR sbr_err = SBRDEC_OK; + Int32 SbrFrameOK = 1; + Int32 sbrCRCAlwaysOn = 0; + + UInt32 bs_header_flag = 0; + + SBR_HEADER_STATUS headerStatus = HEADER_OK; + + SBR_CHANNEL *SbrChannel = self->SbrChannel; + + Int32 zeropadding_bits; + Int32 lr; + + BIT_BUFFER bitBuf ; + + /* + * evaluate Bitstream + */ + + bitBuf.buffer_word = 0; + bitBuf.buffered_bits = 0; + bitBuf.nrBitsRead = 0; + + bitBuf.char_ptr = stream->sbrElement[0].Data; + bitBuf.bufferLen = (stream->sbrElement[0].Payload) << 3; + + + /* + * we have to skip a nibble because the first element of Data only + * contains a nibble of data ! + */ + buf_getbits(&bitBuf, LEN_NIBBLE); + + if ((stream->sbrElement[0].ExtensionType == SBR_EXTENSION_CRC) || + sbrCRCAlwaysOn) + { + Int32 CRCLen = ((stream->sbrElement[0].Payload - 1) << 3) + 4 - SI_SBR_CRC_BITS; + SbrFrameOK = sbr_crc_check(&bitBuf, CRCLen); + } + + + if (SbrFrameOK) + { + /* + * The sbr data seems ok, if the header flag is set we read the header + * and check if vital parameters have changed since the previous frame. + * If the syncState equals UPSAMPLING, the SBR Tool has not been + * initialised by SBR header data, and can only do upsampling + */ + + bs_header_flag = buf_getbits(&bitBuf, 1); /* read Header flag */ + + if (bs_header_flag) + { + /* + * If syncState == SBR_ACTIVE, it means that we've had a SBR header + * before, and we will compare with the previous header to see if a + * reset is required. If the syncState equals UPSAMPLING this means + * that the SBR-Tool so far is only initialised to do upsampling + * and hence we need to do a reset, and initialise the system + * according to the present header. + */ + + headerStatus = sbr_get_header_data(&(SbrChannel[0].frameData.sbr_header), + &bitBuf, + SbrChannel[0].syncState); + } /* if (bs_header_flag) */ + + + switch (stream->sbrElement[0].ElementID) + { + case SBR_ID_SCE : + + /* change of control data, reset decoder */ + if (headerStatus == HEADER_RESET) + { + sbr_err = sbr_reset_dec(&(SbrChannel[0].frameData), + sbrDec, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode); + + if (sbr_err != SBRDEC_OK) + { + break; + } + /* + * At this point we have a header and the system has been reset, + * hence syncState from now on will be SBR_ACTIVE. + */ + SbrChannel[0].syncState = SBR_ACTIVE; + } + + if ((SbrChannel[0].syncState == SBR_ACTIVE)) + { + sbr_err = sbr_get_sce(&(SbrChannel[0].frameData), + &bitBuf +#ifdef PARAMETRICSTEREO + , self->hParametricStereoDec +#endif + ); + + if (sbr_err != SBRDEC_OK) + { + break; + } + } + + break; + + case SBR_ID_CPE : + + if (bs_header_flag) + { + pv_memcpy(&(SbrChannel[1].frameData.sbr_header), + &(SbrChannel[0].frameData.sbr_header), + sizeof(SBR_HEADER_DATA)); + } + + /* change of control data, reset decoder */ + if (headerStatus == HEADER_RESET) + { + for (lr = 0 ; lr < 2 ; lr++) + { + sbr_err = sbr_reset_dec(&(SbrChannel[lr].frameData), + sbrDec, + self->SbrChannel[0].frameData.sbr_header.sampleRateMode); + + if (sbr_err != SBRDEC_OK) + { + break; + } + + SbrChannel[lr].syncState = SBR_ACTIVE; + } + } + + if (SbrChannel[0].syncState == SBR_ACTIVE) + { + sbr_err = sbr_get_cpe(&(SbrChannel[0].frameData), + &(SbrChannel[1].frameData), + &bitBuf); + + if (sbr_err != SBRDEC_OK) + { + break; + } + + } + break; + + default: + sbr_err = SBRDEC_ILLEGAL_PLUS_ELE_ID; + break; + } + + } /* if (SbrFrameOK) */ + + /* + * Check that the bits read did not go beyond SBR frame boundaries + */ + + zeropadding_bits = (8 - (bitBuf.nrBitsRead & 0x7)) & 0x7; + + if ((bitBuf.nrBitsRead + zeropadding_bits) > bitBuf.bufferLen) + { + sbr_err = SBRDEC_INVALID_BITSTREAM; + } + + return sbr_err; +} + + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.h new file mode 100644 index 00000000..b12f8c22 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_read_data.h @@ -0,0 +1,121 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_read_data.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_READ_DATA +#define SBR_READ_DATA + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_sbr_error.h" +#include "s_sbr_channel.h" +#include "s_sbrbitstream.h" +#include "sbr_dec.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + SBR_ERROR sbr_read_data(SBRDECODER_DATA * self, + SBR_DEC * sbrDec, + SBRBITSTREAM *stream); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.c new file mode 100644 index 00000000..050935b4 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.c @@ -0,0 +1,177 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_requantize_envelope_data.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_constants.h" +#include "sbr_requantize_envelope_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define R_SHIFT 30 +#define Qfmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData) + +{ + Int32 i; + + + Int32 nScaleFactors = hFrameData->nScaleFactors; + Int32 nNoiseFactors = hFrameData->nNoiseFactors; + Int32 ampRes = hFrameData->ampRes; + Int32 *iEnvelope_man = hFrameData->iEnvelope_man; + Int32 *iEnvelope_exp = hFrameData->iEnvelope_exp; + Int32 *sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man; + Int32 *sbrNoiseFloorLevel_exp = hFrameData->sbrNoiseFloorLevel_exp; + + /* + * ampRes could be 0 (resolution step = 1.5 dB) or + * 1 (resolution step = 3 dB) + */ + if (ampRes) + { + /* iEnvelope[i] always positive 6 bits max */ + for (i = 0; i < nScaleFactors; i++) + { + + iEnvelope_exp[i] = iEnvelope_man[i] + 6; + iEnvelope_man[i] = Qfmt(1.000F); + } + } + else + { + /* iEnvelope[i] always positive 7 bits max */ + for (i = 0; i < nScaleFactors; i++) + { + iEnvelope_exp[i] = (iEnvelope_man[i] >> 1) + 6; + if (iEnvelope_man[i] & 0x1) /* odd */ + { + iEnvelope_man[i] = Qfmt(1.41421356237310F); + } + else + { + iEnvelope_man[i] = Qfmt(1.000F); + } + } + + } + for (i = 0; i < nNoiseFactors; i++) + { + /* sbrNoiseFloorLevel[i] varies from -31 to 31 if no coupling is used */ + + sbrNoiseFloorLevel_exp[i] = NOISE_FLOOR_OFFSET - sbrNoiseFloorLevel_man[i]; + sbrNoiseFloorLevel_man[i] = 0x40000000; + } +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.h new file mode 100644 index 00000000..61d889aa --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_requantize_envelope_data.h @@ -0,0 +1,74 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_requantize_envelope_data.h + +---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_REQUANTIZE_ENVELOPE_DATA_H +#define SBR_REQUANTIZE_ENVELOPE_DATA_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sbr_frame_data.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.c new file mode 100644 index 00000000..790ef275 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.c @@ -0,0 +1,263 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_reset_dec.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + resets sbr decoder structure +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" +#ifdef AAC_PLUS + +#include "sbr_dec.h" + +#include "pv_log2.h" +#include "fxp_mul32.h" + + +#include "sbr_reset_dec.h" +#include "sbr_find_start_andstop_band.h" +#include "sbr_update_freq_scale.h" +#include "sbr_downsample_lo_res.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData, + SBR_DEC * sbrDec, + Int32 upsampleFac) +{ + + SBR_ERROR err = SBRDEC_OK; + Int lsbM; + Int lsb; + Int usb; + Int32 i; + Int32 tmp_q1; + + SBR_HEADER_DATA *headerData = &(hFrameData->sbr_header); + Int32 samplingFreq = sbrDec->outSampleRate; + + hFrameData->reset_flag = 1; + + /*Calculate master frequency function */ + err = sbr_find_start_andstop_band(samplingFreq, + headerData->startFreq, + headerData->stopFreq, + &lsbM, + &usb); + + if (err != SBRDEC_OK) + { + return err; + } + + /* Calculate new v_k_master if needed */ + if (headerData->masterStatus == MASTER_RESET) + { + sbr_update_freq_scale(sbrDec->V_k_master, + &(sbrDec->Num_Master), + lsbM, + usb, + headerData->freqScale, + headerData->alterScale, + 0); + + } + + /*Derive Hiresolution from master frequency function*/ + + sbrDec->NSfb[HI] = sbrDec->Num_Master - headerData->xover_band; + + for (i = headerData->xover_band; i <= sbrDec->Num_Master; i++) + { + sbrDec->FreqBandTable[HI][i-headerData->xover_band] = (Int)sbrDec->V_k_master[i]; + } + + + if ((sbrDec->NSfb[HI] & 0x01) == 0) /* if even number of hires bands */ + { + + sbrDec->NSfb[LO] = sbrDec->NSfb[HI] >> 1; + /* Use every second lo-res=hi-res[0,2,4...] */ + for (i = 0; i <= sbrDec->NSfb[LO]; i++) + { + sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)]; + } + } + else + { /* odd number of hi-res which means xover is odd */ + + sbrDec->NSfb[LO] = (sbrDec->NSfb[HI] + 1) >> 1; + /* Use lo-res=hi-res[0,1,3,5 ...] */ + sbrDec->FreqBandTable[LO][0] = sbrDec->FreqBandTable[HI][0]; + for (i = 1; i <= sbrDec->NSfb[LO]; i++) + { + sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)-1]; + } + + } + + lsb = sbrDec->FreqBandTable[LOW_RES][0]; + usb = sbrDec->FreqBandTable[LOW_RES][sbrDec->NSfb[LOW_RES]]; + + sbrDec->lowSubband = lsb; + sbrDec->highSubband = usb; + sbrDec->noSubbands = usb - lsb; + + if ((lsb > 32) || (sbrDec->noSubbands <= 0)) + { + return SBRDEC_ILLEGAL_SCFACTORS; /* invalid bands */ + } + + /* Calculate number of noise bands */ + if (headerData->noise_bands == 0) + { + sbrDec->NoNoiseBands = 1; + } + else /* Calculate number of noise bands 1,2 or 3 bands/octave */ + { + + if (! lsb) + { + return SBRDEC_ILLEGAL_SCFACTORS; /* avoid div by 0 */ + } + + tmp_q1 = pv_log2((usb << 20) / lsb); + + tmp_q1 = fxp_mul32_Q15(headerData->noise_bands, tmp_q1); + + sbrDec->NoNoiseBands = (tmp_q1 + 16) >> 5; + + if (sbrDec->NoNoiseBands == 0) + { + sbrDec->NoNoiseBands = 1; + } + } + + headerData->noNoiseBands = sbrDec->NoNoiseBands; + + /* Get noise bands */ + sbr_downsample_lo_res(sbrDec->FreqBandTableNoise, + sbrDec->NoNoiseBands, + sbrDec->FreqBandTable[LO], + sbrDec->NSfb[LO]); + + sbrDec->sbStopCodec = sbrDec->lowSubband; + + if (sbrDec->sbStopCodec > (upsampleFac << 5)) + { + sbrDec->sbStopCodec = (upsampleFac << 5); + } + + hFrameData->nSfb[LO] = sbrDec->NSfb[LO]; + hFrameData->nSfb[HI] = sbrDec->NSfb[HI]; + hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands; + hFrameData->offset = ((hFrameData->nSfb[LO]) << 1) - hFrameData->nSfb[HI]; + + return (SBRDEC_OK); +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.h new file mode 100644 index 00000000..2dc0416f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_reset_dec.h @@ -0,0 +1,112 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_reset_dec.h + Functions: + get_dse + +------------------------------------------------------------------------------ +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + + $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_RESET_DEC_H +#define SBR_RESET_DEC_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "s_sbr_frame_data.h" +#include "sbr_dec.h" +#include "e_sbr_error.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData, + SBR_DEC * sbrDec, + Int32 upsampleFac); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.c new file mode 100644 index 00000000..5a95ea1f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.c @@ -0,0 +1,358 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_update_freq_scale.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +SC 29 Software Copyright Licencing Disclaimer: + +This software module was originally developed by + Coding Technologies + +and edited by + - + +in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 +standards for reference purposes and its performance may not have been +optimized. This software module is an implementation of one or more tools as +specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards. +ISO/IEC gives users free license to this software module or modifications +thereof for use in products claiming conformance to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International +Standards. ISO/IEC gives users the same free license to this software module or +modifications thereof for research purposes and further ISO/IEC standardisation. +Those intending to use this software module in products are advised that its +use may infringe existing patents. ISO/IEC have no liability for use of this +software module or modifications thereof. Copyright is not released for +products that do not conform to audiovisual and image-coding related ITU +Recommendations and/or ISO/IEC International Standards. +The original developer retains full right to modify and use the code for its +own purpose, assign or donate the code to a third party and to inhibit third +parties from using the code for products that do not conform to audiovisual and +image-coding related ITU Recommendations and/or ISO/IEC International Standards. +This copyright notice must be included in all copies or derivative works. +Copyright (c) ISO/IEC 2002. + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "sbr_update_freq_scale.h" +#include "shellsort.h" + +#include "pv_pow2.h" +#include "pv_log2.h" + +#include "fxp_mul32.h" +#define R_SHIFT 30 +#define Q_fmt(x) (Int32)(x*((Int32)1<=0?0.5F:-0.5F)) +#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F)) + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void sbr_update_freq_scale(Int32 * v_k_master, + Int32 *h_num_bands, + const Int32 lsbM, + const Int32 usb, + const Int32 freqScale, + const Int32 alterScale, + const Int32 channelOffset) +{ + Int32 i; + Int32 numBands = 0; + Int32 numBands2; + Int32 tmp_q1; + + if (freqScale > 0) /*Bark mode*/ + { + Int32 reg; + Int32 regions; + Int32 b_p_o; + Int32 k[3]; + Int32 d[MAX_SECOND_REGION]; + Int32 d2[MAX_SECOND_REGION]; + Int32 w[2] = {Q_fmt(1.0F), Q_fmt(1.0F)}; + + + k[0] = lsbM; + k[1] = usb; + k[2] = usb; + + b_p_o = (freqScale == 1) ? 12 : 8; + b_p_o = (freqScale == 2) ? 10 : b_p_o; + + w[1] = (alterScale == 0) ? Q_fmt(0.5f) : Q_fmt(0.384615384615386f); + + if (usb > fxp_mul32_Q28(lsbM, Q28fmt(2.2449))) + { + regions = 2; + k[1] = (lsbM << 1); + } + else + { + regions = 1; + } + + *h_num_bands = 0; + for (reg = 0; reg < regions; reg++) + { + if (reg == 0) + { + + tmp_q1 = pv_log2((k[1] << 20) / k[0]); + + tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o); + tmp_q1 = (tmp_q1 + 32) >> 6; + + numBands = tmp_q1 << 1; + + + CalcBands(d, k[0], k[1], numBands); /* CalcBands => d */ + shellsort(d, numBands); /* SortBands sort d */ + cumSum(k[0] - channelOffset, + d, + numBands, + (v_k_master + *h_num_bands)); /* cumsum */ + + *h_num_bands += numBands; /* Output nr of bands */ + } + else + { + tmp_q1 = pv_log2((k[reg + 1] << 20) / k[reg]); + + tmp_q1 = fxp_mul32_Q30(tmp_q1, w[reg]); + tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o); + tmp_q1 = (tmp_q1 + 16) >> 5; + + numBands2 = tmp_q1 << 1; + + CalcBands(d2, k[reg], k[reg+1], numBands2); /* CalcBands => d */ + shellsort(d2, numBands2); /* SortBands sort d */ + if (d[numBands-1] > d2[0]) + { + + Int32 change = d[numBands-1] - d2[0]; + /* Limit the change so that the last band cannot get narrower than the first one */ + if (change > (d2[numBands2-1] - d2[0]) >> 1) + { + change = (d2[numBands2-1] - d2[0]) >> 1; + } + + d2[0] += change; + d2[numBands2-1] -= change; + shellsort(d2, numBands2); + + } + cumSum(k[reg] - channelOffset, + d2, + numBands2, + v_k_master + *h_num_bands); /* cumsum */ + + *h_num_bands += numBands2; /* Output nr of bands */ + } + } + } + else + { /* Linear mode */ + Int32 k2_achived; + Int32 k2_diff; + Int32 diff_tot[MAX_OCTAVE + MAX_SECOND_REGION]; + Int32 dk; + Int32 incr = 0; + + + if (alterScale) + { + numBands = (usb - lsbM) >> 1; + dk = 1; + k2_achived = lsbM + numBands; + } + else + { + numBands = usb - lsbM; + if (numBands & 0x1) /* equivalent rounding */ + { + numBands--; + } + dk = 2; + k2_achived = lsbM + (numBands << 1); + } + + k2_diff = usb - k2_achived; + + for (i = 0; i < numBands; i++) + { + diff_tot[i] = dk; + } + + if (k2_diff < 0) /* If linear scale wasn't achived */ + { + incr = 1; /* and we got too large SBR area */ + i = 0; + } + + if (k2_diff > 0) /* If linear scale wasn't achived */ + { + incr = -1; /* and we got too small SBR area */ + i = numBands - 1; + } + + /* Adjust diff vector to get spec. SBR range */ + while (k2_diff != 0) + { + diff_tot[i] -= incr; + i += incr; + k2_diff += incr; + } + + cumSum(lsbM, + diff_tot, + numBands, + v_k_master); /* cumsum */ + + *h_num_bands = numBands; /* Output nr of bands */ + } +} + + +void CalcBands(Int32 * diff, + Int32 start, + Int32 stop, + Int32 num_bands) +{ + Int32 i; + Int32 previous; + Int32 current; + Int32 tmp_q1; + + + previous = start; + + for (i = 1; i <= num_bands; i++) + { + /* float temp=(start * pow( (float)stop/start, (float)i/num_bands)); */ + + tmp_q1 = pv_log2((stop << 20) / start); + + tmp_q1 = fxp_mul32_Q20(tmp_q1, (i << 27) / num_bands); + tmp_q1 = pv_pow2(tmp_q1); + + tmp_q1 = fxp_mul32_Q20(tmp_q1, start); + + current = (tmp_q1 + 16) >> 5; + + diff[i-1] = current - previous; + previous = current; + } + +} /* End CalcBands */ + + +void cumSum(Int32 start_value, + Int32 * diff, + Int32 length, + Int32 * start_adress) +{ + Int32 i; + Int32 *pt_start_adress = start_adress; + Int32 *pt_start_adress_1 = start_adress; + Int32 *pt_diff = diff; + + if (length > 0) /* avoid possible error on loop */ + { + *(pt_start_adress_1++) = start_value; + + for (i = (length >> 1); i != 0; i--) + { + *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++); + *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++); + } + + if (length&1) + { + *(pt_start_adress_1) = *(pt_start_adress) + *(pt_diff); + } + } + +} /* End cumSum */ + + +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.h new file mode 100644 index 00000000..221460d3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sbr_update_freq_scale.h @@ -0,0 +1,95 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sbr_update_freq_scale.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SBR_UPDATE_FREQ_SCALE_H +#define SBR_UPDATE_FREQ_SCALE_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define MAX_OCTAVE 29 +#define MAX_SECOND_REGION 50 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void sbr_update_freq_scale(Int32 * v_k_master, + Int32 *h_num_bands, + const Int32 lsbM, + const Int32 usb, + const Int32 freqScale, + const Int32 alterScale, + const Int32 channelOffset); + + +void CalcBands(Int32 * diff, + Int32 start, + Int32 stop, + Int32 num_bands); + +void cumSum(Int32 start_value, + Int32 * diff, + Int32 length, + Int32 * start_adress); + + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.c new file mode 100644 index 00000000..ce70b8d7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.c @@ -0,0 +1,277 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: set_mc_info.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + pMC_Info = pointer to structure MC_Info that holds information of + multiple channels' configurations + Data type pointer to MC_Info + + objectType = variable that holds the Audio Object Type of current + file/bitstream. + Data type Int + + sampling_rate_idx = variable that indicates the sampling rate of the + source file being encoded + Data Type Int + + tag = variable that stores the element instance tag of the + first (front) channel element. + Data type Int + + is_cpe = variable that indicates if a Channel Pair Element (CPE) + or a Single Channel Element (SCE) is used. + Data type Int (maybe Boolean) + + pWinSeqInfo = array of pointers that points to structures holding + frame information of long and short window sequences. + Data type FrameInfo + + pSfbwidth128 = array that will store the scalefactor bandwidth of + short window sequence frame. + Data type Int array + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + return SUCCESS + + Pointers and Buffers Modified: + pMC_Info->nch contains the number of channels depending + upon if CPE or SCE is used + pMC_Info->objectType contents updated with the decoded Audio + Object Type + + pMC_Info->ch_info.tag contents updated with the value of decoded + channel element tag + + PMC_Info->ch_info.cpe contents updated depending upon if CPE or + SCE is used + + pWinSeqInfo contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + pSfbWidth128 contents updated by calling infoinit if + sampling_rate_idx is different from + previous value + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function initializes the channel configuration information. The + structure MC_Info stores the number of channels, channel element tag. + If sampling rate index is different from the previous value, + The frame information will be updated by calling infoinit.c + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall update the relevant information on channel configs + +------------------------------------------------------------------------------ + REFERENCES + + (1) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + + (2) ISO/IEC 14496-3: 1999(E) + Subpart 1 p20 Table 1.6.3 + Subpart 4 p30 5.1.2.1 + Subpart 4 p31 4.5.2.1.1 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + pMC_Info->nch = 0; + + pMC_Info->profile = objectType; + + IF (pMC_Info->sampling_rate_idx != sampling_rate_idx) + THEN + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + CALL infoinit( + samp_rate_idx = sampling_rate_idx + ppWin_seq_info= pWinSeqInfo + pSfbwidth128 = pSfbwidth128) + MODIFYING(pWinSeqInfo, pSfbwidth128) + RETURNING(None) + ENDIF + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + + IF (is_cpe == FALSE) + THEN + pCh_Info->cpe = FALSE; + + pMC_Info->nch = 1; + + ELSE + pCh_Info->cpe = TRUE; + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->tag = tag; + pCh_Info->cpe = TRUE; + + pMC_Info->nch = 2; + + ENDIF + + RETURN(SUCCESS) + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "set_mc_info.h" +#include "huffman.h" +#include "s_ch_info.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +Int set_mc_info( + MC_Info *pMC_Info, + const tMP4AudioObjectType audioObjectType, /* used to be profile */ + const Int sampling_rate_idx, + const Int tag, /* always pass-in last element's value */ + const Int is_cpe, + FrameInfo *pWinSeqInfo[], + Int sfbwidth128[] +) +{ + Ch_Info *pCh_Info; /*optional task: eliminate this structure */ + + /* + * audioObjectType and sampling rate + * re-configure if new sampling rate + * + */ + pMC_Info->audioObjectType = audioObjectType; + + if (pMC_Info->sampling_rate_idx != sampling_rate_idx) + { + pMC_Info->sampling_rate_idx = sampling_rate_idx; + + Int status; + status = infoinit(sampling_rate_idx, + pWinSeqInfo, + sfbwidth128); + if (SUCCESS != status) + { + return 1; + } + } + + /* + * first setup values for mono config, Single Channel Element (SCE) + * then if stereo, go inside if(is_cpe != FALSE) branch to setup + * values for stereo. + * set the channel counts + * save tag for left channel + */ + pMC_Info->nch = 1 + is_cpe; + + pCh_Info = &pMC_Info->ch_info[0]; + pCh_Info->tag = tag; + pCh_Info->cpe = is_cpe; + + /* This if branch maybe deleted in the future */ + if (is_cpe != FALSE) + { + /* Channel Pair Element (CPE) */ + /* right channel*/ + pCh_Info = &pMC_Info->ch_info[1]; + pCh_Info->cpe = TRUE; + + } + + return(SUCCESS); /* possible future error checkings */ +} diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.h new file mode 100644 index 00000000..8d8cf16c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/set_mc_info.h @@ -0,0 +1,89 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: set_mc_info.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This file includes function declaration for set_mc_info.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SET_MC_INFO_H +#define SET_MC_INFO_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_mc_info.h" +#include "s_frameinfo.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +Int set_mc_info( + MC_Info *pMC_Info, + const tMP4AudioObjectType objectType, /* used to be profile */ + const Int sampling_rate_idx, + const Int tag, /* always pass-in last element's value */ + const Int is_cpe, + FrameInfo *pWinSeqInfo[], + Int pSfbwidth128[] +); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.c new file mode 100644 index 00000000..6a0cff08 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.c @@ -0,0 +1,234 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sfb.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + Local Stores/Buffers/Pointers Needed: + + Global Stores/Buffers/Pointers Needed: + + Outputs: + + Pointers and Buffers Modified: + + + Local Stores Modified: + + Global Stores Modified: + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function defines the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3: 1999(E) + Subpart 4 p66 (sfb tables) + p111 (4.6.10) + p200 (Annex 4.B.5) + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "sfb.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +const Int16 sfb_96_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 96, 108, 120, + 132, 144, 156, 172, 188, 212, 240, + 276, 320, 384, 448, 512, 576, 640, + 704, 768, 832, 896, 960, 1024 +}; /* 41 scfbands */ + +const Int16 sfb_64_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, + 64, 72, 80, 88, 100, 112, 124, + 140, 156, 172, 192, 216, 240, 268, + 304, 344, 384, 424, 464, 504, 544, + 584, 624, 664, 704, 744, 784, 824, + 864, 904, 944, 984, 1024 +}; /* 41 scfbands 47 */ + +const Int16 sfb_64_128[] = +{ + 4, 8, 12, 16, 20, 24, 32, + 40, 48, 64, 92, 128 +}; /* 12 scfbands */ + + +const Int16 sfb_48_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 1024 +}; +/* 49 scfbands*/ + +const Int16 sfb_48_128[] = +{ + 4, 8, 12, 16, 20, 28, 36, + 44, 56, 68, 80, 96, 112, 128 +}; /* 14 scfbands */ + +const Int16 sfb_32_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 48, 56, 64, 72, + 80, 88, 96, 108, 120, 132, 144, + 160, 176, 196, 216, 240, 264, 292, + 320, 352, 384, 416, 448, 480, 512, + 544, 576, 608, 640, 672, 704, 736, + 768, 800, 832, 864, 896, 928, 960, + 992, 1024 +}; /* 51 scfbands */ + +const Int16 sfb_24_1024[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 52, 60, 68, + 76, 84, 92, 100, 108, 116, 124, + 136, 148, 160, 172, 188, 204, 220, + 240, 260, 284, 308, 336, 364, 396, + 432, 468, 508, 552, 600, 652, 704, + 768, 832, 896, 960, 1024 +}; /* 47 scfbands */ + +const Int16 sfb_24_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 64, 76, 92, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_16_1024[] = +{ + 8, 16, 24, 32, 40, 48, 56, + 64, 72, 80, 88, 100, 112, 124, + 136, 148, 160, 172, 184, 196, 212, + 228, 244, 260, 280, 300, 320, 344, + 368, 396, 424, 456, 492, 532, 572, + 616, 664, 716, 772, 832, 896, 960, + 1024 +}; /* 43 scfbands */ + +const Int16 sfb_16_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 32, 40, 48, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const Int16 sfb_8_1024[] = +{ + 12, 24, 36, 48, 60, 72, 84, + 96, 108, 120, 132, 144, 156, 172, + 188, 204, 220, 236, 252, 268, 288, + 308, 328, 348, 372, 396, 420, 448, + 476, 508, 544, 580, 620, 664, 712, + 764, 820, 880, 944, 1024 +}; /* 40 scfbands */ + +const Int16 sfb_8_128[] = +{ + 4, 8, 12, 16, 20, 24, 28, + 36, 44, 52, 60, 72, 88, 108, + 128 +}; /* 15 scfbands */ + +const SR_Info samp_rate_info[12] = +{ + /* sampling_frequency, #long sfb, #short sfb */ + /* samp_rate, nsfb1024, nsfb128 */ + {96000, 41, 12}, /* 96000 */ + {88200, 41, 12}, /* 88200 */ + {64000, 47, 12}, /* 64000 */ + {48000, 49, 14}, /* 48000 */ + {44100, 49, 14}, /* 44100 */ + {32000, 51, 14}, /* 32000 */ + {24000, 47, 15}, /* 24000 */ + {22050, 47, 15}, /* 22050 */ + {16000, 43, 15}, /* 16000 */ + {12000, 43, 15}, /* 12000 */ + {11025, 43, 15}, /* 11025 */ + { 8000, 40, 15}, /* 8000 */ +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.h new file mode 100644 index 00000000..179e88c3 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/sfb.h @@ -0,0 +1,107 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: sfb.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + this file declares the scalefactor bands for all sampling rates + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SFB_H +#define SFB_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_sr_info.h" +#include "e_progconfigconst.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ +extern const Int16 sfb_96_1024[]; /* 41 scfbands */ + +extern const Int16 sfb_64_1024[]; /* 41 scfbands 47 */ + +extern const Int16 sfb_64_128[]; /* 12 scfbands */ + + +extern const Int16 sfb_48_1024[]; /* 49 scfbands */ + +extern const Int16 sfb_48_128[]; /* 14 scfbands */ + +extern const Int16 sfb_32_1024[]; /* 51 scfbands */ + +extern const Int16 sfb_24_1024[]; /* 47 scfbands */ + +extern const Int16 sfb_24_128[]; /* 15 scfbands */ + +extern const Int16 sfb_16_1024[]; /* 43 scfbands */ + +extern const Int16 sfb_16_128[]; /* 15 scfbands */ + +extern const Int16 sfb_8_1024[]; /* 40 scfbands */ + +extern const Int16 sfb_8_128[]; /* 15 scfbands */ + +extern const SR_Info samp_rate_info[12]; + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.c new file mode 100644 index 00000000..a9dc87c9 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.c @@ -0,0 +1,132 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: shellsort.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Sorting routine +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + + + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "shellsort.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + +void shellsort(Int32 in[], Int32 n) +{ + + Int32 i; + Int32 j; + Int32 v; + Int32 inc = 1; + + do + { + inc = 3 * inc + 1; + } + while (inc <= n); + + do + { + inc = inc / 3; + for (i = inc + 1; i <= n; i++) + { + v = in[i-1]; + j = i; + while (in[j-inc-1] > v) + { + in[j-1] = in[j-inc-1]; + j -= inc; + if (j <= inc) + { + break; + } + } + in[j-1] = v; + } + } + while (inc > 1); + +} + +#endif + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.h new file mode 100644 index 00000000..21d2dc4f --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/shellsort.h @@ -0,0 +1,75 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: shellsort.h + Functions: + get_dse + + ---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef SHELLSORT_H +#define SHELLSORT_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +void shellsort(Int32 in[], Int32 n); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.c new file mode 100644 index 00000000..8e8fbc62 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.c @@ -0,0 +1,477 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: synthesis_sub_band.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Int32 vec[], Input vector, 32-bit + const Int32 *cosTerms, Cosine Terms + Int32 *scratch_mem Scratch memory + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + Implement root squared of a number + +------------------------------------------------------------------------------ + REQUIREMENTS + + +------------------------------------------------------------------------------ + REFERENCES + +------------------------------------------------------------------------------ + PSEUDO-CODE + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +#include "pv_audio_type_defs.h" +#include "fxp_mul32.h" +#include "dct64.h" +#include "synthesis_sub_band.h" +#include "mdst.h" +#include "dct16.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +#define Qfmt_30(x) (Int32)(x*((Int32)(1<<30)) + (x>=0?0.5F:-0.5F)) +#define Qfmt_25(x) (Int32)(x*((Int32)(1<<25))*(1.5625F) + (x>=0?0.5F:-0.5F)) + +#define SCALE_DOWN_LP Qfmt_30(0.075000F) /* 3/40 */ +#define SCALE_DOWN_HQ Qfmt_30(0.009375F*0.64F) /* 3/40 * 1/8 */ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +const Int32 CosTable_64[64] = +{ + Qfmt_25(0.50003765191555F), Qfmt_25(40.74468810335183F), Qfmt_25(0.50033903744282F), Qfmt_25(13.58429025728446F), + Qfmt_25(0.50094271763809F), Qfmt_25(8.15384860246681F), Qfmt_25(0.50185051748424F), Qfmt_25(5.82768837784465F), + Qfmt_25(0.50306519130137F), Qfmt_25(4.53629093696936F), Qfmt_25(0.50459044322165F), Qfmt_25(3.71524273832697F), + Qfmt_25(0.50643095492855F), Qfmt_25(3.14746219178191F), Qfmt_25(0.50859242104981F), Qfmt_25(2.73164502877394F), + Qfmt_25(0.51108159270668F), Qfmt_25(2.41416000025008F), Qfmt_25(0.51390632984754F), Qfmt_25(2.16395781875198F), + Qfmt_25(0.51707566313349F), Qfmt_25(1.96181784857117F), Qfmt_25(0.52059986630189F), Qfmt_25(1.79520521907789F), + Qfmt_25(0.52449054011472F), Qfmt_25(1.65559652426412F), Qfmt_25(0.52876070920749F), Qfmt_25(1.53699410085250F), + Qfmt_25(0.53342493339713F), Qfmt_25(1.43505508844143F), Qfmt_25(0.53849943529198F), Qfmt_25(1.34655762820629F), + Qfmt_25(0.54400224638178F), Qfmt_25(1.26906117169912F), Qfmt_25(0.54995337418324F), Qfmt_25(1.20068325572942F), + Qfmt_25(0.55637499348989F), Qfmt_25(1.13994867510150F), Qfmt_25(0.56329166534170F), Qfmt_25(1.08568506425801F), + Qfmt_25(0.57073058801215F), Qfmt_25(1.03694904091039F), Qfmt_25(0.57872188513482F), Qfmt_25(0.99297296126755F), + Qfmt_25(0.58729893709379F), Qfmt_25(0.95312587439212F), Qfmt_25(0.59649876302446F), Qfmt_25(0.91688444618465F), + Qfmt_25(0.60636246227215F), Qfmt_25(0.88381100455962F), Qfmt_25(0.61693572600507F), Qfmt_25(0.85353675100661F), + Qfmt_25(0.62826943197077F), Qfmt_25(0.82574877386279F), Qfmt_25(0.64042033824166F), Qfmt_25(0.80017989562169F), + Qfmt_25(0.65345189537513F), Qfmt_25(0.77660065823396F), Qfmt_25(0.66743520092634F), Qfmt_25(0.75481293911653F), + Qfmt_25(0.68245012597642F), Qfmt_25(0.73464482364786F), Qfmt_25(0.69858665064723F), Qfmt_25(0.71594645497057F), +}; + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]) +{ + + Int32 *temp_o1 = (Int32 *) & data[0]; + + Int i; + Int32 *pt_temp_e; + Int32 *pt_temp_o = temp_o1; + Int32 *pt_temp_x = &Sr[63]; + Int32 temp1; + Int32 temp2; + Int32 temp3; + Int32 temp11; + + Int16 *pt_data_1; + Int16 *pt_data_2; + + Int32 *pt_Sr_1 = Sr; + Int16 tmp1; + Int16 tmp2; + Int16 tmp11; + Int16 tmp22; + const Int32 *pt_cosTerms = CosTable_48; + + + temp2 = *(pt_temp_x--); + for (i = 20; i != 0; i--) + { + temp1 = *(pt_Sr_1); + temp3 = *(pt_cosTerms++); + *(pt_Sr_1++) = temp1 + temp2; + *(pt_temp_o++) = fxp_mul32_Q31((temp1 - temp2), temp3) << 1; + temp2 = *(pt_temp_x--); + } + + for (i = 12; i != 0; i--) + { + temp1 = *(pt_Sr_1); + temp3 = *(pt_cosTerms++); + *(pt_Sr_1++) = temp1 + temp2; + *(pt_temp_o++) = fxp_mul32_Q26((temp1 - temp2), temp3); + temp2 = *(pt_temp_x--); + } + + + pv_split_LC(temp_o1, &Sr[32]); + + dct_16(temp_o1, 1); // Even terms + dct_16(&Sr[32], 1); // Odd terms + + /* merge */ + + + pt_Sr_1 = &temp_o1[31]; + pt_temp_e = &temp_o1[15]; + pt_temp_o = &Sr[47]; + + temp1 = *(pt_temp_o--); + *(pt_Sr_1--) = temp1; + for (i = 5; i != 0; i--) + { + temp2 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp1 + temp2; + temp3 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp2 + temp3; + temp1 = *(pt_temp_o--); + *(pt_Sr_1--) = *(pt_temp_e--); + *(pt_Sr_1--) = temp1 + temp3; + } + + + pv_split_LC(Sr, &Sr[32]); + + dct_16(Sr, 1); // Even terms + dct_16(&Sr[32], 1); // Odd terms + + + pt_temp_x = &temp_o1[31]; + pt_temp_e = &Sr[15]; + pt_temp_o = &Sr[47]; + + pt_data_1 = &data[95]; + + temp2 = *(pt_temp_x--); + temp11 = *(pt_temp_x--); + temp1 = *(pt_temp_o--); + + *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp2, SCALE_DOWN_LP); + *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp1, SCALE_DOWN_LP); + + for (i = 5; i != 0; i--) + { + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP); + temp3 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP); + temp2 = *(pt_temp_o--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp2), SCALE_DOWN_LP); + + + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP); + temp1 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP); + temp3 = *(pt_temp_o--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp2 + temp3), SCALE_DOWN_LP); + + + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP); + temp2 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP); + temp1 = *(pt_temp_o--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP); + temp11 = *(pt_temp_x--); + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp3), SCALE_DOWN_LP); + } + + *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP); + *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e), SCALE_DOWN_LP); + + /* ---- merge ends---- */ + + + pt_data_1 = &data[95]; + pt_data_2 = &data[96]; + + *(pt_data_2++) = 0; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + + for (i = 7; i != 0; i--) + { + *(pt_data_2++) = (-tmp1); + *(pt_data_2++) = (-tmp2); + *(pt_data_2++) = (-tmp11); + *(pt_data_2++) = (-tmp22); + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + } + + + *(pt_data_2++) = (-tmp1); + *(pt_data_2++) = (-tmp2); + *(pt_data_2++) = (-tmp11); + + pt_data_2 = &data[0]; + + *(pt_data_2++) = tmp22; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + + for (i = 7; i != 0; i--) + { + *(pt_data_2++) = tmp1; + *(pt_data_2++) = tmp2; + *(pt_data_2++) = tmp11; + *(pt_data_2++) = tmp22; + tmp1 = *(pt_data_1--); + tmp2 = *(pt_data_1--); + tmp11 = *(pt_data_1--); + tmp22 = *(pt_data_1--); + } + + *(pt_data_2++) = tmp1; + *(pt_data_2++) = tmp2; + *(pt_data_2++) = tmp11; + *(pt_data_2) = tmp22; + +} + + +void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]) +{ + + Int i ; + Int16 *pt_data_1; + + pt_data_1 = &data[0]; + + dct_32(Sr); + + for (i = 0; i < 16; i++) + { + pt_data_1[ i] = (Int16)(Sr[16-i] >> 5); + pt_data_1[16+i] = (Int16)(Sr[i] >> 5); + pt_data_1[32+i] = (Int16)(Sr[16+i] >> 5); + } + for (i = 0; i < 15; i++) + { + pt_data_1[49+i] = (Int16)(-Sr[31-i] >> 5); + } + pt_data_1[48] = 0; +} + + +#ifdef HQ_SBR + +void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]) +{ + + + Int32 i ; + Int16 *pt_data_1; + Int16 *pt_data_2; + Int32 *pt_Sr_1; + Int32 *pt_Sr_2; + Int32 *pt_Si_1; + Int32 *pt_Si_2; + + Int32 tmp1; + Int32 tmp2; + Int32 tmp3; + Int32 tmp4; + + Int32 cosx; + const Int32 *pt_CosTable = CosTable_64; + + + pt_Sr_1 = &Sr[0]; + pt_Sr_2 = &Sr[63]; + + pt_Si_1 = &Si[0]; + pt_Si_2 = &Si[63]; + + + tmp3 = *pt_Sr_1; + + for (i = 32; i != 0; i--) + { + tmp4 = *pt_Si_2; + cosx = *(pt_CosTable++); + *(pt_Sr_1++) = fxp_mul32_Q31(tmp3, cosx); + tmp3 = *pt_Si_1; + *(pt_Si_1++) = fxp_mul32_Q31(tmp4, cosx); + tmp4 = *pt_Sr_2; + cosx = *(pt_CosTable++); + *(pt_Si_2--) = fxp_mul32_Q31(tmp3, cosx); + *(pt_Sr_2--) = fxp_mul32_Q31(tmp4, cosx); + tmp3 = *pt_Sr_1; + } + + + dct_64(Sr, (Int32 *)data); + dct_64(Si, (Int32 *)data); + + + pt_data_1 = &data[0]; + pt_data_2 = &data[127]; + + pt_Sr_1 = &Sr[0]; + pt_Si_1 = &Si[0]; + + tmp1 = *(pt_Sr_1++); + tmp3 = *(pt_Sr_1++); + tmp2 = *(pt_Si_1++); + tmp4 = *(pt_Si_1++); + + for (i = 32; i != 0; i--) + { + *(pt_data_1++) = (Int16) fxp_mul32_Q31((tmp2 - tmp1), SCALE_DOWN_HQ); + *(pt_data_1++) = (Int16) fxp_mul32_Q31(-(tmp3 + tmp4), SCALE_DOWN_HQ); + *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp1 + tmp2), SCALE_DOWN_HQ); + *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp3 - tmp4), SCALE_DOWN_HQ); + + tmp1 = *(pt_Sr_1++); + tmp3 = *(pt_Sr_1++); + tmp2 = *(pt_Si_1++); + tmp4 = *(pt_Si_1++); + } + +} + + +const Int32 exp_m0_25_phi[32] = +{ + + 0x7FFEFE6E, 0x7FEAFB4A, 0x7FC2F827, 0x7F87F505, + 0x7F38F1E4, 0x7ED6EEC6, 0x7E60EBAB, 0x7DD6E892, + 0x7D3AE57D, 0x7C89E26D, 0x7BC6DF61, 0x7AEFDC59, + 0x7A06D958, 0x790AD65C, 0x77FBD367, 0x76D9D079, + 0x75A6CD92, 0x7460CAB2, 0x7308C7DB, 0x719EC50D, + 0x7023C248, 0x6E97BF8C, 0x6CF9BCDA, 0x6B4BBA33, + 0x698CB796, 0x67BDB505, 0x65DEB27F, 0x63EFB005, + 0x61F1AD97, 0x5FE4AB36, 0x5DC8A8E2, 0x5B9DA69C +}; + +void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]) +{ + + Int16 k; + Int16 *pt_data_1; + Int32 exp_m0_25; + const Int32 *pt_exp = exp_m0_25_phi; + + Int32 *XX = Sr; + Int32 *YY = (Int32 *)data; + Int32 tmp1; + Int32 tmp2; + + for (k = 0; k < 32; k++) + { + exp_m0_25 = *(pt_exp++); + tmp1 = Sr[k]; + tmp2 = Si[k]; + XX[k] = cmplx_mul32_by_16(-tmp1, tmp2, exp_m0_25); + YY[31-k] = cmplx_mul32_by_16(tmp2, tmp1, exp_m0_25); + } + + mdct_32(XX); + mdct_32(YY); + + for (k = 0; k < 32; k++) + { + Si[k] = YY[k]; + } + + pt_data_1 = data; + + for (k = 0; k < 16; k++) + { + *(pt_data_1++) = (Int16)((XX[2*k ] + Si[2*k ]) >> 14); + *(pt_data_1++) = (Int16)((XX[2*k+1] - Si[2*k+1]) >> 14); + } + + for (k = 15; k > -1; k--) + { + *(pt_data_1++) = (Int16)(-(XX[2*k+1] + Si[2*k+1]) >> 14); + *(pt_data_1++) = (Int16)(-(XX[2*k ] - Si[2*k ]) >> 14); + } + +} + + +#endif /* HQ_SBR */ + +#endif /* AAC_PLUS */ + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.h new file mode 100644 index 00000000..a21c6026 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/synthesis_sub_band.h @@ -0,0 +1,73 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: synthesis_sub_band.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + +------------------------------------------------------------------------------ +*/ + +#ifndef SYNTHESIS_SUB_BAND_H +#define SYNTHESIS_SUB_BAND_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ + +#include "pv_audio_type_defs.h" +#include "config.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES AND SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]); + void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]); + + +#ifdef HQ_SBR + + void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]); + void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]); + +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* SYNTHESIS_SUB_BAND_H */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.c new file mode 100644 index 00000000..68c6956a --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.c @@ -0,0 +1,389 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_ar_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + spec = spectral input to be shaped by the filter. + Fixed point format + Int32[] + length = spec_length + + spec_length = length of spec array. + const Int + + direction = direction for application of tns filter. + +1 filters spectrum from low to high frequencies + (first input to filter is spec[0]) + -1 filters spectrum from high to low frequencies + (first input to filter is spec[spec_length-1]) + const Int + + lpc = array of lpc coefficients, minus lpc[0] which is assumed to be "1" + Fixed point format + const Int[] + length = TNS_MAX_ORDER + + Q_lpc = Q format for the lpc coeffcients (for max. precision, it assumes + that all 16 bits are used) + const Int + + order = order of the TNS filter (Range of 1 - TNS_MAX_ORDER) + Int + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + spec = contains spectral data after application of TNS filter + Int32 array + length = spec_length + + + Local Stores Modified: + + Global Stores Modified: + + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + A block of spectral data (Int32 spec[]) of length (const Int spec_length) + is processed by a simple all-pole filter defined by + LPC coefficients passed via (const Int lpc[]) + + TNS filter equation + y(n) = x(n) - lpc(2)*y(n-1) - ... - lpc(order+1)*y(n-order) + + The filter calculation is performed in place, i.e. the output is passed + back to the calling function via (Int32 spec[]) + + The filter's order is defined by the variable (const Int order) + The direction of the filter's application is defined by (const Int inc) + +------------------------------------------------------------------------------ + REQUIREMENTS + + This function should match the functionality of the ISO code. + The implementation does support filter orders bigger or equal to 1. + The size of the spectral coeffcients has to be bigger or equal than 1. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + FOR (i=0; i0; j--) + + state[j] = state[j-1]; + + ENDFOR + + state[0] = y; + + *spec = y; + + spec = spec + inc; + + ENDFOR + + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_tns_const.h" +#include "tns_ar_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define MASK_LOW16 0xFFFF +#define UPPER16 16 + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +Int tns_ar_filter( + Int32 spec[], + const Int spec_length, + const Int direction, + const Int32 lpc[], + const Int Q_lpc, + const Int order) +{ + + Int i; + Int j; + + /* + * Multiplication related variables + */ + + Int32 temp; + + /* + * Filter related variables + */ + Int32 y0; + + /* + * Circular buffer to hold the filter's state + * (y[n-1],y[n-2],y[n-3],etc.) + * + * p_state and p_lpc should take advantage + * of any special circular buffer instructions + * if this code is hand-optimized in assembly. + */ + + Int32 *p_state = NULL; + + const Int32 *p_lpc; + + + Int shift_up; + Int shift_down_amount; + + /* + * Pointer to the I/O memory space + */ + Int32 *p_spec = spec; + + + i = 0; + j = order; + + /* + * get the power of 2 that is bigger than the order + * i is the bit counter and j is modified until exceed + * the power of 2 corresponding to TNS_MAX_ORDER + */ + + while (j < 0x010) + { + j <<= 1; + i++; + } + + /* + * 5 is the number of bits needed to represent 0x010 + * TNS_MAX_ORDER = 20, power of 2 that include 20 is 5 + */ + shift_down_amount = 4 - i; + + shift_up = UPPER16 - Q_lpc; + + /* + * shift_down_amount == power of 2 that is bigger than the order - 1 + */ + + shift_down_amount += shift_up; + + if (direction == -1) + { + p_spec += spec_length - 1; + + for (i = order; i != 0; i--) + { + + y0 = *p_spec >> shift_down_amount; + + p_lpc = lpc; + + /* 32 by 32 bit multiplication */ + for (j = order; j > i; j--) + { + temp = *p_state++; + y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up; + } + + /* + * Record the output in-place + */ + p_state = p_spec; + *(p_spec--) = y0; + + } + + if (spec_length > order) + { + for (i = (spec_length - order); i != 0; i--) + { + y0 = *p_spec >> shift_down_amount; + + p_lpc = &(lpc[0]); + + /* 32 by 32 bit multiplication */ + for (j = order; j != 0; j--) + { + temp = *p_state++; + y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up; + } + + /* + * Record the output in-place + */ + p_state = p_spec; + *(p_spec--) = y0; + + } /* END for (i = (spec_length - order); i>0; i--) */ + } + + } + else + { + for (i = order; i != 0; i--) + { + + p_lpc = lpc; + + y0 = 0; + + /* 32 by 32 bit multiplication */ + for (j = order; j > i; j--) + { + y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++)); + } + + p_state = p_spec; + /* + * Record the output in-place + */ + *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up); + p_spec++; + } + + if (spec_length > order) + { + for (i = (spec_length - order); i != 0; i--) + { + p_lpc = lpc; + + y0 = 0; + + /* 32 by 32 bit multiplication */ + for (j = order; j != 0; j--) + { + y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++)); + } + + p_state = p_spec; + /* + * Record the output in-place + */ + *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up); + p_spec++; + + } /* END for (i = (spec_length - order); i>0; i--) */ + } + } + + return(shift_down_amount); + + +} /* tns_ar_filter */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.h new file mode 100644 index 00000000..48eca7d7 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_ar_filter.h @@ -0,0 +1,93 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_ar_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for tns_ar_filter() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_AR_FILTER_H +#define TNS_AR_FILTER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "e_tns_const.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + + Int tns_ar_filter( + Int32 spec[], + const Int spec_length, + const Int inc, + const Int32 lpc[], + const Int lpc_qformat, + const Int order); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.c new file mode 100644 index 00000000..d6550363 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.c @@ -0,0 +1,456 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_decode_coef.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + The inputs and their range are defined in ISO/IEC 14496-3:1999(E) + Part 3 MPEG-4 Audio + Subpart 4 + + Inputs: order = RANGE = 1-20 + const Int + + coef_res = RANGE = 0-1 + const Int + + lpc_coef = RANGE = -8 to 7 if coef_res = 1 compression OFF + -4 to 3 if coef_res = 1 compression ON + -4 to 3 if coef_res = 0 compression OFF + -2 to 1 if coef_res = 0 compression ON + + [Int *, length TNS_MAX_ORDER] + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + q_lpc = q_format for the calculated LPC coefs. + Int + + Pointers and Buffers Modified: + lpc_coef = used to return the calculated LPC coefs in-place. + Int * + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +This function calculates the LPC coefs from the encoded coefs... + +------------------------------------------------------------------------------ + REQUIREMENTS + +This function should match the functionality of the ISO source code within +a reasonable tolerance for fixed point errors. + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.8 (Temporal Noise Shaping) + (2) Markel & Gray Page 95 + As referenced in the ISO source code + + (3) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- + PSEUDOCODE: (ISO Reference Code) + + int i, m; + Real iqfac, iqfac_m; + Real lpc_fp[TNS_MAX_ORDER+1]; + Real sin_result_fp[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1]; + + Inverse quantization + iqfac = (Real)(((1 << (coef_res-1)) - 0.5) / (PI/2.0)); + iqfac_m = (Real)(((1 << (coef_res-1)) + 0.5) / (PI/2.0)); + + for (i=0; i= 0) ? iqfac : iqfac_m) ); + } + + lpc[0] = 1; + for (m=1; m<=order; m++) + { + + b[0] = lpc[0]; + for (i=1; i 0; i--) + { + + /* + * temp_ptr used to optimize index into pA + * mult = (Int32)( pA[m-i] * sin_result); + */ + + mult_high = fxp_mul32_Q31(*(temp_ptr--), sin_result); + + /* + * pB[i] = pA[i] + sin_result * pA[m-i] + * + * (mult_high <<1) eliminates extra sign bit + */ + + *(pB++) = *(pA++) + (mult_high << 1); + + } /* END for (i=m; i > 0; i--) */ + + + /* Shift to place pB[m] in q_lpc format */ + + *pB = sin_result >> 12; + + /* + * Swapping the pointers here has the same effect + * as specifically copying the data from b to a + */ + + temp_ptr = pA; + pA = pB; + pB = temp_ptr; + + /* + * At this point, pA = pA[m] + * and pB = pB[m] + */ + temp_ptr = pA; + + tempInt32 = *(pA); + + mask = tempInt32 >> 31; + tempInt32 ^= mask; + + max = tempInt32; + + /* + * It is important that this for loop is not entered on the first + * iteration of the do-while( m < order ) loop. + */ + for (i = m; i > 0; i--) + { + tempInt32 = *(--pA); + + mask = tempInt32 >> 31; + tempInt32 ^= mask; + + max |= tempInt32; + } + + pB -= m; + + /* + * Here, pA = &(pA[0]) + * and pB = &(pB[0]) + */ + + if (max >= 0x40000000L) + { + max >>= 1; + + for (i = m; i > 0; i--) + { + *(pA++) >>= 1; + *(pB++) >>= 1; + } + + /* Shift the most recent entry down also */ + *(pA) >>= 1; + + q_lpc--; + + pA -= m; + pB -= m; + } + + m++; + + } + while (m < order); + + + /* + * The following code compacts + * 32-bit LPC coefficients into 16-bit numbers, + * shifting by the minimum amount necessary. + */ + + shift_amount = 0; + + while (max > 32767) + { + max >>= 1; + shift_amount++; + } + + /* + * This while loop is for protective purposes only. + * I have not found data that causes it to be entered. + * + */ + if (max != 0) + { + while (max < 16384) + { + max <<= 1; + shift_amount--; + } + } + + + pLPC = lpc_coef; + + if (shift_amount >= 0) + { + + for (m = order; m > 0; m--) + { + *(pLPC++) = *(pA++) << (16 - shift_amount); + } + } + + + q_lpc -= shift_amount; + + /* + * make sure that the numbers have some meaning, q_lpc can not be + * bigger than 15 (15 bits + sign) + */ + + if (q_lpc > 15) + { + shift_amount = q_lpc - 15; + pLPC = lpc_coef; + + for (m = order; m > 0; m--) + { + *(pLPC++) >>= shift_amount; + } + + q_lpc -= shift_amount; + } + + return (q_lpc); + +} /* tns_decode_coef */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.h new file mode 100644 index 00000000..6d228050 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_decode_coef.h @@ -0,0 +1,86 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_decode_coef.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This function includes the function declaration for tns_decode_coef() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_DECODE_COEF_H +#define TNS_DECODE_COEF_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; INCLUDES + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; MACROS + ; Define module specific macros here + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + Int tns_decode_coef( + const Int order, + const Int coef_res, + Int32 lpc_coef[], + Int32 scratchTnsDecCoefMem[]); + +#ifdef __cplusplus +} +#endif + +#endif /* TNS_DECODE_COEF */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.c new file mode 100644 index 00000000..9364b144 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.c @@ -0,0 +1,378 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_inv_filter.cpp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + + coef = spectral input to be shaped by the filter. + Fixed point format + [Int32[], length = num_coef] + + num_coef = length of spec array. + [const Int] + + direction = direction for application of tns filter. + +1 applies forward filter + (first input to filter is coef[0]) + -1 applies reversed filter + (first input to filter is coef[num_coef-1]) + [const Int] + + lpc = array of lpc coefficients. + Fixed point format Q-11 + [const Int[], length = TNS_MAX_ORDER] + + lpc_qformat = The q-format of the lpc coefficients. + [const Int] + + order = order of the TNS filter (Range of 1 : TNS_MAX_ORDER) + [const Int] + + scratch_memory = scratch_memory needed for filter operation + [Int[], length = TNS_MAX_ORDER] + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + coef = contains spectral data after application of TNS filter + q-format is not modified. + Int32 array + length = num_coef + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + A block of spectral data (Int32 coef[]) of length (const Int num_coef) + is processed by a simple all-zero filter defined by + LPC coefficients passed via (const Int lpc[]) + + TNS filter equation + y(n) = x(n) + lpc(2)*x(n-1) + ... + lpc(order+1)*x(n-order) + + The filter calculation is performed in place, i.e. the output is passed + back to the calling function via (Int32 coef[]) + + In order to avoid overflow, the filter input (Int32 coef[]) must utilize + only the lower 16-bits. The upper 16-bits must be available. + + The filter's order is defined by the variable (const Int order) + + The direction of the filter's application is defined by + (const Int direction) + +------------------------------------------------------------------------------ + REQUIREMENTS + + [Int32 coef] must store no more than 16 bits of data. + + This is required to utilize methods that do not change the q-format of + the input data [Int32 coef], and to make use of a fast + 16 x 16 bit multiply. + + This function should not be called for order <= 0. + + This function must not be called with lpc_qformat < 5 +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.6.4.1 (LTP with TNS) + Subpart 4.6.8 (Temporal Noise Shaping) + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (direction == -1) + THEN + pCoef = pCoef + (num_coef - 1); + END IF + + FOR (i = order; i > 0; i--) + + *(pFilterInput) = 0; + pFilterInput = pFilterInput + 1; + + END FOR + + wrap_point = 0; + + shift_amt = (lpc_qformat - 5); + + FOR (i = num_coef; i > 0; i--) + + pLPC = lpc; + + mult = 0; + + FOR (j = wrap_point; j>0; j--) + + tempInt32 = (Int32)(*(pLPC) * *(pFilterInput)); + tempInt32 = tempInt32 >> 5; + + mult = mult + tempInt32; + + pFilterInput = pFilterInput + 1; + pLPC = pLPC + 1; + + ENDFOR + + pFilterInput = scratch_memory; + + FOR (j = (order - wrap_point); j>0; j--) + + tempInt32 = (Int32)(*(pLPC) * *(pFilterInput)); + tempInt32 = tempInt32 >> 5; + + mult = mult + tempInt32; + + pFilterInput = pFilterInput + 1; + pLPC = pLPC + 1; + + ENDFOR + + pFilterInput = pFilterInput - 1; + *(pFilterInput) = (Int)(*pCoef); + + mult = mult >> shift_amt; + + *(pCoef) = *(pCoef) + mult; + + pCoef = pCoef + direction; + + wrap_point = wrap_point + 1; + + IF (wrap_point == order) + THEN + wrap_point = 0; + END IF + + END FOR + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "tns_inv_filter.h" +#include "fxp_mul32.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + +void tns_inv_filter( + Int32 coef[], + const Int num_coef, + const Int direction, + const Int32 lpc[], + const Int lpc_qformat, + const Int order, + Int32 scratch_memory[]) +{ + + Int i; + Int j; + Int shift_amt; + Int wrap_point; + + Int32 mult; + + /* + * Circular buffer to hold the filter's input + * + * (x[n-1],x[n-2],x[n-3],etc.) + * + * This scratch space is necessary, because + * the filter's output is returned in-place. + * + * pFilterInput and pLPC should take advantage + * of any special circular buffer instructions + * if this code is hand-optimized in assembly. + * + */ + Int32 *pFilterInput = scratch_memory; + + const Int32 *pLPC; + + /* + * Pointer to the I/O memory space + */ + Int32 *pCoef = coef; + + if (direction == -1) + { + pCoef += (num_coef - 1); + } + + /* Make sure the scratch memory is "clean" */ + for (i = order; i != 0; i--) + { + *(pFilterInput++) = 0; + } + + wrap_point = 0; + + shift_amt = (lpc_qformat - 5); + + for (i = num_coef; i > 0; i--) + { + /* + * Copy spectral input into special + * filter input buffer. + */ + pLPC = lpc; + + mult = 0; + + /* + * wrap_point = 0 when this code is + * entered for the first iteration of + * for(i=num_coef; i>0; i--) + * + * So, this first for-loop will be + * skipped when i == num_coef. + */ + + for (j = wrap_point; j > 0; j--) + { + mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5; + + } /* for (j = wrap_point; j>0; j--) */ + + /* + * pFilterInput has reached &scratch_memory[order-1] + * Reset pointer to beginning of filter's state memory + */ + pFilterInput = scratch_memory; + + for (j = (order - wrap_point); j > 0; j--) + { + mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5; + + } /* for (j = wrap_point; j>0; j--) */ + + + /* + * Fill the filter's state buffer + * avoid obvious casting + */ + *(--pFilterInput) = (*pCoef); + + + /* Scale the data down so the output q-format is not adjusted. + * + * Here is an equation, which shows how the spectral coefficients + * and lpc coefficients are multiplied and the spectral + * coefficient's q-format does not change. + * + * Q-(coef) * Q-(lpc_qformat) >> 5 = Q-(coef + lpc_q_format - 5) + * + * Q-(coef + lpc_q_format - 5) >> (lpc_qformat - 5) = Q-(coef) + */ + + /* Store output in place */ + *(pCoef) += (mult >> shift_amt); + + /* Adjust pointers and placeholders */ + pCoef += direction; + + wrap_point++; + + if (wrap_point == order) + { + wrap_point = 0; + } + + } /* for (i = num_coef; i > 0; i--) */ + +} /* tns_inv_filter */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.h new file mode 100644 index 00000000..d325793c --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/tns_inv_filter.h @@ -0,0 +1,87 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: tns_inv_filter.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This include file contains the function declaration for + tns_inv_filter.c + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef TNS_INV_FILTER_H +#define TNS_INV_FILTER_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +void tns_inv_filter( + Int32 coef[], + const Int num_coef, + const Int inc, + const Int32 lpc[], + const Int lpc_qformat, + const Int order, + Int32 scratch_memory[]); + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_freq_2_time_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_freq_2_time_fxp.c new file mode 100644 index 00000000..12325a9b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_freq_2_time_fxp.c @@ -0,0 +1,2472 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: trans4m_freq_2_time_fxp.cpp + Function: trans4m_freq_2_time_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Frequency_data = vector with spectral information, size 2048 + type Int32 + + Time_data = buffer with data from previous Frequency to Time + conversion, used for overlap and add, size 1024 + type Int32 + + Output_buffer = place holder for current output, size 1024 + type Int16 + + wnd_seq = window sequence + type WINDOW_SEQUENCE + + wnd_shape_prev_bk = previous window shape type + type Int + + wnd_shape_this_bk = current window shape type + type Int + + Q_format = Q format for the input frequency data + type Int + + freq_2_time_buffer[] = scratch memory for computing FFT + type Int32 + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Output_buffer + Time_data + Frequency_data + pWnd_shape_prev_bk + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +The time/frequency representation of the signal is mapped onto the time +domain by feeding it into the filterbank module. This module consists of +an inverse modified discrete cosine transform (IMDCT), and a window and an +overlap-add function. In order to adapt the time/frequency resolution of the +filterbank to the characteristics of the input signal, a block switching tool +is also adopted. N represents the window length, where N is a function of the +window_sequence. For each channel, the N/2 time-frequency values are +transformed into the N time domain values via the IMDCT. After applying the +window function, for each channel, the first half of the sequence is added to +the second half of the previous block windowed sequence to reconstruct the +output samples for each channel outi,n. + +The adaptation of the time-frequency resolution of the filterbank to the +characteristics of the input signal is done by shifting between transforms +whose input lengths are either 2048 or 256 samples. By enabling the block +switching tool, the following transitions are meaningful: + +from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +Window shape decisions are made by the encoder on a frame-by-frame-basis. +The window selected is applicable to the second half of the window function +only, since the first half is constrained to use the appropriate window +shape from the preceding frame. +The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are +the last 1024 values of the previous window_sequence concatenated with 1024 +values of the current block. The formula below shows this fact: + + | x(i-1)(n+1024) for 0 < n < 1024 + x'(i)(n) { + | x(i)(n) for 1024 < n < 2048 + + +Buffer Time_data data from previous Frequency to Time conversion, used +for overlap and add + +Once the window shape is selected, the window_shape syntax element is +initialized. Together with the chosen window_sequence all information needed +for windowing exist. +With the window halves described below all window_sequences can be assembled. +For window_shape == 1, the window coefficients are given by the Kaiser - +Bessel derived (KBD) window. +Otherwise, for window_shape == 0, a sine window is employed. + +The window length N can be 2048 or 256 for the KBD and the sine window. +All four window_sequences explained below have a total length of 2048 +samples. +For all kinds of window_sequences the window_shape of the left half of +the first transform window is determined by the window shape of the previous +block. + +In the case of EIGHT_SHORT_SEQUENCE the processing is done in-place and +in descendent order to avoid using extra memory. +The ordering is as follows: + + Pn: Previous data for window n + Cn: Current data for window n + + + 128 freq. + samples + FREQ ++++++ +IN =========================== + \ + \ + -> 256 time + samples + + P8 C8 + 8 #######++++++ + P7 C7 + 7 #######++++++ + : : + : : + P2 C2 + 2 #######++++++ + P1 C1 + 1 #######++++++ + TIME +OUT ============================================================== + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement a scheme to switch between window types + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3:1999, pag 111 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + + + IF ( wnd_seq == EIGHT_SHORT_SEQUENCE) + THEN + + FOR ( i=0; i=0; wnd--) + + pFreqInfo = &Frequency_data[ wnd*SHORT_WINDOW]; + + CALL IMDCT( pFreqInfo, SHORT_BLOCK1); + MODIFYING(pFreqInfo) + + + IF (wnd == 0) + THEN + pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0]; + ELSE + pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0]; + ENDIF + + pShort_Window_2 = + &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1]; + + FOR( i=0, j=SHORT_WINDOW; i>16; + + +#else + +#define limiter( y, x) z = ((x + ROUNDING )>>SCALING); \ + if ((z>>15) != (z>>31)) \ + { \ + z = (z >> 31) ^ INT16_MAX; \ + } \ + y = (Int16)(z); + +#endif + + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +#include "config.h" + +#ifdef AAC_PLUS + + +void trans4m_freq_2_time_fxp_1( + Int32 Frequency_data[], + Int32 Time_data[], + Int16 Output_buffer[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[]) + +{ + Int exp; + Int shift; + + Int i; + Int wnd; +#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5)) + Int32 z; +#endif + + Int16 *pFreqInfo; + Int32 temp; + Int32 test; + + Int16 *pFreq_2_Time_data_1; + Int16 *pFreq_2_Time_data_2; + + const Int16 *pLong_Window_1; + const Int16 *pLong_Window_2; + const Int16 *pShort_Window_1; + const Int16 *pShort_Window_2; + + Int32 *pOverlap_and_Add_Buffer_1; + Int32 *pOverlap_and_Add_Buffer_2; + + Int16 *pOutput_buffer; + Int16 *pOutput_buffer_2; + + const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES]; + const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES]; + + Long_Window_fxp[0] = Long_Window_sine_fxp; + Long_Window_fxp[1] = Long_Window_KBD_fxp; + Short_Window_fxp[0] = Short_Window_sine_fxp; + Short_Window_fxp[1] = Short_Window_KBD_fxp; + + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + + pFreqInfo = (Int16 *)Frequency_data; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + LONG_BLOCK1, + Q_format, + abs_max_per_window[0]); + + + + /* + * The C Programming Language, Second Edition, Kernighan & Ritchie, + * page 206. + * "The result [of a shift] is undefined if the right operand is + * negative, or greater than or equal to the number of bits in the + * left expression's type" + * => avoid shift by 32 or 16 + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = pFreqInfo; + + switch (wnd_seq) + { + + case ONLY_LONG_SEQUENCE: + default: + + pOutput_buffer = Output_buffer; + + pOverlap_and_Add_Buffer_1 = Time_data; + + { + const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + Int32 * pFreq2T = (Int32 *)pFreqInfo; + Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0]; + Int shift = exp + 15 - SCALING; + + + Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW]; + + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int32 temp2, test2; + + Int32 winx; + + temp2 = *(pFreq2T++); + winx = *(win++); + + test = *(pOverlap_and_Add_Buffer_1++); + test2 = *(pOverlap_and_Add_Buffer_1--); + temp = fxp_mul_16_by_16bb(temp2, winx) >> shift; + temp2 = fxp_mul_16_by_16tt(temp2, winx) >> shift; + limiter(*(pOutput_buffer++), (temp + test)); + limiter(*(pOutput_buffer++), (temp2 + test2)); + + temp2 = *(pFreq2T_2++); + + win1 = *(pLong_Window_2--); + win2 = *(pLong_Window_2--); + temp = fxp_mul_16_by_16bb(temp2, win1) >> shift; + test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + *(pOverlap_and_Add_Buffer_1++) = test2; + + } + } + + break; + + case LONG_START_SEQUENCE: + + + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[ HALF_LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW]; + + pOutput_buffer = Output_buffer; + pOutput_buffer_2 = pOutput_buffer + HALF_LONG_WINDOW; + + + shift = exp + 15 - SCALING; + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + + Int16 win1, win2; + Int16 dat1, dat2; + Int32 test1, test2; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pLong_Window_1++); + test1 = *(pOverlap_and_Add_Buffer_1++); + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pLong_Window_2++); + test2 = *(pOverlap_and_Add_Buffer_2++); + + limiter(*(pOutput_buffer++), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift))); + + limiter(*(pOutput_buffer_2++), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift))); + + } + + /* + * data unchanged from LONG_WINDOW to W_L_START_1 + * only scaled accordingly + */ + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW]; + + exp -= SCALING; + + if (exp >= 0) + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + + } + + } + else if (exp < 0) + { + + Int shift = -exp; + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--) + { + Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + } + + } + else + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + + } + + } + + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 temp2; + dat1 = (*pFreq_2_Time_data_1++); + dat2 = (*pFreq_2_Time_data_2++); + win1 = *(pShort_Window_1--); + win2 = *(pShort_Window_2--); + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + + temp2 = fxp_mul_16_by_16(dat2, win2) >> shift; + *(pOverlap_and_Add_Buffer_2++) = temp2; + + + } + + + pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW; + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + (LONG_BLOCK1 - W_L_START_2) + *sizeof(*pOverlap_and_Add_Buffer_1)); + + + break; + + + case LONG_STOP_SEQUENCE: + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2]; + + pOutput_buffer = &Output_buffer[W_L_STOP_2]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2]; + + exp -= SCALING; /* !!!! */ + + if (exp > 0) + { + Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + tmp1)); + + tmp1 = *(pFreq_2_Time_data_1++) >> exp; + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + else if (exp < 0) + { + shift = -exp; + Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + temp1)); + + temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + else + { + Int16 tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + tmp1)); + + tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + } + } + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1]; + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + pOutput_buffer = &Output_buffer[W_L_STOP_1]; + pOutput_buffer_2 = pOutput_buffer + HALF_SHORT_WINDOW; + + exp += SCALING; /* +8 back to what it was */ + + shift = exp + 15 - SCALING; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + Int16 win1; + Int16 dat1; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pOutput_buffer++), (temp + (test >> shift))); + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2++); + temp = *(pOverlap_and_Add_Buffer_2++); + test = fxp_mul_16_by_16(dat1, win1); + limiter(*(pOutput_buffer_2++), (temp + (test >> shift))); + + } + + + pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = Time_data; + + pOutput_buffer = Output_buffer; + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + /* + * Copy previous time in current buffer, also copy overlap + * and add buffer + */ + + for (i = W_L_STOP_1; i != 0; i--) + { + Int16 win1; + Int16 dat1; + + win1 = *(pLong_Window_2--); + dat1 = *pFreq_2_Time_data_2++; + + limiter(*(pOutput_buffer++), *(pOverlap_and_Add_Buffer_1)); + + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--) + { + temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + } + + + break; + + + + } /* switch (wnd_seq) */ + + } /* if (exp < 16) */ + + else + { + /* all zeros buffer or excessive down shift */ + + /* Overlap and add, setup buffer for next iteration */ + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + + pOutput_buffer = Output_buffer; + + temp = (*pOverlap_and_Add_Buffer_1++); + + for (i = LONG_WINDOW; i != 0; i--) + { + + limiter(*(pOutput_buffer++), temp); + + temp = (*pOverlap_and_Add_Buffer_1++); + + } + + pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0])); + + + } + + } + else + { + + Int32 *pScrath_mem; + Int32 *pScrath_mem_entry; + Int32 *pFrequency_data = Frequency_data; + + Int32 * pOverlap_and_Add_Buffer_1; + Int32 * pOverlap_and_Add_Buffer_2; + Int32 * pOverlap_and_Add_Buffer_1x; + Int32 * pOverlap_and_Add_Buffer_2x; + + /* + * Frequency_data is 2*LONG_WINDOW length but only + * the first LONG_WINDOW elements are filled in, + * then the second part can be used as scratch mem, + * then grab data from one window at a time in + * reverse order. + * The upper LONG_WINDOW Int32 are used to hold the + * computed overlap and add, used in the next call to + * this function, and also as sctrach memory + */ + + /* + * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE + + |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-| + | | Store for next | | memory | + | | call | | | + | | | | | + |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++| + | | | | | + 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW + + | | + W_L_STOP_2 | | + |<-- -->| + SHORT_WINDOW + + HALF_SHORT_WINDOW + * + */ + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ + LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW]; + + /* + * Initialize to zero, only the firt short window used in overlap + * and add + */ + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + + /* + * Showt windows are evaluated in decresing order. Windows from 7 + * to 0 are break down in four cases: window numbers 7 to 5, 4, 3, + * and 2 to 0. + * The data from short windows 3 and 4 is situated at the boundary + * between the 'overlap and add' buffer and the output buffer. + */ + for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--) + { + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + pOverlap_and_Add_Buffer_1 = + &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd]; + + + pOverlap_and_Add_Buffer_2 = + pOverlap_and_Add_Buffer_1 + SHORT_WINDOW; + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + + + /* + * For short windows from 7 to 5 + * | ========================= + * | | 5 6 7 + * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ \/ \|/ | \/ \/ \/ \ + * / /\ /\ /\ /|\ | /\ /\ /\ \ + * / / \ / \ / \ / | \ | / \ / \ / \ \ + * / / \/ \/ \/ | \|/ \/ \ \ \ + * --------------------------------|---[///////////////////////]-------- + * + */ + + + shift = exp + 15 - SCALING; + + + for (i = SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pShort_Window_2--); + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift); + + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */ + + + wnd = NUM_SHORT_WINDOWS / 2; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + /* + * scratch memory is allocated in an unused part of memory + */ + + + pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short window 4 + * ====|=========== + * | 4 + * | | | | + * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_ + * / \/ \/ \/ | \|/ | \/ | \/ \/ \ + * / /\ /\ /\ | /|\ | /\ | /\ /\ \ + * / / \ / \ / \ | / | \ | / \ | / \ / \ \ + * / / \/ \/ \|/ | \|/ \|/ \/ \ \ + * ------------------------------[\\\|\\\|//////]------------------- + * | | A | B | C | + * | + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + { + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> (shift); + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment C ---------------*/ + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift); + + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pScrath_mem, + 0, + HALF_SHORT_WINDOW*sizeof(*pScrath_mem)); + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + wnd = NUM_SHORT_WINDOWS / 2 - 1; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + pScrath_mem_entry = + &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW]; + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + /* point to end of buffer less HALF_SHORT_WINDOW */ + + pOutput_buffer_2 = &Output_buffer[LONG_WINDOW - HALF_SHORT_WINDOW]; + pOutput_buffer = pOutput_buffer_2; + + pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; /* !!!! */ + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * For short window 3 + * ===========|==== + * 3 | + * | | | | + * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ | \/ | \|/ | \/ \/ \/ \ + * / /\ /\ | /\ | /|\ | /\ /\ /\ \ + * / / \ / \ | / \ | / | \ | / \ / \ / \ \ + * / / \/ \|/ \|/ | \|/ \/ \ \ \ + * -----|------------------[\\\\\\|///|///]-------------------------- + * | | A | B | C | + * + * W_L_STOP_1 + */ + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + shift = exp + 15 - SCALING; + + + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp = *(pScrath_mem++) + test; + + + test = *(pOverlap_and_Add_Buffer_1x++); /* !!!! */ + + limiter(*(pOutput_buffer++), (temp + test)); + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + } + + /* -------- segment C ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + temp = fxp_mul_16_by_16(dat1, win1) >> (shift); + + *(pOverlap_and_Add_Buffer_1++) += temp; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + + } /* if (exp < 16) */ + else + { + + pv_memset( + pScrath_mem, + 0, + SHORT_WINDOW*sizeof(*pScrath_mem)); + + pScrath_mem += SHORT_WINDOW; + + temp = *(pScrath_mem++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), temp); + temp = *(pScrath_mem++); + + + } + } + + + for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--) + { + + + pOutput_buffer_2 -= SHORT_WINDOW; + pOutput_buffer = pOutput_buffer_2; + + /* + * The same memory is used as scratch in every iteration + */ + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_2x = + &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + if (wnd == 0) + { + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_prev_bk][0]; + } + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short windows from 2 to 0 + * + * ========================= + * | + * 0 1 2 | | + * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_ + * / \/ \/ \/ | \|/ \/ \/ \/ \ + * / /\ /\ /\ | /|\ /\ /\ /\ \ + * / / \ / \ / \ | / | \ / \ / \ / \ \ + * / / \/ \/ \|/ | \/ \/ \ \ \ + * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|----------------------------- + * | + * + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + + Int16 dat1 = *(pFreq_2_Time_data_2++); + Int16 win1 = *(pShort_Window_2--); + + temp = *(pScrath_mem); + for (i = SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp += test; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + limiter(*(pOutput_buffer++), (temp + *(pOverlap_and_Add_Buffer_2x++))); + + + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + temp = *(pScrath_mem); + + } + + } /* if (exp < 16) */ + else + { + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + test)); + + *(pScrath_mem++) = 0; + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + } + + } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */ + + pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1]; + + pScrath_mem = pScrath_mem_entry; + + pOutput_buffer_2 -= SHORT_WINDOW; + pOutput_buffer = pOutput_buffer_2; + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pOutput_buffer++), (temp + test)); + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + + pOverlap_and_Add_Buffer_1x = Time_data; + + pOutput_buffer = Output_buffer; + + + temp = *(pOverlap_and_Add_Buffer_1x++); + + for (i = W_L_STOP_1; i != 0; i--) + { + limiter(*(pOutput_buffer++), temp); + + temp = *(pOverlap_and_Add_Buffer_1x++); + } + + pOverlap_and_Add_Buffer_1x = &Time_data[0]; + + pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW]; + + /* + * update overlap and add buffer, + * so is ready for next iteration + */ + + for (i = 0; i < W_L_STOP_2; i++) + { + temp = *(pOverlap_and_Add_Buffer_2++); + *(pOverlap_and_Add_Buffer_1x++) = temp; + } + + pv_memset( + pOverlap_and_Add_Buffer_1x, + 0, + W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x)); + + } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + +} + +#endif +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ + + + +void trans4m_freq_2_time_fxp_2( + Int32 Frequency_data[], + Int32 Time_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[], + Int16 *Interleaved_output) + +{ + + Int exp; + Int shift; + + Int i; + Int wnd; +#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5)) + Int32 z; +#endif + Int16 *pFreqInfo; + Int32 temp; + Int32 test; + + Int16 *pFreq_2_Time_data_1; + Int16 *pFreq_2_Time_data_2; + + const Int16 *pLong_Window_1; + const Int16 *pLong_Window_2; + const Int16 *pShort_Window_1; + const Int16 *pShort_Window_2; + + Int32 *pOverlap_and_Add_Buffer_1; + Int32 *pOverlap_and_Add_Buffer_2; + + Int16 *pInterleaved_output; + Int16 *pInterleaved_output_2; + + + const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES]; + const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES]; + + Long_Window_fxp[0] = Long_Window_sine_fxp; + Long_Window_fxp[1] = Long_Window_KBD_fxp; + Short_Window_fxp[0] = Short_Window_sine_fxp; + Short_Window_fxp[1] = Short_Window_KBD_fxp; + + if (wnd_seq != EIGHT_SHORT_SEQUENCE) + { + + pFreqInfo = (Int16 *)Frequency_data; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + LONG_BLOCK1, + Q_format, + abs_max_per_window[0]); + + + /* + * The C Programming Language, Second Edition, Kernighan & Ritchie, + * page 206. + * "The result [of a shift] is undefined if the right operand is + * negative, or greater than or equal to the number of bits in the + * left expression's type" + * => avoid shift by 32 or 16 + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = pFreqInfo; + + + switch (wnd_seq) + { + + case ONLY_LONG_SEQUENCE: + default: + + { + pOverlap_and_Add_Buffer_1 = Time_data; + + pInterleaved_output = Interleaved_output; + + { + + const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + Int32 * pFreq2T = (Int32 *)pFreqInfo; + Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW]; + Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0]; + + Int shift = exp + 15 - SCALING; + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int32 temp2, test2; + + Int32 winx; + + temp2 = *(pFreq2T++); + winx = *(win++); + + test = *(pOverlap_and_Add_Buffer_1++); + test2 = *(pOverlap_and_Add_Buffer_1--); + temp = fxp_mul_16_by_16bb(temp2, winx) >> shift; + temp2 = fxp_mul_16_by_16tt(temp2, winx) >> shift; + + limiter(*(pInterleaved_output), (temp + test)); + + limiter(*(pInterleaved_output + 2), (temp2 + test2)); + pInterleaved_output += 4; + + temp2 = *(pFreq2T_2++); + + win1 = *(pLong_Window_2--); + win2 = *(pLong_Window_2--); + temp = fxp_mul_16_by_16bb(temp2, win1) >> shift; + test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift; + + *(pOverlap_and_Add_Buffer_1++) = temp; + *(pOverlap_and_Add_Buffer_1++) = test2; + } + + } + + } + + break; + + case LONG_START_SEQUENCE: + + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[ HALF_LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW]; + + + pInterleaved_output = Interleaved_output; + pInterleaved_output_2 = pInterleaved_output + (2 * HALF_LONG_WINDOW); + + + /* + * process first LONG_WINDOW elements + */ + + shift = exp + 15 - SCALING; + + for (i = HALF_LONG_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 test1, test2; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pLong_Window_1++); + test1 = *(pOverlap_and_Add_Buffer_1++); + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pLong_Window_2++); + test2 = *(pOverlap_and_Add_Buffer_2++); + + limiter(*(pInterleaved_output), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift))); + + pInterleaved_output += 2; + + limiter(*(pInterleaved_output_2), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift))); + + pInterleaved_output_2 += 2; + } + + + /* + * data unchanged from LONG_WINDOW to W_L_START_1 + * only scaled accordingly + */ + + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW]; + + exp -= SCALING; + + if (exp >= 0) + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++) >> exp; + + } + + } + else if (exp < 0) + { + + Int shift = -exp; + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--) + { + Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + *(pOverlap_and_Add_Buffer_1++) = temp2; + } + + } + else + { + + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + *(pOverlap_and_Add_Buffer_1++) = + *(pFreq_2_Time_data_1++); + + } + + } + + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + { + Int16 win1, win2; + Int16 dat1, dat2; + Int32 temp2; + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + dat1 = (*pFreq_2_Time_data_1++); + dat2 = (*pFreq_2_Time_data_2++); + win1 = *(pShort_Window_1--); + win2 = *(pShort_Window_2--); + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp; + + temp2 = fxp_mul_16_by_16(dat2, win2) >> shift; + *(pOverlap_and_Add_Buffer_2++) = temp2; + + } + } + + pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW; + + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + (LONG_BLOCK1 - W_L_START_2) + *sizeof(*pOverlap_and_Add_Buffer_1)); + + + break; + + + case LONG_STOP_SEQUENCE: + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2]; + + pInterleaved_output = &Interleaved_output[2*W_L_STOP_2]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2]; + + exp -= SCALING; + + + if (exp > 0) + { + Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp); + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + tmp1)); + + pInterleaved_output += 2; + tmp1 = *(pFreq_2_Time_data_1++) >> exp; + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + else if (exp < 0) + { + shift = -exp; + + Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + temp1)); + + pInterleaved_output += 2; + temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift; + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + else + { + Int16 tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + tmp1)); + + pInterleaved_output += 2; + tmp1 = *(pFreq_2_Time_data_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + } + } + + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1]; + pFreq_2_Time_data_2 = + &pFreq_2_Time_data_1[HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1]; + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + pInterleaved_output = &Interleaved_output[2*W_L_STOP_1]; + pInterleaved_output_2 = pInterleaved_output + (2 * HALF_SHORT_WINDOW); + + exp += SCALING; /* +8 back to what it was */ + shift = exp + 15 - SCALING; + + + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + Int16 win1; + Int16 dat1; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + temp = *(pOverlap_and_Add_Buffer_1++); + + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pInterleaved_output), (temp + (test >> shift))); + + pInterleaved_output += 2; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2++); + temp = *(pOverlap_and_Add_Buffer_2++); + test = fxp_mul_16_by_16(dat1, win1); + + limiter(*(pInterleaved_output_2), (temp + (test >> shift))); + + pInterleaved_output_2 += 2; + + } + + + + pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW]; + + pOverlap_and_Add_Buffer_1 = Time_data; + + + pInterleaved_output = Interleaved_output; + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + /* + * Copy previous time in current buffer, also copy overlap + * and add buffer + */ + + for (i = W_L_STOP_1; i != 0; i--) + { + + Int16 win1; + Int16 dat1; + + win1 = *(pLong_Window_2--); + dat1 = *pFreq_2_Time_data_2++; + + limiter(*(pInterleaved_output), *(pOverlap_and_Add_Buffer_1)); + + pInterleaved_output += 2; + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--) + { + + temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift; + *(pOverlap_and_Add_Buffer_1++) = temp ; + + } + + break; + + + + } /* switch (wnd_seq) */ + + } /* if (exp < 16) */ + + else + { + /* all zeros buffer or excessive down shift */ + + /* Overlap and add, setup buffer for next iteration */ + pOverlap_and_Add_Buffer_1 = &Time_data[0]; + + pInterleaved_output = Interleaved_output; + + + temp = (*pOverlap_and_Add_Buffer_1++); + for (i = LONG_WINDOW; i != 0; i--) + { + + limiter(*(pInterleaved_output), temp); + + pInterleaved_output += 2; + temp = (*pOverlap_and_Add_Buffer_1++); + } + pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0])); + } + + } + else + { + + Int32 *pScrath_mem; + Int32 *pScrath_mem_entry; + Int32 *pFrequency_data = Frequency_data; + + Int32 * pOverlap_and_Add_Buffer_1; + Int32 * pOverlap_and_Add_Buffer_2; + Int32 * pOverlap_and_Add_Buffer_1x; + Int32 * pOverlap_and_Add_Buffer_2x; + + + /* + * Frequency_data is 2*LONG_WINDOW length but only + * the first LONG_WINDOW elements are filled in, + * then the second part can be used as scratch mem, + * then grab data from one window at a time in + * reverse order. + * The upper LONG_WINDOW Int32 are used to hold the + * computed overlap and add, used in the next call to + * this function, and also as sctrach memory + */ + + /* + * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE + + |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-| + | | Store for next | | memory | + | | call | | | + | | | | | + |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++| + | | | | | + 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW + + | | + W_L_STOP_2 | | + |<-- -->| + SHORT_WINDOW + + HALF_SHORT_WINDOW + * + */ + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ + LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW]; + + /* + * Initialize to zero, only the firt short window used in overlap + * and add + */ + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + + /* + * Showt windows are evaluated in decresing order. Windows from 7 + * to 0 are break down in four cases: window numbers 7 to 5, 4, 3, + * and 2 to 0. + * The data from short windows 3 and 4 is situated at the boundary + * between the 'overlap and add' buffer and the output buffer. + */ + for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--) + { + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* W_L_STOP_1 == (LONG_WINDOW - SHORT_WINDOW)>>1 */ + pOverlap_and_Add_Buffer_1 = + &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd]; + + + pOverlap_and_Add_Buffer_2 = + pOverlap_and_Add_Buffer_1 + SHORT_WINDOW; + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + + + /* + * For short windows from 7 to 5 + * | ========================= + * | | 5 6 7 + * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ \/ \|/ | \/ \/ \/ \ + * / /\ /\ /\ /|\ | /\ /\ /\ \ + * / / \ / \ / \ / | \ | / \ / \ / \ \ + * / / \/ \/ \/ | \|/ \/ \ \ \ + * --------------------------------|---[///////////////////////]-------- + * + */ + + + shift = exp + 15 - SCALING; + + + for (i = SHORT_WINDOW; i != 0; i--) + { + Int16 win1, win2; + Int16 dat1, dat2; + + dat2 = *(pFreq_2_Time_data_2++); + win2 = *(pShort_Window_2--); + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift); + + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */ + + + wnd = NUM_SHORT_WINDOWS / 2; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + /* + * scratch memory is allocated in an unused part of memory + */ + + + pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW]; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 + + HALF_SHORT_WINDOW; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short window 4 + * ====|=========== + * | 4 + * | | | | + * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_ + * / \/ \/ \/ | \|/ | \/ | \/ \/ \ + * / /\ /\ /\ | /|\ | /\ | /\ /\ \ + * / / \ / \ / \ | / | \ | / \ | / \ / \ \ + * / / \/ \/ \|/ | \|/ \|/ \/ \ \ + * ------------------------------[\\\|\\\|//////]------------------- + * | | A | B | C | + * | + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + { + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift; + + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + /* -------- segment C ---------------*/ + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift); + + temp = *pOverlap_and_Add_Buffer_2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + } + + } /* if (exp < 16) */ + else + { + pv_memset( + pScrath_mem, + 0, + HALF_SHORT_WINDOW*sizeof(*pScrath_mem)); + + pv_memset( + pOverlap_and_Add_Buffer_1, + 0, + HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1)); + } + + + wnd = NUM_SHORT_WINDOWS / 2 - 1; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + pScrath_mem_entry = + &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW]; + + + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW]; + + /* point to end of buffer less HALF_SHORT_WINDOW */ + + pInterleaved_output_2 = &Interleaved_output[2*(LONG_WINDOW - HALF_SHORT_WINDOW)]; + pInterleaved_output = pInterleaved_output_2; + + pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * For short window 3 + * ===========|==== + * 3 | + * | | | | + * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_ + * / \/ \/ | \/ | \|/ | \/ \/ \/ \ + * / /\ /\ | /\ | /|\ | /\ /\ /\ \ + * / / \ / \ | / \ | / | \ | / \ / \ / \ \ + * / / \/ \|/ \|/ | \|/ \/ \ \ \ + * -----|------------------[\\\\\\|///|///]-------------------------- + * | | A | B | C | + * + * W_L_STOP_1 + */ + + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + shift = exp + 15 - SCALING; + + Int16 win1; + Int16 dat1; + /* -------- segment A ---------------*/ + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + for (i = SHORT_WINDOW; i != 0; i--) + { + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + } + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + + /* -------- segment B ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp = *(pScrath_mem++) + test; + + test = *(pOverlap_and_Add_Buffer_1x++); + limiter(*(pInterleaved_output), (temp + test)); + + + pInterleaved_output += 2; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + + } + + /* -------- segment C ---------------*/ + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + + temp = fxp_mul_16_by_16(dat1, win1) >> shift; + + *(pOverlap_and_Add_Buffer_1++) += temp; + + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + } + + + } /* if (exp < 16) */ + else + { + + pv_memset( + pScrath_mem, + 0, + SHORT_WINDOW*sizeof(*pScrath_mem)); + + pScrath_mem += SHORT_WINDOW; + + temp = *(pScrath_mem++); + for (i = HALF_SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp)); + + pInterleaved_output += 2; + temp = *(pScrath_mem++); + + } + } + + + for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--) + { + + + pInterleaved_output_2 -= (SHORT_WINDOW * 2); + pInterleaved_output = pInterleaved_output_2; + + /* + * The same memory is used as scratch in every iteration + */ + pScrath_mem = pScrath_mem_entry; + + pOverlap_and_Add_Buffer_2x = + &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; + + pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW]; + + + + exp = imdct_fxp( + (Int32 *)pFreqInfo, + freq_2_time_buffer, + SHORT_BLOCK1, + Q_format, + abs_max_per_window[wnd]); + + /* + * If all element are zero or if the exponent is bigger than + * 16 ( it becomes an undefined shift) -> skip + */ + + if (exp < 16) + { + + pFreq_2_Time_data_1 = &pFreqInfo[0]; + pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW]; + + + /* + * Each of the eight short blocks is windowed separately. + * Window shape decisions are made on a frame-by-frame + * basis. + */ + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0]; + + if (wnd == 0) + { + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_prev_bk][0]; + } + + pShort_Window_2 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + + /* + * For short windows from 2 to 0 + * + * ========================= + * | + * 0 1 2 | | + * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_ + * / \/ \/ \/ | \|/ \/ \/ \/ \ + * / /\ /\ /\ | /|\ /\ /\ /\ \ + * / / \ / \ / \ | / | \ / \ / \ / \ \ + * / / \/ \/ \|/ | \/ \/ \ \ \ + * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|----------------------------- + * | + * + * W_L_STOP_1 + */ + + shift = exp + 15 - SCALING; + + Int16 dat1 = *(pFreq_2_Time_data_2++); + Int16 win1 = *(pShort_Window_2--); + + temp = *(pScrath_mem); + for (i = SHORT_WINDOW; i != 0; i--) + { + test = fxp_mul_16_by_16(dat1, win1) >> shift; + + temp += test; + dat1 = *(pFreq_2_Time_data_1++); + win1 = *(pShort_Window_1++); + + limiter(*(pInterleaved_output), (temp + *(pOverlap_and_Add_Buffer_2x++))); + + pInterleaved_output += 2; + + *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift; + dat1 = *(pFreq_2_Time_data_2++); + win1 = *(pShort_Window_2--); + temp = *(pScrath_mem); + + } + + } /* if (exp < 16) */ + else + { + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + test)); + + pInterleaved_output += 2; + + *(pScrath_mem++) = 0; + test = *(pScrath_mem); + temp = *(pOverlap_and_Add_Buffer_2x++); + } + } + + } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */ + + pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1]; + + pScrath_mem = pScrath_mem_entry; + + pInterleaved_output_2 -= (SHORT_WINDOW * 2); + pInterleaved_output = pInterleaved_output_2; + + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + for (i = SHORT_WINDOW; i != 0; i--) + { + limiter(*(pInterleaved_output), (temp + test)); + + pInterleaved_output += 2; + test = *(pScrath_mem++); + temp = *(pOverlap_and_Add_Buffer_2x++); + + } + + pOverlap_and_Add_Buffer_1x = Time_data; + + pInterleaved_output = Interleaved_output; + + + temp = *(pOverlap_and_Add_Buffer_1x++); + for (i = W_L_STOP_1; i != 0; i--) + { + limiter(*(pInterleaved_output), temp); + + pInterleaved_output += 2; + temp = *(pOverlap_and_Add_Buffer_1x++); + + } + + pOverlap_and_Add_Buffer_1x = &Time_data[0]; + + pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW]; + + /* + * update overlap and add buffer, + * so is ready for next iteration + */ + + for (i = 0; i < W_L_STOP_2; i++) + { + temp = *(pOverlap_and_Add_Buffer_2++); + *(pOverlap_and_Add_Buffer_1x++) = temp; + } + + pv_memset( + pOverlap_and_Add_Buffer_1x, + 0, + W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x)); + + } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + + + + +} /* trans4m_freq_2_time_fxp */ + + + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_time_2_freq_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_time_2_freq_fxp.c new file mode 100644 index 00000000..b52fb31b --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/trans4m_time_2_freq_fxp.c @@ -0,0 +1,600 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: trans4m_time_2_freq_fxp.cpp + Function: trans4m_time_2_freq_fxp + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Time2Freq_data = buffer with data in the time domain, it holds 2048 + points of input time data + Output holds frequency (first 1024 points ) + type Int32 + + wnd_seq = window sequence + type WINDOW_SEQUENCE + + wnd_shape_prev_bk = previous window shape type + type Int + + wnd_shape_this_bk = current window shape type + type Int + + pQ_format = Holds the Q format of the data in, and data out + type Int * + + mem_4_in_place_FFT[] = scratch memory for computing FFT, 1024 point + type Int32 + + + + Local Stores/Buffers/Pointers Needed: + None + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Frequency information (1024 pts.) is returned in Time2Freq_data + pQ_format content spectral coefficients Q format + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + +The time/frequency representation of the signal is mapped onto the frequency +domain by feeding it into the filterbank module. This module consists of +a modified discrete cosine transform (MDCT), (windowing and DCT). +In order to adapt the time/frequency resolution of the filterbank to the + characteristics of the input signal, a block switching tool is also +adopted. N represents the window length, where N is a function of the +window_sequence. For each channel, the N time values are transformed into the +N/2 frequency domain values via the MDCT. + +The adaptation of the time-frequency resolution of the filterbank to the +characteristics of the input signal is done by shifting between transforms +whose input lengths are either 2048 or 256 samples. By enabling the block +switching tool, the following transitions are meaningful: + +from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE + ONLY_LONG_SEQUENCE + +from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE + EIGHT_SHORT_SEQUENCE + +Window shape decisions are made by the encoder on a frame-by-frame-basis. +The window selected is applicable to the second half of the window function +only, since the first half is constrained to use the appropriate window +shape from the preceding frame. +The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are +the last 1024 values of the previous window_sequence concatenated with 1024 +values of the current block. The formula below shows this fact: + + | x(i-1)(n+1024) for 0 < n < 1024 + x'(i)(n) { + | x(i)(n) for 1024 < n < 2048 + + + +Once the window shape is selected, the window_shape syntax element is +initialized. Together with the chosen window_sequence all information needed +for windowing exist. +With the window halves described below all window_sequences can be assembled. +For window_shape == 1, the window coefficients are given by the Kaiser - +Bessel derived (KBD) window. +Otherwise, for window_shape == 0, a sine window is employed. + +The window length N can be 2048 or 256 for the KBD and the sine window. +All four window_sequences explained below have a total length of 2048 +samples. +For all kinds of window_sequences the window_shape of the left half of +the first transform window is determined by the window shape of the previous +block. +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement a scheme to switch between window types and + in turn perform time to frequency transformations + + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3:1999, pag 111 + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF ( wnd_seq == EIGHT_SHORT_SEQUENCE) + THEN + + + FOR ( wnd=0; wndthis_bk][SHORT_WINDOW_m_1] + + FOR( i=0, j=SHORT_WINDOW; ithis_bk][SHORT_WINDOW_m_1]; + + FOR ( i=0; iprev_bk][0]; + + FOR ( i=0; ithis_bk][LONG_WINDOW_m_1]; + + FOR ( i=0; i 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2++) >> shift; + pAux_temp_2++; + + } + + + /* data unchanged from LONG_WINDOW to W_L_START_1 */ + pAux_temp_1 = &pAux_temp[LONG_WINDOW]; + if (shift) + { + for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--) + { + *(pAux_temp_1++) >>= shift; + *(pAux_temp_1++) >>= shift; + } + } + + + pAux_temp_1 = &pAux_temp[W_L_START_1]; + pAux_temp_2 = &pAux_temp_1[HALF_SHORT_WINDOW]; + + pShort_Window_1 = + &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1]; + + pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW; + + for (i = HALF_SHORT_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1--) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2--) >> shift; + pAux_temp_2++; + + } + + pAux_temp_1 = &pAux_temp[W_L_START_2]; + + pv_memset( + pAux_temp_1, + 0, + (LONG_BLOCK1 - W_L_START_2)*sizeof(*pAux_temp_1)); + + break; + + + case LONG_STOP_SEQUENCE: + + pv_memset( + pAux_temp_1, + 0, + (W_L_STOP_1)*sizeof(*pAux_temp_1)); + + pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0]; + pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW]; + + pAux_temp_1 = &pAux_temp_1[W_L_STOP_1]; + pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW; + + for (i = HALF_SHORT_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2++) >> shift; + pAux_temp_2++; + + + } + + /* data unchanged from W_L_STOP_2 to LONG_WINDOW */ + pAux_temp_1 = &pAux_temp[W_L_STOP_2]; + + if (shift) + { + for (i = ((LONG_WINDOW - W_L_STOP_2) >> 1); i != 0; i--) + { + *(pAux_temp_1++) >>= shift; + *(pAux_temp_1++) >>= shift; + } + } + + + + pAux_temp_1 = &pAux_temp[LONG_WINDOW]; + pAux_temp_2 = pAux_temp_1 + HALF_LONG_WINDOW; + + pLong_Window_1 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + pLong_Window_2 = &pLong_Window_1[-HALF_LONG_WINDOW]; + + for (i = HALF_LONG_WINDOW; i > 0; i--) + { + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1--) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift; + pAux_temp_2++; + + } + + break; + + case ONLY_LONG_SEQUENCE: + default: + + pAux_temp_2 = &pAux_temp[LONG_WINDOW]; + + pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0]; + + + pLong_Window_2 = + &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1]; + + + for (i = LONG_WINDOW; i > 0; i--) + { + + *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift; + pAux_temp_1++; + *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift; + pAux_temp_2++; + } + + break; + + } /* end switch ( wnd_seq) */ + + + + *pQ_format += mdct_fxp( + pAux_temp, + mem_4_in_place_FFT, + LONG_BLOCK1); + + + } /* end if( wnd_seq != EIGHT_SHORT_SEQUENCE) */ + + + + /*****************************************/ + /* decoding process for short window */ + /*****************************************/ + + /* + * For short window the following code will be applied + * in the future when short window is supported in the + * standards + */ + /*------------------------------------------------------------------------- + + * pAux_temp = &mem_4_in_place_FFT[(2*SHORT_BLOCK1)]; + * + * for ( wnd=0; wnd0; i--) + * { + * temp = (*pAux_temp_1) * *pShort_Window_1++; + * *pAux_temp_1++ = (temp + 0x08000L) >> 16; + * + * temp = (*pAux_temp_2) * *pShort_Window_2--; + * *pAux_temp_2++ = (temp + 0x08000L) >> 16; + * + * } + * + * + * exp = mdct_fxp( + * pAux_temp, + * mem_4_in_place_FFT, + * SHORT_BLOCK1); + * + * + * exp += Q_aux; + * + * pAux_temp_1 = pAux_temp; + * pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW; + * pTime_data_1 = &Time2Freq_data[wnd*SHORT_WINDOW]; + * pTime_data_2 = pTime_data_1 + HALF_SHORT_WINDOW; + * + * + * if (exp > 0) + * { + * for ( i=HALF_SHORT_WINDOW; i>0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++>>exp); + * *pTime_data_2++ = (*pAux_temp_2++>>exp); + * } + * } + * else if (exp < 0) + * { + * exp = -exp; + * for ( i=HALF_SHORT_WINDOW; i>0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++<0; i--) + * { + * *pTime_data_1++ = (*pAux_temp_1++); + * *pTime_data_2++ = (*pAux_temp_2++); + * } + * } + * + * } + * + * } + * + *--------------------------------------------------------------------------*/ + +} /* trans4m_time_2_freq_fxp */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.c new file mode 100644 index 00000000..8524e895 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.c @@ -0,0 +1,602 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: unpack_idx.cpp + Function: unpack_idx + unpack_idx_sgn + unpack_idx_esc + +------------------------------------------------------------------------------ + INPUT AND OUTPUT DEFINITIONS + + Inputs: + Int quant_spec[] = Array for storage of the quantized + spectral coefficients. Length is either 2 or 4. + See Ref #1, Page 76 for a complete description. + + Int codeword_indx = The index into the Huffman table. + Range is [1-288] + + const Hcb *pHuffCodebook = Pointer to HuffmanCodebook information. + + BITS *pInputStream = Pointer to the bitstream buffer. + Int *max = Pointer to maximum coefficient value. + + Local Stores/Buffers/Pointers Needed: + const UInt div_mod[18] = An array with the values for 1/mod + stored in Q-formats 13. + + Global Stores/Buffers/Pointers Needed: + None + + Outputs: + None + + Pointers and Buffers Modified: + Int quant_spec[] = Output (the quantized and signed spectral coefficients) + returned via this pointer. + + Local Stores Modified: + None + + Global Stores Modified: + None + +------------------------------------------------------------------------------ + FUNCTION DESCRIPTION + + This function decodes quantized spectral coefficients and decode their signs + from the input bitstream. Quantized spectral coefficients are transmitted as + four-tuples or 2-tuples, and this information is conveyed to the function via + the variable HuffCodebook->dim. + + See Reference #1 for a complete description +------------------------------------------------------------------------------ + REQUIREMENTS + + This function shall correctly calculate pQuantSpec[], given the inputs + + codeword_indx = {1-288}; + HuffCodebook->off = {0, 1, 4}; + HuffCodebook->mod = {3, 8, 9, 13, 17}; + + mod = LAV + 1 if unsigned codebook + mod = 2*LAV + 1 if signed codebook + + Range of values for LAV is {2,7,12,16} if unsigned + {1,4} if signed + + Additionally, + LAV <= 2 if dim == 4 + + This restricts mod == 3 if dim == 4 + and mod == {3, 8, 9, 13, 17} if dim == 2 + + This function will NOT function correctly if fed values that do not + meet the requirements as stated above. + + This limitation on the range of values was determined by analysis + of Reference #1 (see below.) + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 14496-3:1999(E) + Part 3 + Subpart 4.6.3.3 Decoding Process + Subpart 4.6.4 Tables + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ + PSEUDO-CODE + + IF (pHuffCodebook->dim == 4) + *(pQuantSpec) = codeword_indx/(3^3); + codeword_indx = codeword_indx - *(pQuantSpec)*(3^3); + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + + *(pQuantSpec) = codeword_indx/(3^2); + codeword_indx = codeword_indx - *(pQuantSpec)*(3^2); + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + ENDIF + + *(pQuantSpec) = codeword_indx/mod; + codeword_indx = codeword_indx - (*pQuantSpec)*mod; + *(pQuantSpec) = *(pQuantSpec) - off; + + pQuantSpec = pQuantSpec + 1; + + *(pQuantSpec) = codeword_indx - off; + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "config.h" + +#include "pv_audio_type_defs.h" +#include "s_hcb.h" +#include "ibstream.h" +#include "unpack_idx.h" + +#include "fxp_mul32.h" + + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ +#define DIV_3_CUBED 19 /* 19 = 1/27 in Q-9 format */ +#define THREE_CUBED 27 /* 27 = 3^3 */ + +#define DIV_3_SQUARED 57 /* 57 = 1/9 in Q-9 format */ +#define THREE_SQUARED 9 /* 9 = 3^2 */ + +#define Q_FORMAT_MOD 13 /* Q-format for 1/mod table */ +#define Q_FORMAT_MOD2 9 /* Q-format for DIV_3_SQUARED */ +#define Q_FORMAT_MOD3 9 /* Q-format for DIV_3_CUBED */ + +#define LOWER_5_BITS_MASK 0x1F + + +#if ( defined(PV_ARM_V5) || defined(PV_ARM_V4)) + +static inline Int32 abs1(Int32 x) +{ + Int32 z; + /* + z = x - (x<0); + x = z ^ sign(z) + */ + __asm + { + sub z, x, x, lsr #31 + eor x, z, z, asr #31 + } + return (x); +} + +#define pv_abs(x) abs1(x) + + +#else + +#define pv_abs(x) ((x) > 0)? (x) : (-x) + +#endif + + + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL STORE/BUFFER/POINTER DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------- + Possible values for mod = {3,8,9,13,17} + + There exists "empty" spaces in the table. These can potentially + be utilized by other const tables, if available memory becomes an issue. +---------------------------------------------------------------------------*/ + +const Int div_mod[18] = /* mod index Q-format */ +{ + /* ----------------------- */ + 0xCC, /* | | 0 | */ + 0xCC, /* | | 1 | */ + 0xCC, /* | | 2 | */ + 2731, /* | 3 | 3 | 13 */ + 0xCC, /* | | 4 | */ + 0xCC, /* | | 5 | */ + 0xCC, /* | | 6 | */ + 0xCC, /* | | 7 | */ + 1025, /* | 8 | 8 | 13 */ + 911, /* | 9 | 9 | 13 */ + 0xCC, /* | | 10 | */ + 0xCC, /* | | 11 | */ + 0xCC, /* | | 12 | */ + 631, /* | 13 | 13 | 13 */ + 0xCC, /* | | 14 | */ + 0xCC, /* | | 15 | */ + 0xCC, /* | | 16 | */ + 482, /* | 17 | 17 | 13 */ +}; + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; FUNCTION CODE +----------------------------------------------------------------------------*/ +void unpack_idx( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int16 *pQuantSpec = &quant_spec[0]; + Int temp_spec; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + OSCL_UNUSED_ARG(pInputStream); + + + if (pHuffCodebook->dim == DIMENSION_4) + { + /* Calculate pQuantSpec[0] */ + + temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3; + + codeword_indx -= temp_spec * THREE_CUBED; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + /* Calculate pQuantSpec[1] */ + temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2; + + codeword_indx -= temp_spec * THREE_SQUARED; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + + /* + * Calculate pQuantSpec[2] if dim == 4 + * Calculate pQuantSpec[0] if dim == 2 + */ + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + *pQuantSpec++ = (Int16)temp_spec; + + temp_spec = pv_abs(temp_spec); + + + if (temp_spec > *max) + { + *max = temp_spec; + } + + /* + * Calculate pQuantSpec[3] if dim == 4 + * Calculate pQuantSpec[1] if dim == 2 + */ + codeword_indx -= off; + *pQuantSpec = (Int16)codeword_indx ; + + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + + + return ; +} /* unpack_idx */ + + +void unpack_idx_sgn( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int16 *pQuantSpec = &quant_spec[0]; + Int temp_spec; + Int sgn; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + + + if (pHuffCodebook->dim == DIMENSION_4) + { + /* Calculate pQuantSpec[0] */ + preload_cache((Int32 *)pQuantSpec); + temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3; + + codeword_indx -= temp_spec * THREE_CUBED; + + temp_spec -= off; + if (temp_spec) + { + sgn = get1bits(pInputStream); + + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + } + else + { + *pQuantSpec++ = 0; + } + + /* Calculate pQuantSpec[1] */ + temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2; + + codeword_indx -= temp_spec * THREE_SQUARED; + + temp_spec -= off; + if (temp_spec) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + else + { + *pQuantSpec++ = 0; + } + } + + /* + * Calculate pQuantSpec[2] if dim == 4 + * Calculate pQuantSpec[0] if dim == 2 + */ + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + if (temp_spec) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec); + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + } + else + { + *pQuantSpec++ = 0; + } + + /* + * Calculate pQuantSpec[3] if dim == 4 + * Calculate pQuantSpec[1] if dim == 2 + */ + codeword_indx -= off; + if (codeword_indx) + { + + sgn = get1bits(pInputStream); + + *pQuantSpec = (Int16)((sgn) ? -codeword_indx : codeword_indx); + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + } + else + { + *pQuantSpec = 0; + } + + return ; +} /* unpack_idx_sgn */ + + +void unpack_idx_esc( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max) +{ + Int temp_spec; + Int sgn1 = 0, sgn2 = 0; + Int N; + Int32 esc_seq; + + const Int mod = pHuffCodebook->mod; + const Int off = pHuffCodebook->off; + + + temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD; + + codeword_indx -= temp_spec * mod; + + temp_spec -= off; + if (temp_spec) + { + sgn1 = get1bits(pInputStream); + } + + codeword_indx -= off; + if (codeword_indx) + { + sgn2 = get1bits(pInputStream); + } + + + if ((temp_spec & LOWER_5_BITS_MASK) == 16) + { + N = 3; + do + { + N++; + + esc_seq = get1bits(pInputStream); + + } + while (esc_seq != 0); + + esc_seq = getbits(N, pInputStream); + + esc_seq += (1 << N); + + + temp_spec = (Int)((temp_spec * esc_seq) >> 4); + + } + + + if (sgn1) + { + quant_spec[0] = (Int16)(-temp_spec); + } + else + { + quant_spec[0] = (Int16)temp_spec; + } + + temp_spec = pv_abs(temp_spec); + + if (temp_spec > *max) + { + *max = temp_spec; + } + + if ((codeword_indx & LOWER_5_BITS_MASK) == 16) + { + N = 3; + do + { + N++; + + esc_seq = get1bits(pInputStream); + + } + while (esc_seq != 0); + + esc_seq = getbits(N, pInputStream); + + esc_seq += (1 << N); + + codeword_indx = (Int)((codeword_indx * esc_seq) >> 4); + } + + + + + if (sgn2) + { + quant_spec[1] = (Int16)(-codeword_indx); + } + else + { + quant_spec[1] = (Int16)codeword_indx; + } + + + codeword_indx = pv_abs(codeword_indx); + + if (codeword_indx > *max) + { + *max = codeword_indx; + } + + + return ; +} /* unpack_idx_esc */ diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.h new file mode 100644 index 00000000..c0a32606 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/unpack_idx.h @@ -0,0 +1,108 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: unpack_idx.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + This header file includes the function definition for unpack_idx() + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef UNPACK_IDX_H +#define UNPACK_IDX_H + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "s_hcb.h" +#include "s_bits.h" +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. +----------------------------------------------------------------------------*/ +#define DIMENSION_4 4 + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; SIMPLE TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; ENUMERATED TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; STRUCTURES TYPEDEF'S +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; GLOBAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + + void unpack_idx( + Int16 QuantSpec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + void unpack_idx_sgn( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + void unpack_idx_esc( + Int16 quant_spec[], + Int codeword_indx, + const Hcb *pHuffCodebook, + BITS *pInputStream, + Int *max); + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- +; END +----------------------------------------------------------------------------*/ +#endif + + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/window_block_fxp.h b/components/spotify/cspot/bell/external/opencore-aacdec/src/window_block_fxp.h new file mode 100644 index 00000000..59130480 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/window_block_fxp.h @@ -0,0 +1,207 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: window_block_fxp.h + +------------------------------------------------------------------------------ + INCLUDE DESCRIPTION + + Header file for window and block switch + + +------------------------------------------------------------------------------ + REFERENCES + + (1) ISO/IEC 13818-7 Part 7: Advanced Audo Coding (AAC) + + + (2) MPEG-2 NBC Audio Decoder + "This software module was originally developed by AT&T, Dolby + Laboratories, Fraunhofer Gesellschaft IIS in the course of development + of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and + 3. This software module is an implementation of a part of one or more + MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4 + Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio + standards free license to this software module or modifications thereof + for use in hardware or software products claiming conformance to the + MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software + module in hardware or software products are advised that this use may + infringe existing patents. The original developer of this software + module and his/her company, the subsequent editors and their companies, + and ISO/IEC have no liability for use of this software module or + modifications thereof in an implementation. Copyright is not released + for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original + developer retains full right to use the code for his/her own purpose, + assign or donate the code to a third party and to inhibit third party + from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products. + This copyright notice must be included in all copies or derivative + works." + Copyright(c)1996. + +------------------------------------------------------------------------------ +*/ + +/*---------------------------------------------------------------------------- +; CONTINUE ONLY IF NOT ALREADY DEFINED +----------------------------------------------------------------------------*/ +#ifndef WINDOW_BLOCK_FXP_H +#define WINDOW_BLOCK_FXP_H + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "e_window_shape.h" +#include "e_window_sequence.h" +#include "config.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ +#ifdef __cplusplus +extern "C" +{ +#endif + + /*---------------------------------------------------------------------------- + ; DEFINES + ; Include all pre-processor statements here. + ----------------------------------------------------------------------------*/ +#define LONG_WINDOW (1024) +#define SHORT_WINDOW (128) + +#define HALF_LONG_WINDOW (LONG_WINDOW>>1) +#define HALF_SHORT_WINDOW (SHORT_WINDOW>>1) + +#define NUM_SHORT_WINDOWS (8) +#define LONG_WINDOW_m_1 (LONG_WINDOW-1) +#define SHORT_WINDOW_m_1 (SHORT_WINDOW-1) + + /* + * Limits for window sequences, they are used to build + * each long window, they are defined in the standards + */ +#define W_L_START_1 ((3*LONG_WINDOW - SHORT_WINDOW)>>1) +#define W_L_START_2 ((3*LONG_WINDOW + SHORT_WINDOW)>>1) +#define W_L_STOP_1 ((LONG_WINDOW - SHORT_WINDOW)>>1) +#define W_L_STOP_2 ((LONG_WINDOW + SHORT_WINDOW)>>1) + + +#define LONG_BLOCK1 (2*LONG_WINDOW) +#define SHORT_BLOCK1 (2*SHORT_WINDOW) + + +#define SCALING 10 +#define ROUNDING (1<<(SCALING-1)) + + + /*---------------------------------------------------------------------------- + ; EXTERNAL VARIABLES REFERENCES + ; Declare variables used in this module but defined elsewhere + ----------------------------------------------------------------------------*/ + extern const Int16 Short_Window_KBD_fxp[ SHORT_WINDOW]; + extern const Int16 Long_Window_KBD_fxp[ LONG_WINDOW]; + extern const Int16 Short_Window_sine_fxp[ SHORT_WINDOW]; + extern const Int16 Long_Window_sine_fxp[ LONG_WINDOW]; + + extern const Int16 * const Long_Window_fxp[]; + extern const Int16 * const Short_Window_fxp[]; + + /*---------------------------------------------------------------------------- + ; SIMPLE TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; ENUMERATED TYPEDEF'S + ----------------------------------------------------------------------------*/ + + + + /*---------------------------------------------------------------------------- + ; STRUCTURES TYPEDEF'S + ----------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------- + ; GLOBAL FUNCTION DEFINITIONS + ; Function Prototype declaration + ----------------------------------------------------------------------------*/ + + void trans4m_freq_2_time_fxp( + Int32 Frequency_data[], + Int32 Time_data[], +#ifdef AAC_PLUS + Int32 Output_buffer[], +#else + Int16 Output_buffer[], +#endif + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] , + Int16 *Interleave_output + ); + + + + void trans4m_freq_2_time_fxp_1( + Int32 Frequency_data[], + Int32 Time_data[], + Int16 Output_buffer[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] + ); + + + void trans4m_freq_2_time_fxp_2( + Int32 Frequency_data[], + Int32 Time_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int Q_format, + Int32 abs_max_per_window[], + Int32 freq_2_time_buffer[] , + Int16 *Interleave_output + ); + + void trans4m_time_2_freq_fxp( + Int32 Time2Freq_data[], + WINDOW_SEQUENCE wnd_seq, + Int wnd_shape_prev_bk, + Int wnd_shape_this_bk, + Int *pQ_format, + Int32 mem_4_in_place_FFT[]); + + /*---------------------------------------------------------------------------- + ; END + ----------------------------------------------------------------------------*/ +#ifdef __cplusplus +} +#endif + +#endif /* WINDOW_BLOCK_FXP_H */ + diff --git a/components/spotify/cspot/bell/external/opencore-aacdec/src/window_tables_fxp.c b/components/spotify/cspot/bell/external/opencore-aacdec/src/window_tables_fxp.c new file mode 100644 index 00000000..e031fd18 --- /dev/null +++ b/components/spotify/cspot/bell/external/opencore-aacdec/src/window_tables_fxp.c @@ -0,0 +1,706 @@ +/* ------------------------------------------------------------------ + * Copyright (C) 1998-2009 PacketVideo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. + * See the License for the specific language governing permissions + * and limitations under the License. + * ------------------------------------------------------------------- + */ +/* + + Filename: window_tables_fxp.cpp + Functions: + + ------------------------------------------------------------------------------ + MODULE DESCRIPTION + + Window tables + + For a sine table with N points: + + w_left = sin(pi/N (n + 1/2)) for 0 =< n < N/2 + + w_rigth = sin(pi/N (n + 1/2)) for N/2 =< n < N + + + For Kaiser-Bessel derived (KBD) + + n N/2 + w_left = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for 0 =< n < N/2 + p=0 p=0 + + + N-n-1 N/2 + w_rigth = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for N/2 =< n < N + p=0 p=0 + + + W(p,a) see ISO 14496-3, pag 113 + +------------------------------------------------------------------------------ + REQUIREMENTS + + This module shall implement the fix point verwion of the windowing tables + +------------------------------------------------------------------------------ + REFERENCES + + [1] ISO 14496-3, pag 113 + +------------------------------------------------------------------------------ +*/ + + +/*---------------------------------------------------------------------------- +; INCLUDES +----------------------------------------------------------------------------*/ +#include "pv_audio_type_defs.h" +#include "window_block_fxp.h" + +/*---------------------------------------------------------------------------- +; MACROS +; Define module specific macros here +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; DEFINES +; Include all pre-processor statements here. Include conditional +; compile variables also. +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL FUNCTION DEFINITIONS +; Function Prototype declaration +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; LOCAL VARIABLE DEFINITIONS +; Variable declaration - defined here and used outside this module +----------------------------------------------------------------------------*/ + + +/*---------------------------------------------------------------------------- +; EXTERNAL FUNCTION REFERENCES +; Declare functions defined elsewhere and referenced in this module +----------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------- +; EXTERNAL VARIABLES REFERENCES +; Declare variables used in this module but defined elsewhere +----------------------------------------------------------------------------*/ + + +const Int16 Long_Window_sine_fxp[LONG_WINDOW] = +{ + + + 0x0019, 0x004B, 0x007E, 0x00B0, + 0x00E2, 0x0114, 0x0147, 0x0179, + 0x01AB, 0x01DD, 0x0210, 0x0242, + 0x0274, 0x02A7, 0x02D9, 0x030B, + 0x033D, 0x0370, 0x03A2, 0x03D4, + 0x0406, 0x0438, 0x046B, 0x049D, + 0x04CF, 0x0501, 0x0534, 0x0566, + 0x0598, 0x05CA, 0x05FC, 0x062F, + 0x0661, 0x0693, 0x06C5, 0x06F7, + 0x072A, 0x075C, 0x078E, 0x07C0, + 0x07F2, 0x0825, 0x0857, 0x0889, + 0x08BB, 0x08ED, 0x091F, 0x0951, + 0x0984, 0x09B6, 0x09E8, 0x0A1A, + 0x0A4C, 0x0A7E, 0x0AB0, 0x0AE2, + 0x0B14, 0x0B46, 0x0B78, 0x0BAB, + 0x0BDD, 0x0C0F, 0x0C41, 0x0C73, + 0x0CA5, 0x0CD7, 0x0D09, 0x0D3B, + 0x0D6D, 0x0D9F, 0x0DD1, 0x0E03, + 0x0E35, 0x0E67, 0x0E99, 0x0ECA, + 0x0EFC, 0x0F2E, 0x0F60, 0x0F92, + 0x0FC4, 0x0FF6, 0x1028, 0x105A, + 0x108B, 0x10BD, 0x10EF, 0x1121, + 0x1153, 0x1185, 0x11B6, 0x11E8, + 0x121A, 0x124C, 0x127D, 0x12AF, + 0x12E1, 0x1312, 0x1344, 0x1376, + 0x13A8, 0x13D9, 0x140B, 0x143C, + 0x146E, 0x14A0, 0x14D1, 0x1503, + 0x1534, 0x1566, 0x1598, 0x15C9, + 0x15FB, 0x162C, 0x165E, 0x168F, + 0x16C1, 0x16F2, 0x1724, 0x1755, + 0x1786, 0x17B8, 0x17E9, 0x181B, + 0x184C, 0x187D, 0x18AF, 0x18E0, + 0x1911, 0x1942, 0x1974, 0x19A5, + 0x19D6, 0x1A07, 0x1A39, 0x1A6A, + 0x1A9B, 0x1ACC, 0x1AFD, 0x1B2E, + 0x1B60, 0x1B91, 0x1BC2, 0x1BF3, + 0x1C24, 0x1C55, 0x1C86, 0x1CB7, + 0x1CE8, 0x1D19, 0x1D4A, 0x1D7B, + 0x1DAC, 0x1DDC, 0x1E0D, 0x1E3E, + 0x1E6F, 0x1EA0, 0x1ED1, 0x1F01, + 0x1F32, 0x1F63, 0x1F94, 0x1FC4, + 0x1FF5, 0x2026, 0x2056, 0x2087, + 0x20B7, 0x20E8, 0x2119, 0x2149, + 0x217A, 0x21AA, 0x21DB, 0x220B, + 0x223C, 0x226C, 0x229C, 0x22CD, + 0x22FD, 0x232E, 0x235E, 0x238E, + 0x23BE, 0x23EF, 0x241F, 0x244F, + 0x247F, 0x24AF, 0x24E0, 0x2510, + 0x2540, 0x2570, 0x25A0, 0x25D0, + 0x2600, 0x2630, 0x2660, 0x2690, + 0x26C0, 0x26F0, 0x2720, 0x274F, + 0x277F, 0x27AF, 0x27DF, 0x280F, + 0x283E, 0x286E, 0x289E, 0x28CD, + 0x28FD, 0x292D, 0x295C, 0x298C, + 0x29BB, 0x29EB, 0x2A1A, 0x2A4A, + 0x2A79, 0x2AA8, 0x2AD8, 0x2B07, + 0x2B37, 0x2B66, 0x2B95, 0x2BC4, + 0x2BF4, 0x2C23, 0x2C52, 0x2C81, + 0x2CB0, 0x2CDF, 0x2D0E, 0x2D3D, + 0x2D6C, 0x2D9B, 0x2DCA, 0x2DF9, + 0x2E28, 0x2E57, 0x2E86, 0x2EB5, + 0x2EE3, 0x2F12, 0x2F41, 0x2F70, + 0x2F9E, 0x2FCD, 0x2FFC, 0x302A, + 0x3059, 0x3087, 0x30B6, 0x30E4, + 0x3113, 0x3141, 0x316F, 0x319E, + 0x31CC, 0x31FA, 0x3229, 0x3257, + 0x3285, 0x32B3, 0x32E1, 0x330F, + 0x333E, 0x336C, 0x339A, 0x33C8, + 0x33F6, 0x3423, 0x3451, 0x347F, + 0x34AD, 0x34DB, 0x3509, 0x3536, + 0x3564, 0x3592, 0x35BF, 0x35ED, + 0x361A, 0x3648, 0x3676, 0x36A3, + 0x36D0, 0x36FE, 0x372B, 0x3759, + 0x3786, 0x37B3, 0x37E0, 0x380E, + 0x383B, 0x3868, 0x3895, 0x38C2, + 0x38EF, 0x391C, 0x3949, 0x3976, + 0x39A3, 0x39D0, 0x39FD, 0x3A29, + 0x3A56, 0x3A83, 0x3AB0, 0x3ADC, + 0x3B09, 0x3B35, 0x3B62, 0x3B8E, + 0x3BBB, 0x3BE7, 0x3C14, 0x3C40, + 0x3C6C, 0x3C99, 0x3CC5, 0x3CF1, + 0x3D1D, 0x3D4A, 0x3D76, 0x3DA2, + 0x3DCE, 0x3DFA, 0x3E26, 0x3E52, + 0x3E7D, 0x3EA9, 0x3ED5, 0x3F01, + 0x3F2D, 0x3F58, 0x3F84, 0x3FB0, + 0x3FDB, 0x4007, 0x4032, 0x405E, + 0x4089, 0x40B5, 0x40E0, 0x410B, + 0x4136, 0x4162, 0x418D, 0x41B8, + 0x41E3, 0x420E, 0x4239, 0x4264, + 0x428F, 0x42BA, 0x42E5, 0x4310, + 0x433B, 0x4365, 0x4390, 0x43BB, + 0x43E5, 0x4410, 0x443B, 0x4465, + 0x448F, 0x44BA, 0x44E4, 0x450F, + 0x4539, 0x4563, 0x458D, 0x45B8, + 0x45E2, 0x460C, 0x4636, 0x4660, + 0x468A, 0x46B4, 0x46DE, 0x4707, + 0x4731, 0x475B, 0x4785, 0x47AE, + 0x47D8, 0x4802, 0x482B, 0x4855, + 0x487E, 0x48A7, 0x48D1, 0x48FA, + 0x4923, 0x494D, 0x4976, 0x499F, + 0x49C8, 0x49F1, 0x4A1A, 0x4A43, + 0x4A6C, 0x4A95, 0x4ABE, 0x4AE6, + 0x4B0F, 0x4B38, 0x4B61, 0x4B89, + 0x4BB2, 0x4BDA, 0x4C03, 0x4C2B, + 0x4C53, 0x4C7C, 0x4CA4, 0x4CCC, + 0x4CF4, 0x4D1D, 0x4D45, 0x4D6D, + 0x4D95, 0x4DBD, 0x4DE5, 0x4E0D, + 0x4E34, 0x4E5C, 0x4E84, 0x4EAB, + 0x4ED3, 0x4EFB, 0x4F22, 0x4F4A, + 0x4F71, 0x4F99, 0x4FC0, 0x4FE7, + 0x500E, 0x5036, 0x505D, 0x5084, + 0x50AB, 0x50D2, 0x50F9, 0x5120, + 0x5147, 0x516D, 0x5194, 0x51BB, + 0x51E2, 0x5208, 0x522F, 0x5255, + 0x527C, 0x52A2, 0x52C8, 0x52EF, + 0x5315, 0x533B, 0x5361, 0x5387, + 0x53AE, 0x53D4, 0x53FA, 0x541F, + 0x5445, 0x546B, 0x5491, 0x54B7, + 0x54DC, 0x5502, 0x5527, 0x554D, + 0x5572, 0x5598, 0x55BD, 0x55E2, + 0x5608, 0x562D, 0x5652, 0x5677, + 0x569C, 0x56C1, 0x56E6, 0x570B, + 0x5730, 0x5754, 0x5779, 0x579E, + 0x57C2, 0x57E7, 0x580C, 0x5830, + 0x5854, 0x5879, 0x589D, 0x58C1, + 0x58E5, 0x590A, 0x592E, 0x5952, + 0x5976, 0x599A, 0x59BD, 0x59E1, + 0x5A05, 0x5A29, 0x5A4C, 0x5A70, + 0x5A94, 0x5AB7, 0x5ADA, 0x5AFE, + 0x5B21, 0x5B44, 0x5B68, 0x5B8B, + 0x5BAE, 0x5BD1, 0x5BF4, 0x5C17, + 0x5C3A, 0x5C5D, 0x5C7F, 0x5CA2, + 0x5CC5, 0x5CE7, 0x5D0A, 0x5D2C, + 0x5D4F, 0x5D71, 0x5D94, 0x5DB6, + 0x5DD8, 0x5DFA, 0x5E1C, 0x5E3E, + 0x5E60, 0x5E82, 0x5EA4, 0x5EC6, + 0x5EE8, 0x5F09, 0x5F2B, 0x5F4D, + 0x5F6E, 0x5F90, 0x5FB1, 0x5FD2, + 0x5FF4, 0x6015, 0x6036, 0x6057, + 0x6078, 0x6099, 0x60BA, 0x60DB, + 0x60FC, 0x611D, 0x613D, 0x615E, + 0x617F, 0x619F, 0x61C0, 0x61E0, + 0x6200, 0x6221, 0x6241, 0x6261, + 0x6281, 0x62A1, 0x62C1, 0x62E1, + 0x6301, 0x6321, 0x6341, 0x6360, + 0x6380, 0x63A0, 0x63BF, 0x63DF, + 0x63FE, 0x641D, 0x643D, 0x645C, + 0x647B, 0x649A, 0x64B9, 0x64D8, + 0x64F7, 0x6516, 0x6535, 0x6554, + 0x6572, 0x6591, 0x65AF, 0x65CE, + 0x65EC, 0x660B, 0x6629, 0x6647, + 0x6666, 0x6684, 0x66A2, 0x66C0, + 0x66DE, 0x66FC, 0x6719, 0x6737, + 0x6755, 0x6772, 0x6790, 0x67AE, + 0x67CB, 0x67E8, 0x6806, 0x6823, + 0x6840, 0x685D, 0x687A, 0x6897, + 0x68B4, 0x68D1, 0x68EE, 0x690B, + 0x6927, 0x6944, 0x6961, 0x697D, + 0x699A, 0x69B6, 0x69D2, 0x69EE, + 0x6A0B, 0x6A27, 0x6A43, 0x6A5F, + 0x6A7B, 0x6A97, 0x6AB2, 0x6ACE, + 0x6AEA, 0x6B05, 0x6B21, 0x6B3C, + 0x6B58, 0x6B73, 0x6B8E, 0x6BAA, + 0x6BC5, 0x6BE0, 0x6BFB, 0x6C16, + 0x6C31, 0x6C4C, 0x6C66, 0x6C81, + 0x6C9C, 0x6CB6, 0x6CD1, 0x6CEB, + 0x6D06, 0x6D20, 0x6D3A, 0x6D54, + 0x6D6E, 0x6D88, 0x6DA2, 0x6DBC, + 0x6DD6, 0x6DF0, 0x6E0A, 0x6E23, + 0x6E3D, 0x6E56, 0x6E70, 0x6E89, + 0x6EA2, 0x6EBC, 0x6ED5, 0x6EEE, + 0x6F07, 0x6F20, 0x6F39, 0x6F52, + 0x6F6B, 0x6F83, 0x6F9C, 0x6FB4, + 0x6FCD, 0x6FE5, 0x6FFE, 0x7016, + 0x702E, 0x7046, 0x705F, 0x7077, + 0x708F, 0x70A6, 0x70BE, 0x70D6, + 0x70EE, 0x7105, 0x711D, 0x7134, + 0x714C, 0x7163, 0x717A, 0x7192, + 0x71A9, 0x71C0, 0x71D7, 0x71EE, + 0x7205, 0x721C, 0x7232, 0x7249, + 0x7260, 0x7276, 0x728D, 0x72A3, + 0x72B9, 0x72D0, 0x72E6, 0x72FC, + 0x7312, 0x7328, 0x733E, 0x7354, + 0x7369, 0x737F, 0x7395, 0x73AA, + 0x73C0, 0x73D5, 0x73EB, 0x7400, + 0x7415, 0x742A, 0x743F, 0x7454, + 0x7469, 0x747E, 0x7493, 0x74A8, + 0x74BC, 0x74D1, 0x74E5, 0x74FA, + 0x750E, 0x7522, 0x7537, 0x754B, + 0x755F, 0x7573, 0x7587, 0x759B, + 0x75AE, 0x75C2, 0x75D6, 0x75E9, + 0x75FD, 0x7610, 0x7624, 0x7637, + 0x764A, 0x765E, 0x7671, 0x7684, + 0x7697, 0x76A9, 0x76BC, 0x76CF, + 0x76E2, 0x76F4, 0x7707, 0x7719, + 0x772C, 0x773E, 0x7750, 0x7762, + 0x7774, 0x7786, 0x7798, 0x77AA, + 0x77BC, 0x77CE, 0x77DF, 0x77F1, + 0x7803, 0x7814, 0x7825, 0x7837, + 0x7848, 0x7859, 0x786A, 0x787B, + 0x788C, 0x789D, 0x78AE, 0x78BE, + 0x78CF, 0x78E0, 0x78F0, 0x7901, + 0x7911, 0x7921, 0x7931, 0x7941, + 0x7952, 0x7962, 0x7971, 0x7981, + 0x7991, 0x79A1, 0x79B0, 0x79C0, + 0x79CF, 0x79DF, 0x79EE, 0x79FD, + 0x7A0D, 0x7A1C, 0x7A2B, 0x7A3A, + 0x7A49, 0x7A57, 0x7A66, 0x7A75, + 0x7A83, 0x7A92, 0x7AA0, 0x7AAF, + 0x7ABD, 0x7ACB, 0x7AD9, 0x7AE7, + 0x7AF5, 0x7B03, 0x7B11, 0x7B1F, + 0x7B2D, 0x7B3A, 0x7B48, 0x7B55, + 0x7B63, 0x7B70, 0x7B7D, 0x7B8B, + 0x7B98, 0x7BA5, 0x7BB2, 0x7BBF, + 0x7BCB, 0x7BD8, 0x7BE5, 0x7BF1, + 0x7BFE, 0x7C0A, 0x7C17, 0x7C23, + 0x7C2F, 0x7C3B, 0x7C47, 0x7C53, + 0x7C5F, 0x7C6B, 0x7C77, 0x7C83, + 0x7C8E, 0x7C9A, 0x7CA5, 0x7CB1, + 0x7CBC, 0x7CC7, 0x7CD2, 0x7CDD, + 0x7CE8, 0x7CF3, 0x7CFE, 0x7D09, + 0x7D14, 0x7D1E, 0x7D29, 0x7D33, + 0x7D3E, 0x7D48, 0x7D52, 0x7D5C, + 0x7D67, 0x7D71, 0x7D7B, 0x7D84, + 0x7D8E, 0x7D98, 0x7DA2, 0x7DAB, + 0x7DB5, 0x7DBE, 0x7DC8, 0x7DD1, + 0x7DDA, 0x7DE3, 0x7DEC, 0x7DF5, + 0x7DFE, 0x7E07, 0x7E10, 0x7E18, + 0x7E21, 0x7E29, 0x7E32, 0x7E3A, + 0x7E42, 0x7E4B, 0x7E53, 0x7E5B, + 0x7E63, 0x7E6B, 0x7E73, 0x7E7A, + 0x7E82, 0x7E8A, 0x7E91, 0x7E99, + 0x7EA0, 0x7EA7, 0x7EAF, 0x7EB6, + 0x7EBD, 0x7EC4, 0x7ECB, 0x7ED2, + 0x7ED8, 0x7EDF, 0x7EE6, 0x7EEC, + 0x7EF3, 0x7EF9, 0x7EFF, 0x7F05, + 0x7F0C, 0x7F12, 0x7F18, 0x7F1E, + 0x7F23, 0x7F29, 0x7F2F, 0x7F35, + 0x7F3A, 0x7F40, 0x7F45, 0x7F4A, + 0x7F50, 0x7F55, 0x7F5A, 0x7F5F, + 0x7F64, 0x7F69, 0x7F6D, 0x7F72, + 0x7F77, 0x7F7B, 0x7F80, 0x7F84, + 0x7F88, 0x7F8D, 0x7F91, 0x7F95, + 0x7F99, 0x7F9D, 0x7FA1, 0x7FA4, + 0x7FA8, 0x7FAC, 0x7FAF, 0x7FB3, + 0x7FB6, 0x7FB9, 0x7FBD, 0x7FC0, + 0x7FC3, 0x7FC6, 0x7FC9, 0x7FCC, + 0x7FCE, 0x7FD1, 0x7FD4, 0x7FD6, + 0x7FD9, 0x7FDB, 0x7FDD, 0x7FE0, + 0x7FE2, 0x7FE4, 0x7FE6, 0x7FE8, + 0x7FEA, 0x7FEB, 0x7FED, 0x7FEF, + 0x7FF0, 0x7FF2, 0x7FF3, 0x7FF5, + 0x7FF6, 0x7FF7, 0x7FF8, 0x7FF9, + 0x7FFA, 0x7FFB, 0x7FFC, 0x7FFC, + 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF + +}; + + +const Int16 Short_Window_sine_fxp[SHORT_WINDOW] = +{ + + 0x00C9, 0x025B, 0x03ED, 0x057F, + 0x0711, 0x08A2, 0x0A33, 0x0BC4, + 0x0D54, 0x0EE3, 0x1072, 0x1201, + 0x138F, 0x151C, 0x16A8, 0x1833, + 0x19BE, 0x1B47, 0x1CCF, 0x1E57, + 0x1FDD, 0x2161, 0x22E5, 0x2467, + 0x25E8, 0x2767, 0x28E5, 0x2A61, + 0x2BDC, 0x2D55, 0x2ECC, 0x3041, + 0x31B5, 0x3326, 0x3496, 0x3604, + 0x376F, 0x38D9, 0x3A40, 0x3BA5, + 0x3D07, 0x3E68, 0x3FC5, 0x4121, + 0x427A, 0x43D0, 0x4524, 0x4675, + 0x47C3, 0x490F, 0x4A58, 0x4B9D, + 0x4CE0, 0x4E20, 0x4F5D, 0x5097, + 0x51CE, 0x5302, 0x5432, 0x5560, + 0x568A, 0x57B0, 0x58D3, 0x59F3, + 0x5B0F, 0x5C28, 0x5D3E, 0x5E4F, + 0x5F5D, 0x6068, 0x616E, 0x6271, + 0x6370, 0x646C, 0x6563, 0x6656, + 0x6746, 0x6832, 0x6919, 0x69FD, + 0x6ADC, 0x6BB7, 0x6C8E, 0x6D61, + 0x6E30, 0x6EFB, 0x6FC1, 0x7083, + 0x7140, 0x71F9, 0x72AE, 0x735E, + 0x740A, 0x74B2, 0x7555, 0x75F3, + 0x768D, 0x7722, 0x77B3, 0x783F, + 0x78C7, 0x794A, 0x79C8, 0x7A41, + 0x7AB6, 0x7B26, 0x7B91, 0x7BF8, + 0x7C59, 0x7CB6, 0x7D0E, 0x7D62, + 0x7DB0, 0x7DFA, 0x7E3E, 0x7E7E, + 0x7EB9, 0x7EEF, 0x7F21, 0x7F4D, + 0x7F74, 0x7F97, 0x7FB4, 0x7FCD, + 0x7FE1, 0x7FF0, 0x7FF9, 0x7FFE +}; + + + +const Int16 Long_Window_KBD_fxp[LONG_WINDOW] = +{ + + 0x000A, 0x000E, 0x0012, 0x0015, + 0x0019, 0x001C, 0x0020, 0x0023, + 0x0026, 0x002A, 0x002D, 0x0030, + 0x0034, 0x0038, 0x003B, 0x003F, + 0x0043, 0x0047, 0x004B, 0x004F, + 0x0053, 0x0057, 0x005B, 0x0060, + 0x0064, 0x0069, 0x006D, 0x0072, + 0x0077, 0x007C, 0x0081, 0x0086, + 0x008B, 0x0091, 0x0096, 0x009C, + 0x00A1, 0x00A7, 0x00AD, 0x00B3, + 0x00B9, 0x00BF, 0x00C6, 0x00CC, + 0x00D3, 0x00DA, 0x00E0, 0x00E7, + 0x00EE, 0x00F5, 0x00FD, 0x0104, + 0x010C, 0x0113, 0x011B, 0x0123, + 0x012B, 0x0133, 0x013C, 0x0144, + 0x014D, 0x0156, 0x015F, 0x0168, + 0x0171, 0x017A, 0x0183, 0x018D, + 0x0197, 0x01A1, 0x01AB, 0x01B5, + 0x01BF, 0x01CA, 0x01D4, 0x01DF, + 0x01EA, 0x01F5, 0x0200, 0x020C, + 0x0217, 0x0223, 0x022F, 0x023B, + 0x0247, 0x0253, 0x0260, 0x026D, + 0x027A, 0x0287, 0x0294, 0x02A1, + 0x02AF, 0x02BC, 0x02CA, 0x02D8, + 0x02E7, 0x02F5, 0x0304, 0x0312, + 0x0321, 0x0331, 0x0340, 0x034F, + 0x035F, 0x036F, 0x037F, 0x038F, + 0x03A0, 0x03B0, 0x03C1, 0x03D2, + 0x03E3, 0x03F5, 0x0406, 0x0418, + 0x042A, 0x043C, 0x044F, 0x0461, + 0x0474, 0x0487, 0x049A, 0x04AE, + 0x04C1, 0x04D5, 0x04E9, 0x04FD, + 0x0512, 0x0526, 0x053B, 0x0550, + 0x0566, 0x057B, 0x0591, 0x05A7, + 0x05BD, 0x05D3, 0x05EA, 0x0601, + 0x0618, 0x062F, 0x0646, 0x065E, + 0x0676, 0x068E, 0x06A6, 0x06BF, + 0x06D8, 0x06F1, 0x070A, 0x0723, + 0x073D, 0x0757, 0x0771, 0x078C, + 0x07A6, 0x07C1, 0x07DC, 0x07F7, + 0x0813, 0x082F, 0x084B, 0x0867, + 0x0884, 0x08A0, 0x08BD, 0x08DA, + 0x08F8, 0x0916, 0x0933, 0x0952, + 0x0970, 0x098F, 0x09AE, 0x09CD, + 0x09EC, 0x0A0C, 0x0A2C, 0x0A4C, + 0x0A6C, 0x0A8D, 0x0AAD, 0x0ACF, + 0x0AF0, 0x0B11, 0x0B33, 0x0B55, + 0x0B78, 0x0B9A, 0x0BBD, 0x0BE0, + 0x0C03, 0x0C27, 0x0C4B, 0x0C6F, + 0x0C93, 0x0CB8, 0x0CDD, 0x0D02, + 0x0D27, 0x0D4D, 0x0D73, 0x0D99, + 0x0DBF, 0x0DE6, 0x0E0C, 0x0E33, + 0x0E5B, 0x0E82, 0x0EAA, 0x0ED2, + 0x0EFB, 0x0F23, 0x0F4C, 0x0F75, + 0x0F9F, 0x0FC8, 0x0FF2, 0x101C, + 0x1047, 0x1071, 0x109C, 0x10C7, + 0x10F3, 0x111E, 0x114A, 0x1176, + 0x11A3, 0x11D0, 0x11FC, 0x122A, + 0x1257, 0x1285, 0x12B3, 0x12E1, + 0x130F, 0x133E, 0x136D, 0x139C, + 0x13CB, 0x13FB, 0x142B, 0x145B, + 0x148B, 0x14BC, 0x14ED, 0x151E, + 0x1550, 0x1581, 0x15B3, 0x15E5, + 0x1618, 0x164A, 0x167D, 0x16B0, + 0x16E3, 0x1717, 0x174B, 0x177F, + 0x17B3, 0x17E8, 0x181D, 0x1852, + 0x1887, 0x18BC, 0x18F2, 0x1928, + 0x195E, 0x1995, 0x19CB, 0x1A02, + 0x1A39, 0x1A71, 0x1AA8, 0x1AE0, + 0x1B18, 0x1B50, 0x1B89, 0x1BC1, + 0x1BFA, 0x1C34, 0x1C6D, 0x1CA7, + 0x1CE0, 0x1D1A, 0x1D55, 0x1D8F, + 0x1DCA, 0x1E05, 0x1E40, 0x1E7B, + 0x1EB7, 0x1EF2, 0x1F2E, 0x1F6B, + 0x1FA7, 0x1FE4, 0x2020, 0x205D, + 0x209B, 0x20D8, 0x2116, 0x2153, + 0x2191, 0x21D0, 0x220E, 0x224D, + 0x228B, 0x22CA, 0x2309, 0x2349, + 0x2388, 0x23C8, 0x2408, 0x2448, + 0x2488, 0x24C9, 0x2509, 0x254A, + 0x258B, 0x25CC, 0x260E, 0x264F, + 0x2691, 0x26D3, 0x2715, 0x2757, + 0x2799, 0x27DC, 0x281F, 0x2861, + 0x28A4, 0x28E8, 0x292B, 0x296E, + 0x29B2, 0x29F6, 0x2A3A, 0x2A7E, + 0x2AC2, 0x2B06, 0x2B4B, 0x2B8F, + 0x2BD4, 0x2C19, 0x2C5E, 0x2CA3, + 0x2CE9, 0x2D2E, 0x2D74, 0x2DB9, + 0x2DFF, 0x2E45, 0x2E8B, 0x2ED1, + 0x2F18, 0x2F5E, 0x2FA5, 0x2FEB, + 0x3032, 0x3079, 0x30C0, 0x3107, + 0x314E, 0x3195, 0x31DD, 0x3224, + 0x326C, 0x32B4, 0x32FB, 0x3343, + 0x338B, 0x33D3, 0x341B, 0x3463, + 0x34AC, 0x34F4, 0x353D, 0x3585, + 0x35CE, 0x3616, 0x365F, 0x36A8, + 0x36F1, 0x373A, 0x3783, 0x37CC, + 0x3815, 0x385E, 0x38A7, 0x38F0, + 0x393A, 0x3983, 0x39CC, 0x3A16, + 0x3A5F, 0x3AA9, 0x3AF2, 0x3B3C, + 0x3B86, 0x3BCF, 0x3C19, 0x3C63, + 0x3CAC, 0x3CF6, 0x3D40, 0x3D8A, + 0x3DD3, 0x3E1D, 0x3E67, 0x3EB1, + 0x3EFB, 0x3F45, 0x3F8E, 0x3FD8, + 0x4022, 0x406C, 0x40B6, 0x4100, + 0x414A, 0x4193, 0x41DD, 0x4227, + 0x4271, 0x42BB, 0x4304, 0x434E, + 0x4398, 0x43E1, 0x442B, 0x4475, + 0x44BE, 0x4508, 0x4551, 0x459B, + 0x45E4, 0x462E, 0x4677, 0x46C0, + 0x4709, 0x4753, 0x479C, 0x47E5, + 0x482E, 0x4877, 0x48C0, 0x4909, + 0x4951, 0x499A, 0x49E3, 0x4A2B, + 0x4A74, 0x4ABC, 0x4B04, 0x4B4D, + 0x4B95, 0x4BDD, 0x4C25, 0x4C6D, + 0x4CB5, 0x4CFC, 0x4D44, 0x4D8C, + 0x4DD3, 0x4E1A, 0x4E62, 0x4EA9, + 0x4EF0, 0x4F37, 0x4F7E, 0x4FC4, + 0x500B, 0x5051, 0x5098, 0x50DE, + 0x5124, 0x516A, 0x51B0, 0x51F6, + 0x523B, 0x5281, 0x52C6, 0x530B, + 0x5351, 0x5396, 0x53DA, 0x541F, + 0x5464, 0x54A8, 0x54EC, 0x5530, + 0x5574, 0x55B8, 0x55FC, 0x563F, + 0x5683, 0x56C6, 0x5709, 0x574C, + 0x578F, 0x57D1, 0x5814, 0x5856, + 0x5898, 0x58DA, 0x591B, 0x595D, + 0x599E, 0x59E0, 0x5A21, 0x5A61, + 0x5AA2, 0x5AE3, 0x5B23, 0x5B63, + 0x5BA3, 0x5BE3, 0x5C22, 0x5C62, + 0x5CA1, 0x5CE0, 0x5D1F, 0x5D5D, + 0x5D9C, 0x5DDA, 0x5E18, 0x5E56, + 0x5E93, 0x5ED1, 0x5F0E, 0x5F4B, + 0x5F87, 0x5FC4, 0x6000, 0x603D, + 0x6079, 0x60B4, 0x60F0, 0x612B, + 0x6166, 0x61A1, 0x61DC, 0x6216, + 0x6250, 0x628A, 0x62C4, 0x62FE, + 0x6337, 0x6370, 0x63A9, 0x63E2, + 0x641A, 0x6452, 0x648A, 0x64C2, + 0x64F9, 0x6531, 0x6568, 0x659E, + 0x65D5, 0x660B, 0x6641, 0x6677, + 0x66AD, 0x66E2, 0x6717, 0x674C, + 0x6781, 0x67B5, 0x67E9, 0x681D, + 0x6851, 0x6885, 0x68B8, 0x68EB, + 0x691D, 0x6950, 0x6982, 0x69B4, + 0x69E6, 0x6A17, 0x6A48, 0x6A79, + 0x6AAA, 0x6ADB, 0x6B0B, 0x6B3B, + 0x6B6A, 0x6B9A, 0x6BC9, 0x6BF8, + 0x6C27, 0x6C55, 0x6C83, 0x6CB1, + 0x6CDF, 0x6D0D, 0x6D3A, 0x6D67, + 0x6D93, 0x6DC0, 0x6DEC, 0x6E18, + 0x6E44, 0x6E6F, 0x6E9A, 0x6EC5, + 0x6EF0, 0x6F1A, 0x6F44, 0x6F6E, + 0x6F98, 0x6FC1, 0x6FEA, 0x7013, + 0x703C, 0x7064, 0x708C, 0x70B4, + 0x70DB, 0x7103, 0x712A, 0x7151, + 0x7177, 0x719D, 0x71C3, 0x71E9, + 0x720F, 0x7234, 0x7259, 0x727E, + 0x72A2, 0x72C7, 0x72EB, 0x730E, + 0x7332, 0x7355, 0x7378, 0x739B, + 0x73BD, 0x73E0, 0x7402, 0x7424, + 0x7445, 0x7466, 0x7487, 0x74A8, + 0x74C9, 0x74E9, 0x7509, 0x7529, + 0x7548, 0x7568, 0x7587, 0x75A5, + 0x75C4, 0x75E2, 0x7601, 0x761E, + 0x763C, 0x7659, 0x7676, 0x7693, + 0x76B0, 0x76CC, 0x76E9, 0x7705, + 0x7720, 0x773C, 0x7757, 0x7772, + 0x778D, 0x77A8, 0x77C2, 0x77DC, + 0x77F6, 0x780F, 0x7829, 0x7842, + 0x785B, 0x7874, 0x788C, 0x78A5, + 0x78BD, 0x78D5, 0x78EC, 0x7904, + 0x791B, 0x7932, 0x7949, 0x795F, + 0x7976, 0x798C, 0x79A2, 0x79B7, + 0x79CD, 0x79E2, 0x79F7, 0x7A0C, + 0x7A21, 0x7A35, 0x7A4A, 0x7A5E, + 0x7A72, 0x7A85, 0x7A99, 0x7AAC, + 0x7ABF, 0x7AD2, 0x7AE5, 0x7AF7, + 0x7B09, 0x7B1B, 0x7B2D, 0x7B3F, + 0x7B51, 0x7B62, 0x7B73, 0x7B84, + 0x7B95, 0x7BA5, 0x7BB6, 0x7BC6, + 0x7BD6, 0x7BE6, 0x7BF6, 0x7C05, + 0x7C15, 0x7C24, 0x7C33, 0x7C42, + 0x7C50, 0x7C5F, 0x7C6D, 0x7C7B, + 0x7C89, 0x7C97, 0x7CA5, 0x7CB2, + 0x7CC0, 0x7CCD, 0x7CDA, 0x7CE7, + 0x7CF3, 0x7D00, 0x7D0C, 0x7D18, + 0x7D25, 0x7D31, 0x7D3C, 0x7D48, + 0x7D53, 0x7D5F, 0x7D6A, 0x7D75, + 0x7D80, 0x7D8B, 0x7D95, 0x7DA0, + 0x7DAA, 0x7DB4, 0x7DBE, 0x7DC8, + 0x7DD2, 0x7DDC, 0x7DE5, 0x7DEF, + 0x7DF8, 0x7E01, 0x7E0A, 0x7E13, + 0x7E1C, 0x7E25, 0x7E2D, 0x7E36, + 0x7E3E, 0x7E46, 0x7E4E, 0x7E56, + 0x7E5E, 0x7E66, 0x7E6D, 0x7E75, + 0x7E7C, 0x7E83, 0x7E8B, 0x7E92, + 0x7E99, 0x7EA0, 0x7EA6, 0x7EAD, + 0x7EB3, 0x7EBA, 0x7EC0, 0x7EC6, + 0x7ECD, 0x7ED3, 0x7ED9, 0x7EDE, + 0x7EE4, 0x7EEA, 0x7EF0, 0x7EF5, + 0x7EFA, 0x7F00, 0x7F05, 0x7F0A, + 0x7F0F, 0x7F14, 0x7F19, 0x7F1E, + 0x7F23, 0x7F27, 0x7F2C, 0x7F30, + 0x7F35, 0x7F39, 0x7F3D, 0x7F41, + 0x7F46, 0x7F4A, 0x7F4E, 0x7F52, + 0x7F55, 0x7F59, 0x7F5D, 0x7F60, + 0x7F64, 0x7F68, 0x7F6B, 0x7F6E, + 0x7F72, 0x7F75, 0x7F78, 0x7F7B, + 0x7F7E, 0x7F81, 0x7F84, 0x7F87, + 0x7F8A, 0x7F8D, 0x7F90, 0x7F92, + 0x7F95, 0x7F97, 0x7F9A, 0x7F9C, + 0x7F9F, 0x7FA1, 0x7FA4, 0x7FA6, + 0x7FA8, 0x7FAA, 0x7FAC, 0x7FAE, + 0x7FB1, 0x7FB3, 0x7FB5, 0x7FB6, + 0x7FB8, 0x7FBA, 0x7FBC, 0x7FBE, + 0x7FBF, 0x7FC1, 0x7FC3, 0x7FC4, + 0x7FC6, 0x7FC8, 0x7FC9, 0x7FCB, + 0x7FCC, 0x7FCD, 0x7FCF, 0x7FD0, + 0x7FD1, 0x7FD3, 0x7FD4, 0x7FD5, + 0x7FD6, 0x7FD8, 0x7FD9, 0x7FDA, + 0x7FDB, 0x7FDC, 0x7FDD, 0x7FDE, + 0x7FDF, 0x7FE0, 0x7FE1, 0x7FE2, + 0x7FE3, 0x7FE4, 0x7FE4, 0x7FE5, + 0x7FE6, 0x7FE7, 0x7FE8, 0x7FE8, + 0x7FE9, 0x7FEA, 0x7FEA, 0x7FEB, + 0x7FEC, 0x7FEC, 0x7FED, 0x7FEE, + 0x7FEE, 0x7FEF, 0x7FEF, 0x7FF0, + 0x7FF0, 0x7FF1, 0x7FF1, 0x7FF2, + 0x7FF2, 0x7FF3, 0x7FF3, 0x7FF4, + 0x7FF4, 0x7FF4, 0x7FF5, 0x7FF5, + 0x7FF6, 0x7FF6, 0x7FF6, 0x7FF7, + 0x7FF7, 0x7FF7, 0x7FF8, 0x7FF8, + 0x7FF8, 0x7FF8, 0x7FF9, 0x7FF9, + 0x7FF9, 0x7FF9, 0x7FFA, 0x7FFA, + 0x7FFA, 0x7FFA, 0x7FFA, 0x7FFB, + 0x7FFB, 0x7FFB, 0x7FFB, 0x7FFB, + 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC, + 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC, + 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD, + 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD, + 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF + +}; + + + + +const Int16 Short_Window_KBD_fxp[SHORT_WINDOW] = +{ + + 0x0001, 0x0004, 0x0008, 0x000D, + 0x0014, 0x001D, 0x0029, 0x0039, + 0x004C, 0x0063, 0x0080, 0x00A2, + 0x00CB, 0x00FB, 0x0133, 0x0174, + 0x01BE, 0x0214, 0x0275, 0x02E3, + 0x035E, 0x03E8, 0x0481, 0x052B, + 0x05E7, 0x06B4, 0x0795, 0x088A, + 0x0993, 0x0AB2, 0x0BE7, 0x0D32, + 0x0E94, 0x100E, 0x119F, 0x1347, + 0x1507, 0x16DE, 0x18CC, 0x1AD0, + 0x1CEB, 0x1F1A, 0x215F, 0x23B6, + 0x2620, 0x289C, 0x2B27, 0x2DC0, + 0x3066, 0x3317, 0x35D2, 0x3894, + 0x3B5C, 0x3E28, 0x40F6, 0x43C4, + 0x468F, 0x4956, 0x4C18, 0x4ED1, + 0x5181, 0x5425, 0x56BC, 0x5944, + 0x5BBB, 0x5E21, 0x6073, 0x62B1, + 0x64DA, 0x66EC, 0x68E7, 0x6ACB, + 0x6C96, 0x6E49, 0x6FE4, 0x7166, + 0x72D0, 0x7421, 0x755B, 0x767E, + 0x778A, 0x7881, 0x7962, 0x7A30, + 0x7AEA, 0x7B92, 0x7C29, 0x7CB0, + 0x7D28, 0x7D92, 0x7DF0, 0x7E42, + 0x7E89, 0x7EC7, 0x7EFC, 0x7F2A, + 0x7F50, 0x7F71, 0x7F8C, 0x7FA3, + 0x7FB6, 0x7FC5, 0x7FD2, 0x7FDC, + 0x7FE4, 0x7FEB, 0x7FF0, 0x7FF4, + 0x7FF7, 0x7FF9, 0x7FFB, 0x7FFC, + 0x7FFD, 0x7FFE, 0x7FFE, 0x7FFE, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, + 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF +}; + diff --git a/components/spotify/cspot/bell/main/audio-codec/AACDecoder.cpp b/components/spotify/cspot/bell/main/audio-codec/AACDecoder.cpp index b6565b97..53197c12 100644 --- a/components/spotify/cspot/bell/main/audio-codec/AACDecoder.cpp +++ b/components/spotify/cspot/bell/main/audio-codec/AACDecoder.cpp @@ -1,8 +1,10 @@ #include "AACDecoder.h" #include // for free, malloc - -#include "CodecType.h" // for bell +#include +#include +#include "e_tmp4audioobjecttype.h" +#include "pvmp4audiodecoder_api.h" namespace bell { class AudioContainer; @@ -11,47 +13,100 @@ class AudioContainer; using namespace bell; AACDecoder::AACDecoder() { - aac = AACInitDecoder(); - pcmData = (int16_t*)malloc(AAC_MAX_NSAMPS * AAC_MAX_NCHANS * sizeof(int16_t)); + aacDecoder = + (tPVMP4AudioDecoderExternal*)malloc(sizeof(tPVMP4AudioDecoderExternal)); + + int32_t pMemRequirement = PVMP4AudioDecoderGetMemRequirements(); + pMem = malloc(pMemRequirement); + memset(aacDecoder, 0, sizeof(tPVMP4AudioDecoderExternal)); + memset(pMem, 0, pMemRequirement); + + // Initialize the decoder buffers + outputBuffer.resize(4096); + + aacDecoder->pOutputBuffer_plus = &outputBuffer[2048]; + aacDecoder->pOutputBuffer = &outputBuffer[0]; + aacDecoder->inputBufferMaxLength = PVMP4AUDIODECODER_INBUFSIZE; + + // Settings + aacDecoder->desiredChannels = 2; + aacDecoder->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED; + aacDecoder->aacPlusEnabled = TRUE; + + // State + aacDecoder->inputBufferCurrentLength = 0; + aacDecoder->inputBufferUsedLength = 0; + aacDecoder->remainderBits = 0; + + firstFrame = true; + + assert(PVMP4AudioDecoderInitLibrary(aacDecoder, pMem) == MP4AUDEC_SUCCESS); } AACDecoder::~AACDecoder() { - AACFreeDecoder(aac); - free(pcmData); + free(pMem); + free(aacDecoder); +} + +int AACDecoder::getDecodedStreamType() { + switch (aacDecoder->extendedAudioObjectType) { + case MP4AUDIO_AAC_LC: + case MP4AUDIO_LTP: + return AAC; + case MP4AUDIO_SBR: + return AACPLUS; + case MP4AUDIO_PS: + return ENH_AACPLUS; + default: + return -1; + } } bool AACDecoder::setup(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) { + PVMP4AudioDecoderResetBuffer(pMem); + assert(PVMP4AudioDecoderInitLibrary(aacDecoder, pMem) == MP4AUDEC_SUCCESS); + firstFrame = true; return true; } bool AACDecoder::setup(AudioContainer* container) { + PVMP4AudioDecoderResetBuffer(pMem); + assert(PVMP4AudioDecoderInitLibrary(aacDecoder, pMem) == MP4AUDEC_SUCCESS); + firstFrame = true; return true; } uint8_t* AACDecoder::decode(uint8_t* inData, uint32_t& inLen, uint32_t& outLen) { - if (!inData) + if (!inData || inLen == 0) return nullptr; - int status = AACDecode(aac, static_cast(&inData), - reinterpret_cast(&inLen), - static_cast(this->pcmData)); + aacDecoder->inputBufferCurrentLength = inLen; + aacDecoder->inputBufferUsedLength = 0; + aacDecoder->inputBufferMaxLength = inLen; + aacDecoder->pInputBuffer = inData; + aacDecoder->remainderBits = 0; + aacDecoder->repositionFlag = true; - AACGetLastFrameInfo(aac, &frame); - if (status != ERR_AAC_NONE) { - lastErrno = status; + int32_t status; + status = PVMP4AudioDecodeFrame(aacDecoder, pMem); + + if (status != MP4AUDEC_SUCCESS) { + outLen = 0; + inLen = 0; return nullptr; + } else { + inLen -= aacDecoder->inputBufferUsedLength; } - if (sampleRate != frame.sampRateOut) { - this->sampleRate = frame.sampRateOut; + outLen = aacDecoder->frameLength * sizeof(int16_t); + + // Handle AAC+ + if (aacDecoder->aacPlusUpsamplingFactor == 2) { + outLen *= 2; } - if (channelCount != frame.nChans) { - this->channelCount = frame.nChans; - } - - outLen = frame.outputSamps * sizeof(int16_t); - return (uint8_t*)pcmData; + outLen *= aacDecoder->desiredChannels; + return (uint8_t*)&outputBuffer[0]; } diff --git a/components/spotify/cspot/bell/main/audio-codec/BaseCodec.cpp b/components/spotify/cspot/bell/main/audio-codec/BaseCodec.cpp index 46d5f8ad..e92ee55e 100644 --- a/components/spotify/cspot/bell/main/audio-codec/BaseCodec.cpp +++ b/components/spotify/cspot/bell/main/audio-codec/BaseCodec.cpp @@ -1,7 +1,6 @@ #include "BaseCodec.h" #include "AudioContainer.h" // for AudioContainer -#include "CodecType.h" // for bell using namespace bell; @@ -23,10 +22,7 @@ uint8_t* BaseCodec::decode(AudioContainer* container, uint32_t& outLen) { availableBytes = lastSampleLen; auto* result = decode((uint8_t*)data, availableBytes, outLen); - if (result == nullptr) { - container->consumeBytes(1); - } else { - container->consumeBytes(lastSampleLen - availableBytes); - } + container->consumeBytes(lastSampleLen - availableBytes); + return result; } diff --git a/components/spotify/cspot/bell/main/audio-codec/MP3Decoder.cpp b/components/spotify/cspot/bell/main/audio-codec/MP3Decoder.cpp index 5293d0ef..cc9c13e3 100644 --- a/components/spotify/cspot/bell/main/audio-codec/MP3Decoder.cpp +++ b/components/spotify/cspot/bell/main/audio-codec/MP3Decoder.cpp @@ -1,8 +1,7 @@ #include "MP3Decoder.h" #include // for free, malloc - -#include "CodecType.h" // for bell +#include namespace bell { class AudioContainer; @@ -41,6 +40,8 @@ uint8_t* MP3Decoder::decode(uint8_t* inData, uint32_t& inLen, MP3GetLastFrameInfo(mp3, &frame); if (status != ERR_MP3_NONE) { lastErrno = status; + inLen -= 2; + outLen = 0; return nullptr; } if (sampleRate != frame.samprate) { diff --git a/components/spotify/cspot/bell/main/audio-codec/include/AACDecoder.h b/components/spotify/cspot/bell/main/audio-codec/include/AACDecoder.h index e44b101c..4c144333 100644 --- a/components/spotify/cspot/bell/main/audio-codec/include/AACDecoder.h +++ b/components/spotify/cspot/bell/main/audio-codec/include/AACDecoder.h @@ -1,18 +1,23 @@ #pragma once #include // for uint8_t, uint32_t, int16_t +#include -#include "BaseCodec.h" // for BaseCodec -#include "aacdec.h" // for AACFrameInfo, HAACDecoder +#include "BaseCodec.h" // for BaseCodec +#include "pvmp4audiodecoder_api.h" // for tPVMP4AudioDecoderExternal namespace bell { class AudioContainer; class AACDecoder : public BaseCodec { private: - HAACDecoder aac; - int16_t* pcmData; - AACFrameInfo frame = {}; + tPVMP4AudioDecoderExternal* aacDecoder; + std::vector inputBuffer; + std::vector outputBuffer; + void* pMem; + bool firstFrame = true; + + int getDecodedStreamType(); public: AACDecoder(); diff --git a/components/spotify/cspot/bell/main/audio-codec/include/DecoderGlobals.h b/components/spotify/cspot/bell/main/audio-codec/include/DecoderGlobals.h index f8335a25..e2a20257 100644 --- a/components/spotify/cspot/bell/main/audio-codec/include/DecoderGlobals.h +++ b/components/spotify/cspot/bell/main/audio-codec/include/DecoderGlobals.h @@ -7,7 +7,7 @@ #include // for NULL -#include "aacdec.h" // for AACFreeDecoder, AACInitDecoder, HAACDecoder +// #include "aacdec.h" // for AACFreeDecoder, AACInitDecoder, HAACDecoder #include "mp3dec.h" // for MP3FreeDecoder, MP3InitDecoder, HMP3Decoder namespace bell { @@ -16,16 +16,16 @@ class DecodersInstance { DecodersInstance(){}; ~DecodersInstance() { MP3FreeDecoder(mp3Decoder); - AACFreeDecoder(aacDecoder); + // AACFreeDecoder(aacDecoder); }; - HAACDecoder aacDecoder = NULL; + // HAACDecoder aacDecoder = NULL; HMP3Decoder mp3Decoder = NULL; void ensureAAC() { - if (aacDecoder == NULL) { - aacDecoder = AACInitDecoder(); - } + // if (aacDecoder == NULL) { + // aacDecoder = AACInitDecoder(); + // } } void ensureMP3() { diff --git a/components/spotify/cspot/bell/main/audio-containers/AACContainer.cpp b/components/spotify/cspot/bell/main/audio-containers/AACContainer.cpp deleted file mode 100644 index 314fd999..00000000 --- a/components/spotify/cspot/bell/main/audio-containers/AACContainer.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "AACContainer.h" - -#include // for memmove - -#include "StreamInfo.h" // for BitWidth, BitWidth::BW_16, SampleRate, Sampl... -#include "aacdec.h" // for AACFindSyncWord - -using namespace bell; - -#define SYNC_WORLD_LEN 4 - -AACContainer::AACContainer(std::istream& istr) : bell::AudioContainer(istr) {} - -bool AACContainer::fillBuffer() { - if (this->bytesInBuffer < AAC_MAX_FRAME_SIZE * 2) { - this->istr.read((char*)buffer.data() + bytesInBuffer, - buffer.size() - bytesInBuffer); - this->bytesInBuffer += istr.gcount(); - } - return this->bytesInBuffer >= AAC_MAX_FRAME_SIZE * 2; -} - -std::byte* AACContainer::readSample(uint32_t& len) { - if (!this->fillBuffer()) { - len = 0; - return nullptr; - } - - // Align the data if previous read was offseted - if (toConsume > 0 && toConsume <= bytesInBuffer) { - memmove(buffer.data(), buffer.data() + toConsume, - buffer.size() - toConsume); - bytesInBuffer = bytesInBuffer - toConsume; - toConsume = 0; - } - - int startOffset = - AACFindSyncWord((uint8_t*)this->buffer.data(), bytesInBuffer); - - if (startOffset < 0) { - // Discard word - toConsume = AAC_MAX_FRAME_SIZE; - return nullptr; - } - - len = bytesInBuffer - startOffset; - - return this->buffer.data() + startOffset; -} - -void AACContainer::parseSetupData() { - channels = 2; - sampleRate = bell::SampleRate::SR_44100; - bitWidth = bell::BitWidth::BW_16; -} diff --git a/components/spotify/cspot/bell/main/audio-containers/ADTSContainer.cpp b/components/spotify/cspot/bell/main/audio-containers/ADTSContainer.cpp new file mode 100644 index 00000000..87c2078e --- /dev/null +++ b/components/spotify/cspot/bell/main/audio-containers/ADTSContainer.cpp @@ -0,0 +1,129 @@ +#include "ADTSContainer.h" + +#include // for memmove +#include + +#include "StreamInfo.h" // for BitWidth, BitWidth::BW_16, SampleRate, Sampl... +// #include "aacdec.h" // for AACFindSyncWord + +using namespace bell; + +#define SYNC_WORLD_LEN 4 +#define SYNCWORDH 0xff +#define SYNCWORDL 0xf0 + +// AAC ADTS frame header len +#define AAC_ADTS_FRAME_HEADER_LEN 9 + +// AAC ADTS frame sync verify +#define AAC_ADTS_SYNC_VERIFY(buf) \ + ((buf[0] == 0xff) && ((buf[1] & 0xf6) == 0xf0)) + +// AAC ADTS Frame size value stores in 13 bits started at the 31th bit from header +#define AAC_ADTS_FRAME_GETSIZE(buf) \ + ((buf[3] & 0x03) << 11 | buf[4] << 3 | buf[5] >> 5) + +ADTSContainer::ADTSContainer(std::istream& istr, const std::byte* headingBytes) + : bell::AudioContainer(istr) { + if (headingBytes != nullptr) { + memcpy(buffer.data(), headingBytes, 7); + bytesInBuffer = 7; + } +} + +bool ADTSContainer::fillBuffer() { + if (this->bytesInBuffer < AAC_MAX_FRAME_SIZE * 2) { + this->istr.read((char*)buffer.data() + bytesInBuffer, + buffer.size() - bytesInBuffer); + this->bytesInBuffer += istr.gcount(); + } + return this->bytesInBuffer >= AAC_MAX_FRAME_SIZE; +} + +bool ADTSContainer::resyncADTS() { + int resyncOffset = 0; + bool resyncValid = false; + + size_t validBytes = bytesInBuffer - dataOffset; + + while (!resyncValid && resyncOffset < validBytes) { + uint8_t* buf = (uint8_t*)this->buffer.data() + dataOffset + resyncOffset; + if (AAC_ADTS_SYNC_VERIFY(buf)) { + // Read frame size, and check if a consecutive frame is available + uint32_t frameSize = AAC_ADTS_FRAME_GETSIZE(buf); + + if (frameSize + resyncOffset > validBytes) { + // Not enough data, discard this frame + resyncOffset++; + continue; + } + + buf = + (uint8_t*)this->buffer.data() + dataOffset + resyncOffset + frameSize; + + if (AAC_ADTS_SYNC_VERIFY(buf)) { + buf += AAC_ADTS_FRAME_GETSIZE(buf); + if (AAC_ADTS_SYNC_VERIFY(buf)) { + protectionAbsent = (buf[1] & 1); + + // Found 3 consecutive frames, resynced + resyncValid = true; + } + } + } else { + resyncOffset++; + } + } + + dataOffset += resyncOffset; + return resyncValid; +} + +void ADTSContainer::consumeBytes(uint32_t len) { + dataOffset += len; +} + +std::byte* ADTSContainer::readSample(uint32_t& len) { + // Align data if previous read was offseted + if (dataOffset > 0 && bytesInBuffer > 0) { + size_t toConsume = std::min(dataOffset, bytesInBuffer); + memmove(buffer.data(), buffer.data() + toConsume, + buffer.size() - toConsume); + + dataOffset -= toConsume; + bytesInBuffer -= toConsume; + } + + if (!this->fillBuffer()) { + len = 0; + return nullptr; + } + + uint8_t* buf = (uint8_t*)buffer.data() + dataOffset; + + if (!AAC_ADTS_SYNC_VERIFY(buf)) { + if (!resyncADTS()) { + len = 0; + return nullptr; + } + } else { + protectionAbsent = (buf[1] & 1); + } + + len = AAC_ADTS_FRAME_GETSIZE(buf); + + if (len > bytesInBuffer - dataOffset) { + if (!resyncADTS()) { + len = 0; + return nullptr; + } + } + + return buffer.data() + dataOffset; +} + +void ADTSContainer::parseSetupData() { + channels = 2; + sampleRate = bell::SampleRate::SR_44100; + bitWidth = bell::BitWidth::BW_16; +} diff --git a/components/spotify/cspot/bell/main/audio-containers/AudioContainers.cpp b/components/spotify/cspot/bell/main/audio-containers/AudioContainers.cpp index bd8f45b5..344275e2 100644 --- a/components/spotify/cspot/bell/main/audio-containers/AudioContainers.cpp +++ b/components/spotify/cspot/bell/main/audio-containers/AudioContainers.cpp @@ -1,11 +1,12 @@ #include "AudioContainers.h" -#include // for memcmp -#include // for byte +#include // for memcmp +#include // for byte +#include "BellLogger.h" // for BellLogger -#include "AACContainer.h" // for AACContainer -#include "CodecType.h" // for bell -#include "MP3Container.h" // for MP3Container +#include "ADTSContainer.h" // for AACContainer +#include "CodecType.h" // for bell +#include "MP3Container.h" // for MP3Container namespace bell { class AudioContainer; @@ -20,15 +21,19 @@ std::unique_ptr AudioContainers::guessAudioContainer( if (memcmp(tmp, "\xFF\xF1", 2) == 0 || memcmp(tmp, "\xFF\xF9", 2) == 0) { // AAC found - std::cout << "AAC" << std::endl; - return std::make_unique(istr); + BELL_LOG(info, "AudioContainers", + "Mime guesser found AAC in ADTS format, creating ADTSContainer"); + return std::make_unique(istr, tmp); } else if (memcmp(tmp, "\xFF\xFB", 2) == 0 || memcmp(tmp, "\x49\x44\x33", 3) == 0) { // MP3 Found - std::cout << "MP3" << std::endl; + BELL_LOG(info, "AudioContainers", + "Mime guesser found MP3 format, creating MP3Container"); - return std::make_unique(istr); + return std::make_unique(istr, tmp); } + BELL_LOG(error, "AudioContainers", + "Mime guesser found no supported format [%X, %X]", tmp[0], tmp[1]); return nullptr; } diff --git a/components/spotify/cspot/bell/main/audio-containers/MP3Container.cpp b/components/spotify/cspot/bell/main/audio-containers/MP3Container.cpp index 98bb6b66..6b602ec9 100644 --- a/components/spotify/cspot/bell/main/audio-containers/MP3Container.cpp +++ b/components/spotify/cspot/bell/main/audio-containers/MP3Container.cpp @@ -7,7 +7,12 @@ using namespace bell; -MP3Container::MP3Container(std::istream& istr) : bell::AudioContainer(istr) {} +MP3Container::MP3Container(std::istream& istr, const std::byte* headingBytes) : bell::AudioContainer(istr) { + if (headingBytes != nullptr) { + memcpy(buffer.data(), headingBytes, 7); + bytesInBuffer = 7; + } +} bool MP3Container::fillBuffer() { if (this->bytesInBuffer < MP3_MAX_FRAME_SIZE * 2) { @@ -18,32 +23,41 @@ bool MP3Container::fillBuffer() { return this->bytesInBuffer >= MP3_MAX_FRAME_SIZE * 2; } +void MP3Container::consumeBytes(uint32_t len) { + dataOffset += len; +} + std::byte* MP3Container::readSample(uint32_t& len) { + // Align data if previous read was offseted + if (dataOffset > 0 && bytesInBuffer > 0) { + size_t toConsume = std::min(dataOffset, bytesInBuffer); + memmove(buffer.data(), buffer.data() + toConsume, + buffer.size() - toConsume); + + dataOffset -= toConsume; + bytesInBuffer -= toConsume; + } + + if (!this->fillBuffer()) { len = 0; return nullptr; } - // Align the data if previous read was offseted - if (toConsume > 0 && toConsume <= bytesInBuffer) { - memmove(buffer.data(), buffer.data() + toConsume, - buffer.size() - toConsume); - bytesInBuffer = bytesInBuffer - toConsume; - toConsume = 0; - } - int startOffset = MP3FindSyncWord((uint8_t*)this->buffer.data(), bytesInBuffer); if (startOffset < 0) { // Discard word - toConsume = MP3_MAX_FRAME_SIZE; + dataOffset = MP3_MAX_FRAME_SIZE; return nullptr; } - len = bytesInBuffer - startOffset; + dataOffset += startOffset; - return this->buffer.data() + startOffset; + len = bytesInBuffer - dataOffset; + + return this->buffer.data() + dataOffset; } void MP3Container::parseSetupData() { diff --git a/components/spotify/cspot/bell/main/audio-containers/include/AACContainer.h b/components/spotify/cspot/bell/main/audio-containers/include/ADTSContainer.h similarity index 75% rename from components/spotify/cspot/bell/main/audio-containers/include/AACContainer.h rename to components/spotify/cspot/bell/main/audio-containers/include/ADTSContainer.h index da8d9443..162f95cd 100644 --- a/components/spotify/cspot/bell/main/audio-containers/include/AACContainer.h +++ b/components/spotify/cspot/bell/main/audio-containers/include/ADTSContainer.h @@ -9,13 +9,15 @@ #include "CodecType.h" // for AudioCodec, AudioCodec::AAC namespace bell { -class AACContainer : public AudioContainer { +class ADTSContainer : public AudioContainer { public: - ~AACContainer(){}; - AACContainer(std::istream& istr); + ~ADTSContainer(){}; + ADTSContainer(std::istream& istr, const std::byte* headingBytes = nullptr); std::byte* readSample(uint32_t& len) override; + bool resyncADTS(); void parseSetupData() override; + void consumeBytes(uint32_t len) override; bell::AudioCodec getCodec() override { return bell::AudioCodec::AAC; } @@ -27,6 +29,7 @@ class AACContainer : public AudioContainer { size_t bytesInBuffer = 0; size_t dataOffset = 0; + bool protectionAbsent = false; bool fillBuffer(); }; diff --git a/components/spotify/cspot/bell/main/audio-containers/include/AudioContainer.h b/components/spotify/cspot/bell/main/audio-containers/include/AudioContainer.h index 2c25cb96..0f142fb2 100644 --- a/components/spotify/cspot/bell/main/audio-containers/include/AudioContainer.h +++ b/components/spotify/cspot/bell/main/audio-containers/include/AudioContainer.h @@ -10,7 +10,6 @@ namespace bell { class AudioContainer { protected: std::istream& istr; - uint32_t toConsume = 0; public: bell::SampleRate sampleRate; @@ -20,7 +19,7 @@ class AudioContainer { AudioContainer(std::istream& istr) : istr(istr) {} virtual std::byte* readSample(uint32_t& len) = 0; - void consumeBytes(uint32_t bytes) { this->toConsume = bytes; } + virtual void consumeBytes(uint32_t len) = 0; virtual void parseSetupData() = 0; virtual bell::AudioCodec getCodec() = 0; }; diff --git a/components/spotify/cspot/bell/main/audio-containers/include/MP3Container.h b/components/spotify/cspot/bell/main/audio-containers/include/MP3Container.h index d4bbfd0e..9f61a3d0 100644 --- a/components/spotify/cspot/bell/main/audio-containers/include/MP3Container.h +++ b/components/spotify/cspot/bell/main/audio-containers/include/MP3Container.h @@ -12,10 +12,12 @@ namespace bell { class MP3Container : public AudioContainer { public: ~MP3Container(){}; - MP3Container(std::istream& istr); + MP3Container(std::istream& istr, const std::byte* headingBytes = nullptr); std::byte* readSample(uint32_t& len) override; void parseSetupData() override; + void consumeBytes(uint32_t len) override; + bell::AudioCodec getCodec() override { return bell::AudioCodec::MP3; } private: @@ -26,6 +28,7 @@ class MP3Container : public AudioContainer { size_t bytesInBuffer = 0; size_t dataOffset = 0; + size_t toConsume = 0; bool fillBuffer(); }; diff --git a/components/spotify/cspot/bell/main/audio-dsp/BellDSP.cpp b/components/spotify/cspot/bell/main/audio-dsp/BellDSP.cpp index 96e76483..ff43f859 100644 --- a/components/spotify/cspot/bell/main/audio-dsp/BellDSP.cpp +++ b/components/spotify/cspot/bell/main/audio-dsp/BellDSP.cpp @@ -100,7 +100,6 @@ size_t BellDSP::process(uint8_t* data, size_t bytes, int channels, // Data has been downmixed to mono if (streamInfo->numChannels == 1) { - data16Bit[i] = dataLeft[i] * MAX_INT16; // Denormalize left } else { data16Bit[i * 2] = dataLeft[i] * MAX_INT16; // Denormalize left diff --git a/components/spotify/cspot/bell/main/audio-sinks/esp/ES8388AudioSink.cpp b/components/spotify/cspot/bell/main/audio-sinks/esp/ES8388AudioSink.cpp index bd450e26..19860387 100644 --- a/components/spotify/cspot/bell/main/audio-sinks/esp/ES8388AudioSink.cpp +++ b/components/spotify/cspot/bell/main/audio-sinks/esp/ES8388AudioSink.cpp @@ -49,12 +49,12 @@ ES8388AudioSink::ES8388AudioSink() { ESP_LOGE("OI", "i2s set pin error: %d", err); } - err = i2c_param_config(0, &i2c_config); + err = i2c_param_config(I2C_NUM_0, &i2c_config); if (err != ESP_OK) { ESP_LOGE("OI", "i2c param config error: %d", err); } - err = i2c_driver_install(0, I2C_MODE_MASTER, 0, 0, 0); + err = i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0); if (err != ESP_OK) { ESP_LOGE("OI", "i2c driver installation error: %d", err); } @@ -132,7 +132,7 @@ void ES8388AudioSink::writeReg(uint8_t reg_add, uint8_t data) { res |= i2c_master_write_byte(cmd, reg_add, ACK_CHECK_EN); res |= i2c_master_write_byte(cmd, data, ACK_CHECK_EN); res |= i2c_master_stop(cmd); - res |= i2c_master_cmd_begin(0, cmd, 1000 / portTICK_PERIOD_MS); + res |= i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS); i2c_cmd_link_delete(cmd); if (res != ESP_OK) { diff --git a/components/spotify/cspot/bell/main/audio-sinks/include/esp/ES8388AudioSink.h b/components/spotify/cspot/bell/main/audio-sinks/include/esp/ES8388AudioSink.h index 92743647..544380e0 100644 --- a/components/spotify/cspot/bell/main/audio-sinks/include/esp/ES8388AudioSink.h +++ b/components/spotify/cspot/bell/main/audio-sinks/include/esp/ES8388AudioSink.h @@ -97,7 +97,7 @@ class ES8388AudioSink : public BufferedAudioSink { private: i2c_config_t i2c_config; - i2c_port_t i2c_port = 0; + i2c_port_t i2c_port = I2C_NUM_0; }; -#endif \ No newline at end of file +#endif diff --git a/components/spotify/cspot/bell/main/audio-sinks/include/esp/TAS5711AudioSink.h b/components/spotify/cspot/bell/main/audio-sinks/include/esp/TAS5711AudioSink.h index b4319c3a..b12e421d 100644 --- a/components/spotify/cspot/bell/main/audio-sinks/include/esp/TAS5711AudioSink.h +++ b/components/spotify/cspot/bell/main/audio-sinks/include/esp/TAS5711AudioSink.h @@ -22,7 +22,7 @@ class TAS5711AudioSink : public BufferedAudioSink { private: i2c_config_t i2c_config; - i2c_port_t i2c_port = 0; + i2c_port_t i2c_port = I2C_NUM_0; }; -#endif \ No newline at end of file +#endif diff --git a/components/spotify/cspot/bell/main/io/BellHTTPServer.cpp b/components/spotify/cspot/bell/main/io/BellHTTPServer.cpp index b01eb6c4..77cdb30d 100644 --- a/components/spotify/cspot/bell/main/io/BellHTTPServer.cpp +++ b/components/spotify/cspot/bell/main/io/BellHTTPServer.cpp @@ -35,7 +35,14 @@ class WebSocketHandler : public CivetWebSocketHandler { } virtual bool handleData(CivetServer* server, struct mg_connection* conn, - int bits, char* data, size_t data_len) { + int flags, char* data, size_t data_len) { + + if ((flags & 0xf) == MG_WEBSOCKET_OPCODE_CONNECTION_CLOSE) { + // Received close message from client. Close the connection. + this->stateHandler(conn, BellHTTPServer::WSState::CLOSED); + return false; + } + this->dataHandler(conn, data, data_len); return true; } diff --git a/components/spotify/cspot/bell/main/io/EncodedAudioStream.cpp b/components/spotify/cspot/bell/main/io/EncodedAudioStream.cpp index 6d80eb8e..1683a8e8 100644 --- a/components/spotify/cspot/bell/main/io/EncodedAudioStream.cpp +++ b/components/spotify/cspot/bell/main/io/EncodedAudioStream.cpp @@ -14,8 +14,8 @@ using namespace bell; EncodedAudioStream::EncodedAudioStream() { bell::decodersInstance->ensureAAC(); bell::decodersInstance->ensureMP3(); - inputBuffer = std::vector(AAC_READBUF_SIZE * 4); - outputBuffer = std::vector(AAC_MAX_NCHANS * AAC_MAX_NSAMPS * 4 * 4); + inputBuffer = std::vector(1024 * 4); + outputBuffer = std::vector(2 * 2 * 4 * 4); decodePtr = inputBuffer.data(); } @@ -115,46 +115,47 @@ bool EncodedAudioStream::isReadable() { } size_t EncodedAudioStream::decodeFrameAAC(uint8_t* dst) { - size_t writtenBytes = 0; - auto bufSize = AAC_READBUF_SIZE; + return 0; + // size_t writtenBytes = 0; + // auto bufSize = AAC_READBUF_SIZE; - int readBytes = innerStream->read(inputBuffer.data() + bytesInBuffer, - bufSize - bytesInBuffer); - if (readBytes > 0) { - bytesInBuffer += readBytes; - decodePtr = inputBuffer.data(); - offset = AACFindSyncWord(inputBuffer.data(), bytesInBuffer); + // int readBytes = innerStream->read(inputBuffer.data() + bytesInBuffer, + // bufSize - bytesInBuffer); + // if (readBytes > 0) { + // bytesInBuffer += readBytes; + // decodePtr = inputBuffer.data(); + // offset = AACFindSyncWord(inputBuffer.data(), bytesInBuffer); - if (offset != -1) { - bytesInBuffer -= offset; - decodePtr += offset; + // if (offset != -1) { + // bytesInBuffer -= offset; + // decodePtr += offset; - int decodeStatus = - AACDecode(bell::decodersInstance->aacDecoder, &decodePtr, - &bytesInBuffer, outputBuffer.data()); - AACGetLastFrameInfo(bell::decodersInstance->aacDecoder, &aacFrameInfo); - if (decodeStatus == ERR_AAC_NONE) { - decodedSampleRate = aacFrameInfo.sampRateOut; - writtenBytes = - (aacFrameInfo.bitsPerSample / 8) * aacFrameInfo.outputSamps; + // int decodeStatus = + // AACDecode(bell::decodersInstance->aacDecoder, &decodePtr, + // &bytesInBuffer, outputBuffer.data()); + // AACGetLastFrameInfo(bell::decodersInstance->aacDecoder, &aacFrameInfo); + // if (decodeStatus == ERR_AAC_NONE) { + // decodedSampleRate = aacFrameInfo.sampRateOut; + // writtenBytes = + // (aacFrameInfo.bitsPerSample / 8) * aacFrameInfo.outputSamps; - memcpy(dst, outputBuffer.data(), writtenBytes); + // memcpy(dst, outputBuffer.data(), writtenBytes); - } else { - BELL_LOG(info, TAG, "Error in frame, moving two bytes %d", - decodeStatus); - decodePtr += 1; - bytesInBuffer -= 1; - } - } else { - BELL_LOG(info, TAG, "Unexpected error in data, skipping a word"); - decodePtr += 3800; - bytesInBuffer -= 3800; - } + // } else { + // BELL_LOG(info, TAG, "Error in frame, moving two bytes %d", + // decodeStatus); + // decodePtr += 1; + // bytesInBuffer -= 1; + // } + // } else { + // BELL_LOG(info, TAG, "Unexpected error in data, skipping a word"); + // decodePtr += 3800; + // bytesInBuffer -= 3800; + // } - memmove(inputBuffer.data(), decodePtr, bytesInBuffer); - } - return writtenBytes; + // memmove(inputBuffer.data(), decodePtr, bytesInBuffer); + // } + // return writtenBytes; } void EncodedAudioStream::guessDataFormat() { diff --git a/components/spotify/cspot/bell/main/io/MGStreamAdapter.cpp b/components/spotify/cspot/bell/main/io/MGStreamAdapter.cpp new file mode 100644 index 00000000..71660ead --- /dev/null +++ b/components/spotify/cspot/bell/main/io/MGStreamAdapter.cpp @@ -0,0 +1,77 @@ +// MGStreamAdapter.cpp +#include "MGStreamAdapter.h" + +mg_buf::mg_buf(struct mg_connection* _conn) : conn(_conn) { + setp(buffer, buffer + BUF_SIZE - 1); // -1 to leave space for overflow '\0' +} + +mg_buf::int_type mg_buf::overflow(int_type c) { + if (c != EOF) { + *pptr() = c; + pbump(1); + } + + if (flush_buffer() == EOF) { + return EOF; + } + + return c; +} + +int mg_buf::flush_buffer() { + int len = int(pptr() - pbase()); + if (mg_write(conn, buffer, len) != len) { + return EOF; + } + pbump(-len); // reset put pointer accordingly + return len; +} + +int mg_buf::sync() { + if (flush_buffer() == EOF) { + return -1; // return -1 on error + } + return 0; +} + +MGStreamAdapter::MGStreamAdapter(struct mg_connection* _conn) : std::ostream(&buf), buf(_conn) { + rdbuf(&buf); // set the custom streambuf +} + + +mg_read_buf::mg_read_buf(struct mg_connection* _conn) : conn(_conn) { + setg(buffer + BUF_SIZE, // beginning of putback area + buffer + BUF_SIZE, // read position + buffer + BUF_SIZE); // end position +} + +mg_read_buf::int_type mg_read_buf::underflow() { + if (gptr() < egptr()) { // buffer not exhausted + return traits_type::to_int_type(*gptr()); + } + + char* base = buffer; + char* start = base; + + if (eback() == base) { // true when this isn't the first fill + // Make arrangements for putback characters + std::memmove(base, egptr() - 2, 2); + start += 2; + } + + // Read new characters + int n = mg_read(conn, start, buffer + BUF_SIZE - start); + if (n == 0) { + return traits_type::eof(); + } + + // Set buffer pointers + setg(base, start, start + n); + + // Return next character + return traits_type::to_int_type(*gptr()); +} + +MGInputStreamAdapter::MGInputStreamAdapter(struct mg_connection* _conn) : std::istream(&buf), buf(_conn) { + rdbuf(&buf); // set the custom streambuf +} diff --git a/components/spotify/cspot/bell/main/io/include/BellTar.h b/components/spotify/cspot/bell/main/io/include/BellTar.h index ef1b7e6a..70a33fa1 100644 --- a/components/spotify/cspot/bell/main/io/include/BellTar.h +++ b/components/spotify/cspot/bell/main/io/include/BellTar.h @@ -51,7 +51,7 @@ class reader { reader(std::istream& inp) : _inp(inp), _cached_header_data_valid(false), _number_of_files(-1) {} - // Returns true iff another file can be read from |inp|. + // Returns true if another file can be read from |inp|. bool contains_another_file(); // Returns file name of next file in |inp|. @@ -72,4 +72,4 @@ class reader { // Returns number of files in tar at |inp|. int number_of_files(); }; -} // namespace bell::BellTar \ No newline at end of file +} // namespace bell::BellTar diff --git a/components/spotify/cspot/bell/main/io/include/BinaryStream.h b/components/spotify/cspot/bell/main/io/include/BinaryStream.h index 78cdd66a..68fd3fe2 100644 --- a/components/spotify/cspot/bell/main/io/include/BinaryStream.h +++ b/components/spotify/cspot/bell/main/io/include/BinaryStream.h @@ -1,8 +1,9 @@ #pragma once -#ifndef ESP_PLATFORM +#if __has_include() #include // for endian #endif + #include // for int16_t, int32_t, int64_t, uint16_t, uint32_t #include // for byte #include // for istream, ostream diff --git a/components/spotify/cspot/bell/main/io/include/EncodedAudioStream.h b/components/spotify/cspot/bell/main/io/include/EncodedAudioStream.h index ce8a682e..42ebc499 100644 --- a/components/spotify/cspot/bell/main/io/include/EncodedAudioStream.h +++ b/components/spotify/cspot/bell/main/io/include/EncodedAudioStream.h @@ -6,7 +6,6 @@ #include // for basic_string, string #include // for vector -#include "aacdec.h" // for AACFrameInfo #include "mp3dec.h" // for MP3FrameInfo namespace bell { @@ -48,7 +47,7 @@ class EncodedAudioStream { std::vector mp3MagicBytesUntagged = {0xFF, 0xFB}; std::vector mp3MagicBytesIdc = {0x49, 0x44, 0x33}; - AACFrameInfo aacFrameInfo; + // AACFrameInfo aacFrameInfo; MP3FrameInfo mp3FrameInfo; size_t decodeFrameMp3(uint8_t* dst); diff --git a/components/spotify/cspot/bell/main/io/include/MGStreamAdapter.h b/components/spotify/cspot/bell/main/io/include/MGStreamAdapter.h new file mode 100644 index 00000000..4c6086d4 --- /dev/null +++ b/components/spotify/cspot/bell/main/io/include/MGStreamAdapter.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include +#include +#include "civetweb.h" + +const size_t BUF_SIZE = 1024; + +// Custom streambuf +class mg_buf : public std::streambuf { + private: + struct mg_connection* conn; + char buffer[BUF_SIZE]; + + public: + mg_buf(struct mg_connection* _conn); + + protected: + virtual int_type overflow(int_type c); + int flush_buffer(); + virtual int sync(); +}; + +/** + * @brief Adapts ostream to mg_write + * + */ +class MGStreamAdapter : public std::ostream { + private: + mg_buf buf; + + public: + MGStreamAdapter(struct mg_connection* _conn); +}; + +// Custom streambuf +class mg_read_buf : public std::streambuf { +private: + struct mg_connection* conn; + char buffer[BUF_SIZE]; + +public: + mg_read_buf(struct mg_connection* _conn); + +protected: + virtual int_type underflow(); +}; + +/** + * @brief Adapts istream to mg_read + */ +class MGInputStreamAdapter : public std::istream { +private: + mg_read_buf buf; + +public: + MGInputStreamAdapter(struct mg_connection* _conn); +}; + diff --git a/components/spotify/cspot/bell/main/utilities/BellUtils.cpp b/components/spotify/cspot/bell/main/utilities/BellUtils.cpp index 902252f3..f49baa73 100644 --- a/components/spotify/cspot/bell/main/utilities/BellUtils.cpp +++ b/components/spotify/cspot/bell/main/utilities/BellUtils.cpp @@ -4,6 +4,9 @@ #include // for mt19937, uniform_int_distribution, random_device #ifdef ESP_PLATFORM #include "esp_system.h" +#if __has_include("esp_mac.h") +#include "esp_mac.h" +#endif #endif std::string bell::generateRandomUUID() { @@ -27,6 +30,7 @@ std::string bell::generateRandomUUID() { std::string bell::getMacAddress() { #ifdef ESP_PLATFORM + uint8_t mac[6]; esp_read_mac(mac, ESP_MAC_WIFI_STA); char macStr[18]; diff --git a/components/spotify/cspot/bell/main/utilities/Crypto.cpp b/components/spotify/cspot/bell/main/utilities/Crypto.cpp index d3126afa..70d71e29 100644 --- a/components/spotify/cspot/bell/main/utilities/Crypto.cpp +++ b/components/spotify/cspot/bell/main/utilities/Crypto.cpp @@ -135,14 +135,20 @@ std::vector CryptoMbedTLS::pbkdf2HmacSha1( int iterations, int digestSize) { auto digest = std::vector(digestSize); +#if MBEDTLS_VERSION_NUMBER < 0x03030000 // Init sha context sha1Init(); mbedtls_pkcs5_pbkdf2_hmac(&sha1Context, password.data(), password.size(), salt.data(), salt.size(), iterations, digestSize, digest.data()); - + // Free sha context mbedtls_md_free(&sha1Context); +#else + mbedtls_pkcs5_pbkdf2_hmac_ext(MBEDTLS_MD_SHA1, password.data(), password.size(), + salt.data(), salt.size(), iterations, digestSize, + digest.data()); +#endif return digest; } @@ -230,4 +236,4 @@ std::vector CryptoMbedTLS::generateVectorWithRandomData( mbedtls_ctr_drbg_free(&ctrDrbg); return randomVector; -} \ No newline at end of file +}