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