[FFmpeg-cvslog] avformat/mov: Do not hard fail if bit rate calculation overflows unless in explode mode

Derek Buitenhuis git at videolan.org
Thu Oct 21 16:35:31 EEST 2021


ffmpeg | branch: master | Derek Buitenhuis <derek.buitenhuis at gmail.com> | Tue Oct 12 14:48:31 2021 +0100| [7216458c96a7635af5ae7428fdcad6c81ba870d7] | committer: Derek Buitenhuis

avformat/mov: Do not hard fail if bit rate calculation overflows unless in explode mode

bit_rate is not a critical field, and we shouln't hard fail if we
can't caluclate it due to a large timebase - it needlessly breaks
valid files.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7216458c96a7635af5ae7428fdcad6c81ba870d7
---

 libavformat/mov.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 841818b547..263d605c41 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7992,10 +7992,11 @@ static int mov_read_header(AVFormatContext *s)
                 /* Akin to sc->data_size * 8 * sc->time_scale / st->duration but accounting for overflows. */
                 st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) sc->time_scale) * 8, st->duration);
                 if (st->codecpar->bit_rate == INT64_MIN) {
-                    av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
+                    av_log(s, AV_LOG_WARNING, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
                            sc->data_size, sc->time_scale);
                     st->codecpar->bit_rate = 0;
-                    return AVERROR_INVALIDDATA;
+                    if (s->error_recognition & AV_EF_EXPLODE)
+                        return AVERROR_INVALIDDATA;
                 }
             }
         }
@@ -8009,10 +8010,11 @@ static int mov_read_header(AVFormatContext *s)
                 /* Akin to sc->data_size * 8 * sc->time_scale / sc->duration_for_fps but accounting for overflows. */
                 st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) sc->time_scale) * 8, sc->duration_for_fps);
                 if (st->codecpar->bit_rate == INT64_MIN) {
-                    av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
+                    av_log(s, AV_LOG_WARNING, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
                            sc->data_size, sc->time_scale);
                     st->codecpar->bit_rate = 0;
-                    return AVERROR_INVALIDDATA;
+                    if (s->error_recognition & AV_EF_EXPLODE)
+                        return AVERROR_INVALIDDATA;
                 }
             }
         }



More information about the ffmpeg-cvslog mailing list