FFmpeg
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 <stddef.h>
37 #include <stdint.h>
38 #include "libavutil/crc.h"
39 #include "libavutil/mem_internal.h"
40 
41 #define MSBC_BLOCKS 15
42 
43 /* sampling frequency */
44 #define SBC_FREQ_16000 0x00
45 #define SBC_FREQ_32000 0x01
46 #define SBC_FREQ_44100 0x02
47 #define SBC_FREQ_48000 0x03
48 
49 /* blocks */
50 #define SBC_BLK_4 0x00
51 #define SBC_BLK_8 0x01
52 #define SBC_BLK_12 0x02
53 #define SBC_BLK_16 0x03
54 
55 /* channel mode */
56 #define SBC_MODE_MONO 0x00
57 #define SBC_MODE_DUAL_CHANNEL 0x01
58 #define SBC_MODE_STEREO 0x02
59 #define SBC_MODE_JOINT_STEREO 0x03
60 
61 /* allocation method */
62 #define SBC_AM_LOUDNESS 0x00
63 #define SBC_AM_SNR 0x01
64 
65 /* subbands */
66 #define SBC_SB_4 0x00
67 #define SBC_SB_8 0x01
68 
69 /* synchronisation words */
70 #define SBC_SYNCWORD 0x9C
71 #define MSBC_SYNCWORD 0xAD
72 
73 /* extra bits of precision for the synthesis filter input data */
74 #define SBCDEC_FIXED_EXTRA_BITS 2
75 
76 /*
77  * Enforce 16 byte alignment for the data, which is supposed to be used
78  * with SIMD optimized code.
79  */
80 #define SBC_ALIGN 16
81 
82 /* This structure contains an unpacked SBC frame.
83  Yes, there is probably quite some unused space herein */
84 struct sbc_frame {
85  uint8_t frequency;
86  uint8_t blocks;
87  enum {
92  } mode;
93  uint8_t channels;
94  enum {
97  } allocation;
98  uint8_t subbands;
99  uint8_t bitpool;
100  uint16_t codesize;
101 
102  /* bit number x set means joint stereo has been used in subband x */
103  uint8_t joint;
104 
105  /* only the lower 4 bits of every element are to be used */
107 
108  /* raw integer subband samples in the frame */
110 
111  /* modified subband samples */
113 
114  const AVCRC *crc_ctx;
115 };
116 
117 uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len);
118 void ff_sbc_calculate_bits(const struct sbc_frame *frame, int (*bits)[8]);
119 
120 #endif /* AVCODEC_SBC_H */
mem_internal.h
AVCRC
uint32_t AVCRC
Definition: crc.h:46
data
const char data[16]
Definition: mxf.c:143
sbc_frame::subbands
uint8_t subbands
Definition: sbc.h:98
sbc_frame::DUAL_CHANNEL
@ DUAL_CHANNEL
Definition: sbc.h:89
crc.h
sbc_frame::mode
enum sbc_frame::@124 mode
sbc_frame::scale_factor
uint32_t scale_factor[2][8]
Definition: sbc.h:106
sbc_frame::bitpool
uint8_t bitpool
Definition: sbc.h:99
bits
uint8_t bits
Definition: vp3data.h:141
sbc_frame::SNR
@ SNR
Definition: sbc.h:96
SBC_AM_SNR
#define SBC_AM_SNR
Definition: sbc.h:63
SBC_MODE_STEREO
#define SBC_MODE_STEREO
Definition: sbc.h:58
SBC_AM_LOUDNESS
#define SBC_AM_LOUDNESS
Definition: sbc.h:62
SBC_ALIGN
#define SBC_ALIGN
Definition: sbc.h:80
sbc_frame::LOUDNESS
@ LOUDNESS
Definition: sbc.h:95
sbc_frame::channels
uint8_t channels
Definition: sbc.h:93
SBC_MODE_MONO
#define SBC_MODE_MONO
Definition: sbc.h:56
sbc_frame::allocation
enum sbc_frame::@125 allocation
sbc_frame::STEREO
@ STEREO
Definition: sbc.h:90
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:116
sbc_frame
Definition: sbc.h:84
sbc_frame::joint
uint8_t joint
Definition: sbc.h:103
sbc_frame::JOINT_STEREO
@ JOINT_STEREO
Definition: sbc.h:91
ff_sbc_calculate_bits
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
Definition: sbc.c:78
len
int len
Definition: vorbis_enc_data.h:426
sbc_frame::crc_ctx
const AVCRC * crc_ctx
Definition: sbc.h:114
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
sbc_frame::frequency
uint8_t frequency
Definition: sbc.h:85
ff_sbc_crc8
uint8_t ff_sbc_crc8(const AVCRC *crc_ctx, const uint8_t *data, size_t len)
Definition: sbc.c:54
sbc_frame::blocks
uint8_t blocks
Definition: sbc.h:86
SBC_MODE_DUAL_CHANNEL
#define SBC_MODE_DUAL_CHANNEL
Definition: sbc.h:57
int32_t
int32_t
Definition: audioconvert.c:56
sbc_frame::sb_sample
int32_t sb_sample[16][2][8]
Definition: sbc.h:112
SBC_MODE_JOINT_STEREO
#define SBC_MODE_JOINT_STEREO
Definition: sbc.h:59
sbc_frame::MONO
@ MONO
Definition: sbc.h:88
sbc_frame::sb_sample_f
int32_t sb_sample_f[16][2][8]
Definition: sbc.h:109
sbc_frame::codesize
uint16_t codesize
Definition: sbc.h:100