FFmpeg  4.4.5
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/mem_internal.h"
28 #include "libavutil/thread.h"
29 
30 #include "avcodec.h"
31 #include "bswapdsp.h"
32 #include "copy_block.h"
33 #include "get_bits.h"
34 #include "idctdsp.h"
35 #include "internal.h"
36 
37 #define CBPLO_VLC_BITS 6
38 #define CBPHI_VLC_BITS 6
39 #define BLKTYPE_VLC_BITS 9
40 #define BLOCK_VLC_BITS 12
41 
42 typedef struct IMM4Context {
45 
49 
50  int factor;
51  unsigned lo;
52  unsigned hi;
53 
55  DECLARE_ALIGNED(32, int16_t, block)[6][64];
57 } IMM4Context;
58 
59 static const uint8_t intra_cb[] = {
60  24, 18, 12
61 };
62 
63 static const uint8_t inter_cb[] = {
64  30, 20, 15
65 };
66 
67 static const uint8_t cbplo[][2] = {
68  { 0,-6 }, { 0x01, 6 }, { 0x02, 6 }, { 0x03, 6 }, { 0x00, 4 },
69  { 0x01, 3 }, { 0x02, 3 }, { 0x03, 3 }, { 0x00, 1 },
70 };
71 
72 static const uint8_t cbphi_bits[] = {
73  4, 5, 5, 4, 5, 4, 6, 4, 5, 6, 4, 4, 4, 4, 4, 2
74 };
75 
76 static const uint8_t cbphi_codes[] = {
77  3, 5, 4, 9, 3, 7, 2, 11, 2, 3, 5, 10, 4, 8, 6, 3
78 };
79 
80 static const uint8_t blktype[][2] = {
81  { 0,-8 }, { 0x34, 9 }, { 0,-9 }, { 0x14, 9 }, { 0,-9 },
82  { 0x23, 8 }, { 0x13, 8 }, { 0x32, 8 }, { 0x33, 7 }, { 0x22, 7 },
83  { 0x12, 7 }, { 0x21, 7 }, { 0x11, 7 }, { 0x04, 6 }, { 0x30, 6 },
84  { 0x03, 5 }, { 0x20, 4 }, { 0x10, 4 }, { 0x02, 3 }, { 0x01, 3 },
85  { 0x00, 1 },
86 };
87 
88 static const uint16_t block_symbols[] = {
89  0, 0x4082, 0x4003, 0x000B, 0x000A, 0x4E01, 0x4D81, 0x4D01, 0x4C81,
90  0x0482, 0x0402, 0x0382, 0x0302, 0x0282, 0x0183, 0x0103, 0x0084, 0x000C,
91  0x0085, 0x0B81, 0x0C01, 0x4E81, 0x4F01, 0x4F81, 0x5001, 0x0086, 0x0104,
92  0x0203, 0x0283, 0x0303, 0x0502, 0x0C81, 0x0D01, 0x5081, 0x5101, 0x5181,
93  0x5201, 0x5281, 0x5301, 0x5381, 0x5401, 0x0000, 0x0009, 0x0008, 0x4C01,
94  0x4B81, 0x4B01, 0x4A81, 0x4A01, 0x4981, 0x4901, 0x4881, 0x4002, 0x0B01,
95  0x0A81, 0x0A01, 0x0981, 0x0901, 0x0881, 0x0801, 0x0781, 0x0202, 0x0182,
96  0x0007, 0x0006, 0x4801, 0x4781, 0x4701, 0x4681, 0x4601, 0x4581, 0x4501,
97  0x4481, 0x0701, 0x0681, 0x0102, 0x0083, 0x0005, 0x4401, 0x4381, 0x4301,
98  0x4281, 0x0601, 0x0581, 0x0501, 0x0004, 0x4201, 0x4181, 0x4101, 0x4081,
99  0x0481, 0x0401, 0x0381, 0x0301, 0x0082, 0x0003, 0x0281, 0x0201, 0x0181,
100  0x4001, 0x0001, 0x0081, 0x0101, 0x0002,
101 };
102 
103 static const uint8_t block_bits[] = {
104  -9, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
105  11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
106  12, 12, 12, 7, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
107  9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
108  8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6,
109  6, 5, 5, 5, 4, 2, 3, 4, 4,
110 };
111 
112 static VLC cbplo_tab;
113 static VLC cbphi_tab;
115 static VLC block_tab;
116 
117 static int get_cbphi(GetBitContext *gb, int x)
118 {
119  int value;
120 
122  if (value < 0)
123  return AVERROR_INVALIDDATA;
124 
125  return x ? value : 15 - value;
126 }
127 
129  int block, int factor, int flag, int offset, int flag2)
130 {
131  IMM4Context *s = avctx->priv_data;
132  const uint8_t *scantable = s->intra_scantable.permutated;
133  int i, last, len, factor2;
134 
135  for (i = !flag; i < 64; i++) {
136  int value;
137 
139  if (value < 0)
140  return AVERROR_INVALIDDATA;
141  if (value == 0) {
142  last = get_bits1(gb);
143  len = get_bits(gb, 6);
144  factor2 = get_sbits(gb, 8);
145  } else {
146  factor2 = value & 0x7F;
147  last = (value >> 14) & 1;
148  len = (value >> 7) & 0x3F;
149  if (get_bits1(gb))
150  factor2 = -factor2;
151  }
152  i += len;
153  if (i >= 64)
154  break;
155  s->block[block][scantable[i]] = offset * (factor2 < 0 ? -1 : 1) + factor * factor2;
156  if (last)
157  break;
158  }
159 
160  if (s->hi == 2 && flag2 && block < 4) {
161  if (flag)
162  s->block[block][scantable[0]] *= 2;
163  s->block[block][scantable[1]] *= 2;
164  s->block[block][scantable[8]] *= 2;
165  s->block[block][scantable[16]] *= 2;
166  }
167 
168  return 0;
169 }
170 
172  unsigned cbp, int flag, int offset, unsigned flag2)
173 {
174  IMM4Context *s = avctx->priv_data;
175  const uint8_t *scantable = s->intra_scantable.permutated;
176  int ret, i;
177 
178  memset(s->block, 0, sizeof(s->block));
179 
180  for (i = 0; i < 6; i++) {
181  if (!flag) {
182  int x = get_bits(gb, 8);
183 
184  if (x == 255)
185  x = 128;
186  x *= 8;
187 
188  s->block[i][scantable[0]] = x;
189  }
190 
191  if (cbp & (1 << (5 - i))) {
192  ret = decode_block(avctx, gb, i, s->factor, flag, offset, flag2);
193  if (ret < 0)
194  return ret;
195  }
196  }
197 
198  return 0;
199 }
200 
202 {
203  IMM4Context *s = avctx->priv_data;
204  int ret, x, y, offset = 0;
205 
206  if (s->hi == 0) {
207  if (s->lo > 2)
208  return AVERROR_INVALIDDATA;
209  s->factor = intra_cb[s->lo];
210  } else {
211  s->factor = s->lo * 2;
212  }
213 
214  if (s->hi) {
215  offset = s->factor;
216  offset >>= 1;
217  if (!(offset & 1))
218  offset--;
219  }
220 
221  for (y = 0; y < avctx->height; y += 16) {
222  for (x = 0; x < avctx->width; x += 16) {
223  unsigned flag, cbplo;
224  int cbphi;
225 
227  flag = get_bits1(gb);
228 
229  cbphi = get_cbphi(gb, 1);
230  if (cbphi < 0)
231  return cbphi;
232 
233  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag);
234  if (ret < 0)
235  return ret;
236 
237  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
238  frame->linesize[0], s->block[0]);
239  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
240  frame->linesize[0], s->block[1]);
241  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
242  frame->linesize[0], s->block[2]);
243  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
244  frame->linesize[0], s->block[3]);
245  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
246  frame->linesize[1], s->block[4]);
247  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
248  frame->linesize[2], s->block[5]);
249  }
250  }
251 
252  return 0;
253 }
254 
256  AVFrame *frame, AVFrame *prev)
257 {
258  IMM4Context *s = avctx->priv_data;
259  int ret, x, y, offset = 0;
260 
261  if (s->hi == 0) {
262  if (s->lo > 2)
263  return AVERROR_INVALIDDATA;
264  s->factor = inter_cb[s->lo];
265  } else {
266  s->factor = s->lo * 2;
267  }
268 
269  if (s->hi) {
270  offset = s->factor;
271  offset >>= 1;
272  if (!(offset & 1))
273  offset--;
274  }
275 
276  for (y = 0; y < avctx->height; y += 16) {
277  for (x = 0; x < avctx->width; x += 16) {
278  int reverse, intra_block, value;
279  unsigned cbplo, flag2 = 0;
280  int cbphi;
281 
282  if (get_bits1(gb)) {
283  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
284  prev->data[0] + y * prev->linesize[0] + x,
285  frame->linesize[0], prev->linesize[0], 16);
286  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
287  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
288  frame->linesize[1], prev->linesize[1], 8);
289  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
290  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
291  frame->linesize[2], prev->linesize[2], 8);
292  continue;
293  }
294 
296  if (value < 0)
297  return AVERROR_INVALIDDATA;
298 
299  intra_block = value & 0x07;
300  reverse = intra_block == 3;
301  if (reverse)
302  flag2 = get_bits1(gb);
303 
304  cbplo = value >> 4;
305  cbphi = get_cbphi(gb, reverse);
306  if (cbphi < 0)
307  return cbphi;
308 
309  if (intra_block) {
310  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 0, offset, flag2);
311  if (ret < 0)
312  return ret;
313 
314  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x,
315  frame->linesize[0], s->block[0]);
316  s->idsp.idct_put(frame->data[0] + y * frame->linesize[0] + x + 8,
317  frame->linesize[0], s->block[1]);
318  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x,
319  frame->linesize[0], s->block[2]);
320  s->idsp.idct_put(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
321  frame->linesize[0], s->block[3]);
322  s->idsp.idct_put(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
323  frame->linesize[1], s->block[4]);
324  s->idsp.idct_put(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
325  frame->linesize[2], s->block[5]);
326  } else {
327  flag2 = get_bits1(gb);
328  skip_bits1(gb);
329  ret = decode_blocks(avctx, gb, cbplo | (cbphi << 2), 1, offset, flag2);
330  if (ret < 0)
331  return ret;
332 
333  copy_block16(frame->data[0] + y * frame->linesize[0] + x,
334  prev->data[0] + y * prev->linesize[0] + x,
335  frame->linesize[0], prev->linesize[0], 16);
336  copy_block8(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
337  prev->data[1] + (y >> 1) * prev->linesize[1] + (x >> 1),
338  frame->linesize[1], prev->linesize[1], 8);
339  copy_block8(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
340  prev->data[2] + (y >> 1) * prev->linesize[2] + (x >> 1),
341  frame->linesize[2], prev->linesize[2], 8);
342 
343  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x,
344  frame->linesize[0], s->block[0]);
345  s->idsp.idct_add(frame->data[0] + y * frame->linesize[0] + x + 8,
346  frame->linesize[0], s->block[1]);
347  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x,
348  frame->linesize[0], s->block[2]);
349  s->idsp.idct_add(frame->data[0] + (y + 8) * frame->linesize[0] + x + 8,
350  frame->linesize[0], s->block[3]);
351  s->idsp.idct_add(frame->data[1] + (y >> 1) * frame->linesize[1] + (x >> 1),
352  frame->linesize[1], s->block[4]);
353  s->idsp.idct_add(frame->data[2] + (y >> 1) * frame->linesize[2] + (x >> 1),
354  frame->linesize[2], s->block[5]);
355  }
356  }
357  }
358 
359  return 0;
360 }
361 
362 static int decode_frame(AVCodecContext *avctx, void *data,
363  int *got_frame, AVPacket *avpkt)
364 {
365  IMM4Context *s = avctx->priv_data;
366  GetBitContext *gb = &s->gb;
367  AVFrame *frame = data;
368  int width, height;
369  unsigned type;
370  int ret, scaled;
371 
372  if (avpkt->size <= 32)
373  return AVERROR_INVALIDDATA;
374 
375  av_fast_padded_malloc(&s->bitstream, &s->bitstream_size,
376  FFALIGN(avpkt->size, 4));
377  if (!s->bitstream)
378  return AVERROR(ENOMEM);
379 
380  s->bdsp.bswap_buf((uint32_t *)s->bitstream,
381  (uint32_t *)avpkt->data,
382  (avpkt->size + 3) >> 2);
383 
384  if ((ret = init_get_bits8(gb, s->bitstream, FFALIGN(avpkt->size, 4))) < 0)
385  return ret;
386 
387  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
388  avctx->color_range = AVCOL_RANGE_JPEG;
389 
390  width = avctx->width;
391  height = avctx->height;
392 
393  scaled = avpkt->data[8];
394  if (scaled < 2) {
395  int mode = avpkt->data[10];
396 
397  switch (mode) {
398  case 1:
399  width = 352;
400  height = 240;
401  break;
402  case 2:
403  width = 704;
404  height = 240;
405  break;
406  case 4:
407  width = 480;
408  height = 704;
409  break;
410  case 17:
411  width = 352;
412  height = 288;
413  break;
414  case 18:
415  width = 704;
416  height = 288;
417  break;
418  default:
419  width = 704;
420  height = 576;
421  break;
422  }
423  }
424 
425  skip_bits_long(gb, 24 * 8);
426  type = get_bits_long(gb, 32);
427  s->hi = get_bits(gb, 16);
428  s->lo = get_bits(gb, 16);
429 
430  switch (type) {
431  case 0x19781977:
432  frame->key_frame = 1;
434  break;
435  case 0x12250926:
436  frame->key_frame = 0;
438  break;
439  default:
440  avpriv_request_sample(avctx, "type %X", type);
441  return AVERROR_PATCHWELCOME;
442  }
443 
444  if (avctx->width != width ||
445  avctx->height != height) {
446  if (!frame->key_frame) {
447  av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
448  return AVERROR_INVALIDDATA;
449  }
450  av_frame_unref(s->prev_frame);
451  }
452 
453  ret = ff_set_dimensions(avctx, width, height);
454  if (ret < 0)
455  return ret;
456 
457  if ((ret = ff_get_buffer(avctx, frame, frame->key_frame ? AV_GET_BUFFER_FLAG_REF : 0)) < 0)
458  return ret;
459 
460  if (frame->key_frame) {
461  ret = decode_intra(avctx, gb, frame);
462  if (ret < 0)
463  return ret;
464 
465  av_frame_unref(s->prev_frame);
466  if ((ret = av_frame_ref(s->prev_frame, frame)) < 0)
467  return ret;
468  } else {
469  if (!s->prev_frame->data[0]) {
470  av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
471  return AVERROR_INVALIDDATA;
472  }
473 
474  ret = decode_inter(avctx, gb, frame, s->prev_frame);
475  if (ret < 0)
476  return ret;
477  }
478 
479  *got_frame = 1;
480 
481  return avpkt->size;
482 }
483 
485 {
487  &cbplo[0][1], 2, &cbplo[0][0], 2, 1,
488  0, 0, 1 << CBPLO_VLC_BITS);
489 
491  cbphi_bits, 1, 1, cbphi_codes, 1, 1, NULL, 0, 0, 64);
492 
494  &blktype[0][1], 2, &blktype[0][0], 2, 1,
495  0, 0, 1 << BLKTYPE_VLC_BITS);
496 
498  block_bits, 1, block_symbols, 2, 2,
499  0, 0, 1 << BLOCK_VLC_BITS);
500 }
501 
503 {
504  static AVOnce init_static_once = AV_ONCE_INIT;
505  IMM4Context *s = avctx->priv_data;
506  uint8_t table[64];
507 
508  for (int i = 0; i < 64; i++)
509  table[i] = i;
510 
511  ff_bswapdsp_init(&s->bdsp);
512  ff_idctdsp_init(&s->idsp, avctx);
513  ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, table);
514 
515  s->prev_frame = av_frame_alloc();
516  if (!s->prev_frame)
517  return AVERROR(ENOMEM);
518 
519  ff_thread_once(&init_static_once, imm4_init_static_data);
520 
521  return 0;
522 }
523 
524 static void decode_flush(AVCodecContext *avctx)
525 {
526  IMM4Context *s = avctx->priv_data;
527 
528  av_frame_unref(s->prev_frame);
529 }
530 
532 {
533  IMM4Context *s = avctx->priv_data;
534 
535  av_frame_free(&s->prev_frame);
536  av_freep(&s->bitstream);
537  s->bitstream_size = 0;
538 
539  return 0;
540 }
541 
543  .name = "imm4",
544  .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"),
545  .type = AVMEDIA_TYPE_VIDEO,
546  .id = AV_CODEC_ID_IMM4,
547  .priv_data_size = sizeof(IMM4Context),
548  .init = decode_init,
549  .close = decode_close,
550  .decode = decode_frame,
551  .flush = decode_flush,
552  .capabilities = AV_CODEC_CAP_DR1,
553  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
555 };
static void flush(AVCodecContext *avctx)
#define av_cold
Definition: attributes.h:88
uint8_t
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
#define flag(name)
Definition: cbs_av1.c:564
#define s(width, name)
Definition: cbs_vp9.c:257
static void copy_block8(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
Definition: copy_block.h:47
static void copy_block16(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
Definition: copy_block.h:68
#define NULL
Definition: coverity.c:32
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1900
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static AVFrame * frame
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
double value
Definition: eval.c:98
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:546
static int get_sbits(GetBitContext *s, int n)
Definition: get_bits.h:359
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 void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:291
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:677
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:538
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:514
@ AV_CODEC_ID_IMM4
Definition: codec_id.h:286
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:50
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR(e)
Definition: error.h:43
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:553
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:190
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:117
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
cl_device_type type
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
Definition: idctdsp.c:238
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
Definition: idctdsp.c:29
static VLC cbplo_tab
Definition: imm4.c:112
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
Definition: imm4.c:201
static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame, AVFrame *prev)
Definition: imm4.c:255
static const uint8_t intra_cb[]
Definition: imm4.c:59
#define CBPHI_VLC_BITS
Definition: imm4.c:38
static VLC cbphi_tab
Definition: imm4.c:113
static av_cold int decode_close(AVCodecContext *avctx)
Definition: imm4.c:531
static const uint8_t block_bits[]
Definition: imm4.c:103
static VLC blktype_tab
Definition: imm4.c:114
static int get_cbphi(GetBitContext *gb, int x)
Definition: imm4.c:117
static av_cold int decode_init(AVCodecContext *avctx)
Definition: imm4.c:502
static const uint8_t cbphi_codes[]
Definition: imm4.c:76
static av_cold void imm4_init_static_data(void)
Definition: imm4.c:484
AVCodec ff_imm4_decoder
Definition: imm4.c:542
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int block, int factor, int flag, int offset, int flag2)
Definition: imm4.c:128
static const uint16_t block_symbols[]
Definition: imm4.c:88
#define BLOCK_VLC_BITS
Definition: imm4.c:40
static const uint8_t cbplo[][2]
Definition: imm4.c:67
#define BLKTYPE_VLC_BITS
Definition: imm4.c:39
static void decode_flush(AVCodecContext *avctx)
Definition: imm4.c:524
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: imm4.c:362
static const uint8_t cbphi_bits[]
Definition: imm4.c:72
static int decode_blocks(AVCodecContext *avctx, GetBitContext *gb, unsigned cbp, int flag, int offset, unsigned flag2)
Definition: imm4.c:171
static const uint8_t inter_cb[]
Definition: imm4.c:63
static VLC block_tab
Definition: imm4.c:115
#define CBPLO_VLC_BITS
Definition: imm4.c:37
static const uint8_t blktype[][2]
Definition: imm4.c:80
int i
Definition: input.c:407
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition: bswapdsp.c:49
#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:41
#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: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:84
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
#define AVOnce
Definition: thread.h:172
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:175
#define AV_ONCE_INIT
Definition: thread.h:173
#define FFALIGN(x, a)
Definition: macros.h:48
const char data[16]
Definition: mxf.c:142
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:586
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
static const uint16_t table[]
Definition: prosumer.c:206
#define FF_ARRAY_ELEMS(a)
static uint32_t reverse(uint32_t num, int bits)
Definition: speedhqenc.c:51
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
int width
picture width / height.
Definition: avcodec.h:709
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1171
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
const char * name
Name of the codec implementation.
Definition: codec.h:204
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:396
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:401
This structure stores compressed data.
Definition: packet.h:346
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
BswapDSPContext bdsp
Definition: imm4.c:43
IDCTDSPContext idsp
Definition: imm4.c:56
ScanTable intra_scantable
Definition: imm4.c:54
unsigned lo
Definition: imm4.c:51
unsigned hi
Definition: imm4.c:52
uint8_t * bitstream
Definition: imm4.c:47
int16_t block[6][64]
Definition: imm4.c:55
GetBitContext gb
Definition: imm4.c:44
int factor
Definition: imm4.c:50
int bitstream_size
Definition: imm4.c:48
AVFrame * prev_frame
Definition: imm4.c:46
Scantable.
Definition: idctdsp.h:31
Definition: vlc.h:26
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
static int16_t block[64]
Definition: dct.c:116
#define height
#define width
static const int factor[16]
Definition: vf_pp7.c:77
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
#define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
Definition: vlc.h:108
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap, symbols, symbols_wrap, symbols_size, offset, flags, static_size)
Definition: vlc.h:126
int len