From 6abddf37f875a54319eae13166819c0e617cb1d9 Mon Sep 17 00:00:00 2001 From: Debargha Mukherjee Date: Tue, 14 Jun 2016 14:50:30 -0700 Subject: [PATCH] Split some slower tests based on cpu-used Change-Id: Idf84475fe06666d5c73c9d86dfc5c23bef170086 --- test/active_map_test.cc | 35 +++++++++------ test/tile_independence_test.cc | 55 ++++++++++++++++------- test/vp9_ethread_test.cc | 80 ++++++++++++++++++++-------------- 3 files changed, 110 insertions(+), 60 deletions(-) diff --git a/test/active_map_test.cc b/test/active_map_test.cc index 9d953a842..75a65603a 100644 --- a/test/active_map_test.cc +++ b/test/active_map_test.cc @@ -65,32 +65,41 @@ class ActiveMapTest } } + void DoTest() { + // Validate that this non multiple of 64 wide clip encodes + cfg_.g_lag_in_frames = 0; + cfg_.rc_target_bitrate = 400; + cfg_.rc_resize_allowed = 0; + cfg_.g_pass = VPX_RC_ONE_PASS; + cfg_.rc_end_usage = VPX_CBR; + cfg_.kf_max_dist = 90000; + ::libvpx_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30, + 1, 0, 20); + + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + } + int cpu_used_; }; TEST_P(ActiveMapTest, Test) { - // Validate that this non multiple of 64 wide clip encodes - cfg_.g_lag_in_frames = 0; - cfg_.rc_target_bitrate = 400; - cfg_.rc_resize_allowed = 0; - cfg_.g_pass = VPX_RC_ONE_PASS; - cfg_.rc_end_usage = VPX_CBR; - cfg_.kf_max_dist = 90000; + DoTest(); +} - ::libvpx_test::I420VideoSource video("hantro_odd.yuv", kWidth, kHeight, 30, - 1, 0, 20); +class ActiveMapTestLarge : public ActiveMapTest {}; - ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +TEST_P(ActiveMapTestLarge, Test) { + DoTest(); } VP9_INSTANTIATE_TEST_CASE(ActiveMapTest, ::testing::Values(::libvpx_test::kRealTime), ::testing::Range(0, 9)); #if CONFIG_VP10 -#if CONFIG_SUPERTX -VP10_INSTANTIATE_TEST_CASE(ActiveMapTest, +VP10_INSTANTIATE_TEST_CASE(ActiveMapTestLarge, ::testing::Values(::libvpx_test::kRealTime), ::testing::Range(0, 5)); +#if CONFIG_SUPERTX // SuperTx and ActiveMap don't get along at speed 5. // https://bugs.chromium.org/p/webm/issues/detail?id=1234 INSTANTIATE_TEST_CASE_P( @@ -102,7 +111,7 @@ INSTANTIATE_TEST_CASE_P( #else VP10_INSTANTIATE_TEST_CASE(ActiveMapTest, ::testing::Values(::libvpx_test::kRealTime), - ::testing::Range(0, 9)); + ::testing::Range(5, 9)); #endif // CONFIG_SUPERTX #endif // CONFIG_VP10 } // namespace diff --git a/test/tile_independence_test.cc b/test/tile_independence_test.cc index dc31d0670..adc8a8ac0 100644 --- a/test/tile_independence_test.cc +++ b/test/tile_independence_test.cc @@ -64,9 +64,15 @@ class TileIndependenceTest : public ::libvpx_test::EncoderTest, if (video->frame() == 1) { encoder->Control(VP9E_SET_TILE_COLUMNS, n_tile_cols_); encoder->Control(VP9E_SET_TILE_ROWS, n_tile_rows_); + SetCpuUsed(encoder); } } + virtual void SetCpuUsed(libvpx_test::Encoder *encoder) { + static const int kCpuUsed = 3; + encoder->Control(VP8E_SET_CPUUSED, kCpuUsed); + } + void UpdateMD5(::libvpx_test::Decoder *dec, const vpx_codec_cx_pkt_t *pkt, ::libvpx_test::MD5 *md5) { const vpx_codec_err_t res = dec->DecodeFrame( @@ -84,6 +90,22 @@ class TileIndependenceTest : public ::libvpx_test::EncoderTest, UpdateMD5(inv_dec_, pkt, &md5_inv_order_); } + void DoTest() { + const vpx_rational timebase = { 33333333, 1000000000 }; + cfg_.g_timebase = timebase; + cfg_.rc_target_bitrate = 500; + cfg_.g_lag_in_frames = 12; + cfg_.rc_end_usage = VPX_VBR; + + libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 704, 576, + timebase.den, timebase.num, 0, 5); + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + + const char *md5_fw_str = md5_fw_order_.Get(); + const char *md5_inv_str = md5_inv_order_.Get(); + ASSERT_STREQ(md5_fw_str, md5_inv_str); + } + ::libvpx_test::MD5 md5_fw_order_, md5_inv_order_; ::libvpx_test::Decoder *fw_dec_, *inv_dec_; @@ -96,33 +118,36 @@ class TileIndependenceTest : public ::libvpx_test::EncoderTest, // inverted tile ordering. Ensure that the MD5 of the output in both cases // is identical. If so, tiles are considered independent and the test passes. TEST_P(TileIndependenceTest, MD5Match) { - const vpx_rational timebase = { 33333333, 1000000000 }; - cfg_.g_timebase = timebase; - cfg_.rc_target_bitrate = 500; - cfg_.g_lag_in_frames = 12; - cfg_.rc_end_usage = VPX_VBR; + DoTest(); +} - libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 704, 576, - timebase.den, timebase.num, 0, 5); - ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); +class TileIndependenceTestLarge : public TileIndependenceTest { + virtual void SetCpuUsed(libvpx_test::Encoder *encoder) { + static const int kCpuUsed = 0; + encoder->Control(VP8E_SET_CPUUSED, kCpuUsed); + } +}; - const char *md5_fw_str = md5_fw_order_.Get(); - const char *md5_inv_str = md5_inv_order_.Get(); - - // could use ASSERT_EQ(!memcmp(.., .., 16) here, but this gives nicer - // output if it fails. Not sure if it's helpful since it's really just - // a MD5... - ASSERT_STREQ(md5_fw_str, md5_inv_str); +TEST_P(TileIndependenceTestLarge, MD5Match) { + DoTest(); } VP9_INSTANTIATE_TEST_CASE(TileIndependenceTest, ::testing::Values(0, 1), ::testing::Values(0)); +VP9_INSTANTIATE_TEST_CASE(TileIndependenceTestLarge, ::testing::Values(0, 1), + ::testing::Values(0)); #if CONFIG_EXT_TILE VP10_INSTANTIATE_TEST_CASE(TileIndependenceTest, ::testing::Values(1, 2, 32), ::testing::Values(1, 2, 32)); +VP10_INSTANTIATE_TEST_CASE(TileIndependenceTestLarge, + ::testing::Values(1, 2, 32), + ::testing::Values(1, 2, 32)); #else VP10_INSTANTIATE_TEST_CASE(TileIndependenceTest, ::testing::Values(0, 1), ::testing::Values(0, 1)); +VP10_INSTANTIATE_TEST_CASE(TileIndependenceTestLarge, + ::testing::Values(0, 1), + ::testing::Values(0, 1)); #endif // CONFIG_EXT_TILE } // namespace diff --git a/test/vp9_ethread_test.cc b/test/vp9_ethread_test.cc index 35a6619d7..78f1ec3ff 100644 --- a/test/vp9_ethread_test.cc +++ b/test/vp9_ethread_test.cc @@ -125,6 +125,43 @@ class VPxEncoderThreadTest } } + void DoTest() { + ::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 15, 18); + cfg_.rc_target_bitrate = 1000; + + // Encode using single thread. + cfg_.g_threads = 1; + init_flags_ = VPX_CODEC_USE_PSNR; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + std::vector single_thr_size_enc; + std::vector single_thr_md5_enc; + std::vector single_thr_md5_dec; + single_thr_size_enc = size_enc_; + single_thr_md5_enc = md5_enc_; + single_thr_md5_dec = md5_dec_; + size_enc_.clear(); + md5_enc_.clear(); + md5_dec_.clear(); + + // Encode using multiple threads. + cfg_.g_threads = 4; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + std::vector multi_thr_size_enc; + std::vector multi_thr_md5_enc; + std::vector multi_thr_md5_dec; + multi_thr_size_enc = size_enc_; + multi_thr_md5_enc = md5_enc_; + multi_thr_md5_dec = md5_dec_; + size_enc_.clear(); + md5_enc_.clear(); + md5_dec_.clear(); + + // Check that the vectors are equal. + ASSERT_EQ(single_thr_size_enc, multi_thr_size_enc); + ASSERT_EQ(single_thr_md5_enc, multi_thr_md5_enc); + ASSERT_EQ(single_thr_md5_dec, multi_thr_md5_dec); + } + bool encoder_initialized_; ::libvpx_test::TestMode encoding_mode_; int set_cpu_used_; @@ -137,39 +174,13 @@ class VPxEncoderThreadTest }; TEST_P(VPxEncoderThreadTest, EncoderResultTest) { - std::vector single_thr_size_enc, multi_thr_size_enc; - std::vector single_thr_md5_enc, multi_thr_md5_enc; - std::vector single_thr_md5_dec, multi_thr_md5_dec; + DoTest(); +} - ::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 15, 18); +class VPxEncoderThreadTestLarge : public VPxEncoderThreadTest {}; - cfg_.rc_target_bitrate = 1000; - - // Encode using single thread. - cfg_.g_threads = 1; - init_flags_ = VPX_CODEC_USE_PSNR; - ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); - single_thr_size_enc = size_enc_; - single_thr_md5_enc = md5_enc_; - single_thr_md5_dec = md5_dec_; - size_enc_.clear(); - md5_enc_.clear(); - md5_dec_.clear(); - - // Encode using multiple threads. - cfg_.g_threads = 4; - ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); - multi_thr_size_enc = size_enc_; - multi_thr_md5_enc = md5_enc_; - multi_thr_md5_dec = md5_dec_; - size_enc_.clear(); - md5_enc_.clear(); - md5_dec_.clear(); - - // Check that the vectors are equal. - ASSERT_EQ(single_thr_size_enc, multi_thr_size_enc); - ASSERT_EQ(single_thr_md5_enc, multi_thr_md5_enc); - ASSERT_EQ(single_thr_md5_dec, multi_thr_md5_dec); +TEST_P(VPxEncoderThreadTestLarge, EncoderResultTest) { + DoTest(); } VP9_INSTANTIATE_TEST_CASE( @@ -181,5 +192,10 @@ VP9_INSTANTIATE_TEST_CASE( VP10_INSTANTIATE_TEST_CASE( VPxEncoderThreadTest, ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood), - ::testing::Range(1, 9), ::testing::Values(1)); + ::testing::Range(3, 9), ::testing::Values(1)); + +VP10_INSTANTIATE_TEST_CASE( + VPxEncoderThreadTestLarge, + ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood), + ::testing::Range(1, 3), ::testing::Values(1)); } // namespace