calc_pframe_target_size: fix integer overflow
authorXiahong Bao <xiahong.bao@nxp.com>
Fri, 27 Oct 2023 23:52:04 +0000 (08:52 +0900)
committerXiahong Bao <xiahong.bao@nxp.com>
Mon, 30 Oct 2023 02:17:17 +0000 (11:17 +0900)
The intermediate value in the target bandwidth
calculation may exceed integer bounds.

Bug: 308007926

Change-Id: I8288c5820db06a550d88bf91fccc86106996deaa
Signed-off-by: Xiahong Bao <xiahong.bao@nxp.com>
vp8/encoder/ratectrl.c

index 6f14322..fcd4eb0 100644 (file)
@@ -719,7 +719,8 @@ static void calc_pframe_target_size(VP8_COMP *cpi) {
         }
 
         /* lower the target bandwidth for this frame. */
-        cpi->this_frame_target -= (cpi->this_frame_target * percent_low) / 200;
+        cpi->this_frame_target -=
+            (int)(((int64_t)cpi->this_frame_target * percent_low) / 200);
 
         /* Are we using allowing control of active_worst_allowed_q
          * according to buffer level.