OSDN Git Service

sbc: Rename sbc_analyze_4b_xx to sbc_analyze_xx
[android-x86/external-bluetooth-sbc.git] / sbc / sbc_primitives.h
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 inline __attribute__((always_inline))
35 #else
36 #define SBC_ALWAYS_INLINE inline
37 #endif
38
39 struct sbc_encoder_state {
40         int position;
41         /* Number of consecutive blocks handled by the encoder */
42         uint8_t increment;
43         int16_t SBC_ALIGNED X[2][SBC_X_BUFFER_SIZE];
44         /* Polyphase analysis filter for 4 subbands configuration,
45          * it handles "increment" blocks at once */
46         void (*sbc_analyze_4s)(struct sbc_encoder_state *state,
47                         int16_t *x, int32_t *out, int out_stride);
48         /* Polyphase analysis filter for 8 subbands configuration,
49          * it handles "increment" blocks at once */
50         void (*sbc_analyze_8s)(struct sbc_encoder_state *state,
51                         int16_t *x, int32_t *out, int out_stride);
52         /* Process input data (deinterleave, endian conversion, reordering),
53          * depending on the number of subbands and input data byte order */
54         int (*sbc_enc_process_input_4s_le)(int position,
55                         const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
56                         int nsamples, int nchannels);
57         int (*sbc_enc_process_input_4s_be)(int position,
58                         const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
59                         int nsamples, int nchannels);
60         int (*sbc_enc_process_input_8s_le)(int position,
61                         const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
62                         int nsamples, int nchannels);
63         int (*sbc_enc_process_input_8s_be)(int position,
64                         const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE],
65                         int nsamples, int nchannels);
66         /* Scale factors calculation */
67         void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8],
68                         uint32_t scale_factor[2][8],
69                         int blocks, int channels, int subbands);
70         /* Scale factors calculation with joint stereo support */
71         int (*sbc_calc_scalefactors_j)(int32_t sb_sample_f[16][2][8],
72                         uint32_t scale_factor[2][8],
73                         int blocks, int subbands);
74         const char *implementation_info;
75 };
76
77 /*
78  * Initialize pointers to the functions which are the basic "building bricks"
79  * of SBC codec. Best implementation is selected based on target CPU
80  * capabilities.
81  */
82 void sbc_init_primitives(struct sbc_encoder_state *encoder_state);
83
84 #endif