FFmpeg
bonk.c
Go to the documentation of this file.
1 /*
2  * Bonk audio decoder
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/internal.h"
22 #include "libavutil/intreadwrite.h"
23 #include "avcodec.h"
24 #include "codec_internal.h"
25 #include "decode.h"
26 #define BITSTREAM_READER_LE
27 #include "get_bits.h"
28 #include "bytestream.h"
29 
30 typedef struct BitCount {
31  uint8_t bit;
32  unsigned count;
33 } BitCount;
34 
35 typedef struct BonkContext {
37  int skip;
38 
39  uint8_t *bitstream;
40  int64_t max_framesize;
43 
44  uint64_t nb_samples;
45  int lossless;
46  int mid_side;
47  int n_taps;
50 
51  int state[2][2048], k[2048];
52  int *samples[2];
54  uint8_t quant[2048];
56 } BonkContext;
57 
58 static av_cold int bonk_close(AVCodecContext *avctx)
59 {
60  BonkContext *s = avctx->priv_data;
61 
62  av_freep(&s->bitstream);
63  av_freep(&s->input_samples);
64  av_freep(&s->samples[0]);
65  av_freep(&s->samples[1]);
66  av_freep(&s->bits);
67  s->bitstream_size = 0;
68 
69  return 0;
70 }
71 
72 static av_cold int bonk_init(AVCodecContext *avctx)
73 {
74  BonkContext *s = avctx->priv_data;
75 
77  if (avctx->extradata_size < 17)
78  return AVERROR(EINVAL);
79 
80  if (avctx->extradata[0]) {
81  av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
82  return AVERROR_INVALIDDATA;
83  }
84 
85  if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2)
86  return AVERROR_INVALIDDATA;
87 
88  s->nb_samples = AV_RL32(avctx->extradata + 1) / avctx->ch_layout.nb_channels;
89  if (!s->nb_samples)
90  s->nb_samples = UINT64_MAX;
91  s->lossless = avctx->extradata[10] != 0;
92  s->mid_side = avctx->extradata[11] != 0;
93  s->n_taps = AV_RL16(avctx->extradata + 12);
94  if (!s->n_taps || s->n_taps > 2048)
95  return AVERROR(EINVAL);
96 
97  s->down_sampling = avctx->extradata[14];
98  if (!s->down_sampling)
99  return AVERROR(EINVAL);
100 
101  s->samples_per_packet = AV_RL16(avctx->extradata + 15);
102  if (!s->samples_per_packet)
103  return AVERROR(EINVAL);
104  s->max_framesize = s->samples_per_packet * avctx->ch_layout.nb_channels * s->down_sampling * 16LL;
105  if (s->max_framesize > (INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) / 8)
106  return AVERROR_INVALIDDATA;
107 
108  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
109  if (!s->bitstream)
110  return AVERROR(ENOMEM);
111 
112  s->input_samples = av_calloc(s->samples_per_packet, sizeof(*s->input_samples));
113  if (!s->input_samples)
114  return AVERROR(ENOMEM);
115 
116  s->samples[0] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0]));
117  s->samples[1] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0]));
118  if (!s->samples[0] || !s->samples[1])
119  return AVERROR(ENOMEM);
120 
121  s->bits = av_calloc(s->max_framesize * 8, sizeof(*s->bits));
122  if (!s->bits)
123  return AVERROR(ENOMEM);
124 
125  for (int i = 0; i < 512; i++) {
126  s->quant[i] = sqrt(i + 1);
127  }
128 
129  return 0;
130 }
131 
132 static unsigned read_uint_max(BonkContext *s, uint32_t max)
133 {
134  unsigned value = 0;
135 
136  if (max == 0)
137  return 0;
138 
139  av_assert0(max >> 31 == 0);
140 
141  for (unsigned i = 1; i <= max - value; i+=i)
142  if (get_bits1(&s->gb))
143  value += i;
144 
145  return value;
146 }
147 
148 static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
149 {
150  int i, low_bits = 0, x = 0, max_x;
151  int n_zeros = 0, step = 256, dominant = 0;
152  int pos = 0, level = 0;
153  BitCount *bits = s->bits;
154 
155  memset(buf, 0, entries * sizeof(*buf));
156  if (base_2_part) {
157  low_bits = get_bits(&s->gb, 4);
158 
159  if (low_bits)
160  for (i = 0; i < entries; i++)
161  buf[i] = get_bits(&s->gb, low_bits);
162  }
163 
164  while (n_zeros < entries) {
165  int steplet = step >> 8;
166 
167  if (get_bits_left(&s->gb) <= 0)
168  return AVERROR_INVALIDDATA;
169 
170  if (!get_bits1(&s->gb)) {
171  av_assert0(steplet >= 0);
172 
173  if (steplet > 0) {
174  bits[x ].bit = dominant;
175  bits[x++].count = steplet;
176  }
177 
178  if (!dominant)
179  n_zeros += steplet;
180 
181  if (step > INT32_MAX*8LL/9 + 1)
182  return AVERROR_INVALIDDATA;
183  step += step / 8;
184  } else if (steplet > 0) {
185  int actual_run = read_uint_max(s, steplet - 1);
186 
187  av_assert0(actual_run >= 0);
188 
189  if (actual_run > 0) {
190  bits[x ].bit = dominant;
191  bits[x++].count = actual_run;
192  }
193 
194  bits[x ].bit = !dominant;
195  bits[x++].count = 1;
196 
197  if (!dominant)
198  n_zeros += actual_run;
199  else
200  n_zeros++;
201 
202  step -= step / 8;
203  }
204 
205  if (step < 256) {
206  step = 65536 / step;
207  dominant = !dominant;
208  }
209  }
210 
211  max_x = x;
212  x = 0;
213  n_zeros = 0;
214  for (i = 0; n_zeros < entries; i++) {
215  if (pos >= entries) {
216  pos = 0;
217  level += 1 << low_bits;
218  }
219 
220  if (level > 1 << 15)
221  return AVERROR_INVALIDDATA;
222 
223  if (x >= max_x)
224  return AVERROR_INVALIDDATA;
225 
226  if (buf[pos] >= level) {
227  if (bits[x].bit)
228  buf[pos] += 1 << low_bits;
229  else
230  n_zeros++;
231 
232  bits[x].count--;
233  x += bits[x].count == 0;
234  }
235 
236  pos++;
237  }
238 
239  for (i = 0; i < entries; i++) {
240  if (buf[i] && get_bits1(&s->gb)) {
241  buf[i] = -buf[i];
242  }
243  }
244 
245  return 0;
246 }
247 
248 static inline int shift_down(int a, int b)
249 {
250  return (a >> b) + (a < 0);
251 }
252 
253 static inline int shift(int a, int b)
254 {
255  return a + (1 << b - 1) >> b;
256 }
257 
258 #define LATTICE_SHIFT 10
259 #define SAMPLE_SHIFT 4
260 #define SAMPLE_FACTOR (1 << SAMPLE_SHIFT)
261 
262 static int predictor_calc_error(int *k, int *state, int order, int error)
263 {
264  int i, x = error - shift_down(k[order-1] * state[order-1], LATTICE_SHIFT);
265  int *k_ptr = &(k[order-2]),
266  *state_ptr = &(state[order-2]);
267 
268  for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) {
269  unsigned k_value = *k_ptr, state_value = *state_ptr;
270 
271  x -= shift_down(k_value * state_value, LATTICE_SHIFT);
272  state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
273  }
274 
275  // don't drift too far, to avoid overflows
276  x = av_clip(x, -(SAMPLE_FACTOR << 16), SAMPLE_FACTOR << 16);
277 
278  state[0] = x;
279 
280  return x;
281 }
282 
283 static void predictor_init_state(int *k, unsigned *state, int order)
284 {
285  for (int i = order - 2; i >= 0; i--) {
286  unsigned x = state[i];
287 
288  for (int j = 0, p = i + 1; p < order; j++, p++) {
289  int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT);
290 
291  state[p] += shift_down(k[j] * x, LATTICE_SHIFT);
292  x = tmp;
293  }
294  }
295 }
296 
298  int *got_frame_ptr, AVPacket *pkt)
299 {
300  BonkContext *s = avctx->priv_data;
301  GetBitContext *gb = &s->gb;
302  const uint8_t *buf;
303  int quant, n, buf_size, input_buf_size;
304  int ret = AVERROR_INVALIDDATA;
305 
306  if ((!pkt->size && !s->bitstream_size) || s->nb_samples == 0) {
307  *got_frame_ptr = 0;
308  return pkt->size;
309  }
310 
311  buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
312  input_buf_size = buf_size;
313  if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->max_framesize) {
314  memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
315  s->bitstream_index = 0;
316  }
317  if (pkt->data)
318  memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], pkt->data, buf_size);
319  buf = &s->bitstream[s->bitstream_index];
320  buf_size += s->bitstream_size;
321  s->bitstream_size = buf_size;
322  if (buf_size < s->max_framesize && pkt->data) {
323  *got_frame_ptr = 0;
324  return input_buf_size;
325  }
326 
327  frame->nb_samples = FFMIN(s->samples_per_packet * s->down_sampling, s->nb_samples);
328  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
329  return ret;
330 
331  if ((ret = init_get_bits8(gb, buf, buf_size)) < 0)
332  return ret;
333 
334  skip_bits(gb, s->skip);
335  if ((ret = intlist_read(s, s->k, s->n_taps, 0)) < 0)
336  goto fail;
337 
338  for (int i = 0; i < s->n_taps; i++)
339  s->k[i] *= s->quant[i];
340  quant = s->lossless ? 1 : get_bits(&s->gb, 16) * SAMPLE_FACTOR;
341 
342  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
343  const int samples_per_packet = s->samples_per_packet;
344  const int down_sampling = s->down_sampling;
345  const int offset = samples_per_packet * down_sampling - 1;
346  int *state = s->state[ch];
347  int *sample = s->samples[ch];
348 
349  predictor_init_state(s->k, state, s->n_taps);
350  if ((ret = intlist_read(s, s->input_samples, samples_per_packet, 1)) < 0)
351  goto fail;
352 
353  for (int i = 0; i < samples_per_packet; i++) {
354  for (int j = 0; j < s->down_sampling - 1; j++) {
355  sample[0] = predictor_calc_error(s->k, state, s->n_taps, 0);
356  sample++;
357  }
358 
359  sample[0] = predictor_calc_error(s->k, state, s->n_taps, s->input_samples[i] * quant);
360  sample++;
361  }
362 
363  sample = s->samples[ch];
364  for (int i = 0; i < s->n_taps; i++)
365  state[i] = sample[offset - i];
366  }
367 
368  if (s->mid_side && avctx->ch_layout.nb_channels == 2) {
369  for (int i = 0; i < frame->nb_samples; i++) {
370  s->samples[1][i] += shift(s->samples[0][i], 1);
371  s->samples[0][i] -= s->samples[1][i];
372  }
373  }
374 
375  if (!s->lossless) {
376  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
377  int *samples = s->samples[ch];
378  for (int i = 0; i < frame->nb_samples; i++)
379  samples[i] = shift(samples[i], 4);
380  }
381  }
382 
383  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
384  int16_t *osamples = (int16_t *)frame->extended_data[ch];
385  int *samples = s->samples[ch];
386  for (int i = 0; i < frame->nb_samples; i++)
387  osamples[i] = av_clip_int16(samples[i]);
388  }
389 
390  s->nb_samples -= frame->nb_samples;
391 
392  s->skip = get_bits_count(gb) - 8 * (get_bits_count(gb) / 8);
393  n = get_bits_count(gb) / 8;
394 
395  if (n > buf_size) {
396 fail:
397  s->bitstream_size = 0;
398  s->bitstream_index = 0;
399  return AVERROR_INVALIDDATA;
400  }
401 
402  *got_frame_ptr = 1;
403 
404  if (s->bitstream_size) {
405  s->bitstream_index += n;
406  s->bitstream_size -= n;
407  return input_buf_size;
408  }
409  return n;
410 }
411 
413  .p.name = "bonk",
414  CODEC_LONG_NAME("Bonk audio"),
415  .p.type = AVMEDIA_TYPE_AUDIO,
416  .p.id = AV_CODEC_ID_BONK,
417  .priv_data_size = sizeof(BonkContext),
418  .init = bonk_init,
420  .close = bonk_close,
421  .p.capabilities = AV_CODEC_CAP_DELAY |
424  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
425  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
427 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
level
uint8_t level
Definition: svq3.c:204
av_clip
#define av_clip
Definition: common.h:95
SAMPLE_FACTOR
#define SAMPLE_FACTOR
Definition: bonk.c:260
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:839
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
BonkContext::gb
GetBitContext gb
Definition: bonk.c:36
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
shift_down
static int shift_down(int a, int b)
Definition: bonk.c:248
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
AVPacket::data
uint8_t * data
Definition: packet.h:374
read_uint_max
static unsigned read_uint_max(BonkContext *s, uint32_t max)
Definition: bonk.c:132
b
#define b
Definition: input.c:41
BonkContext::samples_per_packet
int samples_per_packet
Definition: bonk.c:49
FFCodec
Definition: codec_internal.h:119
BitCount::count
unsigned count
Definition: bonk.c:32
max
#define max(a, b)
Definition: cuda_runtime.h:33
BonkContext::mid_side
int mid_side
Definition: bonk.c:46
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
BitCount::bit
uint8_t bit
Definition: bonk.c:31
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:58
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
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
fail
#define fail()
Definition: checkasm.h:134
predictor_calc_error
static int predictor_calc_error(int *k, int *state, int order, int error)
Definition: bonk.c:262
GetBitContext
Definition: get_bits.h:61
quant
static int quant(float coef, const float Q, const float rounding)
Quantize one coefficient.
Definition: aacenc_utils.h:59
bonk_decode
static int bonk_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
Definition: bonk.c:297
LATTICE_SHIFT
#define LATTICE_SHIFT
Definition: bonk.c:258
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
BonkContext
Definition: bonk.c:35
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:667
BonkContext::bitstream_index
int bitstream_index
Definition: bonk.c:42
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:500
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:298
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:363
bits
uint8_t bits
Definition: vp3data.h:128
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
BonkContext::samples
int * samples[2]
Definition: bonk.c:52
bonk_init
static av_cold int bonk_init(AVCodecContext *avctx)
Definition: bonk.c:72
decode.h
get_bits.h
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:94
state
static struct @344 state
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:264
av_clip_int16
#define av_clip_int16
Definition: common.h:110
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
BonkContext::input_samples
int * input_samples
Definition: bonk.c:53
BonkContext::k
int k[2048]
Definition: bonk.c:51
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
codec_internal.h
shift
static int shift(int a, int b)
Definition: bonk.c:253
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
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
sample
#define sample
Definition: flacdsp_template.c:44
BonkContext::down_sampling
int down_sampling
Definition: bonk.c:48
BonkContext::n_taps
int n_taps
Definition: bonk.c:47
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
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
BonkContext::lossless
int lossless
Definition: bonk.c:45
BonkContext::bits
BitCount * bits
Definition: bonk.c:55
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:499
BonkContext::quant
uint8_t quant[2048]
Definition: bonk.c:54
internal.h
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
AV_CODEC_ID_BONK
@ AV_CODEC_ID_BONK
Definition: codec_id.h:532
value
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 default value
Definition: writing_filters.txt:86
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
BonkContext::max_framesize
int64_t max_framesize
Definition: bonk.c:40
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:211
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:272
avcodec.h
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
pos
unsigned int pos
Definition: spdifenc.c:412
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ff_bonk_decoder
const FFCodec ff_bonk_decoder
Definition: bonk.c:412
BitCount
Definition: bonk.c:30
AVCodecContext
main external API structure.
Definition: avcodec.h:398
BonkContext::skip
int skip
Definition: bonk.c:37
BonkContext::state
int state[2][2048]
Definition: bonk.c:51
intlist_read
static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
Definition: bonk.c:148
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:82
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
BonkContext::nb_samples
uint64_t nb_samples
Definition: bonk.c:44
BonkContext::bitstream
uint8_t * bitstream
Definition: bonk.c:39
AV_CODEC_CAP_SUBFRAMES
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
Definition: codec.h:100
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:425
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
bytestream.h
BonkContext::bitstream_size
int bitstream_size
Definition: bonk.c:41
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
bonk_close
static av_cold int bonk_close(AVCodecContext *avctx)
Definition: bonk.c:58
samples_per_packet
static uint32_t samples_per_packet(const AVCodecParameters *par)
Definition: cafenc.c:56
predictor_init_state
static void predictor_init_state(int *k, unsigned *state, int order)
Definition: bonk.c:283