Unified · Split
| @@ -3055,8 +3055,7 @@ static int test_candidate_kf(TWO_PASS *twopass, · 3054 unmodified lines | ||
| 3055 | 3055 | #define MAX_KF_TOT_BOOST 5400 |
| 3056 | 3056 | #endif |
| 3057 | 3057 | |
| 3058 | −static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame, | |
| 3059 | − int kf_show_idx) { | |
| 3058 | +static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { | |
| 3060 | 3059 | int i, j; |
| 3061 | 3060 | RATE_CONTROL *const rc = &cpi->rc; |
| 3062 | 3061 | TWO_PASS *const twopass = &cpi->twopass; |
| @@ -3065,8 +3064,9 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame, · 2 unmodified lines | ||
| 3065 | 3064 | const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; |
| 3066 | 3065 | const FRAME_INFO *frame_info = &cpi->frame_info; |
| 3067 | 3066 | const FIRSTPASS_STATS *const start_position = twopass->stats_in; |
| 3067 | + const FIRSTPASS_STATS *keyframe_stats = | |
| 3068 | + fps_get_frame_stats(first_pass_info, kf_show_idx); | |
| 3068 | 3069 | FIRSTPASS_STATS next_frame; |
| 3069 | − FIRSTPASS_STATS last_frame; | |
| 3070 | 3070 | int kf_bits = 0; |
| 3071 | 3071 | int64_t max_kf_bits; |
| 3072 | 3072 | double decay_accumulator = 1.0; |
| @@ -3109,9 +3109,9 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame, · 36 unmodified lines | ||
| 3109 | 3109 | twopass->kf_group_bits = 0; // Total bits available to kf group |
| 3110 | 3110 | twopass->kf_group_error_left = 0.0; // Group modified error score. |
| 3111 | 3111 | |
| 3112 | − kf_raw_err = this_frame->intra_error; | |
| 3113 | − kf_mod_err = | |
| 3114 | − calculate_norm_frame_score(cpi, twopass, oxcf, this_frame, av_err); | |
| 3112 | + kf_raw_err = keyframe_stats->intra_error; | |
| 3113 | + kf_mod_err = calc_norm_frame_score(oxcf, frame_info, keyframe_stats, | |
| 3114 | + mean_mod_score, av_err); | |
| 3115 | 3115 | |
| 3116 | 3116 | // Initialize the decay rates for the recent frames to check |
| 3117 | 3117 | for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j) recent_loop_decay[j] = 1.0; |
| @@ -3121,15 +3121,17 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame, · 3 unmodified lines | ||
| 3121 | 3121 | while (twopass->stats_in < twopass->stats_in_end && |
| 3122 | 3122 | rc->frames_to_key < cpi->oxcf.key_freq) { |
| 3123 | 3123 | // Load the next frame's stats. |
| 3124 | − last_frame = *this_frame; | |
| 3125 | − input_stats(twopass, this_frame); | |
| 3124 | + const FIRSTPASS_STATS *last_frame = | |
| 3125 | + fps_get_frame_stats(first_pass_info, kf_show_idx + i); | |
| 3126 | + FIRSTPASS_STATS this_frame; | |
| 3127 | + input_stats(twopass, &this_frame); | |
| 3126 | 3128 | |
| 3127 | 3129 | // Provided that we are not at the end of the file... |
| 3128 | 3130 | if (cpi->oxcf.auto_key && twopass->stats_in < twopass->stats_in_end) { |
| 3129 | 3131 | double loop_decay_rate; |
| 3130 | 3132 | |
| 3131 | 3133 | // Check for a scene cut. |
| 3132 | − if (test_candidate_kf(twopass, &last_frame, this_frame, | |
| 3134 | + if (test_candidate_kf(twopass, last_frame, &this_frame, | |
| 3133 | 3135 | twopass->stats_in)) |
| 3134 | 3136 | break; |
| 3135 | 3137 | |
| @@ -3434,11 +3436,8 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { · 298 unmodified lines | ||
| 3434 | 3436 | |
| 3435 | 3437 | // Keyframe and section processing. |
| 3436 | 3438 | if (rc->frames_to_key == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY)) { |
| 3437 | − FIRSTPASS_STATS this_frame_copy; | |
| 3438 | − this_frame_copy = this_frame; | |
| 3439 | 3439 | // Define next KF group and assign bits to it. |
| 3440 | − find_next_key_frame(cpi, &this_frame, show_idx); | |
| 3441 | − this_frame = this_frame_copy; | |
| 3440 | + find_next_key_frame(cpi, show_idx); | |
| 3442 | 3441 | } else { |
| 3443 | 3442 | cm->frame_type = INTER_FRAME; |
| 3444 | 3443 | } |