indeo5.c
Go to the documentation of this file.
1 /*
2  * Indeo Video Interactive v5 compatible decoder
3  * Copyright (c) 2009 Maxim Poliakovski
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
30 #define BITSTREAM_READER_LE
31 #include "avcodec.h"
32 #include "get_bits.h"
33 #include "dsputil.h"
34 #include "ivi_dsp.h"
35 #include "ivi_common.h"
36 #include "indeo5data.h"
37 
41 enum {
47 };
48 
49 #define IVI5_PIC_SIZE_ESC 15
50 
61 {
62  int result, i, p, tile_size, pic_size_indx, mb_size, blk_size;
63  int quant_mat, blk_size_changed = 0;
64  IVIBandDesc *band, *band1, *band2;
65  IVIPicConfig pic_conf;
66 
67  ctx->gop_flags = get_bits(&ctx->gb, 8);
68 
69  ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
70 
71  if (ctx->gop_flags & IVI5_IS_PROTECTED)
72  ctx->lock_word = get_bits_long(&ctx->gb, 32);
73 
74  tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
75  if (tile_size > 256) {
76  av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
77  return AVERROR_INVALIDDATA;
78  }
79 
80  /* decode number of wavelet bands */
81  /* num_levels * 3 + 1 */
82  pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1;
83  pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1;
84  ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
85  if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
86  av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
87  pic_conf.luma_bands, pic_conf.chroma_bands);
88  return AVERROR_INVALIDDATA;
89  }
90 
91  pic_size_indx = get_bits(&ctx->gb, 4);
92  if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
93  pic_conf.pic_height = get_bits(&ctx->gb, 13);
94  pic_conf.pic_width = get_bits(&ctx->gb, 13);
95  } else {
96  pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
97  pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2;
98  }
99 
100  if (ctx->gop_flags & 2) {
101  av_log_missing_feature(avctx, "YV12 picture format", 0);
102  return AVERROR_PATCHWELCOME;
103  }
104 
105  pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
106  pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
107 
108  if (!tile_size) {
109  pic_conf.tile_height = pic_conf.pic_height;
110  pic_conf.tile_width = pic_conf.pic_width;
111  } else {
112  pic_conf.tile_height = pic_conf.tile_width = tile_size;
113  }
114 
115  /* check if picture layout was changed and reallocate buffers */
116  if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf) || ctx->gop_invalid) {
117  result = ff_ivi_init_planes(ctx->planes, &pic_conf);
118  if (result < 0) {
119  av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
120  return result;
121  }
122  ctx->pic_conf = pic_conf;
123  blk_size_changed = 1; /* force reallocation of the internal structures */
124  }
125 
126  for (p = 0; p <= 1; p++) {
127  for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
128  band = &ctx->planes[p].bands[i];
129 
130  band->is_halfpel = get_bits1(&ctx->gb);
131 
132  mb_size = get_bits1(&ctx->gb);
133  blk_size = 8 >> get_bits1(&ctx->gb);
134  mb_size = blk_size << !mb_size;
135 
136  blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
137  if (blk_size_changed) {
138  band->mb_size = mb_size;
139  band->blk_size = blk_size;
140  }
141 
142  if (get_bits1(&ctx->gb)) {
143  av_log_missing_feature(avctx, "Extended transform info", 0);
144  return AVERROR_PATCHWELCOME;
145  }
146 
147  /* select transform function and scan pattern according to plane and band number */
148  switch ((p << 2) + i) {
149  case 0:
152  band->scan = ff_zigzag_direct;
153  band->transform_size = 8;
154  break;
155 
156  case 1:
160  band->transform_size = 8;
161  break;
162 
163  case 2:
167  band->transform_size = 8;
168  break;
169 
170  case 3:
174  band->transform_size = 8;
175  break;
176 
177  case 4:
181  band->transform_size = 4;
182  break;
183  }
184 
187 
188  if (band->transform_size != band->blk_size)
189  return AVERROR_INVALIDDATA;
190 
191  /* select dequant matrix according to plane and band number */
192  if (!p) {
193  quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
194  } else {
195  quant_mat = 5;
196  }
197 
198  if (band->blk_size == 8) {
199  band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
200  band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
201  band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
202  band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0];
203  } else {
208  }
209 
210  if (get_bits(&ctx->gb, 2)) {
211  av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
212  return AVERROR_INVALIDDATA;
213  }
214  }
215  }
216 
217  /* copy chroma parameters into the 2nd chroma plane */
218  for (i = 0; i < pic_conf.chroma_bands; i++) {
219  band1 = &ctx->planes[1].bands[i];
220  band2 = &ctx->planes[2].bands[i];
221 
222  band2->width = band1->width;
223  band2->height = band1->height;
224  band2->mb_size = band1->mb_size;
225  band2->blk_size = band1->blk_size;
226  band2->is_halfpel = band1->is_halfpel;
227  band2->intra_base = band1->intra_base;
228  band2->inter_base = band1->inter_base;
229  band2->intra_scale = band1->intra_scale;
230  band2->inter_scale = band1->inter_scale;
231  band2->scan = band1->scan;
232  band2->inv_transform = band1->inv_transform;
233  band2->dc_transform = band1->dc_transform;
234  band2->is_2d_trans = band1->is_2d_trans;
235  }
236 
237  /* reallocate internal structures if needed */
238  if (blk_size_changed) {
239  result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
240  pic_conf.tile_height);
241  if (result < 0) {
242  av_log(avctx, AV_LOG_ERROR,
243  "Couldn't reallocate internal structures!\n");
244  return result;
245  }
246  }
247 
248  if (ctx->gop_flags & 8) {
249  if (get_bits(&ctx->gb, 3)) {
250  av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
251  return AVERROR_INVALIDDATA;
252  }
253 
254  if (get_bits1(&ctx->gb))
255  skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */
256  }
257 
258  align_get_bits(&ctx->gb);
259 
260  skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
261 
262  /* skip GOP extension if any */
263  if (get_bits1(&ctx->gb)) {
264  do {
265  i = get_bits(&ctx->gb, 16);
266  } while (i & 0x8000);
267  }
268 
269  align_get_bits(&ctx->gb);
270 
271  return 0;
272 }
273 
274 
280 static inline void skip_hdr_extension(GetBitContext *gb)
281 {
282  int i, len;
283 
284  do {
285  len = get_bits(gb, 8);
286  for (i = 0; i < len; i++) skip_bits(gb, 8);
287  } while(len);
288 }
289 
290 
299 {
300  int ret;
301 
302  if (get_bits(&ctx->gb, 5) != 0x1F) {
303  av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
304  return AVERROR_INVALIDDATA;
305  }
306 
307  ctx->prev_frame_type = ctx->frame_type;
308  ctx->frame_type = get_bits(&ctx->gb, 3);
309  if (ctx->frame_type >= 5) {
310  av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
311  return AVERROR_INVALIDDATA;
312  }
313 
314  ctx->frame_num = get_bits(&ctx->gb, 8);
315 
316  if (ctx->frame_type == FRAMETYPE_INTRA) {
317  if ((ret = decode_gop_header(ctx, avctx)) < 0) {
318  av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
319  ctx->gop_invalid = 1;
320  return ret;
321  }
322  ctx->gop_invalid = 0;
323  }
324 
325  if (ctx->frame_type != FRAMETYPE_NULL) {
326  ctx->frame_flags = get_bits(&ctx->gb, 8);
327 
328  ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0;
329 
330  ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
331 
332  /* skip unknown extension if any */
333  if (ctx->frame_flags & 0x20)
334  skip_hdr_extension(&ctx->gb); /* XXX: untested */
335 
336  /* decode macroblock huffman codebook */
337  ret = ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40,
338  IVI_MB_HUFF, &ctx->mb_vlc, avctx);
339  if (ret < 0)
340  return ret;
341 
342  skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
343  }
344 
345  align_get_bits(&ctx->gb);
346 
347  return 0;
348 }
349 
350 
360  AVCodecContext *avctx)
361 {
362  int i, ret;
363  uint8_t band_flags;
364 
365  band_flags = get_bits(&ctx->gb, 8);
366 
367  if (band_flags & 1) {
368  band->is_empty = 1;
369  return 0;
370  }
371 
372  band->data_size = (ctx->frame_flags & 0x80) ? get_bits_long(&ctx->gb, 24) : 0;
373 
374  band->inherit_mv = band_flags & 2;
375  band->inherit_qdelta = band_flags & 8;
376  band->qdelta_present = band_flags & 4;
377  if (!band->qdelta_present) band->inherit_qdelta = 1;
378 
379  /* decode rvmap probability corrections if any */
380  band->num_corr = 0; /* there are no corrections */
381  if (band_flags & 0x10) {
382  band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
383  if (band->num_corr > 61) {
384  av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
385  band->num_corr);
386  return AVERROR_INVALIDDATA;
387  }
388 
389  /* read correction pairs */
390  for (i = 0; i < band->num_corr * 2; i++)
391  band->corr[i] = get_bits(&ctx->gb, 8);
392  }
393 
394  /* select appropriate rvmap table for this band */
395  band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
396 
397  /* decode block huffman codebook */
398  ret = ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF,
399  &band->blk_vlc, avctx);
400  if (ret < 0)
401  return ret;
402 
403  band->checksum_present = get_bits1(&ctx->gb);
404  if (band->checksum_present)
405  band->checksum = get_bits(&ctx->gb, 16);
406 
407  band->glob_quant = get_bits(&ctx->gb, 5);
408 
409  /* skip unknown extension if any */
410  if (band_flags & 0x20) { /* XXX: untested */
411  align_get_bits(&ctx->gb);
412  skip_hdr_extension(&ctx->gb);
413  }
414 
415  align_get_bits(&ctx->gb);
416 
417  return 0;
418 }
419 
420 
432  IVITile *tile, AVCodecContext *avctx)
433 {
434  int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
435  mv_scale, blks_per_mb;
436  IVIMbInfo *mb, *ref_mb;
437  int row_offset = band->mb_size * band->pitch;
438 
439  mb = tile->mbs;
440  ref_mb = tile->ref_mbs;
441  offs = tile->ypos * band->pitch + tile->xpos;
442 
443  if (!ref_mb &&
444  ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
445  return AVERROR_INVALIDDATA;
446 
447  if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
448  av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches parameters %d\n",
449  tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
450  return AVERROR_INVALIDDATA;
451  }
452 
453  /* scale factor for motion vectors */
454  mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
455  mv_x = mv_y = 0;
456 
457  for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
458  mb_offset = offs;
459 
460  for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
461  mb->xpos = x;
462  mb->ypos = y;
463  mb->buf_offs = mb_offset;
464 
465  if (get_bits1(&ctx->gb)) {
466  if (ctx->frame_type == FRAMETYPE_INTRA) {
467  av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
468  return AVERROR_INVALIDDATA;
469  }
470  mb->type = 1; /* empty macroblocks are always INTER */
471  mb->cbp = 0; /* all blocks are empty */
472 
473  mb->q_delta = 0;
474  if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
475  mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
476  IVI_VLC_BITS, 1);
477  mb->q_delta = IVI_TOSIGNED(mb->q_delta);
478  }
479 
480  mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
481  if (band->inherit_mv){
482  /* motion vector inheritance */
483  if (mv_scale) {
484  mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
485  mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
486  } else {
487  mb->mv_x = ref_mb->mv_x;
488  mb->mv_y = ref_mb->mv_y;
489  }
490  }
491  } else {
492  if (band->inherit_mv) {
493  mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
494  } else if (ctx->frame_type == FRAMETYPE_INTRA) {
495  mb->type = 0; /* mb_type is always INTRA for intra-frames */
496  } else {
497  mb->type = get_bits1(&ctx->gb);
498  }
499 
500  blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
501  mb->cbp = get_bits(&ctx->gb, blks_per_mb);
502 
503  mb->q_delta = 0;
504  if (band->qdelta_present) {
505  if (band->inherit_qdelta) {
506  if (ref_mb) mb->q_delta = ref_mb->q_delta;
507  } else if (mb->cbp || (!band->plane && !band->band_num &&
508  (ctx->frame_flags & 8))) {
509  mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
510  IVI_VLC_BITS, 1);
511  mb->q_delta = IVI_TOSIGNED(mb->q_delta);
512  }
513  }
514 
515  if (!mb->type) {
516  mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
517  } else {
518  if (band->inherit_mv){
519  /* motion vector inheritance */
520  if (mv_scale) {
521  mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
522  mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
523  } else {
524  mb->mv_x = ref_mb->mv_x;
525  mb->mv_y = ref_mb->mv_y;
526  }
527  } else {
528  /* decode motion vector deltas */
529  mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
530  IVI_VLC_BITS, 1);
531  mv_y += IVI_TOSIGNED(mv_delta);
532  mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
533  IVI_VLC_BITS, 1);
534  mv_x += IVI_TOSIGNED(mv_delta);
535  mb->mv_x = mv_x;
536  mb->mv_y = mv_y;
537  }
538  }
539  }
540 
541  mb++;
542  if (ref_mb)
543  ref_mb++;
544  mb_offset += band->mb_size;
545  }
546 
547  offs += row_offset;
548  }
549 
550  align_get_bits(&ctx->gb);
551 
552  return 0;
553 }
554 
555 
562 {
563  switch (ctx->prev_frame_type) {
564  case FRAMETYPE_INTRA:
565  case FRAMETYPE_INTER:
566  ctx->buf_switch ^= 1;
567  ctx->dst_buf = ctx->buf_switch;
568  ctx->ref_buf = ctx->buf_switch ^ 1;
569  break;
571  if (!ctx->inter_scal) {
572  ctx->ref2_buf = 2;
573  ctx->inter_scal = 1;
574  }
575  FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
576  ctx->ref_buf = ctx->ref2_buf;
577  break;
579  break;
580  }
581 
582  switch (ctx->frame_type) {
583  case FRAMETYPE_INTRA:
584  ctx->buf_switch = 0;
585  /* FALLTHROUGH */
586  case FRAMETYPE_INTER:
587  ctx->inter_scal = 0;
588  ctx->dst_buf = ctx->buf_switch;
589  ctx->ref_buf = ctx->buf_switch ^ 1;
590  break;
593  case FRAMETYPE_NULL:
594  break;
595  }
596 }
597 
598 
600 {
601  return ctx->frame_type != FRAMETYPE_NULL;
602 }
603 
604 
609 {
610  IVI45DecContext *ctx = avctx->priv_data;
611  int result;
612 
614 
615  /* copy rvmap tables in our context so we can apply changes to them */
616  memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
617 
618  /* set the initial picture layout according to the basic profile:
619  there is only one band per plane (no scalability), only one tile (no local decoding)
620  and picture format = YVU9 */
621  ctx->pic_conf.pic_width = avctx->width;
622  ctx->pic_conf.pic_height = avctx->height;
623  ctx->pic_conf.chroma_width = (avctx->width + 3) >> 2;
624  ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
625  ctx->pic_conf.tile_width = avctx->width;
626  ctx->pic_conf.tile_height = avctx->height;
627  ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1;
628 
629  result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
630  if (result) {
631  av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
632  return AVERROR_INVALIDDATA;
633  }
634 
635  ctx->buf_switch = 0;
636  ctx->inter_scal = 0;
637 
643 
644  avctx->pix_fmt = PIX_FMT_YUV410P;
645 
646  return 0;
647 }
648 
649 
651  .name = "indeo5",
652  .type = AVMEDIA_TYPE_VIDEO,
653  .id = CODEC_ID_INDEO5,
654  .priv_data_size = sizeof(IVI45DecContext),
655  .init = decode_init,
658  .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"),
659 };
static const uint8_t ivi5_scale_quant_8x8_inter[5][24]
Definition: indeo5data.h:115
int is_empty
= 1 if this band doesn't contain any data
Definition: ivi_common.h:145
uint8_t type
macroblock type: 0 - INTRA, 1 - INTER
Definition: ivi_common.h:105
int num_MBs
number of macroblocks in this tile
Definition: ivi_common.h:124
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
Definition: avcodec.h:1426
Huffman table is used for coding macroblocks.
Definition: ivi_common.h:63
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
static const uint16_t ivi5_base_quant_4x4_inter[16]
Definition: indeo5data.h:106
av_cold int ff_ivi_decode_close(AVCodecContext *avctx)
Close Indeo5 decoder and clean up its context.
Definition: ivi_common.c:970
const uint8_t ff_zigzag_direct[64]
Definition: dsputil.c:61
InvTransformPtr * inv_transform
Definition: ivi_common.h:164
int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab, IVIHuffTab *huff_tab, AVCodecContext *avctx)
Decode a huffman codebook descriptor from the bitstream and select specified huffman table...
Definition: ivi_common.c:138
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:237
int(* decode_pic_hdr)(struct IVI45DecContext *ctx, AVCodecContext *avctx)
Definition: ivi_common.h:247
static void skip_bits_long(GetBitContext *s, int n)
Definition: get_bits.h:197
int inter_scal
signals a sequence of scalable inter frames
Definition: ivi_common.h:212
static const uint16_t ivi5_base_quant_4x4_intra[16]
Definition: indeo5data.h:110
static void align_get_bits(GetBitContext *s)
Definition: get_bits.h:378
const uint8_t ff_ivi_direct_scan_4x4[16]
Definition: ivi_common.c:1057
int(* decode_mb_info)(struct IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx)
Definition: ivi_common.h:249
static const uint8_t ivi5_common_pic_sizes[30]
standard picture dimensions (width, height divided by 4)
Definition: indeo5data.h:35
int dst_buf
buffer index for the currently decoded frame
Definition: ivi_common.h:222
void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
Copy the DC coefficient into the first pixel of the block and zero all others.
Definition: ivi_dsp.c:560
DSP functions (inverse transforms, motion compensations, wavelet recompostion) for Indeo Video Intera...
int is_halfpel
precision of the motion compensation: 0 - fullpel, 1 - halfpel
Definition: ivi_common.h:148
uint8_t chroma_bands
Definition: ivi_common.h:197
int plane
plane number this band belongs to
Definition: ivi_common.h:134
IVIPicConfig pic_conf
Definition: ivi_common.h:218
non-droppable P-frame
Definition: indeo5.c:43
AVCodec.
Definition: avcodec.h:3189
static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx)
Decode info (block type, cbp, quant delta, motion vector) for all macroblocks in the current tile...
Definition: indeo5.c:431
void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
Copy the pixels into the frame buffer.
Definition: ivi_dsp.c:550
int av_cold ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
Initialize planes (prepares descriptors, allocates buffers etc).
Definition: ivi_common.c:200
static av_cold int decode_init(AVCodecContext *avctx)
Initialize Indeo5 decoder.
Definition: indeo5.c:608
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
uint8_t luma_bands
Definition: ivi_common.h:196
VLC * tab
index of one of the predefined tables or "7" for custom one
Definition: ivi_common.h:54
#define av_cold
Definition: attributes.h:71
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:70
const uint16_t * inter_base
quantization matrix for inter blocks
Definition: ivi_common.h:172
static const uint16_t ivi5_base_quant_8x8_intra[5][64]
Definition: indeo5data.h:78
static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
Decode Indeo5 GOP (Group of pictures) header.
Definition: indeo5.c:60
uint16_t pic_height
Definition: ivi_common.h:191
int inherit_mv
tells if motion vector is inherited from reference macroblock
Definition: ivi_common.h:149
uint16_t tile_height
Definition: ivi_common.h:195
GetBitContext gb
Definition: ivi_common.h:201
uint16_t chroma_width
Definition: ivi_common.h:192
int pitch
pitch associated with the buffers above
Definition: ivi_common.h:144
uint8_t cbp
coded block pattern
Definition: ivi_common.h:106
int qdelta_present
tells if Qdelta signal is present in the bitstream (Indeo5 only)
Definition: ivi_common.h:151
uint16_t checksum
frame checksum
Definition: ivi_common.h:216
bitstream reader API header.
uint32_t pic_hdr_size
picture header size in bytes
Definition: ivi_common.h:214
uint16_t pic_width
Definition: ivi_common.h:190
IVIPlaneDesc planes[3]
color planes
Definition: ivi_common.h:219
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:336
void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
inverse 1D row slant transform
Definition: ivi_dsp.c:471
const uint16_t * intra_base
quantization matrix for intra blocks
Definition: ivi_common.h:171
int data_size
size of the band data
Definition: ivi_common.h:140
void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only inverse row slant transform.
Definition: ivi_dsp.c:491
int blk_size
block size
Definition: ivi_common.h:147
const RVMapDesc ff_ivi_rvmap_tabs[9]
Run-value (RLE) tables.
Definition: ivi_common.c:1065
static int is_nonnull_frame(IVI45DecContext *ctx)
Definition: indeo5.c:599
uint8_t corr[61 *2]
rvmap correction pairs
Definition: ivi_common.h:159
static int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
compare some properties of two pictures
Definition: ivi_common.h:257
RVMapDesc rvmap_tabs[9]
local corrected copy of the static rvmap tables
Definition: ivi_common.h:203
#define IVI_VLC_BITS
max number of bits of the ivi's huffman codes
Definition: ivi_common.h:36
AVCodec ff_indeo5_decoder
Definition: indeo5.c:650
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
static const uint16_t ivi5_base_quant_8x8_inter[5][64]
Indeo5 dequantization matrixes consist of two tables: base table and scale table. ...
Definition: indeo5data.h:50
This file contains structures and macros shared by both Indeo4 and Indeo5 decoders.
void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only inverse column slant transform.
Definition: ivi_dsp.c:536
int ref_buf
inter frame reference buffer index
Definition: ivi_common.h:223
DCTransformPtr * dc_transform
Definition: ivi_common.h:166
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:140
const char * name
Name of the codec implementation.
Definition: avcodec.h:3196
struct IVI45DecContext IVI45DecContext
static const uint8_t ivi5_scale_quant_8x8_intra[5][24]
Definition: indeo5data.h:133
#define IVI5_PIC_SIZE_ESC
Definition: indeo5.c:49
#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size)
calculate number of macroblocks in a tile
Definition: ivi_common.h:269
int inherit_qdelta
tells if quantiser delta is inherited from reference macroblock
Definition: ivi_common.h:150
uint32_t frame_num
Definition: ivi_common.h:205
int(* decode_band_hdr)(struct IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx)
Definition: ivi_common.h:248
This file contains data needed for the Indeo5 decoder.
int width
picture width / height.
Definition: avcodec.h:1408
IVIMbInfo * mbs
array of macroblock descriptors
Definition: ivi_common.h:125
const uint8_t * inter_scale
quantization coefficient for inter blocks
Definition: ivi_common.h:174
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:481
uint16_t chroma_height
Definition: ivi_common.h:193
uint32_t lock_word
Definition: ivi_common.h:237
void ff_ivi_init_static_vlc(void)
Initialize static codes used for macroblock and block decoding.
Definition: ivi_common.c:117
int8_t q_delta
quant delta
Definition: ivi_common.h:107
void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
two-dimensional inverse slant 8x8 transform
Definition: ivi_dsp.c:378
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
Definition: error.h:57
droppable P-frame used in the scalability mode
Definition: indeo5.c:44
uint16_t tile_width
Definition: ivi_common.h:194
int ypos
Definition: ivi_common.h:118
IVIHuffTab mb_vlc
current macroblock table descriptor
Definition: ivi_common.h:226
int is_2d_trans
1 indicates that the two-dimensional inverse transform is used
Definition: ivi_common.h:167
external API header
int glob_quant
quant base for this band
Definition: ivi_common.h:153
int height
Definition: ivi_common.h:120
main external API structure.
Definition: avcodec.h:1329
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:327
uint8_t frame_flags
Definition: ivi_common.h:215
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:111
int num_corr
number of correction entries
Definition: ivi_common.h:158
information for Indeo tile
Definition: ivi_common.h:116
int(* is_nonnull_frame)(struct IVI45DecContext *ctx)
Definition: ivi_common.h:251
const uint8_t ff_ivi_vertical_scan_8x8[64]
Scan patterns shared between indeo4 and indeo5.
Definition: ivi_common.c:1035
int buf_switch
used to switch between three buffers
Definition: ivi_common.h:221
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:268
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:260
uint8_t gop_flags
Definition: ivi_common.h:236
static void skip_hdr_extension(GetBitContext *gb)
Skip a header extension.
Definition: indeo5.c:280
static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
Decode Indeo5 picture header.
Definition: indeo5.c:298
void(* switch_buffers)(struct IVI45DecContext *ctx)
Definition: ivi_common.h:250
IVIBandDesc * bands
array of band descriptors
Definition: ivi_common.h:185
int32_t checksum
for debug purposes
Definition: ivi_common.h:168
int rvmap_sel
rvmap table selector
Definition: ivi_common.h:160
int8_t mv_x
motion vector (x component)
Definition: ivi_common.h:108
int8_t mv_y
motion vector (y component)
Definition: ivi_common.h:109
static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx)
Decode Indeo5 band header.
Definition: indeo5.c:359
int mb_size
macroblock size
Definition: ivi_common.h:146
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:301
IVIMbInfo * ref_mbs
ptr to the macroblock descriptors of the reference tile
Definition: ivi_common.h:126
int xpos
Definition: ivi_common.h:117
empty frame with no data
Definition: indeo5.c:46
uint16_t gop_hdr_size
Definition: ivi_common.h:235
void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
two-dimensional inverse slant 4x4 transform
Definition: ivi_dsp.c:418
int16_t xpos
Definition: ivi_common.h:102
int av_cold ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
Initialize tile and macroblock descriptors.
Definition: ivi_common.c:328
static const uint8_t ivi5_scale_quant_4x4_inter[24]
Definition: indeo5data.h:151
int band_num
band number
Definition: ivi_common.h:135
int transform_size
Definition: ivi_common.h:165
int ref2_buf
temporal storage for switching buffers
Definition: ivi_common.h:224
DSP utils.
const uint8_t * scan
ptr to the scan pattern
Definition: ivi_common.h:154
void * priv_data
Definition: avcodec.h:1531
int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: ivi_common.c:870
int width
Definition: ivi_common.h:119
int len
int checksum_present
Definition: ivi_common.h:169
static const uint8_t ivi5_scale_quant_4x4_intra[24]
Definition: indeo5data.h:156
VLC_TYPE(* table)[2]
code, bits
Definition: get_bits.h:65
static int ivi_scale_mv(int mv, int mv_scale)
scale motion vector
Definition: ivi_common.h:276
void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
DC-only two-dimensional inverse slant transform.
Definition: ivi_dsp.c:458
int16_t ypos
Definition: ivi_common.h:103
static void switch_buffers(IVI45DecContext *ctx)
Switch buffers.
Definition: indeo5.c:561
int prev_frame_type
frame type of the previous frame
Definition: ivi_common.h:207
information for Indeo macroblock (16x16, 8x8 or 4x4)
Definition: ivi_common.h:101
IVIHuffTab blk_vlc
vlc table for decoding block data
Definition: ivi_common.h:156
const uint8_t ff_ivi_horizontal_scan_8x8[64]
Definition: ivi_common.c:1046
const uint8_t * intra_scale
quantization coefficient for intra blocks
Definition: ivi_common.h:173
#define FFSWAP(type, a, b)
Definition: common.h:58
uint32_t buf_offs
address in the output buffer for this mb
Definition: ivi_common.h:104
#define IVI_TOSIGNED(val)
convert unsigned values into signed ones (the sign is in the LSB)
Definition: ivi_common.h:273
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
Log a generic warning message about a missing feature.
Definition: utils.c:1714
information for Indeo wavelet band
Definition: ivi_common.h:133
droppable P-frame
Definition: indeo5.c:45
#define IVI5_IS_PROTECTED
Definition: ivi_common.h:38
void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
inverse 1D column slant transform
Definition: ivi_dsp.c:509