]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/motionpixels.c
avformat/argo_asf: fix enforcement of chunk count
[ffmpeg] / libavcodec / motionpixels.c
index a88b837b3ef7ab980a44d88b4c1fea611011f948..b48200b017953c030a9ffeed798a3deb013d920e 100644 (file)
@@ -81,19 +81,13 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
     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;
 }
@@ -171,7 +165,7 @@ static int mp_read_codes_table(MotionPixelsContext *mp, GetBitContext *gb)
    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;
 
@@ -196,11 +190,13 @@ static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const Yuv
     *(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;
 }
 
@@ -290,7 +286,7 @@ static int mp_decode_frame(AVCodecContext *avctx,
     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 */
@@ -352,4 +348,5 @@ AVCodec ff_motionpixels_decoder = {
     .close          = mp_decode_end,
     .decode         = mp_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };