From: angiebird Date: Tue, 22 Oct 2019 01:04:49 +0000 (-0700) Subject: Pass first_pass_info/show_idx to test_candidate_kf X-Git-Tag: v1.8.2~74^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=793ae588538f20bff0993574381e73ebce677d1b;p=libvpx Pass first_pass_info/show_idx to test_candidate_kf Change-Id: I5c18de464be9981236f95c62391258c4963e469b --- diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 8e58011f6..f75abdb87 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2945,9 +2945,14 @@ static int intra_step_transition(const FIRSTPASS_STATS *this_frame, #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; @@ -3106,9 +3111,6 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { 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); @@ -3117,8 +3119,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { 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? diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h index 6aa296bd0..2158dfe4f 100644 --- a/vp9/encoder/vp9_firstpass.h +++ b/vp9/encoder/vp9_firstpass.h @@ -164,7 +164,7 @@ static INLINE int fps_get_num_frames(const FIRST_PASS_INFO *first_pass_info) { 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];