aom: Use the saturate_cast_double_to_int() function

From 94c721b0024ee8d2bc580af891f5eef714b5f32c Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Thu, 8 Aug 2024 14:17:35 -0700
Subject: [PATCH] Use the saturate_cast_double_to_int() function

Just added in https://aomedia-review.googlesource.com/c/aom/+/192483.

Change-Id: I2c95a71402d2356a07cff17bbf2cd6ab8eff6c05
---
 av1/encoder/ratectrl.c | 5 ++---
 av1/ratectrl_rtc.cc    | 9 ++++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 320d98483..09129425d 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -3680,9 +3680,8 @@ void av1_get_one_pass_rt_params(AV1_COMP *cpi, FRAME_TYPE *const frame_type,
       LAYER_IDS_TO_IDX(svc->spatial_layer_id, svc->temporal_layer_id,
                        svc->number_temporal_layers);
   if (cpi->oxcf.rc_cfg.max_consec_drop_ms > 0) {
-    rc->max_consec_drop = (int)AOMMIN(
-        ceil(cpi->oxcf.rc_cfg.max_consec_drop_ms * cpi->framerate / 1000),
-        INT_MAX);
+    rc->max_consec_drop = saturate_cast_double_to_int(
+        ceil(cpi->oxcf.rc_cfg.max_consec_drop_ms * cpi->framerate / 1000));
   }
   if (cpi->ppi->use_svc) {
     av1_update_temporal_layer_framerate(cpi);
diff --git a/av1/ratectrl_rtc.cc b/av1/ratectrl_rtc.cc
index e0d896c81..7957d240f 100644
--- a/av1/ratectrl_rtc.cc
+++ b/av1/ratectrl_rtc.cc
@@ -11,7 +11,6 @@
 
 #include "av1/ratectrl_rtc.h"
 
-#include <climits>
 #include <memory>
 #include <new>
 
@@ -130,8 +129,8 @@ bool AV1RateControlRTC::InitRateControl(const AV1RateControlRtcConfig &rc_cfg) {
   oxcf->tune_cfg.content = AOM_CONTENT_DEFAULT;
   oxcf->rc_cfg.drop_frames_water_mark = rc_cfg.frame_drop_thresh;
   if (rc_cfg.max_consec_drop_ms > 0) {
-    rc->max_consec_drop = (int)AOMMIN(
-        ceil(cpi_->framerate * rc_cfg.max_consec_drop_ms / 1000), INT_MAX);
+    rc->max_consec_drop = saturate_cast_double_to_int(
+        ceil(cpi_->framerate * rc_cfg.max_consec_drop_ms / 1000));
   }
   cpi_->svc.framedrop_mode = AOM_FULL_SUPERFRAME_DROP;
   oxcf->tool_cfg.bit_depth = AOM_BITS_8;
@@ -196,8 +195,8 @@ bool AV1RateControlRTC::UpdateRateControl(
   oxcf->rc_cfg.over_shoot_pct = rc_cfg.overshoot_pct;
   oxcf->rc_cfg.drop_frames_water_mark = rc_cfg.frame_drop_thresh;
   if (rc_cfg.max_consec_drop_ms > 0) {
-    rc->max_consec_drop = (int)AOMMIN(
-        ceil(cpi_->framerate * rc_cfg.max_consec_drop_ms / 1000), INT_MAX);
+    rc->max_consec_drop = saturate_cast_double_to_int(
+        ceil(cpi_->framerate * rc_cfg.max_consec_drop_ms / 1000));
   }
   oxcf->rc_cfg.max_intra_bitrate_pct = rc_cfg.max_intra_bitrate_pct;
   oxcf->rc_cfg.max_inter_bitrate_pct = rc_cfg.max_inter_bitrate_pct;