[FFmpeg-devel] [PATCH] avformat/mov: Do not hard fail if bit rate calculation overflows unless in explode mode
Michael Niedermayer
michael at niedermayer.cc
Tue Oct 12 17:43:03 EEST 2021
On Tue, Oct 12, 2021 at 02:50:40PM +0100, Derek Buitenhuis wrote:
> 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>
> ---
> libavformat/mov.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d0b8b2595b..99d10c2b33 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7666,11 +7666,12 @@ static int mov_read_header(AVFormatContext *s)
> MOVStreamContext *sc = st->priv_data;
> if (st->duration > 0) {
> if (sc->data_size > INT64_MAX / sc->time_scale / 8) {
> - 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);
> - return AVERROR_INVALIDDATA;
> - }
> - st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
> + if (s->error_recognition & AV_EF_EXPLODE)
> + return AVERROR_INVALIDDATA;
> + } else
> + st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
> }
this should be using av_rescale() i think
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211012/1f9b9afa/attachment.sig>
More information about the ffmpeg-devel
mailing list