X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmsvideo1.c;h=cfd51cfd672cb7fc4425961c39d6036e288c4be0;hb=ef6a9e5e311f09fa8032974fa4d0c1e166a959bb;hp=29700f54b66e9829729f3a6630298dcd7f44e32a;hpb=3bbec8e7c20b0f8b7b85a173bd006a76bb0c2601;p=ffmpeg diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index 29700f54b66..cfd51cfd672 100644 --- a/libavcodec/msvideo1.c +++ b/libavcodec/msvideo1.c @@ -33,6 +33,7 @@ #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "decode.h" #include "internal.h" #define PALETTE_COUNT 256 @@ -62,6 +63,9 @@ static av_cold int msvideo1_decode_init(AVCodecContext *avctx) s->avctx = avctx; + if (avctx->width < 4 || avctx->height < 4) + return AVERROR_INVALIDDATA; + /* figure out the colorspace based on the presence of a palette */ if (s->avctx->bits_per_coded_sample == 8) { s->mode_8bit = 1; @@ -307,19 +311,11 @@ static int msvideo1_decode_frame(AVCodecContext *avctx, 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 (s->mode_8bit) { - int size; - const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &size); - - if (pal && size == AVPALETTE_SIZE) { - memcpy(s->pal, pal, AVPALETTE_SIZE); - s->frame->palette_has_changed = 1; - } 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); } if (s->mode_8bit)