Chromium Code Reviews| Index: media/gpu/video_encode_accelerator_unittest.cc |
| diff --git a/media/gpu/video_encode_accelerator_unittest.cc b/media/gpu/video_encode_accelerator_unittest.cc |
| index ab0e9c07597cae85a7fa503fd9d9b9eb92c42b1d..ac3e5fb9831378c223dab03f866ea5a4514af6c4 100644 |
| --- a/media/gpu/video_encode_accelerator_unittest.cc |
| +++ b/media/gpu/video_encode_accelerator_unittest.cc |
| @@ -760,7 +760,8 @@ class VEAClient : public VideoEncodeAccelerator::Client { |
| bool test_perf, |
| bool mid_stream_bitrate_switch, |
| bool mid_stream_framerate_switch, |
| - bool verify_output); |
| + bool verify_output, |
| + bool verify_output_timestamp); |
| ~VEAClient() override; |
| void CreateEncoder(); |
| void DestroyEncoder(); |
| @@ -924,6 +925,9 @@ class VEAClient : public VideoEncodeAccelerator::Client { |
| // Check the output frame quality of the encoder. |
| bool verify_output_; |
| + // Check whether the output timestamps match input timestamps. |
| + bool verify_output_timestamp_; |
| + |
| // Used to perform codec-specific sanity checks on the stream. |
| std::unique_ptr<StreamValidator> stream_validator_; |
| @@ -953,6 +957,9 @@ class VEAClient : public VideoEncodeAccelerator::Client { |
| // The timer used to feed the encoder with the input frames. |
| std::unique_ptr<base::RepeatingTimer> input_timer_; |
| + |
| + // The timestamps for each frame in the order of CreateFrame() invocation. |
| + std::queue<base::TimeDelta> frame_timestamps_; |
| }; |
| VEAClient::VEAClient(TestStream* test_stream, |
| @@ -963,7 +970,8 @@ VEAClient::VEAClient(TestStream* test_stream, |
| bool test_perf, |
| bool mid_stream_bitrate_switch, |
| bool mid_stream_framerate_switch, |
| - bool verify_output) |
| + bool verify_output, |
| + bool verify_output_timestamp) |
| : state_(CS_CREATED), |
| test_stream_(test_stream), |
| note_(note), |
| @@ -986,6 +994,7 @@ VEAClient::VEAClient(TestStream* test_stream, |
| encoded_stream_size_since_last_check_(0), |
| test_perf_(test_perf), |
| verify_output_(verify_output), |
| + verify_output_timestamp_(verify_output_timestamp), |
| requested_bitrate_(0), |
| requested_framerate_(0), |
| requested_subsequent_bitrate_(0), |
| @@ -1227,6 +1236,18 @@ void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, |
| if (state_ == CS_FINISHED || state_ == CS_VALIDATED) |
| return; |
| + if (verify_output_timestamp_) { |
| + CHECK(!frame_timestamps_.empty()); |
|
henryhsu
2016/07/07 07:44:58
s/CHECK/EXPECT_TRUE/
shenghao1
2016/07/07 09:49:50
Done.
|
| + |
| + // One input frame may be mapped to multiple output frames, so the current |
| + // timestamp should be equal to one of the top two elements in |
| + // frame_timestamps_. |
| + if (timestamp != frame_timestamps_.front()) { |
| + frame_timestamps_.pop(); |
| + CHECK_EQ(timestamp, frame_timestamps_.front()); |
|
henryhsu
2016/07/07 07:44:58
s/CHECK_EQ/EXPECT_EQ/ to fail this test case and r
shenghao1
2016/07/07 09:49:50
Done.
|
| + } |
| + } |
| + |
| encoded_stream_size_since_last_check_ += payload_size; |
| const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory()); |
| @@ -1363,6 +1384,7 @@ void VEAClient::FeedEncoderWithOneInput() { |
| int32_t input_id; |
| scoped_refptr<VideoFrame> video_frame = |
| PrepareInputFrame(pos_in_input_stream_, &input_id); |
| + frame_timestamps_.push(video_frame->timestamp()); |
| pos_in_input_stream_ += test_stream_->aligned_buffer_size; |
| bool force_keyframe = false; |
| @@ -1557,7 +1579,7 @@ void VEAClient::WriteIvfFrameHeader(int frame_index, size_t frame_size) { |
| // - If true, verify the output frames of encoder. |
|
henryhsu
2016/07/07 07:44:58
Add comment for the new parameter
shenghao1
2016/07/07 09:49:50
Done.
|
| class VideoEncodeAcceleratorTest |
| : public ::testing::TestWithParam< |
| - std::tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; |
| + std::tuple<int, bool, int, bool, bool, bool, bool, bool, bool>> {}; |
| TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { |
| size_t num_concurrent_encoders = std::get<0>(GetParam()); |
| @@ -1569,6 +1591,7 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { |
| const bool mid_stream_framerate_switch = std::get<6>(GetParam()); |
| const bool verify_output = |
| std::get<7>(GetParam()) || g_env->verify_all_output(); |
| + const bool verify_output_timestamp = std::get<8>(GetParam()); |
| ScopedVector<ClientStateNotification<ClientState>> notes; |
| ScopedVector<VEAClient> clients; |
| @@ -1590,7 +1613,8 @@ TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { |
| clients.push_back(new VEAClient( |
| g_env->test_streams_[test_stream_index], notes.back(), |
| encoder_save_to_file, keyframe_period, force_bitrate, test_perf, |
| - mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output)); |
| + mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output, |
| + verify_output_timestamp)); |
| encoder_thread.task_runner()->PostTask( |
| FROM_HERE, base::Bind(&VEAClient::CreateEncoder, |
| @@ -1629,65 +1653,84 @@ INSTANTIATE_TEST_CASE_P( |
| SimpleEncode, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, true, 0, false, false, false, false, false), |
| - std::make_tuple(1, true, 0, false, false, false, false, true))); |
| + std::make_tuple(1, true, 0, false, false, false, false, false, false), |
| + std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| INSTANTIATE_TEST_CASE_P( |
| EncoderPerf, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, false, 0, false, true, false, false, false))); |
| - |
| -INSTANTIATE_TEST_CASE_P( |
| - ForceKeyframes, |
| - VideoEncodeAcceleratorTest, |
| - ::testing::Values( |
| - std::make_tuple(1, false, 10, false, false, false, false, false))); |
| + std::make_tuple(1, false, 0, false, true, false, false, false, false))); |
| + |
| +INSTANTIATE_TEST_CASE_P(ForceKeyframes, |
|
henryhsu
2016/07/07 07:44:58
Is this generated by "git cl format"?
shenghao1
2016/07/07 09:49:50
yes
|
| + VideoEncodeAcceleratorTest, |
| + ::testing::Values(std::make_tuple(1, |
| + false, |
| + 10, |
| + false, |
| + false, |
| + false, |
| + false, |
| + false, |
| + false))); |
| INSTANTIATE_TEST_CASE_P( |
| ForceBitrate, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, false, 0, true, false, false, false, false))); |
| + std::make_tuple(1, false, 0, true, false, false, false, false, false))); |
| INSTANTIATE_TEST_CASE_P( |
| MidStreamParamSwitchBitrate, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, false, 0, true, false, true, false, false))); |
| + std::make_tuple(1, false, 0, true, false, true, false, false, false))); |
| INSTANTIATE_TEST_CASE_P( |
| MidStreamParamSwitchFPS, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, false, 0, true, false, false, true, false))); |
| + std::make_tuple(1, false, 0, true, false, false, true, false, false))); |
| INSTANTIATE_TEST_CASE_P( |
| MultipleEncoders, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(3, false, 0, false, false, false, false, false), |
| - std::make_tuple(3, false, 0, true, false, false, true, false), |
| - std::make_tuple(3, false, 0, true, false, true, false, false))); |
| -#else |
| + std::make_tuple(3, false, 0, false, false, false, false, false, false), |
| + std::make_tuple(3, false, 0, true, false, false, true, false, false), |
| + std::make_tuple(3, false, 0, true, false, true, false, false, false))); |
| + |
| INSTANTIATE_TEST_CASE_P( |
| - SimpleEncode, |
| + VerifyTimestamp, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, true, 0, false, false, false, false, false), |
| - std::make_tuple(1, true, 0, false, false, false, false, true))); |
| + std::make_tuple(1, true, 0, false, false, false, false, false, true))); |
| +#else |
| INSTANTIATE_TEST_CASE_P( |
| - EncoderPerf, |
| + SimpleEncode, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(1, false, 0, false, true, false, false, false))); |
| + std::make_tuple(1, true, 0, false, false, false, false, false, false), |
| + std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| INSTANTIATE_TEST_CASE_P( |
| - MultipleEncoders, |
| + EncoderPerf, |
| VideoEncodeAcceleratorTest, |
| ::testing::Values( |
| - std::make_tuple(3, false, 0, false, false, false, false, false))); |
| + std::make_tuple(1, false, 0, false, true, false, false, false, false))); |
| + |
| +INSTANTIATE_TEST_CASE_P(MultipleEncoders, |
| + VideoEncodeAcceleratorTest, |
| + ::testing::Values(std::make_tuple(3, |
| + false, |
| + 0, |
| + false, |
| + false, |
| + false, |
| + false, |
| + false, |
| + false))); |
| #endif |
| // TODO(posciak): more tests: |