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

Derek Buitenhuis derek.buitenhuis at gmail.com
Mon Oct 18 16:24:08 EEST 2021


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?

- Derek

More information about the ffmpeg-devel mailing list