FFmpeg  4.3.9
imm4.c
Go to the documentation of this file.
1 /*
2  * Infinity IMM4 decoder
3  *
4  * Copyright (c) 2018 Paul B Mahol
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 
27 #include "libavutil/thread.h"
28 
29 #include "avcodec.h"
30 #include "bswapdsp.h"
31 #include "copy_block.h"
32 #include "get_bits.h"
33 #include "idctdsp.h"
34 #include "internal.h"
35 
36 typedef struct IMM4Context {
39 
43 
44  int factor;
45  unsigned lo;
46  unsigned hi;
47 
49  DECLARE_ALIGNED(32, int16_t, block)[6][64];
51 } IMM4Context;
52 
53 static const uint8_t intra_cb[] = {
54  24, 18, 12
55 };
56 
57 static const uint8_t inter_cb[] = {
58  30, 20, 15
59 };
60 
61 static const uint8_t cbplo_symbols[] = {
62  3, 4, 19, 20, 35, 36, 51, 52
63 };
64 
65 static const uint8_t cbplo_bits[] = {
66  1, 4, 3, 6, 3, 6, 3, 6
67 };
68 
69 static const uint8_t cbplo_codes[] = {
70  1, 1, 1, 1, 2, 2, 3, 3
71 };
72 
73 static const uint8_t cbphi_bits[] = {
74  4, 5, 5, 4, 5, 4, 6, 4, 5, 6, 4, 4, 4, 4, 4, 2
75 };
76 
77 static const uint8_t cbphi_codes[] = {
78  3, 5, 4, 9, 3, 7, 2, 11, 2, 3, 5, 10, 4, 8, 6, 3
79 };
80 
81 static const uint8_t blktype_symbols[] = {
82  0, 1, 2, 3, 4, 16, 17, 18, 19, 20, 32, 33, 34, 35, 48, 50, 51, 52
83 };
84 
85 static const uint8_t blktype_bits[] = {
86  1, 3, 3, 5, 6, 4, 7, 7, 8, 9, 4, 7, 7, 8, 6, 8, 7, 9
87 };
88 
89 static const uint8_t blktype_codes[] = {
90  1, 3, 2, 3, 4, 3, 7, 5, 4, 4, 2, 6, 4, 3, 5, 5, 3, 2
91 };
92 
93 static const uint16_t block_symbols[] = {
94  0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0x81, 0x82, 0x83,
95  0x84, 0x85, 0x86, 0x101, 0x102, 0x103, 0x104, 0x181, 0x182, 0x183, 0x201, 0x202,
96  0x203, 0x281, 0x282, 0x283, 0x301, 0x302, 0x303, 0x381, 0x382, 0x401, 0x402,
97  0x481, 0x482, 0x501, 0x502, 0x581, 0x601, 0x681, 0x701, 0x781, 0x801, 0x881,
98  0x901, 0x981, 0xA01, 0xA81, 0xB01, 0xB81, 0xC01, 0xC81, 0xD01, 0x4001, 0x4002,
99  0x4003, 0x4081, 0x4082, 0x4101, 0x4181, 0x4201, 0x4281, 0x4301, 0x4381, 0x4401,
100  0x4481, 0x4501, 0x4581, 0x4601, 0x4681, 0x4701, 0x4781, 0x4801, 0x4881, 0x4901,
101  0x4981, 0x4A01, 0x4A81, 0x4B01, 0x4B81, 0x4C01, 0x4C81, 0x4D01, 0x4D81, 0x4E01,
102  0x4E81, 0x4F01, 0x4F81, 0x5001, 0x5081, 0x5101, 0x5181, 0x5201, 0x5281, 0x5301,
103  0x5381, 0x5401
104 };
105 
106 static const uint8_t block_bits[] = {
107  7, 2, 4, 6, 7, 8, 9, 9, 10, 10, 11, 11, 11, 3, 6, 8, 10, 11, 12, 4, 8,
108  10, 12, 5, 9, 10, 5, 9, 12, 5, 10, 12, 6, 10, 12, 6, 10, 6, 10, 6,
109  10, 7, 12, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 12, 12, 4, 9,
110  11, 6, 11, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
111  9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
112  12, 12
113 };
114 
115 static const uint8_t block_codes[] = {
116  3, 2, 15, 21, 23, 31, 37, 36, 33, 32, 7, 6, 32, 6, 20, 30, 15, 33, 80,
117  14, 29, 14, 81, 13, 35, 13, 12, 34, 82, 11, 12, 83, 19, 11, 84, 18,
118  10, 17, 9, 16, 8, 22, 85, 21, 20, 28, 27, 33, 32, 31, 30, 29, 28,
119  27, 26, 34, 35, 86, 87, 7, 25, 5, 15, 4, 14, 13, 12, 19, 18, 17, 16,
120  26, 25, 24, 23, 22, 21, 20, 19, 24, 23, 22, 21, 20, 19, 18, 17, 7,
121  6, 5, 4, 36, 37, 38, 39, 88, 89, 90, 91, 92, 93, 94, 95
122 };
123 
124 static VLC cbplo_tab;
125 static VLC cbphi_tab;
127 static VLC block_tab;
128 
129 static int get_cbphi(GetBitContext *gb, int x)
130 {
131  int value;
132 
133  value = get_vlc2(gb, cbphi_tab.table, cbphi_tab.bits, 1);
134  if (value < 0)
135  return AVERROR_INVALIDDATA;
136 
137  return x ? value : 15 - value;
138 }
139 
141  int block, int factor, int flag, int offset, int flag2)
142 {
143  IMM4Context *s = avctx->priv_data;
144  const uint8_t *scantable = s->intra_scantable.permutated;
145  int i, last, len, factor2;
146 
147  for (i = !flag; i < 64; i++) {
148  int value;
149 
150  value = get_vlc2(gb, block_tab.table, block_tab.bits, 1);
151  if (value < 0)
152  return AVERROR_INVALIDDATA;
153  if (value == 0) {
154  last = get_bits1(gb);
155  len = get_bits(gb, 6);
156  factor2 = get_sbits(gb, 8);
157  } else {
158  factor2 = value & 0x7F;
159  last = (value >> 14) & 1;
160  len = (value >> 7) & 0x3F;
161  if (get_bits1(gb))
162  factor2 = -factor2;
163  }
164  i += len;
165  if (i >= 64)
166  break;
167  s->block[block][scantable[i]] = offset * (factor2 < 0 ? -1 : 1) + factor * factor2;
168  if (last)
169  break;
170  }
171 
172  if (s->hi == 2 && flag2 && block < 4) {
173  if (flag)
174  s->block[block][scantable[0]] *= 2;
175  s->block[block][scantable[1]] *= 2;
176  s->block[block][scantable[8]] *= 2;
177  s->block[block][scantable[16]] *= 2;
178  }
179 
180  return 0;
181 }
182 
184  unsigned cbp, int flag, int offset, unsigned flag2)
185 {
186  IMM4Context *s = avctx->priv_data;
187  const uint8_t *scantable = s->intra_scantable.permutated;
188  int ret, i;
189 
190  memset(s->block, 0, sizeof(s->block));
191 
192  for (i = 0; i < 6; i++) {
193  if (!flag) {
194  int x = get_bits(gb, 8);
195 
196  if (x == 255)
197  x = 128;
198  x *= 8;
199 
200  s->block[i][scantable[0]] = x;
201  }
202 
203  if (cbp & (1 << (5 - i))) {
204  ret = decode_block(avctx, gb, i, s->factor, flag, offset, flag2);
205  if (ret < 0)
206  return ret;
207  }
208  }
209 
210  return 0;
211 }
212 
214 {
215  IMM4Context *s = avctx->priv_data;
216  int ret, x, y, offset = 0;
217 
218  if (s->hi == 0) {
219  if (s->lo > 2)
220  return AVERROR_INVALIDDATA;
221  s->factor = intra_cb[s->lo];
222  } else {
223  s->factor = s->lo * 2;
224  }
225 
226  if (s->hi) {
227  offset = s->factor;
228  offset >>= 1;
229  if (!(offset & 1))
230  offset--;
231  }
232 
233  for (y = 0; y < avctx->height; y += 16) {
234  for (x = 0; x < avctx->width; x += 16) {
235  unsigned flag, cbplo;
236  int cbphi;
237 
238  cbplo = get_vlc2(gb, cbplo_tab.table, cbplo_tab.bits, 1) >> 4;
239  flag = get_bits1(gb);
240 
241  cbphi = get_cbphi(gb, 1);
242  if (cbphi < 0)
243  return cbphi;
244 
245  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag);
246  if (ret < 0)
247  return ret;
248 
249  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
250  frame->linesize[0], s->block[0]);
251  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
252  frame->linesize[0], s->block[1]);
253  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
254  frame->linesize[0], s->block[2]);
255  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
256  frame->linesize[0], s->block[3]);
257  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
258  frame->linesize[1], s->block[4]);
259  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
260  frame->linesize[2], s->block[5]);
261  }
262  }
263 
264  return 0;
265 }
266 
268  AVFrame *frame, AVFrame *prev)
269 {
270  IMM4Context *s = avctx->priv_data;
271  int ret, x, y, offset = 0;
272 
273  if (s->hi == 0) {
274  if (s->lo > 2)
275  return AVERROR_INVALIDDATA;
276  s->factor = inter_cb[s->lo];
277  } else {
278  s->factor = s->lo * 2;
279  }
280 
281  if (s->hi) {
282  offset = s->factor;
283  offset >>= 1;
284  if (!(offset & 1))
285  offset--;
286  }
287 
288  for (y = 0; y < avctx->height; y += 16) {
289  for (x = 0; x < avctx->width; x += 16) {
290  int reverse, intra_block, value;
291  unsigned cbplo, flag2 = 0;
292  int cbphi;
293 
294  if (get_bits1(gb)) {
295  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
296  prev->data[0] + y * prev->linesize[0] + x,
297  frame->linesize[0], prev->linesize[0], 16);
298  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
299  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
300  frame->linesize[1], prev->linesize[1], 8);
301  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
302  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
303  frame->linesize[2], prev->linesize[2], 8);
304  continue;
305  }
306 
307  value = get_vlc2(gb, blktype_tab.table, blktype_tab.bits, 1);
308  if (value < 0)
309  return AVERROR_INVALIDDATA;
310 
311  intra_block = value & 0x07;
312  reverse = intra_block == 3;
313  if (reverse)
314  flag2 = get_bits1(gb);
315 
316  cbplo = value >> 4;
317  cbphi = get_cbphi(gb, reverse);
318  if (cbphi < 0)
319  return cbphi;
320 
321  if (intra_block) {
322  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag2);
323  if (ret < 0)
324  return ret;
325 
326  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
327  frame->linesize[0], s->block[0]);
328  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
329  frame->linesize[0], s->block[1]);
330  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
331  frame->linesize[0], s->block[2]);
332  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
333  frame->linesize[0], s->block[3]);
334  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
335  frame->linesize[1], s->block[4]);
336  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
337  frame->linesize[2], s->block[5]);
338  } else {
339  flag2 = get_bits1(gb);
340  skip_bits1(gb);
341  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 1, offset, flag2);
342  if (ret < 0)
343  return ret;
344 
345  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
346  prev->data[0] + y * prev->linesize[0] + x,
347  frame->linesize[0], prev->linesize[0], 16);
348  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
349  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
350  frame->linesize[1], prev->linesize[1], 8);
351  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
352  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
353  frame->linesize[2], prev->linesize[2], 8);
354 
355  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x,
356  frame->linesize[0], s->block[0]);
357  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x + 8,
358  frame->linesize[0], s->block[1]);
359  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x,
360  frame->linesize[0], s->block[2]);
361  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
362  frame->linesize[0], s->block[3]);
363  s->idsp.idct_add(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
364  frame->linesize[1], s->block[4]);
365  s->idsp.idct_add(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
366  frame->linesize[2], s->block[5]);
367  }
368  }
369  }
370 
371  return 0;
372 }
373 
374 static int decode_frame(AVCodecContext *avctx, void *data,
375  int *got_frame, AVPacket *avpkt)
376 {
377  IMM4Context *s = avctx->priv_data;
378  GetBitContext *gb = &s->gb;
379  AVFrame *frame = data;
380  int width, height;
381  unsigned type;
382  int ret, scaled;
383 
384  if (avpkt->size <= 32)
385  return AVERROR_INVALIDDATA;
386 
388  FFALIGN(avpkt->size, 4));
389  if (!s->bitstream)
390  return AVERROR(ENOMEM);
391 
392  s->bdsp.bswap_buf((uint32_t *)s->bitstream,
393  (uint32_t *)avpkt->data,
394  (avpkt->size + 3) >> 2);
395 
396  if ((ret = init_get_bits8(gb, s->bitstream, FFALIGN(avpkt->size, 4))) < 0)
397  return ret;
398 
399  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
400  avctx->color_range = AVCOL_RANGE_JPEG;
401 
402  width = avctx->width;
403  height = avctx->height;
404 
405  scaled = avpkt->data[8];
406  if (scaled < 2) {
407  int mode = avpkt->data[10];
408 
409  switch (mode) {
410  case 1:
411  width = 352;
412  height = 240;
413  break;
414  case 2:
415  width = 704;
416  height = 240;
417  break;
418  case 4:
419  width = 480;
420  height = 704;
421  break;
422  case 17:
423  width = 352;
424  height = 288;
425  break;
426  case 18:
427  width = 704;
428  height = 288;
429  break;
430  default:
431  width = 704;
432  height = 576;
433  break;
434  }
435  }
436 
437  skip_bits_long(gb, 24 * 8);
438  type = get_bits_long(gb, 32);
439  s->hi = get_bits(gb, 16);
440  s->lo = get_bits(gb, 16);
441 
442  switch (type) {
443  case 0x19781977:
444  frame->key_frame = 1;
445  frame->pict_type = AV_PICTURE_TYPE_I;
446  break;
447  case 0x12250926:
448  frame->key_frame = 0;
449  frame->pict_type = AV_PICTURE_TYPE_P;
450  break;
451  default:
452  avpriv_request_sample(avctx, "type %X", type);
453  return AVERROR_PATCHWELCOME;
454  }
455 
456  if (avctx->width != width ||
457  avctx->height != height) {
458  if (!frame->key_frame) {
459  av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
460  return AVERROR_INVALIDDATA;
461  }
463  }
464 
465  ret = ff_set_dimensions(avctx, width, height);
466  if (ret < 0)
467  return ret;
468 
469  if ((ret = ff_get_buffer(avctx, frame, frame->key_frame ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
470  return ret;
471 
472  if (frame->key_frame) {
473  ret = decode_intra(avctx, gb, frame);
474  if (ret < 0)
475  return ret;
476 
478  if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
479  return ret;
480  } else {
481  if (!s->prev_frame->data[0]) {
482  av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
483  return AVERROR_INVALIDDATA;
484  }
485 
486  ret = decode_inter(avctx, gb, frame, s->prev_frame);
487  if (ret < 0)
488  return ret;
489  }
490 
491  *got_frame = 1;
492 
493  return avpkt->size;
494 }
495 
497 {
499  cbplo_bits, 1, 1, cbplo_codes, 1, 1, cbplo_symbols, 1, 1, 512);
500 
502  cbphi_bits, 1, 1, cbphi_codes, 1, 1, NULL, 0, 0, 64);
503 
505  blktype_bits, 1, 1, blktype_codes, 1, 1, blktype_symbols, 1, 1, 512);
506 
508  block_bits, 1, 1, block_codes, 1, 1, block_symbols, 2, 2, 4096);
509 }
510 
512 {
513  static AVOnce init_static_once = AV_ONCE_INIT;
514  IMM4Context *s = avctx->priv_data;
515  uint8_t table[64];
516 
517  for (int i = 0; i < 64; i++)
518  table[i] = i;
519 
520  ff_bswapdsp_init(&s->bdsp);
521  ff_idctdsp_init(&s->idsp, avctx);
523 
524  s->prev_frame = av_frame_alloc();
525  if (!s->prev_frame)
526  return AVERROR(ENOMEM);
527 
528  ff_thread_once(&init_static_once, imm4_init_static_data);
529 
530  return 0;
531 }
532 
533 static void decode_flush(AVCodecContext *avctx)
534 {
535  IMM4Context *s = avctx->priv_data;
536 
538 }
539 
541 {
542  IMM4Context *s = avctx->priv_data;
543 
545  av_freep(&s->bitstream);
546  s->bitstream_size = 0;
547 
548  return 0;
549 }
550 
552  .name = "imm4",
553  .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"),
554  .type = AVMEDIA_TYPE_VIDEO,
555  .id = AV_CODEC_ID_IMM4,
556  .priv_data_size = sizeof(IMM4Context),
557  .init = decode_init,
558  .close = decode_close,
559  .decode = decode_frame,
560  .flush = decode_flush,
561  .capabilities = AV_CODEC_CAP_DR1,
562  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
564 };
#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:48
#define NULL
Definition: coverity.c:32
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
static void flush(AVCodecContext *avctx)
static VLC cbplo_tab
Definition: imm4.c:124
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
static const uint8_t blktype_bits[]
Definition: imm4.c:85
int16_t block[6][64]
Definition: imm4.c:49
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:104
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:291
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define avpriv_request_sample(...)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1161
Scantable.
Definition: idctdsp.h:31
int size
Definition: packet.h:356
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:736
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:70
uint8_t permutated[64]
Definition: idctdsp.h:33
static void copy_block8(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
Definition: copy_block.h:47
AVCodec.
Definition: codec.h:190
static int get_sbits(GetBitContext *s, int n)
Definition: get_bits.h:359
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static const uint16_t block_symbols[]
Definition: imm4.c:93
GetBitContext gb
Definition: imm4.c:38
static int get_cbphi(GetBitContext *gb, int x)
Definition: imm4.c:129
#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:40
uint8_t
#define av_cold
Definition: attributes.h:88
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:190
static uint32_t reverse(uint32_t num, int bits)
Definition: speedhq.c:567
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
Definition: bswapdsp.h:25
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:444
static AVFrame * frame
const char data[16]
Definition: mxf.c:91
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:112
#define height
unsigned lo
Definition: imm4.c:45
uint8_t * data
Definition: packet.h:355
static av_cold void imm4_init_static_data(void)
Definition: imm4.c:496
bitstream reader API header.
static void decode_flush(AVCodecContext *avctx)
Definition: imm4.c:533
#define AVOnce
Definition: thread.h:172
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
static const uint16_t table[]
Definition: prosumer.c:206
static const uint8_t blktype_codes[]
Definition: imm4.c:89
uint8_t * bitstream
Definition: imm4.c:41
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:188
const char * name
Name of the codec implementation.
Definition: codec.h:197
static const uint8_t offset[127][2]
Definition: vf_spp.c:93
Definition: vlc.h:26
static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame, AVFrame *prev)
Definition: imm4.c:267
static const uint8_t cbplo_codes[]
Definition: imm4.c:69
static av_cold int decode_close(AVCodecContext *avctx)
Definition: imm4.c:540
AVCodec ff_imm4_decoder
Definition: imm4.c:551
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:383
int factor
Definition: imm4.c:44
#define width
int width
picture width / height.
Definition: avcodec.h:699
void(* idct_add)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
Definition: idctdsp.h:79
#define s(width, name)
Definition: cbs_vp9.c:257
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:797
static VLC cbphi_tab
Definition: imm4.c:125
ScanTable intra_scantable
Definition: imm4.c:48
uint8_t idct_permutation[64]
IDCT input permutation.
Definition: idctdsp.h:96
void(* idct_put)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
Definition: idctdsp.h:72
BswapDSPContext bdsp
Definition: imm4.c:37
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:535
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int block, int factor, int flag, int offset, int flag2)
Definition: imm4.c:140
int bits
Definition: vlc.h:27
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
AVFrame * prev_frame
Definition: imm4.c:40
#define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
Definition: vlc.h:57
#define AV_ONCE_INIT
Definition: thread.h:173
Libavcodec external API header.
static const uint8_t cbphi_codes[]
Definition: imm4.c:77
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:331
static VLC blktype_tab
Definition: imm4.c:126
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:677
main external API structure.
Definition: avcodec.h:526
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1854
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:538
double value
Definition: eval.c:98
static int decode_blocks(AVCodecContext *avctx, GetBitContext *gb, unsigned cbp, int flag, int offset, unsigned flag2)
Definition: imm4.c:183
IDCTDSPContext idsp
Definition: imm4.c:50
cl_device_type type
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: imm4.c:374
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:546
static void copy_block16(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
Definition: copy_block.h:68
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:554
int bitstream_size
Definition: imm4.c:42
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:314
static const uint8_t cbphi_bits[]
Definition: imm4.c:73
static const uint8_t block_codes[]
Definition: imm4.c:115
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
common internal api header.
#define flag(name)
Definition: cbs_av1.c:568
static const uint8_t inter_cb[]
Definition: imm4.c:57
unsigned hi
Definition: imm4.c:46
static const uint8_t cbplo_bits[]
Definition: imm4.c:65
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition: bswapdsp.c:49
void * priv_data
Definition: avcodec.h:553
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
Definition: idctdsp.c:29
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
Definition: idctdsp.c:238
int len
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:175
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:378
#define av_freep(p)
static VLC block_tab
Definition: imm4.c:127
static const uint8_t block_bits[]
Definition: imm4.c:106
static const uint8_t intra_cb[]
Definition: imm4.c:53
static const uint8_t cbplo_symbols[]
Definition: imm4.c:61
This structure stores compressed data.
Definition: packet.h:332
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:509
mode
Use these values in ebur128_init (or&#39;ed).
Definition: ebur128.h:83
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:50
static const uint8_t blktype_symbols[]
Definition: imm4.c:81
Predicted.
Definition: avutil.h:275
static av_cold int decode_init(AVCodecContext *avctx)
Definition: imm4.c:511
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
Definition: imm4.c:213