[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 19 21:28:35 EEST 2021

On Mon, Oct 18, 2021 at 02:24:08PM +0100, Derek Buitenhuis wrote:
> Hi,
> Sorry for the slow reply.
> On 10/12/2021 8:18 PM, Michael Niedermayer wrote:
> > 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
> It's unclear to me from reading the code of av_rescale what happens if
> the return value is not representative as an int64_t, for example:
> av_rescale(INT64_MAX/2, INT64_MAX/2, 1);
> I don't think we can even check this usng only av_rescale without
> explicit checks before calling it?

av_rescale() should return INT64_MIN on overflows



Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- 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/20211019/ee00afda/attachment.sig>

More information about the ffmpeg-devel mailing list