mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
mp->vpt = av_mallocz_array(avctx->height, sizeof(YuvPixel));
mp->hpt = av_mallocz_array(h4 / 4, w4 / 4 * sizeof(YuvPixel));
- if (!mp->changes_map || !mp->vpt || !mp->hpt) {
- av_freep(&mp->changes_map);
- av_freep(&mp->vpt);
- av_freep(&mp->hpt);
+ if (!mp->changes_map || !mp->vpt || !mp->hpt)
return AVERROR(ENOMEM);
- }
avctx->pix_fmt = AV_PIX_FMT_RGB555;
mp->frame = av_frame_alloc();
- if (!mp->frame) {
- mp_decode_end(avctx);
+ if (!mp->frame)
return AVERROR(ENOMEM);
- }
return 0;
}
return 0;
}
-static int mp_gradient(MotionPixelsContext *mp, int component, int v)
+static av_always_inline int mp_gradient(MotionPixelsContext *mp, int component, int v)
{
int delta;
*(uint16_t *)&mp->frame->data[0][y * mp->frame->linesize[0] + x * 2] = color;
}
-static int mp_get_vlc(MotionPixelsContext *mp, GetBitContext *gb)
+static av_always_inline int mp_get_vlc(MotionPixelsContext *mp, GetBitContext *gb)
{
int i;
i = (mp->codes_count == 1) ? 0 : get_vlc2(gb, mp->vlc.table, mp->max_codes_bits, 1);
+ if (i < 0)
+ return i;
return mp->codes[i].delta;
}
GetBitContext gb;
int i, count1, count2, sz, ret;
- if ((ret = ff_reget_buffer(avctx, mp->frame)) < 0)
+ if ((ret = ff_reget_buffer(avctx, mp->frame, 0)) < 0)
return ret;
/* le32 bitstream msb first */
.close = mp_decode_end,
.decode = mp_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};