Commit b26ce8b1 authored by Marco Paniconi's avatar Marco Paniconi

Updates to 1-pass:

   -Don't reduce maxQ for gold/alt in CBR mode.

   -Fix to min/maxQ for first/initial key frame.

   -Add more speeds to datarate test and reduce the starting bitrate for test.

Change-Id: Id2a333d76dd3f6a51b322ca984588e2a22159c58
parent a2a5c6f8
......@@ -176,14 +176,32 @@ TEST_P(DatarateTest, ChangingDropFrameThresh) {
}
}
class DatarateTestVP9 : public DatarateTest {
class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
public:
DatarateTestVP9() : EncoderTest(GET_PARAM(0)) {}
protected:
virtual ~DatarateTestVP9() {}
virtual void SetUp() {
InitializeConfig();
SetMode(GET_PARAM(1));
set_cpu_used_ = GET_PARAM(2);
ResetModel();
}
virtual void ResetModel() {
last_pts_ = 0;
frame_number_ = 0;
bits_total_ = 0;
duration_ = 0.0;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
::libvpx_test::Encoder *encoder) {
if (video->frame() == 1) {
encoder->Control(VP8E_SET_CPUUSED, 2);
encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
}
const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den;
......@@ -205,6 +223,14 @@ class DatarateTestVP9 : public DatarateTest {
effective_datarate_ = ((bits_total_) / 1000.0) / duration_;
}
}
vpx_codec_pts_t last_pts_;
double timebase_;
int frame_number_;
int64_t bits_total_;
double duration_;
double effective_datarate_;
int set_cpu_used_;
};
// There is no buffer model/frame dropper in VP9 currently, so for now we
......@@ -218,7 +244,7 @@ TEST_P(DatarateTestVP9, BasicRateTargeting) {
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 140);
for (int i = 200; i < 800; i += 200) {
for (int i = 150; i < 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
......@@ -231,5 +257,6 @@ TEST_P(DatarateTestVP9, BasicRateTargeting) {
VP8_INSTANTIATE_TEST_CASE(DatarateTest, ALL_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9,
::testing::Values(::libvpx_test::kOnePassGood));
::testing::Values(::libvpx_test::kOnePassGood),
::testing::Range(1, 5));
} // namespace
......@@ -2866,7 +2866,7 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi,
cpi->active_best_quality = inter_minq[q];
// 1-pass: for now, use the average Q for the active_best, if its lower
// than active_worst.
if (cpi->pass == 0 && (cpi->avg_frame_qindex < cpi->active_worst_quality))
if (cpi->pass == 0 && (cpi->avg_frame_qindex < q))
cpi->active_best_quality = inter_minq[cpi->avg_frame_qindex];
#endif
......@@ -2902,7 +2902,14 @@ static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi,
if (cm->frame_type == KEY_FRAME && !cpi->this_key_frame_forced) {
*top_index =
(cpi->active_worst_quality + cpi->active_best_quality * 3) / 4;
// If this is the first (key) frame in 1-pass, active best is the user
// best-allowed, and leave the top_index to active_worst.
if (cpi->pass == 0 && cpi->common.current_video_frame == 0) {
cpi->active_best_quality = cpi->oxcf.best_allowed_q;
*top_index = cpi->oxcf.worst_allowed_q;
}
} else if (!cpi->is_src_frame_alt_ref &&
(cpi->oxcf.end_usage != USAGE_STREAM_FROM_SERVER) &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
*top_index =
(cpi->active_worst_quality + cpi->active_best_quality) / 2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment