diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index f548de5039f8d8be13b344dfc247f0428e9e9e84..acb5a09b5abfcf89855b67e537b5beee1a870172 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1412,7 +1412,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { active_max_gf_interval = rc->max_gf_interval; i = 0; - while (i < twopass->static_scene_max_gf_interval && i < rc->frames_to_key) { + while (i < rc->static_scene_max_gf_interval && i < rc->frames_to_key) { ++i; // Accumulate error score of frames in this gf group. diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h index 9f44a307b69c4d05a8d24e2a8921022c24088c9d..278b22c5cd9c0bfe5000543e5fe75a5717b4230f 100644 --- a/vp9/encoder/vp9_firstpass.h +++ b/vp9/encoder/vp9_firstpass.h @@ -57,7 +57,6 @@ struct twopass_rc { double modified_error_left; double kf_intra_err_min; double gf_intra_err_min; - int static_scene_max_gf_interval; int kf_bits; // Remaining error from uncoded frames in a gf group. Two pass use only int64_t gf_group_error_left; diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 57d2c78ab94fe44a8fada46211334b46d67bcc4f..235005f32974fc389056ff250f1907788119a0a1 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -1134,21 +1134,19 @@ int vp9_reverse_trans(int x) { void vp9_new_framerate(VP9_COMP *cpi, double framerate) { VP9_COMMON *const cm = &cpi->common; + RATE_CONTROL *const rc = &cpi->rc; + VP9_CONFIG *const oxcf = &cpi->oxcf; int vbr_max_bits; - if (framerate < 0.1) - framerate = 30; - - cpi->oxcf.framerate = framerate; + oxcf->framerate = framerate < 0.1 ? 30 : framerate; cpi->output_framerate = cpi->oxcf.framerate; - cpi->rc.av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth - / cpi->output_framerate); - cpi->rc.min_frame_bandwidth = (int)(cpi->rc.av_per_frame_bandwidth * - cpi->oxcf.two_pass_vbrmin_section / 100); + rc->av_per_frame_bandwidth = (int)(oxcf->target_bandwidth / + cpi->output_framerate); + rc->min_frame_bandwidth = (int)(rc->av_per_frame_bandwidth * + oxcf->two_pass_vbrmin_section / 100); - cpi->rc.min_frame_bandwidth = MAX(cpi->rc.min_frame_bandwidth, - FRAME_OVERHEAD_BITS); + rc->min_frame_bandwidth = MAX(rc->min_frame_bandwidth, FRAME_OVERHEAD_BITS); // A maximum bitrate for a frame is defined. // The baseline for this aligns with HW implementations that @@ -1158,28 +1156,28 @@ void vp9_new_framerate(VP9_COMP *cpi, double framerate) { // be acheived because of a user specificed max q (e.g. when the user // specifies lossless encode. // - vbr_max_bits = (int)(((int64_t)cpi->rc.av_per_frame_bandwidth * - cpi->oxcf.two_pass_vbrmax_section) / 100); - cpi->rc.max_frame_bandwidth = - MAX(MAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P), vbr_max_bits); + vbr_max_bits = (int)(((int64_t)rc->av_per_frame_bandwidth * + oxcf->two_pass_vbrmax_section) / 100); + rc->max_frame_bandwidth = MAX(MAX((cm->MBs * MAX_MB_RATE), MAXRATE_1080P), + vbr_max_bits); // Set Maximum gf/arf interval - cpi->rc.max_gf_interval = 16; + rc->max_gf_interval = 16; // Extended interval for genuinely static scenes - cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; + rc->static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; // Special conditions when alt ref frame enabled in lagged compress mode - if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) { - if (cpi->rc.max_gf_interval > cpi->oxcf.lag_in_frames - 1) - cpi->rc.max_gf_interval = cpi->oxcf.lag_in_frames - 1; + 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 (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1) - cpi->twopass.static_scene_max_gf_interval = cpi->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 (cpi->rc.max_gf_interval > cpi->twopass.static_scene_max_gf_interval) - cpi->rc.max_gf_interval = cpi->twopass.static_scene_max_gf_interval; + if (rc->max_gf_interval > rc->static_scene_max_gf_interval) + rc->max_gf_interval = rc->static_scene_max_gf_interval; } static int64_t rescale(int64_t val, int64_t num, int denom) { diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h index 5dbc7d138d7ebe77cae6cb576de8930b23c65b1a..a6f2c31c08b0cd7320ccfac44bda0d277da03469 100644 --- a/vp9/encoder/vp9_ratectrl.h +++ b/vp9/encoder/vp9_ratectrl.h @@ -37,6 +37,7 @@ typedef struct { int frames_since_golden; int frames_till_gf_update_due; int max_gf_interval; + int static_scene_max_gf_interval; int baseline_gf_interval; int frames_to_key; int frames_since_key;