]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpjpegdec: ensure seekback for latest chunk
authorMoritz Barsnick <barsnick@gmx.net>
Sun, 6 Oct 2019 22:19:30 +0000 (00:19 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 12 Oct 2019 11:21:50 +0000 (13:21 +0200)
Not only the first, but each latest chunk must be cached to allow
seekback after finding the mime boundary.

Fixes trac #5023 and #5921.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mpjpegdec.c

index 24bf232db27d06c4f6d6de201b7e21527d5f9fc2..c79a39c69d1d0ef427c5fb0daae6b638d8cf18d9 100644 (file)
@@ -336,10 +336,8 @@ static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
         pkt->size = 0;
         pkt->pos  = avio_tell(s->pb);
 
-        /* we may need to return as much as all we've read back to the buffer */
-        ffio_ensure_seekback(s->pb, read_chunk);
-
-        while ((ret = av_append_packet(s->pb, pkt, read_chunk - remaining)) >= 0) {
+        while ((ret = ffio_ensure_seekback(s->pb, read_chunk - remaining)) >= 0 && /* we may need to return as much as all we've read back to the buffer */
+               (ret = av_append_packet(s->pb, pkt, read_chunk - remaining)) >= 0) {
             /* scan the new data */
             char *start;