Go to the documentation of this file.
67 unsigned int consumed;
70 uint8_t crc_header[11] = { 0 };
74 uint32_t audio_sample;
78 uint32_t levels[2][8];
98 frame->blocks = 4 * ((
data[1] >> 4) & 0x03) + 4;
101 frame->allocation = (
data[1] >> 1) & 0x01;
102 frame->subbands =
data[1] & 0x01 ? 8 : 4;
116 crc_header[0] =
data[1];
117 crc_header[1] =
data[2];
121 if (
len * 8 < consumed +
frame->subbands)
125 for (sb = 0; sb <
frame->subbands - 1; sb++)
126 frame->joint |= ((
data[4] >> (7 - sb)) & 0x01) << sb;
127 if (
frame->subbands == 4)
128 crc_header[crc_pos / 8] =
data[4] & 0xf0;
130 crc_header[crc_pos / 8] =
data[4];
132 consumed +=
frame->subbands;
133 crc_pos +=
frame->subbands;
136 if (
len * 8 < consumed + (4 *
frame->subbands *
frame->channels))
139 for (ch = 0; ch <
frame->channels; ch++) {
140 for (sb = 0; sb <
frame->subbands; sb++) {
142 frame->scale_factor[ch][sb] =
143 (
data[consumed >> 3] >> (4 - (consumed & 0x7))) & 0x0F;
144 crc_header[crc_pos >> 3] |=
145 frame->scale_factor[ch][sb] << (4 - (crc_pos & 0x7));
157 for (ch = 0; ch <
frame->channels; ch++) {
158 for (sb = 0; sb <
frame->subbands; sb++)
159 levels[ch][sb] = (1 <<
bits[ch][sb]) - 1;
163 for (ch = 0; ch <
frame->channels; ch++) {
164 for (sb = 0; sb <
frame->subbands; sb++) {
167 if (levels[ch][sb] == 0) {
177 if (consumed >
len * 8)
180 if ((
data[consumed >> 3] >> (7 - (consumed & 0x7))) & 0x01)
181 audio_sample |= 1 << (
bits[ch][sb] -
bit - 1);
187 (((((uint64_t) audio_sample << 1) | 1) <<
shift) /
188 levels[ch][sb]) - (1 <<
shift);
195 for (sb = 0; sb <
frame->subbands; sb++) {
196 if (
frame->joint & (0x01 << sb)) {
208 if ((consumed & 0x7) != 0)
209 consumed += 8 - (consumed & 0x7);
211 return consumed >> 3;
222 for (
i = 0;
i < 8;
i++) {
227 memcpy(v + 80, v, 9 *
sizeof(*v));
239 for (idx = 0,
i = 0;
i < 4;
i++, idx += 5) {
265 for (
i = 0;
i < 16;
i++) {
270 memcpy(v + 160, v, 9 *
sizeof(*v));
286 for (idx = 0,
i = 0;
i < 8;
i++, idx += 5) {
309 switch (
frame->subbands) {
311 for (ch = 0; ch <
frame->channels; ch++)
317 for (ch = 0; ch <
frame->channels; ch++)
333 memset(sbc->
dsp.
V, 0,
sizeof(sbc->
dsp.
V));
334 for (ch = 0; ch < 2; ch++)
341 int *got_frame_ptr,
AVPacket *avpkt)
344 int ret, frame_length;
347 if (frame_length <= 0)
379 .p.supported_samplerates = (
const int[]) { 16000, 32000, 44100, 48000, 0 },
#define AV_CHANNEL_LAYOUT_STEREO
This structure describes decoded (raw) audio or video data.
static int sbc_decode_init(AVCodecContext *avctx)
#define SBCDEC_FIXED_EXTRA_BITS
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
static void sbc_synthesize_eight(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
#define bit(string, value)
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
const int32_t ff_sbc_proto_4_40m1[]
#define FF_ARRAY_ELEMS(a)
const FFCodec ff_sbc_decoder
#define FF_CODEC_DECODE_CB(func)
static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame, size_t len)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
const int32_t ff_synmatrix8[16][8]
const int32_t ff_synmatrix4[8][4]
#define CODEC_LONG_NAME(str)
struct sbc_decoder_state dsp
Describe the class of an AVClass context structure.
const int32_t ff_sbc_proto_8_80m1[]
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
An AVChannelLayout holds information about the channel layout of audio data.
#define DECLARE_ALIGNED(n, t, v)
static int shift(int a, int b)
enum AVSampleFormat sample_fmt
audio sample format
static void sbc_synthesize_audio(struct sbc_decoder_state *state, struct sbc_frame *frame, AVFrame *output_frame)
const int32_t ff_sbc_proto_4_40m0[]
static int sbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
#define i(width, name, range_min, range_max)
AVSampleFormat
Audio sample formats.
#define xf(width, name, var, range_min, range_max, subs,...)
const char * name
Name of the codec implementation.
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
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
main external API structure.
static void sbc_synthesize_four(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
#define AV_CHANNEL_LAYOUT_MONO
This structure stores compressed data.
const int32_t ff_sbc_proto_8_80m0[]