#define V_LOW_INTRA 0.5
static int test_candidate_kf(TWO_PASS *twopass,
- const FIRSTPASS_STATS *last_frame,
- const FIRSTPASS_STATS *this_frame,
- const FIRSTPASS_STATS *next_frame) {
+ const FIRST_PASS_INFO *first_pass_info,
+ int show_idx) {
+ const FIRSTPASS_STATS *last_frame =
+ fps_get_frame_stats(first_pass_info, show_idx - 1);
+ const FIRSTPASS_STATS *this_frame =
+ fps_get_frame_stats(first_pass_info, show_idx);
+ const FIRSTPASS_STATS *next_frame =
+ fps_get_frame_stats(first_pass_info, show_idx + 1);
int is_viable_kf = 0;
double pcnt_intra = 1.0 - this_frame->pcnt_inter;
int i = 0;
while (twopass->stats_in < twopass->stats_in_end &&
rc->frames_to_key < cpi->oxcf.key_freq) {
- // Load the next frame's stats.
- const FIRSTPASS_STATS *last_frame =
- fps_get_frame_stats(first_pass_info, kf_show_idx + i);
FIRSTPASS_STATS this_frame;
input_stats(twopass, &this_frame);
double loop_decay_rate;
// Check for a scene cut.
- if (test_candidate_kf(twopass, last_frame, &this_frame,
- twopass->stats_in))
+ if (test_candidate_kf(twopass, first_pass_info, kf_show_idx + i + 1))
break;
// How fast is the prediction quality decaying?
static INLINE const FIRSTPASS_STATS *fps_get_frame_stats(
const FIRST_PASS_INFO *first_pass_info, int show_idx) {
- if (show_idx >= first_pass_info->num_frames) {
+ if (show_idx < 0 || show_idx >= first_pass_info->num_frames) {
return NULL;
}
return &first_pass_info->stats[show_idx];