summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-01-13 16:27:50 -0800
committerDmitry Kovalev <dkovalev@google.com>2014-01-13 16:27:50 -0800
commit46a951c846a1f7db5308cfc8ea1c2eaffc391b9d (patch)
treeb50df0582c2a8eddf11ded85e304f57d646841dd
parentdd31f2e4ae480f074841e0653dff91ccda9df091 (diff)
downloadlibvpx-46a951c846a1f7db5308cfc8ea1c2eaffc391b9d.tar
libvpx-46a951c846a1f7db5308cfc8ea1c2eaffc391b9d.tar.gz
libvpx-46a951c846a1f7db5308cfc8ea1c2eaffc391b9d.tar.bz2
libvpx-46a951c846a1f7db5308cfc8ea1c2eaffc391b9d.zip
Using clamp() function instead of the same raw code.
Change-Id: Ia2ffca072f5391b277ce1a0c4e5b4ece9ffc6831
-rw-r--r--vp9/encoder/vp9_firstpass.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 812ffa96d..2bd7dbe3b 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1932,12 +1932,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Allocate bits to a normal frame that is neither a gf an arf or a key frame.
static void assign_std_frame_bits(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
int target_frame_size;
-
double modified_err;
double err_fraction;
-
- // Max for a single frame.
- int max_bits = frame_max_bits(cpi);
+ const int max_bits = frame_max_bits(cpi); // Max for a single frame.
// Calculate modified prediction error used in bit allocation.
modified_err = calculate_modified_err(cpi, this_frame);
@@ -1953,15 +1950,8 @@ static void assign_std_frame_bits(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Clip target size to 0 - max_bits (or cpi->twopass.gf_group_bits) at
// the top end.
- if (target_frame_size < 0) {
- target_frame_size = 0;
- } else {
- if (target_frame_size > max_bits)
- target_frame_size = max_bits;
-
- if (target_frame_size > cpi->twopass.gf_group_bits)
- target_frame_size = (int)cpi->twopass.gf_group_bits;
- }
+ target_frame_size = clamp(target_frame_size, 0,
+ MIN(max_bits, (int)cpi->twopass.gf_group_bits));
// Adjust error and bits remaining.
cpi->twopass.gf_group_error_left -= (int64_t)modified_err;