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

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: change commit message 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 (timestamp != previous_timestamp_) {
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 // Timestamp needs to avoid starting from 0.
1375 base::TimeDelta().FromMilliseconds((next_input_id_ + 1) *
1344 base::Time::kMillisecondsPerSecond / 1376 base::Time::kMillisecondsPerSecond /
1345 current_framerate_)); 1377 current_framerate_));
1346 EXPECT_NE(nullptr, video_frame.get()); 1378 EXPECT_NE(nullptr, video_frame.get());
1347 return video_frame; 1379 return video_frame;
1348 } 1380 }
1349 1381
1350 scoped_refptr<VideoFrame> VEAClient::PrepareInputFrame(off_t position, 1382 scoped_refptr<VideoFrame> VEAClient::PrepareInputFrame(off_t position,
1351 int32_t* input_id) { 1383 int32_t* input_id) {
1352 CHECK_LE(position + test_stream_->aligned_buffer_size, 1384 CHECK_LE(position + test_stream_->aligned_buffer_size,
1353 test_stream_->aligned_in_file_data.size()); 1385 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. 1420 // we require for bitrate tests.
1389 pos_in_input_stream_ = 0; 1421 pos_in_input_stream_ = 0;
1390 } 1422 }
1391 1423
1392 if (quality_validator_) 1424 if (quality_validator_)
1393 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_)); 1425 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_));
1394 1426
1395 int32_t input_id; 1427 int32_t input_id;
1396 scoped_refptr<VideoFrame> video_frame = 1428 scoped_refptr<VideoFrame> video_frame =
1397 PrepareInputFrame(pos_in_input_stream_, &input_id); 1429 PrepareInputFrame(pos_in_input_stream_, &input_id);
1430 frame_timestamps_.push(video_frame->timestamp());
1398 pos_in_input_stream_ += test_stream_->aligned_buffer_size; 1431 pos_in_input_stream_ += test_stream_->aligned_buffer_size;
1399 1432
1400 bool force_keyframe = false; 1433 bool force_keyframe = false;
1401 if (keyframe_period_ && input_id % keyframe_period_ == 0) { 1434 if (keyframe_period_ && input_id % keyframe_period_ == 0) {
1402 force_keyframe = true; 1435 force_keyframe = true;
1403 ++num_keyframes_requested_; 1436 ++num_keyframes_requested_;
1404 } 1437 }
1405 1438
1406 if (input_id == 0) { 1439 if (input_id == 0) {
1407 first_frame_start_time_ = base::TimeTicks::Now(); 1440 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_, 1514 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_,
1482 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1515 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1483 } 1516 }
1484 } else if (num_encoded_frames_ == num_frames_to_encode_) { 1517 } else if (num_encoded_frames_ == num_frames_to_encode_) {
1485 LogPerf(); 1518 LogPerf();
1486 VerifyMinFPS(); 1519 VerifyMinFPS();
1487 VerifyStreamProperties(); 1520 VerifyStreamProperties();
1488 SetState(CS_FINISHED); 1521 SetState(CS_FINISHED);
1489 if (!quality_validator_) 1522 if (!quality_validator_)
1490 SetState(CS_VALIDATED); 1523 SetState(CS_VALIDATED);
1524 if (verify_output_timestamp_) {
1525 // There may be some timestamps left because we push extra frames to flush
1526 // encoder.
1527 EXPECT_LE(frame_timestamps_.size(),
1528 static_cast<size_t>(next_input_id_ - num_frames_to_encode_));
1529 }
1491 return false; 1530 return false;
1492 } 1531 }
1493 1532
1494 return true; 1533 return true;
1495 } 1534 }
1496 1535
1497 void VEAClient::LogPerf() { 1536 void VEAClient::LogPerf() {
1498 g_env->LogToFile("Measured encoder FPS", 1537 g_env->LogToFile("Measured encoder FPS",
1499 base::StringPrintf("%.3f", frames_per_second())); 1538 base::StringPrintf("%.3f", frames_per_second()));
1500 1539
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 // one input stream; otherwise, one encoder per input stream will be 1619 // one input stream; otherwise, one encoder per input stream will be
1581 // instantiated. 1620 // instantiated.
1582 // - If true, save output to file (provided an output filename was supplied). 1621 // - If true, save output to file (provided an output filename was supplied).
1583 // - Force a keyframe every n frames. 1622 // - Force a keyframe every n frames.
1584 // - Force bitrate; the actual required value is provided as a property 1623 // - Force bitrate; the actual required value is provided as a property
1585 // of the input stream, because it depends on stream type/resolution/etc. 1624 // of the input stream, because it depends on stream type/resolution/etc.
1586 // - If true, measure performance. 1625 // - If true, measure performance.
1587 // - If true, switch bitrate mid-stream. 1626 // - If true, switch bitrate mid-stream.
1588 // - If true, switch framerate mid-stream. 1627 // - If true, switch framerate mid-stream.
1589 // - If true, verify the output frames of encoder. 1628 // - If true, verify the output frames of encoder.
1629 // - If true, verify the timestamps of output frames.
1590 class VideoEncodeAcceleratorTest 1630 class VideoEncodeAcceleratorTest
1591 : public ::testing::TestWithParam< 1631 : public ::testing::TestWithParam<
1592 std::tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; 1632 std::tuple<int, bool, int, bool, bool, bool, bool, bool, bool>> {};
1593 1633
1594 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { 1634 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
1595 size_t num_concurrent_encoders = std::get<0>(GetParam()); 1635 size_t num_concurrent_encoders = std::get<0>(GetParam());
1596 const bool save_to_file = std::get<1>(GetParam()); 1636 const bool save_to_file = std::get<1>(GetParam());
1597 const unsigned int keyframe_period = std::get<2>(GetParam()); 1637 const unsigned int keyframe_period = std::get<2>(GetParam());
1598 const bool force_bitrate = std::get<3>(GetParam()); 1638 const bool force_bitrate = std::get<3>(GetParam());
1599 const bool test_perf = std::get<4>(GetParam()); 1639 const bool test_perf = std::get<4>(GetParam());
1600 const bool mid_stream_bitrate_switch = std::get<5>(GetParam()); 1640 const bool mid_stream_bitrate_switch = std::get<5>(GetParam());
1601 const bool mid_stream_framerate_switch = std::get<6>(GetParam()); 1641 const bool mid_stream_framerate_switch = std::get<6>(GetParam());
1602 const bool verify_output = 1642 const bool verify_output =
1603 std::get<7>(GetParam()) || g_env->verify_all_output(); 1643 std::get<7>(GetParam()) || g_env->verify_all_output();
1644 const bool verify_output_timestamp = std::get<8>(GetParam());
1604 1645
1605 ScopedVector<ClientStateNotification<ClientState>> notes; 1646 ScopedVector<ClientStateNotification<ClientState>> notes;
1606 ScopedVector<VEAClient> clients; 1647 ScopedVector<VEAClient> clients;
1607 base::Thread encoder_thread("EncoderThread"); 1648 base::Thread encoder_thread("EncoderThread");
1608 ASSERT_TRUE(encoder_thread.Start()); 1649 ASSERT_TRUE(encoder_thread.Start());
1609 1650
1610 if (g_env->test_streams_.size() > 1) 1651 if (g_env->test_streams_.size() > 1)
1611 num_concurrent_encoders = g_env->test_streams_.size(); 1652 num_concurrent_encoders = g_env->test_streams_.size();
1612 1653
1613 // Create all encoders. 1654 // Create all encoders.
1614 for (size_t i = 0; i < num_concurrent_encoders; i++) { 1655 for (size_t i = 0; i < num_concurrent_encoders; i++) {
1615 size_t test_stream_index = i % g_env->test_streams_.size(); 1656 size_t test_stream_index = i % g_env->test_streams_.size();
1616 // Disregard save_to_file if we didn't get an output filename. 1657 // Disregard save_to_file if we didn't get an output filename.
1617 bool encoder_save_to_file = 1658 bool encoder_save_to_file =
1618 (save_to_file && 1659 (save_to_file &&
1619 !g_env->test_streams_[test_stream_index]->out_filename.empty()); 1660 !g_env->test_streams_[test_stream_index]->out_filename.empty());
1620 1661
1621 notes.push_back(new ClientStateNotification<ClientState>()); 1662 notes.push_back(new ClientStateNotification<ClientState>());
1622 clients.push_back(new VEAClient( 1663 clients.push_back(new VEAClient(
1623 g_env->test_streams_[test_stream_index], notes.back(), 1664 g_env->test_streams_[test_stream_index], notes.back(),
1624 encoder_save_to_file, keyframe_period, force_bitrate, test_perf, 1665 encoder_save_to_file, keyframe_period, force_bitrate, test_perf,
1625 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output)); 1666 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output,
1667 verify_output_timestamp));
1626 1668
1627 encoder_thread.task_runner()->PostTask( 1669 encoder_thread.task_runner()->PostTask(
1628 FROM_HERE, base::Bind(&VEAClient::CreateEncoder, 1670 FROM_HERE, base::Bind(&VEAClient::CreateEncoder,
1629 base::Unretained(clients.back()))); 1671 base::Unretained(clients.back())));
1630 } 1672 }
1631 1673
1632 // All encoders must pass through states in this order. 1674 // All encoders must pass through states in this order.
1633 enum ClientState state_transitions[] = { 1675 enum ClientState state_transitions[] = {
1634 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; 1676 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED};
1635 1677
(...skipping 18 matching lines...) Expand all
1654 1696
1655 // This ensures all tasks have finished. 1697 // This ensures all tasks have finished.
1656 encoder_thread.Stop(); 1698 encoder_thread.Stop();
1657 } 1699 }
1658 1700
1659 #if !defined(OS_MACOSX) 1701 #if !defined(OS_MACOSX)
1660 INSTANTIATE_TEST_CASE_P( 1702 INSTANTIATE_TEST_CASE_P(
1661 SimpleEncode, 1703 SimpleEncode,
1662 VideoEncodeAcceleratorTest, 1704 VideoEncodeAcceleratorTest,
1663 ::testing::Values( 1705 ::testing::Values(
1664 std::make_tuple(1, true, 0, false, false, false, false, false), 1706 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1665 std::make_tuple(1, true, 0, false, false, false, false, true))); 1707 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1666 1708
1667 INSTANTIATE_TEST_CASE_P( 1709 INSTANTIATE_TEST_CASE_P(
1668 EncoderPerf, 1710 EncoderPerf,
1669 VideoEncodeAcceleratorTest, 1711 VideoEncodeAcceleratorTest,
1670 ::testing::Values( 1712 ::testing::Values(
1671 std::make_tuple(1, false, 0, false, true, false, false, false))); 1713 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1672 1714
1673 INSTANTIATE_TEST_CASE_P( 1715 INSTANTIATE_TEST_CASE_P(ForceKeyframes,
1674 ForceKeyframes, 1716 VideoEncodeAcceleratorTest,
1675 VideoEncodeAcceleratorTest, 1717 ::testing::Values(std::make_tuple(1,
1676 ::testing::Values( 1718 false,
1677 std::make_tuple(1, false, 10, false, false, false, false, false))); 1719 10,
1720 false,
1721 false,
1722 false,
1723 false,
1724 false,
1725 false)));
1678 1726
1679 INSTANTIATE_TEST_CASE_P( 1727 INSTANTIATE_TEST_CASE_P(
1680 ForceBitrate, 1728 ForceBitrate,
1681 VideoEncodeAcceleratorTest, 1729 VideoEncodeAcceleratorTest,
1682 ::testing::Values( 1730 ::testing::Values(
1683 std::make_tuple(1, false, 0, true, false, false, false, false))); 1731 std::make_tuple(1, false, 0, true, false, false, false, false, false)));
1684 1732
1685 INSTANTIATE_TEST_CASE_P( 1733 INSTANTIATE_TEST_CASE_P(
1686 MidStreamParamSwitchBitrate, 1734 MidStreamParamSwitchBitrate,
1687 VideoEncodeAcceleratorTest, 1735 VideoEncodeAcceleratorTest,
1688 ::testing::Values( 1736 ::testing::Values(
1689 std::make_tuple(1, false, 0, true, false, true, false, false))); 1737 std::make_tuple(1, false, 0, true, false, true, false, false, false)));
1690 1738
1691 INSTANTIATE_TEST_CASE_P( 1739 INSTANTIATE_TEST_CASE_P(
1692 MidStreamParamSwitchFPS, 1740 MidStreamParamSwitchFPS,
1693 VideoEncodeAcceleratorTest, 1741 VideoEncodeAcceleratorTest,
1694 ::testing::Values( 1742 ::testing::Values(
1695 std::make_tuple(1, false, 0, true, false, false, true, false))); 1743 std::make_tuple(1, false, 0, true, false, false, true, false, false)));
1696 1744
1697 INSTANTIATE_TEST_CASE_P( 1745 INSTANTIATE_TEST_CASE_P(
1698 MultipleEncoders, 1746 MultipleEncoders,
1699 VideoEncodeAcceleratorTest, 1747 VideoEncodeAcceleratorTest,
1700 ::testing::Values( 1748 ::testing::Values(
1701 std::make_tuple(3, false, 0, false, false, false, false, false), 1749 std::make_tuple(3, false, 0, false, false, false, false, false, false),
1702 std::make_tuple(3, false, 0, true, false, false, true, false), 1750 std::make_tuple(3, false, 0, true, false, false, true, false, false),
1703 std::make_tuple(3, false, 0, true, false, true, false, false))); 1751 std::make_tuple(3, false, 0, true, false, true, false, false, false)));
1752
1753 INSTANTIATE_TEST_CASE_P(
1754 VerifyTimestamp,
1755 VideoEncodeAcceleratorTest,
1756 ::testing::Values(
1757 std::make_tuple(1, true, 0, false, false, false, false, false, true)));
wuchengli 2016/07/12 11:46:13 No need to save the output to a file. std::make_t
shenghao1 2016/07/12 11:49:49 Done.
1758
1704 #else 1759 #else
1705 INSTANTIATE_TEST_CASE_P( 1760 INSTANTIATE_TEST_CASE_P(
1706 SimpleEncode, 1761 SimpleEncode,
1707 VideoEncodeAcceleratorTest, 1762 VideoEncodeAcceleratorTest,
1708 ::testing::Values( 1763 ::testing::Values(
1709 std::make_tuple(1, true, 0, false, false, false, false, false), 1764 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1710 std::make_tuple(1, true, 0, false, false, false, false, true))); 1765 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1711 1766
1712 INSTANTIATE_TEST_CASE_P( 1767 INSTANTIATE_TEST_CASE_P(
1713 EncoderPerf, 1768 EncoderPerf,
1714 VideoEncodeAcceleratorTest, 1769 VideoEncodeAcceleratorTest,
1715 ::testing::Values( 1770 ::testing::Values(
1716 std::make_tuple(1, false, 0, false, true, false, false, false))); 1771 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1717 1772
1718 INSTANTIATE_TEST_CASE_P( 1773 INSTANTIATE_TEST_CASE_P(MultipleEncoders,
1719 MultipleEncoders, 1774 VideoEncodeAcceleratorTest,
1720 VideoEncodeAcceleratorTest, 1775 ::testing::Values(std::make_tuple(3,
1721 ::testing::Values( 1776 false,
1722 std::make_tuple(3, false, 0, false, false, false, false, false))); 1777 0,
1778 false,
1779 false,
1780 false,
1781 false,
1782 false,
1783 false)));
1723 #endif 1784 #endif
1724 1785
1725 // TODO(posciak): more tests: 1786 // TODO(posciak): more tests:
1726 // - async FeedEncoderWithOutput 1787 // - async FeedEncoderWithOutput
1727 // - out-of-order return of outputs to encoder 1788 // - out-of-order return of outputs to encoder
1728 // - multiple encoders + decoders 1789 // - multiple encoders + decoders
1729 // - mid-stream encoder_->Destroy() 1790 // - mid-stream encoder_->Destroy()
1730 1791
1731 } // namespace 1792 } // namespace
1732 } // namespace media 1793 } // namespace media
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 1871
1811 media::g_env = 1872 media::g_env =
1812 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( 1873 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
1813 testing::AddGlobalTestEnvironment( 1874 testing::AddGlobalTestEnvironment(
1814 new media::VideoEncodeAcceleratorTestEnvironment( 1875 new media::VideoEncodeAcceleratorTestEnvironment(
1815 std::move(test_stream_data), log_path, run_at_fps, 1876 std::move(test_stream_data), log_path, run_at_fps,
1816 needs_encode_latency, verify_all_output))); 1877 needs_encode_latency, verify_all_output)));
1817 1878
1818 return RUN_ALL_TESTS(); 1879 return RUN_ALL_TESTS();
1819 } 1880 }
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