X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmimic.c;h=e5f7123e947a39f7abe2a460c658c0f37fb55ef5;hb=deca86eab1623b3391b7113b4ac6e74b8408639d;hp=252dd886454ba2d1c10915b693136ead0a05bba4;hpb=9ed0cff98ec9d9c45b6f1138b42768c3002acf6f;p=ffmpeg diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 252dd886454..e5f7123e947 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -24,7 +24,7 @@ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #include "dsputil.h" @@ -36,7 +36,7 @@ typedef struct { int num_vblocks[3]; int num_hblocks[3]; - uint8_t *swap_buf; + void *swap_buf; int swap_buf_size; int cur_index; @@ -45,7 +45,7 @@ typedef struct { AVFrame buf_ptrs [16]; AVPicture flipped_ptrs[16]; - DECLARE_ALIGNED_16(DCTELEM, dct_block[64]); + DECLARE_ALIGNED(16, DCTELEM, dct_block)[64]; GetBitContext gb; ScanTable scantable; @@ -110,7 +110,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) ctx->prev_index = 0; ctx->cur_index = 15; - if(init_vlc(&ctx->vlc, 8, sizeof(huffbits)/sizeof(huffbits[0]), + if(init_vlc(&ctx->vlc, 11, FF_ARRAY_ELEMS(huffbits), huffbits, 1, 1, huffcodes, 4, 4, 0)) { av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n"); return -1; @@ -121,7 +121,7 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) return 0; } -const static int8_t vlcdec_lookup[9][64] = { +static const int8_t vlcdec_lookup[9][64] = { { 0, }, { -1, 1, }, { -3, 3, -2, 2, }, @@ -163,7 +163,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) DCTELEM *block = ctx->dct_block; unsigned int pos; - memset(block, 0, 64 * sizeof(DCTELEM)); + ctx->dsp.clear_block(block); block[0] = get_bits(&ctx->gb, 8) << 3; @@ -172,7 +172,7 @@ static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale) int value; int coeff; - vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 4); + vlc = get_vlc2(&ctx->gb, ctx->vlc.table, ctx->vlc.bits, 3); if(!vlc) /* end-of-block code */ return 1; if(vlc == -1) @@ -274,8 +274,10 @@ static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src) } static int mimic_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, const uint8_t *buf, int buf_size) + int *data_size, AVPacket *avpkt) { + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; MimicContext *ctx = avctx->priv_data; int is_pframe; int width, height; @@ -293,7 +295,8 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, height = bytestream_get_le16(&buf); buf += 4; /* some constant */ is_pframe = bytestream_get_le32(&buf); - num_coeffs = bytestream_get_le32(&buf); + num_coeffs = bytestream_get_byte(&buf); + buf += 3; /* some constant */ if(!ctx->avctx) { int i; @@ -331,12 +334,12 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index], (AVPicture*) &ctx->buf_ptrs[ctx->cur_index]); - ctx->swap_buf = av_fast_realloc(ctx->swap_buf, &ctx->swap_buf_size, + av_fast_malloc(&ctx->swap_buf, &ctx->swap_buf_size, swap_buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if(!ctx->swap_buf) - return AVERROR_NOMEM; + return AVERROR(ENOMEM); - ctx->dsp.bswap_buf((uint32_t*)ctx->swap_buf, + ctx->dsp.bswap_buf(ctx->swap_buf, (const uint32_t*) buf, swap_buf_size>>2); init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3); @@ -377,7 +380,7 @@ static av_cold int mimic_decode_end(AVCodecContext *avctx) AVCodec mimic_decoder = { "mimic", - CODEC_TYPE_VIDEO, + AVMEDIA_TYPE_VIDEO, CODEC_ID_MIMIC, sizeof(MimicContext), mimic_decode_init, @@ -385,4 +388,5 @@ AVCodec mimic_decoder = { mimic_decode_end, mimic_decode_frame, CODEC_CAP_DR1, + .long_name = NULL_IF_CONFIG_SMALL("Mimic"), };