FFmpeg  4.4.6
sbc.h
Go to the documentation of this file.
1 /*
2  * Bluetooth low-complexity, subband codec (SBC)
3  *
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>
10  *
11  * This file is part of FFmpeg.
12  *
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.
17  *
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.
22  *
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
26  */
27 
28 /**
29  * @file
30  * SBC common definitions for the encoder and decoder
31  */
32 
33 #ifndef AVCODEC_SBC_H
34 #define AVCODEC_SBC_H
35 
36 #include "avcodec.h"
37 #include "libavutil/crc.h"
38 #include "libavutil/mem_internal.h"
39 
40 #define MSBC_BLOCKS 15
41 
42 /* sampling frequency */
43 #define SBC_FREQ_16000 0x00
44 #define SBC_FREQ_32000 0x01
45 #define SBC_FREQ_44100 0x02
46 #define SBC_FREQ_48000 0x03
47 
48 /* blocks */
49 #define SBC_BLK_4 0x00
50 #define SBC_BLK_8 0x01
51 #define SBC_BLK_12 0x02
52 #define SBC_BLK_16 0x03
53 
54 /* channel mode */
55 #define SBC_MODE_MONO 0x00
56 #define SBC_MODE_DUAL_CHANNEL 0x01
57 #define SBC_MODE_STEREO 0x02
58 #define SBC_MODE_JOINT_STEREO 0x03
59 
60 /* allocation method */
61 #define SBC_AM_LOUDNESS 0x00
62 #define SBC_AM_SNR 0x01
63 
64 /* subbands */
65 #define SBC_SB_4 0x00
66 #define SBC_SB_8 0x01
67 
68 /* synchronisation words */
69 #define SBC_SYNCWORD 0x9C
70 #define MSBC_SYNCWORD 0xAD
71 
72 /* extra bits of precision for the synthesis filter input data */
73 #define SBCDEC_FIXED_EXTRA_BITS 2
74 
75 /*
76  * Enforce 16 byte alignment for the data, which is supposed to be used
77  * with SIMD optimized code.
78  */
79 #define SBC_ALIGN 16
80 
81 /* This structure contains an unpacked SBC frame.
82  Yes, there is probably quite some unused space herein */
83 struct sbc_frame {
86  enum {
91  } mode;
93  enum {
95  SNR = SBC_AM_SNR
99  uint16_t codesize;
100 
101  /* bit number x set means joint stereo has been used in subband x */
103 
104  /* only the lower 4 bits of every element are to be used */
106 
107  /* raw integer subband samples in the frame */
109 
110  /* modified subband samples */
112 
113  const AVCRC *crc_ctx;
114 };
115 
116 uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len);
117 void ff_sbc_calculate_bits(const struct sbc_frame *frame, int (*bits)[8]);
118 
119 #endif /* AVCODEC_SBC_H */
uint8_t
int32_t
Libavcodec external API header.
Public header for CRC hash function implementation.
static AVFrame * frame
uint32_t AVCRC
Definition: crc.h:47
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:117
const char data[16]
Definition: mxf.c:142
#define SBC_MODE_JOINT_STEREO
Definition: sbc.h:58
#define SBC_ALIGN
Definition: sbc.h:79
#define SBC_AM_LOUDNESS
Definition: sbc.h:61
#define SBC_MODE_STEREO
Definition: sbc.h:57
#define SBC_AM_SNR
Definition: sbc.h:62
uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len)
Definition: sbc.c:55
#define SBC_MODE_DUAL_CHANNEL
Definition: sbc.h:56
#define SBC_MODE_MONO
Definition: sbc.h:55
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
Definition: sbc.c:79
Definition: sbc.h:83
enum sbc_frame::@128 mode
uint16_t codesize
Definition: sbc.h:99
enum sbc_frame::@129 allocation
int32_t sb_sample_f[16][2][8]
Definition: sbc.h:108
uint32_t scale_factor[2][8]
Definition: sbc.h:105
uint8_t bitpool
Definition: sbc.h:98
@ MONO
Definition: sbc.h:87
@ STEREO
Definition: sbc.h:89
@ JOINT_STEREO
Definition: sbc.h:90
@ DUAL_CHANNEL
Definition: sbc.h:88
uint8_t channels
Definition: sbc.h:92
@ SNR
Definition: sbc.h:95
@ LOUDNESS
Definition: sbc.h:94
uint8_t frequency
Definition: sbc.h:84
const AVCRC * crc_ctx
Definition: sbc.h:113
int32_t sb_sample[16][2][8]
Definition: sbc.h:111
uint8_t subbands
Definition: sbc.h:97
uint8_t joint
Definition: sbc.h:102
uint8_t blocks
Definition: sbc.h:85
int len
uint8_t bits
Definition: vp3data.h:141