*/
#include "libavutil/common.h"
+
#include "avcodec.h"
-#include "internal.h"
-#include "get_bits.h"
+#include "bitstream.h"
#include "golomb.h"
+#include "internal.h"
typedef struct FICThreadContext {
DECLARE_ALIGNED(16, int16_t, block)[64];
ptr += 8;
}
}
-static int fic_decode_block(FICContext *ctx, GetBitContext *gb,
+static int fic_decode_block(FICContext *ctx, BitstreamContext *bc,
uint8_t *dst, int stride, int16_t *block)
{
int i, num_coeff;
/* Is it a skip block? */
- if (get_bits1(gb)) {
+ if (bitstream_read_bit(bc)) {
/* This is a P-frame. */
ctx->frame->key_frame = 0;
ctx->frame->pict_type = AV_PICTURE_TYPE_P;
memset(block, 0, sizeof(*block) * 64);
- num_coeff = get_bits(gb, 7);
+ num_coeff = bitstream_read(bc, 7);
if (num_coeff > 64)
return AVERROR_INVALIDDATA;
for (i = 0; i < num_coeff; i++)
- block[ff_zigzag_direct[i]] = get_se_golomb(gb) *
+ block[ff_zigzag_direct[i]] = get_se_golomb(bc) *
ctx->qmat[ff_zigzag_direct[i]];
fic_idct_put(dst, stride, block);
{
FICContext *ctx = avctx->priv_data;
FICThreadContext *tctx = tdata;
- GetBitContext gb;
+ BitstreamContext bc;
uint8_t *src = tctx->src;
int slice_h = tctx->slice_h;
int src_size = tctx->src_size;
int y_off = tctx->y_off;
int x, y, p;
- init_get_bits(&gb, src, src_size * 8);
+ bitstream_init8(&bc, src, src_size);
for (p = 0; p < 3; p++) {
int stride = ctx->frame->linesize[p];
for (x = 0; x < (ctx->aligned_width >> !!p); x += 8) {
int ret;
- if ((ret = fic_decode_block(ctx, &gb, dst + x, stride, tctx->block)) != 0)
+ if ((ret = fic_decode_block(ctx, &bc, dst + x, stride, tctx->block)) != 0)
return ret;
}
/* Convert to YUVA444. */
for (i = 0; i < 1024; i++) {
- planes[0][i] = av_clip_uint8((( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16);
- planes[1][i] = av_clip_uint8(((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128);
- planes[2][i] = av_clip_uint8(((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128);
+ planes[0][i] = (( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16;
+ planes[1][i] = ((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128;
+ planes[2][i] = ((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128;
planes[3][i] = ptr[3];
ptr += 4;
/* Skip cursor data. */
tsize = AV_RB24(src + 24);
if (tsize > avpkt->size - FIC_HEADER_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size.\n");
+ av_log(avctx, AV_LOG_ERROR,
+ "Packet is too small to contain cursor (%d vs %d bytes).\n",
+ tsize, avpkt->size - FIC_HEADER_SIZE);
return AVERROR_INVALIDDATA;
}
.init = fic_decode_init,
.decode = fic_decode_frame,
.close = fic_decode_close,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
};