]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xl.c
avcodec options: add enum option for color_primaries
[ffmpeg] / libavcodec / xl.c
index 530a1bd2c22708b4207349ce0194d8815fa4a60f..8e9bdc66f60b6c13acd84b274542b85bd1904c4d 100644 (file)
@@ -49,6 +49,16 @@ static int decode_frame(AVCodecContext *avctx,
     uint32_t val;
     int y0, y1, y2, y3 = 0, c0 = 0, c1 = 0;
 
+    if (avctx->width % 4) {
+        av_log(avctx, AV_LOG_ERROR, "Width not a multiple of 4.\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (buf_size < avctx->width * avctx->height) {
+        av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;
@@ -62,11 +72,6 @@ static int decode_frame(AVCodecContext *avctx,
 
     stride = avctx->width - 4;
 
-    if (buf_size < avctx->width * avctx->height) {
-        av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
-        return AVERROR_INVALIDDATA;
-    }
-
     for (i = 0; i < avctx->height; i++) {
         /* lines are stored in reversed order */
         buf += stride;
@@ -127,10 +132,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 AVCodec ff_xl_decoder = {
     .name         = "xl",
+    .long_name    = NULL_IF_CONFIG_SMALL("Miro VideoXL"),
     .type         = AVMEDIA_TYPE_VIDEO,
     .id           = AV_CODEC_ID_VIXL,
     .init         = decode_init,
     .decode       = decode_frame,
     .capabilities = CODEC_CAP_DR1,
-    .long_name    = NULL_IF_CONFIG_SMALL("Miro VideoXL"),
 };