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/intreadwrite.h"
22 #include "libavutil/mem.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 
29 typedef struct BitCount {
30  uint8_t bit;
31  unsigned count;
32 } BitCount;
33 
34 typedef struct BonkContext {
36  int skip;
37 
38  uint8_t *bitstream;
42 
43  uint64_t nb_samples;
44  int lossless;
45  int mid_side;
46  int n_taps;
49 
50  int state[2][2048], k[2048];
51  int *samples[2];
53  uint8_t quant[2048];
55 } BonkContext;
56 
57 static av_cold int bonk_close(AVCodecContext *avctx)
58 {
59  BonkContext *s = avctx->priv_data;
60 
61  av_freep(&s->bitstream);
62  av_freep(&s->input_samples);
63  av_freep(&s->samples[0]);
64  av_freep(&s->samples[1]);
65  av_freep(&s->bits);
66  s->bitstream_size = 0;
67 
68  return 0;
69 }
70 
71 static av_cold int bonk_init(AVCodecContext *avctx)
72 {
73  BonkContext *s = avctx->priv_data;
74 
76  if (avctx->extradata_size < 17)
77  return AVERROR(EINVAL);
78 
79  if (avctx->extradata[0]) {
80  av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
81  return AVERROR_INVALIDDATA;
82  }
83 
84  if (avctx->ch_layout.nb_channels < 1 || avctx->ch_layout.nb_channels > 2)
85  return AVERROR_INVALIDDATA;
86 
87  s->nb_samples = AV_RL32(avctx->extradata + 1) / avctx->ch_layout.nb_channels;
88  if (!s->nb_samples)
89  s->nb_samples = UINT64_MAX;
90  s->lossless = avctx->extradata[10] != 0;
91  s->mid_side = avctx->extradata[11] != 0;
92  s->n_taps = AV_RL16(avctx->extradata + 12);
93  if (!s->n_taps || s->n_taps > 2048)
94  return AVERROR(EINVAL);
95 
96  s->down_sampling = avctx->extradata[14];
97  if (!s->down_sampling)
98  return AVERROR(EINVAL);
99 
100  s->samples_per_packet = AV_RL16(avctx->extradata + 15);
101  if (!s->samples_per_packet)
102  return AVERROR(EINVAL);
103 
104  if (s->down_sampling * s->samples_per_packet < s->n_taps)
105  return AVERROR_INVALIDDATA;
106 
107  s->max_framesize = s->samples_per_packet * avctx->ch_layout.nb_channels * s->down_sampling * 16LL;
108  if (s->max_framesize > (INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) / 8)
109  return AVERROR_INVALIDDATA;
110 
111  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
112  if (!s->bitstream)
113  return AVERROR(ENOMEM);
114 
115  s->input_samples = av_calloc(s->samples_per_packet, sizeof(*s->input_samples));
116  if (!s->input_samples)
117  return AVERROR(ENOMEM);
118 
119  s->samples[0] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0]));
120  s->samples[1] = av_calloc(s->samples_per_packet * s->down_sampling, sizeof(*s->samples[0]));
121  if (!s->samples[0] || !s->samples[1])
122  return AVERROR(ENOMEM);
123 
124  s->bits = av_calloc(s->max_framesize * 8, sizeof(*s->bits));
125  if (!s->bits)
126  return AVERROR(ENOMEM);
127 
128  for (int i = 0; i < 512; i++) {
129  s->quant[i] = sqrt(i + 1);
130  }
131 
132  return 0;
133 }
134 
135 static unsigned read_uint_max(BonkContext *s, uint32_t max)
136 {
137  unsigned value = 0;
138 
139  if (max == 0)
140  return 0;
141 
142  av_assert0(max >> 31 == 0);
143 
144  for (unsigned i = 1; i <= max - value; i+=i)
145  if (get_bits1(&s->gb))
146  value += i;
147 
148  return value;
149 }
150 
151 static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
152 {
153  int i, low_bits = 0, x = 0, max_x;
154  int n_zeros = 0, step = 256, dominant = 0;
155  int pos = 0, level = 0;
156  BitCount *bits = s->bits;
157  int passes = 1;
158 
159  memset(buf, 0, entries * sizeof(*buf));
160  if (base_2_part) {
161  low_bits = get_bits(&s->gb, 4);
162 
163  if (low_bits)
164  for (i = 0; i < entries; i++)
165  buf[i] = get_bits(&s->gb, low_bits);
166  }
167 
168  while (n_zeros < entries) {
169  int steplet = step >> 8;
170 
171  if (get_bits_left(&s->gb) <= 0)
172  return AVERROR_INVALIDDATA;
173 
174  if (!get_bits1(&s->gb)) {
175  av_assert0(steplet >= 0);
176 
177  if (steplet > 0) {
178  bits[x ].bit = dominant;
179  bits[x++].count = steplet;
180  }
181 
182  if (!dominant)
183  n_zeros += steplet;
184 
185  if (step > INT32_MAX*8LL/9 + 1)
186  return AVERROR_INVALIDDATA;
187  step += step / 8;
188  } else if (steplet > 0) {
189  int actual_run = read_uint_max(s, steplet - 1);
190 
191  av_assert0(actual_run >= 0);
192 
193  if (actual_run > 0) {
194  bits[x ].bit = dominant;
195  bits[x++].count = actual_run;
196  }
197 
198  bits[x ].bit = !dominant;
199  bits[x++].count = 1;
200 
201  if (!dominant)
202  n_zeros += actual_run;
203  else
204  n_zeros++;
205 
206  step -= step / 8;
207  }
208 
209  if (step < 256) {
210  step = 65536 / step;
211  dominant = !dominant;
212  }
213  }
214 
215  max_x = x;
216  x = 0;
217  n_zeros = 0;
218  for (i = 0; n_zeros < entries; i++) {
219  if (x >= max_x)
220  return AVERROR_INVALIDDATA;
221 
222  if (pos >= entries) {
223  pos = 0;
224  level += passes << low_bits;
225  passes = 1;
226  if (bits[x].bit && bits[x].count > entries - n_zeros)
227  passes = bits[x].count / (entries - n_zeros);
228  }
229 
230  if (level > 1 << 16)
231  return AVERROR_INVALIDDATA;
232 
233  if (buf[pos] >= level) {
234  if (bits[x].bit)
235  buf[pos] += passes << low_bits;
236  else
237  n_zeros++;
238 
239  av_assert1(bits[x].count >= passes);
240  bits[x].count -= passes;
241  x += bits[x].count == 0;
242  }
243 
244  pos++;
245  }
246 
247  for (i = 0; i < entries; i++) {
248  if (buf[i] && get_bits1(&s->gb)) {
249  buf[i] = -buf[i];
250  }
251  }
252 
253  return 0;
254 }
255 
256 static inline int shift_down(int a, int b)
257 {
258  return (a >> b) + (a < 0);
259 }
260 
261 static inline int shift(int a, int b)
262 {
263  return a + (1 << b - 1) >> b;
264 }
265 
266 #define LATTICE_SHIFT 10
267 #define SAMPLE_SHIFT 4
268 #define SAMPLE_FACTOR (1 << SAMPLE_SHIFT)
269 
270 static int predictor_calc_error(int *k, int *state, int order, int error)
271 {
272  int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT);
273  int *k_ptr = &(k[order-2]),
274  *state_ptr = &(state[order-2]);
275 
276  for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) {
277  unsigned k_value = *k_ptr, state_value = *state_ptr;
278 
279  x -= (unsigned) shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT);
280  state_ptr[1] = state_value + shift_down(k_value * x, LATTICE_SHIFT);
281  }
282 
283  // don't drift too far, to avoid overflows
284  x = av_clip(x, -(SAMPLE_FACTOR << 16), SAMPLE_FACTOR << 16);
285 
286  state[0] = x;
287 
288  return x;
289 }
290 
291 static void predictor_init_state(int *k, unsigned *state, int order)
292 {
293  for (int i = order - 2; i >= 0; i--) {
294  unsigned x = state[i];
295 
296  for (int j = 0, p = i + 1; p < order; j++, p++) {
297  int tmp = x + shift_down(k[j] * state[p], LATTICE_SHIFT);
298 
299  state[p] += shift_down(k[j] * x, LATTICE_SHIFT);
300  x = tmp;
301  }
302  }
303 }
304 
306  int *got_frame_ptr, AVPacket *pkt)
307 {
308  BonkContext *s = avctx->priv_data;
309  GetBitContext *gb = &s->gb;
310  const uint8_t *buf;
311  int quant, n, buf_size, input_buf_size;
312  int ret = AVERROR_INVALIDDATA;
313 
314  if ((!pkt->size && !s->bitstream_size) || s->nb_samples == 0) {
315  *got_frame_ptr = 0;
316  return pkt->size;
317  }
318 
319  buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
320  input_buf_size = buf_size;
321  if (s->bitstream_index + s->bitstream_size + buf_size + AV_INPUT_BUFFER_PADDING_SIZE > s->max_framesize) {
322  memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
323  s->bitstream_index = 0;
324  }
325  if (pkt->data)
326  memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], pkt->data, buf_size);
327  buf = &s->bitstream[s->bitstream_index];
328  buf_size += s->bitstream_size;
329  s->bitstream_size = buf_size;
330  if (buf_size < s->max_framesize && pkt->data) {
331  *got_frame_ptr = 0;
332  return input_buf_size;
333  }
334 
335  frame->nb_samples = FFMIN(s->samples_per_packet * s->down_sampling, s->nb_samples);
336  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
337  goto fail;
338 
339  if ((ret = init_get_bits8(gb, buf, buf_size)) < 0)
340  goto fail;
341 
342  skip_bits(gb, s->skip);
343  if ((ret = intlist_read(s, s->k, s->n_taps, 0)) < 0)
344  goto fail;
345 
346  for (int i = 0; i < s->n_taps; i++)
347  s->k[i] *= s->quant[i];
348  quant = s->lossless ? 1 : get_bits(&s->gb, 16) * SAMPLE_FACTOR;
349 
350  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
351  const int samples_per_packet = s->samples_per_packet;
352  const int down_sampling = s->down_sampling;
353  const int offset = samples_per_packet * down_sampling - 1;
354  int *state = s->state[ch];
355  int *sample = s->samples[ch];
356 
357  predictor_init_state(s->k, state, s->n_taps);
358  if ((ret = intlist_read(s, s->input_samples, samples_per_packet, 1)) < 0)
359  goto fail;
360 
361  for (int i = 0; i < samples_per_packet; i++) {
362  for (int j = 0; j < s->down_sampling - 1; j++) {
363  sample[0] = predictor_calc_error(s->k, state, s->n_taps, 0);
364  sample++;
365  }
366 
367  sample[0] = predictor_calc_error(s->k, state, s->n_taps, s->input_samples[i] * (unsigned)quant);
368  sample++;
369  }
370 
371  sample = s->samples[ch];
372  for (int i = 0; i < s->n_taps; i++)
373  state[i] = sample[offset - i];
374  }
375 
376  if (s->mid_side && avctx->ch_layout.nb_channels == 2) {
377  for (int i = 0; i < frame->nb_samples; i++) {
378  s->samples[1][i] += shift(s->samples[0][i], 1);
379  s->samples[0][i] -= s->samples[1][i];
380  }
381  }
382 
383  if (!s->lossless) {
384  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
385  int *samples = s->samples[ch];
386  for (int i = 0; i < frame->nb_samples; i++)
387  samples[i] = shift(samples[i], 4);
388  }
389  }
390 
391  for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
392  int16_t *osamples = (int16_t *)frame->extended_data[ch];
393  int *samples = s->samples[ch];
394  for (int i = 0; i < frame->nb_samples; i++)
395  osamples[i] = av_clip_int16(samples[i]);
396  }
397 
398  s->nb_samples -= frame->nb_samples;
399 
400  s->skip = get_bits_count(gb) - 8 * (get_bits_count(gb) / 8);
401  n = get_bits_count(gb) / 8;
402 
403  if (n > buf_size) {
404 fail:
405  s->bitstream_size = 0;
406  s->bitstream_index = 0;
407  return AVERROR_INVALIDDATA;
408  }
409 
410  *got_frame_ptr = 1;
411 
412  if (s->bitstream_size) {
413  s->bitstream_index += n;
414  s->bitstream_size -= n;
415  return input_buf_size;
416  }
417  return n;
418 }
419 
421  .p.name = "bonk",
422  CODEC_LONG_NAME("Bonk audio"),
423  .p.type = AVMEDIA_TYPE_AUDIO,
424  .p.id = AV_CODEC_ID_BONK,
425  .priv_data_size = sizeof(BonkContext),
426  .init = bonk_init,
428  .close = bonk_close,
429  .p.capabilities = AV_CODEC_CAP_DELAY |
430 #if FF_API_SUBFRAMES
431  AV_CODEC_CAP_SUBFRAMES |
432 #endif
434  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
435  .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
437 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
level
uint8_t level
Definition: svq3.c:205
av_clip
#define av_clip
Definition: common.h:100
SAMPLE_FACTOR
#define SAMPLE_FACTOR
Definition: bonk.c:268
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:43
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:695
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:35
int64_t
long long int64_t
Definition: coverity.c:34
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
shift_down
static int shift_down(int a, int b)
Definition: bonk.c:256
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
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:539
read_uint_max
static unsigned read_uint_max(BonkContext *s, uint32_t max)
Definition: bonk.c:135
b
#define b
Definition: input.c:41
BonkContext::samples_per_packet
int samples_per_packet
Definition: bonk.c:48
FFCodec
Definition: codec_internal.h:127
BitCount::count
unsigned count
Definition: bonk.c:31
max
#define max(a, b)
Definition: cuda_runtime.h:33
BonkContext::mid_side
int mid_side
Definition: bonk.c:45
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
BitCount::bit
uint8_t bit
Definition: bonk.c:30
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:56
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1071
fail
#define fail()
Definition: checkasm.h:188
predictor_calc_error
static int predictor_calc_error(int *k, int *state, int order, int error)
Definition: bonk.c:270
GetBitContext
Definition: get_bits.h:108
quant
static const uint8_t quant[64]
Definition: vmixdec.c:71
bonk_decode
static int bonk_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
Definition: bonk.c:305
LATTICE_SHIFT
#define LATTICE_SHIFT
Definition: bonk.c:266
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
BonkContext
Definition: bonk.c:34
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
BonkContext::bitstream_index
int bitstream_index
Definition: bonk.c:41
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:530
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
bits
uint8_t bits
Definition: vp3data.h:128
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
BonkContext::samples
int * samples[2]
Definition: bonk.c:51
bonk_init
static av_cold int bonk_init(AVCodecContext *avctx)
Definition: bonk.c:71
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
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
av_clip_int16
#define av_clip_int16
Definition: common.h:115
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
BonkContext::input_samples
int * input_samples
Definition: bonk.c:52
BonkContext::k
int k[2048]
Definition: bonk.c:50
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1692
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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:540
codec_internal.h
shift
static int shift(int a, int b)
Definition: bonk.c:261
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:1063
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:47
BonkContext::n_taps
int n_taps
Definition: bonk.c:46
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:44
BonkContext::bits
BitCount * bits
Definition: bonk.c:54
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:256
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:529
BonkContext::quant
uint8_t quant[2048]
Definition: bonk.c:53
state
static struct @457 state
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
AV_CODEC_ID_BONK
@ AV_CODEC_ID_BONK
Definition: codec_id.h:538
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:39
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
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:414
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:420
BitCount
Definition: bonk.c:29
AVCodecContext
main external API structure.
Definition: avcodec.h:451
BonkContext::skip
int skip
Definition: bonk.c:36
BonkContext::state
int state[2][2048]
Definition: bonk.c:50
intlist_read
static int intlist_read(BonkContext *s, int *buf, int entries, int base_2_part)
Definition: bonk.c:151
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:76
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:43
BonkContext::bitstream
uint8_t * bitstream
Definition: bonk.c:38
mem.h
AVPacket
This structure stores compressed data.
Definition: packet.h:516
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
BonkContext::bitstream_size
int bitstream_size
Definition: bonk.c:40
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:57
samples_per_packet
static uint32_t samples_per_packet(const AVCodecParameters *par)
Definition: cafenc.c:57
predictor_init_state
static void predictor_init_state(int *k, unsigned *state, int order)
Definition: bonk.c:291