summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r--vp9/encoder/vp9_firstpass.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 314f8ab84..3d4b96259 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1935,7 +1935,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Find the next keyframe.
i = 0;
- while (twopass->stats_in < twopass->stats_in_end) {
+ while (twopass->stats_in < twopass->stats_in_end &&
+ rc->frames_to_key < cpi->oxcf.key_freq) {
// Accumulate kf group error.
kf_group_err += calculate_modified_err(cpi, this_frame);
@@ -1965,7 +1966,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Special check for transition or high motion followed by a
// static scene.
- if (detect_transition_to_still(twopass, i, cpi->key_frame_frequency - i,
+ if (detect_transition_to_still(twopass, i, cpi->oxcf.key_freq - i,
loop_decay_rate, decay_accumulator))
break;
@@ -1973,8 +1974,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
++rc->frames_to_key;
// If we don't have a real key frame within the next two
- // key_frame_frequency intervals then break out of the loop.
- if (rc->frames_to_key >= 2 * (int)cpi->key_frame_frequency)
+ // key_freq intervals then break out of the loop.
+ if (rc->frames_to_key >= 2 * cpi->oxcf.key_freq)
break;
} else {
++rc->frames_to_key;
@@ -1987,7 +1988,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// This code centers the extra kf if the actual natural interval
// is between 1x and 2x.
if (cpi->oxcf.auto_key &&
- rc->frames_to_key > (int)cpi->key_frame_frequency) {
+ rc->frames_to_key > cpi->oxcf.key_freq) {
FIRSTPASS_STATS tmp_frame = first_frame;
rc->frames_to_key /= 2;
@@ -2003,7 +2004,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
input_stats(twopass, &tmp_frame);
}
rc->next_key_frame_forced = 1;
- } else if (twopass->stats_in == twopass->stats_in_end) {
+ } else if (twopass->stats_in == twopass->stats_in_end ||
+ rc->frames_to_key >= cpi->oxcf.key_freq) {
rc->next_key_frame_forced = 1;
} else {
rc->next_key_frame_forced = 0;