summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-05-22 19:26:39 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-05-22 19:26:39 -0700
commitd1ad3b678b5b5542122340d4b5db33c95fc1f858 (patch)
tree19bed131eb4f3f341376e2eb211e9117c62298a5 /vp9/encoder/vp9_firstpass.c
parent8a571170a20373286328cfeec92b57fc129d26da (diff)
parent0a6e42c241ba96448dbe57665f254c8c24430c8c (diff)
downloadlibvpx-d1ad3b678b5b5542122340d4b5db33c95fc1f858.tar
libvpx-d1ad3b678b5b5542122340d4b5db33c95fc1f858.tar.gz
libvpx-d1ad3b678b5b5542122340d4b5db33c95fc1f858.tar.bz2
libvpx-d1ad3b678b5b5542122340d4b5db33c95fc1f858.zip
Merge "Adding several consts to assign_std_frame_bits()."
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r--vp9/encoder/vp9_firstpass.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index a5f9f9a1c..247e5eeb5 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1757,23 +1757,14 @@ static void assign_std_frame_bits(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
const int max_bits = frame_max_bits(&cpi->rc, oxcf);
// Calculate modified prediction error used in bit allocation.
const double modified_err = calculate_modified_err(twopass, oxcf, this_frame);
- int target_frame_size;
- double err_fraction;
-
- if (twopass->gf_group_error_left > 0)
- // What portion of the remaining GF group error is used by this frame.
- err_fraction = modified_err / twopass->gf_group_error_left;
- else
- err_fraction = 0.0;
-
- // How many of those bits available for allocation should we give it?
- target_frame_size = (int)((double)twopass->gf_group_bits * err_fraction);
-
- // Clip target size to 0 - max_bits (or cpi->twopass.gf_group_bits) at
- // the top end.
- target_frame_size = clamp(target_frame_size, 0,
- MIN(max_bits, (int)twopass->gf_group_bits));
-
+ // What portion of the remaining GF group error is used by this frame.
+ const double err_fraction = twopass->gf_group_error_left > 0 ?
+ modified_err / twopass->gf_group_error_left : 0.0;
+ // How many of those bits available for allocation should we give it? Clip
+ // target size to 0 - max_bits (or cpi->twopass.gf_group_bits) at the top end.
+ const int target_frame_size =
+ clamp((int)(twopass->gf_group_bits * err_fraction),
+ 0, MIN(max_bits, (int)twopass->gf_group_bits));
// Adjust error and bits remaining.
twopass->gf_group_error_left -= (int64_t)modified_err;