History

Change the interface of find_next_key_frame

angiebird committed 7 years ago

Commit 1bd337b1 parent b2e49801 file · +12 −13Browse files

Unified · Split

vp9/encoder/vp9_firstpass.c+12−13
@@ -3055,8 +3055,7 @@ static int test_candidate_kf(TWO_PASS *twopass, · 3054 unmodified lines
30553055 #define MAX_KF_TOT_BOOST 5400
30563056 #endif
30573057
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) {
30603059 int i, j;
30613060 RATE_CONTROL *const rc = &cpi->rc;
30623061 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
30653064 const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info;
30663065 const FRAME_INFO *frame_info = &cpi->frame_info;
30673066 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);
30683069 FIRSTPASS_STATS next_frame;
3069− FIRSTPASS_STATS last_frame;
30703070 int kf_bits = 0;
30713071 int64_t max_kf_bits;
30723072 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
31093109 twopass->kf_group_bits = 0; // Total bits available to kf group
31103110 twopass->kf_group_error_left = 0.0; // Group modified error score.
31113111
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);
31153115
31163116 // Initialize the decay rates for the recent frames to check
31173117 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
31213121 while (twopass->stats_in < twopass->stats_in_end &&
31223122 rc->frames_to_key < cpi->oxcf.key_freq) {
31233123 // 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);
31263128
31273129 // Provided that we are not at the end of the file...
31283130 if (cpi->oxcf.auto_key && twopass->stats_in < twopass->stats_in_end) {
31293131 double loop_decay_rate;
31303132
31313133 // 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,
31333135 twopass->stats_in))
31343136 break;
31353137
@@ -3434,11 +3436,8 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { · 298 unmodified lines
34343436
34353437 // Keyframe and section processing.
34363438 if (rc->frames_to_key == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY)) {
3437− FIRSTPASS_STATS this_frame_copy;
3438− this_frame_copy = this_frame;
34393439 // 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);
34423441 } else {
34433442 cm->frame_type = INTER_FRAME;
34443443 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t