Smart Remote 3 nRF52 v1.2
sbc_encoder.h
1 /******************************************************************************
2  *
3  * Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  * This file contains constants and structures used by Encoder.
22  *
23  ******************************************************************************/
24 
25 #ifndef SBC_ENCODER_H
26 #define SBC_ENCODER_H
27 
28 #define ENCODER_VERSION "0025"
29 
30 #ifdef BUILDCFG
31  #include "bt_target.h"
32 #endif
33 
34 /*DEFINES*/
35 #ifndef FALSE
36 #define FALSE 0
37 #endif
38 
39 #ifndef TRUE
40 #define TRUE (!FALSE)
41 #endif
42 
43 /* BK4BTSTACK_CHANGE START */
44 #define SBC_NO_PCM_CPY_OPTION TRUE
45 /* BK4BTSTACK_CHANGE END */
46 
47 /* Added for Smart Remote 3 nRF52 */
48 #define SBC_JOINT_STE_INCLUDED FALSE
49 
50 #define SBC_MAX_NUM_OF_SUBBANDS 8
51 /* Changed for Smart Remote 3 nRF52 (was: 2) */
52 #define SBC_MAX_NUM_OF_CHANNELS 1
53 #define SBC_MAX_NUM_OF_BLOCKS 16
54 
55 #define SBC_LOUDNESS 0
56 #define SBC_SNR 1
57 
58 #define SUB_BANDS_8 8
59 #define SUB_BANDS_4 4
60 
61 #define SBC_sf16000 0
62 #define SBC_sf32000 1
63 #define SBC_sf44100 2
64 #define SBC_sf48000 3
65 
66 #define SBC_MONO 0
67 #define SBC_DUAL 1
68 #define SBC_STEREO 2
69 #define SBC_JOINT_STEREO 3
70 
71 #define SBC_BLOCK_0 4
72 #define SBC_BLOCK_1 8
73 #define SBC_BLOCK_2 12
74 #define SBC_BLOCK_3 16
75 
76 #define SBC_NULL 0
77 
78 #ifndef SBC_MAX_NUM_FRAME
79 #define SBC_MAX_NUM_FRAME 1
80 #endif
81 
82 #ifndef SBC_DSP_OPT
83 #define SBC_DSP_OPT FALSE
84 #endif
85 
86 /* Set SBC_USE_ARM_PRAGMA to TRUE to use "#pragma arm section zidata" */
87 #ifndef SBC_USE_ARM_PRAGMA
88 #define SBC_USE_ARM_PRAGMA FALSE
89 #endif
90 
91 /* Set SBC_ARM_ASM_OPT to TRUE in case the target is an ARM */
92 /* this will replace all the 32 and 64 bit mult by in line assembly code */
93 #ifndef SBC_ARM_ASM_OPT
94 #define SBC_ARM_ASM_OPT FALSE
95 #endif
96 
97 /* green hill compiler option -> Used to distinguish the syntax for inline assembly code*/
98 #ifndef SBC_GHS_COMPILER
99 #define SBC_GHS_COMPILER FALSE
100 #endif
101 
102 /* ARM compiler option -> Used to distinguish the syntax for inline assembly code */
103 #ifndef SBC_ARM_COMPILER
104 #define SBC_ARM_COMPILER TRUE
105 #endif
106 
107 /* Set SBC_IPAQ_OPT to TRUE in case the target is an ARM */
108 /* 32 and 64 bit mult will be performed using SINT64 ( usualy __int64 ) cast that usualy give optimal performance if supported */
109 #ifndef SBC_IPAQ_OPT
110 #define SBC_IPAQ_OPT TRUE
111 #endif
112 
113 /* Debug only: set SBC_IS_64_MULT_IN_WINDOW_ACCU to TRUE to use 64 bit multiplication in the windowing */
114 /* -> not recomended, more MIPS for the same restitution. */
115 #ifndef SBC_IS_64_MULT_IN_WINDOW_ACCU
116 #define SBC_IS_64_MULT_IN_WINDOW_ACCU FALSE
117 #endif /*SBC_IS_64_MULT_IN_WINDOW_ACCU */
118 
119 /* Set SBC_IS_64_MULT_IN_IDCT to TRUE to use 64 bits multiplication in the DCT of Matrixing */
120 /* -> more MIPS required for a better audio quality. comparasion with the SIG utilities shows a division by 10 of the RMS */
121 /* CAUTION: It only apply in the if SBC_FAST_DCT is set to TRUE */
122 #ifndef SBC_IS_64_MULT_IN_IDCT
123 #define SBC_IS_64_MULT_IN_IDCT FALSE
124 #endif /*SBC_IS_64_MULT_IN_IDCT */
125 
126 /* set SBC_IS_64_MULT_IN_QUANTIZER to TRUE to use 64 bits multiplication in the quantizer */
127 /* setting this flag to FALSE add whistling noise at 5.5 and 11 KHz usualy not perceptible by human's hears. */
128 #ifndef SBC_IS_64_MULT_IN_QUANTIZER
129 #define SBC_IS_64_MULT_IN_QUANTIZER TRUE
130 #endif /*SBC_IS_64_MULT_IN_IDCT */
131 
132 /* Debug only: set this flag to FALSE to disable fast DCT algorithm */
133 #ifndef SBC_FAST_DCT
134 #define SBC_FAST_DCT TRUE
135 #endif /*SBC_FAST_DCT */
136 
137 /* In case we do not use joint stereo mode the flag save some RAM and ROM in case it is set to FALSE */
138 #ifndef SBC_JOINT_STE_INCLUDED
139 #define SBC_JOINT_STE_INCLUDED TRUE
140 #endif
141 
142 /* TRUE -> application should provide PCM buffer, FALSE PCM buffer reside in SBC_ENC_PARAMS */
143 #ifndef SBC_NO_PCM_CPY_OPTION
144 #define SBC_NO_PCM_CPY_OPTION FALSE
145 #endif
146 
147 #define MINIMUM_ENC_VX_BUFFER_SIZE (8*10*2)
148 #ifndef ENC_VX_BUFFER_SIZE
149 #define ENC_VX_BUFFER_SIZE (MINIMUM_ENC_VX_BUFFER_SIZE + 64)
150 /*#define ENC_VX_BUFFER_SIZE MINIMUM_ENC_VX_BUFFER_SIZE + 1024*/
151 #endif
152 
153 #ifndef SBC_FOR_EMBEDDED_LINUX
154 #define SBC_FOR_EMBEDDED_LINUX FALSE
155 #endif
156 
157 /*constants used for index calculation*/
158 #define SBC_BLK (SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS)
159 
160 #include "sbc_types.h"
161 
162 typedef struct SBC_ENC_PARAMS_TAG
163 {
164  SINT16 s16SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
165  SINT16 s16ChannelMode; /* mono, dual, streo or joint streo*/
166  SINT16 s16NumOfSubBands; /* 4 or 8 */
167  SINT16 s16NumOfChannels;
168  SINT16 s16NumOfBlocks; /* SBC: 4, 8, 12 or 16; mSBC: 15*/
169  SINT16 s16AllocationMethod; /* loudness or SNR*/
170  SINT16 s16BitPool; /* 16*numOfSb for mono & dual;
171  32*numOfSb for stereo & joint stereo */
172  /* BK4BTSTACK_CHANGE START */
173  // UINT16 u16BitRate;
174  /* BK4BTSTACK_CHANGE END */
175  UINT8 u8NumPacketToEncode; /* number of sbc frame to encode. Default is 1 */
176 #if (SBC_JOINT_STE_INCLUDED == TRUE)
177  SINT16 as16Join[SBC_MAX_NUM_OF_SUBBANDS]; /*1 if JS, 0 otherwise*/
178 #endif
179 
180  SINT16 s16MaxBitNeed;
181  SINT16 as16ScaleFactor[SBC_MAX_NUM_OF_CHANNELS*SBC_MAX_NUM_OF_SUBBANDS];
182 
183  SINT16 *ps16NextPcmBuffer;
184 #if (SBC_NO_PCM_CPY_OPTION == TRUE)
185  SINT16 *ps16PcmBuffer;
186 #else
187  SINT16 as16PcmBuffer[SBC_MAX_NUM_FRAME*SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS];
188 #endif
189 
190  SINT16 s16ScartchMemForBitAlloc[16];
191 
192  SINT32 s32SbBuffer[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * SBC_MAX_NUM_OF_BLOCKS];
193 
194  SINT16 as16Bits[SBC_MAX_NUM_OF_CHANNELS*SBC_MAX_NUM_OF_SUBBANDS];
195 
196  UINT8 *pu8Packet;
197  UINT8 *pu8NextPacket;
198  UINT16 FrameHeader;
199  UINT16 u16PacketLength;
200  /* BK4BTSTACK_CHANGE START */
201  UINT8 mSBCEnabled;
202  /* BK4BTSTACK_CHANGE END */
203 }SBC_ENC_PARAMS;
204 
205 #ifdef __cplusplus
206 extern "C"
207 {
208 #endif
209 SBC_API extern void SBC_Encoder(SBC_ENC_PARAMS *strEncParams);
210 SBC_API extern void SBC_Encoder_Init(SBC_ENC_PARAMS *strEncParams);
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif

Documentation feedback | Developer Zone | Subscribe | Updated