if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
if (ff_ivi_init_planes(ctx->planes, &pic_conf)) {
av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
+ ctx->pic_conf.luma_bands = 0;
return AVERROR(ENOMEM);
}
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;
- scan_indx = get_bits(&ctx->gb, 4);
- if ((scan_indx>4 && scan_indx<10) != (band->blk_size==4)) {
- av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
+ if (transform_id < 10)
+ band->transform_size = 8;
+ else
+ band->transform_size = 4;
+
+ if (band->blk_size != band->transform_size) {
+ av_log(avctx, AV_LOG_ERROR, "transform and block size mismatch (%d != %d)\n", band->transform_size, band->blk_size);
return AVERROR_INVALIDDATA;
}
+
+ scan_indx = get_bits(&ctx->gb, 4);
if (scan_indx == 15) {
av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
return AVERROR_INVALIDDATA;
}
+ if (scan_indx > 4 && scan_indx < 10) {
+ if (band->blk_size != 4) {
+ av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
+ return AVERROR_INVALIDDATA;
+ }
+ } else if (band->blk_size != 8) {
+ av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
+ return AVERROR_INVALIDDATA;
+ }
+
band->scan = scan_index_to_tab[scan_indx];
band->scan_size = band->blk_size;
av_log(avctx, AV_LOG_ERROR, "Custom quant matrix encountered!\n");
return AVERROR_INVALIDDATA;
}
- if (quant_mat > 21) {
- av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix encountered!\n");
+ if (quant_mat >= FF_ARRAY_ELEMS(quant_index_to_tab)) {
+ avpriv_request_sample(avctx, "Quantization matrix %d",
+ quant_mat);
return AVERROR_INVALIDDATA;
}
band->quant_mat = quant_mat;
}
}
} else {
- if (band->inherit_mv && ref_mb) {
- mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
+ if (band->inherit_mv) {
+ /* copy mb_type from corresponding reference mb */
+ if (!ref_mb) {
+ av_log(avctx, AV_LOG_ERROR, "ref_mb unavailable\n");
+ return AVERROR_INVALIDDATA;
+ }
+ mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA ||
ctx->frame_type == FRAMETYPE_INTRA1) {
mb->type = 0; /* mb_type is always INTRA for intra-frames */
if (!mb->type) {
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
} else {
- if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
+ if (band->inherit_mv) {
+ if (ref_mb)
+ /* motion vector inheritance */
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ } else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
} else {
/* decode motion vector deltas */
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,