FFmpeg
interplayacm.c
Go to the documentation of this file.
1 /*
2  * Interplay ACM decoder
3  *
4  * Copyright (c) 2004-2008 Marko Kreen
5  * Copyright (c) 2008 Adam Gashlin
6  * Copyright (c) 2015 Paul B Mahol
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 #include "libavutil/intreadwrite.h"
22 #include "libavutil/thread.h"
23 
24 #define BITSTREAM_READER_LE
25 #include "avcodec.h"
26 #include "codec_internal.h"
27 #include "decode.h"
28 #include "get_bits.h"
29 
30 static const int8_t map_1bit[] = { -1, +1 };
31 static const int8_t map_2bit_near[] = { -2, -1, +1, +2 };
32 static const int8_t map_2bit_far[] = { -3, -2, +2, +3 };
33 static const int8_t map_3bit[] = { -4, -3, -2, -1, +1, +2, +3, +4 };
34 
35 static int mul_3x3 [3 * 3 * 3];
36 static int mul_3x5 [5 * 5 * 5];
37 static int mul_2x11[11 * 11];
38 
39 typedef struct InterplayACMContext {
42  uint8_t *bitstream;
44  uint64_t max_samples;
47 
48  int level;
49  int rows;
50  int cols;
52  int block_len;
53  int skip;
54 
55  int *block;
56  int *wrapbuf;
57  int *ampbuf;
58  int *midbuf;
60 
61 static av_cold void decode_init_static(void)
62 {
63  for (int x3 = 0; x3 < 3; x3++)
64  for (int x2 = 0; x2 < 3; x2++)
65  for (int x1 = 0; x1 < 3; x1++)
66  mul_3x3[x1 + x2 * 3 + x3 * 3 * 3] = x1 + (x2 << 4) + (x3 << 8);
67  for (int x3 = 0; x3 < 5; x3++)
68  for (int x2 = 0; x2 < 5; x2++)
69  for (int x1 = 0; x1 < 5; x1++)
70  mul_3x5[x1 + x2 * 5 + x3 * 5 * 5] = x1 + (x2 << 4) + (x3 << 8);
71  for (int x2 = 0; x2 < 11; x2++)
72  for (int x1 = 0; x1 < 11; x1++)
73  mul_2x11[x1 + x2 * 11] = x1 + (x2 << 4);
74 }
75 
77 {
78  static AVOnce init_static_once = AV_ONCE_INIT;
80 
81  s->avctx = avctx;
82  if (avctx->extradata_size < 14)
83  return AVERROR_INVALIDDATA;
84 
85  if (avctx->ch_layout.nb_channels <= 0) {
86  av_log(avctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", avctx->ch_layout.nb_channels);
87  return AVERROR_INVALIDDATA;
88  }
89 
90  s->max_samples = AV_RL32(avctx->extradata + 4) / avctx->ch_layout.nb_channels;
91  if (s->max_samples == 0)
92  s->max_samples = UINT64_MAX;
93  s->level = AV_RL16(avctx->extradata + 12) & 0xf;
94  s->rows = AV_RL16(avctx->extradata + 12) >> 4;
95  s->cols = 1 << s->level;
96  s->wrapbuf_len = 2 * s->cols - 2;
97  s->block_len = s->rows * s->cols;
98  s->max_framesize = s->block_len;
99 
100  s->block = av_calloc(s->block_len, sizeof(int));
101  s->wrapbuf = av_calloc(s->wrapbuf_len, sizeof(int));
102  s->ampbuf = av_calloc(0x10000, sizeof(int));
103  s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*s->bitstream) + 1, sizeof(*s->bitstream));
104  if (!s->block || !s->wrapbuf || !s->ampbuf || !s->bitstream)
105  return AVERROR(ENOMEM);
106 
107  s->midbuf = s->ampbuf + 0x8000;
108  avctx->sample_fmt = AV_SAMPLE_FMT_S16;
109 
110  ff_thread_once(&init_static_once, decode_init_static);
111 
112  return 0;
113 }
114 
115 #define set_pos(s, r, c, idx) do { \
116  unsigned pos = ((r) << s->level) + (c); \
117  s->block[pos] = s->midbuf[(idx)]; \
118  } while (0)
119 
120 static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
121 {
122  unsigned i;
123 
124  for (i = 0; i < s->rows; i++)
125  set_pos(s, i, col, 0);
126  return 0;
127 }
128 
129 static int bad(InterplayACMContext *s, unsigned ind, unsigned col)
130 {
131  return AVERROR_INVALIDDATA;
132 }
133 
134 static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
135 {
136  GetBitContext *gb = &s->gb;
137  unsigned int i;
138  int b, middle = 1 << (ind - 1);
139 
140  for (i = 0; i < s->rows; i++) {
141  b = get_bits(gb, ind);
142  set_pos(s, i, col, b - middle);
143  }
144  return 0;
145 }
146 
147 static int k13(InterplayACMContext *s, unsigned ind, unsigned col)
148 {
149  GetBitContext *gb = &s->gb;
150  unsigned i, b;
151 
152  for (i = 0; i < s->rows; i++) {
153  b = get_bits1(gb);
154  if (b == 0) {
155  set_pos(s, i++, col, 0);
156  if (i >= s->rows)
157  break;
158  set_pos(s, i, col, 0);
159  continue;
160  }
161  b = get_bits1(gb);
162  if (b == 0) {
163  set_pos(s, i, col, 0);
164  continue;
165  }
166  b = get_bits1(gb);
167  set_pos(s, i, col, map_1bit[b]);
168  }
169  return 0;
170 }
171 
172 static int k12(InterplayACMContext *s, unsigned ind, unsigned col)
173 {
174  GetBitContext *gb = &s->gb;
175  unsigned i, b;
176 
177  for (i = 0; i < s->rows; i++) {
178  b = get_bits1(gb);
179  if (b == 0) {
180  set_pos(s, i, col, 0);
181  continue;
182  }
183 
184  b = get_bits1(gb);
185  set_pos(s, i, col, map_1bit[b]);
186  }
187  return 0;
188 }
189 
190 static int k24(InterplayACMContext *s, unsigned ind, unsigned col)
191 {
192  GetBitContext *gb = &s->gb;
193  unsigned i, b;
194 
195  for (i = 0; i < s->rows; i++) {
196  b = get_bits1(gb);
197  if (b == 0) {
198  set_pos(s, i++, col, 0);
199  if (i >= s->rows) break;
200  set_pos(s, i, col, 0);
201  continue;
202  }
203 
204  b = get_bits1(gb);
205  if (b == 0) {
206  set_pos(s, i, col, 0);
207  continue;
208  }
209 
210  b = get_bits(gb, 2);
211  set_pos(s, i, col, map_2bit_near[b]);
212  }
213  return 0;
214 }
215 
216 static int k23(InterplayACMContext *s, unsigned ind, unsigned col)
217 {
218  GetBitContext *gb = &s->gb;
219  unsigned i, b;
220 
221  for (i = 0; i < s->rows; i++) {
222  b = get_bits1(gb);
223  if (b == 0) {
224  set_pos(s, i, col, 0);
225  continue;
226  }
227 
228  b = get_bits(gb, 2);
229  set_pos(s, i, col, map_2bit_near[b]);
230  }
231  return 0;
232 }
233 
234 static int k35(InterplayACMContext *s, unsigned ind, unsigned col)
235 {
236  GetBitContext *gb = &s->gb;
237  unsigned i, b;
238 
239  for (i = 0; i < s->rows; i++) {
240  b = get_bits1(gb);
241  if (b == 0) {
242  set_pos(s, i++, col, 0);
243  if (i >= s->rows)
244  break;
245  set_pos(s, i, col, 0);
246  continue;
247  }
248 
249  b = get_bits1(gb);
250  if (b == 0) {
251  set_pos(s, i, col, 0);
252  continue;
253  }
254 
255  b = get_bits1(gb);
256  if (b == 0) {
257  b = get_bits1(gb);
258  set_pos(s, i, col, map_1bit[b]);
259  continue;
260  }
261 
262  b = get_bits(gb, 2);
263  set_pos(s, i, col, map_2bit_far[b]);
264  }
265  return 0;
266 }
267 
268 static int k34(InterplayACMContext *s, unsigned ind, unsigned col)
269 {
270  GetBitContext *gb = &s->gb;
271  unsigned i, b;
272 
273  for (i = 0; i < s->rows; i++) {
274  b = get_bits1(gb);
275  if (b == 0) {
276  set_pos(s, i, col, 0);
277  continue;
278  }
279 
280  b = get_bits1(gb);
281  if (b == 0) {
282  b = get_bits1(gb);
283  set_pos(s, i, col, map_1bit[b]);
284  continue;
285  }
286 
287  b = get_bits(gb, 2);
288  set_pos(s, i, col, map_2bit_far[b]);
289  }
290  return 0;
291 }
292 
293 static int k45(InterplayACMContext *s, unsigned ind, unsigned col)
294 {
295  GetBitContext *gb = &s->gb;
296  unsigned i, b;
297 
298  for (i = 0; i < s->rows; i++) {
299  b = get_bits1(gb);
300  if (b == 0) {
301  set_pos(s, i, col, 0); i++;
302  if (i >= s->rows)
303  break;
304  set_pos(s, i, col, 0);
305  continue;
306  }
307 
308  b = get_bits1(gb);
309  if (b == 0) {
310  set_pos(s, i, col, 0);
311  continue;
312  }
313 
314  b = get_bits(gb, 3);
315  set_pos(s, i, col, map_3bit[b]);
316  }
317  return 0;
318 }
319 
320 static int k44(InterplayACMContext *s, unsigned ind, unsigned col)
321 {
322  GetBitContext *gb = &s->gb;
323  unsigned i, b;
324 
325  for (i = 0; i < s->rows; i++) {
326  b = get_bits1(gb);
327  if (b == 0) {
328  set_pos(s, i, col, 0);
329  continue;
330  }
331 
332  b = get_bits(gb, 3);
333  set_pos(s, i, col, map_3bit[b]);
334  }
335  return 0;
336 }
337 
338 static int t15(InterplayACMContext *s, unsigned ind, unsigned col)
339 {
340  GetBitContext *gb = &s->gb;
341  unsigned i, b;
342  int n1, n2, n3;
343 
344  for (i = 0; i < s->rows; i++) {
345  /* b = (x1) + (x2 * 3) + (x3 * 9) */
346  b = get_bits(gb, 5);
347  if (b > 26) {
348  av_log(s->avctx, AV_LOG_ERROR, "Too large b = %d > 26\n", b);
349  return AVERROR_INVALIDDATA;
350  }
351 
352  n1 = (mul_3x3[b] & 0x0F) - 1;
353  n2 = ((mul_3x3[b] >> 4) & 0x0F) - 1;
354  n3 = ((mul_3x3[b] >> 8) & 0x0F) - 1;
355 
356  set_pos(s, i++, col, n1);
357  if (i >= s->rows)
358  break;
359  set_pos(s, i++, col, n2);
360  if (i >= s->rows)
361  break;
362  set_pos(s, i, col, n3);
363  }
364  return 0;
365 }
366 
367 static int t27(InterplayACMContext *s, unsigned ind, unsigned col)
368 {
369  GetBitContext *gb = &s->gb;
370  unsigned i, b;
371  int n1, n2, n3;
372 
373  for (i = 0; i < s->rows; i++) {
374  /* b = (x1) + (x2 * 5) + (x3 * 25) */
375  b = get_bits(gb, 7);
376  if (b > 124) {
377  av_log(s->avctx, AV_LOG_ERROR, "Too large b = %d > 124\n", b);
378  return AVERROR_INVALIDDATA;
379  }
380 
381  n1 = (mul_3x5[b] & 0x0F) - 2;
382  n2 = ((mul_3x5[b] >> 4) & 0x0F) - 2;
383  n3 = ((mul_3x5[b] >> 8) & 0x0F) - 2;
384 
385  set_pos(s, i++, col, n1);
386  if (i >= s->rows)
387  break;
388  set_pos(s, i++, col, n2);
389  if (i >= s->rows)
390  break;
391  set_pos(s, i, col, n3);
392  }
393  return 0;
394 }
395 
396 static int t37(InterplayACMContext *s, unsigned ind, unsigned col)
397 {
398  GetBitContext *gb = &s->gb;
399  unsigned i, b;
400  int n1, n2;
401  for (i = 0; i < s->rows; i++) {
402  /* b = (x1) + (x2 * 11) */
403  b = get_bits(gb, 7);
404  if (b > 120) {
405  av_log(s->avctx, AV_LOG_ERROR, "Too large b = %d > 120\n", b);
406  return AVERROR_INVALIDDATA;
407  }
408 
409  n1 = (mul_2x11[b] & 0x0F) - 5;
410  n2 = ((mul_2x11[b] >> 4) & 0x0F) - 5;
411 
412  set_pos(s, i++, col, n1);
413  if (i >= s->rows)
414  break;
415  set_pos(s, i, col, n2);
416  }
417  return 0;
418 }
419 
420 typedef int (*filler)(InterplayACMContext *s, unsigned ind, unsigned col);
421 
422 static const filler filler_list[] = {
423  zero, bad, bad, linear,
427  linear, k13, k12, t15,
428  k24, k23, t27, k35,
429  k34, bad, k45, k44,
430  bad, t37, bad, bad,
431 };
432 
434 {
435  GetBitContext *gb = &s->gb;
436  unsigned i, ind;
437  int ret;
438 
439  for (i = 0; i < s->cols; i++) {
440  ind = get_bits(gb, 5);
441  ret = filler_list[ind](s, ind, i);
442  if (ret < 0)
443  return ret;
444  }
445  return 0;
446 }
447 
448 static void juggle(int *wrap_p, int *block_p, unsigned sub_len, unsigned sub_count)
449 {
450  unsigned i, j;
451  int *p;
452  unsigned int r0, r1, r2, r3;
453 
454  for (i = 0; i < sub_len; i++) {
455  p = block_p;
456  r0 = wrap_p[0];
457  r1 = wrap_p[1];
458  for (j = 0; j < sub_count/2; j++) {
459  r2 = *p;
460  *p = r1 * 2 + (r0 + r2);
461  p += sub_len;
462  r3 = *p;
463  *p = r2 * 2 - (r1 + r3);
464  p += sub_len;
465  r0 = r2;
466  r1 = r3;
467  }
468 
469  *wrap_p++ = r0;
470  *wrap_p++ = r1;
471  block_p++;
472  }
473 }
474 
476 {
477  unsigned sub_count, sub_len, todo_count, step_subcount, i;
478  int *wrap_p, *block_p, *p;
479 
480  /* juggle only if subblock_len > 1 */
481  if (s->level == 0)
482  return;
483 
484  /* 2048 / subblock_len */
485  if (s->level > 9)
486  step_subcount = 1;
487  else
488  step_subcount = (2048 >> s->level) - 2;
489 
490  /* Apply juggle() (rows)x(cols)
491  * from (step_subcount * 2) x (subblock_len/2)
492  * to (step_subcount * subblock_len) x (1)
493  */
494  todo_count = s->rows;
495  block_p = s->block;
496  while (1) {
497  wrap_p = s->wrapbuf;
498  sub_count = step_subcount;
499  if (sub_count > todo_count)
500  sub_count = todo_count;
501 
502  sub_len = s->cols / 2;
503  sub_count *= 2;
504 
505  juggle(wrap_p, block_p, sub_len, sub_count);
506  wrap_p += sub_len * 2;
507 
508  for (i = 0, p = block_p; i < sub_count; i++) {
509  p[0]++;
510  p += sub_len;
511  }
512 
513  while (sub_len > 1) {
514  sub_len /= 2;
515  sub_count *= 2;
516  juggle(wrap_p, block_p, sub_len, sub_count);
517  wrap_p += sub_len * 2;
518  }
519 
520  if (todo_count <= step_subcount)
521  break;
522 
523  todo_count -= step_subcount;
524  block_p += step_subcount << s->level;
525  }
526 }
527 
529 {
530  GetBitContext *gb = &s->gb;
531  int pwr, count, val, i, x, ret;
532 
533  pwr = get_bits(gb, 4);
534  val = get_bits(gb, 16);
535 
536  count = 1 << pwr;
537 
538  for (i = 0, x = 0; i < count; i++) {
539  s->midbuf[i] = x;
540  x += val;
541  }
542 
543  for (i = 1, x = -val; i <= count; i++) {
544  s->midbuf[-i] = x;
545  x -= (unsigned)val;
546  }
547 
548  ret = fill_block(s);
549  if (ret < 0)
550  return ret;
551 
552  juggle_block(s);
553 
554  return 0;
555 }
556 
558  int *got_frame_ptr, AVPacket *pkt)
559 {
560  InterplayACMContext *s = avctx->priv_data;
561  GetBitContext *gb = &s->gb;
562  const uint8_t *buf;
563  int16_t *samples;
564  int ret, n, buf_size, input_buf_size;
565 
566  if (!pkt->size && !s->bitstream_size) {
567  *got_frame_ptr = 0;
568  return 0;
569  }
570 
571  buf_size = FFMIN(pkt->size, s->max_framesize - s->bitstream_size);
572  input_buf_size = buf_size;
573  if (s->bitstream_index + s->bitstream_size + buf_size > s->max_framesize) {
574  memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
575  s->bitstream_index = 0;
576  }
577  if (pkt->data)
578  memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], pkt->data, buf_size);
579  buf = &s->bitstream[s->bitstream_index];
580  buf_size += s->bitstream_size;
581  s->bitstream_size = buf_size;
582  if (buf_size < s->max_framesize && pkt->data) {
583  *got_frame_ptr = 0;
584  return input_buf_size;
585  }
586 
587  if ((ret = init_get_bits8(gb, buf, buf_size)) < 0)
588  return ret;
589 
590  frame->nb_samples = FFMIN(s->block_len / avctx->ch_layout.nb_channels, s->max_samples);
591  s->max_samples -= FFMIN(frame->nb_samples, s->max_samples);
592  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
593  return ret;
594 
595  skip_bits(gb, s->skip);
596  ret = decode_block(s);
597  if (ret < 0)
598  return ret;
599 
600  samples = (int16_t *)frame->data[0];
601  for (n = 0; n < frame->nb_samples * avctx->ch_layout.nb_channels; n++) {
602  int val = s->block[n] >> s->level;
603  *samples++ = val;
604  }
605 
606  *got_frame_ptr = 1;
607  s->skip = get_bits_count(gb) - 8 * (get_bits_count(gb) / 8);
608  n = get_bits_count(gb) / 8;
609 
610  if (n > buf_size && pkt->data) {
611  s->bitstream_size = 0;
612  s->bitstream_index = 0;
613  return AVERROR_INVALIDDATA;
614  }
615 
616  if (s->bitstream_size > 0) {
617  s->bitstream_index += n;
618  s->bitstream_size -= FFMIN(s->bitstream_size, n);
619  return input_buf_size;
620  }
621  return n;
622 }
623 
625 {
626  InterplayACMContext *s = avctx->priv_data;
627 
628  av_freep(&s->block);
629  av_freep(&s->wrapbuf);
630  av_freep(&s->ampbuf);
631  av_freep(&s->bitstream);
632  s->bitstream_size = 0;
633 
634  return 0;
635 }
636 
638  .p.name = "interplayacm",
639  CODEC_LONG_NAME("Interplay ACM"),
640  .p.type = AVMEDIA_TYPE_AUDIO,
642  .init = decode_init,
643  .close = decode_close,
645  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1,
646  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
647  .priv_data_size = sizeof(InterplayACMContext),
648 };
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
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
decode_init_static
static av_cold void decode_init_static(void)
Definition: interplayacm.c:61
k45
static int k45(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:293
AV_CODEC_ID_INTERPLAY_ACM
@ AV_CODEC_ID_INTERPLAY_ACM
Definition: codec_id.h:518
thread.h
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *pkt)
Definition: interplayacm.c:557
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
decode_block
static int decode_block(InterplayACMContext *s)
Definition: interplayacm.c:528
AVPacket::data
uint8_t * data
Definition: packet.h:522
b
#define b
Definition: input.c:41
map_2bit_near
static const int8_t map_2bit_near[]
Definition: interplayacm.c:31
linear
static int linear(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:134
ff_interplay_acm_decoder
const FFCodec ff_interplay_acm_decoder
Definition: interplayacm.c:637
FFCodec
Definition: codec_internal.h:127
InterplayACMContext::wrapbuf
int * wrapbuf
Definition: interplayacm.c:56
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
InterplayACMContext::bitstream_size
int bitstream_size
Definition: interplayacm.c:45
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
InterplayACMContext::skip
int skip
Definition: interplayacm.c:53
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
map_2bit_far
static const int8_t map_2bit_far[]
Definition: interplayacm.c:32
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
InterplayACMContext::cols
int cols
Definition: interplayacm.c:50
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:1065
GetBitContext
Definition: get_bits.h:108
val
static double val(void *priv, double ch)
Definition: aeval.c:78
mul_3x5
static int mul_3x5[5 *5 *5]
Definition: interplayacm.c:36
set_pos
#define set_pos(s, r, c, idx)
Definition: interplayacm.c:115
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:205
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
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
k44
static int k44(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:320
t15
static int t15(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:338
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
InterplayACMContext::avctx
AVCodecContext * avctx
Definition: interplayacm.c:40
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
InterplayACMContext::max_samples
uint64_t max_samples
Definition: interplayacm.c:44
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
k35
static int k35(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:234
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
k34
static int k34(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:268
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: interplayacm.c:76
mul_2x11
static int mul_2x11[11 *11]
Definition: interplayacm.c:37
k12
static int k12(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:172
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: interplayacm.c:624
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
InterplayACMContext::bitstream
uint8_t * bitstream
Definition: interplayacm.c:42
InterplayACMContext::midbuf
int * midbuf
Definition: interplayacm.c:58
InterplayACMContext
Definition: interplayacm.c:39
AVOnce
#define AVOnce
Definition: thread.h:202
juggle_block
static void juggle_block(InterplayACMContext *s)
Definition: interplayacm.c:475
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1568
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:523
codec_internal.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
juggle
static void juggle(int *wrap_p, int *block_p, unsigned sub_len, unsigned sub_count)
Definition: interplayacm.c:448
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1057
filler_list
static const filler filler_list[]
Definition: interplayacm.c:422
t27
static int t27(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:367
InterplayACMContext::block
int * block
Definition: interplayacm.c:55
zero
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:120
InterplayACMContext::bitstream_index
int bitstream_index
Definition: interplayacm.c:46
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:420
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
k23
static int k23(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:216
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
map_1bit
static const int8_t map_1bit[]
Definition: interplayacm.c:30
InterplayACMContext::wrapbuf_len
int wrapbuf_len
Definition: interplayacm.c:51
InterplayACMContext::gb
GetBitContext gb
Definition: interplayacm.c:41
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_SAMPLE_FMT_S16
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition: samplefmt.h:58
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:262
avcodec.h
fill_block
static int fill_block(InterplayACMContext *s)
Definition: interplayacm.c:433
InterplayACMContext::block_len
int block_len
Definition: interplayacm.c:52
ret
ret
Definition: filter_design.txt:187
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
t37
static int t37(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:396
AVCodecContext
main external API structure.
Definition: avcodec.h:445
k13
static int k13(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:147
filler
int(* filler)(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:420
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
mul_3x3
static int mul_3x3[3 *3 *3]
Definition: interplayacm.c:35
samples
Filter the word “frame” indicates either a video frame or a group of audio samples
Definition: filter_design.txt:8
InterplayACMContext::max_framesize
int max_framesize
Definition: interplayacm.c:43
bad
static int bad(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:129
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
map_3bit
static const int8_t map_3bit[]
Definition: interplayacm.c:33
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
k24
static int k24(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:190
InterplayACMContext::level
int level
Definition: interplayacm.c:48
InterplayACMContext::rows
int rows
Definition: interplayacm.c:49
int
int
Definition: ffmpeg_filter.c:425
InterplayACMContext::ampbuf
int * ampbuf
Definition: interplayacm.c:57