66 unsigned int consumed;
69 uint8_t crc_header[11] = { 0 };
73 uint32_t audio_sample;
77 uint32_t levels[2][8];
97 frame->blocks = 4 * ((
data[1] >> 4) & 0x03) + 4;
100 frame->allocation = (
data[1] >> 1) & 0x01;
101 frame->subbands =
data[1] & 0x01 ? 8 : 4;
115 crc_header[0] =
data[1];
116 crc_header[1] =
data[2];
120 if (
len * 8 < consumed +
frame->subbands)
124 for (sb = 0; sb <
frame->subbands - 1; sb++)
125 frame->joint |= ((
data[4] >> (7 - sb)) & 0x01) << sb;
126 if (
frame->subbands == 4)
127 crc_header[crc_pos / 8] =
data[4] & 0xf0;
129 crc_header[crc_pos / 8] =
data[4];
131 consumed +=
frame->subbands;
132 crc_pos +=
frame->subbands;
135 if (
len * 8 < consumed + (4 *
frame->subbands *
frame->channels))
138 for (ch = 0; ch <
frame->channels; ch++) {
139 for (sb = 0; sb <
frame->subbands; sb++) {
141 frame->scale_factor[ch][sb] =
142 (
data[consumed >> 3] >> (4 - (consumed & 0x7))) & 0x0F;
143 crc_header[crc_pos >> 3] |=
144 frame->scale_factor[ch][sb] << (4 - (crc_pos & 0x7));
156 for (ch = 0; ch <
frame->channels; ch++) {
157 for (sb = 0; sb <
frame->subbands; sb++)
158 levels[ch][sb] = (1 <<
bits[ch][sb]) - 1;
162 for (ch = 0; ch <
frame->channels; ch++) {
163 for (sb = 0; sb <
frame->subbands; sb++) {
166 if (levels[ch][sb] == 0) {
176 if (consumed >
len * 8)
179 if ((
data[consumed >> 3] >> (7 - (consumed & 0x7))) & 0x01)
180 audio_sample |= 1 << (
bits[ch][sb] -
bit - 1);
186 (((((uint64_t) audio_sample << 1) | 1) <<
shift) /
187 levels[ch][sb]) - (1 <<
shift);
194 for (sb = 0; sb <
frame->subbands; sb++) {
195 if (
frame->joint & (0x01 << sb)) {
207 if ((consumed & 0x7) != 0)
208 consumed += 8 - (consumed & 0x7);
210 return consumed >> 3;
221 for (
i = 0;
i < 8;
i++) {
226 memcpy(v + 80, v, 9 *
sizeof(*v));
238 for (idx = 0,
i = 0;
i < 4;
i++, idx += 5) {
264 for (
i = 0;
i < 16;
i++) {
269 memcpy(v + 160, v, 9 *
sizeof(*v));
285 for (idx = 0,
i = 0;
i < 8;
i++, idx += 5) {
308 switch (
frame->subbands) {
310 for (ch = 0; ch <
frame->channels; ch++)
316 for (ch = 0; ch <
frame->channels; ch++)
332 memset(sbc->
dsp.
V, 0,
sizeof(sbc->
dsp.
V));
333 for (ch = 0; ch < 2; ch++)
340 int *got_frame_ptr,
AVPacket *avpkt)
343 int ret, frame_length;
346 if (frame_length <= 0)
const FFCodec ff_sbc_decoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define bit(string, value)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
static struct @346255127015250356166251341105367306144006377143 state
static const uint8_t bits[8]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
static int shift(int a, int b)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame, size_t len)
static void sbc_synthesize_four(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
static av_cold int sbc_decode_init(AVCodecContext *avctx)
static void sbc_synthesize_audio(struct sbc_decoder_state *state, struct sbc_frame *frame, AVFrame *output_frame)
static void sbc_synthesize_eight(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
static int sbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
SBC common definitions for the encoder and decoder.
#define SBCDEC_FIXED_EXTRA_BITS
static const int32_t synmatrix8[16][8]
static const int32_t sbc_proto_4_40m1[]
static const int32_t sbc_proto_8_80m1[]
static const int32_t sbc_proto_8_80m0[]
static const int32_t sbc_proto_4_40m0[]
static const int32_t synmatrix4[8][4]
#define FF_ARRAY_ELEMS(a)
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
struct sbc_decoder_state dsp