RC: Support screen content Bug: b/281463780 Change-Id: Ife1bf579c948685ce839c701dfb1418584bc68fe
diff --git a/av1/ratectrl_rtc.cc b/av1/ratectrl_rtc.cc index cd9597b..62d6e74 100644 --- a/av1/ratectrl_rtc.cc +++ b/av1/ratectrl_rtc.cc
@@ -193,6 +193,10 @@ oxcf->rc_cfg.max_intra_bitrate_pct = rc_cfg.max_intra_bitrate_pct; oxcf->rc_cfg.max_inter_bitrate_pct = rc_cfg.max_inter_bitrate_pct; cpi_->framerate = rc_cfg.framerate; + if (rc_cfg.is_screen) { + cpi_->oxcf.tune_cfg.content = AOM_CONTENT_SCREEN; + cpi_->is_screen_content_type = 1; + } cpi_->svc.number_spatial_layers = rc_cfg.ss_number_layers; cpi_->svc.number_temporal_layers = rc_cfg.ts_number_layers; set_primary_rc_buffer_sizes(oxcf, cpi_->ppi); @@ -310,7 +314,7 @@ cpi_->common.current_frame.frame_number++; return FrameDropDecision::kDrop; } - int bottom_index, top_index; + int bottom_index = 0, top_index = 0; cpi_->common.quant_params.base_qindex = av1_rc_pick_q_and_bounds(cpi_, cm->width, cm->height, cpi_->gf_frame_index, &bottom_index, &top_index);
diff --git a/av1/ratectrl_rtc.h b/av1/ratectrl_rtc.h index 48ed9aa..1894469 100644 --- a/av1/ratectrl_rtc.h +++ b/av1/ratectrl_rtc.h
@@ -33,7 +33,7 @@ int width; int height; // Flag indicating if the content is screen or not. - bool is_screen; + bool is_screen = false; // 0-63 int max_quantizer; int min_quantizer;
diff --git a/test/ratectrl_rtc_test.cc b/test/ratectrl_rtc_test.cc index 92b7d39..cc054b6 100644 --- a/test/ratectrl_rtc_test.cc +++ b/test/ratectrl_rtc_test.cc
@@ -36,8 +36,9 @@ RcInterfaceTest() : EncoderTest(GET_PARAM(0)), aq_mode_(GET_PARAM(1)), key_interval_(3000), encoder_exit_(false), layer_frame_cnt_(0), superframe_cnt_(0), - dynamic_temporal_layers_(false), dynamic_spatial_layers_(false), - num_drops_(0), max_consec_drop_(0), frame_drop_thresh_(0) { + frame_cnt_(0), dynamic_temporal_layers_(false), + dynamic_spatial_layers_(false), num_drops_(0), max_consec_drop_(0), + frame_drop_thresh_(0) { memset(&svc_params_, 0, sizeof(svc_params_)); memset(&layer_id_, 0, sizeof(layer_id_)); } @@ -58,7 +59,11 @@ if (video->frame() == 0 && layer_frame_cnt_ == 0) { encoder->Control(AOME_SET_CPUUSED, 7); encoder->Control(AV1E_SET_AQ_MODE, aq_mode_); - encoder->Control(AV1E_SET_TUNE_CONTENT, AOM_CONTENT_DEFAULT); + if (rc_cfg_.is_screen) { + encoder->Control(AV1E_SET_TUNE_CONTENT, AOM_CONTENT_SCREEN); + } else { + encoder->Control(AV1E_SET_TUNE_CONTENT, AOM_CONTENT_DEFAULT); + } encoder->Control(AOME_SET_MAX_INTRA_BITRATE_PCT, rc_cfg_.max_intra_bitrate_pct); if (use_svc) encoder->Control(AV1E_SET_SVC_PARAMS, &svc_params_); @@ -142,12 +147,13 @@ return; } layer_frame_cnt_++; + frame_cnt_++; if (layer_id_.spatial_layer_id == rc_cfg_.ss_number_layers - 1) superframe_cnt_++; int qp; encoder->Control(AOME_GET_LAST_QUANTIZER, &qp); if (rc_api_->ComputeQP(frame_params_) == aom::FrameDropDecision::kOk) { - ASSERT_EQ(rc_api_->GetQP(), qp); + ASSERT_EQ(rc_api_->GetQP(), qp) << "at frame " << frame_cnt_ - 1; int encoder_lpf_level; encoder->Control(AOME_GET_LOOPFILTER_LEVEL, &encoder_lpf_level); aom::AV1LoopfilterLevel loopfilter_level = rc_api_->GetLoopfilterLevel(); @@ -186,6 +192,22 @@ ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); } + void RunOneLayerScreen() { + key_interval_ = 10000; + SetConfig(); + rc_cfg_.is_screen = true; + rc_cfg_.width = 352; + rc_cfg_.height = 288; + rc_api_ = aom::AV1RateControlRTC::Create(rc_cfg_); + frame_params_.spatial_layer_id = 0; + frame_params_.temporal_layer_id = 0; + + ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, + 288, 30, 1, 0, 140); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + void RunOneLayerDropFramesCBR() { key_interval_ = 10000; max_consec_drop_ = 8; @@ -454,6 +476,7 @@ aom_svc_layer_id_t layer_id_; int layer_frame_cnt_; int superframe_cnt_; + int frame_cnt_; bool dynamic_temporal_layers_; bool dynamic_spatial_layers_; int num_drops_; @@ -467,6 +490,8 @@ TEST_P(RcInterfaceTest, OneLayerPeriodicKey) { RunOneLayerPeriodicKey(); } +TEST_P(RcInterfaceTest, OneLayerScreen) { RunOneLayerScreen(); } + TEST_P(RcInterfaceTest, Svc) { RunSvc(); } TEST_P(RcInterfaceTest, SvcPeriodicKey) { RunSvcPeriodicKey(); }