From 4ed5ac50d3e4f921003ecf60985f78337400f354 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Fri, 14 Sep 2012 17:01:35 +0200 Subject: [PATCH 1/4] file: return proper error on seek failures --- libavformat/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 3ea681fd9f..fc0af92277 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -121,12 +121,18 @@ static int file_open(URLContext *h, const char *filename, int flags) static int64_t file_seek(URLContext *h, int64_t pos, int whence) { FileContext *c = h->priv_data; + int ret; + if (whence == AVSEEK_SIZE) { struct stat st; - int ret = fstat(c->fd, &st); + + ret = fstat(c->fd, &st); return ret < 0 ? AVERROR(errno) : st.st_size; } - return lseek(c->fd, pos, whence); + + ret = lseek(c->fd, pos, whence); + + return ret < 0 ? AVERROR(errno) : ret; } static int file_close(URLContext *h) From 9db67bedf0e517c19dad02db1752a5dfb52eaa69 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 18 Dec 2011 21:37:54 +0100 Subject: [PATCH 2/4] mov: detect EOF in mov_read_dref() Avoid a near infinite loop. Issue discovered by cosminamironesei. Signed-off-by: Michael Niedermayer Signed-off-by: Luca Barbato --- libavformat/mov.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 640377a134..09228cb011 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -416,6 +416,8 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_skip(pb, 16); for (type = 0; type != -1 && avio_tell(pb) < next; ) { + if (pb->eof_reached) + return AVERROR_EOF; type = avio_rb16(pb); len = avio_rb16(pb); av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len); From a5ea623b364b8a605fc92c973a98cd66cb7e6a5d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 15 Dec 2011 20:51:00 +0100 Subject: [PATCH 3/4] mov: stsd entries must be at least 16 byte Fix near infinite loop in stsd parsing. Bug found by: Diana Elena Muscalu The size is unsigned according the specification. Signed-off-by: Michael Niedermayer Signed-off-by: Luca Barbato --- libavformat/mov.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 09228cb011..87c890ebfc 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1098,13 +1098,16 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) int dref_id = 1; MOVAtom a = { AV_RL32("stsd") }; int64_t start_pos = avio_tell(pb); - int size = avio_rb32(pb); /* size */ + uint32_t size = avio_rb32(pb); /* size */ uint32_t format = avio_rl32(pb); /* data format */ if (size >= 16) { avio_rb32(pb); /* reserved */ avio_rb16(pb); /* reserved */ dref_id = avio_rb16(pb); + } else { + av_log(c->fc, AV_LOG_ERROR, "invalid size %d in stsd\n", size); + return AVERROR_INVALIDDATA; } if (st->codec->codec_tag && From 2f34021d57b1343bb01b377a4797bef7cbc7be3c Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Thu, 6 Sep 2012 21:51:31 +0200 Subject: [PATCH 4/4] avconv: flush filtered frames before reconfiguring filters This prevents lost frames after a resolution change. --- avconv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/avconv.c b/avconv.c index ea736066ec..df09b21c78 100644 --- a/avconv.c +++ b/avconv.c @@ -1245,6 +1245,10 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) ist->resample_width, ist->resample_height, av_get_pix_fmt_name(ist->resample_pix_fmt), decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format)); + ret = poll_filters(); + if (ret < 0 && (ret != AVERROR_EOF && ret != AVERROR(EAGAIN))) + av_log(NULL, AV_LOG_ERROR, "Error while filtering.\n"); + ist->resample_width = decoded_frame->width; ist->resample_height = decoded_frame->height; ist->resample_pix_fmt = decoded_frame->format;