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