]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/indeo2.c
rv40: NEON optimised chroma MC
[ffmpeg] / libavcodec / indeo2.c
index 0e588c39662538d2171232cccbf6c641170ebc47..398a9acd9233e94bd3920470ff011db12cb3eaff 100644 (file)
@@ -156,6 +156,13 @@ static int ir2_decode_frame(AVCodecContext *avctx,
         return -1;
     }
 
+    start = 48; /* hardcoded for now */
+
+    if (start >= buf_size) {
+        av_log(s->avctx, AV_LOG_ERROR, "input buffer size too small (%d)\n", buf_size);
+        return AVERROR_INVALIDDATA;
+    }
+
     s->decode_delta = buf[18];
 
     /* decide whether frame uses deltas or not */
@@ -163,9 +170,8 @@ static int ir2_decode_frame(AVCodecContext *avctx,
     for (i = 0; i < buf_size; i++)
         buf[i] = av_reverse[buf[i]];
 #endif
-    start = 48; /* hardcoded for now */
 
-    init_get_bits(&s->gb, buf + start, buf_size - start);
+    init_get_bits(&s->gb, buf + start, (buf_size - start) * 8);
 
     if (s->decode_delta) { /* intraframe */
         ir2_decode_plane(s, avctx->width, avctx->height,
@@ -225,14 +231,13 @@ static av_cold int ir2_decode_end(AVCodecContext *avctx){
 }
 
 AVCodec ff_indeo2_decoder = {
-    "indeo2",
-    AVMEDIA_TYPE_VIDEO,
-    CODEC_ID_INDEO2,
-    sizeof(Ir2Context),
-    ir2_decode_init,
-    NULL,
-    ir2_decode_end,
-    ir2_decode_frame,
-    CODEC_CAP_DR1,
+    .name           = "indeo2",
+    .type           = AVMEDIA_TYPE_VIDEO,
+    .id             = CODEC_ID_INDEO2,
+    .priv_data_size = sizeof(Ir2Context),
+    .init           = ir2_decode_init,
+    .close          = ir2_decode_end,
+    .decode         = ir2_decode_frame,
+    .capabilities   = CODEC_CAP_DR1,
     .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"),
 };