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