Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: media/gpu/video_encode_accelerator_unittest.cc

Issue 2104883005: VEA unit test: Add timestamp test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed rewind check Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <inttypes.h> 5 #include <inttypes.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 class VEAClient : public VideoEncodeAccelerator::Client { 785 class VEAClient : public VideoEncodeAccelerator::Client {
786 public: 786 public:
787 VEAClient(TestStream* test_stream, 787 VEAClient(TestStream* test_stream,
788 ClientStateNotification<ClientState>* note, 788 ClientStateNotification<ClientState>* note,
789 bool save_to_file, 789 bool save_to_file,
790 unsigned int keyframe_period, 790 unsigned int keyframe_period,
791 bool force_bitrate, 791 bool force_bitrate,
792 bool test_perf, 792 bool test_perf,
793 bool mid_stream_bitrate_switch, 793 bool mid_stream_bitrate_switch,
794 bool mid_stream_framerate_switch, 794 bool mid_stream_framerate_switch,
795 bool verify_output); 795 bool verify_output,
796 bool verify_output_timestamp);
796 ~VEAClient() override; 797 ~VEAClient() override;
797 void CreateEncoder(); 798 void CreateEncoder();
798 void DestroyEncoder(); 799 void DestroyEncoder();
799 800
800 // VideoDecodeAccelerator::Client implementation. 801 // VideoDecodeAccelerator::Client implementation.
801 void RequireBitstreamBuffers(unsigned int input_count, 802 void RequireBitstreamBuffers(unsigned int input_count,
802 const gfx::Size& input_coded_size, 803 const gfx::Size& input_coded_size,
803 size_t output_buffer_size) override; 804 size_t output_buffer_size) override;
804 void BitstreamBufferReady(int32_t bitstream_buffer_id, 805 void BitstreamBufferReady(int32_t bitstream_buffer_id,
805 size_t payload_size, 806 size_t payload_size,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 873
873 // Callback function of the |input_timer_|. 874 // Callback function of the |input_timer_|.
874 void OnInputTimer(); 875 void OnInputTimer();
875 876
876 // Called when the quality validator has decoded all the frames. 877 // Called when the quality validator has decoded all the frames.
877 void DecodeCompleted(); 878 void DecodeCompleted();
878 879
879 // Called when the quality validator fails to decode a frame. 880 // Called when the quality validator fails to decode a frame.
880 void DecodeFailed(); 881 void DecodeFailed();
881 882
883 // Verify that the output timestamp matches input timestamp.
884 void VerifyOutputTimestamp(base::TimeDelta timestamp);
885
882 ClientState state_; 886 ClientState state_;
883 std::unique_ptr<VideoEncodeAccelerator> encoder_; 887 std::unique_ptr<VideoEncodeAccelerator> encoder_;
884 888
885 TestStream* test_stream_; 889 TestStream* test_stream_;
886 890
887 // Used to notify another thread about the state. VEAClient does not own this. 891 // Used to notify another thread about the state. VEAClient does not own this.
888 ClientStateNotification<ClientState>* note_; 892 ClientStateNotification<ClientState>* note_;
889 893
890 // Ids assigned to VideoFrames. 894 // Ids assigned to VideoFrames.
891 std::set<int32_t> inputs_at_client_; 895 std::set<int32_t> inputs_at_client_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 // Byte size of the encoded stream (for bitrate calculation) since last 953 // Byte size of the encoded stream (for bitrate calculation) since last
950 // time we checked bitrate. 954 // time we checked bitrate.
951 size_t encoded_stream_size_since_last_check_; 955 size_t encoded_stream_size_since_last_check_;
952 956
953 // If true, verify performance at the end of the test. 957 // If true, verify performance at the end of the test.
954 bool test_perf_; 958 bool test_perf_;
955 959
956 // Check the output frame quality of the encoder. 960 // Check the output frame quality of the encoder.
957 bool verify_output_; 961 bool verify_output_;
958 962
963 // Check whether the output timestamps match input timestamps.
964 bool verify_output_timestamp_;
965
959 // Used to perform codec-specific sanity checks on the stream. 966 // Used to perform codec-specific sanity checks on the stream.
960 std::unique_ptr<StreamValidator> stream_validator_; 967 std::unique_ptr<StreamValidator> stream_validator_;
961 968
962 // Used to validate the encoded frame quality. 969 // Used to validate the encoded frame quality.
963 std::unique_ptr<VideoFrameQualityValidator> quality_validator_; 970 std::unique_ptr<VideoFrameQualityValidator> quality_validator_;
964 971
965 // The time when the first frame is submitted for encode. 972 // The time when the first frame is submitted for encode.
966 base::TimeTicks first_frame_start_time_; 973 base::TimeTicks first_frame_start_time_;
967 974
968 // The time when the last encoded frame is ready. 975 // The time when the last encoded frame is ready.
969 base::TimeTicks last_frame_ready_time_; 976 base::TimeTicks last_frame_ready_time_;
970 977
971 // All methods of this class should be run on the same thread. 978 // All methods of this class should be run on the same thread.
972 base::ThreadChecker thread_checker_; 979 base::ThreadChecker thread_checker_;
973 980
974 // Requested bitrate in bits per second. 981 // Requested bitrate in bits per second.
975 unsigned int requested_bitrate_; 982 unsigned int requested_bitrate_;
976 983
977 // Requested initial framerate. 984 // Requested initial framerate.
978 unsigned int requested_framerate_; 985 unsigned int requested_framerate_;
979 986
980 // Bitrate to switch to in the middle of the stream. 987 // Bitrate to switch to in the middle of the stream.
981 unsigned int requested_subsequent_bitrate_; 988 unsigned int requested_subsequent_bitrate_;
982 989
983 // Framerate to switch to in the middle of the stream. 990 // Framerate to switch to in the middle of the stream.
984 unsigned int requested_subsequent_framerate_; 991 unsigned int requested_subsequent_framerate_;
985 992
986 // The timer used to feed the encoder with the input frames. 993 // The timer used to feed the encoder with the input frames.
987 std::unique_ptr<base::RepeatingTimer> input_timer_; 994 std::unique_ptr<base::RepeatingTimer> input_timer_;
995
996 // The timestamps for each frame in the order of CreateFrame() invocation.
997 std::queue<base::TimeDelta> frame_timestamps_;
998
999 // The last timestamp popped from |frame_timestamps_|.
1000 base::TimeDelta previous_timestamp_;
988 }; 1001 };
989 1002
990 VEAClient::VEAClient(TestStream* test_stream, 1003 VEAClient::VEAClient(TestStream* test_stream,
991 ClientStateNotification<ClientState>* note, 1004 ClientStateNotification<ClientState>* note,
992 bool save_to_file, 1005 bool save_to_file,
993 unsigned int keyframe_period, 1006 unsigned int keyframe_period,
994 bool force_bitrate, 1007 bool force_bitrate,
995 bool test_perf, 1008 bool test_perf,
996 bool mid_stream_bitrate_switch, 1009 bool mid_stream_bitrate_switch,
997 bool mid_stream_framerate_switch, 1010 bool mid_stream_framerate_switch,
998 bool verify_output) 1011 bool verify_output,
1012 bool verify_output_timestamp)
999 : state_(CS_CREATED), 1013 : state_(CS_CREATED),
1000 test_stream_(test_stream), 1014 test_stream_(test_stream),
1001 note_(note), 1015 note_(note),
1002 next_input_id_(0), 1016 next_input_id_(0),
1003 next_output_buffer_id_(0), 1017 next_output_buffer_id_(0),
1004 pos_in_input_stream_(0), 1018 pos_in_input_stream_(0),
1005 num_required_input_buffers_(0), 1019 num_required_input_buffers_(0),
1006 output_buffer_size_(0), 1020 output_buffer_size_(0),
1007 num_frames_to_encode_(0), 1021 num_frames_to_encode_(0),
1008 num_encoded_frames_(0), 1022 num_encoded_frames_(0),
1009 num_frames_since_last_check_(0), 1023 num_frames_since_last_check_(0),
1010 seen_keyframe_in_this_buffer_(false), 1024 seen_keyframe_in_this_buffer_(false),
1011 save_to_file_(save_to_file), 1025 save_to_file_(save_to_file),
1012 keyframe_period_(keyframe_period), 1026 keyframe_period_(keyframe_period),
1013 num_keyframes_requested_(0), 1027 num_keyframes_requested_(0),
1014 next_keyframe_at_(0), 1028 next_keyframe_at_(0),
1015 force_bitrate_(force_bitrate), 1029 force_bitrate_(force_bitrate),
1016 current_requested_bitrate_(0), 1030 current_requested_bitrate_(0),
1017 current_framerate_(0), 1031 current_framerate_(0),
1018 encoded_stream_size_since_last_check_(0), 1032 encoded_stream_size_since_last_check_(0),
1019 test_perf_(test_perf), 1033 test_perf_(test_perf),
1020 verify_output_(verify_output), 1034 verify_output_(verify_output),
1035 verify_output_timestamp_(verify_output_timestamp),
1021 requested_bitrate_(0), 1036 requested_bitrate_(0),
1022 requested_framerate_(0), 1037 requested_framerate_(0),
1023 requested_subsequent_bitrate_(0), 1038 requested_subsequent_bitrate_(0),
1024 requested_subsequent_framerate_(0) { 1039 requested_subsequent_framerate_(0) {
1025 if (keyframe_period_) 1040 if (keyframe_period_)
1026 LOG_ASSERT(kMaxKeyframeDelay < keyframe_period_); 1041 LOG_ASSERT(kMaxKeyframeDelay < keyframe_period_);
1027 1042
1028 // Fake encoder produces an invalid stream, so skip validating it. 1043 // Fake encoder produces an invalid stream, so skip validating it.
1029 if (!g_fake_encoder) { 1044 if (!g_fake_encoder) {
1030 stream_validator_ = StreamValidator::Create( 1045 stream_validator_ = StreamValidator::Create(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 input_timer_->Start( 1252 input_timer_->Start(
1238 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_, 1253 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_,
1239 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1254 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1240 } else { 1255 } else {
1241 while (inputs_at_client_.size() < 1256 while (inputs_at_client_.size() <
1242 num_required_input_buffers_ + kNumExtraInputFrames) 1257 num_required_input_buffers_ + kNumExtraInputFrames)
1243 FeedEncoderWithOneInput(); 1258 FeedEncoderWithOneInput();
1244 } 1259 }
1245 } 1260 }
1246 1261
1262 void VEAClient::VerifyOutputTimestamp(base::TimeDelta timestamp) {
1263 // One input frame may be mapped to multiple output frames, so the current
1264 // timestamp should be equal to previous timestamp or the top of
1265 // frame_timestamps_.
1266 if (num_encoded_frames_ == 0 || timestamp != previous_timestamp_) {
wuchengli 2016/07/12 09:28:06 This failed on oak for H264. Did you test any devi
shenghao1 2016/07/12 11:05:51 Done.
1267 ASSERT_TRUE(!frame_timestamps_.empty());
1268 EXPECT_EQ(frame_timestamps_.front(), timestamp);
1269 previous_timestamp_ = frame_timestamps_.front();
1270 frame_timestamps_.pop();
1271 }
1272 }
1273
1247 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, 1274 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id,
1248 size_t payload_size, 1275 size_t payload_size,
1249 bool key_frame, 1276 bool key_frame,
1250 base::TimeDelta timestamp) { 1277 base::TimeDelta timestamp) {
1251 DCHECK(thread_checker_.CalledOnValidThread()); 1278 DCHECK(thread_checker_.CalledOnValidThread());
1252 ASSERT_LE(payload_size, output_buffer_size_); 1279 ASSERT_LE(payload_size, output_buffer_size_);
1253 1280
1254 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id); 1281 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id);
1255 ASSERT_NE(it, output_buffers_at_client_.end()); 1282 ASSERT_NE(it, output_buffers_at_client_.end());
1256 base::SharedMemory* shm = it->second; 1283 base::SharedMemory* shm = it->second;
1257 output_buffers_at_client_.erase(it); 1284 output_buffers_at_client_.erase(it);
1258 1285
1259 if (state_ == CS_FINISHED || state_ == CS_VALIDATED) 1286 if (state_ == CS_FINISHED || state_ == CS_VALIDATED)
1260 return; 1287 return;
1261 1288
1289 if (verify_output_timestamp_) {
1290 VerifyOutputTimestamp(timestamp);
1291 }
1292
1262 encoded_stream_size_since_last_check_ += payload_size; 1293 encoded_stream_size_since_last_check_ += payload_size;
1263 1294
1264 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory()); 1295 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory());
1265 if (payload_size > 0) { 1296 if (payload_size > 0) {
1266 if (stream_validator_) { 1297 if (stream_validator_) {
1267 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size); 1298 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size);
1268 } else { 1299 } else {
1269 HandleEncodedFrame(key_frame); 1300 HandleEncodedFrame(key_frame);
1270 } 1301 }
1271 1302
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 position; 1364 position;
1334 uint8_t* frame_data_u = frame_data_y + test_stream_->aligned_plane_size[0]; 1365 uint8_t* frame_data_u = frame_data_y + test_stream_->aligned_plane_size[0];
1335 uint8_t* frame_data_v = frame_data_u + test_stream_->aligned_plane_size[1]; 1366 uint8_t* frame_data_v = frame_data_u + test_stream_->aligned_plane_size[1];
1336 CHECK_GT(current_framerate_, 0U); 1367 CHECK_GT(current_framerate_, 0U);
1337 1368
1338 scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData( 1369 scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData(
1339 kInputFormat, input_coded_size_, gfx::Rect(test_stream_->visible_size), 1370 kInputFormat, input_coded_size_, gfx::Rect(test_stream_->visible_size),
1340 test_stream_->visible_size, input_coded_size_.width(), 1371 test_stream_->visible_size, input_coded_size_.width(),
1341 input_coded_size_.width() / 2, input_coded_size_.width() / 2, 1372 input_coded_size_.width() / 2, input_coded_size_.width() / 2,
1342 frame_data_y, frame_data_u, frame_data_v, 1373 frame_data_y, frame_data_u, frame_data_v,
1343 base::TimeDelta().FromMilliseconds(next_input_id_ * 1374 base::TimeDelta().FromMilliseconds(next_input_id_ *
wuchengli 2016/07/12 09:28:07 (next_input_id_ + 1) See the another comment.
shenghao1 2016/07/12 11:05:51 Done.
1344 base::Time::kMillisecondsPerSecond / 1375 base::Time::kMillisecondsPerSecond /
1345 current_framerate_)); 1376 current_framerate_));
1346 EXPECT_NE(nullptr, video_frame.get()); 1377 EXPECT_NE(nullptr, video_frame.get());
1347 return video_frame; 1378 return video_frame;
1348 } 1379 }
1349 1380
1350 scoped_refptr<VideoFrame> VEAClient::PrepareInputFrame(off_t position, 1381 scoped_refptr<VideoFrame> VEAClient::PrepareInputFrame(off_t position,
1351 int32_t* input_id) { 1382 int32_t* input_id) {
1352 CHECK_LE(position + test_stream_->aligned_buffer_size, 1383 CHECK_LE(position + test_stream_->aligned_buffer_size,
1353 test_stream_->aligned_in_file_data.size()); 1384 test_stream_->aligned_in_file_data.size());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 // we require for bitrate tests. 1419 // we require for bitrate tests.
1389 pos_in_input_stream_ = 0; 1420 pos_in_input_stream_ = 0;
1390 } 1421 }
1391 1422
1392 if (quality_validator_) 1423 if (quality_validator_)
1393 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_)); 1424 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_));
1394 1425
1395 int32_t input_id; 1426 int32_t input_id;
1396 scoped_refptr<VideoFrame> video_frame = 1427 scoped_refptr<VideoFrame> video_frame =
1397 PrepareInputFrame(pos_in_input_stream_, &input_id); 1428 PrepareInputFrame(pos_in_input_stream_, &input_id);
1429 frame_timestamps_.push(video_frame->timestamp());
1398 pos_in_input_stream_ += test_stream_->aligned_buffer_size; 1430 pos_in_input_stream_ += test_stream_->aligned_buffer_size;
1399 1431
1400 bool force_keyframe = false; 1432 bool force_keyframe = false;
1401 if (keyframe_period_ && input_id % keyframe_period_ == 0) { 1433 if (keyframe_period_ && input_id % keyframe_period_ == 0) {
1402 force_keyframe = true; 1434 force_keyframe = true;
1403 ++num_keyframes_requested_; 1435 ++num_keyframes_requested_;
1404 } 1436 }
1405 1437
1406 if (input_id == 0) { 1438 if (input_id == 0) {
1407 first_frame_start_time_ = base::TimeTicks::Now(); 1439 first_frame_start_time_ = base::TimeTicks::Now();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_, 1513 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_,
1482 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1514 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1483 } 1515 }
1484 } else if (num_encoded_frames_ == num_frames_to_encode_) { 1516 } else if (num_encoded_frames_ == num_frames_to_encode_) {
1485 LogPerf(); 1517 LogPerf();
1486 VerifyMinFPS(); 1518 VerifyMinFPS();
1487 VerifyStreamProperties(); 1519 VerifyStreamProperties();
1488 SetState(CS_FINISHED); 1520 SetState(CS_FINISHED);
1489 if (!quality_validator_) 1521 if (!quality_validator_)
1490 SetState(CS_VALIDATED); 1522 SetState(CS_VALIDATED);
1523 if (verify_output_timestamp_) {
1524 // The last timestamp in |frame_timestamps_| won't be popped out.
wuchengli 2016/07/12 09:28:07 Update the comment.
shenghao1 2016/07/12 11:05:51 Done.
1525 EXPECT_LE(frame_timestamps_.size(),
1526 static_cast<size_t>(next_input_id_ - num_frames_to_encode_));
1527 }
1491 return false; 1528 return false;
1492 } 1529 }
1493 1530
1494 return true; 1531 return true;
1495 } 1532 }
1496 1533
1497 void VEAClient::LogPerf() { 1534 void VEAClient::LogPerf() {
1498 g_env->LogToFile("Measured encoder FPS", 1535 g_env->LogToFile("Measured encoder FPS",
1499 base::StringPrintf("%.3f", frames_per_second())); 1536 base::StringPrintf("%.3f", frames_per_second()));
1500 1537
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 // one input stream; otherwise, one encoder per input stream will be 1617 // one input stream; otherwise, one encoder per input stream will be
1581 // instantiated. 1618 // instantiated.
1582 // - If true, save output to file (provided an output filename was supplied). 1619 // - If true, save output to file (provided an output filename was supplied).
1583 // - Force a keyframe every n frames. 1620 // - Force a keyframe every n frames.
1584 // - Force bitrate; the actual required value is provided as a property 1621 // - Force bitrate; the actual required value is provided as a property
1585 // of the input stream, because it depends on stream type/resolution/etc. 1622 // of the input stream, because it depends on stream type/resolution/etc.
1586 // - If true, measure performance. 1623 // - If true, measure performance.
1587 // - If true, switch bitrate mid-stream. 1624 // - If true, switch bitrate mid-stream.
1588 // - If true, switch framerate mid-stream. 1625 // - If true, switch framerate mid-stream.
1589 // - If true, verify the output frames of encoder. 1626 // - If true, verify the output frames of encoder.
1627 // - If true, verify the timestamps of output frames.
1590 class VideoEncodeAcceleratorTest 1628 class VideoEncodeAcceleratorTest
1591 : public ::testing::TestWithParam< 1629 : public ::testing::TestWithParam<
1592 std::tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; 1630 std::tuple<int, bool, int, bool, bool, bool, bool, bool, bool>> {};
1593 1631
1594 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { 1632 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
1595 size_t num_concurrent_encoders = std::get<0>(GetParam()); 1633 size_t num_concurrent_encoders = std::get<0>(GetParam());
1596 const bool save_to_file = std::get<1>(GetParam()); 1634 const bool save_to_file = std::get<1>(GetParam());
1597 const unsigned int keyframe_period = std::get<2>(GetParam()); 1635 const unsigned int keyframe_period = std::get<2>(GetParam());
1598 const bool force_bitrate = std::get<3>(GetParam()); 1636 const bool force_bitrate = std::get<3>(GetParam());
1599 const bool test_perf = std::get<4>(GetParam()); 1637 const bool test_perf = std::get<4>(GetParam());
1600 const bool mid_stream_bitrate_switch = std::get<5>(GetParam()); 1638 const bool mid_stream_bitrate_switch = std::get<5>(GetParam());
1601 const bool mid_stream_framerate_switch = std::get<6>(GetParam()); 1639 const bool mid_stream_framerate_switch = std::get<6>(GetParam());
1602 const bool verify_output = 1640 const bool verify_output =
1603 std::get<7>(GetParam()) || g_env->verify_all_output(); 1641 std::get<7>(GetParam()) || g_env->verify_all_output();
1642 const bool verify_output_timestamp = std::get<8>(GetParam());
1604 1643
1605 ScopedVector<ClientStateNotification<ClientState>> notes; 1644 ScopedVector<ClientStateNotification<ClientState>> notes;
1606 ScopedVector<VEAClient> clients; 1645 ScopedVector<VEAClient> clients;
1607 base::Thread encoder_thread("EncoderThread"); 1646 base::Thread encoder_thread("EncoderThread");
1608 ASSERT_TRUE(encoder_thread.Start()); 1647 ASSERT_TRUE(encoder_thread.Start());
1609 1648
1610 if (g_env->test_streams_.size() > 1) 1649 if (g_env->test_streams_.size() > 1)
1611 num_concurrent_encoders = g_env->test_streams_.size(); 1650 num_concurrent_encoders = g_env->test_streams_.size();
1612 1651
1613 // Create all encoders. 1652 // Create all encoders.
1614 for (size_t i = 0; i < num_concurrent_encoders; i++) { 1653 for (size_t i = 0; i < num_concurrent_encoders; i++) {
1615 size_t test_stream_index = i % g_env->test_streams_.size(); 1654 size_t test_stream_index = i % g_env->test_streams_.size();
1616 // Disregard save_to_file if we didn't get an output filename. 1655 // Disregard save_to_file if we didn't get an output filename.
1617 bool encoder_save_to_file = 1656 bool encoder_save_to_file =
1618 (save_to_file && 1657 (save_to_file &&
1619 !g_env->test_streams_[test_stream_index]->out_filename.empty()); 1658 !g_env->test_streams_[test_stream_index]->out_filename.empty());
1620 1659
1621 notes.push_back(new ClientStateNotification<ClientState>()); 1660 notes.push_back(new ClientStateNotification<ClientState>());
1622 clients.push_back(new VEAClient( 1661 clients.push_back(new VEAClient(
1623 g_env->test_streams_[test_stream_index], notes.back(), 1662 g_env->test_streams_[test_stream_index], notes.back(),
1624 encoder_save_to_file, keyframe_period, force_bitrate, test_perf, 1663 encoder_save_to_file, keyframe_period, force_bitrate, test_perf,
1625 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output)); 1664 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output,
1665 verify_output_timestamp));
1626 1666
1627 encoder_thread.task_runner()->PostTask( 1667 encoder_thread.task_runner()->PostTask(
1628 FROM_HERE, base::Bind(&VEAClient::CreateEncoder, 1668 FROM_HERE, base::Bind(&VEAClient::CreateEncoder,
1629 base::Unretained(clients.back()))); 1669 base::Unretained(clients.back())));
1630 } 1670 }
1631 1671
1632 // All encoders must pass through states in this order. 1672 // All encoders must pass through states in this order.
1633 enum ClientState state_transitions[] = { 1673 enum ClientState state_transitions[] = {
1634 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; 1674 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED};
1635 1675
(...skipping 18 matching lines...) Expand all
1654 1694
1655 // This ensures all tasks have finished. 1695 // This ensures all tasks have finished.
1656 encoder_thread.Stop(); 1696 encoder_thread.Stop();
1657 } 1697 }
1658 1698
1659 #if !defined(OS_MACOSX) 1699 #if !defined(OS_MACOSX)
1660 INSTANTIATE_TEST_CASE_P( 1700 INSTANTIATE_TEST_CASE_P(
1661 SimpleEncode, 1701 SimpleEncode,
1662 VideoEncodeAcceleratorTest, 1702 VideoEncodeAcceleratorTest,
1663 ::testing::Values( 1703 ::testing::Values(
1664 std::make_tuple(1, true, 0, false, false, false, false, false), 1704 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1665 std::make_tuple(1, true, 0, false, false, false, false, true))); 1705 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1666 1706
1667 INSTANTIATE_TEST_CASE_P( 1707 INSTANTIATE_TEST_CASE_P(
1668 EncoderPerf, 1708 EncoderPerf,
1669 VideoEncodeAcceleratorTest, 1709 VideoEncodeAcceleratorTest,
1670 ::testing::Values( 1710 ::testing::Values(
1671 std::make_tuple(1, false, 0, false, true, false, false, false))); 1711 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1672 1712
1673 INSTANTIATE_TEST_CASE_P( 1713 INSTANTIATE_TEST_CASE_P(ForceKeyframes,
1674 ForceKeyframes, 1714 VideoEncodeAcceleratorTest,
1675 VideoEncodeAcceleratorTest, 1715 ::testing::Values(std::make_tuple(1,
1676 ::testing::Values( 1716 false,
1677 std::make_tuple(1, false, 10, false, false, false, false, false))); 1717 10,
1718 false,
1719 false,
1720 false,
1721 false,
1722 false,
1723 false)));
1678 1724
1679 INSTANTIATE_TEST_CASE_P( 1725 INSTANTIATE_TEST_CASE_P(
1680 ForceBitrate, 1726 ForceBitrate,
1681 VideoEncodeAcceleratorTest, 1727 VideoEncodeAcceleratorTest,
1682 ::testing::Values( 1728 ::testing::Values(
1683 std::make_tuple(1, false, 0, true, false, false, false, false))); 1729 std::make_tuple(1, false, 0, true, false, false, false, false, false)));
1684 1730
1685 INSTANTIATE_TEST_CASE_P( 1731 INSTANTIATE_TEST_CASE_P(
1686 MidStreamParamSwitchBitrate, 1732 MidStreamParamSwitchBitrate,
1687 VideoEncodeAcceleratorTest, 1733 VideoEncodeAcceleratorTest,
1688 ::testing::Values( 1734 ::testing::Values(
1689 std::make_tuple(1, false, 0, true, false, true, false, false))); 1735 std::make_tuple(1, false, 0, true, false, true, false, false, false)));
1690 1736
1691 INSTANTIATE_TEST_CASE_P( 1737 INSTANTIATE_TEST_CASE_P(
1692 MidStreamParamSwitchFPS, 1738 MidStreamParamSwitchFPS,
1693 VideoEncodeAcceleratorTest, 1739 VideoEncodeAcceleratorTest,
1694 ::testing::Values( 1740 ::testing::Values(
1695 std::make_tuple(1, false, 0, true, false, false, true, false))); 1741 std::make_tuple(1, false, 0, true, false, false, true, false, false)));
1696 1742
1697 INSTANTIATE_TEST_CASE_P( 1743 INSTANTIATE_TEST_CASE_P(
1698 MultipleEncoders, 1744 MultipleEncoders,
1699 VideoEncodeAcceleratorTest, 1745 VideoEncodeAcceleratorTest,
1700 ::testing::Values( 1746 ::testing::Values(
1701 std::make_tuple(3, false, 0, false, false, false, false, false), 1747 std::make_tuple(3, false, 0, false, false, false, false, false, false),
1702 std::make_tuple(3, false, 0, true, false, false, true, false), 1748 std::make_tuple(3, false, 0, true, false, false, true, false, false),
1703 std::make_tuple(3, false, 0, true, false, true, false, false))); 1749 std::make_tuple(3, false, 0, true, false, true, false, false, false)));
1750
1751 INSTANTIATE_TEST_CASE_P(
1752 VerifyTimestamp,
1753 VideoEncodeAcceleratorTest,
1754 ::testing::Values(
1755 std::make_tuple(1, true, 0, false, false, false, false, false, true)));
1756
1704 #else 1757 #else
1705 INSTANTIATE_TEST_CASE_P( 1758 INSTANTIATE_TEST_CASE_P(
1706 SimpleEncode, 1759 SimpleEncode,
1707 VideoEncodeAcceleratorTest, 1760 VideoEncodeAcceleratorTest,
1708 ::testing::Values( 1761 ::testing::Values(
1709 std::make_tuple(1, true, 0, false, false, false, false, false), 1762 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1710 std::make_tuple(1, true, 0, false, false, false, false, true))); 1763 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1711 1764
1712 INSTANTIATE_TEST_CASE_P( 1765 INSTANTIATE_TEST_CASE_P(
1713 EncoderPerf, 1766 EncoderPerf,
1714 VideoEncodeAcceleratorTest, 1767 VideoEncodeAcceleratorTest,
1715 ::testing::Values( 1768 ::testing::Values(
1716 std::make_tuple(1, false, 0, false, true, false, false, false))); 1769 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1717 1770
1718 INSTANTIATE_TEST_CASE_P( 1771 INSTANTIATE_TEST_CASE_P(MultipleEncoders,
1719 MultipleEncoders, 1772 VideoEncodeAcceleratorTest,
1720 VideoEncodeAcceleratorTest, 1773 ::testing::Values(std::make_tuple(3,
1721 ::testing::Values( 1774 false,
1722 std::make_tuple(3, false, 0, false, false, false, false, false))); 1775 0,
1776 false,
1777 false,
1778 false,
1779 false,
1780 false,
1781 false)));
wuchengli 2016/07/12 09:28:07 Try testing with you CL with verify_output_timesta
shenghao1 2016/07/12 11:05:51 Verified that they all pass.
1723 #endif 1782 #endif
1724 1783
1725 // TODO(posciak): more tests: 1784 // TODO(posciak): more tests:
1726 // - async FeedEncoderWithOutput 1785 // - async FeedEncoderWithOutput
1727 // - out-of-order return of outputs to encoder 1786 // - out-of-order return of outputs to encoder
1728 // - multiple encoders + decoders 1787 // - multiple encoders + decoders
1729 // - mid-stream encoder_->Destroy() 1788 // - mid-stream encoder_->Destroy()
1730 1789
1731 } // namespace 1790 } // namespace
1732 } // namespace media 1791 } // namespace media
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 1869
1811 media::g_env = 1870 media::g_env =
1812 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( 1871 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
1813 testing::AddGlobalTestEnvironment( 1872 testing::AddGlobalTestEnvironment(
1814 new media::VideoEncodeAcceleratorTestEnvironment( 1873 new media::VideoEncodeAcceleratorTestEnvironment(
1815 std::move(test_stream_data), log_path, run_at_fps, 1874 std::move(test_stream_data), log_path, run_at_fps,
1816 needs_encode_latency, verify_all_output))); 1875 needs_encode_latency, verify_all_output)));
1817 1876
1818 return RUN_ALL_TESTS(); 1877 return RUN_ALL_TESTS();
1819 } 1878 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698