[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 22:18:08 EEST 2021


On Tue, Oct 12, 2021 at 04:17:31PM +0100, Derek Buitenhuis wrote:
> On 10/12/2021 3:43 PM, Michael Niedermayer wrote:
> > this should be using av_rescale() i think
> 
> That seems unrelated to this patch - but I can send a second patch
> that does that, if you want.
> 
> Is your intent something like this;
> 
>     if (sc->data_size > INT64_MAX / 8) {
>         av_log(s, AV_LOG_WARNING, "Overflow during bit rate calculation %"PRId64" * 8 > INT64_MAX\n",
>                sc->data_size);
>         if (s->error_recognition & AV_EF_EXPLODE)
>             return AVERROR_INVALIDDATA;
>     } else
>         st->codecpar->bit_rate = av_rescale(sc->data_size * 8, c->time_scale, st->duration);

i was thinking of something like
st->codecpar->bit_rate = av_rescale(sc->data_size, c->time_scale * 8LL, st->duration);

because i thought that would fix the overflow
but i didnt look beyond the code in this patch
this may still require some check so the value fits in bit_rate, i didnt
investigate that

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- 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/be7b5a10/attachment.sig>


More information about the ffmpeg-devel mailing list