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