FFmpeg
sbcdec.c
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-2013 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-2008 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 decoder implementation
31  */
32 
33 #include "avcodec.h"
34 #include "codec_internal.h"
35 #include "decode.h"
37 #include "libavutil/intreadwrite.h"
38 #include "libavutil/mem_internal.h"
39 #include "sbc.h"
40 #include "sbcdec_data.h"
41 
43  int32_t V[2][170];
44  int offset[2][16];
45 };
46 
47 typedef struct SBCDecContext {
48  AVClass *class;
52 
53 /*
54  * Unpacks a SBC frame at the beginning of the stream in data,
55  * which has at most len bytes into frame.
56  * Returns the length in bytes of the packed frame, or a negative
57  * value on error. The error codes are:
58  *
59  * -1 Data stream too short
60  * -2 Sync byte incorrect
61  * -3 CRC8 incorrect
62  * -4 Bitpool value out of bounds
63  */
64 static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame,
65  size_t len)
66 {
67  unsigned int consumed;
68  /* Will copy the parts of the header that are relevant to crc
69  * calculation here */
70  uint8_t crc_header[11] = { 0 };
71  int crc_pos;
72  int32_t temp;
73 
74  uint32_t audio_sample;
75  int ch, sb, blk, bit; /* channel, subband, block and bit standard
76  counters */
77  int bits[2][8]; /* bits distribution */
78  uint32_t levels[2][8]; /* levels derived from that */
79 
80  if (len < 4)
81  return -1;
82 
83  if (data[0] == MSBC_SYNCWORD) {
84  if (data[1] != 0)
85  return -2;
86  if (data[2] != 0)
87  return -2;
88 
89  frame->frequency = SBC_FREQ_16000;
90  frame->blocks = MSBC_BLOCKS;
91  frame->allocation = LOUDNESS;
92  frame->mode = MONO;
93  frame->channels = 1;
94  frame->subbands = 8;
95  frame->bitpool = 26;
96  } else if (data[0] == SBC_SYNCWORD) {
97  frame->frequency = (data[1] >> 6) & 0x03;
98  frame->blocks = 4 * ((data[1] >> 4) & 0x03) + 4;
99  frame->mode = (data[1] >> 2) & 0x03;
100  frame->channels = frame->mode == MONO ? 1 : 2;
101  frame->allocation = (data[1] >> 1) & 0x01;
102  frame->subbands = data[1] & 0x01 ? 8 : 4;
103  frame->bitpool = data[2];
104 
105  if ((frame->mode == MONO || frame->mode == DUAL_CHANNEL) &&
106  frame->bitpool > 16 * frame->subbands)
107  return -4;
108 
109  if ((frame->mode == STEREO || frame->mode == JOINT_STEREO) &&
110  frame->bitpool > 32 * frame->subbands)
111  return -4;
112  } else
113  return -2;
114 
115  consumed = 32;
116  crc_header[0] = data[1];
117  crc_header[1] = data[2];
118  crc_pos = 16;
119 
120  if (frame->mode == JOINT_STEREO) {
121  if (len * 8 < consumed + frame->subbands)
122  return -1;
123 
124  frame->joint = 0x00;
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;
129  else
130  crc_header[crc_pos / 8] = data[4];
131 
132  consumed += frame->subbands;
133  crc_pos += frame->subbands;
134  }
135 
136  if (len * 8 < consumed + (4 * frame->subbands * frame->channels))
137  return -1;
138 
139  for (ch = 0; ch < frame->channels; ch++) {
140  for (sb = 0; sb < frame->subbands; sb++) {
141  /* FIXME assert(consumed % 4 == 0); */
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));
146 
147  consumed += 4;
148  crc_pos += 4;
149  }
150  }
151 
152  if (data[3] != ff_sbc_crc8(frame->crc_ctx, crc_header, crc_pos))
153  return -3;
154 
156 
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;
160  }
161 
162  for (blk = 0; blk < frame->blocks; blk++) {
163  for (ch = 0; ch < frame->channels; ch++) {
164  for (sb = 0; sb < frame->subbands; sb++) {
165  uint32_t shift;
166 
167  if (levels[ch][sb] == 0) {
168  frame->sb_sample[blk][ch][sb] = 0;
169  continue;
170  }
171 
172  shift = frame->scale_factor[ch][sb] +
174 
175  audio_sample = 0;
176  for (bit = 0; bit < bits[ch][sb]; bit++) {
177  if (consumed > len * 8)
178  return -1;
179 
180  if ((data[consumed >> 3] >> (7 - (consumed & 0x7))) & 0x01)
181  audio_sample |= 1 << (bits[ch][sb] - bit - 1);
182 
183  consumed++;
184  }
185 
186  frame->sb_sample[blk][ch][sb] = (int32_t)
187  (((((uint64_t) audio_sample << 1) | 1) << shift) /
188  levels[ch][sb]) - (1 << shift);
189  }
190  }
191  }
192 
193  if (frame->mode == JOINT_STEREO) {
194  for (blk = 0; blk < frame->blocks; blk++) {
195  for (sb = 0; sb < frame->subbands; sb++) {
196  if (frame->joint & (0x01 << sb)) {
197  temp = frame->sb_sample[blk][0][sb] +
198  frame->sb_sample[blk][1][sb];
199  frame->sb_sample[blk][1][sb] =
200  frame->sb_sample[blk][0][sb] -
201  frame->sb_sample[blk][1][sb];
202  frame->sb_sample[blk][0][sb] = temp;
203  }
204  }
205  }
206  }
207 
208  if ((consumed & 0x7) != 0)
209  consumed += 8 - (consumed & 0x7);
210 
211  return consumed >> 3;
212 }
213 
214 static inline void sbc_synthesize_four(struct sbc_decoder_state *state,
215  struct sbc_frame *frame,
216  int ch, int blk, AVFrame *output_frame)
217 {
218  int i, k, idx;
219  int32_t *v = state->V[ch];
220  int *offset = state->offset[ch];
221 
222  for (i = 0; i < 8; i++) {
223  /* Shifting */
224  offset[i]--;
225  if (offset[i] < 0) {
226  offset[i] = 79;
227  memcpy(v + 80, v, 9 * sizeof(*v));
228  }
229 
230  /* Distribute the new matrix value to the shifted position */
231  v[offset[i]] =
232  (int)( (unsigned)ff_synmatrix4[i][0] * frame->sb_sample[blk][ch][0] +
233  (unsigned)ff_synmatrix4[i][1] * frame->sb_sample[blk][ch][1] +
234  (unsigned)ff_synmatrix4[i][2] * frame->sb_sample[blk][ch][2] +
235  (unsigned)ff_synmatrix4[i][3] * frame->sb_sample[blk][ch][3] ) >> 15;
236  }
237 
238  /* Compute the samples */
239  for (idx = 0, i = 0; i < 4; i++, idx += 5) {
240  k = (i + 4) & 0xf;
241 
242  /* Store in output, Q0 */
243  AV_WN16A(&output_frame->data[ch][blk * 8 + i * 2], av_clip_int16(
244  (int)( (unsigned)v[offset[i] + 0] * ff_sbc_proto_4_40m0[idx + 0] +
245  (unsigned)v[offset[k] + 1] * ff_sbc_proto_4_40m1[idx + 0] +
246  (unsigned)v[offset[i] + 2] * ff_sbc_proto_4_40m0[idx + 1] +
247  (unsigned)v[offset[k] + 3] * ff_sbc_proto_4_40m1[idx + 1] +
248  (unsigned)v[offset[i] + 4] * ff_sbc_proto_4_40m0[idx + 2] +
249  (unsigned)v[offset[k] + 5] * ff_sbc_proto_4_40m1[idx + 2] +
250  (unsigned)v[offset[i] + 6] * ff_sbc_proto_4_40m0[idx + 3] +
251  (unsigned)v[offset[k] + 7] * ff_sbc_proto_4_40m1[idx + 3] +
252  (unsigned)v[offset[i] + 8] * ff_sbc_proto_4_40m0[idx + 4] +
253  (unsigned)v[offset[k] + 9] * ff_sbc_proto_4_40m1[idx + 4] ) >> 15));
254  }
255 }
256 
257 static inline void sbc_synthesize_eight(struct sbc_decoder_state *state,
258  struct sbc_frame *frame,
259  int ch, int blk, AVFrame *output_frame)
260 {
261  int i, k, idx;
262  int32_t *v = state->V[ch];
263  int *offset = state->offset[ch];
264 
265  for (i = 0; i < 16; i++) {
266  /* Shifting */
267  offset[i]--;
268  if (offset[i] < 0) {
269  offset[i] = 159;
270  memcpy(v + 160, v, 9 * sizeof(*v));
271  }
272 
273  /* Distribute the new matrix value to the shifted position */
274  v[offset[i]] =
275  (int)( (unsigned)ff_synmatrix8[i][0] * frame->sb_sample[blk][ch][0] +
276  (unsigned)ff_synmatrix8[i][1] * frame->sb_sample[blk][ch][1] +
277  (unsigned)ff_synmatrix8[i][2] * frame->sb_sample[blk][ch][2] +
278  (unsigned)ff_synmatrix8[i][3] * frame->sb_sample[blk][ch][3] +
279  (unsigned)ff_synmatrix8[i][4] * frame->sb_sample[blk][ch][4] +
280  (unsigned)ff_synmatrix8[i][5] * frame->sb_sample[blk][ch][5] +
281  (unsigned)ff_synmatrix8[i][6] * frame->sb_sample[blk][ch][6] +
282  (unsigned)ff_synmatrix8[i][7] * frame->sb_sample[blk][ch][7] ) >> 15;
283  }
284 
285  /* Compute the samples */
286  for (idx = 0, i = 0; i < 8; i++, idx += 5) {
287  k = (i + 8) & 0xf;
288 
289  /* Store in output, Q0 */
290  AV_WN16A(&output_frame->data[ch][blk * 16 + i * 2], av_clip_int16(
291  (int)( (unsigned)v[offset[i] + 0] * ff_sbc_proto_8_80m0[idx + 0] +
292  (unsigned)v[offset[k] + 1] * ff_sbc_proto_8_80m1[idx + 0] +
293  (unsigned)v[offset[i] + 2] * ff_sbc_proto_8_80m0[idx + 1] +
294  (unsigned)v[offset[k] + 3] * ff_sbc_proto_8_80m1[idx + 1] +
295  (unsigned)v[offset[i] + 4] * ff_sbc_proto_8_80m0[idx + 2] +
296  (unsigned)v[offset[k] + 5] * ff_sbc_proto_8_80m1[idx + 2] +
297  (unsigned)v[offset[i] + 6] * ff_sbc_proto_8_80m0[idx + 3] +
298  (unsigned)v[offset[k] + 7] * ff_sbc_proto_8_80m1[idx + 3] +
299  (unsigned)v[offset[i] + 8] * ff_sbc_proto_8_80m0[idx + 4] +
300  (unsigned)v[offset[k] + 9] * ff_sbc_proto_8_80m1[idx + 4] ) >> 15));
301  }
302 }
303 
306 {
307  int ch, blk;
308 
309  switch (frame->subbands) {
310  case 4:
311  for (ch = 0; ch < frame->channels; ch++)
312  for (blk = 0; blk < frame->blocks; blk++)
314  break;
315 
316  case 8:
317  for (ch = 0; ch < frame->channels; ch++)
318  for (blk = 0; blk < frame->blocks; blk++)
320  break;
321  }
322 }
323 
324 static int sbc_decode_init(AVCodecContext *avctx)
325 {
326  SBCDecContext *sbc = avctx->priv_data;
327  int i, ch;
328 
330 
332 
333  memset(sbc->dsp.V, 0, sizeof(sbc->dsp.V));
334  for (ch = 0; ch < 2; ch++)
335  for (i = 0; i < FF_ARRAY_ELEMS(sbc->dsp.offset[0]); i++)
336  sbc->dsp.offset[ch][i] = (10 * i + 10);
337  return 0;
338 }
339 
341  int *got_frame_ptr, AVPacket *avpkt)
342 {
343  SBCDecContext *sbc = avctx->priv_data;
344  int ret, frame_length;
345 
346  if (!sbc)
347  return AVERROR(EIO);
348 
349  frame_length = sbc_unpack_frame(avpkt->data, &sbc->frame, avpkt->size);
350  if (frame_length <= 0)
351  return frame_length;
352 
355  avctx->ch_layout.nb_channels = sbc->frame.channels;
356 
357  frame->nb_samples = sbc->frame.blocks * sbc->frame.subbands;
358  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
359  return ret;
360 
361  sbc_synthesize_audio(&sbc->dsp, &sbc->frame, frame);
362 
363  *got_frame_ptr = 1;
364 
365  return frame_length;
366 }
367 
369  .p.name = "sbc",
370  CODEC_LONG_NAME("SBC (low-complexity subband codec)"),
371  .p.type = AVMEDIA_TYPE_AUDIO,
372  .p.id = AV_CODEC_ID_SBC,
373  .priv_data_size = sizeof(SBCDecContext),
376  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
378  .p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO,
380  { 0 } },
381  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
383  .p.supported_samplerates = (const int[]) { 16000, 32000, 44100, 48000, 0 },
384 };
SBCDecContext::frame
struct sbc_frame frame
Definition: sbcdec.c:49
AVERROR
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
AV_CRC_8_EBU
@ AV_CRC_8_EBU
Definition: crc.h:56
MSBC_SYNCWORD
#define MSBC_SYNCWORD
Definition: sbc.h:71
JOINT_STEREO
#define JOINT_STEREO
Definition: atrac3.c:58
mem_internal.h
AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_MONO
Definition: channel_layout.h:204
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
AVPacket::data
uint8_t * data
Definition: packet.h:374
sbc_decode_init
static int sbc_decode_init(AVCodecContext *avctx)
Definition: sbcdec.c:324
data
const char data[16]
Definition: mxf.c:146
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:356
sbc_frame::subbands
uint8_t subbands
Definition: sbc.h:98
SBCDEC_FIXED_EXTRA_BITS
#define SBCDEC_FIXED_EXTRA_BITS
Definition: sbc.h:74
FFCodec
Definition: codec_internal.h:119
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:357
STEREO
#define STEREO
Definition: cook.c:64
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:298
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:303
sbc_synthesize_eight
static void sbc_synthesize_eight(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
Definition: sbcdec.c:257
MSBC_BLOCKS
#define MSBC_BLOCKS
Definition: sbc.h:41
init
static int init
Definition: av_tx.c:47
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:123
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2059
sbc_decoder_state::offset
int offset[2][16]
Definition: sbcdec.c:44
AV_CH_LAYOUT_STEREO
#define AV_CH_LAYOUT_STEREO
Definition: channel_layout.h:205
ff_sbc_proto_4_40m1
const int32_t ff_sbc_proto_4_40m1[]
Definition: sbcdec_data.c:49
AV_CODEC_ID_SBC
@ AV_CODEC_ID_SBC
Definition: codec_id.h:520
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
sbc_decoder_state::V
int32_t V[2][170]
Definition: sbcdec.c:43
ff_sbc_decoder
const FFCodec ff_sbc_decoder
Definition: sbcdec.c:368
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:298
intreadwrite.h
sbc_unpack_frame
static int sbc_unpack_frame(const uint8_t *data, struct sbc_frame *frame, size_t len)
Definition: sbcdec.c:64
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:106
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
bits
uint8_t bits
Definition: vp3data.h:141
CODEC_OLD_CHANNEL_LAYOUTS
#define CODEC_OLD_CHANNEL_LAYOUTS(...)
Definition: codec_internal.h:294
ff_synmatrix8
const int32_t ff_synmatrix8[16][8]
Definition: sbcdec_data.c:94
ff_synmatrix4
const int32_t ff_synmatrix4[8][4]
Definition: sbcdec_data.c:83
decode.h
AV_WN16A
#define AV_WN16A(p, v)
Definition: intreadwrite.h:534
SBC_SYNCWORD
#define SBC_SYNCWORD
Definition: sbc.h:70
blk
#define blk(i)
Definition: sha.c:186
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:264
SBCDecContext
Definition: sbcdec.c:47
SBCDecContext::dsp
struct sbc_decoder_state dsp
Definition: sbcdec.c:50
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
av_clip_int16
#define av_clip_int16
Definition: common.h:110
state
static struct @336 state
ff_sbc_proto_8_80m1
const int32_t ff_sbc_proto_8_80m1[]
Definition: sbcdec_data.c:70
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:630
AV_CODEC_CAP_CHANNEL_CONF
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition: codec.h:109
SBC_ALIGN
#define SBC_ALIGN
Definition: sbc.h:80
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1450
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:375
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:293
codec_internal.h
shift
static int shift(int a, int b)
Definition: bonk.c:260
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1023
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
sbc_frame::channels
uint8_t channels
Definition: sbc.h:93
sbc_synthesize_audio
static void sbc_synthesize_audio(struct sbc_decoder_state *state, struct sbc_frame *frame, AVFrame *output_frame)
Definition: sbcdec.c:304
ff_sbc_proto_4_40m0
const int32_t ff_sbc_proto_4_40m0[]
Definition: sbcdec_data.c:41
sbc_decode_frame
static int sbc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition: sbcdec.c:340
sbcdec_data.h
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
output_frame
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
Definition: h264dec.c:844
offset
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
Definition: writing_filters.txt:86
sbc.h
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:116
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
sbc_frame
Definition: sbc.h:84
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
xf
#define xf(width, name, var, range_min, range_max, subs,...)
Definition: cbs_av1.c:664
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
len
int len
Definition: vorbis_enc_data.h:426
ff_sbc_crc8
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
Definition: sbc.c:54
avcodec.h
sbc_frame::crc_ctx
const AVCRC * crc_ctx
Definition: sbc.h:114
MONO
#define MONO
Definition: cook.c:63
SBC_FREQ_16000
#define SBC_FREQ_16000
Definition: sbc.h:44
ret
ret
Definition: filter_design.txt:187
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
AVCodecContext
main external API structure.
Definition: avcodec.h:398
channel_layout.h
LOUDNESS
#define LOUDNESS(energy)
Definition: f_ebur128.c:514
sbc_synthesize_four
static void sbc_synthesize_four(struct sbc_decoder_state *state, struct sbc_frame *frame, int ch, int blk, AVFrame *output_frame)
Definition: sbcdec.c:214
sbc_frame::blocks
uint8_t blocks
Definition: sbc.h:86
temp
else temp
Definition: vf_mcdeint.c:248
ff_sbc_calculate_bits
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
Definition: sbc.c:78
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:425
ff_sbc_proto_8_80m0
const int32_t ff_sbc_proto_8_80m0[]
Definition: sbcdec_data.c:57
int32_t
int32_t
Definition: audioconvert.c:56
sbc_decoder_state
Definition: sbcdec.c:42
int
int
Definition: ffmpeg_filter.c:156