X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmotionpixels.c;h=b48200b017953c030a9ffeed798a3deb013d920e;hb=101ac40f69c51605347fa2b7f5c76481592acd28;hp=a88b837b3ef7ab980a44d88b4c1fea611011f948;hpb=ce265b0bf5d0c77a092a1f5fbeb652c7cdea5fc7;p=ffmpeg diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index a88b837b3ef..b48200b0179 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -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, };