ref: d6b8709eb08be135ce3a39e762051e6621ff8037
parent: 29beeff11dd957af3f28d52fea9433ec43603bc7
author: Dmitry Kovalev <[email protected]>
date: Mon Mar 10 13:29:15 EDT 2014
Moving static_scene_max_gf_interval to RATE_CONTROL struct. Change-Id: Id63e114a8f0615dbafd6a816019cdebffb983d2c
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1412,7 +1412,7 @@
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.
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -57,7 +57,6 @@
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;
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -1134,21 +1134,19 @@
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 @@
// 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) {
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -37,6 +37,7 @@
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;