#include "avcodec.h"
#include "bytestream.h"
-#include "dsputil.h"
#include "internal.h"
#include "get_bits.h"
#include "golomb.h"
+#include "idctdsp.h"
#include "unary.h"
#define AIC_HDR_SIZE 24
typedef struct AICContext {
AVCodecContext *avctx;
AVFrame *frame;
- DSPContext dsp;
+ IDCTDSPContext idsp;
ScanTable scantable;
int num_x_slices;
recombine_block_il(ctx->block, ctx->scantable.permutated,
&base_y, &ext_y, blk);
unquant_block(ctx->block, ctx->quant);
- ctx->dsp.idct(ctx->block);
+ ctx->idsp.idct(ctx->block);
if (!ctx->interlaced) {
dst = Y + (blk >> 1) * 8 * ystride + (blk & 1) * 8;
- ctx->dsp.put_signed_pixels_clamped(ctx->block, dst,
- ystride);
+ ctx->idsp.put_signed_pixels_clamped(ctx->block, dst, ystride);
} else {
dst = Y + (blk & 1) * 8 + (blk >> 1) * ystride;
- ctx->dsp.put_signed_pixels_clamped(ctx->block, dst,
- ystride * 2);
+ ctx->idsp.put_signed_pixels_clamped(ctx->block, dst,
+ ystride * 2);
}
}
Y += 16;
recombine_block(ctx->block, ctx->scantable.permutated,
&base_c, &ext_c);
unquant_block(ctx->block, ctx->quant);
- ctx->dsp.idct(ctx->block);
- ctx->dsp.put_signed_pixels_clamped(ctx->block, C[blk],
- ctx->frame->linesize[blk + 1]);
+ ctx->idsp.idct(ctx->block);
+ ctx->idsp.put_signed_pixels_clamped(ctx->block, C[blk],
+ ctx->frame->linesize[blk + 1]);
C[blk] += 8;
}
}
return AVERROR_INVALIDDATA;
}
- if ((ret = aic_decode_header(ctx, buf, buf_size)) < 0)
+ ret = aic_decode_header(ctx, buf, buf_size);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid header\n");
return ret;
+ }
if ((ret = ff_get_buffer(avctx, ctx->frame, 0)) < 0)
return ret;
for (x = 0; x < ctx->mb_width; x += ctx->slice_width) {
slice_size = bytestream2_get_le16(&gb) * 4;
if (slice_size + off > buf_size || !slice_size) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Incorrect slice size %d at %d.%d\n", slice_size, x, y);
return AVERROR_INVALIDDATA;
}
- if ((ret = aic_decode_slice(ctx, x, y,
- buf + off, slice_size)) < 0)
+ ret = aic_decode_slice(ctx, x, y, buf + off, slice_size);
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Error decoding slice at %d.%d\n", x, y);
return ret;
+ }
off += slice_size;
}
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
- ff_dsputil_init(&ctx->dsp, avctx);
+ ff_idctdsp_init(&ctx->idsp, avctx);
for (i = 0; i < 64; i++)
scan[i] = i;
- ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, scan);
+ ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, scan);
ctx->mb_width = FFALIGN(avctx->width, 16) >> 4;
ctx->mb_height = FFALIGN(avctx->height, 16) >> 4;
- ctx->num_x_slices = 16;
- ctx->slice_width = ctx->mb_width / 16;
+ ctx->num_x_slices = (ctx->mb_width + 15) >> 4;
+ ctx->slice_width = 16;
for (i = 1; i < 32; i++) {
- if (!(ctx->mb_width % i) && (ctx->mb_width / i < 32)) {
+ if (!(ctx->mb_width % i) && (ctx->mb_width / i <= 32)) {
ctx->slice_width = ctx->mb_width / i;
ctx->num_x_slices = i;
break;
.init = aic_decode_init,
.close = aic_decode_close,
.decode = aic_decode_frame,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1,
};