[FFmpeg-devel] [PATCH v1] avcodec/utils: use av_rescale()
Michael Niedermayer
michael at niedermayer.cc
Wed Apr 22 00:05:59 EEST 2020
On Mon, Apr 20, 2020 at 07:00:55PM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
> libavcodec/utils.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 26c038dfd9..005d596dfd 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2229,8 +2229,8 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
> bits_per_coded_sample = av_get_bits_per_pixel(desc);
> }
> - bitrate = (int64_t)bits_per_coded_sample * avctx->width * avctx->height *
> - framerate.num / framerate.den;
> + bitrate = av_rescale(avctx->width * avctx->height,
> + bits_per_coded_sample * framerate.num, framerate.den);
why this change ?
also
bits_per_coded_sample * framerate.num
could possibly overflow after this i think
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Nations do behave wisely once they have exhausted all other alternatives.
-- Abba Eban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200421/5b067057/attachment.sig>
More information about the ffmpeg-devel
mailing list