History

Simplify the logics in find_next_key_frame

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.

angiebird committed 7 years ago

Commit f2d91e21 parent 31193de1 file · +3 −27Browse files

Unified · Split

vp9/encoder/vp9_firstpass.c+3−27
@@ -3061,7 +3061,6 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 3060 unmodified lines
30613061 TWO_PASS *const twopass = &cpi->twopass;
30623062 GF_GROUP *const gf_group = &twopass->gf_group;
30633063 const VP9EncoderConfig *const oxcf = &cpi->oxcf;
3064− const FIRSTPASS_STATS first_frame = *this_frame;
30653064 const FIRSTPASS_STATS *const start_position = twopass->stats_in;
30663065 FIRSTPASS_STATS next_frame;
30673066 FIRSTPASS_STATS last_frame;
@@ -3153,14 +3152,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 85 unmodified lines
31533152 break;
31543153
31553154 // 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;
31633155 }
3156+ ++rc->frames_to_key;
31643157 ++i;
31653158 }
31663159
@@ -3168,25 +3161,8 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 1 unmodified line
31683161 // We already breakout of the loop above at 2x max.
31693162 // This code centers the extra kf if the actual natural interval
31703163 // 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) {
31903166 rc->next_key_frame_forced = 1;
31913167 } else {
31923168 rc->next_key_frame_forced = 0;

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