summaryrefslogtreecommitdiffstats
path: root/embdrv
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-03-07 19:30:20 -0800
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:12 -0700
commit95fa11b3b2f19a382c7e3a744a6afb452fad86df (patch)
tree1019e123db4596f2b8bd1259da04b51f3c44d7b2 /embdrv
parente2197423bcf1a93c620be13d458a9da6693fa94d (diff)
downloadexternal_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.zip
external_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.tar.gz
external_bluetooth_bluedroid-95fa11b3b2f19a382c7e3a744a6afb452fad86df.tar.bz2
AV control and data path added
Change-Id: I88ec6084c140fa257154a98e23e075900e84cc8c
Diffstat (limited to 'embdrv')
-rw-r--r--embdrv/sbc/encoder/include/sbc_dct.h78
-rw-r--r--embdrv/sbc/encoder/include/sbc_enc_func_declare.h46
-rw-r--r--embdrv/sbc/encoder/include/sbc_encoder.h191
-rw-r--r--embdrv/sbc/encoder/include/sbc_if.h28
-rw-r--r--embdrv/sbc/encoder/include/sbc_types.h46
-rw-r--r--embdrv/sbc/encoder/srce/sbc_analysis.c1096
-rw-r--r--embdrv/sbc/encoder/srce/sbc_dct.c234
-rw-r--r--embdrv/sbc/encoder/srce/sbc_dct_coeffs.c189
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c188
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c201
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_coeffs.c308
-rw-r--r--embdrv/sbc/encoder/srce/sbc_encoder.c386
-rw-r--r--embdrv/sbc/encoder/srce/sbc_packing.c264
13 files changed, 3255 insertions, 0 deletions
diff --git a/embdrv/sbc/encoder/include/sbc_dct.h b/embdrv/sbc/encoder/include/sbc_dct.h
new file mode 100644
index 0000000..be077e2
--- /dev/null
+++ b/embdrv/sbc/encoder/include/sbc_dct.h
@@ -0,0 +1,78 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_dct.h,v $
+**
+** Description: Definitions for the fast DCT.
+**
+** Copyright (c) 1999-2008, Broadcom Corp., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#ifndef SBC_DCT_H
+#define SBC_DCT_H
+
+#if (SBC_ARM_ASM_OPT==TRUE)
+#define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1, s32OutLow) \
+{ \
+ __asm \
+{ \
+ MUL s32OutLow,(SINT32)s16In2, (s32In1>>15) \
+} \
+}
+#else
+#if (SBC_DSP_OPT==TRUE)
+#define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow) s32OutLow = SBC_Multiply_32_16_Simplified((SINT32)s16In2,s32In1);
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+/*#define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow) s32OutLow=(SINT32)((SINT32)(s16In2)*(SINT32)(s32In1>>15)); */
+#define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow) s32OutLow=(SINT32)(((SINT64)s16In2*(SINT64)s32In1)>>15);
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+#define SBC_MULT_32_32(s32In2, s32In1, s32OutLow) \
+{ \
+ s64Temp = ((SINT64) s32In2) * ((SINT64) s32In1)>>31; \
+ s32OutLow = (SINT32) s64Temp; \
+}
+#endif
+#else
+#define SBC_MULT_32_16_SIMPLIFIED(s16In2, s32In1 , s32OutLow) \
+{ \
+ s32In1Temp = s32In1; \
+ s32In2Temp = (SINT32)s16In2; \
+ \
+ /* Multiply one +ve and the other -ve number */ \
+ if (s32In1Temp < 0) \
+ { \
+ s32In1Temp ^= 0xFFFFFFFF; \
+ s32In1Temp++; \
+ s32OutLow = (s32In2Temp * (s32In1Temp >> 16)); \
+ s32OutLow += (( s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
+ s32OutLow ^= 0xFFFFFFFF; \
+ s32OutLow++; \
+ } \
+ else \
+ { \
+ s32OutLow = (s32In2Temp * (s32In1Temp >> 16)); \
+ s32OutLow += (( s32In2Temp * (s32In1Temp & 0xFFFF)) >> 16); \
+ } \
+ s32OutLow <<= 1; \
+}
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+#define SBC_MULT_64(s32In1, s32In2, s32OutLow, s32OutHi) \
+{\
+ s32OutLow=(SINT32)(((SINT64)s32In1*(SINT64)s32In2)& 0x00000000FFFFFFFF);\
+ s32OutHi=(SINT32)(((SINT64)s32In1*(SINT64)s32In2)>>32);\
+}
+#define SBC_MULT_32_32(s32In2, s32In1, s32OutLow) \
+{ \
+ s32HiTemp = 0; \
+ SBC_MULT_64(s32In2,s32In1 , s32OutLow, s32HiTemp); \
+ s32OutLow = (((s32OutLow>>15)&0x1FFFF) | (s32HiTemp << 17)); \
+}
+#endif
+
+#endif
+#endif
+#endif
+
+#endif
diff --git a/embdrv/sbc/encoder/include/sbc_enc_func_declare.h b/embdrv/sbc/encoder/include/sbc_enc_func_declare.h
new file mode 100644
index 0000000..cfe5777
--- /dev/null
+++ b/embdrv/sbc/encoder/include/sbc_enc_func_declare.h
@@ -0,0 +1,46 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_enc_func_declare.h,v $
+**
+** Description: Function declarations.
+**
+** Revision : $Id: sbc_enc_func_declare.h,v 1.8 2006/04/13 16:59:58 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#ifndef SBC_FUNCDECLARE_H
+#define SBC_FUNCDECLARE_H
+
+/*#include "sbc_encoder.h"*/
+/* Global data */
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == FALSE)
+extern const SINT16 gas32CoeffFor4SBs[];
+extern const SINT16 gas32CoeffFor8SBs[];
+#else
+extern const SINT32 gas32CoeffFor4SBs[];
+extern const SINT32 gas32CoeffFor8SBs[];
+#endif
+
+/* Global functions*/
+
+extern void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *CodecParams);
+extern void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *CodecParams);
+
+extern void SbcAnalysisInit (void);
+
+extern void SbcAnalysisFilter4(SBC_ENC_PARAMS *strEncParams);
+extern void SbcAnalysisFilter8(SBC_ENC_PARAMS *strEncParams);
+
+extern void SBC_FastIDCT8 (SINT32 *pInVect, SINT32 *pOutVect);
+extern void SBC_FastIDCT4 (SINT32 *x0, SINT32 *pOutVect);
+
+extern void EncPacking(SBC_ENC_PARAMS *strEncParams);
+extern void EncQuantizer(SBC_ENC_PARAMS *);
+#if (SBC_DSP_OPT==TRUE)
+ SINT32 SBC_Multiply_32_16_Simplified(SINT32 s32In2Temp,SINT32 s32In1Temp);
+#endif
+#endif
+
diff --git a/embdrv/sbc/encoder/include/sbc_encoder.h b/embdrv/sbc/encoder/include/sbc_encoder.h
new file mode 100644
index 0000000..b348de8
--- /dev/null
+++ b/embdrv/sbc/encoder/include/sbc_encoder.h
@@ -0,0 +1,191 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_encoder.h,v $
+**
+** Description: This file contains constants and structures used by Encoder.
+**
+** Revision : $Id: sbc_encoder.h,v 1.28 2006/06/27 12:29:32 mjougit Exp $
+**
+** Copyright (c) 1999-2008, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#ifndef SBC_ENCODER_H
+#define SBC_ENCODER_H
+
+#define ENCODER_VERSION "0025"
+
+#ifdef BUILDCFG
+ #include "bt_target.h"
+#endif
+
+/*DEFINES*/
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+#define SBC_MAX_NUM_OF_SUBBANDS 8
+#define SBC_MAX_NUM_OF_CHANNELS 2
+#define SBC_MAX_NUM_OF_BLOCKS 16
+
+#define SBC_LOUDNESS 0
+#define SBC_SNR 1
+
+#define SUB_BANDS_8 8
+#define SUB_BANDS_4 4
+
+#define SBC_sf16000 0
+#define SBC_sf32000 1
+#define SBC_sf44100 2
+#define SBC_sf48000 3
+
+#define SBC_MONO 0
+#define SBC_DUAL 1
+#define SBC_STEREO 2
+#define SBC_JOINT_STEREO 3
+
+#define SBC_BLOCK_0 4
+#define SBC_BLOCK_1 8
+#define SBC_BLOCK_2 12
+#define SBC_BLOCK_3 16
+
+#define SBC_NULL 0
+
+#ifndef SBC_MAX_NUM_FRAME
+#define SBC_MAX_NUM_FRAME 1
+#endif
+
+#ifndef SBC_DSP_OPT
+#define SBC_DSP_OPT FALSE
+#endif
+
+/* Set SBC_USE_ARM_PRAGMA to TRUE to use "#pragma arm section zidata" */
+#ifndef SBC_USE_ARM_PRAGMA
+#define SBC_USE_ARM_PRAGMA FALSE
+#endif
+
+/* Set SBC_ARM_ASM_OPT to TRUE in case the target is an ARM */
+/* this will replace all the 32 and 64 bit mult by in line assembly code */
+#ifndef SBC_ARM_ASM_OPT
+#define SBC_ARM_ASM_OPT FALSE
+#endif
+
+/* green hill compiler option -> Used to distinguish the syntax for inline assembly code*/
+#ifndef SBC_GHS_COMPILER
+#define SBC_GHS_COMPILER FALSE
+#endif
+
+/* ARM compiler option -> Used to distinguish the syntax for inline assembly code */
+#ifndef SBC_ARM_COMPILER
+#define SBC_ARM_COMPILER TRUE
+#endif
+
+/* Set SBC_IPAQ_OPT to TRUE in case the target is an ARM */
+/* 32 and 64 bit mult will be performed using SINT64 ( usualy __int64 ) cast that usualy give optimal performance if supported */
+#ifndef SBC_IPAQ_OPT
+#define SBC_IPAQ_OPT TRUE
+#endif
+
+/* Debug only: set SBC_IS_64_MULT_IN_WINDOW_ACCU to TRUE to use 64 bit multiplication in the windowing */
+/* -> not recomended, more MIPS for the same restitution. */
+#ifndef SBC_IS_64_MULT_IN_WINDOW_ACCU
+#define SBC_IS_64_MULT_IN_WINDOW_ACCU FALSE
+#endif /*SBC_IS_64_MULT_IN_WINDOW_ACCU */
+
+/* Set SBC_IS_64_MULT_IN_IDCT to TRUE to use 64 bits multiplication in the DCT of Matrixing */
+/* -> more MIPS required for a better audio quality. comparasion with the SIG utilities shows a division by 10 of the RMS */
+/* CAUTION: It only apply in the if SBC_FAST_DCT is set to TRUE */
+#ifndef SBC_IS_64_MULT_IN_IDCT
+#define SBC_IS_64_MULT_IN_IDCT FALSE
+#endif /*SBC_IS_64_MULT_IN_IDCT */
+
+/* set SBC_IS_64_MULT_IN_QUANTIZER to TRUE to use 64 bits multiplication in the quantizer */
+/* setting this flag to FALSE add whistling noise at 5.5 and 11 KHz usualy not perceptible by human's hears. */
+#ifndef SBC_IS_64_MULT_IN_QUANTIZER
+#define SBC_IS_64_MULT_IN_QUANTIZER TRUE
+#endif /*SBC_IS_64_MULT_IN_IDCT */
+
+/* Debug only: set this flag to FALSE to disable fast DCT algorithm */
+#ifndef SBC_FAST_DCT
+#define SBC_FAST_DCT TRUE
+#endif /*SBC_FAST_DCT */
+
+/* In case we do not use joint stereo mode the flag save some RAM and ROM in case it is set to FALSE */
+#ifndef SBC_JOINT_STE_INCLUDED
+#define SBC_JOINT_STE_INCLUDED TRUE
+#endif
+
+/* TRUE -> application should provide PCM buffer, FALSE PCM buffer reside in SBC_ENC_PARAMS */
+#ifndef SBC_NO_PCM_CPY_OPTION
+#define SBC_NO_PCM_CPY_OPTION FALSE
+#endif
+
+#define MINIMUM_ENC_VX_BUFFER_SIZE (8*10*2)
+#ifndef ENC_VX_BUFFER_SIZE
+#define ENC_VX_BUFFER_SIZE (MINIMUM_ENC_VX_BUFFER_SIZE + 64)
+/*#define ENC_VX_BUFFER_SIZE MINIMUM_ENC_VX_BUFFER_SIZE + 1024*/
+#endif
+
+#ifndef SBC_FOR_EMBEDDED_LINUX
+#define SBC_FOR_EMBEDDED_LINUX FALSE
+#endif
+
+/*constants used for index calculation*/
+#define SBC_BLK (SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS)
+
+#include "sbc_types.h"
+
+typedef struct SBC_ENC_PARAMS_TAG
+{
+ SINT16 s16SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
+ SINT16 s16ChannelMode; /* mono, dual, streo or joint streo*/
+ SINT16 s16NumOfSubBands; /* 4 or 8 */
+ SINT16 s16NumOfChannels;
+ SINT16 s16NumOfBlocks; /* 4, 8, 12 or 16*/
+ SINT16 s16AllocationMethod; /* loudness or SNR*/
+ SINT16 s16BitPool; /* 16*numOfSb for mono & dual;
+ 32*numOfSb for stereo & joint stereo */
+ UINT16 u16BitRate;
+ UINT8 u8NumPacketToEncode; /* number of sbc frame to encode. Default is 1 */
+#if (SBC_JOINT_STE_INCLUDED == TRUE)
+ SINT16 as16Join[SBC_MAX_NUM_OF_SUBBANDS]; /*1 if JS, 0 otherwise*/
+#endif
+
+ SINT16 s16MaxBitNeed;
+ SINT16 as16ScaleFactor[SBC_MAX_NUM_OF_CHANNELS*SBC_MAX_NUM_OF_SUBBANDS];
+
+ SINT16 *ps16NextPcmBuffer;
+#if (SBC_NO_PCM_CPY_OPTION == TRUE)
+ SINT16 *ps16PcmBuffer;
+#else
+ SINT16 as16PcmBuffer[SBC_MAX_NUM_FRAME*SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS];
+#endif
+
+ SINT16 s16ScartchMemForBitAlloc[16];
+
+ SINT32 s32SbBuffer[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * SBC_MAX_NUM_OF_BLOCKS];
+
+ SINT16 as16Bits[SBC_MAX_NUM_OF_CHANNELS*SBC_MAX_NUM_OF_SUBBANDS];
+
+ UINT8 *pu8Packet;
+ UINT8 *pu8NextPacket;
+ UINT16 FrameHeader;
+ UINT16 u16PacketLength;
+
+}SBC_ENC_PARAMS;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+SBC_API extern void SBC_Encoder(SBC_ENC_PARAMS *strEncParams);
+SBC_API extern void SBC_Encoder_Init(SBC_ENC_PARAMS *strEncParams);
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/embdrv/sbc/encoder/include/sbc_if.h b/embdrv/sbc/encoder/include/sbc_if.h
new file mode 100644
index 0000000..7e4c2c5
--- /dev/null
+++ b/embdrv/sbc/encoder/include/sbc_if.h
@@ -0,0 +1,28 @@
+#ifndef _SBC_IF_H
+#define _SBC_IF_H
+
+#define PCM_BUFFER_SIZE 512
+
+/*
+ SBC_Init - called once for each track played
+
+ pcm_sample_freq - 4000 to 48000
+ channels - 1 mono 2 stereo
+ bits_per_sample - 8 or 16
+ return - 0 sucess
+*/
+
+int SBC_init(int pcm_sample_freq, int channels, int bits_per_sample);
+
+/*
+ SBC_write - called repeatedly with pcm_in pointer
+ increasing by length until track is finished.
+
+ pcm_in - pointer to PCM buffer
+ length - any
+ sbc_out - pointer to SBC output buffer
+ return - number of bytes written to sbc_out
+*/
+
+int SBC_write(unsigned char *pcm_in, int length, unsigned char *sbc_out);
+#endif
diff --git a/embdrv/sbc/encoder/include/sbc_types.h b/embdrv/sbc/encoder/include/sbc_types.h
new file mode 100644
index 0000000..531bb2c
--- /dev/null
+++ b/embdrv/sbc/encoder/include/sbc_types.h
@@ -0,0 +1,46 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_types.h,v $
+**
+** Description: Data type declarations.
+**
+** Revision : $Id: sbc_types.h,v 1.7 2006/04/11 17:07:39 mjougit Exp $
+**
+** Copyright (c) 1999-2008, Broadcom Corp., All Rights Reserved.
+** Broadcom Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#ifndef SBC_TYPES_H
+#define SBC_TYPES_H
+
+#ifdef BUILDCFG
+#include "bt_target.h"
+#endif
+
+#include "data_types.h"
+
+typedef short SINT16;
+typedef long SINT32;
+
+#if (SBC_IPAQ_OPT == TRUE)
+
+#if (SBC_FOR_EMBEDDED_LINUX == TRUE)
+typedef long long SINT64;
+#else
+typedef __int64 SINT64;
+#endif
+
+#elif (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE) || (SBC_IS_64_MULT_IN_IDCT == TRUE)
+
+#if (SBC_FOR_EMBEDDED_LINUX == TRUE)
+typedef long long SINT64;
+#else
+typedef __int64 SINT64;
+#endif
+
+#endif
+
+#define abs32(x) ( (x >= 0) ? x : (-x) )
+
+#endif
diff --git a/embdrv/sbc/encoder/srce/sbc_analysis.c b/embdrv/sbc/encoder/srce/sbc_analysis.c
new file mode 100644
index 0000000..77f4dbe
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_analysis.c
@@ -0,0 +1,1096 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_analysis.c,v $
+**
+** Description: This file contains the code that performs Analysis of the input
+** audio stream.
+**
+** Revision : $Id: sbc_analysis.c,v 1.29 2006/04/13 17:00:37 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+#include <string.h>
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+/*#include <math.h>*/
+
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+#define WIND_4_SUBBANDS_0_1 (SINT32)0x01659F45 /* gas32CoeffFor4SBs[8] = -gas32CoeffFor4SBs[32] = 0x01659F45 */
+#define WIND_4_SUBBANDS_0_2 (SINT32)0x115B1ED2 /* gas32CoeffFor4SBs[16] = -gas32CoeffFor4SBs[24] = 0x115B1ED2 */
+#define WIND_4_SUBBANDS_1_0 (SINT32)0x001194E6 /* gas32CoeffFor4SBs[1 et 39] = 0x001194E6 */
+#define WIND_4_SUBBANDS_1_1 (SINT32)0x029DBAA3 /* gas32CoeffFor4SBs[9 et 31] = 0x029DBAA3 */
+#define WIND_4_SUBBANDS_1_2 (SINT32)0x18F55C90 /* gas32CoeffFor4SBs[17 et 23] = 0x18F55C90 */
+#define WIND_4_SUBBANDS_1_3 (SINT32)0xF60FAF37 /* gas32CoeffFor4SBs[15 et 25] = 0xF60FAF37 */
+#define WIND_4_SUBBANDS_1_4 (SINT32)0xFF9BB9D5 /* gas32CoeffFor4SBs[7 et 33] = 0xFF9BB9D5 */
+#define WIND_4_SUBBANDS_2_0 (SINT32)0x0030E2D3 /* gas32CoeffFor4SBs[2 et 38] = 0x0030E2D3 */
+#define WIND_4_SUBBANDS_2_1 (SINT32)0x03B23341 /* gas32CoeffFor4SBs[10 et 30] = 0x03B23341 */
+#define WIND_4_SUBBANDS_2_2 (SINT32)0x1F91CA46 /* gas32CoeffFor4SBs[18 et 22] = 0x1F91CA46 */
+#define WIND_4_SUBBANDS_2_3 (SINT32)0xFC4F91D4 /* gas32CoeffFor4SBs[14 et 26] = 0xFC4F91D4 */
+#define WIND_4_SUBBANDS_2_4 (SINT32)0x003D239B /* gas32CoeffFor4SBs[6 et 34] = 0x003D239B */
+#define WIND_4_SUBBANDS_3_0 (SINT32)0x00599403 /* gas32CoeffFor4SBs[3 et 37] = 0x00599403 */
+#define WIND_4_SUBBANDS_3_1 (SINT32)0x041EEE40 /* gas32CoeffFor4SBs[11 et 29] = 0x041EEE40 */
+#define WIND_4_SUBBANDS_3_2 (SINT32)0x2412F251 /* gas32CoeffFor4SBs[19 et 21] = 0x2412F251 */
+#define WIND_4_SUBBANDS_3_3 (SINT32)0x00C8F2BC /* gas32CoeffFor4SBs[13 et 27] = 0x00C8F2BC */
+#define WIND_4_SUBBANDS_3_4 (SINT32)0x007F88E4 /* gas32CoeffFor4SBs[5 et 35] = 0x007F88E4 */
+#define WIND_4_SUBBANDS_4_0 (SINT32)0x007DBCC8 /* gas32CoeffFor4SBs[4 et 36] = 0x007DBCC8 */
+#define WIND_4_SUBBANDS_4_1 (SINT32)0x034FEE2C /* gas32CoeffFor4SBs[12 et 28] = 0x034FEE2C */
+#define WIND_4_SUBBANDS_4_2 (SINT32)0x25AC1FF2 /* gas32CoeffFor4SBs[20] = 0x25AC1FF2 */
+
+#define WIND_8_SUBBANDS_0_1 (SINT32)0x00B97348 /* 16 0x00B97348 */
+#define WIND_8_SUBBANDS_0_2 (SINT32)0x08B4307A /* 32 0x08B4307A */
+#define WIND_8_SUBBANDS_1_0 (SINT32)0x00052173 /* 1 et 79 = 0x00052173 */
+#define WIND_8_SUBBANDS_1_1 (SINT32)0x01071B96 /* 17 et 63 = 0x01071B96 */
+#define WIND_8_SUBBANDS_1_2 (SINT32)0x0A9F3E9A /* 33 et 47 = 0x0A9F3E9A*/
+#define WIND_8_SUBBANDS_1_3 (SINT32)0xF9312891 /* 31 et 49 = 0xF9312891 */
+#define WIND_8_SUBBANDS_1_4 (SINT32)0xFF8D6793 /* 15 et 65 = 0xFF8D6793 */
+#define WIND_8_SUBBANDS_2_0 (SINT32)0x000B3F71 /* 2 et 78 = 0x000B3F71 */
+#define WIND_8_SUBBANDS_2_1 (SINT32)0x0156B3CA /* 18 et 62 = 0x0156B3CA */
+#define WIND_8_SUBBANDS_2_2 (SINT32)0x0C7D59B6 /* 34 et 46 = 0x0C7D59B6 */
+#define WIND_8_SUBBANDS_2_3 (SINT32)0xFAFF95FC /* 30 et 50 = 0xFAFF95FC */
+#define WIND_8_SUBBANDS_2_4 (SINT32)0xFFC9F10E /* 14 et 66 = 0xFFC9F10E */
+#define WIND_8_SUBBANDS_3_0 (SINT32)0x00122C7D /* 3 et 77 = 0x00122C7D*/
+#define WIND_8_SUBBANDS_3_1 (SINT32)0x01A1B38B /* 19 et 61 = 0x01A1B38B */
+#define WIND_8_SUBBANDS_3_2 (SINT32)0x0E3BB16F /* 35 et 45 = 0x0E3BB16F */
+#define WIND_8_SUBBANDS_3_3 (SINT32)0xFCA86E7E /* 29 et 51 = 0xFCA86E7E */
+#define WIND_8_SUBBANDS_3_4 (SINT32)0xFFFA2413 /* 13 et 67 = 0xFFFA2413 */
+#define WIND_8_SUBBANDS_4_0 (SINT32)0x001AFF89 /* 4 et 66 = 0x001AFF89 */
+#define WIND_8_SUBBANDS_4_1 (SINT32)0x01E0224C /* 20 et 60 = 0x01E0224C */
+#define WIND_8_SUBBANDS_4_2 (SINT32)0x0FC721F9 /* 36 et 44 = 0x0FC721F9 */
+#define WIND_8_SUBBANDS_4_3 (SINT32)0xFE20435D /* 28 et 52 = 0xFE20435D */
+#define WIND_8_SUBBANDS_4_4 (SINT32)0x001D8FD2 /* 12 et 68 = 0x001D8FD2 */
+#define WIND_8_SUBBANDS_5_0 (SINT32)0x00255A62 /* 5 et 75 = 0x00255A62 */
+#define WIND_8_SUBBANDS_5_1 (SINT32)0x0209291F /* 21 et 59 = 0x0209291F */
+#define WIND_8_SUBBANDS_5_2 (SINT32)0x110ECEF0 /* 37 et 43 = 0x110ECEF0 */
+#define WIND_8_SUBBANDS_5_3 (SINT32)0xFF5EEB73 /* 27 et 53 = 0xFF5EEB73 */
+#define WIND_8_SUBBANDS_5_4 (SINT32)0x0034F8B6 /* 11 et 69 = 0x0034F8B6 */
+#define WIND_8_SUBBANDS_6_0 (SINT32)0x003060F4 /* 6 et 74 = 0x003060F4 */
+#define WIND_8_SUBBANDS_6_1 (SINT32)0x02138653 /* 22 et 58 = 0x02138653 */
+#define WIND_8_SUBBANDS_6_2 (SINT32)0x120435FA /* 38 et 42 = 0x120435FA */
+#define WIND_8_SUBBANDS_6_3 (SINT32)0x005FD0FF /* 26 et 54 = 0x005FD0FF */
+#define WIND_8_SUBBANDS_6_4 (SINT32)0x00415B75 /* 10 et 70 = 0x00415B75 */
+#define WIND_8_SUBBANDS_7_0 (SINT32)0x003A72E7 /* 7 et 73 = 0x003A72E7 */
+#define WIND_8_SUBBANDS_7_1 (SINT32)0x01F5F424 /* 23 et 57 = 0x01F5F424 */
+#define WIND_8_SUBBANDS_7_2 (SINT32)0x129C226F /* 39 et 41 = 0x129C226F */
+#define WIND_8_SUBBANDS_7_3 (SINT32)0x01223EBA /* 25 et 55 = 0x01223EBA */
+#define WIND_8_SUBBANDS_7_4 (SINT32)0x0044EF48 /* 9 et 71 = 0x0044EF48 */
+#define WIND_8_SUBBANDS_8_0 (SINT32)0x0041EC6A /* 8 et 72 = 0x0041EC6A */
+#define WIND_8_SUBBANDS_8_1 (SINT32)0x01A7ECEF /* 24 et 56 = 0x01A7ECEF */
+#define WIND_8_SUBBANDS_8_2 (SINT32)0x12CF6C75 /* 40 = 0x12CF6C75 */
+#else
+#define WIND_4_SUBBANDS_0_1 (SINT16)0x0166 /* gas32CoeffFor4SBs[8] = -gas32CoeffFor4SBs[32] = 0x01659F45 */
+#define WIND_4_SUBBANDS_0_2 (SINT16)0x115B /* gas32CoeffFor4SBs[16] = -gas32CoeffFor4SBs[24] = 0x115B1ED2 */
+#define WIND_4_SUBBANDS_1_0 (SINT16)0x0012 /* gas32CoeffFor4SBs[1 et 39] = 0x001194E6 */
+#define WIND_4_SUBBANDS_1_1 (SINT16)0x029E /* gas32CoeffFor4SBs[9 et 31] = 0x029DBAA3 */
+#define WIND_4_SUBBANDS_1_2 (SINT16)0x18F5 /* gas32CoeffFor4SBs[17 et 23] = 0x18F55C90 */
+#define WIND_4_SUBBANDS_1_3 (SINT16)0xF610 /* gas32CoeffFor4SBs[15 et 25] = 0xF60FAF37 */
+#define WIND_4_SUBBANDS_1_4 (SINT16)0xFF9C /* gas32CoeffFor4SBs[7 et 33] = 0xFF9BB9D5 */
+#define WIND_4_SUBBANDS_2_0 (SINT16)0x0031 /* gas32CoeffFor4SBs[2 et 38] = 0x0030E2D3 */
+#define WIND_4_SUBBANDS_2_1 (SINT16)0x03B2 /* gas32CoeffFor4SBs[10 et 30] = 0x03B23341 */
+#define WIND_4_SUBBANDS_2_2 (SINT16)0x1F91 /* gas32CoeffFor4SBs[18 et 22] = 0x1F91CA46 */
+#define WIND_4_SUBBANDS_2_3 (SINT16)0xFC50 /* gas32CoeffFor4SBs[14 et 26] = 0xFC4F91D4 */
+#define WIND_4_SUBBANDS_2_4 (SINT16)0x003D /* gas32CoeffFor4SBs[6 et 34] = 0x003D239B */
+#define WIND_4_SUBBANDS_3_0 (SINT16)0x005A /* gas32CoeffFor4SBs[3 et 37] = 0x00599403 */
+#define WIND_4_SUBBANDS_3_1 (SINT16)0x041F /* gas32CoeffFor4SBs[11 et 29] = 0x041EEE40 */
+#define WIND_4_SUBBANDS_3_2 (SINT16)0x2413 /* gas32CoeffFor4SBs[19 et 21] = 0x2412F251 */
+#define WIND_4_SUBBANDS_3_3 (SINT16)0x00C9 /* gas32CoeffFor4SBs[13 et 27] = 0x00C8F2BC */
+#define WIND_4_SUBBANDS_3_4 (SINT16)0x0080 /* gas32CoeffFor4SBs[5 et 35] = 0x007F88E4 */
+#define WIND_4_SUBBANDS_4_0 (SINT16)0x007E /* gas32CoeffFor4SBs[4 et 36] = 0x007DBCC8 */
+#define WIND_4_SUBBANDS_4_1 (SINT16)0x0350 /* gas32CoeffFor4SBs[12 et 28] = 0x034FEE2C */
+#define WIND_4_SUBBANDS_4_2 (SINT16)0x25AC /* gas32CoeffFor4SBs[20] = 25AC1FF2 */
+
+#define WIND_8_SUBBANDS_0_1 (SINT16)0x00B9 /* 16 0x12CF6C75 */
+#define WIND_8_SUBBANDS_0_2 (SINT16)0x08B4 /* 32 0x08B4307A */
+#define WIND_8_SUBBANDS_1_0 (SINT16)0x0005 /* 1 et 79 = 0x00052173 */
+#define WIND_8_SUBBANDS_1_1 (SINT16)0x0107 /* 17 et 63 = 0x01071B96 */
+#define WIND_8_SUBBANDS_1_2 (SINT16)0x0A9F /* 33 et 47 = 0x0A9F3E9A*/
+#define WIND_8_SUBBANDS_1_3 (SINT16)0xF931 /* 31 et 49 = 0xF9312891 */
+#define WIND_8_SUBBANDS_1_4 (SINT16)0xFF8D /* 15 et 65 = 0xFF8D6793 */
+#define WIND_8_SUBBANDS_2_0 (SINT16)0x000B /* 2 et 78 = 0x000B3F71 */
+#define WIND_8_SUBBANDS_2_1 (SINT16)0x0157 /* 18 et 62 = 0x0156B3CA */
+#define WIND_8_SUBBANDS_2_2 (SINT16)0x0C7D /* 34 et 46 = 0x0C7D59B6 */
+#define WIND_8_SUBBANDS_2_3 (SINT16)0xFB00 /* 30 et 50 = 0xFAFF95FC */
+#define WIND_8_SUBBANDS_2_4 (SINT16)0xFFCA /* 14 et 66 = 0xFFC9F10E */
+#define WIND_8_SUBBANDS_3_0 (SINT16)0x0012 /* 3 et 77 = 0x00122C7D*/
+#define WIND_8_SUBBANDS_3_1 (SINT16)0x01A2 /* 19 et 61 = 0x01A1B38B */
+#define WIND_8_SUBBANDS_3_2 (SINT16)0x0E3C /* 35 et 45 = 0x0E3BB16F */
+#define WIND_8_SUBBANDS_3_3 (SINT16)0xFCA8 /* 29 et 51 = 0xFCA86E7E */
+#define WIND_8_SUBBANDS_3_4 (SINT16)0xFFFA /* 13 et 67 = 0xFFFA2413 */
+#define WIND_8_SUBBANDS_4_0 (SINT16)0x001B /* 4 et 66 = 0x001AFF89 */
+#define WIND_8_SUBBANDS_4_1 (SINT16)0x01E0 /* 20 et 60 = 0x01E0224C */
+#define WIND_8_SUBBANDS_4_2 (SINT16)0x0FC7 /* 36 et 44 = 0x0FC721F9 */
+#define WIND_8_SUBBANDS_4_3 (SINT16)0xFE20 /* 28 et 52 = 0xFE20435D */
+#define WIND_8_SUBBANDS_4_4 (SINT16)0x001E /* 12 et 68 = 0x001D8FD2 */
+#define WIND_8_SUBBANDS_5_0 (SINT16)0x0025 /* 5 et 75 = 0x00255A62 */
+#define WIND_8_SUBBANDS_5_1 (SINT16)0x0209 /* 21 et 59 = 0x0209291F */
+#define WIND_8_SUBBANDS_5_2 (SINT16)0x110F /* 37 et 43 = 0x110ECEF0 */
+#define WIND_8_SUBBANDS_5_3 (SINT16)0xFF5F /* 27 et 53 = 0xFF5EEB73 */
+#define WIND_8_SUBBANDS_5_4 (SINT16)0x0035 /* 11 et 69 = 0x0034F8B6 */
+#define WIND_8_SUBBANDS_6_0 (SINT16)0x0030 /* 6 et 74 = 0x003060F4 */
+#define WIND_8_SUBBANDS_6_1 (SINT16)0x0214 /* 22 et 58 = 0x02138653 */
+#define WIND_8_SUBBANDS_6_2 (SINT16)0x1204 /* 38 et 42 = 0x120435FA */
+#define WIND_8_SUBBANDS_6_3 (SINT16)0x0060 /* 26 et 54 = 0x005FD0FF */
+#define WIND_8_SUBBANDS_6_4 (SINT16)0x0041 /* 10 et 70 = 0x00415B75 */
+#define WIND_8_SUBBANDS_7_0 (SINT16)0x003A /* 7 et 73 = 0x003A72E7 */
+#define WIND_8_SUBBANDS_7_1 (SINT16)0x01F6 /* 23 et 57 = 0x01F5F424 */
+#define WIND_8_SUBBANDS_7_2 (SINT16)0x129C /* 39 et 41 = 0x129C226F */
+#define WIND_8_SUBBANDS_7_3 (SINT16)0x0122 /* 25 et 55 = 0x01223EBA */
+#define WIND_8_SUBBANDS_7_4 (SINT16)0x0045 /* 9 et 71 = 0x0044EF48 */
+#define WIND_8_SUBBANDS_8_0 (SINT16)0x0042 /* 8 et 72 = 0x0041EC6A */
+#define WIND_8_SUBBANDS_8_1 (SINT16)0x01A8 /* 24 et 56 = 0x01A7ECEF */
+#define WIND_8_SUBBANDS_8_2 (SINT16)0x12CF /* 40 = 0x12CF6C75 */
+#endif
+
+#if (SBC_USE_ARM_PRAGMA==TRUE)
+#pragma arm section zidata = "sbc_s32_analysis_section"
+#endif
+static SINT32 s32DCTY[16] = {0};
+static SINT32 s32X[ENC_VX_BUFFER_SIZE/2];
+static SINT16 *s16X=(SINT16*) s32X; /* s16X must be 32 bits aligned cf SHIFTUP_X8_2*/
+#if (SBC_USE_ARM_PRAGMA==TRUE)
+#pragma arm section zidata
+#endif
+
+/* This macro is for 4 subbands */
+#define SHIFTUP_X4 \
+{ \
+ ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+38); \
+ for (i=0;i<9;i++) \
+ { \
+ *ps32X=*(ps32X-2-(ShiftCounter>>1)); ps32X--; \
+ *ps32X=*(ps32X-2-(ShiftCounter>>1)); ps32X--; \
+ } \
+}
+#define SHIFTUP_X4_2 \
+{ \
+ ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+38); \
+ ps32X2=(SINT32 *)(s16X+(EncMaxShiftCounter<<1)+78); \
+ for (i=0;i<9;i++) \
+ { \
+ *ps32X=*(ps32X-2-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-2-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ *ps32X=*(ps32X-2-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-2-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ } \
+}
+
+/* This macro is for 8 subbands */
+#define SHIFTUP_X8 \
+{ \
+ ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+78); \
+ for (i=0;i<9;i++) \
+ { \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); ps32X--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); ps32X--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); ps32X--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); ps32X--; \
+ } \
+}
+#define SHIFTUP_X8_2 \
+{ \
+ ps32X=(SINT32 *)(s16X+EncMaxShiftCounter+78); \
+ ps32X2=(SINT32 *)(s16X+(EncMaxShiftCounter<<1)+158); \
+ for (i=0;i<9;i++) \
+ { \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ *ps32X=*(ps32X-4-(ShiftCounter>>1)); *(ps32X2)=*(ps32X2-4-(ShiftCounter>>1)); ps32X--; ps32X2--; \
+ } \
+}
+
+#if (SBC_ARM_ASM_OPT==TRUE)
+#define WINDOW_ACCU_8_0 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_0_1,(s16X[ChOffset+16]-s16X[ChOffset+64]);\
+ MLA s32Hi,WIND_8_SUBBANDS_0_2,(s16X[ChOffset+32]-s16X[ChOffset+48]),s32Hi;\
+ MOV s32DCTY[0],s32Hi;\
+ }\
+}
+#define WINDOW_ACCU_8_1_15 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_1_0,s16X[ChOffset+1];\
+ MUL s32Hi2,WIND_8_SUBBANDS_1_0,s16X[ChOffset+64+15];\
+ MLA s32Hi,WIND_8_SUBBANDS_1_1,s16X[ChOffset+16+1],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_1_1,s16X[ChOffset+48+15],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_1_2,s16X[ChOffset+32+1],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_1_2,s16X[ChOffset+32+15],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_1_3,s16X[ChOffset+48+1],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_1_3,s16X[ChOffset+16+15],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_1_4,s16X[ChOffset+64+1],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_1_4,s16X[ChOffset+15],s32Hi2;\
+ MOV s32DCTY[1],s32Hi;\
+ MOV s32DCTY[15],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_2_14 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_2_0,s16X[ChOffset+2];\
+ MUL s32Hi2,WIND_8_SUBBANDS_2_0,s16X[ChOffset+64+14];\
+ MLA s32Hi,WIND_8_SUBBANDS_2_1,s16X[ChOffset+16+2],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_2_1,s16X[ChOffset+48+14],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_2_2,s16X[ChOffset+32+2],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_2_2,s16X[ChOffset+32+14],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_2_3,s16X[ChOffset+48+2],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_2_3,s16X[ChOffset+16+14],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_2_4,s16X[ChOffset+64+2],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_2_4,s16X[ChOffset+14],s32Hi2;\
+ MOV s32DCTY[2],s32Hi;\
+ MOV s32DCTY[14],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_3_13 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_3_0,s16X[ChOffset+3];\
+ MUL s32Hi2,WIND_8_SUBBANDS_3_0,s16X[ChOffset+64+13];\
+ MLA s32Hi,WIND_8_SUBBANDS_3_1,s16X[ChOffset+16+3],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_3_1,s16X[ChOffset+48+13],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_3_2,s16X[ChOffset+32+3],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_3_2,s16X[ChOffset+32+13],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_3_3,s16X[ChOffset+48+3],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_3_3,s16X[ChOffset+16+13],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_3_4,s16X[ChOffset+64+3],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_3_4,s16X[ChOffset+13],s32Hi2;\
+ MOV s32DCTY[3],s32Hi;\
+ MOV s32DCTY[13],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_4_12 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_4_0,s16X[ChOffset+4];\
+ MUL s32Hi2,WIND_8_SUBBANDS_4_0,s16X[ChOffset+64+12];\
+ MLA s32Hi,WIND_8_SUBBANDS_4_1,s16X[ChOffset+16+4],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_4_1,s16X[ChOffset+48+12],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_4_2,s16X[ChOffset+32+4],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_4_2,s16X[ChOffset+32+12],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_4_3,s16X[ChOffset+48+4],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_4_3,s16X[ChOffset+16+12],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_4_4,s16X[ChOffset+64+4],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_4_4,s16X[ChOffset+12],s32Hi2;\
+ MOV s32DCTY[4],s32Hi;\
+ MOV s32DCTY[12],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_5_11 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_5_0,s16X[ChOffset+5];\
+ MUL s32Hi2,WIND_8_SUBBANDS_5_0,s16X[ChOffset+64+11];\
+ MLA s32Hi,WIND_8_SUBBANDS_5_1,s16X[ChOffset+16+5],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_5_1,s16X[ChOffset+48+11],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_5_2,s16X[ChOffset+32+5],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_5_2,s16X[ChOffset+32+11],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_5_3,s16X[ChOffset+48+5],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_5_3,s16X[ChOffset+16+11],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_5_4,s16X[ChOffset+64+5],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_5_4,s16X[ChOffset+11],s32Hi2;\
+ MOV s32DCTY[5],s32Hi;\
+ MOV s32DCTY[11],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_6_10 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_6_0,s16X[ChOffset+6];\
+ MUL s32Hi2,WIND_8_SUBBANDS_6_0,s16X[ChOffset+64+10];\
+ MLA s32Hi,WIND_8_SUBBANDS_6_1,s16X[ChOffset+16+6],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_6_1,s16X[ChOffset+48+10],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_6_2,s16X[ChOffset+32+6],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_6_2,s16X[ChOffset+32+10],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_6_3,s16X[ChOffset+48+6],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_6_3,s16X[ChOffset+16+10],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_6_4,s16X[ChOffset+64+6],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_6_4,s16X[ChOffset+10],s32Hi2;\
+ MOV s32DCTY[6],s32Hi;\
+ MOV s32DCTY[10],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_7_9 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_7_0,s16X[ChOffset+7];\
+ MUL s32Hi2,WIND_8_SUBBANDS_7_0,s16X[ChOffset+64+9];\
+ MLA s32Hi,WIND_8_SUBBANDS_7_1,s16X[ChOffset+16+7],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_7_1,s16X[ChOffset+48+9],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_7_2,s16X[ChOffset+32+7],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_7_2,s16X[ChOffset+32+9],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_7_3,s16X[ChOffset+48+7],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_7_3,s16X[ChOffset+16+9],s32Hi2;\
+ MLA s32Hi,WIND_8_SUBBANDS_7_4,s16X[ChOffset+64+7],s32Hi;\
+ MLA s32Hi2,WIND_8_SUBBANDS_7_4,s16X[ChOffset+9],s32Hi2;\
+ MOV s32DCTY[7],s32Hi;\
+ MOV s32DCTY[9],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_8_8 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_8_SUBBANDS_8_0,(s16X[ChOffset+8]+s16X[ChOffset+8+64]);\
+ MLA s32Hi,WIND_8_SUBBANDS_8_1,(s16X[ChOffset+8+16]+s16X[ChOffset+8+64]),s32Hi;\
+ MLA s32Hi,WIND_8_SUBBANDS_8_2,s16X[ChOffset+8+32],s32Hi;\
+ MOV s32DCTY[8],s32Hi;\
+ }\
+}
+#define WINDOW_ACCU_4_0 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_4_SUBBANDS_0_1,(s16X[ChOffset+8]-s16X[ChOffset+32]);\
+ MLA s32Hi,WIND_4_SUBBANDS_0_2,(s16X[ChOffset+16]-s16X[ChOffset+24]),s32Hi;\
+ MOV s32DCTY[0],s32Hi;\
+ }\
+}
+#define WINDOW_ACCU_4_1_7 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_4_SUBBANDS_1_0,s16X[ChOffset+1];\
+ MUL s32Hi2,WIND_4_SUBBANDS_1_0,s16X[ChOffset+32+7];\
+ MLA s32Hi,WIND_4_SUBBANDS_1_1,s16X[ChOffset+8+1],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_1_1,s16X[ChOffset+24+7],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_1_2,s16X[ChOffset+16+1],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_1_2,s16X[ChOffset+16+7],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_1_3,s16X[ChOffset+24+1],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_1_3,s16X[ChOffset+8+7],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_1_4,s16X[ChOffset+32+1],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_1_4,s16X[ChOffset+7],s32Hi2;\
+ MOV s32DCTY[1],s32Hi;\
+ MOV s32DCTY[7],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_4_2_6 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_4_SUBBANDS_2_0,s16X[ChOffset+2];\
+ MUL s32Hi2,WIND_4_SUBBANDS_2_0,s16X[ChOffset+32+6];\
+ MLA s32Hi,WIND_4_SUBBANDS_2_1,s16X[ChOffset+8+2],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_2_1,s16X[ChOffset+24+6],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_2_2,s16X[ChOffset+16+2],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_2_2,s16X[ChOffset+16+6],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_2_3,s16X[ChOffset+24+2],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_2_3,s16X[ChOffset+8+6],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_2_4,s16X[ChOffset+32+2],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_2_4,s16X[ChOffset+6],s32Hi2;\
+ MOV s32DCTY[2],s32Hi;\
+ MOV s32DCTY[6],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_4_3_5 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_4_SUBBANDS_3_0,s16X[ChOffset+3];\
+ MUL s32Hi2,WIND_4_SUBBANDS_3_0,s16X[ChOffset+32+5];\
+ MLA s32Hi,WIND_4_SUBBANDS_3_1,s16X[ChOffset+8+3],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_3_1,s16X[ChOffset+24+5],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_3_2,s16X[ChOffset+16+3],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_3_2,s16X[ChOffset+16+5],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_3_3,s16X[ChOffset+24+3],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_3_3,s16X[ChOffset+8+5],s32Hi2;\
+ MLA s32Hi,WIND_4_SUBBANDS_3_4,s16X[ChOffset+32+3],s32Hi;\
+ MLA s32Hi2,WIND_4_SUBBANDS_3_4,s16X[ChOffset+5],s32Hi2;\
+ MOV s32DCTY[3],s32Hi;\
+ MOV s32DCTY[5],s32Hi2;\
+ }\
+}
+#define WINDOW_ACCU_4_4 \
+{\
+ __asm\
+ {\
+ MUL s32Hi,WIND_4_SUBBANDS_4_0,(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
+ MLA s32Hi,WIND_4_SUBBANDS_4_1,(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]),s32Hi;\
+ MLA s32Hi,WIND_4_SUBBANDS_4_2,s16X[ChOffset+4+16],s32Hi;\
+ MOV s32DCTY[4],s32Hi;\
+ }\
+}
+
+#define WINDOW_PARTIAL_4 \
+{\
+ WINDOW_ACCU_4_0; WINDOW_ACCU_4_1_7;\
+ WINDOW_ACCU_4_2_6; WINDOW_ACCU_4_3_5;\
+ WINDOW_ACCU_4_4;\
+}
+
+#define WINDOW_PARTIAL_8 \
+{\
+ WINDOW_ACCU_8_0; WINDOW_ACCU_8_1_15;\
+ WINDOW_ACCU_8_2_14; WINDOW_ACCU_8_3_13;\
+ WINDOW_ACCU_8_4_12; WINDOW_ACCU_8_5_11;\
+ WINDOW_ACCU_8_6_10; WINDOW_ACCU_8_7_9;\
+ WINDOW_ACCU_8_8;\
+}
+
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+#define WINDOW_ACCU_8_0 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_0_1*(SINT64)(s16X[ChOffset+16]-s16X[ChOffset+64]);\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_0_2*(SINT64)(s16X[ChOffset+32]-s16X[ChOffset+48]);\
+ s32DCTY[0]=(SINT32)(s64Temp>>16);\
+}
+#define WINDOW_ACCU_8_1_15 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_1_0*(SINT64)s16X[ChOffset+1];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_1_0*(SINT64)s16X[ChOffset+64+15];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_1_1*(SINT64)s16X[ChOffset+16+1];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_1*(SINT64)s16X[ChOffset+48+15];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_1_2*(SINT64)s16X[ChOffset+32+1];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_2*(SINT64)s16X[ChOffset+32+15];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_1_3*(SINT64)s16X[ChOffset+48+1];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_3*(SINT64)s16X[ChOffset+16+15];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_1_4*(SINT64)s16X[ChOffset+64+1];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_1_4*(SINT64)s16X[ChOffset+15];\
+ s32DCTY[1]=(SINT32)(s64Temp>>16);\
+ s32DCTY[15]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_2_14 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_2_0*(SINT64)s16X[ChOffset+2];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_2_0*(SINT64)s16X[ChOffset+64+14];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_2_1*(SINT64)s16X[ChOffset+16+2];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_1*(SINT64)s16X[ChOffset+48+14];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_2_2*(SINT64)s16X[ChOffset+32+2];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_2*(SINT64)s16X[ChOffset+32+14];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_2_3*(SINT64)s16X[ChOffset+48+2];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_3*(SINT64)s16X[ChOffset+16+14];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_2_4*(SINT64)s16X[ChOffset+64+2];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_2_4*(SINT64)s16X[ChOffset+14];\
+ s32DCTY[2]=(SINT32)(s64Temp>>16);\
+ s32DCTY[14]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_3_13 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_3_0*(SINT64)s16X[ChOffset+3];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_3_0*(SINT64)s16X[ChOffset+64+13];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_3_1*(SINT64)s16X[ChOffset+16+3];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_1*(SINT64)s16X[ChOffset+48+13];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_3_2*(SINT64)s16X[ChOffset+32+3];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_2*(SINT64)s16X[ChOffset+32+13];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_3_3*(SINT64)s16X[ChOffset+48+3];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_3*(SINT64)s16X[ChOffset+16+13];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_3_4*(SINT64)s16X[ChOffset+64+3];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_3_4*(SINT64)s16X[ChOffset+13];\
+ s32DCTY[3]=(SINT32)(s64Temp>>16);\
+ s32DCTY[13]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_4_12 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_4_0*(SINT64)s16X[ChOffset+4];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_4_0*(SINT64)s16X[ChOffset+64+12];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_4_1*(SINT64)s16X[ChOffset+16+4];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_1*(SINT64)s16X[ChOffset+48+12];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_4_2*(SINT64)s16X[ChOffset+32+4];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_2*(SINT64)s16X[ChOffset+32+12];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_4_3*(SINT64)s16X[ChOffset+48+4];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_3*(SINT64)s16X[ChOffset+16+12];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_4_4*(SINT64)s16X[ChOffset+64+4];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_4_4*(SINT64)s16X[ChOffset+12];\
+ s32DCTY[4]=(SINT32)(s64Temp>>16);\
+ s32DCTY[12]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_5_11 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_5_0*(SINT64)s16X[ChOffset+5];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_5_0*(SINT64)s16X[ChOffset+64+11];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_5_1*(SINT64)s16X[ChOffset+16+5];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_1*(SINT64)s16X[ChOffset+48+11];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_5_2*(SINT64)s16X[ChOffset+32+5];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_2*(SINT64)s16X[ChOffset+32+11];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_5_3*(SINT64)s16X[ChOffset+48+5];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_3*(SINT64)s16X[ChOffset+16+11];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_5_4*(SINT64)s16X[ChOffset+64+5];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_5_4*(SINT64)s16X[ChOffset+11];\
+ s32DCTY[5]=(SINT32)(s64Temp>>16);\
+ s32DCTY[11]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_6_10 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_6_0*(SINT64)s16X[ChOffset+6];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_6_0*(SINT64)s16X[ChOffset+64+10];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_6_1*(SINT64)s16X[ChOffset+16+6];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_1*(SINT64)s16X[ChOffset+48+10];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_6_2*(SINT64)s16X[ChOffset+32+6];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_2*(SINT64)s16X[ChOffset+32+10];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_6_3*(SINT64)s16X[ChOffset+48+6];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_3*(SINT64)s16X[ChOffset+16+10];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_6_4*(SINT64)s16X[ChOffset+64+6];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_6_4*(SINT64)s16X[ChOffset+10];\
+ s32DCTY[6]=(SINT32)(s64Temp>>16);\
+ s32DCTY[10]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_7_9 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_7_0*(SINT64)s16X[ChOffset+7];\
+ s64Temp2=(SINT64)WIND_8_SUBBANDS_7_0*(SINT64)s16X[ChOffset+64+9];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_7_1*(SINT64)s16X[ChOffset+16+7];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_1*(SINT64)s16X[ChOffset+48+9];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_7_2*(SINT64)s16X[ChOffset+32+7];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_2*(SINT64)s16X[ChOffset+32+9];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_7_3*(SINT64)s16X[ChOffset+48+7];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_3*(SINT64)s16X[ChOffset+16+9];\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_7_4*(SINT64)s16X[ChOffset+64+7];\
+ s64Temp2+=(SINT64)WIND_8_SUBBANDS_7_4*(SINT64)s16X[ChOffset+9];\
+ s32DCTY[7]=(SINT32)(s64Temp>>16);\
+ s32DCTY[9]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_8_8 \
+{\
+ s64Temp=(SINT64)WIND_8_SUBBANDS_8_0*(SINT64)(s16X[ChOffset+8]+s16X[ChOffset+64+8]);\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_8_1*(SINT64)(s16X[ChOffset+16+8]+s16X[ChOffset+48+8]);\
+ s64Temp+=(SINT64)WIND_8_SUBBANDS_8_2*(SINT64)s16X[ChOffset+32+8];\
+ s32DCTY[8]=(SINT32)(s64Temp>>16);\
+}
+#define WINDOW_ACCU_4_0 \
+{\
+ s64Temp=(SINT64)WIND_4_SUBBANDS_0_1*(SINT64)(s16X[ChOffset+8]-s16X[ChOffset+32]);\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_0_2*(SINT64)(s16X[ChOffset+16]-s16X[ChOffset+24]);\
+ s32DCTY[0]=(SINT32)(s64Temp>>16);\
+}
+#define WINDOW_ACCU_4_1_7 \
+{\
+ s64Temp=(SINT64)WIND_4_SUBBANDS_1_0*(SINT64)s16X[ChOffset+1];\
+ s64Temp2=(SINT64)WIND_4_SUBBANDS_1_0*(SINT64)s16X[ChOffset+32+7];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_1_1*(SINT64)s16X[ChOffset+8+1];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_1*(SINT64)s16X[ChOffset+24+7];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_1_2*(SINT64)s16X[ChOffset+16+1];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_2*(SINT64)s16X[ChOffset+16+7];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_1_3*(SINT64)s16X[ChOffset+24+1];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_3*(SINT64)s16X[ChOffset+8+7];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_1_4*(SINT64)s16X[ChOffset+32+1];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_1_4*(SINT64)s16X[ChOffset+7];\
+ s32DCTY[1]=(SINT32)(s64Temp>>16);\
+ s32DCTY[7]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_4_2_6 \
+{\
+ s64Temp=(SINT64)WIND_4_SUBBANDS_2_0*(SINT64)s16X[ChOffset+2];\
+ s64Temp2=(SINT64)WIND_4_SUBBANDS_2_0*(SINT64)s16X[ChOffset+32+6];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_2_1*(SINT64)s16X[ChOffset+8+2];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_1*(SINT64)s16X[ChOffset+24+6];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_2_2*(SINT64)s16X[ChOffset+16+2];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_2*(SINT64)s16X[ChOffset+16+6];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_2_3*(SINT64)s16X[ChOffset+24+2];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_3*(SINT64)s16X[ChOffset+8+6];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_2_4*(SINT64)s16X[ChOffset+32+2];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_2_4*(SINT64)s16X[ChOffset+6];\
+ s32DCTY[2]=(SINT32)(s64Temp>>16);\
+ s32DCTY[6]=(SINT32)(s64Temp2>>16);\
+}
+#define WINDOW_ACCU_4_3_5 \
+{\
+ s64Temp=(SINT64)WIND_4_SUBBANDS_3_0*(SINT64)s16X[ChOffset+3];\
+ s64Temp2=(SINT64)WIND_4_SUBBANDS_3_0*(SINT64)s16X[ChOffset+32+5];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_3_1*(SINT64)s16X[ChOffset+8+3];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_1*(SINT64)s16X[ChOffset+24+5];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_3_2*(SINT64)s16X[ChOffset+16+3];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_2*(SINT64)s16X[ChOffset+16+5];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_3_3*(SINT64)s16X[ChOffset+24+3];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_3*(SINT64)s16X[ChOffset+8+5];\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_3_4*(SINT64)s16X[ChOffset+32+3];\
+ s64Temp2+=(SINT64)WIND_4_SUBBANDS_3_4*(SINT64)s16X[ChOffset+5];\
+ s32DCTY[3]=(SINT32)(s64Temp>>16);\
+ s32DCTY[5]=(SINT32)(s64Temp2>>16);\
+}
+
+#define WINDOW_ACCU_4_4 \
+{\
+ s64Temp=(SINT64)WIND_4_SUBBANDS_4_0*(SINT64)(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_4_1*(SINT64)(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]);\
+ s64Temp+=(SINT64)WIND_4_SUBBANDS_4_2*(SINT64)s16X[ChOffset+4+16];\
+ s32DCTY[4]=(SINT32)(s64Temp>>16);\
+}
+#else /* SBC_IS_64_MULT_IN_WINDOW_ACCU == FALSE */
+#define WINDOW_ACCU_8_0 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_0_1*(SINT32)(s16X[ChOffset+16]-s16X[ChOffset+64]);\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_0_2*(SINT32)(s16X[ChOffset+32]-s16X[ChOffset+48]);\
+ s32DCTY[0]=(SINT32)s32Temp;\
+}
+#define WINDOW_ACCU_8_1_15 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_1_0*(SINT32)s16X[ChOffset+1];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_1_0*(SINT32)s16X[ChOffset+64+15];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_1_1*(SINT32)s16X[ChOffset+16+1];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_1*(SINT32)s16X[ChOffset+48+15];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_1_2*(SINT32)s16X[ChOffset+32+1];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_2*(SINT32)s16X[ChOffset+32+15];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_1_3*(SINT32)s16X[ChOffset+48+1];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_3*(SINT32)s16X[ChOffset+16+15];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_1_4*(SINT32)s16X[ChOffset+64+1];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_1_4*(SINT32)s16X[ChOffset+15];\
+ s32DCTY[1]=(SINT32)s32Temp;\
+ s32DCTY[15]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_2_14 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_2_0*(SINT32)s16X[ChOffset+2];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_2_0*(SINT32)s16X[ChOffset+64+14];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_2_1*(SINT32)s16X[ChOffset+16+2];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_1*(SINT32)s16X[ChOffset+48+14];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_2_2*(SINT32)s16X[ChOffset+32+2];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_2*(SINT32)s16X[ChOffset+32+14];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_2_3*(SINT32)s16X[ChOffset+48+2];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_3*(SINT32)s16X[ChOffset+16+14];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_2_4*(SINT32)s16X[ChOffset+64+2];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_2_4*(SINT32)s16X[ChOffset+14];\
+ s32DCTY[2]=(SINT32)s32Temp;\
+ s32DCTY[14]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_3_13 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_3_0*(SINT32)s16X[ChOffset+3];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_3_0*(SINT32)s16X[ChOffset+64+13];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_3_1*(SINT32)s16X[ChOffset+16+3];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_1*(SINT32)s16X[ChOffset+48+13];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_3_2*(SINT32)s16X[ChOffset+32+3];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_2*(SINT32)s16X[ChOffset+32+13];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_3_3*(SINT32)s16X[ChOffset+48+3];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_3*(SINT32)s16X[ChOffset+16+13];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_3_4*(SINT32)s16X[ChOffset+64+3];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_3_4*(SINT32)s16X[ChOffset+13];\
+ s32DCTY[3]=(SINT32)s32Temp;\
+ s32DCTY[13]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_4_12 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_4_0*(SINT32)s16X[ChOffset+4];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_4_0*(SINT32)s16X[ChOffset+64+12];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_4_1*(SINT32)s16X[ChOffset+16+4];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_1*(SINT32)s16X[ChOffset+48+12];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_4_2*(SINT32)s16X[ChOffset+32+4];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_2*(SINT32)s16X[ChOffset+32+12];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_4_3*(SINT32)s16X[ChOffset+48+4];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_3*(SINT32)s16X[ChOffset+16+12];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_4_4*(SINT32)s16X[ChOffset+64+4];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_4_4*(SINT32)s16X[ChOffset+12];\
+ s32DCTY[4]=(SINT32)s32Temp;\
+ s32DCTY[12]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_5_11 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_5_0*(SINT32)s16X[ChOffset+5];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_5_0*(SINT32)s16X[ChOffset+64+11];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_5_1*(SINT32)s16X[ChOffset+16+5];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_1*(SINT32)s16X[ChOffset+48+11];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_5_2*(SINT32)s16X[ChOffset+32+5];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_2*(SINT32)s16X[ChOffset+32+11];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_5_3*(SINT32)s16X[ChOffset+48+5];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_3*(SINT32)s16X[ChOffset+16+11];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_5_4*(SINT32)s16X[ChOffset+64+5];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_5_4*(SINT32)s16X[ChOffset+11];\
+ s32DCTY[5]=(SINT32)s32Temp;\
+ s32DCTY[11]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_6_10 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_6_0*(SINT32)s16X[ChOffset+6];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_6_0*(SINT32)s16X[ChOffset+64+10];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_6_1*(SINT32)s16X[ChOffset+16+6];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_1*(SINT32)s16X[ChOffset+48+10];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_6_2*(SINT32)s16X[ChOffset+32+6];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_2*(SINT32)s16X[ChOffset+32+10];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_6_3*(SINT32)s16X[ChOffset+48+6];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_3*(SINT32)s16X[ChOffset+16+10];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_6_4*(SINT32)s16X[ChOffset+64+6];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_6_4*(SINT32)s16X[ChOffset+10];\
+ s32DCTY[6]=(SINT32)s32Temp;\
+ s32DCTY[10]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_7_9 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_7_0*(SINT32)s16X[ChOffset+7];\
+ s32Temp2=(SINT32)WIND_8_SUBBANDS_7_0*(SINT32)s16X[ChOffset+64+9];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_7_1*(SINT32)s16X[ChOffset+16+7];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_1*(SINT32)s16X[ChOffset+48+9];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_7_2*(SINT32)s16X[ChOffset+32+7];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_2*(SINT32)s16X[ChOffset+32+9];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_7_3*(SINT32)s16X[ChOffset+48+7];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_3*(SINT32)s16X[ChOffset+16+9];\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_7_4*(SINT32)s16X[ChOffset+64+7];\
+ s32Temp2+=(SINT32)WIND_8_SUBBANDS_7_4*(SINT32)s16X[ChOffset+9];\
+ s32DCTY[7]=(SINT32)s32Temp;\
+ s32DCTY[9]=(SINT32)s32Temp2;\
+}
+#define WINDOW_ACCU_8_8 \
+{\
+ s32Temp=(SINT32)WIND_8_SUBBANDS_8_0*(SINT32)(s16X[ChOffset+8]+s16X[ChOffset+64+8]);\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_8_1*(SINT32)(s16X[ChOffset+16+8]+s16X[ChOffset+48+8]);\
+ s32Temp+=(SINT32)WIND_8_SUBBANDS_8_2*(SINT32)s16X[ChOffset+32+8];\
+ s32DCTY[8]=(SINT32)s32Temp;\
+}
+#define WINDOW_ACCU_4_0 \
+{\
+ s32Temp=(SINT32)WIND_4_SUBBANDS_0_1*(SINT32)(s16X[ChOffset+8]-s16X[ChOffset+32]);\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_0_2*(SINT32)(s16X[ChOffset+16]-s16X[ChOffset+24]);\
+ s32DCTY[0]=(SINT32)(s32Temp);\
+}
+#define WINDOW_ACCU_4_1_7 \
+{\
+ s32Temp=(SINT32)WIND_4_SUBBANDS_1_0*(SINT32)s16X[ChOffset+1];\
+ s32Temp2=(SINT32)WIND_4_SUBBANDS_1_0*(SINT32)s16X[ChOffset+32+7];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_1_1*(SINT32)s16X[ChOffset+8+1];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_1*(SINT32)s16X[ChOffset+24+7];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_1_2*(SINT32)s16X[ChOffset+16+1];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_2*(SINT32)s16X[ChOffset+16+7];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_1_3*(SINT32)s16X[ChOffset+24+1];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_3*(SINT32)s16X[ChOffset+8+7];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_1_4*(SINT32)s16X[ChOffset+32+1];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_1_4*(SINT32)s16X[ChOffset+7];\
+ s32DCTY[1]=(SINT32)(s32Temp);\
+ s32DCTY[7]=(SINT32)(s32Temp2);\
+}
+#define WINDOW_ACCU_4_2_6 \
+{\
+ s32Temp=(SINT32)WIND_4_SUBBANDS_2_0*(SINT32)s16X[ChOffset+2];\
+ s32Temp2=(SINT32)WIND_4_SUBBANDS_2_0*(SINT32)s16X[ChOffset+32+6];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_2_1*(SINT32)s16X[ChOffset+8+2];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_1*(SINT32)s16X[ChOffset+24+6];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_2_2*(SINT32)s16X[ChOffset+16+2];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_2*(SINT32)s16X[ChOffset+16+6];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_2_3*(SINT32)s16X[ChOffset+24+2];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_3*(SINT32)s16X[ChOffset+8+6];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_2_4*(SINT32)s16X[ChOffset+32+2];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_2_4*(SINT32)s16X[ChOffset+6];\
+ s32DCTY[2]=(SINT32)(s32Temp);\
+ s32DCTY[6]=(SINT32)(s32Temp2);\
+}
+#define WINDOW_ACCU_4_3_5 \
+{\
+ s32Temp=(SINT32)WIND_4_SUBBANDS_3_0*(SINT32)s16X[ChOffset+3];\
+ s32Temp2=(SINT32)WIND_4_SUBBANDS_3_0*(SINT32)s16X[ChOffset+32+5];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_3_1*(SINT32)s16X[ChOffset+8+3];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_1*(SINT32)s16X[ChOffset+24+5];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_3_2*(SINT32)s16X[ChOffset+16+3];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_2*(SINT32)s16X[ChOffset+16+5];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_3_3*(SINT32)s16X[ChOffset+24+3];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_3*(SINT32)s16X[ChOffset+8+5];\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_3_4*(SINT32)s16X[ChOffset+32+3];\
+ s32Temp2+=(SINT32)WIND_4_SUBBANDS_3_4*(SINT32)s16X[ChOffset+5];\
+ s32DCTY[3]=(SINT32)(s32Temp);\
+ s32DCTY[5]=(SINT32)(s32Temp2);\
+}
+
+#define WINDOW_ACCU_4_4 \
+{\
+ s32Temp=(SINT32)WIND_4_SUBBANDS_4_0*(SINT32)(s16X[ChOffset+4]+s16X[ChOffset+4+32]);\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_4_1*(SINT32)(s16X[ChOffset+4+8]+s16X[ChOffset+4+24]);\
+ s32Temp+=(SINT32)WIND_4_SUBBANDS_4_2*(SINT32)s16X[ChOffset+4+16];\
+ s32DCTY[4]=(SINT32)(s32Temp);\
+}
+#endif
+#define WINDOW_PARTIAL_4 \
+{\
+ WINDOW_ACCU_4_0; WINDOW_ACCU_4_1_7;\
+ WINDOW_ACCU_4_2_6; WINDOW_ACCU_4_3_5;\
+ WINDOW_ACCU_4_4;\
+}
+
+#define WINDOW_PARTIAL_8 \
+{\
+ WINDOW_ACCU_8_0; WINDOW_ACCU_8_1_15;\
+ WINDOW_ACCU_8_2_14; WINDOW_ACCU_8_3_13;\
+ WINDOW_ACCU_8_4_12; WINDOW_ACCU_8_5_11;\
+ WINDOW_ACCU_8_6_10; WINDOW_ACCU_8_7_9;\
+ WINDOW_ACCU_8_8;\
+}
+#else
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+#define WINDOW_ACCU_4(i) \
+{\
+ s64Temp=((SINT64)gas32CoeffFor4SBs[i] * (SINT64)s16X[ChOffset+i]); \
+ s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+8)] * (SINT64)s16X[ChOffset+i+8]); \
+ s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+16)] * (SINT64)s16X[ChOffset+i+16]); \
+ s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+24)] * (SINT64)s16X[ChOffset+i+24]); \
+ s64Temp+=((SINT64)gas32CoeffFor4SBs[(i+32)] * (SINT64)s16X[ChOffset+i+32]); \
+ s32DCTY[i]=(SINT32)(s64Temp>>16);\
+ /*printf("s32DCTY4: 0x%x \n", s32DCTY[i]);*/\
+}
+#else
+#define WINDOW_ACCU_4(i) \
+{\
+ s32DCTY[i]=(gas32CoeffFor4SBs[i * 2] * s16X[ChOffset+i]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor4SBs[(i * 2) + 1]) * s16X[ChOffset+i]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor4SBs[(i+8) * 2] * s16X[ChOffset+i+8]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+8) * 2) + 1]) * s16X[ChOffset+i+8]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor4SBs[(i+16) * 2] * s16X[ChOffset+i+16]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+16) * 2) + 1]) * s16X[ChOffset+i+16]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor4SBs[(i+24) * 2] * s16X[ChOffset+i+24]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+24) * 2) + 1]) * s16X[ChOffset+i+24]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor4SBs[(i+32) * 2] * s16X[ChOffset+i+32]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor4SBs[((i+32) * 2) + 1]) * s16X[ChOffset+i+32]) >> 16); \
+}
+#endif
+#define WINDOW_PARTIAL_4 \
+{\
+ WINDOW_ACCU_4(0); WINDOW_ACCU_4(1);\
+ WINDOW_ACCU_4(2); WINDOW_ACCU_4(3);\
+ WINDOW_ACCU_4(4); WINDOW_ACCU_4(5);\
+ WINDOW_ACCU_4(6); WINDOW_ACCU_4(7);\
+}
+
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+#define WINDOW_ACCU_8(i) \
+{\
+ s64Temp = ((((SINT64)gas32CoeffFor8SBs[i] * (SINT64)s16X[ChOffset+i] ))); \
+ s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+16)] * (SINT64)s16X[ChOffset+i+16]))); \
+ s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+32)] * (SINT64)s16X[ChOffset+i+32]))); \
+ s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+48)] * (SINT64)s16X[ChOffset+i+48]))); \
+ s64Temp+= ((((SINT64)gas32CoeffFor8SBs[(i+64)] * (SINT64)s16X[ChOffset+i+64]))); \
+ /*printf("s32DCTY8: %d= 0x%x * %d\n", s32DCTY[i], gas32CoeffFor8SBs[i], s16X[ChOffset+i]);*/ \
+ s32DCTY[i]=(SINT32)(s64Temp>>16);\
+}
+#else
+#define WINDOW_ACCU_8(i) \
+{\
+ s32DCTY[i]=(gas32CoeffFor8SBs[i * 2] * s16X[ChOffset+i]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor8SBs[(i * 2) + 1]) * s16X[ChOffset+i]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor8SBs[(i+16) * 2] * s16X[ChOffset+i+16]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+16) * 2) + 1]) * s16X[ChOffset+i+16]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor8SBs[(i+32) * 2] * s16X[ChOffset+i+32]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+32) * 2) + 1]) * s16X[ChOffset+i+32]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor8SBs[(i+48) * 2] * s16X[ChOffset+i+48]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+48) * 2) + 1]) * s16X[ChOffset+i+48]) >> 16); \
+ s32DCTY[i]+=(gas32CoeffFor8SBs[(i+64) * 2] * s16X[ChOffset+i+64]) \
+ + (((SINT32)(UINT16)(gas32CoeffFor8SBs[((i+64) * 2) + 1]) * s16X[ChOffset+i+64]) >> 16); \
+ /*printf("s32DCTY8: %d = 0x%4x%4x * %d\n", s32DCTY[i], gas32CoeffFor8SBs[i * 2], (gas32CoeffFor8SBs[(i * 2) + 1]), s16X[ChOffset+i]);*/\
+ /*s32DCTY[i]=(SINT32)(s64Temp>>16);*/\
+}
+#endif
+#define WINDOW_PARTIAL_8 \
+{\
+ WINDOW_ACCU_8(0); WINDOW_ACCU_8(1);\
+ WINDOW_ACCU_8(2); WINDOW_ACCU_8(3);\
+ WINDOW_ACCU_8(4); WINDOW_ACCU_8(5);\
+ WINDOW_ACCU_8(6); WINDOW_ACCU_8(7);\
+ WINDOW_ACCU_8(8); WINDOW_ACCU_8(9);\
+ WINDOW_ACCU_8(10); WINDOW_ACCU_8(11);\
+ WINDOW_ACCU_8(12); WINDOW_ACCU_8(13);\
+ WINDOW_ACCU_8(14); WINDOW_ACCU_8(15);\
+}
+#endif
+#endif
+
+static SINT16 ShiftCounter=0;
+extern SINT16 EncMaxShiftCounter;
+/****************************************************************************
+* SbcAnalysisFilter - performs Analysis of the input audio stream
+*
+* RETURNS : N/A
+*/
+void SbcAnalysisFilter4(SBC_ENC_PARAMS *pstrEncParams)
+{
+ SINT16 *ps16PcmBuf;
+ SINT32 *ps32SbBuf;
+ SINT32 s32Blk,s32Ch;
+ SINT32 s32NumOfChannels, s32NumOfBlocks;
+ SINT32 i,*ps32X,*ps32X2;
+ SINT32 Offset,Offset2,ChOffset;
+#if (SBC_ARM_ASM_OPT==TRUE)
+ register SINT32 s32Hi,s32Hi2;
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+ register SINT64 s64Temp,s64Temp2;
+#else
+ register SINT32 s32Temp,s32Temp2;
+#endif
+#else
+
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+ SINT64 s64Temp;
+#endif
+
+#endif
+#endif
+
+ s32NumOfChannels = pstrEncParams->s16NumOfChannels;
+ s32NumOfBlocks = pstrEncParams->s16NumOfBlocks;
+
+ ps16PcmBuf = pstrEncParams->ps16NextPcmBuffer;
+
+ ps32SbBuf = pstrEncParams->s32SbBuffer;
+ Offset2=(SINT32)(EncMaxShiftCounter+40);
+ for (s32Blk=0; s32Blk <s32NumOfBlocks; s32Blk++)
+ {
+ Offset=(SINT32)(EncMaxShiftCounter-ShiftCounter);
+ /* Store new samples */
+ if (s32NumOfChannels==1)
+ {
+ s16X[3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ }
+ else
+ {
+ s16X[3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ }
+ for (s32Ch=0;s32Ch<s32NumOfChannels;s32Ch++)
+ {
+ ChOffset=s32Ch*Offset2+Offset;
+
+ WINDOW_PARTIAL_4
+
+ SBC_FastIDCT4(s32DCTY, ps32SbBuf);
+
+ ps32SbBuf +=SUB_BANDS_4;
+ }
+ if (s32NumOfChannels==1)
+ {
+ if (ShiftCounter>=EncMaxShiftCounter)
+ {
+ SHIFTUP_X4;
+ ShiftCounter=0;
+ }
+ else
+ {
+ ShiftCounter+=SUB_BANDS_4;
+ }
+ }
+ else
+ {
+ if (ShiftCounter>=EncMaxShiftCounter)
+ {
+ SHIFTUP_X4_2;
+ ShiftCounter=0;
+ }
+ else
+ {
+ ShiftCounter+=SUB_BANDS_4;
+ }
+ }
+ }
+}
+
+/* //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */
+void SbcAnalysisFilter8 (SBC_ENC_PARAMS *pstrEncParams)
+{
+ SINT16 *ps16PcmBuf;
+ SINT32 *ps32SbBuf;
+ SINT32 s32Blk,s32Ch; /* counter for block*/
+ SINT32 Offset,Offset2;
+ SINT32 s32NumOfChannels, s32NumOfBlocks;
+ SINT32 i,*ps32X,*ps32X2;
+ SINT32 ChOffset;
+#if (SBC_ARM_ASM_OPT==TRUE)
+ register SINT32 s32Hi,s32Hi2;
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+ register SINT64 s64Temp,s64Temp2;
+#else
+ register SINT32 s32Temp,s32Temp2;
+#endif
+#else
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == TRUE)
+ SINT64 s64Temp;
+#endif
+#endif
+#endif
+
+ s32NumOfChannels = pstrEncParams->s16NumOfChannels;
+ s32NumOfBlocks = pstrEncParams->s16NumOfBlocks;
+
+ ps16PcmBuf = pstrEncParams->ps16NextPcmBuffer;
+
+ ps32SbBuf = pstrEncParams->s32SbBuffer;
+ Offset2=(SINT32)(EncMaxShiftCounter+80);
+ for (s32Blk=0; s32Blk <s32NumOfBlocks; s32Blk++)
+ {
+ Offset=(SINT32)(EncMaxShiftCounter-ShiftCounter);
+ /* Store new samples */
+ if (s32NumOfChannels==1)
+ {
+ s16X[7+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[6+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[5+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[4+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ }
+ else
+ {
+ s16X[7+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+7+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[6+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+6+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[5+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+5+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[4+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+4+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+3+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+2+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+1+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ s16X[Offset2+0+Offset] = *ps16PcmBuf; ps16PcmBuf++;
+ }
+ for (s32Ch=0;s32Ch<s32NumOfChannels;s32Ch++)
+ {
+ ChOffset=s32Ch*Offset2+Offset;
+
+ WINDOW_PARTIAL_8
+
+ SBC_FastIDCT8 (s32DCTY, ps32SbBuf);
+
+ ps32SbBuf +=SUB_BANDS_8;
+ }
+ if (s32NumOfChannels==1)
+ {
+ if (ShiftCounter>=EncMaxShiftCounter)
+ {
+ SHIFTUP_X8;
+ ShiftCounter=0;
+ }
+ else
+ {
+ ShiftCounter+=SUB_BANDS_8;
+ }
+ }
+ else
+ {
+ if (ShiftCounter>=EncMaxShiftCounter)
+ {
+ SHIFTUP_X8_2;
+ ShiftCounter=0;
+ }
+ else
+ {
+ ShiftCounter+=SUB_BANDS_8;
+ }
+ }
+ }
+}
+
+void SbcAnalysisInit (void)
+{
+ memset(s16X,0,ENC_VX_BUFFER_SIZE*sizeof(SINT16));
+ ShiftCounter=0;
+}
diff --git a/embdrv/sbc/encoder/srce/sbc_dct.c b/embdrv/sbc/encoder/srce/sbc_dct.c
new file mode 100644
index 0000000..0ff7f1f
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_dct.c
@@ -0,0 +1,234 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_dct.c,v $
+**
+** Description: source file for fast dct operations
+**
+** Revision : $Id: sbc_dct.c,v 1.19 2006/04/13 17:01:04 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+#include "sbc_dct.h"
+
+
+
+/*******************************************************************************
+**
+** Function SBC_FastIDCT8
+**
+** Description implementation of fast DCT algorithm by Feig and Winograd
+**
+**
+** Returns y = dct(pInVect)
+**
+**
+*******************************************************************************/
+
+#if (SBC_IS_64_MULT_IN_IDCT == FALSE)
+#define SBC_COS_PI_SUR_4 (0x00005a82) /* ((0x8000) * 0.7071) = cos(pi/4) */
+#define SBC_COS_PI_SUR_8 (0x00007641) /* ((0x8000) * 0.9239) = (cos(pi/8)) */
+#define SBC_COS_3PI_SUR_8 (0x000030fb) /* ((0x8000) * 0.3827) = (cos(3*pi/8)) */
+#define SBC_COS_PI_SUR_16 (0x00007d8a) /* ((0x8000) * 0.9808)) = (cos(pi/16)) */
+#define SBC_COS_3PI_SUR_16 (0x00006a6d) /* ((0x8000) * 0.8315)) = (cos(3*pi/16)) */
+#define SBC_COS_5PI_SUR_16 (0x0000471c) /* ((0x8000) * 0.5556)) = (cos(5*pi/16)) */
+#define SBC_COS_7PI_SUR_16 (0x000018f8) /* ((0x8000) * 0.1951)) = (cos(7*pi/16)) */
+#define SBC_IDCT_MULT(a,b,c) SBC_MULT_32_16_SIMPLIFIED(a,b,c)
+#else
+#define SBC_COS_PI_SUR_4 (0x5A827999) /* ((0x80000000) * 0.707106781) = (cos(pi/4) ) */
+#define SBC_COS_PI_SUR_8 (0x7641AF3C) /* ((0x80000000) * 0.923879533) = (cos(pi/8) ) */
+#define SBC_COS_3PI_SUR_8 (0x30FBC54D) /* ((0x80000000) * 0.382683432) = (cos(3*pi/8) ) */
+#define SBC_COS_PI_SUR_16 (0x7D8A5F3F) /* ((0x80000000) * 0.98078528 )) = (cos(pi/16) ) */
+#define SBC_COS_3PI_SUR_16 (0x6A6D98A4) /* ((0x80000000) * 0.831469612)) = (cos(3*pi/16)) */
+#define SBC_COS_5PI_SUR_16 (0x471CECE6) /* ((0x80000000) * 0.555570233)) = (cos(5*pi/16)) */
+#define SBC_COS_7PI_SUR_16 (0x18F8B83C) /* ((0x80000000) * 0.195090322)) = (cos(7*pi/16)) */
+#define SBC_IDCT_MULT(a,b,c) SBC_MULT_32_32(a,b,c)
+#endif /* SBC_IS_64_MULT_IN_IDCT */
+
+#if (SBC_FAST_DCT == FALSE)
+extern const SINT16 gas16AnalDCTcoeff8[];
+extern const SINT16 gas16AnalDCTcoeff4[];
+#endif
+
+void SBC_FastIDCT8(SINT32 *pInVect, SINT32 *pOutVect)
+{
+#if (SBC_FAST_DCT == TRUE)
+#if (SBC_ARM_ASM_OPT==TRUE)
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+ SINT64 s64Temp;
+#endif
+#else
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+ SINT32 s32HiTemp;
+#else
+ SINT32 s32In2Temp;
+ register SINT32 s32In1Temp;
+#endif
+#endif
+#endif
+
+ register SINT32 x0, x1, x2, x3, x4, x5, x6, x7,temp;
+ SINT32 res_even[4], res_odd[4];
+ /*x0= (pInVect[4])/2 ;*/
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4,pInVect[4], x0);
+ /*printf("x0 0x%x = %d = %d * %d\n", x0, x0, SBC_COS_PI_SUR_4, pInVect[4]);*/
+
+ x1 = (pInVect[3] + pInVect[5]) >>1;
+ x2 = (pInVect[2] + pInVect[6]) >>1;
+ x3 = (pInVect[1] + pInVect[7]) >>1;
+ x4 = (pInVect[0] + pInVect[8]) >>1;
+ x5 = (pInVect[9] - pInVect[15]) >>1;
+ x6 = (pInVect[10] - pInVect[14])>>1;
+ x7 = (pInVect[11] - pInVect[13])>>1;
+
+ /* 2-point IDCT of x0 and x4 as in (11) */
+ temp = x0 ;
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4, ( x0 + x4 ), x0); /*x0 = ( x0 + x4 ) * cos(1*pi/4) ; */
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4, ( temp - x4 ), x4); /*x4 = ( temp - x4 ) * cos(1*pi/4) ; */
+
+ /* rearrangement of x2 and x6 as in (15) */
+ x2 -=x6;
+ x6 <<= 1 ;
+
+ /* 2-point IDCT of x2 and x6 and post-multiplication as in (15) */
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4,x6, x6); /*x6 = x6 * cos(1*pi/4) ; */
+ temp = x2 ;
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_8,( x2 + x6 ), x2); /*x2 = ( x2 + x6 ) * cos(1*pi/8) ; */
+ SBC_IDCT_MULT(SBC_COS_3PI_SUR_8,( temp - x6 ), x6); /*x6 = ( temp - x6 ) * cos(3*pi/8) ;*/
+
+ /* 4-point IDCT of x0,x2,x4 and x6 as in (11) */
+ res_even[ 0 ] = x0 + x2 ;
+ res_even[ 1 ] = x4 + x6 ;
+ res_even[ 2 ] = x4 - x6 ;
+ res_even[ 3 ] = x0 - x2 ;
+
+
+ /* rearrangement of x1,x3,x5,x7 as in (15) */
+ x7 <<= 1 ;
+ x5 = ( x5 <<1 ) - x7 ;
+ x3 = ( x3 <<1 ) - x5 ;
+ x1 -= x3 >>1 ;
+
+ /* two-dimensional IDCT of x1 and x5 */
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4, x5, x5); /*x5 = x5 * cos(1*pi/4) ; */
+ temp = x1 ;
+ x1 = x1 + x5 ;
+ x5 = temp - x5 ;
+
+ /* rearrangement of x3 and x7 as in (15) */
+ x3 -= x7;
+ x7 <<= 1 ;
+ SBC_IDCT_MULT(SBC_COS_PI_SUR_4, x7, x7); /*x7 = x7 * cos(1*pi/4) ; */
+
+ /* 2-point IDCT of x3 and x7 and post-multiplication as in (15) */
+ temp = x3 ;
+ SBC_IDCT_MULT( SBC_COS_PI_SUR_8,( x3 + x7 ), x3); /*x3 = ( x3 + x7 ) * cos(1*pi/8) ; */
+ SBC_IDCT_MULT( SBC_COS_3PI_SUR_8,( temp - x7 ), x7); /*x7 = ( temp - x7 ) * cos(3*pi/8) ;*/
+
+ /* 4-point IDCT of x1,x3,x5 and x7 and post multiplication by diagonal matrix as in (14) */
+ SBC_IDCT_MULT((SBC_COS_PI_SUR_16), ( x1 + x3 ) , res_odd[0]); /*res_odd[ 0 ] = ( x1 + x3 ) * cos(1*pi/16) ; */
+ SBC_IDCT_MULT((SBC_COS_3PI_SUR_16), ( x5 + x7 ) , res_odd[1]); /*res_odd[ 1 ] = ( x5 + x7 ) * cos(3*pi/16) ; */
+ SBC_IDCT_MULT((SBC_COS_5PI_SUR_16), ( x5 - x7 ) , res_odd[2]); /*res_odd[ 2 ] = ( x5 - x7 ) * cos(5*pi/16) ; */
+ SBC_IDCT_MULT((SBC_COS_7PI_SUR_16), ( x1 - x3 ) , res_odd[3]); /*res_odd[ 3 ] = ( x1 - x3 ) * cos(7*pi/16) ; */
+
+ /* additions and subtractions as in (9) */
+ pOutVect[0] = (res_even[ 0 ] + res_odd[ 0 ]) ;
+ pOutVect[1] = (res_even[ 1 ] + res_odd[ 1 ]) ;
+ pOutVect[2] = (res_even[ 2 ] + res_odd[ 2 ]) ;
+ pOutVect[3] = (res_even[ 3 ] + res_odd[ 3 ]) ;
+ pOutVect[7] = (res_even[ 0 ] - res_odd[ 0 ]) ;
+ pOutVect[6] = (res_even[ 1 ] - res_odd[ 1 ]) ;
+ pOutVect[5] = (res_even[ 2 ] - res_odd[ 2 ]) ;
+ pOutVect[4] = (res_even[ 3 ] - res_odd[ 3 ]) ;
+#else
+ UINT8 Index, k;
+ SINT32 temp;
+ /*Calculate 4 subband samples by matrixing*/
+ for(Index=0; Index<8; Index++)
+ {
+ temp = 0;
+ for(k=0; k<16; k++)
+ {
+ /*temp += (SINT32)(((SINT64)M[(Index*strEncParams->numOfSubBands*2)+k] * Y[k]) >> 16 );*/
+ temp += (gas16AnalDCTcoeff8[(Index*8*2)+k] * (pInVect[k] >> 16));
+ temp += ((gas16AnalDCTcoeff8[(Index*8*2)+k] * (pInVect[k] & 0xFFFF)) >> 16);
+ }
+ pOutVect[Index] = temp;
+ }
+#endif
+/* printf("pOutVect: 0x%x;0x%x;0x%x;0x%x;0x%x;0x%x;0x%x;0x%x\n",\
+ pOutVect[0],pOutVect[1],pOutVect[2],pOutVect[3],pOutVect[4],pOutVect[5],pOutVect[6],pOutVect[7]);*/
+}
+
+/*******************************************************************************
+**
+** Function SBC_FastIDCT4
+**
+** Description implementation of fast DCT algorithm by Feig and Winograd
+**
+**
+** Returns y = dct(x0)
+**
+**
+*******************************************************************************/
+void SBC_FastIDCT4(SINT32 *pInVect, SINT32 *pOutVect)
+{
+#if (SBC_FAST_DCT == TRUE)
+#if (SBC_ARM_ASM_OPT==TRUE)
+#else
+#if (SBC_IPAQ_OPT==TRUE)
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+ SINT64 s64Temp;
+#endif
+#else
+#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
+ SINT32 s32HiTemp;
+#else
+ UINT16 s32In2Temp;
+ SINT32 s32In1Temp;
+#endif
+#endif
+#endif
+ SINT32 temp,x2;
+ SINT32 tmp[8];
+
+ x2=pInVect[2]>>1;
+ temp=(pInVect[0]+pInVect[4]);
+ SBC_IDCT_MULT((SBC_COS_PI_SUR_4>>1), temp , tmp[0]);
+ tmp[1]=x2-tmp[0];
+ tmp[0]+=x2;
+ temp=(pInVect[1]+pInVect[3]);
+ SBC_IDCT_MULT((SBC_COS_3PI_SUR_8>>1), temp , tmp[3]);
+ SBC_IDCT_MULT((SBC_COS_PI_SUR_8>>1), temp , tmp[2]);
+ temp=(pInVect[5]-pInVect[7]);
+ SBC_IDCT_MULT((SBC_COS_3PI_SUR_8>>1), temp , tmp[5]);
+ SBC_IDCT_MULT((SBC_COS_PI_SUR_8>>1), temp , tmp[4]);
+ tmp[6]=tmp[2]+tmp[5];
+ tmp[7]=tmp[3]-tmp[4];
+ pOutVect[0] = (tmp[0]+tmp[6]);
+ pOutVect[1] = (tmp[1]+tmp[7]);
+ pOutVect[2] = (tmp[1]-tmp[7]);
+ pOutVect[3] = (tmp[0]-tmp[6]);
+#else
+ UINT8 Index, k;
+ SINT32 temp;
+ /*Calculate 4 subband samples by matrixing*/
+ for(Index=0; Index<4; Index++)
+ {
+ temp = 0;
+ for(k=0; k<8; k++)
+ {
+ /*temp += (SINT32)(((SINT64)M[(Index*strEncParams->numOfSubBands*2)+k] * Y[k]) >> 16 ); */
+ temp += (gas16AnalDCTcoeff4[(Index*4*2)+k] * (pInVect[k] >> 16));
+ temp += ((gas16AnalDCTcoeff4[(Index*4*2)+k] * (pInVect[k] & 0xFFFF)) >> 16);
+ }
+ pOutVect[Index] = temp;
+ }
+#endif
+}
diff --git a/embdrv/sbc/encoder/srce/sbc_dct_coeffs.c b/embdrv/sbc/encoder/srce/sbc_dct_coeffs.c
new file mode 100644
index 0000000..03f632f
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_dct_coeffs.c
@@ -0,0 +1,189 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_dct_coeffs.c,v $
+**
+** Description: This file contains the coefficient table used for DCT computation
+** in analysis.
+**
+** Revision : $Id: sbc_dct_coeffs.c,v 1.5 2006/04/13 17:01:16 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#include "sbc_encoder.h"
+/*DCT coeff for 4 sub-band case.*/
+#if (SBC_FAST_DCT == FALSE)
+const SINT16 gas16AnalDCTcoeff4[] =
+{
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(0.0000*32768),
+ (SINT16)(-0.3827*32768),
+
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.3827*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.9239*32768),
+
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.0000*32768),
+ (SINT16)(-0.9239*32768),
+
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.3827*32768)
+};
+
+/*DCT coeff for 8 sub-band case.*/
+const SINT16 gas16AnalDCTcoeff8[] =
+{
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.9808*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(0.0000*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.8315*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.5556*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(0.0000*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(0.1951*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(0.0000*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.8315*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(-0.7071*32768),
+ (SINT16)(0.9808*32768),
+ (SINT16)(-0.9239*32768),
+ (SINT16)(0.5556*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(1.0000*32767),
+ (SINT16)(-0.9808*32768),
+ (SINT16)(0.9239*32768),
+ (SINT16)(-0.8315*32768),
+ (SINT16)(0.7071*32768),
+ (SINT16)(-0.5556*32768),
+ (SINT16)(0.3827*32768),
+ (SINT16)(-0.1951*32768),
+ (SINT16)(-0.0000*32768),
+ (SINT16)(0.1951*32768),
+ (SINT16)(-0.3827*32768),
+ (SINT16)(0.5556*32768)
+};
+#endif
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c
new file mode 100644
index 0000000..c8b13a9
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c
@@ -0,0 +1,188 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_enc_bit_alloc_mono.c,v $
+**
+** Description: This file contains the code for bit allocation algorithm.
+** It calculates the number of bits required for the encoded stream of data.
+**
+** Revision : $Id: sbc_enc_bit_alloc_mono.c,v 1.9 2006/03/31 17:16:35 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+/*Includes*/
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+
+/*global arrays*/
+const SINT16 sbc_enc_as16Offset4[4][4] = { {-1, 0, 0, 0}, {-2, 0, 0, 1},
+ {-2, 0, 0, 1}, {-2, 0, 0, 1} };
+const SINT16 sbc_enc_as16Offset8[4][8] = { {-2, 0, 0, 0, 0, 0, 0, 1},
+ {-3, 0, 0, 0, 0, 0, 1, 2},
+ {-4, 0, 0, 0, 0, 0, 1, 2},
+ {-4, 0, 0, 0, 0, 0, 1, 2} };
+
+/****************************************************************************
+* BitAlloc - Calculates the required number of bits for the given scale factor
+* and the number of subbands.
+*
+* RETURNS : N/A
+*/
+
+void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
+{
+ SINT32 s32MaxBitNeed; /*to store the max bits needed per sb*/
+ SINT32 s32BitCount; /*the used number of bits*/
+ SINT32 s32SliceCount; /*to store hwo many slices can be put in bitpool*/
+ SINT32 s32BitSlice; /*number of bitslices in bitpool*/
+ SINT32 s32Sb; /*counter for sub-band*/
+ SINT32 s32Ch; /*counter for channel*/
+ SINT16 *ps16BitNeed; /*temp memory to store required number of bits*/
+ SINT32 s32Loudness; /*used in Loudness calculation*/
+ SINT16 *ps16GenBufPtr;
+ SINT16 *ps16GenArrPtr;
+ SINT16 *ps16GenTabPtr;
+ SINT32 s32NumOfSubBands = pstrCodecParams->s16NumOfSubBands;
+
+ ps16BitNeed = pstrCodecParams->s16ScartchMemForBitAlloc;
+
+ for (s32Ch = 0; s32Ch < pstrCodecParams->s16NumOfChannels; s32Ch++)
+ {
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Ch*SBC_MAX_NUM_OF_SUBBANDS;
+
+ /* bitneed values are derived from scale factor */
+ if (pstrCodecParams->s16AllocationMethod == SBC_SNR)
+ {
+ ps16BitNeed = pstrCodecParams->as16ScaleFactor;
+ ps16GenBufPtr = ps16BitNeed + s32Ch * s32NumOfSubBands;
+ }
+ else
+ {
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ if(s32NumOfSubBands == 4)
+ {
+ ps16GenTabPtr = (SINT16 *)
+ sbc_enc_as16Offset4[pstrCodecParams->s16SamplingFreq];
+ }
+ else
+ {
+ ps16GenTabPtr = (SINT16 *)
+ sbc_enc_as16Offset8[pstrCodecParams->s16SamplingFreq];
+ }
+ for(s32Sb=0; s32Sb<s32NumOfSubBands; s32Sb++)
+ {
+ if(pstrCodecParams->as16ScaleFactor[s32Ch*s32NumOfSubBands+s32Sb] == 0)
+ *(ps16GenBufPtr) = -5;
+ else
+ {
+ s32Loudness =
+ (SINT32)(pstrCodecParams->as16ScaleFactor[s32Ch*s32NumOfSubBands+s32Sb]
+ - *ps16GenTabPtr);
+ if(s32Loudness > 0)
+ *(ps16GenBufPtr) = (SINT16)(s32Loudness >>1);
+ else
+ *(ps16GenBufPtr) = (SINT16)s32Loudness;
+ }
+ ps16GenBufPtr++;
+ ps16GenTabPtr++;
+ }
+
+ }
+
+ /* max bitneed index is searched*/
+ s32MaxBitNeed = 0;
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ for(s32Sb=0; s32Sb<s32NumOfSubBands; s32Sb++)
+ {
+ if( *(ps16GenBufPtr) > s32MaxBitNeed)
+ s32MaxBitNeed = *(ps16GenBufPtr);
+
+ ps16GenBufPtr++;
+ }
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ /*iterative process to find hwo many bitslices fit into the bitpool*/
+ s32BitSlice = s32MaxBitNeed + 1;
+ s32BitCount = pstrCodecParams->s16BitPool;
+ s32SliceCount = 0;
+ do
+ {
+ s32BitSlice --;
+ s32BitCount -= s32SliceCount;
+ s32SliceCount = 0;
+
+ for(s32Sb=0; s32Sb<s32NumOfSubBands; s32Sb++)
+ {
+ if( (((*ps16GenBufPtr-s32BitSlice)< 16) && (*ps16GenBufPtr-s32BitSlice) >= 1))
+ {
+ if((*ps16GenBufPtr-s32BitSlice) == 1)
+ s32SliceCount+=2;
+ else
+ s32SliceCount++;
+ }
+ ps16GenBufPtr++;
+
+ }/*end of for*/
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ }while(s32BitCount-s32SliceCount>0);
+
+ if(s32BitCount == 0)
+ {
+ s32BitCount -= s32SliceCount;
+ s32BitSlice --;
+ }
+
+ /*Bits are distributed until the last bitslice is reached*/
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Ch*s32NumOfSubBands;
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ for(s32Sb=0; s32Sb<s32NumOfSubBands; s32Sb++)
+ {
+ if(*(ps16GenBufPtr) < s32BitSlice+2)
+ *(ps16GenArrPtr) = 0;
+ else
+ *(ps16GenArrPtr) = ((*(ps16GenBufPtr)-s32BitSlice)<16) ?
+ (SINT16)(*(ps16GenBufPtr)-s32BitSlice) : 16;
+
+ ps16GenBufPtr++;
+ ps16GenArrPtr++;
+ }
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Ch*s32NumOfSubBands;
+ ps16GenBufPtr = ps16BitNeed + s32Ch*s32NumOfSubBands;
+ /*the remaining bits are allocated starting at subband 0*/
+ s32Sb=0;
+ while( (s32BitCount > 0) && (s32Sb < s32NumOfSubBands) )
+ {
+ if( (*(ps16GenArrPtr) >= 2) && (*(ps16GenArrPtr) < 16) )
+ {
+ (*(ps16GenArrPtr))++;
+ s32BitCount--;
+ }
+ else if( (*(ps16GenBufPtr) == s32BitSlice+1) &&
+ (s32BitCount > 1) )
+ {
+ *(ps16GenArrPtr) = 2;
+ s32BitCount -= 2;
+ }
+ s32Sb++;
+ ps16GenArrPtr++;
+ ps16GenBufPtr++;
+ }
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Ch*s32NumOfSubBands;
+
+
+ s32Sb=0;
+ while( (s32BitCount > 0) && (s32Sb < s32NumOfSubBands) )
+ {
+ if( *(ps16GenArrPtr) < 16)
+ {
+ (*(ps16GenArrPtr))++;
+ s32BitCount--;
+ }
+ s32Sb++;
+ ps16GenArrPtr++;
+ }
+ }
+}
+/*End of BitAlloc() function*/
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c
new file mode 100644
index 0000000..cbcb809
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c
@@ -0,0 +1,201 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_enc_bit_alloc_ste.c,v $
+**
+** Description: This file contains the code for bit allocation algorithm.
+** It calculates the number of bits required for the encoded stream of data.
+**
+** Revision : $Id: sbc_enc_bit_alloc_ste.c,v 1.9 2006/03/31 17:17:07 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+/*Includes*/
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+
+/*global arrays*/
+extern const SINT16 sbc_enc_as16Offset4[4][4];
+extern const SINT16 sbc_enc_as16Offset8[4][8];
+
+/****************************************************************************
+* BitAlloc - Calculates the required number of bits for the given scale factor
+* and the number of subbands.
+*
+* RETURNS : N/A
+*/
+
+void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
+{
+ /* CAUTIOM -> mips optim for arm 32 require to use SINT32 instead of SINT16 */
+ /* Do not change variable type or name */
+ SINT32 s32MaxBitNeed; /*to store the max bits needed per sb*/
+ SINT32 s32BitCount; /*the used number of bits*/
+ SINT32 s32SliceCount; /*to store hwo many slices can be put in bitpool*/
+ SINT32 s32BitSlice; /*number of bitslices in bitpool*/
+ SINT32 s32Sb; /*counter for sub-band*/
+ SINT32 s32Ch; /*counter for channel*/
+ SINT16 *ps16BitNeed; /*temp memory to store required number of bits*/
+ SINT32 s32Loudness; /*used in Loudness calculation*/
+ SINT16 *ps16GenBufPtr,*pas16ScaleFactor;
+ SINT16 *ps16GenArrPtr;
+ SINT16 *ps16GenTabPtr;
+ SINT32 s32NumOfSubBands = pstrCodecParams->s16NumOfSubBands;
+ SINT32 s32BitPool = pstrCodecParams->s16BitPool;
+
+ /* bitneed values are derived from scale factor */
+ if (pstrCodecParams->s16AllocationMethod == SBC_SNR)
+ {
+ ps16BitNeed = pstrCodecParams->as16ScaleFactor;
+ s32MaxBitNeed = pstrCodecParams->s16MaxBitNeed;
+ }
+ else
+ {
+ ps16BitNeed = pstrCodecParams->s16ScartchMemForBitAlloc;
+ pas16ScaleFactor=pstrCodecParams->as16ScaleFactor;
+ s32MaxBitNeed = 0;
+ ps16GenBufPtr = ps16BitNeed;
+ for (s32Ch = 0; s32Ch < 2; s32Ch++)
+ {
+ if (s32NumOfSubBands == 4)
+ {
+ ps16GenTabPtr = (SINT16 *)sbc_enc_as16Offset4[pstrCodecParams->s16SamplingFreq];
+ }
+ else
+ {
+ ps16GenTabPtr = (SINT16 *)sbc_enc_as16Offset8[pstrCodecParams->s16SamplingFreq];
+ }
+
+ for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++)
+ {
+ if (*pas16ScaleFactor == 0)
+ *ps16GenBufPtr = -5;
+ else
+ {
+ s32Loudness = (SINT32)(*pas16ScaleFactor - *ps16GenTabPtr);
+
+ if (s32Loudness > 0)
+ *ps16GenBufPtr = (SINT16)(s32Loudness >> 1);
+ else
+ *ps16GenBufPtr = (SINT16)s32Loudness;
+ }
+
+ if (*ps16GenBufPtr > s32MaxBitNeed)
+ s32MaxBitNeed = *ps16GenBufPtr;
+ pas16ScaleFactor++;
+ ps16GenBufPtr++;
+ ps16GenTabPtr++;
+ }
+ }
+ }
+
+ /* iterative process to find out hwo many bitslices fit into the bitpool */
+ s32BitSlice = s32MaxBitNeed + 1;
+ s32BitCount = s32BitPool;
+ s32SliceCount = 0;
+ do
+ {
+ s32BitSlice --;
+ s32BitCount -= s32SliceCount;
+ s32SliceCount = 0;
+ ps16GenBufPtr = ps16BitNeed;
+
+ for (s32Sb = 0; s32Sb < 2*s32NumOfSubBands; s32Sb++)
+ {
+ if ( (*ps16GenBufPtr >= s32BitSlice + 1) && (*ps16GenBufPtr < s32BitSlice + 16) )
+ {
+ if (*(ps16GenBufPtr) == s32BitSlice+1)
+ s32SliceCount += 2;
+ else
+ s32SliceCount++;
+ }
+ ps16GenBufPtr++;
+ }
+ } while (s32BitCount-s32SliceCount>0);
+
+ if (s32BitCount-s32SliceCount == 0)
+ {
+ s32BitCount -= s32SliceCount;
+ s32BitSlice --;
+ }
+
+ /* Bits are distributed until the last bitslice is reached */
+ ps16GenBufPtr = ps16BitNeed;
+ ps16GenArrPtr = pstrCodecParams->as16Bits;
+ for (s32Ch = 0; s32Ch < 2; s32Ch++)
+ {
+ for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++)
+ {
+ if (*ps16GenBufPtr < s32BitSlice+2)
+ *ps16GenArrPtr = 0;
+ else
+ *ps16GenArrPtr = ((*(ps16GenBufPtr)-s32BitSlice) < 16) ?
+ (SINT16)(*(ps16GenBufPtr)-s32BitSlice):16;
+ ps16GenBufPtr++;
+ ps16GenArrPtr++;
+ }
+ }
+
+ /* the remaining bits are allocated starting at subband 0 */
+ s32Ch=0;
+ s32Sb=0;
+ ps16GenBufPtr = ps16BitNeed;
+ ps16GenArrPtr -= 2*s32NumOfSubBands;
+
+ while ( (s32BitCount > 0) && (s32Sb < s32NumOfSubBands) )
+ {
+ if ( (*(ps16GenArrPtr) >= 2) && (*(ps16GenArrPtr) < 16) )
+ {
+ (*(ps16GenArrPtr))++;
+ s32BitCount--;
+ }
+ else if ((*ps16GenBufPtr == s32BitSlice+1) && (s32BitCount > 1))
+ {
+ *(ps16GenArrPtr) = 2;
+ s32BitCount -= 2;
+ }
+ if(s32Ch == 1)
+ {
+ s32Ch = 0;
+ s32Sb++;
+ ps16GenBufPtr = ps16BitNeed+s32Sb;
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Sb;
+
+ }
+ else
+ {
+ s32Ch =1;
+ ps16GenBufPtr = ps16BitNeed+s32NumOfSubBands+s32Sb;
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32NumOfSubBands+s32Sb;
+ }
+ }
+
+ s32Ch=0;
+ s32Sb=0;
+ ps16GenArrPtr = pstrCodecParams->as16Bits;
+
+ while ((s32BitCount >0) && (s32Sb < s32NumOfSubBands))
+ {
+ if(*(ps16GenArrPtr) < 16)
+ {
+ (*(ps16GenArrPtr))++;
+ s32BitCount--;
+ }
+ if (s32Ch == 1)
+ {
+ s32Ch = 0;
+ s32Sb++;
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32Sb;
+ }
+ else
+ {
+ s32Ch = 1;
+ ps16GenArrPtr = pstrCodecParams->as16Bits+s32NumOfSubBands+s32Sb;
+ }
+ }
+}
+
+/*End of BitAlloc() function*/
+
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c b/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c
new file mode 100644
index 0000000..48cc22f
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c
@@ -0,0 +1,308 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_enc_coeffs.c,v $
+**
+** Description: This file contains the Windowing coeffs for synthesis filter
+**
+** Revision : $Id: sbc_enc_coeffs.c,v 1.10 2006/04/11 17:05:34 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#include "sbc_encoder.h"
+
+#if (SBC_ARM_ASM_OPT==FALSE && SBC_IPAQ_OPT==FALSE)
+#if (SBC_IS_64_MULT_IN_WINDOW_ACCU == FALSE)
+/*Window coeff for 4 sub band case*/
+const SINT16 gas32CoeffFor4SBs[] =
+{
+ (SINT16)((SINT32)0x00000000 >> 16), (SINT16)0x00000000,
+ (SINT16)((SINT32)0x001194E6 >> 16), (SINT16)0x001194E6,
+ (SINT16)((SINT32)0x0030E2D3 >> 16), (SINT16)0x0030E2D3,
+ (SINT16)((SINT32)0x00599403 >> 16), (SINT16)0x00599403,
+ (SINT16)((SINT32)0x007DBCC8 >> 16), (SINT16)0x007DBCC8,
+ (SINT16)((SINT32)0x007F88E4 >> 16), (SINT16)0x007F88E4,
+ (SINT16)((SINT32)0x003D239B >> 16), (SINT16)0x003D239B,
+ (SINT16)((SINT32)0xFF9BB9D5 >> 16), (SINT16)0xFF9BB9D5,
+
+ (SINT16)((SINT32)0x01659F45 >> 16), (SINT16)0x01659F45,
+ (SINT16)((SINT32)0x029DBAA3 >> 16), (SINT16)0x029DBAA3,
+ (SINT16)((SINT32)0x03B23341 >> 16), (SINT16)0x03B23341,
+ (SINT16)((SINT32)0x041EEE40 >> 16), (SINT16)0x041EEE40,
+ (SINT16)((SINT32)0x034FEE2C >> 16), (SINT16)0x034FEE2C,
+ (SINT16)((SINT32)0x00C8F2BC >> 16), (SINT16)0x00C8F2BC,
+ (SINT16)((SINT32)0xFC4F91D4 >> 16), (SINT16)0xFC4F91D4,
+ (SINT16)((SINT32)0xF60FAF37 >> 16), (SINT16)0xF60FAF37,
+
+ (SINT16)((SINT32)0x115B1ED2 >> 16), (SINT16)0x115B1ED2,
+ (SINT16)((SINT32)0x18F55C90 >> 16), (SINT16)0x18F55C90,
+ (SINT16)((SINT32)0x1F91CA46 >> 16), (SINT16)0x1F91CA46,
+ (SINT16)((SINT32)0x2412F251 >> 16), (SINT16)0x2412F251,
+ (SINT16)((SINT32)0x25AC1FF2 >> 16), (SINT16)0x25AC1FF2,
+ (SINT16)((SINT32)0x2412F251 >> 16), (SINT16)0x2412F251,
+ (SINT16)((SINT32)0x1F91CA46 >> 16), (SINT16)0x1F91CA46,
+ (SINT16)((SINT32)0x18F55C90 >> 16), (SINT16)0x18F55C90,
+
+ (SINT16)((SINT32)0xEEA4E12E >> 16), (SINT16)0xEEA4E12E,
+ (SINT16)((SINT32)0xF60FAF37 >> 16), (SINT16)0xF60FAF37,
+ (SINT16)((SINT32)0xFC4F91D4 >> 16), (SINT16)0xFC4F91D4,
+ (SINT16)((SINT32)0x00C8F2BC >> 16), (SINT16)0x00C8F2BC,
+ (SINT16)((SINT32)0x034FEE2C >> 16), (SINT16)0x034FEE2C,
+ (SINT16)((SINT32)0x041EEE40 >> 16), (SINT16)0x041EEE40,
+ (SINT16)((SINT32)0x03B23341 >> 16), (SINT16)0x03B23341,
+ (SINT16)((SINT32)0x029DBAA3 >> 16), (SINT16)0x029DBAA3,
+
+ (SINT16)((SINT32)0xFE9A60BB >> 16), (SINT16)0xFE9A60BB,
+ (SINT16)((SINT32)0xFF9BB9D5 >> 16), (SINT16)0xFF9BB9D5,
+ (SINT16)((SINT32)0x003D239B >> 16), (SINT16)0x003D239B,
+ (SINT16)((SINT32)0x007F88E4 >> 16), (SINT16)0x007F88E4,
+ (SINT16)((SINT32)0x007DBCC8 >> 16), (SINT16)0x007DBCC8,
+ (SINT16)((SINT32)0x00599403 >> 16), (SINT16)0x00599403,
+ (SINT16)((SINT32)0x0030E2D3 >> 16), (SINT16)0x0030E2D3,
+ (SINT16)((SINT32)0x001194E6 >> 16), (SINT16)0x001194E6
+};
+
+/*Window coeff for 8 sub band case*/
+const SINT16 gas32CoeffFor8SBs[] =
+{
+ (SINT16)((SINT32)0x00000000 >>16), (SINT16)0x00000000,
+ (SINT16)((SINT32)0x00052173 >>16), (SINT16)0x00052173,
+ (SINT16)((SINT32)0x000B3F71 >>16), (SINT16)0x000B3F71,
+ (SINT16)((SINT32)0x00122C7D >>16), (SINT16)0x00122C7D,
+ (SINT16)((SINT32)0x001AFF89 >>16), (SINT16)0x001AFF89,
+ (SINT16)((SINT32)0x00255A62 >>16), (SINT16)0x00255A62,
+ (SINT16)((SINT32)0x003060F4 >>16), (SINT16)0x003060F4,
+ (SINT16)((SINT32)0x003A72E7 >>16), (SINT16)0x003A72E7,
+
+ (SINT16)((SINT32)0x0041EC6A >>16), (SINT16)0x0041EC6A, /* 8 */
+ (SINT16)((SINT32)0x0044EF48 >>16), (SINT16)0x0044EF48,
+ (SINT16)((SINT32)0x00415B75 >>16), (SINT16)0x00415B75,
+ (SINT16)((SINT32)0x0034F8B6 >>16), (SINT16)0x0034F8B6,
+ (SINT16)((SINT32)0x001D8FD2 >>16), (SINT16)0x001D8FD2,
+ (SINT16)((SINT32)0xFFFA2413 >>16), (SINT16)0xFFFA2413,
+ (SINT16)((SINT32)0xFFC9F10E >>16), (SINT16)0xFFC9F10E,
+ (SINT16)((SINT32)0xFF8D6793 >>16), (SINT16)0xFF8D6793,
+
+ (SINT16)((SINT32)0x00B97348 >>16), (SINT16)0x00B97348, /* 16 */
+ (SINT16)((SINT32)0x01071B96 >>16), (SINT16)0x01071B96,
+ (SINT16)((SINT32)0x0156B3CA >>16), (SINT16)0x0156B3CA,
+ (SINT16)((SINT32)0x01A1B38B >>16), (SINT16)0x01A1B38B,
+ (SINT16)((SINT32)0x01E0224C >>16), (SINT16)0x01E0224C,
+ (SINT16)((SINT32)0x0209291F >>16), (SINT16)0x0209291F,
+ (SINT16)((SINT32)0x02138653 >>16), (SINT16)0x02138653,
+ (SINT16)((SINT32)0x01F5F424 >>16), (SINT16)0x01F5F424,
+
+ (SINT16)((SINT32)0x01A7ECEF >>16), (SINT16)0x01A7ECEF, /* 24 */
+ (SINT16)((SINT32)0x01223EBA >>16), (SINT16)0x01223EBA,
+ (SINT16)((SINT32)0x005FD0FF >>16), (SINT16)0x005FD0FF,
+ (SINT16)((SINT32)0xFF5EEB73 >>16), (SINT16)0xFF5EEB73,
+ (SINT16)((SINT32)0xFE20435D >>16), (SINT16)0xFE20435D,
+ (SINT16)((SINT32)0xFCA86E7E >>16), (SINT16)0xFCA86E7E,
+ (SINT16)((SINT32)0xFAFF95FC >>16), (SINT16)0xFAFF95FC,
+ (SINT16)((SINT32)0xF9312891 >>16), (SINT16)0xF9312891,
+
+ (SINT16)((SINT32)0x08B4307A >>16), (SINT16)0x08B4307A, /* 32 */
+ (SINT16)((SINT32)0x0A9F3E9A >>16), (SINT16)0x0A9F3E9A,
+ (SINT16)((SINT32)0x0C7D59B6 >>16), (SINT16)0x0C7D59B6,
+ (SINT16)((SINT32)0x0E3BB16F >>16), (SINT16)0x0E3BB16F,
+ (SINT16)((SINT32)0x0FC721F9 >>16), (SINT16)0x0FC721F9,
+ (SINT16)((SINT32)0x110ECEF0 >>16), (SINT16)0x110ECEF0,
+ (SINT16)((SINT32)0x120435FA >>16), (SINT16)0x120435FA,
+ (SINT16)((SINT32)0x129C226F >>16), (SINT16)0x129C226F,
+
+ (SINT16)((SINT32)0x12CF6C75 >>16), (SINT16)0x12CF6C75, /* 40 */
+ (SINT16)((SINT32)0x129C226F >>16), (SINT16)0x129C226F,
+ (SINT16)((SINT32)0x120435FA >>16), (SINT16)0x120435FA,
+ (SINT16)((SINT32)0x110ECEF0 >>16), (SINT16)0x110ECEF0,
+ (SINT16)((SINT32)0x0FC721F9 >>16), (SINT16)0x0FC721F9,
+ (SINT16)((SINT32)0x0E3BB16F >>16), (SINT16)0x0E3BB16F,
+ (SINT16)((SINT32)0x0C7D59B6 >>16), (SINT16)0x0C7D59B6,
+ (SINT16)((SINT32)0x0A9F3E9A >>16), (SINT16)0x0A9F3E9A,
+
+ (SINT16)((SINT32)0xF74BCF86 >>16), (SINT16)0xF74BCF86, /* 48 */
+ (SINT16)((SINT32)0xF9312891 >>16), (SINT16)0xF9312891,
+ (SINT16)((SINT32)0xFAFF95FC >>16), (SINT16)0xFAFF95FC,
+ (SINT16)((SINT32)0xFCA86E7E >>16), (SINT16)0xFCA86E7E,
+ (SINT16)((SINT32)0xFE20435D >>16), (SINT16)0xFE20435D,
+ (SINT16)((SINT32)0xFF5EEB73 >>16), (SINT16)0xFF5EEB73,
+ (SINT16)((SINT32)0x005FD0FF >>16), (SINT16)0x005FD0FF,
+ (SINT16)((SINT32)0x01223EBA >>16), (SINT16)0x01223EBA,
+
+ (SINT16)((SINT32)0x01A7ECEF >>16), (SINT16)0x01A7ECEF, /* 56 */
+ (SINT16)((SINT32)0x01F5F424 >>16), (SINT16)0x01F5F424,
+ (SINT16)((SINT32)0x02138653 >>16), (SINT16)0x02138653,
+ (SINT16)((SINT32)0x0209291F >>16), (SINT16)0x0209291F,
+ (SINT16)((SINT32)0x01E0224C >>16), (SINT16)0x01E0224C,
+ (SINT16)((SINT32)0x01A1B38B >>16), (SINT16)0x01A1B38B,
+ (SINT16)((SINT32)0x0156B3CA >>16), (SINT16)0x0156B3CA,
+ (SINT16)((SINT32)0x01071B96 >>16), (SINT16)0x01071B96,
+
+ (SINT16)((SINT32)0xFF468CB8 >>16), (SINT16)0xFF468CB8, /* 64 */
+ (SINT16)((SINT32)0xFF8D6793 >>16), (SINT16)0xFF8D6793,
+ (SINT16)((SINT32)0xFFC9F10E >>16), (SINT16)0xFFC9F10E,
+ (SINT16)((SINT32)0xFFFA2413 >>16), (SINT16)0xFFFA2413,
+ (SINT16)((SINT32)0x001D8FD2 >>16), (SINT16)0x001D8FD2,
+ (SINT16)((SINT32)0x0034F8B6 >>16), (SINT16)0x0034F8B6,
+ (SINT16)((SINT32)0x00415B75 >>16), (SINT16)0x00415B75,
+ (SINT16)((SINT32)0x0044EF48 >>16), (SINT16)0x0044EF48,
+
+ (SINT16)((SINT32)0x0041EC6A >>16), (SINT16)0x0041EC6A, /* 72 */
+ (SINT16)((SINT32)0x003A72E7 >>16), (SINT16)0x003A72E7,
+ (SINT16)((SINT32)0x003060F4 >>16), (SINT16)0x003060F4,
+ (SINT16)((SINT32)0x00255A62 >>16), (SINT16)0x00255A62,
+ (SINT16)((SINT32)0x001AFF89 >>16), (SINT16)0x001AFF89,
+ (SINT16)((SINT32)0x00122C7D >>16), (SINT16)0x00122C7D,
+ (SINT16)((SINT32)0x000B3F71 >>16), (SINT16)0x000B3F71,
+ (SINT16)((SINT32)0x00052173 >>16), (SINT16)0x00052173
+};
+
+#else
+
+/*Window coeff for 4 sub band case*/
+const SINT32 gas32CoeffFor4SBs[] =
+{
+ (SINT32)0x00000000,
+ (SINT32)0x001194E6,
+ (SINT32)0x0030E2D3,
+ (SINT32)0x00599403,
+ (SINT32)0x007DBCC8,
+ (SINT32)0x007F88E4,
+ (SINT32)0x003D239B,
+ (SINT32)0xFF9BB9D5,
+
+ (SINT32)0x01659F45,
+ (SINT32)0x029DBAA3,
+ (SINT32)0x03B23341,
+ (SINT32)0x041EEE40,
+ (SINT32)0x034FEE2C,
+ (SINT32)0x00C8F2BC,
+ (SINT32)0xFC4F91D4,
+ (SINT32)0xF60FAF37,
+
+ (SINT32)0x115B1ED2,
+ (SINT32)0x18F55C90,
+ (SINT32)0x1F91CA46,
+ (SINT32)0x2412F251,
+ (SINT32)0x25AC1FF2,
+ (SINT32)0x2412F251,
+ (SINT32)0x1F91CA46,
+ (SINT32)0x18F55C90,
+
+ (SINT32)0xEEA4E12E,
+ (SINT32)0xF60FAF37,
+ (SINT32)0xFC4F91D4,
+ (SINT32)0x00C8F2BC,
+ (SINT32)0x034FEE2C,
+ (SINT32)0x041EEE40,
+ (SINT32)0x03B23341,
+ (SINT32)0x029DBAA3,
+
+ (SINT32)0xFE9A60BB,
+ (SINT32)0xFF9BB9D5,
+ (SINT32)0x003D239B,
+ (SINT32)0x007F88E4,
+ (SINT32)0x007DBCC8,
+ (SINT32)0x00599403,
+ (SINT32)0x0030E2D3,
+ (SINT32)0x001194E6
+};
+
+/*Window coeff for 8 sub band case*/
+const SINT32 gas32CoeffFor8SBs[] =
+{
+ (SINT32)0x00000000,
+ (SINT32)0x00052173,
+ (SINT32)0x000B3F71,
+ (SINT32)0x00122C7D,
+ (SINT32)0x001AFF89,
+ (SINT32)0x00255A62,
+ (SINT32)0x003060F4,
+ (SINT32)0x003A72E7,
+
+ (SINT32)0x0041EC6A, /* 8 */
+ (SINT32)0x0044EF48,
+ (SINT32)0x00415B75,
+ (SINT32)0x0034F8B6,
+ (SINT32)0x001D8FD2,
+ (SINT32)0xFFFA2413,
+ (SINT32)0xFFC9F10E,
+ (SINT32)0xFF8D6793,
+
+ (SINT32)0x00B97348, /* 16 */
+ (SINT32)0x01071B96,
+ (SINT32)0x0156B3CA,
+ (SINT32)0x01A1B38B,
+ (SINT32)0x01E0224C,
+ (SINT32)0x0209291F,
+ (SINT32)0x02138653,
+ (SINT32)0x01F5F424,
+
+ (SINT32)0x01A7ECEF, /* 24 */
+ (SINT32)0x01223EBA,
+ (SINT32)0x005FD0FF,
+ (SINT32)0xFF5EEB73,
+ (SINT32)0xFE20435D,
+ (SINT32)0xFCA86E7E,
+ (SINT32)0xFAFF95FC,
+ (SINT32)0xF9312891,
+
+ (SINT32)0x08B4307A, /* 32 */
+ (SINT32)0x0A9F3E9A,
+ (SINT32)0x0C7D59B6,
+ (SINT32)0x0E3BB16F,
+ (SINT32)0x0FC721F9,
+ (SINT32)0x110ECEF0,
+ (SINT32)0x120435FA,
+ (SINT32)0x129C226F,
+
+ (SINT32)0x12CF6C75, /* 40 */
+ (SINT32)0x129C226F,
+ (SINT32)0x120435FA,
+ (SINT32)0x110ECEF0,
+ (SINT32)0x0FC721F9,
+ (SINT32)0x0E3BB16F,
+ (SINT32)0x0C7D59B6,
+ (SINT32)0x0A9F3E9A,
+
+ (SINT32)0xF74BCF86, /* 48 */
+ (SINT32)0xF9312891,
+ (SINT32)0xFAFF95FC,
+ (SINT32)0xFCA86E7E,
+ (SINT32)0xFE20435D,
+ (SINT32)0xFF5EEB73,
+ (SINT32)0x005FD0FF,
+ (SINT32)0x01223EBA,
+
+ (SINT32)0x01A7ECEF, /* 56 */
+ (SINT32)0x01F5F424,
+ (SINT32)0x02138653,
+ (SINT32)0x0209291F,
+ (SINT32)0x01E0224C,
+ (SINT32)0x01A1B38B,
+ (SINT32)0x0156B3CA,
+ (SINT32)0x01071B96,
+
+ (SINT32)0xFF468CB8, /* 64 */
+ (SINT32)0xFF8D6793,
+ (SINT32)0xFFC9F10E,
+ (SINT32)0xFFFA2413,
+ (SINT32)0x001D8FD2,
+ (SINT32)0x0034F8B6,
+ (SINT32)0x00415B75,
+ (SINT32)0x0044EF48,
+
+ (SINT32)0x0041EC6A, /* 72 */
+ (SINT32)0x003A72E7,
+ (SINT32)0x003060F4,
+ (SINT32)0x00255A62,
+ (SINT32)0x001AFF89,
+ (SINT32)0x00122C7D,
+ (SINT32)0x000B3F71,
+ (SINT32)0x00052173
+};
+
+#endif
+#endif
+
diff --git a/embdrv/sbc/encoder/srce/sbc_encoder.c b/embdrv/sbc/encoder/srce/sbc_encoder.c
new file mode 100644
index 0000000..281c970
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_encoder.c
@@ -0,0 +1,386 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_encoder.c,v $
+**
+** Description: contains code for encoder flow and initalization of encoder
+**
+** Revision : $Id: sbc_encoder.c,v 1.17 2006/04/13 17:24:47 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#include <string.h>
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+
+SINT16 EncMaxShiftCounter;
+
+/*************************************************************************************************
+ * SBC encoder scramble code
+ * Purpose: to tie the SBC code with BTE/mobile stack code,
+ * especially for the case when the SBC is ported into a third-party Multimedia chip
+ *
+ * Algorithm:
+ * init process: all counters reset to 0,
+ * calculate base_index: (6 + s16NumOfChannels*s16NumOfSubBands/2)
+ * scramble side: the init process happens every time SBC_Encoder_Init() is called.
+ * descramble side: it would be nice to know if he "init" process has happened.
+ * alter the SBC SYNC word 0x9C (1001 1100) to 0x8C (1000 1100).
+ *
+ * scramble process:
+ * The CRC byte:
+ * Every SBC frame has a frame header.
+ * The 1st byte is the sync word and the following 2 bytes are about the stream format.
+ * They are supposed to be "constant" within a "song"
+ * The 4th byte is the CRC byte. The CRC byte is bound to be random.
+ * Derive 2 items from the CRC byte; one is the "use" bit, the other is the "index".
+ *
+ * SBC keeps 2 sets of "use" & "index"; derived the current and the previous frame.
+ *
+ * The "use" bit is any bit in SBC_PRTC_USE_MASK is set.
+ * If set, SBC uses the "index" from the current frame.
+ * If not set, SBC uses the "index" from the previous frame or 0.
+ *
+ * index = (CRC & 0x3) + ((CRC & 0x30) >> 2) // 8 is the max index
+ *
+ * if(index > 0)
+ * {
+ * p = &u8frame[base_index];
+ * if((index&1)&&(u16PacketLength > (base_index+index*2)))
+ * {
+ * // odd index: swap 2 bytes
+ * tmp = p[index];
+ * p[index] = p[index*2];
+ * p[index*2] = tmp;
+ * }
+ * else
+ * {
+ * // even index: shift by 3
+ * tmp = (p[index] >> 5) + (p[index] << 3);
+ * p[index] = tmp;
+ * }
+ * }
+ * //else index is 0. The frame stays unaltered
+ *
+ */
+
+#define SBC_PRTC_CRC_IDX 3
+#define SBC_PRTC_USE_MASK 0x64
+#define SBC_PRTC_SYNC_MASK 0x10
+#define SBC_PRTC_CIDX 0
+#define SBC_PRTC_LIDX 1
+typedef struct
+{
+ UINT8 use;
+ UINT8 idx;
+} tSBC_FR_CB;
+
+typedef struct
+{
+ tSBC_FR_CB fr[2];
+ UINT8 init;
+ UINT8 index;
+ UINT8 base;
+} tSBC_PRTC_CB;
+tSBC_PRTC_CB sbc_prtc_cb;
+
+#define SBC_PRTC_IDX(sc) (((sc) & 0x3) + (((sc) & 0x30) >> 2))
+#define SBC_PRTC_CHK_INIT(ar) {if(sbc_prtc_cb.init == 0){sbc_prtc_cb.init=1; ar[0] &= ~SBC_PRTC_SYNC_MASK;}}
+#define SBC_PRTC_C2L() {p_last=&sbc_prtc_cb.fr[SBC_PRTC_LIDX]; p_cur=&sbc_prtc_cb.fr[SBC_PRTC_CIDX]; \
+ p_last->idx = p_cur->idx; p_last->use = p_cur->use;}
+#define SBC_PRTC_GETC(ar) {p_cur->use = ar[SBC_PRTC_CRC_IDX] & SBC_PRTC_USE_MASK; \
+ p_cur->idx = SBC_PRTC_IDX(ar[SBC_PRTC_CRC_IDX]);}
+#define SBC_PRTC_CHK_CRC(ar) {SBC_PRTC_C2L();SBC_PRTC_GETC(ar);sbc_prtc_cb.index = (p_cur->use)?SBC_PRTC_CIDX:SBC_PRTC_LIDX;}
+#define SBC_PRTC_SCRMB(ar) {idx = sbc_prtc_cb.fr[sbc_prtc_cb.index].idx; \
+ if(idx > 0){if((idx&1)&&(pstrEncParams->u16PacketLength > (sbc_prtc_cb.base+(idx<<1)))) {tmp2=idx<<1; tmp=ar[idx];ar[idx]=ar[tmp2];ar[tmp2]=tmp;} \
+ else{tmp2=ar[idx]; tmp=(tmp2>>5)+(tmp2<<3);ar[idx]=(UINT8)tmp;}}}
+
+#if (SBC_JOINT_STE_INCLUDED == TRUE)
+SINT32 s32LRDiff[SBC_MAX_NUM_OF_BLOCKS] = {0};
+SINT32 s32LRSum[SBC_MAX_NUM_OF_BLOCKS] = {0};
+#endif
+
+void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
+{
+ SINT32 s32Ch; /* counter for ch*/
+ SINT32 s32Sb; /* counter for sub-band*/
+ UINT32 u32Count, maxBit = 0; /* loop count*/
+ SINT32 s32MaxValue; /* temp variable to store max value */
+
+ SINT16 *ps16ScfL;
+ SINT32 *SbBuffer;
+ SINT32 s32Blk; /* counter for block*/
+ SINT32 s32NumOfBlocks = pstrEncParams->s16NumOfBlocks;
+#if (SBC_JOINT_STE_INCLUDED == TRUE)
+ SINT32 s32MaxValue2;
+ UINT32 u32CountSum,u32CountDiff;
+ SINT32 *pSum, *pDiff;
+#endif
+ UINT8 *pu8;
+ tSBC_FR_CB *p_cur, *p_last;
+ UINT32 idx, tmp, tmp2;
+ register SINT32 s32NumOfSubBands = pstrEncParams->s16NumOfSubBands;
+
+ pstrEncParams->pu8NextPacket = pstrEncParams->pu8Packet;
+
+#if (SBC_NO_PCM_CPY_OPTION == TRUE)
+ pstrEncParams->ps16NextPcmBuffer = pstrEncParams->ps16PcmBuffer;
+#else
+ pstrEncParams->ps16NextPcmBuffer = pstrEncParams->as16PcmBuffer;
+#endif
+ do
+ {
+ /* SBC ananlysis filter*/
+ if (s32NumOfSubBands == 4)
+ SbcAnalysisFilter4(pstrEncParams);
+ else
+ SbcAnalysisFilter8(pstrEncParams);
+
+ /* compute the scale factor, and save the max */
+ ps16ScfL = pstrEncParams->as16ScaleFactor;
+ s32Ch=pstrEncParams->s16NumOfChannels*s32NumOfSubBands;
+
+ pstrEncParams->ps16NextPcmBuffer+=s32Ch*s32NumOfBlocks; /* in case of multible sbc frame to encode update the pcm pointer */
+
+ for (s32Sb=0; s32Sb<s32Ch; s32Sb++)
+ {
+ SbBuffer=pstrEncParams->s32SbBuffer+s32Sb;
+ s32MaxValue=0;
+ for (s32Blk=s32NumOfBlocks;s32Blk>0;s32Blk--)
+ {
+ if (s32MaxValue<abs32(*SbBuffer))
+ s32MaxValue=abs32(*SbBuffer);
+ SbBuffer+=s32Ch;
+ }
+
+ u32Count = (s32MaxValue > 0x800000) ? 9 : 0;
+
+ for ( ; u32Count < 15; u32Count++)
+ {
+ if (s32MaxValue <= (SINT32)(0x8000 << u32Count))
+ break;
+ }
+ *ps16ScfL++ = (SINT16)u32Count;
+
+ if (u32Count > maxBit)
+ maxBit = u32Count;
+ }
+ /* In case of JS processing,check whether to use JS */
+#if (SBC_JOINT_STE_INCLUDED == TRUE)
+ if (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO)
+ {
+ /* Calculate sum and differance scale factors for making JS decision */
+ ps16ScfL = pstrEncParams->as16ScaleFactor ;
+ /* calculate the scale factor of Joint stereo max sum and diff */
+ for (s32Sb = 0; s32Sb < s32NumOfSubBands-1; s32Sb++)
+ {
+ SbBuffer=pstrEncParams->s32SbBuffer+s32Sb;
+ s32MaxValue2=0;
+ s32MaxValue=0;
+ pSum = s32LRSum;
+ pDiff = s32LRDiff;
+ for (s32Blk=0;s32Blk<s32NumOfBlocks;s32Blk++)
+ {
+ *pSum=(*SbBuffer+*(SbBuffer+s32NumOfSubBands))>>1;
+ if (abs32(*pSum)>s32MaxValue)
+ s32MaxValue=abs32(*pSum);
+ pSum++;
+ *pDiff=(*SbBuffer-*(SbBuffer+s32NumOfSubBands))>>1;
+ if (abs32(*pDiff)>s32MaxValue2)
+ s32MaxValue2=abs32(*pDiff);
+ pDiff++;
+ SbBuffer+=s32Ch;
+ }
+ u32Count = (s32MaxValue > 0x800000) ? 9 : 0;
+ for ( ; u32Count < 15; u32Count++)
+ {
+ if (s32MaxValue <= (SINT32)(0x8000 << u32Count))
+ break;
+ }
+ u32CountSum=u32Count;
+ u32Count = (s32MaxValue2 > 0x800000) ? 9 : 0;
+ for ( ; u32Count < 15; u32Count++)
+ {
+ if (s32MaxValue2 <= (SINT32)(0x8000 << u32Count))
+ break;
+ }
+ u32CountDiff=u32Count;
+ if ( (*ps16ScfL + *(ps16ScfL+s32NumOfSubBands)) > (SINT16)(u32CountSum + u32CountDiff) )
+ {
+
+ if (u32CountSum > maxBit)
+ maxBit = u32CountSum;
+
+ if (u32CountDiff > maxBit)
+ maxBit = u32CountDiff;
+
+ *ps16ScfL = (SINT16)u32CountSum;
+ *(ps16ScfL+s32NumOfSubBands) = (SINT16)u32CountDiff;
+
+ SbBuffer=pstrEncParams->s32SbBuffer+s32Sb;
+ pSum = s32LRSum;
+ pDiff = s32LRDiff;
+
+ for (s32Blk = 0; s32Blk < s32NumOfBlocks; s32Blk++)
+ {
+ *SbBuffer = *pSum;
+ *(SbBuffer+s32NumOfSubBands) = *pDiff;
+
+ SbBuffer += s32NumOfSubBands<<1;
+ pSum++;
+ pDiff++;
+ }
+
+ pstrEncParams->as16Join[s32Sb] = 1;
+ }
+ else
+ {
+ pstrEncParams->as16Join[s32Sb] = 0;
+ }
+ ps16ScfL++;
+ }
+ pstrEncParams->as16Join[s32Sb] = 0;
+ }
+#endif
+
+ pstrEncParams->s16MaxBitNeed = (SINT16)maxBit;
+
+ /* bit allocation */
+ if ((pstrEncParams->s16ChannelMode == SBC_STEREO) || (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO))
+ sbc_enc_bit_alloc_ste(pstrEncParams);
+ else
+ sbc_enc_bit_alloc_mono(pstrEncParams);
+
+ /* save the beginning of the frame. pu8NextPacket is modified in EncPacking() */
+ pu8 = pstrEncParams->pu8NextPacket;
+ /* Quantize the encoded audio */
+ EncPacking(pstrEncParams);
+
+ /* scramble the code */
+ SBC_PRTC_CHK_INIT(pu8);
+ SBC_PRTC_CHK_CRC(pu8);
+#if 0
+ if(pstrEncParams->u16PacketLength > ((sbc_prtc_cb.fr[sbc_prtc_cb.index].idx * 2) + sbc_prtc_cb.base))
+ printf("len: %d, idx: %d\n", pstrEncParams->u16PacketLength, sbc_prtc_cb.fr[sbc_prtc_cb.index].idx);
+ else
+ printf("len: %d, idx: %d!!!!\n", pstrEncParams->u16PacketLength, sbc_prtc_cb.fr[sbc_prtc_cb.index].idx);
+#endif
+ SBC_PRTC_SCRMB((&pu8[sbc_prtc_cb.base]));
+ }
+ while(--(pstrEncParams->u8NumPacketToEncode));
+
+ pstrEncParams->u8NumPacketToEncode = 1; /* default is one for retrocompatibility purpose */
+
+}
+
+/****************************************************************************
+* InitSbcAnalysisFilt - Initalizes the input data to 0
+*
+* RETURNS : N/A
+*/
+void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams)
+{
+ UINT16 s16SamplingFreq; /*temp variable to store smpling freq*/
+ SINT16 s16Bitpool; /*to store bit pool value*/
+ SINT16 s16BitRate; /*to store bitrate*/
+ SINT16 s16FrameLen; /*to store frame length*/
+ UINT16 HeaderParams;
+
+ pstrEncParams->u8NumPacketToEncode = 1; /* default is one for retrocompatibility purpose */
+
+ /* Required number of channels */
+ if (pstrEncParams->s16ChannelMode == SBC_MONO)
+ pstrEncParams->s16NumOfChannels = 1;
+ else
+ pstrEncParams->s16NumOfChannels = 2;
+
+ /* Bit pool calculation */
+ if (pstrEncParams->s16SamplingFreq == SBC_sf16000)
+ s16SamplingFreq = 16000;
+ else if (pstrEncParams->s16SamplingFreq == SBC_sf32000)
+ s16SamplingFreq = 32000;
+ else if (pstrEncParams->s16SamplingFreq == SBC_sf44100)
+ s16SamplingFreq = 44100;
+ else
+ s16SamplingFreq = 48000;
+
+ if ( (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO)
+ || (pstrEncParams->s16ChannelMode == SBC_STEREO) )
+ {
+ s16Bitpool = (SINT16)( (pstrEncParams->u16BitRate *
+ pstrEncParams->s16NumOfSubBands * 1000 / s16SamplingFreq)
+ -( (32 + (4 * pstrEncParams->s16NumOfSubBands *
+ pstrEncParams->s16NumOfChannels)
+ + ( (pstrEncParams->s16ChannelMode - 2) *
+ pstrEncParams->s16NumOfSubBands ) )
+ / pstrEncParams->s16NumOfBlocks) );
+
+ s16FrameLen = 4 + (4*pstrEncParams->s16NumOfSubBands*
+ pstrEncParams->s16NumOfChannels)/8
+ + ( ((pstrEncParams->s16ChannelMode - 2) *
+ pstrEncParams->s16NumOfSubBands)
+ + (pstrEncParams->s16NumOfBlocks * s16Bitpool) ) / 8;
+
+ s16BitRate = (8 * s16FrameLen * s16SamplingFreq)
+ / (pstrEncParams->s16NumOfSubBands *
+ pstrEncParams->s16NumOfBlocks * 1000);
+
+ if (s16BitRate > pstrEncParams->u16BitRate)
+ s16Bitpool--;
+
+ if(pstrEncParams->s16NumOfSubBands == 8)
+ pstrEncParams->s16BitPool = (s16Bitpool > 255) ? 255 : s16Bitpool;
+ else
+ pstrEncParams->s16BitPool = (s16Bitpool > 128) ? 128 : s16Bitpool;
+ }
+ else
+ {
+ s16Bitpool = (SINT16)( ((pstrEncParams->s16NumOfSubBands *
+ pstrEncParams->u16BitRate * 1000)
+ / (s16SamplingFreq * pstrEncParams->s16NumOfChannels))
+ -( ( (32 / pstrEncParams->s16NumOfChannels) +
+ (4 * pstrEncParams->s16NumOfSubBands) )
+ / pstrEncParams->s16NumOfBlocks ) );
+
+ pstrEncParams->s16BitPool = (s16Bitpool >
+ (16 * pstrEncParams->s16NumOfSubBands))
+ ? (16*pstrEncParams->s16NumOfSubBands) : s16Bitpool;
+ }
+
+ if (pstrEncParams->s16BitPool < 0)
+ pstrEncParams->s16BitPool = 0;
+ /* sampling freq */
+ HeaderParams = ((pstrEncParams->s16SamplingFreq & 3)<< 6);
+
+ /* number of blocks*/
+ HeaderParams |= (((pstrEncParams->s16NumOfBlocks -4) & 12) << 2);
+
+ /* channel mode: mono, dual...*/
+ HeaderParams |= ((pstrEncParams->s16ChannelMode & 3)<< 2);
+
+ /* Loudness or SNR */
+ HeaderParams |= ((pstrEncParams->s16AllocationMethod & 1)<< 1);
+ HeaderParams |= ((pstrEncParams->s16NumOfSubBands >> 3) & 1); /*4 or 8*/
+ pstrEncParams->FrameHeader=HeaderParams;
+
+ if (pstrEncParams->s16NumOfSubBands==4)
+ {
+ if (pstrEncParams->s16NumOfChannels==1)
+ EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-4*10)>>2)<<2;
+ else
+ EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-4*10*2)>>3)<<2;
+ }
+ else
+ {
+ if (pstrEncParams->s16NumOfChannels==1)
+ EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-8*10)>>3)<<3;
+ else
+ EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-8*10*2)>>4)<<3;
+ }
+ SbcAnalysisInit();
+
+ memset(&sbc_prtc_cb, 0, sizeof(tSBC_PRTC_CB));
+ sbc_prtc_cb.base = 6 + pstrEncParams->s16NumOfChannels*pstrEncParams->s16NumOfSubBands/2;
+}
diff --git a/embdrv/sbc/encoder/srce/sbc_packing.c b/embdrv/sbc/encoder/srce/sbc_packing.c
new file mode 100644
index 0000000..55edb9b
--- /dev/null
+++ b/embdrv/sbc/encoder/srce/sbc_packing.c
@@ -0,0 +1,264 @@
+/******************************************************************************
+**
+** File Name: $RCSfile: sbc_packing.c,v $
+**
+** Description: This file contains code for packing the Encoded data into bit
+** streams.
+**
+** Revision : $Id: sbc_packing.c,v 1.17 2006/04/11 17:07:03 mjougit Exp $
+**
+** Copyright (c) 1999-2002, Widcomm Inc., All Rights Reserved.
+** Widcomm Bluetooth Core. Proprietary and confidential.
+**
+******************************************************************************/
+
+#include "sbc_encoder.h"
+#include "sbc_enc_func_declare.h"
+
+#if (SBC_ARM_ASM_OPT==TRUE)
+#define Mult32(s32In1,s32In2,s32OutLow) \
+{ \
+ __asm \
+ { \
+ MUL s32OutLow,s32In1,s32In2; \
+ } \
+}
+#define Mult64(s32In1, s32In2, s32OutLow, s32OutHi) \
+{ \
+ __asm \
+ { \
+ SMULL s32OutLow,s32OutHi,s32In1,s32In2 \
+ } \
+}
+#else
+#define Mult32(s32In1,s32In2,s32OutLow) s32OutLow=(SINT32)s32In1*(SINT32)s32In2;
+#define Mult64(s32In1, s32In2, s32OutLow, s32OutHi) \
+{ \
+ s32OutLow = ((SINT32)(UINT16)s32In1 * (UINT16)s32In2); \
+ s32TempVal2 = (SINT32)((s32In1 >> 16) * (UINT16)s32In2); \
+ s32Carry = ( (((UINT32)(s32OutLow)>>16)&0xFFFF) + \
+ + (s32TempVal2 & 0xFFFF) ) >> 16; \
+ s32OutLow += (s32TempVal2 << 16); \
+ s32OutHi = (s32TempVal2 >> 16) + s32Carry; \
+}
+#endif
+
+void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
+{
+ UINT8 *pu8PacketPtr; /* packet ptr*/
+ UINT8 Temp;
+ SINT32 s32Blk; /* counter for block*/
+ SINT32 s32Ch; /* counter for channel*/
+ SINT32 s32Sb; /* counter for sub-band*/
+ SINT32 s32PresentBit; /* represents bit to be stored*/
+ /*SINT32 s32LoopCountI; loop counter*/
+ SINT32 s32LoopCountJ; /* loop counter*/
+ UINT32 u32QuantizedSbValue,u32QuantizedSbValue0; /* temp variable to store quantized sb val*/
+ SINT32 s32LoopCount; /* loop counter*/
+ UINT8 u8XoredVal; /* to store XORed value in CRC calculation*/
+ UINT8 u8CRC; /* to store CRC value*/
+ SINT16 *ps16GenPtr;
+ SINT32 s32NumOfBlocks;
+ SINT32 s32NumOfSubBands = pstrEncParams->s16NumOfSubBands;
+ SINT32 s32NumOfChannels = pstrEncParams->s16NumOfChannels;
+ UINT32 u32SfRaisedToPow2; /*scale factor raised to power 2*/
+ SINT16 *ps16ScfPtr;
+ SINT32 *ps32SbPtr;
+ UINT16 u16Levels; /*to store levels*/
+ SINT32 s32Temp1; /*used in 64-bit multiplication*/
+ SINT32 s32Low; /*used in 64-bit multiplication*/
+#if (SBC_IS_64_MULT_IN_QUANTIZER==TRUE)
+ SINT32 s32Hi1,s32Low1,s32Carry,s32TempVal2,s32Hi, s32Temp2;
+#endif
+
+ pu8PacketPtr = pstrEncParams->pu8NextPacket; /*Initialize the ptr*/
+ *pu8PacketPtr++ = (UINT8)0x9C; /*Sync word*/
+ *pu8PacketPtr++=(UINT8)(pstrEncParams->FrameHeader);
+
+ *pu8PacketPtr = (UINT8)(pstrEncParams->s16BitPool & 0x00FF);
+ pu8PacketPtr += 2; /*skip for CRC*/
+
+ /*here it indicate if it is byte boundary or nibble boundary*/
+ s32PresentBit = 8;
+ Temp=0;
+#if (SBC_JOINT_STE_INCLUDED == TRUE)
+ if (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO)
+ {
+ /* pack join stero parameters */
+ for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++)
+ {
+ Temp <<= 1;
+ Temp |= pstrEncParams->as16Join[s32Sb];
+ }
+
+ /* pack RFA */
+ if (s32NumOfSubBands == SUB_BANDS_4)
+ {
+ s32PresentBit = 4;
+ }
+ else
+ {
+ *(pu8PacketPtr++)=Temp;
+ Temp = 0;
+ }
+ }
+#endif
+
+ /* Pack Scale factor */
+ ps16GenPtr = pstrEncParams->as16ScaleFactor;
+ s32Sb=s32NumOfChannels*s32NumOfSubBands;
+ /*Temp=*pu8PacketPtr;*/
+ for (s32Ch = s32Sb; s32Ch >0; s32Ch--)
+ {
+ Temp<<= 4;
+ Temp |= *ps16GenPtr++;
+
+ if(s32PresentBit == 4)
+ {
+ s32PresentBit = 8;
+ *(pu8PacketPtr++)=Temp;
+ Temp = 0;
+ }
+ else
+ {
+ s32PresentBit = 4;
+ }
+ }
+
+ /* Pack samples */
+ ps32SbPtr = pstrEncParams->s32SbBuffer;
+ /*Temp=*pu8PacketPtr;*/
+ s32NumOfBlocks= pstrEncParams->s16NumOfBlocks;
+ for (s32Blk = s32NumOfBlocks-1; s32Blk >=0; s32Blk--)
+ {
+ ps16GenPtr = pstrEncParams->as16Bits;
+ ps16ScfPtr = pstrEncParams->as16ScaleFactor;
+ for (s32Ch = s32Sb-1; s32Ch >= 0; s32Ch--)
+ {
+ s32LoopCount = *ps16GenPtr++;
+ if (s32LoopCount != 0)
+ {
+#if (SBC_IS_64_MULT_IN_QUANTIZER==TRUE)
+ /* finding level from reconstruction part of decoder */
+ u32SfRaisedToPow2 = ((UINT32)1 << ((*ps16ScfPtr)+1));
+ u16Levels = (UINT16)(((UINT32)1 << s32LoopCount) - 1);
+
+ /* quantizer */
+ s32Temp1 = (*ps32SbPtr >> 2) + (u32SfRaisedToPow2 << 12);
+ s32Temp2 = u16Levels;
+
+ Mult64 (s32Temp1, s32Temp2, s32Low, s32Hi);
+
+ s32Low1 = s32Low >> ((*ps16ScfPtr)+2);
+ s32Low1 &= ((UINT32)1 << (32 - ((*ps16ScfPtr)+2))) - 1;
+ s32Hi1 = s32Hi << (32 - ((*ps16ScfPtr) +2));
+
+ u32QuantizedSbValue0 = (UINT16)((s32Low1 | s32Hi1) >> 12);
+#else
+ /* finding level from reconstruction part of decoder */
+ u32SfRaisedToPow2 = ((UINT32)1 << *ps16ScfPtr);
+ u16Levels = (UINT16)(((UINT32)1 << s32LoopCount)-1);
+
+ /* quantizer */
+ s32Temp1 = (*ps32SbPtr >> 15) + u32SfRaisedToPow2;
+ Mult32(s32Temp1,u16Levels,s32Low);
+ s32Low>>= (*ps16ScfPtr+1);
+ u32QuantizedSbValue0 = (UINT16)s32Low;
+#endif
+ /*store the number of bits required and the quantized s32Sb
+ sample to ease the coding*/
+ u32QuantizedSbValue = u32QuantizedSbValue0;
+
+ if(s32PresentBit >= s32LoopCount)
+ {
+ Temp <<= s32LoopCount;
+ Temp |= u32QuantizedSbValue;
+ s32PresentBit -= s32LoopCount;
+ }
+ else
+ {
+ while (s32PresentBit < s32LoopCount)
+ {
+ s32LoopCount -= s32PresentBit;
+ u32QuantizedSbValue >>= s32LoopCount;
+
+ /*remove the unwanted msbs*/
+ /*u32QuantizedSbValue <<= 16 - s32PresentBit;
+ u32QuantizedSbValue >>= 16 - s32PresentBit;*/
+
+ Temp <<= s32PresentBit;
+
+ Temp |= u32QuantizedSbValue ;
+ /*restore the original*/
+ u32QuantizedSbValue=u32QuantizedSbValue0;
+
+ *(pu8PacketPtr++)=Temp;
+ Temp = 0;
+ s32PresentBit = 8;
+ }
+ Temp <<= s32LoopCount;
+
+ /* remove the unwanted msbs */
+ /*u32QuantizedSbValue <<= 16 - s32LoopCount;
+ u32QuantizedSbValue >>= 16 - s32LoopCount;*/
+
+ Temp |= u32QuantizedSbValue;
+
+ s32PresentBit -= s32LoopCount;
+ }
+ }
+ ps16ScfPtr++;
+ ps32SbPtr++;
+ }
+ }
+
+ Temp <<= s32PresentBit;
+ *pu8PacketPtr=Temp;
+ pstrEncParams->u16PacketLength=pu8PacketPtr-pstrEncParams->pu8NextPacket+1;
+ /*find CRC*/
+ pu8PacketPtr = pstrEncParams->pu8NextPacket+1; /*Initialize the ptr*/
+ u8CRC = 0x0F;
+ s32LoopCount = s32Sb >> 1;
+
+ /*
+ The loops is run from the start of the packet till the scale factor
+ parameters. In case of JS, 'join' parameter is included in the packet
+ so that many more bytes are included in CRC calculation.
+ */
+ Temp=*pu8PacketPtr;
+ for (s32Ch=1; s32Ch < (s32LoopCount+4); s32Ch++)
+ {
+ /* skip sync word and CRC bytes */
+ if (s32Ch != 3)
+ {
+ for (s32LoopCountJ=7; s32LoopCountJ>=0; s32LoopCountJ--)
+ {
+ u8XoredVal = ((u8CRC >> 7) & 0x01) ^((Temp >> s32LoopCountJ) & 0x01);
+ u8CRC <<= 1;
+ u8CRC ^= (u8XoredVal * 0x1D);
+ u8CRC &= 0xFF;
+ }
+ }
+ Temp=*(++pu8PacketPtr);
+ }
+
+ if (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO)
+ {
+ for (s32LoopCountJ = 7; s32LoopCountJ >= (8 - s32NumOfSubBands); s32LoopCountJ--)
+ {
+ u8XoredVal = ((u8CRC >> 7) & 0x01) ^((Temp >> s32LoopCountJ) & 0x01);
+ u8CRC <<= 1;
+ u8CRC ^= (u8XoredVal * 0x1D);
+ u8CRC &= 0xFF;
+ }
+ }
+
+ /* CRC calculation ends here */
+
+ /* store CRC in packet */
+ pu8PacketPtr = pstrEncParams->pu8NextPacket; /*Initialize the ptr*/
+ pu8PacketPtr += 3;
+ *pu8PacketPtr = u8CRC;
+ pstrEncParams->pu8NextPacket+=pstrEncParams->u16PacketLength; /* move the pointer to the end in case there is more than one frame to encode */
+}
+