X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmsvideo1.c;h=99965b04a2cc02377ce97c566b334bdd20d801ae;hb=a247ac640df3da573cd661065bf53f37863e2b46;hp=29700f54b66e9829729f3a6630298dcd7f44e32a;hpb=0ff76ca86e0ea4dcf2b392c45f5fac8e5576bb0d;p=ffmpeg diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c index 29700f54b66..99965b04a2c 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) @@ -345,7 +341,7 @@ static av_cold int msvideo1_decode_end(AVCodecContext *avctx) return 0; } -AVCodec ff_msvideo1_decoder = { +const AVCodec ff_msvideo1_decoder = { .name = "msvideo1", .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video 1"), .type = AVMEDIA_TYPE_VIDEO,