64 unsigned int consumed;
71 uint32_t audio_sample;
75 uint32_t levels[2][8];
95 frame->
blocks = 4 * ((data[1] >> 4) & 0x03) + 4;
96 frame->
mode = (data[1] >> 2) & 0x03;
99 frame->
subbands = data[1] & 0x01 ? 8 : 4;
102 if ((frame->
mode ==
MONO || frame->
mode == DUAL_CHANNEL) &&
113 crc_header[0] = data[1];
114 crc_header[1] = data[2];
118 if (len * 8 < consumed + frame->
subbands)
122 for (sb = 0; sb < frame->
subbands - 1; sb++)
123 frame->
joint |= ((data[4] >> (7 - sb)) & 0x01) << sb;
125 crc_header[crc_pos / 8] = data[4] & 0xf0;
127 crc_header[crc_pos / 8] = data[4];
136 for (ch = 0; ch < frame->
channels; ch++) {
137 for (sb = 0; sb < frame->
subbands; sb++) {
140 (data[consumed >> 3] >> (4 - (consumed & 0x7))) & 0x0F;
141 crc_header[crc_pos >> 3] |=
154 for (ch = 0; ch < frame->
channels; ch++) {
155 for (sb = 0; sb < frame->
subbands; sb++)
156 levels[ch][sb] = (1 << bits[ch][sb]) - 1;
159 for (blk = 0; blk < frame->
blocks; blk++) {
160 for (ch = 0; ch < frame->
channels; ch++) {
161 for (sb = 0; sb < frame->
subbands; sb++) {
164 if (levels[ch][sb] == 0) {
173 for (bit = 0; bit < bits[ch][sb]; bit++) {
174 if (consumed > len * 8)
177 if ((data[consumed >> 3] >> (7 - (consumed & 0x7))) & 0x01)
178 audio_sample |= 1 << (bits[ch][sb] - bit - 1);
184 (((((uint64_t) audio_sample << 1) | 1) <<
shift) /
185 levels[ch][sb]) - (1 <<
shift);
191 for (blk = 0; blk < frame->
blocks; blk++) {
192 for (sb = 0; sb < frame->
subbands; sb++) {
193 if (frame->
joint & (0x01 << sb)) {
205 if ((consumed & 0x7) != 0)
206 consumed += 8 - (consumed & 0x7);
208 return consumed >> 3;
219 for (i = 0; i < 8; i++) {
224 memcpy(v + 80, v, 9 *
sizeof(*v));
236 for (idx = 0, i = 0; i < 4; i++, idx += 5) {
240 AV_WN16A(&output_frame->
data[ch][blk * 8 + i * 2], av_clip_int16(
262 for (i = 0; i < 16; i++) {
267 memcpy(v + 160, v, 9 *
sizeof(*v));
283 for (idx = 0, i = 0; i < 8; i++, idx += 5) {
287 AV_WN16A(&output_frame->
data[ch][blk * 16 + i * 2], av_clip_int16(
308 for (ch = 0; ch < frame->
channels; ch++)
309 for (blk = 0; blk < frame->
blocks; blk++)
314 for (ch = 0; ch < frame->
channels; ch++)
315 for (blk = 0; blk < frame->
blocks; blk++)
330 memset(sbc->
dsp.
V, 0,
sizeof(sbc->
dsp.
V));
331 for (ch = 0; ch < 2; ch++)
338 void *
data,
int *got_frame_ptr,
343 int ret, frame_length;
349 if (frame_length <= 0)
379 .supported_samplerates = (
const int[]) { 16000, 32000, 44100, 48000, 0 },
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
static void sbc_synthesize_four(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
const int32_t ff_sbc_proto_4_40m1[]
#define AV_CH_LAYOUT_STEREO
static void sbc_synthesize_audio(struct sbc_decoder_state *state, struct sbc_frame *frame, AVFrame *output_frame)
const int32_t ff_sbc_proto_8_80m0[]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
const int32_t ff_synmatrix8[16][8]
enum sbc_frame::@131 allocation
enum sbc_frame::@130 mode
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
enum AVSampleFormat sample_fmt
audio sample format
struct sbc_decoder_state dsp
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const int32_t ff_synmatrix4[8][4]
#define i(width, name, range_min, range_max)
uint32_t scale_factor[2][8]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
const int32_t ff_sbc_proto_4_40m0[]
#define FF_ARRAY_ELEMS(a)
static int sbc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
const int32_t ff_sbc_proto_8_80m1[]
static void sbc_synthesize_eight(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int sbc_decode_init(AVCodecContext *avctx)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static const uint16_t channel_layouts[7]
Describe the class of an AVClass context structure.
static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame, size_t len)
#define SBCDEC_FIXED_EXTRA_BITS
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
common internal api header.
#define bit(string, value)
SBC common definitions for the encoder and decoder.
#define xf(width, name, var, range_min, range_max, subs,...)
int channels
number of audio channels
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int32_t sb_sample[16][2][8]