diff mbox series

[FFmpeg-devel] avcodec/libx265: Fix integer overflow in computation of max and avg bitrate

Message ID 1591628558-23484-1-git-send-email-lance.lmwang@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel] avcodec/libx265: Fix integer overflow in computation of max and avg bitrate | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Lance Wang June 8, 2020, 3:02 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/libx265.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lance Wang June 15, 2020, 2:29 p.m. UTC | #1
On Mon, Jun 08, 2020 at 11:02:38PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/libx265.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index f560d7f62f..686c205b6b 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -310,8 +310,8 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
>      if (!cpb_props)
>          return AVERROR(ENOMEM);
>      cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000;
> -    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000;
> -    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000;
> +    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000LL;
> +    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000LL;
>  
>      if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
>          ctx->params->bRepeatHeaders = 1;
> -- 
> 2.21.0
> 

ping for review.
Lance Wang June 18, 2020, 4:34 a.m. UTC | #2
On Mon, Jun 08, 2020 at 11:02:38PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/libx265.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index f560d7f62f..686c205b6b 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -310,8 +310,8 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
>      if (!cpb_props)
>          return AVERROR(ENOMEM);
>      cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000;
> -    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000;
> -    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000;
> +    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000LL;
> +    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000LL;
>  
>      if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
>          ctx->params->bRepeatHeaders = 1;
> -- 
> 2.21.0
> 

will apply tomorrow if no objection.
diff mbox series

Patch

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index f560d7f62f..686c205b6b 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -310,8 +310,8 @@  static av_cold int libx265_encode_init(AVCodecContext *avctx)
     if (!cpb_props)
         return AVERROR(ENOMEM);
     cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000;
-    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000;
-    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000;
+    cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000LL;
+    cpb_props->avg_bitrate = ctx->params->rc.bitrate       * 1000LL;
 
     if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER))
         ctx->params->bRepeatHeaders = 1;