Commit 39c91d84 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Re-factor some duplicate code.

Change-Id: I89a1dbea39c50c7633f746d9c93fec3a289f1b42
parent 8df1b869
......@@ -1578,7 +1578,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Break out conditions.
if (
// Break at cpi->max_gf_interval unless almost totally static.
// Break at active_max_gf_interval unless almost totally static.
(i >= active_max_gf_interval && (zero_motion_accumulator < 0.995)) ||
(
// Don't break out with a very short interval.
......
......@@ -1390,6 +1390,24 @@ int vp9_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type,
return target_index - qindex;
}
void vp9_rc_set_gf_max_interval(const VP9EncoderConfig *const oxcf,
RATE_CONTROL *const rc) {
// Set Maximum gf/arf interval
rc->max_gf_interval = 16;
// Extended interval for genuinely static scenes
rc->static_scene_max_gf_interval = oxcf->key_freq >> 1;
// Special conditions when alt ref frame enabled
if (oxcf->play_alternate && oxcf->lag_in_frames) {
if (rc->static_scene_max_gf_interval > oxcf->lag_in_frames - 1)
rc->static_scene_max_gf_interval = oxcf->lag_in_frames - 1;
}
if (rc->max_gf_interval > rc->static_scene_max_gf_interval)
rc->max_gf_interval = rc->static_scene_max_gf_interval;
}
void vp9_rc_update_framerate(VP9_COMP *cpi) {
const VP9_COMMON *const cm = &cpi->common;
const VP9EncoderConfig *const oxcf = &cpi->oxcf;
......@@ -1414,21 +1432,5 @@ void vp9_rc_update_framerate(VP9_COMP *cpi) {
rc->max_frame_bandwidth = MAX(MAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P),
vbr_max_bits);
// Set Maximum gf/arf interval
rc->max_gf_interval = 16;
// Extended interval for genuinely static scenes
rc->static_scene_max_gf_interval = cpi->oxcf.key_freq >> 1;
// Special conditions when alt ref frame enabled in lagged compress mode
if (oxcf->play_alternate && oxcf->lag_in_frames) {
if (rc->max_gf_interval > oxcf->lag_in_frames - 1)
rc->max_gf_interval = oxcf->lag_in_frames - 1;
if (rc->static_scene_max_gf_interval > oxcf->lag_in_frames - 1)
rc->static_scene_max_gf_interval = oxcf->lag_in_frames - 1;
}
if (rc->max_gf_interval > rc->static_scene_max_gf_interval)
rc->max_gf_interval = rc->static_scene_max_gf_interval;
vp9_rc_set_gf_max_interval(oxcf, rc);
}
......@@ -178,6 +178,9 @@ int vp9_compute_qdelta_by_rate(const RATE_CONTROL *rc, FRAME_TYPE frame_type,
void vp9_rc_update_framerate(struct VP9_COMP *cpi);
void vp9_rc_set_gf_max_interval(const struct VP9EncoderConfig *const oxcf,
RATE_CONTROL *const rc);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -150,20 +150,7 @@ void vp9_update_spatial_layer_framerate(VP9_COMP *const cpi, double framerate) {
oxcf->two_pass_vbrmin_section / 100);
lrc->max_frame_bandwidth = (int)(((int64_t)lrc->avg_frame_bandwidth *
oxcf->two_pass_vbrmax_section) / 100);
lrc->max_gf_interval = 16;
lrc->static_scene_max_gf_interval = cpi->oxcf.key_freq >> 1;
if (oxcf->play_alternate && oxcf->lag_in_frames) {
if (lrc->max_gf_interval > oxcf->lag_in_frames - 1)
lrc->max_gf_interval = oxcf->lag_in_frames - 1;
if (lrc->static_scene_max_gf_interval > oxcf->lag_in_frames - 1)
lrc->static_scene_max_gf_interval = oxcf->lag_in_frames - 1;
}
if (lrc->max_gf_interval > lrc->static_scene_max_gf_interval)
lrc->max_gf_interval = lrc->static_scene_max_gf_interval;
vp9_rc_set_gf_max_interval(oxcf, lrc);
}
void vp9_restore_layer_context(VP9_COMP *const cpi) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment