]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xl.c
mov_chan: Pass a separate AVIOContext for reading
[ffmpeg] / libavcodec / xl.c
index 197b0c24a277a128ca54c378ae178f00e6d49609..7ba24132214ef8ec128d2322358f032c7f989455 100644 (file)
@@ -24,6 +24,7 @@
  * Miro VideoXL codec.
  */
 
+#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 
@@ -45,7 +46,7 @@ static int decode_frame(AVCodecContext *avctx,
     const uint8_t *buf = avpkt->data;
     int buf_size = avpkt->size;
     VideoXLContext * const a = avctx->priv_data;
-    AVFrame * const p= (AVFrame*)&a->pic;
+    AVFrame * const p = &a->pic;
     uint8_t *Y, *U, *V;
     int i, j;
     int stride;
@@ -68,6 +69,12 @@ static int decode_frame(AVCodecContext *avctx,
     V = a->pic.data[2];
 
     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;
@@ -141,11 +148,11 @@ static av_cold int decode_end(AVCodecContext *avctx){
 AVCodec ff_xl_decoder = {
     .name           = "xl",
     .type           = AVMEDIA_TYPE_VIDEO,
-    .id             = CODEC_ID_VIXL,
+    .id             = AV_CODEC_ID_VIXL,
     .priv_data_size = sizeof(VideoXLContext),
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
     .capabilities   = CODEC_CAP_DR1,
-    .long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"),
+    .long_name      = NULL_IF_CONFIG_SMALL("Miro VideoXL"),
 };