2 * Bluetooth low-complexity, subband codec (SBC)
4 * Copyright (C) 2017 Aurelien Jacobs <aurel@gnuage.org>
5 * Copyright (C) 2012-2014 Intel Corporation
6 * Copyright (C) 2008-2010 Nokia Corporation
7 * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
8 * Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
9 * Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
11 * This file is part of FFmpeg.
13 * FFmpeg is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * FFmpeg is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with FFmpeg; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 * SBC common definitions for the encoder and decoder
37 #include "libavutil/crc.h"
39 #define MSBC_BLOCKS 15
41 /* sampling frequency */
42 #define SBC_FREQ_16000 0x00
43 #define SBC_FREQ_32000 0x01
44 #define SBC_FREQ_44100 0x02
45 #define SBC_FREQ_48000 0x03
48 #define SBC_BLK_4 0x00
49 #define SBC_BLK_8 0x01
50 #define SBC_BLK_12 0x02
51 #define SBC_BLK_16 0x03
54 #define SBC_MODE_MONO 0x00
55 #define SBC_MODE_DUAL_CHANNEL 0x01
56 #define SBC_MODE_STEREO 0x02
57 #define SBC_MODE_JOINT_STEREO 0x03
59 /* allocation method */
60 #define SBC_AM_LOUDNESS 0x00
61 #define SBC_AM_SNR 0x01
67 /* synchronisation words */
68 #define SBC_SYNCWORD 0x9C
69 #define MSBC_SYNCWORD 0xAD
71 /* extra bits of precision for the synthesis filter input data */
72 #define SBCDEC_FIXED_EXTRA_BITS 2
75 * Enforce 16 byte alignment for the data, which is supposed to be used
76 * with SIMD optimized code.
80 /* This structure contains an unpacked SBC frame.
81 Yes, there is probably quite some unused space herein */
87 DUAL_CHANNEL = SBC_MODE_DUAL_CHANNEL,
88 STEREO = SBC_MODE_STEREO,
89 JOINT_STEREO = SBC_MODE_JOINT_STEREO
93 LOUDNESS = SBC_AM_LOUDNESS,
100 /* bit number x set means joint stereo has been used in subband x */
103 /* only the lower 4 bits of every element are to be used */
104 DECLARE_ALIGNED(SBC_ALIGN, uint32_t, scale_factor)[2][8];
106 /* raw integer subband samples in the frame */
107 DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample_f)[16][2][8];
109 /* modified subband samples */
110 DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample)[16][2][8];
112 const AVCRC *crc_ctx;
115 uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len);
116 void ff_sbc_calculate_bits(const struct sbc_frame *frame, int (*bits)[8]);
118 #endif /* AVCODEC_SBC_H */