Lines Matching refs:band
81 static int ivi_mc(const IVIBandDesc *band, ivi_mc_func mc, ivi_mc_avg_func mc_avg,
85 int ref_offs = offs + mv_y * band->pitch + mv_x;
86 int buf_size = band->pitch * band->aheight;
87 int min_size = band->pitch * (band->blk_size - 1) + band->blk_size;
88 int ref_size = (mc_type > 1) * band->pitch + (mc_type & 1);
91 av_assert0(offs >= 0 && ref_offs >= 0 && band->ref_buf);
97 mc(band->buf + offs, band->ref_buf + ref_offs, band->pitch, mc_type);
99 int ref_offs2 = offs + mv_y2 * band->pitch + mv_x2;
100 int ref_size2 = (mc_type2 > 1) * band->pitch + (mc_type2 & 1);
101 if (offs < 0 || ref_offs2 < 0 || !band->b_ref_buf)
107 mc(band->buf + offs, band->b_ref_buf + ref_offs2,
108 band->pitch, mc_type2);
110 mc_avg(band->buf + offs, band->ref_buf + ref_offs,
111 band->b_ref_buf + ref_offs2, band->pitch,
273 IVIBandDesc *band = &planes[p].bands[b];
274 av_freep(&band->bufs[0]);
275 av_freep(&band->bufs[1]);
276 av_freep(&band->bufs[2]);
277 av_freep(&band->bufs[3]);
279 if (band->blk_vlc.cust_tab.table)
280 ff_free_vlc(&band->blk_vlc.cust_tab);
281 for (t = 0; t < band->num_tiles; t++)
282 av_freep(&band->tiles[t].mbs);
283 av_freep(&band->tiles);
297 IVIBandDesc *band;
320 /* select band dimensions: if there is only one band then it
328 /* luma band buffers will be aligned on 16x16 (max macroblock size) */
329 /* chroma band buffers will be aligned on 8x8 (max macroblock size) */
336 band = &planes[p].bands[b]; /* select appropriate plane/band */
337 band->plane = p;
338 band->band_num = b;
339 band->width = b_width;
340 band->height = b_height;
341 band->pitch = width_aligned;
342 band->aheight = height_aligned;
343 av_assert0(!band->bufs[0] && !band->bufs[1] &&
344 !band->bufs[2] && !band->bufs[3]);
345 band->bufsize = buf_size/2;
356 static int ivi_init_tiles(const IVIBandDesc *band, IVITile *ref_tile,
360 IVITile *tile = band->tiles;
362 for (y = 0; y < band->height; y += t_height) {
363 for (x = 0; x < band->width; x += t_width) {
366 tile->mb_size = band->mb_size;
367 tile->width = FFMIN(band->width - x, t_width);
368 tile->height = FFMIN(band->height - y, t_height);
372 band->mb_size);
399 IVIBandDesc *band;
417 band = &planes[p].bands[b];
419 if (band->tiles) {
421 for (t = 0; t < band->num_tiles; t++) {
422 av_freep(&band->tiles[t].mbs);
426 x_tiles = IVI_NUM_TILES(band->width, t_width);
427 y_tiles = IVI_NUM_TILES(band->height, t_height);
428 band->num_tiles = x_tiles * y_tiles;
430 av_freep(&band->tiles);
431 band->tiles = av_calloc(band->num_tiles, sizeof(*band->tiles));
432 if (!band->tiles) {
433 band->num_tiles = 0;
437 /* use the first luma band as reference for motion vectors
439 ret = ivi_init_tiles(band, planes[0].bands[0].tiles,
476 static int ivi_dc_transform(const IVIBandDesc *band, int *prev_dc, int buf_offs,
479 band->dc_transform(prev_dc, band->buf + buf_offs,
480 band->pitch, blk_size);
485 static int ivi_decode_coded_blocks(GetBitContext *gb, const IVIBandDesc *band,
494 const uint16_t *base_tab = is_intra ? band->intra_base : band->inter_base;
495 RVMapDesc *rvmap = band->rv_map;
500 int blk_size = band->blk_size;
504 int min_size = band->pitch * (band->transform_size - 1) +
505 band->transform_size;
506 int buf_size = band->pitch * band->aheight - offs;
511 if (!band->scan) {
521 sym = get_vlc2(gb, band->blk_vlc.tab->table,
528 run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
529 lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
530 hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
546 pos = band->scan[scan_pos];
563 if (is_intra && band->is_2d_trans) {
569 if(band->transform_size > band->blk_size){
575 band->inv_transform(trvec, band->buf + offs,
576 band->pitch, col_flags);
580 return ivi_mc(band, mc, mc_avg, offs, mv_x, mv_y, mv_x2, mv_y2,
592 * @param[in] band pointer to the band descriptor
596 static int ivi_decode_blocks(GetBitContext *gb, const IVIBandDesc *band,
611 blk_size = band->blk_size;
613 num_blocks = (band->mb_size != blk_size) ? 4 : 1;
631 quant = band->glob_quant + mb->q_delta;
637 scale_tab = is_intra ? band->intra_scale : band->inter_scale;
646 if (band->is_halfpel) {
661 dmv_x = mb->mv_x >> band->is_halfpel;
662 dmv_y = mb->mv_y >> band->is_halfpel;
663 cx = mb->mv_x & band->is_halfpel;
664 cy = mb->mv_y & band->is_halfpel;
667 mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
669 mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
676 dmv_x = mb->b_mv_x >> band->is_halfpel;
677 dmv_y = mb->b_mv_y >> band->is_halfpel;
678 cx = mb->b_mv_x & band->is_halfpel;
679 cy = mb->b_mv_y & band->is_halfpel;
682 mb->xpos + dmv_x + band->mb_size + cx > band->pitch ||
684 mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
696 buf_offs += blk_size * band->pitch;
700 ret = ivi_decode_coded_blocks(gb, band, mc_with_delta_func,
709 int buf_size = band->pitch * band->aheight - buf_offs;
710 int min_size = (blk_size - 1) * band->pitch + blk_size;
718 ret = ivi_dc_transform(band, &prev_dc, buf_offs, blk_size);
722 ret = ivi_mc(band, mc_no_delta_func, mc_avg_no_delta_func,
744 * @param[in] band pointer to the band descriptor
748 static int ivi_process_empty_tile(AVCodecContext *avctx, const IVIBandDesc *band,
757 int clear_first = !band->qdelta_present && !band->plane && !band->band_num;
758 int mb_size = band->mb_size;
760 int is_halfpel = band->is_halfpel;
761 int pitch = band->pitch;
788 mb->q_delta = band->glob_quant;
794 if (band->inherit_qdelta)
797 if (band->inherit_mv) {
818 || mb->ypos + dmv_y + mb_size + cy > band->aheight) {
833 if (band->inherit_mv && need_mc) { /* apply motion compensation if there is at least one non-zero motion vector */
834 num_blocks = (mb_size != band->blk_size) ? 4 : 1; /* number of blocks per mb */
835 mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
841 if (!band->is_halfpel) {
851 offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * pitch);
852 ret = ivi_mc(band, mc_no_delta_func, 0, offs,
860 src = band->ref_buf + tile->ypos * pitch + tile->xpos;
861 dst = band->buf + tile->ypos * pitch + tile->xpos;
863 memcpy(dst, src, tile->width*sizeof(band->buf[0]));
874 static uint16_t ivi_calc_band_checksum(const IVIBandDesc *band)
879 src = band->buf;
882 for (y = 0; y < band->height; src += band->pitch, y++)
883 for (x = 0; x < band->width; x++)
924 static void *prepare_buf(IVI45DecContext *ctx, IVIBandDesc *band, int i)
928 if (!band->bufs[i])
929 band->bufs[i] = av_mallocz(2 * band->bufsize);
930 return band->bufs[i];
934 * Decode an Indeo 4 or 5 band.
937 * @param[in,out] band ptr to the band descriptor
942 IVIBandDesc *band, AVCodecContext *avctx)
947 band->buf = prepare_buf(ctx, band, ctx->dst_buf);
948 if (!band->buf) {
953 band->ref_buf = prepare_buf(ctx, band, ctx->b_ref_buf);
954 band->b_ref_buf = prepare_buf(ctx, band, ctx->ref_buf);
955 if (!band->b_ref_buf)
958 band->ref_buf = prepare_buf(ctx, band, ctx->ref_buf);
959 band->b_ref_buf = 0;
961 if (!band->ref_buf)
963 band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
965 result = ctx->decode_band_hdr(ctx, band, avctx);
967 av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
972 if (band->is_empty) {
973 av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
977 band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
980 for (i = 0; i < band->num_corr; i++) {
981 idx1 = band->corr[i * 2];
982 idx2 = band->corr[i * 2 + 1];
983 FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
984 FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
985 if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
986 band->rv_map->eob_sym ^= idx1 ^ idx2;
987 if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
988 band->rv_map->esc_sym ^= idx1 ^ idx2;
993 for (t = 0; t < band->num_tiles; t++) {
994 tile = &band->tiles[t];
996 if (tile->mb_size != band->mb_size) {
998 band->mb_size, tile->mb_size);
1003 result = ivi_process_empty_tile(avctx, band, tile,
1004 (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
1016 result = ctx->decode_mb_info(ctx, band, tile, avctx);
1020 result = ivi_decode_blocks(&ctx->gb, band, tile, avctx);
1040 for (i = band->num_corr-1; i >= 0; i--) {
1041 idx1 = band->corr[i*2];
1042 idx2 = band->corr[i*2+1];
1043 FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
1044 FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
1045 if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
1046 band->rv_map->eob_sym ^= idx1 ^ idx2;
1047 if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
1048 band->rv_map->esc_sym ^= idx1 ^ idx2;
1052 if (band->checksum_present) {
1053 uint16_t chksum = ivi_calc_band_checksum(band);
1054 if (chksum != band->checksum) {
1056 "Band checksum mismatch! Plane %d, band %d, "
1058 band->plane, band->band_num, band->checksum, chksum);
1121 "Error while decoding band: %d, plane: %d\n", b, p);