summaryrefslogtreecommitdiffstats
path: root/embdrv
diff options
context:
space:
mode:
authorAndre Eisenbach <andre@broadcom.com>2012-09-18 01:35:44 -0700
committerMatthew Xie <mattx@google.com>2012-09-18 16:26:28 -0700
commit6ef101187774e30ddba6b46bbedef549a42196ad (patch)
treef36eb347f03083671640fbc750171e3b951e0082 /embdrv
parentf80d3d045eab5f002be4b5e8a3d2d376fdf7581a (diff)
downloadexternal_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.zip
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.gz
external_bluetooth_bluedroid-6ef101187774e30ddba6b46bbedef549a42196ad.tar.bz2
Initual Bluetooth open source release
First release under Apache source license with updated header files and whitespace cleanups. Also fixed file permission to remove executable bit from source files. Change-Id: I7155903edfc2f491c1cbbd0db108f207852caaa0
Diffstat (limited to 'embdrv')
-rw-r--r--embdrv/sbc/encoder/include/sbc_dct.h31
-rw-r--r--embdrv/sbc/encoder/include/sbc_enc_func_declare.h33
-rw-r--r--embdrv/sbc/encoder/include/sbc_encoder.h45
-rw-r--r--embdrv/sbc/encoder/include/sbc_if.h21
-rw-r--r--embdrv/sbc/encoder/include/sbc_types.h33
-rw-r--r--embdrv/sbc/encoder/srce/sbc_analysis.c71
-rw-r--r--embdrv/sbc/encoder/srce/sbc_dct.c145
-rw-r--r--embdrv/sbc/encoder/srce/sbc_dct_coeffs.c39
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c65
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c43
-rw-r--r--embdrv/sbc/encoder/srce/sbc_enc_coeffs.c41
-rw-r--r--embdrv/sbc/encoder/srce/sbc_encoder.c133
-rw-r--r--embdrv/sbc/encoder/srce/sbc_packing.c68
13 files changed, 460 insertions, 308 deletions
diff --git a/embdrv/sbc/encoder/include/sbc_dct.h b/embdrv/sbc/encoder/include/sbc_dct.h
index be077e2..245e65d 100644
--- a/embdrv/sbc/encoder/include/sbc_dct.h
+++ b/embdrv/sbc/encoder/include/sbc_dct.h
@@ -1,13 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Definitions for the fast DCT.
+ *
+ ******************************************************************************/
#ifndef SBC_DCT_H
#define SBC_DCT_H
diff --git a/embdrv/sbc/encoder/include/sbc_enc_func_declare.h b/embdrv/sbc/encoder/include/sbc_enc_func_declare.h
index cfe5777..2ac34ff 100644
--- a/embdrv/sbc/encoder/include/sbc_enc_func_declare.h
+++ b/embdrv/sbc/encoder/include/sbc_enc_func_declare.h
@@ -1,15 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Function declarations.
+ *
+ ******************************************************************************/
#ifndef SBC_FUNCDECLARE_H
#define SBC_FUNCDECLARE_H
diff --git a/embdrv/sbc/encoder/include/sbc_encoder.h b/embdrv/sbc/encoder/include/sbc_encoder.h
index b348de8..78ed044 100644
--- a/embdrv/sbc/encoder/include/sbc_encoder.h
+++ b/embdrv/sbc/encoder/include/sbc_encoder.h
@@ -1,22 +1,33 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains constants and structures used by Encoder.
+ *
+ ******************************************************************************/
#ifndef SBC_ENCODER_H
#define SBC_ENCODER_H
#define ENCODER_VERSION "0025"
-
-#ifdef BUILDCFG
+
+#ifdef BUILDCFG
#include "bt_target.h"
#endif
@@ -60,7 +71,7 @@
#define SBC_MAX_NUM_FRAME 1
#endif
-#ifndef SBC_DSP_OPT
+#ifndef SBC_DSP_OPT
#define SBC_DSP_OPT FALSE
#endif
@@ -101,7 +112,7 @@
/* -> 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
+#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 */
@@ -126,7 +137,7 @@
#endif
#define MINIMUM_ENC_VX_BUFFER_SIZE (8*10*2)
-#ifndef ENC_VX_BUFFER_SIZE
+#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
@@ -148,7 +159,7 @@ typedef struct SBC_ENC_PARAMS_TAG
SINT16 s16NumOfChannels;
SINT16 s16NumOfBlocks; /* 4, 8, 12 or 16*/
SINT16 s16AllocationMethod; /* loudness or SNR*/
- SINT16 s16BitPool; /* 16*numOfSb for mono & dual;
+ 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 */
diff --git a/embdrv/sbc/encoder/include/sbc_if.h b/embdrv/sbc/encoder/include/sbc_if.h
index 7e4c2c5..de8dd48 100644
--- a/embdrv/sbc/encoder/include/sbc_if.h
+++ b/embdrv/sbc/encoder/include/sbc_if.h
@@ -1,3 +1,21 @@
+/******************************************************************************
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
#ifndef _SBC_IF_H
#define _SBC_IF_H
@@ -24,5 +42,6 @@ int SBC_init(int pcm_sample_freq, int channels, int bits_per_sample);
return - number of bytes written to sbc_out
*/
-int SBC_write(unsigned char *pcm_in, int length, unsigned char *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
index 531bb2c..d161051 100644
--- a/embdrv/sbc/encoder/include/sbc_types.h
+++ b/embdrv/sbc/encoder/include/sbc_types.h
@@ -1,15 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Data type declarations.
+ *
+ ******************************************************************************/
#ifndef SBC_TYPES_H
#define SBC_TYPES_H
diff --git a/embdrv/sbc/encoder/srce/sbc_analysis.c b/embdrv/sbc/encoder/srce/sbc_analysis.c
index 77f4dbe..95079fa 100644
--- a/embdrv/sbc/encoder/srce/sbc_analysis.c
+++ b/embdrv/sbc/encoder/srce/sbc_analysis.c
@@ -1,16 +1,27 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the code that performs Analysis of the input audio
+ * stream.
+ *
+ ******************************************************************************/
#include <string.h>
#include "sbc_encoder.h"
#include "sbc_enc_func_declare.h"
@@ -64,7 +75,7 @@
#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_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 */
@@ -72,7 +83,7 @@
#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_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 */
@@ -126,7 +137,7 @@
#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_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 */
@@ -134,7 +145,7 @@
#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_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 */
@@ -147,7 +158,7 @@
#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*/
+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
@@ -951,17 +962,17 @@ void SbcAnalysisFilter4(SBC_ENC_PARAMS *pstrEncParams)
for (s32Ch=0;s32Ch<s32NumOfChannels;s32Ch++)
{
ChOffset=s32Ch*Offset2+Offset;
-
- WINDOW_PARTIAL_4
-
+
+ WINDOW_PARTIAL_4
+
SBC_FastIDCT4(s32DCTY, ps32SbBuf);
-
+
ps32SbBuf +=SUB_BANDS_4;
}
if (s32NumOfChannels==1)
{
if (ShiftCounter>=EncMaxShiftCounter)
- {
+ {
SHIFTUP_X4;
ShiftCounter=0;
}
@@ -973,7 +984,7 @@ void SbcAnalysisFilter4(SBC_ENC_PARAMS *pstrEncParams)
else
{
if (ShiftCounter>=EncMaxShiftCounter)
- {
+ {
SHIFTUP_X4_2;
ShiftCounter=0;
}
@@ -1055,17 +1066,17 @@ void SbcAnalysisFilter8 (SBC_ENC_PARAMS *pstrEncParams)
for (s32Ch=0;s32Ch<s32NumOfChannels;s32Ch++)
{
ChOffset=s32Ch*Offset2+Offset;
-
- WINDOW_PARTIAL_8
-
+
+ WINDOW_PARTIAL_8
+
SBC_FastIDCT8 (s32DCTY, ps32SbBuf);
-
+
ps32SbBuf +=SUB_BANDS_8;
}
if (s32NumOfChannels==1)
{
if (ShiftCounter>=EncMaxShiftCounter)
- {
+ {
SHIFTUP_X8;
ShiftCounter=0;
}
@@ -1077,7 +1088,7 @@ void SbcAnalysisFilter8 (SBC_ENC_PARAMS *pstrEncParams)
else
{
if (ShiftCounter>=EncMaxShiftCounter)
- {
+ {
SHIFTUP_X8_2;
ShiftCounter=0;
}
@@ -1086,7 +1097,7 @@ void SbcAnalysisFilter8 (SBC_ENC_PARAMS *pstrEncParams)
ShiftCounter+=SUB_BANDS_8;
}
}
- }
+ }
}
void SbcAnalysisInit (void)
diff --git a/embdrv/sbc/encoder/srce/sbc_dct.c b/embdrv/sbc/encoder/srce/sbc_dct.c
index 0ff7f1f..0f6c9d3 100644
--- a/embdrv/sbc/encoder/srce/sbc_dct.c
+++ b/embdrv/sbc/encoder/srce/sbc_dct.c
@@ -1,15 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * source file for fast dct operations
+ *
+ ******************************************************************************/
#include "sbc_encoder.h"
#include "sbc_enc_func_declare.h"
@@ -22,10 +33,10 @@
** Function SBC_FastIDCT8
**
** Description implementation of fast DCT algorithm by Feig and Winograd
-**
+**
**
** Returns y = dct(pInVect)
-**
+**
**
*******************************************************************************/
@@ -86,66 +97,66 @@ void SBC_FastIDCT8(SINT32 *pInVect, SINT32 *pOutVect)
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 ;
+
+ /* 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) */
+
+ /* 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) */
+ 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 ;
+ 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 ;
+ 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 */
+
+ /* 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) */
+ temp = x1 ;
+ x1 = x1 + x5 ;
+ x5 = temp - x5 ;
+
+ /* rearrangement of x3 and x7 as in (15) */
x3 -= x7;
- x7 <<= 1 ;
+ 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 ;
+
+ /* 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_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 ]) ;
+
+ /* 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;
@@ -171,16 +182,16 @@ void SBC_FastIDCT8(SINT32 *pInVect, SINT32 *pOutVect)
** 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)
+#if (SBC_ARM_ASM_OPT==TRUE)
#else
#if (SBC_IPAQ_OPT==TRUE)
#if (SBC_IS_64_MULT_IN_IDCT == TRUE)
@@ -211,10 +222,10 @@ void SBC_FastIDCT4(SINT32 *pInVect, SINT32 *pOutVect)
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]);
+ 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;
@@ -229,6 +240,6 @@ void SBC_FastIDCT4(SINT32 *pInVect, SINT32 *pOutVect)
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
index 03f632f..c450c27 100644
--- a/embdrv/sbc/encoder/srce/sbc_dct_coeffs.c
+++ b/embdrv/sbc/encoder/srce/sbc_dct_coeffs.c
@@ -1,21 +1,32 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the coefficient table used for DCT computation in
+ * analysis.
+ *
+ ******************************************************************************/
#include "sbc_encoder.h"
/*DCT coeff for 4 sub-band case.*/
#if (SBC_FAST_DCT == FALSE)
-const SINT16 gas16AnalDCTcoeff4[] =
+const SINT16 gas16AnalDCTcoeff4[] =
{
(SINT16)(0.7071*32768),
(SINT16)(0.9239*32768),
@@ -55,7 +66,7 @@ const SINT16 gas16AnalDCTcoeff4[] =
};
/*DCT coeff for 8 sub-band case.*/
-const SINT16 gas16AnalDCTcoeff8[] =
+const SINT16 gas16AnalDCTcoeff8[] =
{
(SINT16)(0.7071*32768),
(SINT16)(0.8315*32768),
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c
index c8b13a9..c033e24 100644
--- a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c
+++ b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c
@@ -1,32 +1,43 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the code for bit allocation algorithm. It calculates
+ * the number of bits required for the encoded stream of data.
+ *
+ ******************************************************************************/
/*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},
+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},
+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},
{-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.
+* and the number of subbands.
*
* RETURNS : N/A
*/
@@ -78,8 +89,8 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
*(ps16GenBufPtr) = -5;
else
{
- s32Loudness =
- (SINT32)(pstrCodecParams->as16ScaleFactor[s32Ch*s32NumOfSubBands+s32Sb]
+ s32Loudness =
+ (SINT32)(pstrCodecParams->as16ScaleFactor[s32Ch*s32NumOfSubBands+s32Sb]
- *ps16GenTabPtr);
if(s32Loudness > 0)
*(ps16GenBufPtr) = (SINT16)(s32Loudness >>1);
@@ -89,7 +100,7 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
ps16GenBufPtr++;
ps16GenTabPtr++;
}
-
+
}
/* max bitneed index is searched*/
@@ -112,7 +123,7 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
s32BitSlice --;
s32BitCount -= s32SliceCount;
s32SliceCount = 0;
-
+
for(s32Sb=0; s32Sb<s32NumOfSubBands; s32Sb++)
{
if( (((*ps16GenBufPtr-s32BitSlice)< 16) && (*ps16GenBufPtr-s32BitSlice) >= 1))
@@ -123,17 +134,17 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
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;
@@ -142,7 +153,7 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
if(*(ps16GenBufPtr) < s32BitSlice+2)
*(ps16GenArrPtr) = 0;
else
- *(ps16GenArrPtr) = ((*(ps16GenBufPtr)-s32BitSlice)<16) ?
+ *(ps16GenArrPtr) = ((*(ps16GenBufPtr)-s32BitSlice)<16) ?
(SINT16)(*(ps16GenBufPtr)-s32BitSlice) : 16;
ps16GenBufPtr++;
@@ -159,7 +170,7 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
(*(ps16GenArrPtr))++;
s32BitCount--;
}
- else if( (*(ps16GenBufPtr) == s32BitSlice+1) &&
+ else if( (*(ps16GenBufPtr) == s32BitSlice+1) &&
(s32BitCount > 1) )
{
*(ps16GenArrPtr) = 2;
@@ -170,8 +181,8 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
ps16GenBufPtr++;
}
ps16GenArrPtr = pstrCodecParams->as16Bits+s32Ch*s32NumOfSubBands;
-
-
+
+
s32Sb=0;
while( (s32BitCount > 0) && (s32Sb < s32NumOfSubBands) )
{
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c
index cbcb809..75d1630 100644
--- a/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c
+++ b/embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c
@@ -1,16 +1,27 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the code for bit allocation algorithm. It calculates
+ * the number of bits required for the encoded stream of data.
+ *
+ ******************************************************************************/
/*Includes*/
#include "sbc_encoder.h"
@@ -22,7 +33,7 @@ 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.
+* and the number of subbands.
*
* RETURNS : N/A
*/
@@ -101,7 +112,7 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
s32BitCount -= s32SliceCount;
s32SliceCount = 0;
ps16GenBufPtr = ps16BitNeed;
-
+
for (s32Sb = 0; s32Sb < 2*s32NumOfSubBands; s32Sb++)
{
if ( (*ps16GenBufPtr >= s32BitSlice + 1) && (*ps16GenBufPtr < s32BitSlice + 16) )
@@ -131,7 +142,7 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
if (*ps16GenBufPtr < s32BitSlice+2)
*ps16GenArrPtr = 0;
else
- *ps16GenArrPtr = ((*(ps16GenBufPtr)-s32BitSlice) < 16) ?
+ *ps16GenArrPtr = ((*(ps16GenBufPtr)-s32BitSlice) < 16) ?
(SINT16)(*(ps16GenBufPtr)-s32BitSlice):16;
ps16GenBufPtr++;
ps16GenArrPtr++;
@@ -162,7 +173,7 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
s32Sb++;
ps16GenBufPtr = ps16BitNeed+s32Sb;
ps16GenArrPtr = pstrCodecParams->as16Bits+s32Sb;
-
+
}
else
{
diff --git a/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c b/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c
index 48cc22f..2ecfbfd 100644
--- a/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c
+++ b/embdrv/sbc/encoder/srce/sbc_enc_coeffs.c
@@ -1,22 +1,33 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains the Windowing coeffs for synthesis filter
+ *
+ ******************************************************************************/
#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[] =
+const SINT16 gas32CoeffFor4SBs[] =
{
(SINT16)((SINT32)0x00000000 >> 16), (SINT16)0x00000000,
(SINT16)((SINT32)0x001194E6 >> 16), (SINT16)0x001194E6,
@@ -65,7 +76,7 @@ const SINT16 gas32CoeffFor4SBs[] =
};
/*Window coeff for 8 sub band case*/
-const SINT16 gas32CoeffFor8SBs[] =
+const SINT16 gas32CoeffFor8SBs[] =
{
(SINT16)((SINT32)0x00000000 >>16), (SINT16)0x00000000,
(SINT16)((SINT32)0x00052173 >>16), (SINT16)0x00052173,
@@ -161,7 +172,7 @@ const SINT16 gas32CoeffFor8SBs[] =
#else
/*Window coeff for 4 sub band case*/
-const SINT32 gas32CoeffFor4SBs[] =
+const SINT32 gas32CoeffFor4SBs[] =
{
(SINT32)0x00000000,
(SINT32)0x001194E6,
@@ -210,7 +221,7 @@ const SINT32 gas32CoeffFor4SBs[] =
};
/*Window coeff for 8 sub band case*/
-const SINT32 gas32CoeffFor8SBs[] =
+const SINT32 gas32CoeffFor8SBs[] =
{
(SINT32)0x00000000,
(SINT32)0x00052173,
diff --git a/embdrv/sbc/encoder/srce/sbc_encoder.c b/embdrv/sbc/encoder/srce/sbc_encoder.c
index ce7dbb9..f111ed0 100644
--- a/embdrv/sbc/encoder/srce/sbc_encoder.c
+++ b/embdrv/sbc/encoder/srce/sbc_encoder.c
@@ -1,15 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * contains code for encoder flow and initalization of encoder
+ *
+ ******************************************************************************/
#include <string.h>
#include "sbc_encoder.h"
@@ -47,7 +58,7 @@ SINT16 EncMaxShiftCounter;
*
* if(index > 0)
* {
- * p = &u8frame[base_index];
+ * p = &u8frame[base_index];
* if((index&1)&&(u16PacketLength > (base_index+index*2)))
* {
* // odd index: swap 2 bytes
@@ -108,7 +119,7 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
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*/
@@ -122,7 +133,7 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
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)
@@ -131,19 +142,19 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
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;
@@ -154,16 +165,16 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
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;
}
@@ -209,30 +220,30 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
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 = *pSum;
*(SbBuffer+s32NumOfSubBands) = *pDiff;
-
- SbBuffer += s32NumOfSubBands<<1;
+
+ SbBuffer += s32NumOfSubBands<<1;
pSum++;
pDiff++;
}
-
+
pstrEncParams->as16Join[s32Sb] = 1;
}
else
@@ -241,18 +252,18 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
}
ps16ScfL++;
}
- pstrEncParams->as16Join[s32Sb] = 0;
+ 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 */
@@ -270,9 +281,9 @@ void SBC_Encoder(SBC_ENC_PARAMS *pstrEncParams)
SBC_PRTC_SCRMB((&pu8[sbc_prtc_cb.base]));
}
while(--(pstrEncParams->u8NumPacketToEncode));
-
+
pstrEncParams->u8NumPacketToEncode = 1; /* default is one for retrocompatibility purpose */
-
+
}
/****************************************************************************
@@ -295,7 +306,7 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams)
pstrEncParams->s16NumOfChannels = 1;
else
pstrEncParams->s16NumOfChannels = 2;
-
+
/* Bit pool calculation */
if (pstrEncParams->s16SamplingFreq == SBC_sf16000)
s16SamplingFreq = 16000;
@@ -305,31 +316,31 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams)
s16SamplingFreq = 44100;
else
s16SamplingFreq = 48000;
-
+
if ( (pstrEncParams->s16ChannelMode == SBC_JOINT_STEREO)
|| (pstrEncParams->s16ChannelMode == SBC_STEREO) )
{
- s16Bitpool = (SINT16)( (pstrEncParams->u16BitRate *
+ s16Bitpool = (SINT16)( (pstrEncParams->u16BitRate *
pstrEncParams->s16NumOfSubBands * 1000 / s16SamplingFreq)
- -( (32 + (4 * pstrEncParams->s16NumOfSubBands *
+ -( (32 + (4 * pstrEncParams->s16NumOfSubBands *
pstrEncParams->s16NumOfChannels)
- + ( (pstrEncParams->s16ChannelMode - 2) *
+ + ( (pstrEncParams->s16ChannelMode - 2) *
pstrEncParams->s16NumOfSubBands ) )
/ pstrEncParams->s16NumOfBlocks) );
-
+
s16FrameLen = 4 + (4*pstrEncParams->s16NumOfSubBands*
pstrEncParams->s16NumOfChannels)/8
- + ( ((pstrEncParams->s16ChannelMode - 2) *
- pstrEncParams->s16NumOfSubBands)
+ + ( ((pstrEncParams->s16ChannelMode - 2) *
+ pstrEncParams->s16NumOfSubBands)
+ (pstrEncParams->s16NumOfBlocks * s16Bitpool) ) / 8;
-
- s16BitRate = (8 * s16FrameLen * s16SamplingFreq)
- / (pstrEncParams->s16NumOfSubBands *
+
+ 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
@@ -337,34 +348,34 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams)
}
else
{
- s16Bitpool = (SINT16)( ((pstrEncParams->s16NumOfSubBands *
+ s16Bitpool = (SINT16)( ((pstrEncParams->s16NumOfSubBands *
pstrEncParams->u16BitRate * 1000)
/ (s16SamplingFreq * pstrEncParams->s16NumOfChannels))
- -( ( (32 / pstrEncParams->s16NumOfChannels) +
+ -( ( (32 / pstrEncParams->s16NumOfChannels) +
(4 * pstrEncParams->s16NumOfSubBands) )
/ pstrEncParams->s16NumOfBlocks ) );
-
- pstrEncParams->s16BitPool = (s16Bitpool >
+
+ pstrEncParams->s16BitPool = (s16Bitpool >
(16 * pstrEncParams->s16NumOfSubBands))
? (16*pstrEncParams->s16NumOfSubBands) : s16Bitpool;
}
-
+
if (pstrEncParams->s16BitPool < 0)
pstrEncParams->s16BitPool = 0;
/* sampling freq */
- HeaderParams = ((pstrEncParams->s16SamplingFreq & 3)<< 6);
-
+ HeaderParams = ((pstrEncParams->s16SamplingFreq & 3)<< 6);
+
/* number of blocks*/
HeaderParams |= (((pstrEncParams->s16NumOfBlocks -4) & 12) << 2);
-
+
/* channel mode: mono, dual...*/
- HeaderParams |= ((pstrEncParams->s16ChannelMode & 3)<< 2);
-
+ 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)
@@ -379,8 +390,8 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams)
else
EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-8*10*2)>>4)<<3;
}
-
- APPL_TRACE_EVENT2("SBC_Encoder_Init : bitrate %d, bitpool %d",
+
+ APPL_TRACE_EVENT2("SBC_Encoder_Init : bitrate %d, bitpool %d",
pstrEncParams->u16BitRate, pstrEncParams->s16BitPool);
SbcAnalysisInit();
diff --git a/embdrv/sbc/encoder/srce/sbc_packing.c b/embdrv/sbc/encoder/srce/sbc_packing.c
index 55edb9b..bdbefea 100644
--- a/embdrv/sbc/encoder/srce/sbc_packing.c
+++ b/embdrv/sbc/encoder/srce/sbc_packing.c
@@ -1,16 +1,26 @@
/******************************************************************************
-**
-** 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.
-**
-******************************************************************************/
+ *
+ * Copyright (C) 1999-2012 Broadcom Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * This file contains code for packing the Encoded data into bit streams.
+ *
+ ******************************************************************************/
#include "sbc_encoder.h"
#include "sbc_enc_func_declare.h"
@@ -22,7 +32,7 @@
{ \
MUL s32OutLow,s32In1,s32In2; \
} \
-}
+}
#define Mult64(s32In1, s32In2, s32OutLow, s32OutHi) \
{ \
__asm \
@@ -74,7 +84,7 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
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*/
@@ -103,7 +113,7 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
}
}
#endif
-
+
/* Pack Scale factor */
ps16GenPtr = pstrEncParams->as16ScaleFactor;
s32Sb=s32NumOfChannels*s32NumOfSubBands;
@@ -112,10 +122,10 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
{
Temp<<= 4;
Temp |= *ps16GenPtr++;
-
+
if(s32PresentBit == 4)
{
- s32PresentBit = 8;
+ s32PresentBit = 8;
*(pu8PacketPtr++)=Temp;
Temp = 0;
}
@@ -124,7 +134,7 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
s32PresentBit = 4;
}
}
-
+
/* Pack samples */
ps32SbPtr = pstrEncParams->s32SbBuffer;
/*Temp=*pu8PacketPtr;*/
@@ -165,10 +175,10 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
s32Low>>= (*ps16ScfPtr+1);
u32QuantizedSbValue0 = (UINT16)s32Low;
#endif
- /*store the number of bits required and the quantized s32Sb
+ /*store the number of bits required and the quantized s32Sb
sample to ease the coding*/
u32QuantizedSbValue = u32QuantizedSbValue0;
-
+
if(s32PresentBit >= s32LoopCount)
{
Temp <<= s32LoopCount;
@@ -181,33 +191,33 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
{
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++;
+ ps16ScfPtr++;
ps32SbPtr++;
}
}
@@ -221,7 +231,7 @@ void EncPacking(SBC_ENC_PARAMS *pstrEncParams)
s32LoopCount = s32Sb >> 1;
/*
- The loops is run from the start of the packet till the scale factor
+ 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.
*/