OSDN Git Service

sbc: Fix signedness of libsbc parameters
[android-x86/external-bluetooth-sbc.git] / sbc / sbc.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_H
28 #define __SBC_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #include <stdint.h>
35 #include <sys/types.h>
36
37 /* sampling frequency */
38 #define SBC_FREQ_16000          0x00
39 #define SBC_FREQ_32000          0x01
40 #define SBC_FREQ_44100          0x02
41 #define SBC_FREQ_48000          0x03
42
43 /* blocks */
44 #define SBC_BLK_4               0x00
45 #define SBC_BLK_8               0x01
46 #define SBC_BLK_12              0x02
47 #define SBC_BLK_16              0x03
48
49 /* channel mode */
50 #define SBC_MODE_MONO           0x00
51 #define SBC_MODE_DUAL_CHANNEL   0x01
52 #define SBC_MODE_STEREO         0x02
53 #define SBC_MODE_JOINT_STEREO   0x03
54
55 /* allocation method */
56 #define SBC_AM_LOUDNESS         0x00
57 #define SBC_AM_SNR              0x01
58
59 /* subbands */
60 #define SBC_SB_4                0x00
61 #define SBC_SB_8                0x01
62
63 /* Data endianess */
64 #define SBC_LE                  0x00
65 #define SBC_BE                  0x01
66
67 struct sbc_struct {
68         unsigned long flags;
69
70         uint8_t frequency;
71         uint8_t blocks;
72         uint8_t subbands;
73         uint8_t mode;
74         uint8_t allocation;
75         uint8_t bitpool;
76         uint8_t endian;
77
78         void *priv;
79         void *priv_alloc_base;
80 };
81
82 typedef struct sbc_struct sbc_t;
83
84 int sbc_init(sbc_t *sbc, unsigned long flags);
85 int sbc_reinit(sbc_t *sbc, unsigned long flags);
86
87 ssize_t sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
88
89 /* Decodes ONE input block into ONE output block */
90 ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
91                         void *output, size_t output_len, size_t *written);
92
93 /* Encodes ONE input block into ONE output block */
94 ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
95                         void *output, size_t output_len, ssize_t *written);
96
97 /* Returns the output block size in bytes */
98 size_t sbc_get_frame_length(sbc_t *sbc);
99
100 /* Returns the time one input/output block takes to play in msec*/
101 unsigned sbc_get_frame_duration(sbc_t *sbc);
102
103 /* Returns the input block size in bytes */
104 size_t sbc_get_codesize(sbc_t *sbc);
105
106 const char *sbc_get_implementation_info(sbc_t *sbc);
107 void sbc_finish(sbc_t *sbc);
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif /* __SBC_H */