From 55c88437916b716ab885369246cac6427dbdc18c Mon Sep 17 00:00:00 2001 From: jackychen Date: Mon, 9 Nov 2015 14:58:14 -0800 Subject: [PATCH] VP9: add unit test for realtime external resize. Change-Id: I9bfa80de73847d9be88b6ce9865d7bb5fafaaa57 --- test/resize_test.cc | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/test/resize_test.cc b/test/resize_test.cc index 7a5240e08..dd184d18e 100644 --- a/test/resize_test.cc +++ b/test/resize_test.cc @@ -286,11 +286,11 @@ TEST_P(ResizeInternalTest, TestInternalResizeChangeConfig) { ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); } -class ResizeInternalRealtimeTest : public ::libvpx_test::EncoderTest, +class ResizeRealtimeTest : public ::libvpx_test::EncoderTest, public ::libvpx_test::CodecTestWith2Params { protected: - ResizeInternalRealtimeTest() : EncoderTest(GET_PARAM(0)) {} - virtual ~ResizeInternalRealtimeTest() {} + ResizeRealtimeTest() : EncoderTest(GET_PARAM(0)) {} + virtual ~ResizeRealtimeTest() {} virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video, libvpx_test::Encoder *encoder) { @@ -318,8 +318,6 @@ class ResizeInternalRealtimeTest : public ::libvpx_test::EncoderTest, } void DefaultConfig() { - cfg_.g_w = 352; - cfg_.g_h = 288; cfg_.rc_buf_initial_sz = 500; cfg_.rc_buf_optimal_sz = 600; cfg_.rc_buf_sz = 1000; @@ -346,13 +344,34 @@ class ResizeInternalRealtimeTest : public ::libvpx_test::EncoderTest, bool change_bitrate_; }; +TEST_P(ResizeRealtimeTest, TestExternalResizeWorks) { + ResizingVideoSource video; + DefaultConfig(); + change_bitrate_ = false; + ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); + + for (std::vector::const_iterator info = frame_info_list_.begin(); + info != frame_info_list_.end(); ++info) { + const unsigned int frame = static_cast(info->pts); + const unsigned int expected_w = ScaleForFrameNumber(frame, kInitialWidth); + const unsigned int expected_h = ScaleForFrameNumber(frame, kInitialHeight); + + EXPECT_EQ(expected_w, info->w) + << "Frame " << frame << " had unexpected width"; + EXPECT_EQ(expected_h, info->h) + << "Frame " << frame << " had unexpected height"; + } +} + // Verify the dynamic resizer behavior for real time, 1 pass CBR mode. // Run at low bitrate, with resize_allowed = 1, and verify that we get // one resize down event. -TEST_P(ResizeInternalRealtimeTest, TestInternalResizeDown) { +TEST_P(ResizeRealtimeTest, TestInternalResizeDown) { ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 30, 1, 0, 299); DefaultConfig(); + cfg_.g_w = 352; + cfg_.g_h = 288; change_bitrate_ = false; ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); @@ -378,10 +397,12 @@ TEST_P(ResizeInternalRealtimeTest, TestInternalResizeDown) { // Verify the dynamic resizer behavior for real time, 1 pass CBR mode. // Start at low target bitrate, raise the bitrate in the middle of the clip, // scaling-up should occur after bitrate changed. -TEST_P(ResizeInternalRealtimeTest, TestInternalResizeDownUpChangeBitRate) { +TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) { ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 30, 1, 0, 359); DefaultConfig(); + cfg_.g_w = 352; + cfg_.g_h = 288; change_bitrate_ = true; // Disable dropped frames. cfg_.rc_dropframe_thresh = 0; @@ -524,7 +545,7 @@ VP9_INSTANTIATE_TEST_CASE(ResizeTest, ::testing::Values(::libvpx_test::kRealTime)); VP9_INSTANTIATE_TEST_CASE(ResizeInternalTest, ::testing::Values(::libvpx_test::kOnePassBest)); -VP9_INSTANTIATE_TEST_CASE(ResizeInternalRealtimeTest, +VP9_INSTANTIATE_TEST_CASE(ResizeRealtimeTest, ::testing::Values(::libvpx_test::kRealTime), ::testing::Range(5, 9)); VP9_INSTANTIATE_TEST_CASE(ResizeCspTest,