Use correct base q for tpl pass in DuckyEncode Bug: b/244730922 Change-Id: I51af27ac6059ac2c987bb493006edd5833d220e9
diff --git a/av1/ducky_encode.cc b/av1/ducky_encode.cc index 5bfc124..a4fa2f8 100644 --- a/av1/ducky_encode.cc +++ b/av1/ducky_encode.cc
@@ -47,6 +47,7 @@ int g_usage; int max_ref_frames; int speed; + int base_qindex; enum aom_rc_mode rc_end_usage; aom_rational64_t timestamp_ratio; std::vector<FIRSTPASS_STATS> stats_list; @@ -54,12 +55,13 @@ }; DuckyEncode::DuckyEncode(const VideoInfo &video_info, int max_ref_frames, - int speed) { + int speed, int base_qindex) { impl_ptr_ = std::unique_ptr<EncodeImpl>(new EncodeImpl()); impl_ptr_->video_info = video_info; impl_ptr_->g_usage = GOOD; impl_ptr_->max_ref_frames = max_ref_frames; impl_ptr_->speed = speed; + impl_ptr_->base_qindex = base_qindex; impl_ptr_->rc_end_usage = AOM_Q; // TODO(angiebird): Set timestamp_ratio properly // timestamp_ratio.den = cfg->g_timebase.den; @@ -455,7 +457,8 @@ // encoding frame frame_number aom::EncodeFrameDecision frame_decision = { aom::EncodeFrameMode::kQindex, aom::EncodeGopMode::kGopRcl, - { 128, -1 } }; + { impl_ptr_->base_qindex, + -1 } }; (void)frame; EncodeFrame(frame_decision); if (ppi->cpi->common.show_frame) pending_ctx_size_ = 0;
diff --git a/av1/ducky_encode.h b/av1/ducky_encode.h index ffa53b0..086681b 100644 --- a/av1/ducky_encode.h +++ b/av1/ducky_encode.h
@@ -74,7 +74,7 @@ class DuckyEncode { public: explicit DuckyEncode(const VideoInfo &video_info, int max_ref_frames, - int speed = 3); + int speed, int base_qindex); ~DuckyEncode(); std::vector<FIRSTPASS_STATS> ComputeFirstPassStats(); void StartEncode(const std::vector<FIRSTPASS_STATS> &stats_list);
diff --git a/test/ducky_encode_test.cc b/test/ducky_encode_test.cc index ce64253..fe4ddf3 100644 --- a/test/ducky_encode_test.cc +++ b/test/ducky_encode_test.cc
@@ -35,7 +35,7 @@ 1, "bus_352x288_420_f20_b8.yuv" }; video_info.file_path = libaom_test::GetDataPath() + "/" + video_info.file_path; - DuckyEncode ducky_encode(video_info, kMaxRefFrames); + DuckyEncode ducky_encode(video_info, kMaxRefFrames, 3, 128); std::vector<FIRSTPASS_STATS> frame_stats = ducky_encode.ComputeFirstPassStats(); EXPECT_EQ(frame_stats.size(), static_cast<size_t>(video_info.frame_count)); @@ -52,7 +52,7 @@ 17, "bus_352x288_420_f20_b8.yuv" }; video_info.file_path = libaom_test::GetDataPath() + "/" + video_info.file_path; - DuckyEncode ducky_encode(video_info, kMaxRefFrames); + DuckyEncode ducky_encode(video_info, kMaxRefFrames, 3, 128); std::vector<FIRSTPASS_STATS> frame_stats = ducky_encode.ComputeFirstPassStats(); ducky_encode.StartEncode(frame_stats); @@ -78,7 +78,7 @@ 17, "bus_352x288_420_f20_b8.yuv" }; video_info.file_path = libaom_test::GetDataPath() + "/" + video_info.file_path; - DuckyEncode ducky_encode(video_info, kMaxRefFrames); + DuckyEncode ducky_encode(video_info, kMaxRefFrames, 3, 128); std::vector<FIRSTPASS_STATS> frame_stats = ducky_encode.ComputeFirstPassStats(); ducky_encode.StartEncode(frame_stats);
diff --git a/test/ratectrl_qmode_test.cc b/test/ratectrl_qmode_test.cc index 6d11f59..71d858c 100644 --- a/test/ratectrl_qmode_test.cc +++ b/test/ratectrl_qmode_test.cc
@@ -1036,6 +1036,7 @@ AV1RateControlQMode rc; rc_param_.max_gop_show_frame_count = 16; rc_param_.max_ref_frames = 3; + rc_param_.base_q_index = 117; ASSERT_THAT(rc.SetRcParam(rc_param_), IsOkStatus()); const auto gop_info = rc.DetermineGopInfo(firstpass_info); ASSERT_THAT(gop_info.status(), IsOkStatus()); @@ -1046,7 +1047,8 @@ frame_rate, AOM_IMG_FMT_I420, 50, libaom_test::GetDataPath() + "/hantro_collage_w352h288.yuv" }; - DuckyEncode ducky_encode(input_video, 3, 3); + DuckyEncode ducky_encode(input_video, rc_param_.max_ref_frames, 3, + rc_param_.base_q_index); ducky_encode.StartEncode(firstpass_info.stats_list); // Read TPL stats std::vector<TplGopStats> tpl_gop_list =