Since the while loop's condition already check rc->frames_to_key < cpi->oxcf.key_freq, it impossible to have "frames_to_key >= 2 * cpi->oxcf.key_freq" and "frames_to_key > cpi->oxcf.key_freq". Hence, these logics are removed.
Unified · Split
| @@ -3061,7 +3061,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 3060 unmodified lines | ||
| 3061 | 3061 | TWO_PASS *const twopass = &cpi->twopass; |
| 3062 | 3062 | GF_GROUP *const gf_group = &twopass->gf_group; |
| 3063 | 3063 | const VP9EncoderConfig *const oxcf = &cpi->oxcf; |
| 3064 | − const FIRSTPASS_STATS first_frame = *this_frame; | |
| 3065 | 3064 | const FIRSTPASS_STATS *const start_position = twopass->stats_in; |
| 3066 | 3065 | FIRSTPASS_STATS next_frame; |
| 3067 | 3066 | FIRSTPASS_STATS last_frame; |
| @@ -3153,14 +3152,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 85 unmodified lines | ||
| 3153 | 3152 | break; |
| 3154 | 3153 | |
| 3155 | 3154 | // Step on to the next frame. |
| 3156 | − ++rc->frames_to_key; | |
| 3157 | − | |
| 3158 | − // If we don't have a real key frame within the next two | |
| 3159 | − // key_freq intervals then break out of the loop. | |
| 3160 | − if (rc->frames_to_key >= 2 * cpi->oxcf.key_freq) break; | |
| 3161 | − } else { | |
| 3162 | − ++rc->frames_to_key; | |
| 3163 | 3155 | } |
| 3156 | + ++rc->frames_to_key; | |
| 3164 | 3157 | ++i; |
| 3165 | 3158 | } |
| 3166 | 3159 | |
| @@ -3168,25 +3161,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 1 unmodified line | ||
| 3168 | 3161 | // We already breakout of the loop above at 2x max. |
| 3169 | 3162 | // This code centers the extra kf if the actual natural interval |
| 3170 | 3163 | // is between 1x and 2x. |
| 3171 | − if (cpi->oxcf.auto_key && rc->frames_to_key > cpi->oxcf.key_freq) { | |
| 3172 | − FIRSTPASS_STATS tmp_frame = first_frame; | |
| 3173 | − | |
| 3174 | − rc->frames_to_key /= 2; | |
| 3175 | − | |
| 3176 | − // Reset to the start of the group. | |
| 3177 | − reset_fpf_position(twopass, start_position); | |
| 3178 | − | |
| 3179 | − kf_group_err = 0.0; | |
| 3180 | − | |
| 3181 | − // Rescan to get the correct error data for the forced kf group. | |
| 3182 | − for (i = 0; i < rc->frames_to_key; ++i) { | |
| 3183 | − kf_group_err += | |
| 3184 | − calculate_norm_frame_score(cpi, twopass, oxcf, &tmp_frame, av_err); | |
| 3185 | − input_stats(twopass, &tmp_frame); | |
| 3186 | − } | |
| 3187 | − rc->next_key_frame_forced = 1; | |
| 3188 | − } else if (twopass->stats_in == twopass->stats_in_end || | |
| 3189 | − rc->frames_to_key >= cpi->oxcf.key_freq) { | |
| 3164 | + if (twopass->stats_in == twopass->stats_in_end || | |
| 3165 | + rc->frames_to_key >= cpi->oxcf.key_freq) { | |
| 3190 | 3166 | rc->next_key_frame_forced = 1; |
| 3191 | 3167 | } else { |
| 3192 | 3168 | rc->next_key_frame_forced = 0; |