diff options
author | Kausik Sinnaswamy <kausik@broadcom.com> | 2012-03-07 19:30:20 -0800 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:12 -0700 |
commit | 95fa11b3b2f19a382c7e3a744a6afb452fad86df (patch) | |
tree | 1019e123db4596f2b8bd1259da04b51f3c44d7b2 /embdrv/sbc/encoder/include | |
parent | e2197423bcf1a93c620be13d458a9da6693fa94d (diff) | |
download | external_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/sbc/encoder/include')
-rw-r--r-- | embdrv/sbc/encoder/include/sbc_dct.h | 78 | ||||
-rw-r--r-- | embdrv/sbc/encoder/include/sbc_enc_func_declare.h | 46 | ||||
-rw-r--r-- | embdrv/sbc/encoder/include/sbc_encoder.h | 191 | ||||
-rw-r--r-- | embdrv/sbc/encoder/include/sbc_if.h | 28 | ||||
-rw-r--r-- | embdrv/sbc/encoder/include/sbc_types.h | 46 |
5 files changed, 389 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 |