FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
45  int factor;
46  unsigned lo;
47  unsigned hi;
48 
50  DECLARE_ALIGNED(32, int16_t, block)[6][64];
52 } IMM4Context;
53 
54 static const uint8_t intra_cb[] = {
55  24, 18, 12
56 };
57 
58 static const uint8_t inter_cb[] = {
59  30, 20, 15
60 };
61 
62 static const uint8_t cbplo_symbols[] = {
63  3, 4, 19, 20, 35, 36, 51, 52
64 };
65 
66 static const uint8_t cbplo_bits[] = {
67  1, 4, 3, 6, 3, 6, 3, 6
68 };
69 
70 static const uint8_t cbplo_codes[] = {
71  1, 1, 1, 1, 2, 2, 3, 3
72 };
73 
74 static const uint8_t cbphi_bits[] = {
75  4, 5, 5, 4, 5, 4, 6, 4, 5, 6, 4, 4, 4, 4, 4, 2
76 };
77 
78 static const uint8_t cbphi_codes[] = {
79  3, 5, 4, 9, 3, 7, 2, 11, 2, 3, 5, 10, 4, 8, 6, 3
80 };
81 
82 static const uint8_t blktype_symbols[] = {
83  0, 1, 2, 3, 4, 16, 17, 18, 19, 20, 32, 33, 34, 35, 48, 50, 51, 52
84 };
85 
86 static const uint8_t blktype_bits[] = {
87  1, 3, 3, 5, 6, 4, 7, 7, 8, 9, 4, 7, 7, 8, 6, 8, 7, 9
88 };
89 
90 static const uint8_t blktype_codes[] = {
91  1, 3, 2, 3, 4, 3, 7, 5, 4, 4, 2, 6, 4, 3, 5, 5, 3, 2
92 };
93 
94 static const uint16_t block_symbols[] = {
95  0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0x81, 0x82, 0x83,
96  0x84, 0x85, 0x86, 0x101, 0x102, 0x103, 0x104, 0x181, 0x182, 0x183, 0x201, 0x202,
97  0x203, 0x281, 0x282, 0x283, 0x301, 0x302, 0x303, 0x381, 0x382, 0x401, 0x402,
98  0x481, 0x482, 0x501, 0x502, 0x581, 0x601, 0x681, 0x701, 0x781, 0x801, 0x881,
99  0x901, 0x981, 0xA01, 0xA81, 0xB01, 0xB81, 0xC01, 0xC81, 0xD01, 0x4001, 0x4002,
100  0x4003, 0x4081, 0x4082, 0x4101, 0x4181, 0x4201, 0x4281, 0x4301, 0x4381, 0x4401,
101  0x4481, 0x4501, 0x4581, 0x4601, 0x4681, 0x4701, 0x4781, 0x4801, 0x4881, 0x4901,
102  0x4981, 0x4A01, 0x4A81, 0x4B01, 0x4B81, 0x4C01, 0x4C81, 0x4D01, 0x4D81, 0x4E01,
103  0x4E81, 0x4F01, 0x4F81, 0x5001, 0x5081, 0x5101, 0x5181, 0x5201, 0x5281, 0x5301,
104  0x5381, 0x5401
105 };
106 
107 static const uint8_t block_bits[] = {
108  7, 2, 4, 6, 7, 8, 9, 9, 10, 10, 11, 11, 11, 3, 6, 8, 10, 11, 12, 4, 8,
109  10, 12, 5, 9, 10, 5, 9, 12, 5, 10, 12, 6, 10, 12, 6, 10, 6, 10, 6,
110  10, 7, 12, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 12, 12, 4, 9,
111  11, 6, 11, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
112  9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
113  12, 12
114 };
115 
116 static const uint8_t block_codes[] = {
117  3, 2, 15, 21, 23, 31, 37, 36, 33, 32, 7, 6, 32, 6, 20, 30, 15, 33, 80,
118  14, 29, 14, 81, 13, 35, 13, 12, 34, 82, 11, 12, 83, 19, 11, 84, 18,
119  10, 17, 9, 16, 8, 22, 85, 21, 20, 28, 27, 33, 32, 31, 30, 29, 28,
120  27, 26, 34, 35, 86, 87, 7, 25, 5, 15, 4, 14, 13, 12, 19, 18, 17, 16,
121  26, 25, 24, 23, 22, 21, 20, 19, 24, 23, 22, 21, 20, 19, 18, 17, 7,
122  6, 5, 4, 36, 37, 38, 39, 88, 89, 90, 91, 92, 93, 94, 95
123 };
124 
125 static VLC cbplo_tab;
126 static VLC cbphi_tab;
128 static VLC block_tab;
129 
130 static int get_cbphi(GetBitContext *gb, int x)
131 {
132  int value;
133 
134  value = get_vlc2(gb, cbphi_tab.table, cbphi_tab.bits, 1);
135  if (value < 0)
136  return AVERROR_INVALIDDATA;
137 
138  return x ? value : 15 - value;
139 }
140 
142  int block, int factor, int flag, int offset)
143 {
144  IMM4Context *s = avctx->priv_data;
145  const uint8_t *scantable = s->intra_scantable.permutated;
146  int i, last, len, factor2;
147 
148  for (i = !flag; i < 64; i++) {
149  int value;
150 
151  value = get_vlc2(gb, block_tab.table, block_tab.bits, 1);
152  if (value < 0)
153  return AVERROR_INVALIDDATA;
154  if (value == 0) {
155  last = get_bits1(gb);
156  len = get_bits(gb, 6);
157  factor2 = get_sbits(gb, 8);
158  } else {
159  factor2 = value & 0x7F;
160  last = (value >> 14) & 1;
161  len = (value >> 7) & 0x3F;
162  if (get_bits1(gb))
163  factor2 = -factor2;
164  }
165  i += len;
166  if (i >= 64)
167  break;
168  s->block[block][scantable[i]] = offset * (factor2 < 0 ? -1 : 1) + factor * factor2;
169  if (last)
170  break;
171  }
172 
173  return 0;
174 }
175 
177  unsigned cbp, int flag, int offset)
178 {
179  IMM4Context *s = avctx->priv_data;
180  const uint8_t *scantable = s->intra_scantable.permutated;
181  int ret, i;
182 
183  memset(s->block, 0, sizeof(s->block));
184 
185  for (i = 0; i < 6; i++) {
186  if (!flag) {
187  int x = get_bits(gb, 8);
188 
189  if (x == 255)
190  x = 128;
191  x *= 8;
192 
193  s->block[i][scantable[0]] = x;
194  }
195 
196  if (cbp & (1 << (5 - i))) {
197  ret = decode_block(avctx, gb, i, s->factor, flag, offset);
198  if (ret < 0)
199  return ret;
200  }
201  }
202 
203  return 0;
204 }
205 
207 {
208  IMM4Context *s = avctx->priv_data;
209  int ret, x, y, offset = 0;
210 
211  if (s->hi == 0) {
212  if (s->lo > 2)
213  return AVERROR_INVALIDDATA;
214  s->factor = intra_cb[s->lo];
215  } else {
216  if (s->hi == 1) {
217  s->factor = s->lo * 2;
218  } else {
219  s->factor = s->lo * 2;
220  }
221  }
222 
223  if (s->hi) {
224  offset = s->factor;
225  offset >>= 1;
226  if (!(offset & 1))
227  offset--;
228  }
229 
230  for (y = 0; y < avctx->height; y += 16) {
231  for (x = 0; x < avctx->width; x += 16) {
232  unsigned cbphi, cbplo;
233 
234  cbplo = get_vlc2(gb, cbplo_tab.table, cbplo_tab.bits, 1) >> 4;
235  skip_bits1(gb);
236 
237  cbphi = get_cbphi(gb, 1);
238 
239  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset);
240  if (ret < 0)
241  return ret;
242 
243  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
244  frame->linesize[0], s->block[0]);
245  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
246  frame->linesize[0], s->block[1]);
247  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
248  frame->linesize[0], s->block[2]);
249  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
250  frame->linesize[0], s->block[3]);
251  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
252  frame->linesize[1], s->block[4]);
253  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
254  frame->linesize[2], s->block[5]);
255  }
256  }
257 
258  return 0;
259 }
260 
262  AVFrame *frame, AVFrame *prev)
263 {
264  IMM4Context *s = avctx->priv_data;
265  int ret, x, y, offset = 0;
266 
267  if (s->hi == 0) {
268  if (s->lo > 2)
269  return AVERROR_INVALIDDATA;
270  s->factor = inter_cb[s->lo];
271  } else {
272  if (s->hi == 1) {
273  s->factor = s->lo * 2;
274  } else {
275  s->factor = s->lo * 2;
276  }
277  }
278 
279  if (s->hi) {
280  offset = s->factor;
281  offset >>= 1;
282  if (!(offset & 1))
283  offset--;
284  }
285 
286  for (y = 0; y < avctx->height; y += 16) {
287  for (x = 0; x < avctx->width; x += 16) {
288  int reverse, intra_block, value;
289  unsigned cbphi, cbplo;
290 
291  if (get_bits1(gb)) {
292  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
293  prev->data[0] + y * prev->linesize[0] + x,
294  frame->linesize[0], prev->linesize[0], 16);
295  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
296  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
297  frame->linesize[1], prev->linesize[1], 8);
298  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
299  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
300  frame->linesize[2], prev->linesize[2], 8);
301  continue;
302  }
303 
304  value = get_vlc2(gb, blktype_tab.table, blktype_tab.bits, 1);
305  if (value < 0)
306  return AVERROR_INVALIDDATA;
307 
308  intra_block = value & 0x07;
309  reverse = intra_block == 3;
310  if (reverse)
311  skip_bits1(gb);
312 
313  cbplo = value >> 4;
314  cbphi = get_cbphi(gb, reverse);
315  if (intra_block) {
316  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset);
317  if (ret < 0)
318  return ret;
319 
320  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
321  frame->linesize[0], s->block[0]);
322  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
323  frame->linesize[0], s->block[1]);
324  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
325  frame->linesize[0], s->block[2]);
326  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
327  frame->linesize[0], s->block[3]);
328  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
329  frame->linesize[1], s->block[4]);
330  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
331  frame->linesize[2], s->block[5]);
332  } else {
333  skip_bits(gb, 2);
334  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 1, offset);
335  if (ret < 0)
336  return ret;
337 
338  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
339  prev->data[0] + y * prev->linesize[0] + x,
340  frame->linesize[0], prev->linesize[0], 16);
341  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
342  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
343  frame->linesize[1], prev->linesize[1], 8);
344  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
345  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
346  frame->linesize[2], prev->linesize[2], 8);
347 
348  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x,
349  frame->linesize[0], s->block[0]);
350  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x + 8,
351  frame->linesize[0], s->block[1]);
352  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x,
353  frame->linesize[0], s->block[2]);
354  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
355  frame->linesize[0], s->block[3]);
356  s->idsp.idct_add(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
357  frame->linesize[1], s->block[4]);
358  s->idsp.idct_add(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
359  frame->linesize[2], s->block[5]);
360  }
361  }
362  }
363 
364  return 0;
365 }
366 
367 static int decode_frame(AVCodecContext *avctx, void *data,
368  int *got_frame, AVPacket *avpkt)
369 {
370  IMM4Context *s = avctx->priv_data;
371  GetBitContext *gb = &s->gb;
372  AVFrame *frame = data;
373  unsigned type;
374  int ret, scaled;
375 
376  if (avpkt->size <= 32)
377  return AVERROR_INVALIDDATA;
378 
380  FFALIGN(avpkt->size, 4));
381  if (!s->bitstream)
382  return AVERROR(ENOMEM);
383 
384  s->bdsp.bswap_buf((uint32_t *)s->bitstream,
385  (uint32_t *)avpkt->data,
386  (avpkt->size + 3) >> 2);
387 
388  if ((ret = init_get_bits8(gb, s->bitstream, FFALIGN(avpkt->size, 4))) < 0)
389  return ret;
390 
391  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
392  avctx->color_range = AVCOL_RANGE_JPEG;
393 
394  scaled = avpkt->data[8];
395  if (scaled < 2) {
396  int width, height;
397  int mode = avpkt->data[10];
398 
399  switch (mode) {
400  case 1:
401  width = 352;
402  height = 240;
403  break;
404  case 2:
405  width = 704;
406  height = 240;
407  break;
408  case 4:
409  width = 480;
410  height = 704;
411  break;
412  case 17:
413  width = 352;
414  height = 288;
415  break;
416  case 18:
417  width = 704;
418  height = 288;
419  break;
420  default:
421  width = 704;
422  height = 576;
423  break;
424  }
425 
426  if (s->changed_size == 1 &&
427  (avctx->width != width || avctx->height != height)) {
428  av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
429  return AVERROR_INVALIDDATA;
430  }
431  avctx->width = width;
432  avctx->height = height;
433  }
434 
435  s->changed_size = 1;
436  skip_bits_long(gb, 24 * 8);
437  type = get_bits_long(gb, 32);
438  s->hi = get_bits(gb, 16);
439  s->lo = get_bits(gb, 16);
440 
441  switch (type) {
442  case 0x19781977:
443  frame->key_frame = 1;
444  frame->pict_type = AV_PICTURE_TYPE_I;
445  break;
446  case 0x12250926:
447  frame->key_frame = 0;
448  frame->pict_type = AV_PICTURE_TYPE_P;
449  break;
450  default:
451  avpriv_request_sample(avctx, "type %X", type);
452  return AVERROR_PATCHWELCOME;
453  }
454 
455  if ((ret = ff_get_buffer(avctx, frame, frame->key_frame ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
456  return ret;
457 
458  if (frame->key_frame) {
459  ret = decode_intra(avctx, gb, frame);
460  if (ret < 0)
461  return ret;
462 
464  if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
465  return ret;
466  } else {
467  if (!s->prev_frame->data[0]) {
468  av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
469  return AVERROR_INVALIDDATA;
470  }
471 
472  ret = decode_inter(avctx, gb, frame, s->prev_frame);
473  if (ret < 0)
474  return ret;
475  }
476 
477  *got_frame = 1;
478 
479  return avpkt->size;
480 }
481 
483 {
485  cbplo_bits, 1, 1, cbplo_codes, 1, 1, cbplo_symbols, 1, 1, 512);
486 
488  cbphi_bits, 1, 1, cbphi_codes, 1, 1, NULL, 0, 0, 64);
489 
491  blktype_bits, 1, 1, blktype_codes, 1, 1, blktype_symbols, 1, 1, 512);
492 
494  block_bits, 1, 1, block_codes, 1, 1, block_symbols, 2, 2, 4096);
495 }
496 
498 {
499  static AVOnce init_static_once = AV_ONCE_INIT;
500  IMM4Context *s = avctx->priv_data;
501  uint8_t table[64];
502 
503  for (int i = 0; i < 64; i++)
504  table[i] = i;
505 
506  ff_bswapdsp_init(&s->bdsp);
507  ff_idctdsp_init(&s->idsp, avctx);
509 
510  s->prev_frame = av_frame_alloc();
511  if (!s->prev_frame)
512  return AVERROR(ENOMEM);
513 
514  ff_thread_once(&init_static_once, imm4_init_static_data);
515 
516  return 0;
517 }
518 
520 {
521  IMM4Context *s = avctx->priv_data;
522 
524  av_freep(&s->bitstream);
525  s->bitstream_size = 0;
526 
527  return 0;
528 }
529 
531  .name = "imm4",
532  .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"),
533  .type = AVMEDIA_TYPE_VIDEO,
534  .id = AV_CODEC_ID_IMM4,
535  .priv_data_size = sizeof(IMM4Context),
536  .init = decode_init,
537  .close = decode_close,
538  .decode = decode_frame,
539  .capabilities = AV_CODEC_CAP_DR1,
540  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
542 };
#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
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
Definition: bswapdsp.h:25
#define NULL
Definition: coverity.c:32
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int changed_size
Definition: imm4.c:44
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
static VLC cbplo_tab
Definition: imm4.c:125
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:381
static const uint8_t blktype_bits[]
Definition: imm4.c:86
int16_t block[6][64]
Definition: imm4.c:50
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:293
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2164
Scantable.
Definition: idctdsp.h:31
int size
Definition: avcodec.h:1446
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1743
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: avcodec.h:3424
static int get_sbits(GetBitContext *s, int n)
Definition: get_bits.h:361
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static const uint16_t block_symbols[]
Definition: imm4.c:94
GetBitContext gb
Definition: imm4.c:38
static int16_t block[64]
Definition: dct.c:115
static int get_cbphi(GetBitContext *gb, int x)
Definition: imm4.c:130
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#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:82
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:189
static uint32_t reverse(uint32_t num, int bits)
Definition: speedhq.c:565
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:443
static AVFrame * frame
#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:46
uint8_t * data
Definition: avcodec.h:1445
static av_cold void imm4_init_static_data(void)
Definition: imm4.c:482
bitstream reader API header.
#define AVOnce
Definition: thread.h:159
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
static const uint16_t table[]
Definition: prosumer.c:203
static const uint8_t blktype_codes[]
Definition: imm4.c:90
uint8_t * bitstream
Definition: imm4.c:41
#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:202
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
const char * name
Name of the codec implementation.
Definition: avcodec.h:3431
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
Definition: vlc.h:26
static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame, AVFrame *prev)
Definition: imm4.c:261
static const uint8_t cbplo_codes[]
Definition: imm4.c:70
static av_cold int decode_close(AVCodecContext *avctx)
Definition: imm4.c:519
AVCodec ff_imm4_decoder
Definition: imm4.c:530
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:309
int factor
Definition: imm4.c:45
#define width
int width
picture width / height.
Definition: avcodec.h:1706
GLsizei GLboolean const GLfloat * value
Definition: opengl_enc.c:109
#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:762
static VLC cbphi_tab
Definition: imm4.c:126
ScanTable intra_scantable
Definition: imm4.c:49
uint8_t idct_permutation[64]
IDCT input permutation.
Definition: idctdsp.h:96
BswapDSPContext bdsp
Definition: imm4.c:37
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:512
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:160
Libavcodec external API header.
static const uint8_t cbphi_codes[]
Definition: imm4.c:78
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
static VLC blktype_tab
Definition: imm4.c:127
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:650
main external API structure.
Definition: avcodec.h:1533
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1918
GLint GLenum type
Definition: opengl_enc.c:105
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:487
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:523
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
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:460
IDCTDSPContext idsp
Definition: imm4.c:51
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: imm4.c:367
static const int factor[16]
Definition: vf_pp7.c:75
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:531
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:553
int bitstream_size
Definition: imm4.c:42
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
static const uint8_t cbphi_bits[]
Definition: imm4.c:74
static const uint8_t block_codes[]
Definition: imm4.c:116
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
common internal api header.
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
#define flag(name)
Definition: cbs_av1.c:588
static const uint8_t inter_cb[]
Definition: imm4.c:58
unsigned hi
Definition: imm4.c:47
static const uint8_t cbplo_bits[]
Definition: imm4.c:66
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition: bswapdsp.c:49
void * priv_data
Definition: avcodec.h:1560
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:162
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:304
static int decode_blocks(AVCodecContext *avctx, GetBitContext *gb, unsigned cbp, int flag, int offset)
Definition: imm4.c:176
#define av_freep(p)
static VLC block_tab
Definition: imm4.c:128
static const uint8_t block_bits[]
Definition: imm4.c:107
static const uint8_t intra_cb[]
Definition: imm4.c:54
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int block, int factor, int flag, int offset)
Definition: imm4.c:141
static const uint8_t cbplo_symbols[]
Definition: imm4.c:62
This structure stores compressed data.
Definition: avcodec.h:1422
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:1144
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:968
static const uint8_t blktype_symbols[]
Definition: imm4.c:82
Predicted.
Definition: avutil.h:275
static av_cold int decode_init(AVCodecContext *avctx)
Definition: imm4.c:497
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
Definition: imm4.c:206