65 unsigned int consumed;
72 uint32_t audio_sample;
76 uint32_t levels[2][8];
96 frame->
blocks = 4 * ((data[1] >> 4) & 0x03) + 4;
97 frame->
mode = (data[1] >> 2) & 0x03;
100 frame->
subbands = data[1] & 0x01 ? 8 : 4;
103 if ((frame->
mode ==
MONO || frame->
mode == DUAL_CHANNEL) &&
114 crc_header[0] = data[1];
115 crc_header[1] = data[2];
119 if (len * 8 < consumed + frame->
subbands)
123 for (sb = 0; sb < frame->
subbands - 1; sb++)
124 frame->
joint |= ((data[4] >> (7 - sb)) & 0x01) << sb;
126 crc_header[crc_pos / 8] = data[4] & 0xf0;
128 crc_header[crc_pos / 8] = data[4];
137 for (ch = 0; ch < frame->
channels; ch++) {
138 for (sb = 0; sb < frame->
subbands; sb++) {
141 (data[consumed >> 3] >> (4 - (consumed & 0x7))) & 0x0F;
142 crc_header[crc_pos >> 3] |=
155 for (ch = 0; ch < frame->
channels; ch++) {
156 for (sb = 0; sb < frame->
subbands; sb++)
157 levels[ch][sb] = (1 << bits[ch][sb]) - 1;
160 for (blk = 0; blk < frame->
blocks; blk++) {
161 for (ch = 0; ch < frame->
channels; ch++) {
162 for (sb = 0; sb < frame->
subbands; sb++) {
165 if (levels[ch][sb] == 0) {
174 for (bit = 0; bit < bits[ch][sb]; bit++) {
175 if (consumed > len * 8)
178 if ((data[consumed >> 3] >> (7 - (consumed & 0x7))) & 0x01)
179 audio_sample |= 1 << (bits[ch][sb] - bit - 1);
185 (((((uint64_t) audio_sample << 1) | 1) <<
shift) /
186 levels[ch][sb]) - (1 <<
shift);
192 for (blk = 0; blk < frame->
blocks; blk++) {
193 for (sb = 0; sb < frame->
subbands; sb++) {
194 if (frame->
joint & (0x01 << sb)) {
206 if ((consumed & 0x7) != 0)
207 consumed += 8 - (consumed & 0x7);
209 return consumed >> 3;
220 for (i = 0; i < 8; i++) {
225 memcpy(v + 80, v, 9 *
sizeof(*v));
237 for (idx = 0, i = 0; i < 4; i++, idx += 5) {
241 AV_WN16A(&output_frame->
data[ch][blk * 8 + i * 2], av_clip_int16(
263 for (i = 0; i < 16; i++) {
268 memcpy(v + 160, v, 9 *
sizeof(*v));
284 for (idx = 0, i = 0; i < 8; i++, idx += 5) {
288 AV_WN16A(&output_frame->
data[ch][blk * 16 + i * 2], av_clip_int16(
309 for (ch = 0; ch < frame->
channels; ch++)
310 for (blk = 0; blk < frame->
blocks; blk++)
315 for (ch = 0; ch < frame->
channels; ch++)
316 for (blk = 0; blk < frame->
blocks; blk++)
331 memset(sbc->
dsp.
V, 0,
sizeof(sbc->
dsp.
V));
332 for (ch = 0; ch < 2; ch++)
339 void *
data,
int *got_frame_ptr,
344 int ret, frame_length;
350 if (frame_length <= 0)
380 .supported_samplerates = (
const int[]) { 16000, 32000, 44100, 48000, 0 },
enum sbc_frame::@129 mode
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * 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_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#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]
#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]
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.
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
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.
enum sbc_frame::@130 allocation
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])
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#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]