X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmsrle.c;h=42c8f483730d02d0f9d2e940fbb8c12e1eb9db3e;hb=0181162bb54ce62ec212436a12d059726d8cd1df;hp=1ab8a419851f82ffc8c3f4ae765ff77839590cf9;hpb=94346ab593f3fc0822f11d3e3f378f9944ad2d40;p=ffmpeg diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index 1ab8a419851..42c8f483730 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -33,6 +33,7 @@ #include #include "avcodec.h" +#include "decode.h" #include "internal.h" #include "msrledec.h" #include "libavutil/imgutils.h" @@ -42,8 +43,6 @@ typedef struct MsrleContext { AVFrame *frame; GetByteContext gb; - const unsigned char *buf; - int size; uint32_t pal[256]; } MsrleContext; @@ -92,25 +91,15 @@ static int msrle_decode_frame(AVCodecContext *avctx, int istride = FFALIGN(avctx->width*avctx->bits_per_coded_sample, 32) / 8; int ret; - s->buf = buf; - s->size = buf_size; - if (buf_size < 2) //Minimally a end of picture code should be there return AVERROR_INVALIDDATA; - if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) + if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) return ret; if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) { - int size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); - - if (pal && size == AVPALETTE_SIZE) { - s->frame->palette_has_changed = 1; - memcpy(s->pal, pal, AVPALETTE_SIZE); - } else if (pal) { - av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size); - } + s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx); + /* make the palette available */ memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE); } @@ -153,6 +142,13 @@ static int msrle_decode_frame(AVCodecContext *avctx, return buf_size; } +static void msrle_decode_flush(AVCodecContext *avctx) +{ + MsrleContext *s = avctx->priv_data; + + av_frame_unref(s->frame); +} + static av_cold int msrle_decode_end(AVCodecContext *avctx) { MsrleContext *s = avctx->priv_data; @@ -172,5 +168,6 @@ AVCodec ff_msrle_decoder = { .init = msrle_decode_init, .close = msrle_decode_end, .decode = msrle_decode_frame, + .flush = msrle_decode_flush, .capabilities = AV_CODEC_CAP_DR1, };