aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoritz Barsnick <barsnick@gmx.net>2019-10-07 00:19:30 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-10-12 13:21:50 +0200
commitf76a899abc80512959ec7deab25bc9642c4feb73 (patch)
tree8bf174efb9b0287db2c9c9bee0d76bb7d5355a1e
parent1ea44a55fe36c92420cba3542de256a1507f52fe (diff)
downloadffmpeg-f76a899abc80512959ec7deab25bc9642c4feb73.tar.gz
avformat/mpjpegdec: ensure seekback for latest chunk
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>
-rw-r--r--libavformat/mpjpegdec.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index 24bf232db2..c79a39c69d 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -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;