Group input related config in AV1EncoderConfig
This CL groups the configuration parameters related to the input
sequence from Av1EncoderConfig into a new struct InputCfg, and adds
relevant documentation.
BUG=aomedia:2701
Change-Id: If0170f8fa5fed2b259202e198dc3fd0911f52d60
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 0e747ab..4ba57c4 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -730,6 +730,8 @@
ColorCfg *const color_cfg = &oxcf->color_cfg;
+ InputCfg *const input_cfg = &oxcf->input_cfg;
+
const int is_vbr = cfg->rc_end_usage == AOM_VBR;
oxcf->profile = cfg->g_profile;
oxcf->max_threads = (int)cfg->g_threads;
@@ -744,9 +746,24 @@
frm_dim_cfg->render_height = extra_cfg->render_height;
oxcf->bit_depth = cfg->g_bit_depth;
- oxcf->input_bit_depth = cfg->g_input_bit_depth;
+
+ // Set input video related configuration.
+ input_cfg->input_bit_depth = cfg->g_input_bit_depth;
// guess a frame rate if out of whack, use 30
- oxcf->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num;
+ input_cfg->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num;
+ if (cfg->g_pass == AOM_RC_LAST_PASS) {
+ const size_t packet_sz = sizeof(FIRSTPASS_STATS);
+ const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
+ input_cfg->limit = n_packets - 1;
+ } else {
+ input_cfg->limit = cfg->g_limit;
+ }
+ input_cfg->chroma_subsampling_x = extra_cfg->chroma_subsampling_x;
+ input_cfg->chroma_subsampling_y = extra_cfg->chroma_subsampling_y;
+ if (input_cfg->init_framerate > 180) {
+ input_cfg->init_framerate = 30;
+ dec_model_cfg->timing_info_present = 0;
+ }
// Set Decoder model configuration.
if (extra_cfg->timing_info_type == AOM_TIMING_EQUAL ||
@@ -778,10 +795,6 @@
dec_model_cfg->decoder_model_info_present_flag = 1;
dec_model_cfg->display_model_info_present_flag = 1;
}
- if (oxcf->init_framerate > 180) {
- oxcf->init_framerate = 30;
- dec_model_cfg->timing_info_present = 0;
- }
switch (cfg->g_pass) {
case AOM_RC_ONE_PASS: oxcf->pass = 0; break;
@@ -1051,15 +1064,8 @@
oxcf->error_resilient_mode =
cfg->g_error_resilient | extra_cfg->error_resilient_mode;
oxcf->frame_parallel_decoding_mode = extra_cfg->frame_parallel_decoding_mode;
- if (cfg->g_pass == AOM_RC_LAST_PASS) {
- const size_t packet_sz = sizeof(FIRSTPASS_STATS);
- const int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
- oxcf->limit = n_packets - 1;
- } else {
- oxcf->limit = cfg->g_limit;
- }
- if (oxcf->limit == 1) {
+ if (input_cfg->limit == 1) {
// still picture mode, display model and timing is meaningless
dec_model_cfg->display_model_info_present_flag = 0;
dec_model_cfg->timing_info_present = 0;
@@ -1080,8 +1086,6 @@
oxcf->unit_test_cfg.sb_multipass_unit_test =
extra_cfg->sb_multipass_unit_test;
- oxcf->chroma_subsampling_x = extra_cfg->chroma_subsampling_x;
- oxcf->chroma_subsampling_y = extra_cfg->chroma_subsampling_y;
oxcf->border_in_pixels =
(resize_cfg->resize_mode || superres_cfg->superres_mode)
? AOM_BORDER_IN_PIXELS
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index c0fd988..7ae8079 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -385,7 +385,8 @@
const AV1EncoderConfig *oxcf, int use_svc) {
const FrameDimensionCfg *const frm_dim_cfg = &oxcf->frm_dim_cfg;
- seq->still_picture = (oxcf->force_video_mode == 0) && (oxcf->limit == 1);
+ seq->still_picture =
+ (oxcf->force_video_mode == 0) && (oxcf->input_cfg.limit == 1);
seq->reduced_still_picture_hdr = seq->still_picture;
seq->reduced_still_picture_hdr &= !oxcf->full_still_picture_hdr;
seq->force_screen_content_tools = (oxcf->mode == REALTIME) ? 0 : 2;
@@ -439,7 +440,7 @@
seq->enable_filter_intra = oxcf->intra_mode_cfg.enable_filter_intra;
set_bitstream_level_tier(seq, cm, frm_dim_cfg->width, frm_dim_cfg->height,
- oxcf->init_framerate);
+ oxcf->input_cfg.init_framerate);
if (seq->operating_points_cnt_minus_1 == 0) {
seq->operating_point_idc[0] = 0;
@@ -469,7 +470,7 @@
const DecoderModelCfg *const dec_model_cfg = &oxcf->dec_model_cfg;
const ColorCfg *const color_cfg = &oxcf->color_cfg;
cpi->oxcf = *oxcf;
- cpi->framerate = oxcf->init_framerate;
+ cpi->framerate = oxcf->input_cfg.init_framerate;
seq_params->profile = oxcf->profile;
seq_params->bit_depth = oxcf->bit_depth;
@@ -527,8 +528,8 @@
seq_params->subsampling_y = 0;
} else {
if (seq_params->bit_depth == AOM_BITS_12) {
- seq_params->subsampling_x = oxcf->chroma_subsampling_x;
- seq_params->subsampling_y = oxcf->chroma_subsampling_y;
+ seq_params->subsampling_x = oxcf->input_cfg.chroma_subsampling_x;
+ seq_params->subsampling_y = oxcf->input_cfg.chroma_subsampling_y;
} else {
seq_params->subsampling_x = 1;
seq_params->subsampling_y = 0;
@@ -1338,7 +1339,8 @@
(cpi->time_receive_data + cpi->time_compress_data) / 1000.000;
const double dr =
(double)cpi->bytes * (double)8 / (double)1000 / time_encoded;
- const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1);
+ const double peak =
+ (double)((1 << cpi->oxcf.input_cfg.input_bit_depth) - 1);
const double target_rate = (double)cpi->oxcf.target_bandwidth / 1000;
const double rate_err = ((100.0 * (dr - target_rate)) / target_rate);
@@ -1474,7 +1476,7 @@
int i;
PSNR_STATS psnr;
#if CONFIG_AV1_HIGHBITDEPTH
- const uint32_t in_bit_depth = cpi->oxcf.input_bit_depth;
+ const uint32_t in_bit_depth = cpi->oxcf.input_cfg.input_bit_depth;
const uint32_t bit_depth = cpi->td.mb.e_mbd.bd;
aom_calc_highbd_psnr(cpi->source, &cpi->common.cur_frame->buf, &psnr,
bit_depth, in_bit_depth);
@@ -3181,7 +3183,7 @@
static void compute_internal_stats(AV1_COMP *cpi, int frame_bytes) {
AV1_COMMON *const cm = &cpi->common;
double samples = 0.0;
- const uint32_t in_bit_depth = cpi->oxcf.input_bit_depth;
+ const uint32_t in_bit_depth = cpi->oxcf.input_cfg.input_bit_depth;
const uint32_t bit_depth = cpi->td.mb.e_mbd.bd;
#if CONFIG_INTER_STATS_ONLY
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index b4c5f40..ce53991 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -573,6 +573,19 @@
} UnitTestCfg;
typedef struct {
+ // Indicates the framerate of the input video.
+ double init_framerate;
+ // Indicates the bit-depth of the input video.
+ unsigned int input_bit_depth;
+ // Indicates the maximum number of frames to be encoded.
+ unsigned int limit;
+ // Indicates the chrome subsampling x value.
+ unsigned int chroma_subsampling_x;
+ // Indicates the chrome subsampling y value.
+ unsigned int chroma_subsampling_y;
+} InputCfg;
+
+typedef struct {
// List of QP offsets for: keyframe, ALTREF, and 3 levels of internal ARFs.
// If any of these values are negative, fixed offsets are disabled.
// Uses internal q range.
@@ -604,10 +617,11 @@
typedef struct AV1EncoderConfig {
/*!\cond */
BITSTREAM_PROFILE profile;
- aom_bit_depth_t bit_depth; // Codec bit-depth.
- unsigned int input_bit_depth; // Input bit depth.
- double init_framerate; // set to passed in framerate
- int64_t target_bandwidth; // bandwidth to be used in bits per second
+ aom_bit_depth_t bit_depth; // Codec bit-depth.
+ int64_t target_bandwidth; // bandwidth to be used in bits per second
+
+ // Configuration related to the input video.
+ InputCfg input_cfg;
// Configuration related to frame-dimensions.
FrameDimensionCfg frm_dim_cfg;
@@ -670,8 +684,6 @@
*/
unsigned int frame_parallel_decoding_mode;
- unsigned int limit;
-
int arnr_max_frames;
int arnr_strength;
@@ -741,9 +753,6 @@
int noise_block_size;
#endif
- unsigned int chroma_subsampling_x;
- unsigned int chroma_subsampling_y;
-
// Configuration related to frequency of cost update.
CostUpdateFreq cost_upd_freq;
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index b00bb21..72cc146 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -854,7 +854,7 @@
FeatureFlags *const features = &cm->features;
projected_size_pass[pass] = cpi->rc.projected_frame_size;
#if CONFIG_AV1_HIGHBITDEPTH
- const uint32_t in_bit_depth = cpi->oxcf.input_bit_depth;
+ const uint32_t in_bit_depth = cpi->oxcf.input_cfg.input_bit_depth;
const uint32_t bit_depth = cpi->td.mb.e_mbd.bd;
aom_calc_highbd_psnr(cpi->source, &cpi->common.cur_frame->buf, &psnr[pass],
bit_depth, in_bit_depth);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index de0bf40..45616be 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -333,10 +333,10 @@
if (rc->min_gf_interval == 0)
rc->min_gf_interval = av1_rc_get_default_min_gf_interval(
oxcf->frm_dim_cfg.width, oxcf->frm_dim_cfg.height,
- oxcf->init_framerate);
+ oxcf->input_cfg.init_framerate);
if (rc->max_gf_interval == 0)
rc->max_gf_interval = av1_rc_get_default_max_gf_interval(
- oxcf->init_framerate, rc->min_gf_interval);
+ oxcf->input_cfg.init_framerate, rc->min_gf_interval);
rc->baseline_gf_interval = (rc->min_gf_interval + rc->max_gf_interval) / 2;
rc->avg_frame_low_motion = 0;
}