Home | History | Annotate | Download | only in sbc
      1 /*
      2  *
      3  *  Bluetooth low-complexity, subband codec (SBC) library
      4  *
      5  *  Copyright (C) 2004-2009  Marcel Holtmann <marcel (at) holtmann.org>
      6  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk (at) ploetzli.ch>
      7  *  Copyright (C) 2005-2006  Brad Midgley <bmidgley (at) xmission.com>
      8  *
      9  *
     10  *  This library is free software; you can redistribute it and/or
     11  *  modify it under the terms of the GNU Lesser General Public
     12  *  License as published by the Free Software Foundation; either
     13  *  version 2.1 of the License, or (at your option) any later version.
     14  *
     15  *  This library is distributed in the hope that it will be useful,
     16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     18  *  Lesser General Public License for more details.
     19  *
     20  *  You should have received a copy of the GNU Lesser General Public
     21  *  License along with this library; if not, write to the Free Software
     22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     23  *
     24  */
     25 
     26 #ifndef __SBC_PRIMITIVES_H
     27 #define __SBC_PRIMITIVES_H
     28 
     29 #define SCALE_OUT_BITS 15
     30 #define SBC_X_BUFFER_SIZE 328
     31 
     32 #ifdef __GNUC__
     33 #define SBC_ALWAYS_INLINE __attribute__((always_inline))
     34 #else
     35 #define SBC_ALWAYS_INLINE inline
     36 #endif
     37 
     38 struct sbc_encoder_state {
     39 	int position;
     40 	int16_t SBC_ALIGNED X[2][SBC_X_BUFFER_SIZE];
     41 	/* Polyphase analysis filter for 4 subbands configuration,
     42 	 * it handles 4 blocks at once */
     43 	void (*sbc_analyze_4b_4s)(int16_t *x, int32_t *out, int out_stride);
     44 	/* Polyphase analysis filter for 8 subbands configuration,
     45 	 * it handles 4 blocks at once */
     46 	void (*sbc_analyze_4b_8s)(int16_t *x, int32_t *out, int out_stride);
     47 	/* Process input data (deinterleave, endian conversion, reordering),
     48 	 * depending on the number of subbands and input data byte order */
     49 	int (*sbc_enc_process_input_4s_le)(int position,
     50 			const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
     51 			int nsamples, int nchannels);
     52 	int (*sbc_enc_process_input_4s_be)(int position,
     53 			const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
     54 			int nsamples, int nchannels);
     55 	int (*sbc_enc_process_input_8s_le)(int position,
     56 			const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
     57 			int nsamples, int nchannels);
     58 	int (*sbc_enc_process_input_8s_be)(int position,
     59 			const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
     60 			int nsamples, int nchannels);
     61 	/* Scale factors calculation */
     62 	void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
     63 			uint32_t scale_factor[2][8],
     64 			int blocks, int channels, int subbands);
     65 	const char *implementation_info;
     66 };
     67 
     68 /*
     69  * Initialize pointers to the functions which are the basic "building bricks"
     70  * of SBC codec. Best implementation is selected based on target CPU
     71  * capabilities.
     72  */
     73 void sbc_init_primitives(struct sbc_encoder_state *encoder_state);
     74 
     75 #endif
     76