[FFmpeg-devel] [PATCH 1/2] avformat/mov: Use av_rescale when calculating bit rate
Michael Niedermayer
michael at niedermayer.cc
Wed Oct 20 21:30:46 EEST 2021
On Wed, Oct 20, 2021 at 03:03:53PM +0100, Derek Buitenhuis wrote:
> It is less susceptible to overflows.
>
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
> libavformat/mov.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 57c67e3aac..431f430368 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7989,12 +7989,14 @@ static int mov_read_header(AVFormatContext *s)
> AVStream *st = s->streams[i];
> MOVStreamContext *sc = st->priv_data;
> if (st->duration > 0) {
> - if (sc->data_size > INT64_MAX / sc->time_scale / 8) {
> + /* Akin to sc->data_size * 8 * sc->time_scale / st->duration but accounting for overflows. */
> + st->codecpar->bit_rate = av_rescale(sc->data_size, sc->time_scale * 8, st->duration);
Does something ensure time_scale * 8 fits in int ? if not this needs a cast to *int64_t
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Republics decline into democracies and democracies degenerate into
despotisms. -- 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/20211020/d6393906/attachment.sig>
More information about the ffmpeg-devel
mailing list