]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/smvjpegdec.c
tests/audio_fifo: fix buffer allocation for non planar formats
[ffmpeg] / libavcodec / smvjpegdec.c
index 9057e86161c9b4ba07278b867d46229534ada2fc..018e135b30010f49b6a0240c6ed445046d2ed2ce 100644 (file)
@@ -152,6 +152,10 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
 
     cur_frame = avpkt->pts % s->frames_per_jpeg;
 
+    /* cur_frame is later used to calculate the buffer offset, so it mustn't be negative */
+    if (cur_frame < 0)
+        cur_frame += s->frames_per_jpeg;
+
     /* Are we at the start of a block? */
     if (!cur_frame) {
         av_frame_unref(mjpeg_data);
@@ -196,9 +200,11 @@ static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_siz
             s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
 
         ret = av_frame_ref(data, s->picture[1]);
+        if (ret < 0)
+            return ret;
     }
 
-    return ret;
+    return avpkt->size;
 }
 
 static const AVClass smvjpegdec_class = {