* @param[in] tile pointer to the tile descriptor
* @return result code: 0 - OK, -1 = error (corrupted blocks data)
*/
-static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
+static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile,
+ AVCodecContext *avctx)
{
int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val,
pos, is_intra, mc_type = 0, mv_x, mv_y, col_mask;
}
if (cbp & 1) { /* block coded ? */
+ if (!band->scan) {
+ av_log(avctx, AV_LOG_ERROR, "Scan pattern is not set.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
scan_pos = -1;
memset(trvec, 0, num_coeffs*sizeof(trvec[0])); /* zero transform vector */
memset(col_flags, 0, sizeof(col_flags)); /* zero column flags */
val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */
} else {
if (sym >= 256U) {
- av_log(NULL, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
+ av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
return -1;
}
run = rvmap->runtab[sym];
pos = band->scan[scan_pos];
if (!val)
- av_dlog(NULL, "Val = 0 encountered!\n");
+ av_dlog(avctx, "Val = 0 encountered!\n");
q = (base_tab[pos] * quant) >> 9;
if (q > 1)
/* block not coded */
/* for intra blocks apply the dc slant transform */
/* for inter - perform the motion compensation without delta */
- if (is_intra && band->dc_transform) {
- band->dc_transform(&prev_dc, band->buf + buf_offs,
- band->pitch, blk_size);
+ if (is_intra) {
+ if (band->dc_transform)
+ band->dc_transform(&prev_dc, band->buf + buf_offs,
+ band->pitch, blk_size);
} else
mc_no_delta_func(band->buf + buf_offs,
band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
if (result < 0)
break;
- result = ivi_decode_blocks(&ctx->gb, band, tile);
+ result = ivi_decode_blocks(&ctx->gb, band, tile, avctx);
if (result < 0 || ((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) {
av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n");
break;
{
IVI45DecContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
+ AVFrame *frame = data;
int buf_size = avpkt->size;
int result, p, b;
av_log(avctx, AV_LOG_ERROR, "Buffer contains IP frames!\n");
}
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
- ctx->frame.reference = 0;
avcodec_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height);
- if ((result = ff_get_buffer(avctx, &ctx->frame)) < 0) {
+ if ((result = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return result;
}
if (ctx->is_scalable) {
if (avctx->codec_id == AV_CODEC_ID_INDEO4)
- ff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
+ ff_ivi_recompose_haar(&ctx->planes[0], frame->data[0], frame->linesize[0]);
else
- ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
+ ff_ivi_recompose53 (&ctx->planes[0], frame->data[0], frame->linesize[0]);
} else {
- ivi_output_plane(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
+ ivi_output_plane(&ctx->planes[0], frame->data[0], frame->linesize[0]);
}
- ivi_output_plane(&ctx->planes[2], ctx->frame.data[1], ctx->frame.linesize[1]);
- ivi_output_plane(&ctx->planes[1], ctx->frame.data[2], ctx->frame.linesize[2]);
+ ivi_output_plane(&ctx->planes[2], frame->data[1], frame->linesize[1]);
+ ivi_output_plane(&ctx->planes[1], frame->data[2], frame->linesize[2]);
*got_frame = 1;
- *(AVFrame*)data = ctx->frame;
return buf_size;
}
if (ctx->mb_vlc.cust_tab.table)
ff_free_vlc(&ctx->mb_vlc.cust_tab);
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
#if IVI4_STREAM_ANALYSER
if (avctx->codec_id == AV_CODEC_ID_INDEO4) {
if (ctx->is_scalable)