#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
+#include "decode.h"
#include "internal.h"
#define PALETTE_COUNT 256
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;
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)
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,