band->inv_transform = transforms[transform_id].inv_trans;
band->dc_transform = transforms[transform_id].dc_trans;
band->is_2d_trans = transforms[transform_id].is_2d_trans;
- band->transform_size= (transform_id < 10) ? 8 : 4;
++
+ if (transform_id < 10)
+ band->transform_size = 8;
+ else
+ band->transform_size = 4;
+
+ if (band->blk_size != band->transform_size)
+ return AVERROR_INVALIDDATA;
scan_indx = get_bits(&ctx->gb, 4);
if (scan_indx == 15) {
return len;
}
- if (!band->dc_transform)
- return 0;
-
-
+ static int ivi_dc_transform(IVIBandDesc *band, int *prev_dc, int buf_offs,
+ int blk_size)
+ {
+ int buf_size = band->pitch * band->aheight - buf_offs;
+ int min_size = (blk_size - 1) * band->pitch + blk_size;
+
+ if (min_size > buf_size)
+ return AVERROR_INVALIDDATA;
+
+ band->dc_transform(prev_dc, band->buf + buf_offs,
+ band->pitch, blk_size);
+
+ return 0;
+ }
static int ivi_decode_coded_blocks(GetBitContext *gb, IVIBandDesc *band,
ivi_mc_func mc, int mv_x, int mv_y,