XenevaOS
Loading...
Searching...
No Matches
sbc.h
Go to the documentation of this file.
1
30#ifndef __BT_SBC_H__
31#define __BT_SBC_H__
32
33#include <stdint.h>
34
35/* Encode-only SBC for A2DP (Bluetooth Advanced Audio Distribution,
36 * Appendix B). Fixed production configuration, matching what every A2DP
37 * sink (including Sony ULT WEAR) accepts:
38 * joint stereo, 8 subbands, 16 blocks, Loudness allocation,
39 * 44.1 kHz or 48 kHz, configurable bitpool (53 = A2DP high quality).
40 *
41 * One frame carries 16 blocks x 8 subbands = 128 PCM samples per channel.
42 * At bitpool 53 a frame is 119 bytes (~328 kbit/s at 44.1 kHz).
43 *
44 * Filterbank, Loudness offsets, bit allocation, CRC and packing follow the
45 * A2DP spec as implemented by google/libsbc (Apache-2.0); only integer
46 * <stdint.h>/<string.h> operations are used so this compiles both in the
47 * kernel and in the host unit test. */
48#define SBC_NBLOCKS 16
49#define SBC_NSUBBANDS 8
50#define SBC_NSAMPLES (SBC_NBLOCKS * SBC_NSUBBANDS)
51#define SBC_MAX_FRAME 128
52#define SBC_FREQ_44100 0
53#define SBC_FREQ_48000 1
54
55typedef struct {
58 int idx;
59} BtSbcCh;
60
61typedef struct {
62 BtSbcCh ch[2];
63} BtSbcEnc;
64
65void bt_sbc_init(BtSbcEnc* e);
66/* Frame length in bytes for a bitpool, or 0 when the bitpool is invalid. */
67unsigned bt_sbc_frame_len(int bitpool);
68/* Encode 128 interleaved stereo frames (256 int16 samples, LRLR...).
69 * freq is SBC_FREQ_44100 or SBC_FREQ_48000. Returns frame bytes in out
70 * (SBC_MAX_FRAME available), or -1 on bad parameters. */
71int bt_sbc_encode(BtSbcEnc* e, const int16_t* interleaved, int bitpool, int freq,
72 uint8_t* out);
73
74#endif
#define out(...)
Definition main.cpp:65
int int32_t
Definition acefiex.h:160
short int int16_t
Definition acefiex.h:159
unsigned char uint8_t
Definition acefiex.h:161
int y
Definition layout.c:118
int x
Definition layout.c:118
int bt_sbc_encode(BtSbcEnc *e, const int16_t *interleaved, int bitpool, int freq, uint8_t *out)
Definition sbc.c:223
unsigned bt_sbc_frame_len(int bitpool)
Definition sbc.c:205
#define SBC_NSUBBANDS
Definition sbc.h:49
void bt_sbc_init(BtSbcEnc *e)
Definition sbc.c:201
Definition sbc.h:55
int idx
Definition sbc.h:58
Definition sbc.h:61