Commit 42a89eb8 authored by Adrian Grange's avatar Adrian Grange
Browse files

Clamp rate correction factor after scaling it

Added clamp on the rate correction factor after
it has been scaled.

Change-Id: I5d4b46a101987b43c5bcfd7e0bd1b7b4d53640a4
parent 78df7122
...@@ -377,7 +377,7 @@ static double get_rate_correction_factor(const VP9_COMP *cpi) { ...@@ -377,7 +377,7 @@ static double get_rate_correction_factor(const VP9_COMP *cpi) {
rcf = rc->rate_correction_factors[INTER_NORMAL]; rcf = rc->rate_correction_factors[INTER_NORMAL];
} }
rcf *= rcf_mult[rc->frame_size_selector]; rcf *= rcf_mult[rc->frame_size_selector];
return rcf > MAX_BPB_FACTOR ? MAX_BPB_FACTOR : rcf; return fclamp(rcf, MIN_BPB_FACTOR, MAX_BPB_FACTOR);
} }
static void set_rate_correction_factor(VP9_COMP *cpi, double factor) { static void set_rate_correction_factor(VP9_COMP *cpi, double factor) {
...@@ -386,6 +386,8 @@ static void set_rate_correction_factor(VP9_COMP *cpi, double factor) { ...@@ -386,6 +386,8 @@ static void set_rate_correction_factor(VP9_COMP *cpi, double factor) {
// Normalize RCF to account for the size-dependent scaling factor. // Normalize RCF to account for the size-dependent scaling factor.
factor /= rcf_mult[cpi->rc.frame_size_selector]; factor /= rcf_mult[cpi->rc.frame_size_selector];
factor = fclamp(factor, MIN_BPB_FACTOR, MAX_BPB_FACTOR);
if (cpi->common.frame_type == KEY_FRAME) { if (cpi->common.frame_type == KEY_FRAME) {
rc->rate_correction_factors[KF_STD] = factor; rc->rate_correction_factors[KF_STD] = factor;
} else if (cpi->oxcf.pass == 2) { } else if (cpi->oxcf.pass == 2) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment