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 "common/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 #define SBC_MAX_NUM_OF_SUBBANDS 8 44 #define SBC_MAX_NUM_OF_CHANNELS 2 45 #define SBC_MAX_NUM_OF_BLOCKS 16 46 47 #define SBC_LOUDNESS 0 48 #define SBC_SNR 1 49 50 #define SUB_BANDS_8 8 51 #define SUB_BANDS_4 4 52 53 #define SBC_sf16000 0 54 #define SBC_sf32000 1 55 #define SBC_sf44100 2 56 #define SBC_sf48000 3 57 58 #define SBC_MONO 0 59 #define SBC_DUAL 1 60 #define SBC_STEREO 2 61 #define SBC_JOINT_STEREO 3 62 63 #define SBC_BLOCK_0 4 64 #define SBC_BLOCK_1 8 65 #define SBC_BLOCK_2 12 66 #define SBC_BLOCK_3 16 67 68 #define SBC_NULL 0 69 70 #define SBC_MODE_STD 0 71 #define SBC_MODE_MSBC 1 72 73 #define SBC_SYNC_WORD_STD (0x9C) 74 #define SBC_SYNC_WORD_MSBC (0xAD) 75 76 #ifndef SBC_MAX_NUM_FRAME 77 #define SBC_MAX_NUM_FRAME 1 78 #endif 79 80 #ifndef SBC_DSP_OPT 81 #define SBC_DSP_OPT FALSE 82 #endif 83 84 /* Set SBC_USE_ARM_PRAGMA to TRUE to use "#pragma arm section zidata" */ 85 #ifndef SBC_USE_ARM_PRAGMA 86 #define SBC_USE_ARM_PRAGMA FALSE 87 #endif 88 89 /* Set SBC_ARM_ASM_OPT to TRUE in case the target is an ARM */ 90 /* this will replace all the 32 and 64 bit mult by in line assembly code */ 91 #ifndef SBC_ARM_ASM_OPT 92 #define SBC_ARM_ASM_OPT FALSE 93 #endif 94 95 /* green hill compiler option -> Used to distinguish the syntax for inline assembly code*/ 96 #ifndef SBC_GHS_COMPILER 97 #define SBC_GHS_COMPILER FALSE 98 #endif 99 100 /* ARM compiler option -> Used to distinguish the syntax for inline assembly code */ 101 #ifndef SBC_ARM_COMPILER 102 #define SBC_ARM_COMPILER TRUE 103 #endif 104 105 /* Set SBC_IPAQ_OPT to TRUE in case the target is an ARM */ 106 /* 32 and 64 bit mult will be performed using SINT64 ( usualy __int64 ) cast that usualy give optimal performance if supported */ 107 #ifndef SBC_IPAQ_OPT 108 #define SBC_IPAQ_OPT TRUE 109 #endif 110 111 /* Debug only: set SBC_IS_64_MULT_IN_WINDOW_ACCU to TRUE to use 64 bit multiplication in the windowing */ 112 /* -> not recomended, more MIPS for the same restitution. */ 113 #ifndef SBC_IS_64_MULT_IN_WINDOW_ACCU 114 #define SBC_IS_64_MULT_IN_WINDOW_ACCU FALSE 115 #endif /*SBC_IS_64_MULT_IN_WINDOW_ACCU */ 116 117 /* Set SBC_IS_64_MULT_IN_IDCT to TRUE to use 64 bits multiplication in the DCT of Matrixing */ 118 /* -> more MIPS required for a better audio quality. comparasion with the SIG utilities shows a division by 10 of the RMS */ 119 /* CAUTION: It only apply in the if SBC_FAST_DCT is set to TRUE */ 120 #ifndef SBC_IS_64_MULT_IN_IDCT 121 #define SBC_IS_64_MULT_IN_IDCT FALSE 122 #endif /*SBC_IS_64_MULT_IN_IDCT */ 123 124 /* set SBC_IS_64_MULT_IN_QUANTIZER to TRUE to use 64 bits multiplication in the quantizer */ 125 /* setting this flag to FALSE add whistling noise at 5.5 and 11 KHz usualy not perceptible by human's hears. */ 126 #ifndef SBC_IS_64_MULT_IN_QUANTIZER 127 #define SBC_IS_64_MULT_IN_QUANTIZER TRUE 128 #endif /*SBC_IS_64_MULT_IN_IDCT */ 129 130 /* Debug only: set this flag to FALSE to disable fast DCT algorithm */ 131 #ifndef SBC_FAST_DCT 132 #define SBC_FAST_DCT TRUE 133 #endif /*SBC_FAST_DCT */ 134 135 /* In case we do not use joint stereo mode the flag save some RAM and ROM in case it is set to FALSE */ 136 #ifndef SBC_JOINT_STE_INCLUDED 137 #define SBC_JOINT_STE_INCLUDED TRUE 138 #endif 139 140 /* TRUE -> application should provide PCM buffer, FALSE PCM buffer reside in SBC_ENC_PARAMS */ 141 #ifndef SBC_NO_PCM_CPY_OPTION 142 #define SBC_NO_PCM_CPY_OPTION FALSE 143 #endif 144 145 #define MINIMUM_ENC_VX_BUFFER_SIZE (8*10*2) 146 #ifndef ENC_VX_BUFFER_SIZE 147 #define ENC_VX_BUFFER_SIZE (MINIMUM_ENC_VX_BUFFER_SIZE + 64) 148 /*#define ENC_VX_BUFFER_SIZE MINIMUM_ENC_VX_BUFFER_SIZE + 1024*/ 149 #endif 150 151 #ifndef SBC_FOR_EMBEDDED_LINUX 152 #define SBC_FOR_EMBEDDED_LINUX FALSE 153 #endif 154 155 /*constants used for index calculation*/ 156 #define SBC_BLK (SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS) 157 158 #include "sbc_types.h" 159 160 typedef struct SBC_ENC_PARAMS_TAG { 161 SINT16 s16SamplingFreq; /* 16k, 32k, 44.1k or 48k*/ 162 SINT16 s16ChannelMode; /* mono, dual, streo or joint streo*/ 163 SINT16 s16NumOfSubBands; /* 4 or 8 */ 164 SINT16 s16NumOfChannels; 165 SINT16 s16NumOfBlocks; /* 4, 8, 12 or 16*/ 166 SINT16 s16AllocationMethod; /* loudness or SNR*/ 167 SINT16 s16BitPool; /* 16*numOfSb for mono & dual; 168 32*numOfSb for stereo & joint stereo */ 169 UINT16 u16BitRate; 170 UINT8 sbc_mode; /* SBC_MODE_STD or SBC_MODE_MSBC */ 171 UINT8 u8NumPacketToEncode; /* number of sbc frame to encode. Default is 1 */ 172 #if (SBC_JOINT_STE_INCLUDED == TRUE) 173 SINT16 as16Join[SBC_MAX_NUM_OF_SUBBANDS]; /*1 if JS, 0 otherwise*/ 174 #endif 175 176 SINT16 s16MaxBitNeed; 177 SINT16 as16ScaleFactor[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; 178 179 SINT16 *ps16NextPcmBuffer; 180 #if (SBC_NO_PCM_CPY_OPTION == TRUE) 181 SINT16 *ps16PcmBuffer; 182 #else 183 SINT16 as16PcmBuffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS * SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; 184 #endif 185 186 SINT16 s16ScartchMemForBitAlloc[16]; 187 188 SINT32 s32SbBuffer[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * SBC_MAX_NUM_OF_BLOCKS]; 189 190 SINT16 as16Bits[SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS]; 191 192 UINT8 *pu8Packet; 193 UINT8 *pu8NextPacket; 194 UINT16 FrameHeader; 195 UINT16 u16PacketLength; 196 197 } SBC_ENC_PARAMS; 198 199 #ifdef __cplusplus 200 extern "C" 201 { 202 #endif 203 extern void SBC_Encoder(SBC_ENC_PARAMS *strEncParams); 204 extern void SBC_Encoder_Init(SBC_ENC_PARAMS *strEncParams); 205 #ifdef __cplusplus 206 } 207 #endif 208 #endif 209