]> granicus.if.org Git - libvpx/commitdiff
Cleaning up vp9_rc_compute_frame_size_bounds().
authorDmitry Kovalev <dkovalev@google.com>
Thu, 10 Apr 2014 18:44:35 +0000 (11:44 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Thu, 10 Apr 2014 18:44:35 +0000 (11:44 -0700)
Change-Id: Ibc040bee99908e4dc5793d7a9f6e8bf2d15610e7

vp9/encoder/vp9_ratectrl.c

index b4e883fb58bc9cc1d076dfc95ea9bd7dbbb6b74f..9044e5b71b830771536c49181c6b4551c4d6a0b8 100644 (file)
@@ -987,31 +987,19 @@ int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi,
 }
 
 void vp9_rc_compute_frame_size_bounds(const VP9_COMP *cpi,
-                                      int this_frame_target,
+                                      int frame_target,
                                       int *frame_under_shoot_limit,
                                       int *frame_over_shoot_limit) {
-  // Set-up bounds on acceptable frame size:
   if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
     *frame_under_shoot_limit = 0;
     *frame_over_shoot_limit  = INT_MAX;
   } else {
-    int recode_tolerance =
-      (cpi->sf.recode_tolerance * this_frame_target) / 100;
-
-    *frame_over_shoot_limit = this_frame_target + recode_tolerance;
-    *frame_under_shoot_limit = this_frame_target - recode_tolerance;
-
     // For very small rate targets where the fractional adjustment
     // may be tiny make sure there is at least a minimum range.
-    *frame_over_shoot_limit += 200;
-    *frame_under_shoot_limit -= 200;
-    if (*frame_under_shoot_limit < 0)
-      *frame_under_shoot_limit = 0;
-
-    // Clip to maximum allowed rate for a frame.
-    if (*frame_over_shoot_limit > cpi->rc.max_frame_bandwidth) {
-      *frame_over_shoot_limit = cpi->rc.max_frame_bandwidth;
-    }
+    const int tolerance = (cpi->sf.recode_tolerance * frame_target) / 100;
+    *frame_under_shoot_limit = MAX(frame_target - tolerance - 200, 0);
+    *frame_over_shoot_limit = MIN(frame_target + tolerance + 200,
+                                  cpi->rc.max_frame_bandwidth);
   }
 }