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

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: Address Wucheng's comments 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 // Whether the input stream position has been rewinded.
1000 bool input_pos_rewinded;
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),
1040 input_pos_rewinded(false) {
1025 if (keyframe_period_) 1041 if (keyframe_period_)
1026 LOG_ASSERT(kMaxKeyframeDelay < keyframe_period_); 1042 LOG_ASSERT(kMaxKeyframeDelay < keyframe_period_);
1027 1043
1028 // Fake encoder produces an invalid stream, so skip validating it. 1044 // Fake encoder produces an invalid stream, so skip validating it.
1029 if (!g_fake_encoder) { 1045 if (!g_fake_encoder) {
1030 stream_validator_ = StreamValidator::Create( 1046 stream_validator_ = StreamValidator::Create(
1031 test_stream_->requested_profile, 1047 test_stream_->requested_profile,
1032 base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this))); 1048 base::Bind(&VEAClient::HandleEncodedFrame, base::Unretained(this)));
1033 CHECK(stream_validator_); 1049 CHECK(stream_validator_);
1034 } 1050 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 input_timer_->Start( 1253 input_timer_->Start(
1238 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_, 1254 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_,
1239 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1255 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1240 } else { 1256 } else {
1241 while (inputs_at_client_.size() < 1257 while (inputs_at_client_.size() <
1242 num_required_input_buffers_ + kNumExtraInputFrames) 1258 num_required_input_buffers_ + kNumExtraInputFrames)
1243 FeedEncoderWithOneInput(); 1259 FeedEncoderWithOneInput();
1244 } 1260 }
1245 } 1261 }
1246 1262
1263 void VEAClient::VerifyOutputTimestamp(base::TimeDelta timestamp) {
1264 ASSERT_TRUE(!frame_timestamps_.empty());
1265
1266 // One input frame may be mapped to multiple output frames, so the current
1267 // timestamp should be equal to one of the top two elements in
1268 // frame_timestamps_.
1269 if (timestamp != frame_timestamps_.front()) {
1270 frame_timestamps_.pop();
1271 ASSERT_TRUE(!frame_timestamps_.empty());
1272 EXPECT_EQ(frame_timestamps_.front(), timestamp);
1273 }
1274 }
1275
1247 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id, 1276 void VEAClient::BitstreamBufferReady(int32_t bitstream_buffer_id,
1248 size_t payload_size, 1277 size_t payload_size,
1249 bool key_frame, 1278 bool key_frame,
1250 base::TimeDelta timestamp) { 1279 base::TimeDelta timestamp) {
1251 DCHECK(thread_checker_.CalledOnValidThread()); 1280 DCHECK(thread_checker_.CalledOnValidThread());
1252 ASSERT_LE(payload_size, output_buffer_size_); 1281 ASSERT_LE(payload_size, output_buffer_size_);
1253 1282
1254 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id); 1283 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id);
1255 ASSERT_NE(it, output_buffers_at_client_.end()); 1284 ASSERT_NE(it, output_buffers_at_client_.end());
1256 base::SharedMemory* shm = it->second; 1285 base::SharedMemory* shm = it->second;
1257 output_buffers_at_client_.erase(it); 1286 output_buffers_at_client_.erase(it);
1258 1287
1259 if (state_ == CS_FINISHED || state_ == CS_VALIDATED) 1288 if (state_ == CS_FINISHED || state_ == CS_VALIDATED)
1260 return; 1289 return;
1261 1290
1291 if (verify_output_timestamp_) {
1292 VerifyOutputTimestamp(timestamp);
1293 }
1294
1262 encoded_stream_size_since_last_check_ += payload_size; 1295 encoded_stream_size_since_last_check_ += payload_size;
1263 1296
1264 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory()); 1297 const uint8_t* stream_ptr = static_cast<const uint8_t*>(shm->memory());
1265 if (payload_size > 0) { 1298 if (payload_size > 0) {
1266 if (stream_validator_) { 1299 if (stream_validator_) {
1267 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size); 1300 stream_validator_->ProcessStreamBuffer(stream_ptr, payload_size);
1268 } else { 1301 } else {
1269 HandleEncodedFrame(key_frame); 1302 HandleEncodedFrame(key_frame);
1270 } 1303 }
1271 1304
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 1413
1381 size_t bytes_left = 1414 size_t bytes_left =
1382 test_stream_->aligned_in_file_data.size() - pos_in_input_stream_; 1415 test_stream_->aligned_in_file_data.size() - pos_in_input_stream_;
1383 if (bytes_left < test_stream_->aligned_buffer_size) { 1416 if (bytes_left < test_stream_->aligned_buffer_size) {
1384 DCHECK_EQ(bytes_left, 0UL); 1417 DCHECK_EQ(bytes_left, 0UL);
1385 // Rewind if at the end of stream and we are still encoding. 1418 // Rewind if at the end of stream and we are still encoding.
1386 // This is to flush the encoder with additional frames from the beginning 1419 // This is to flush the encoder with additional frames from the beginning
1387 // of the stream, or if the stream is shorter that the number of frames 1420 // of the stream, or if the stream is shorter that the number of frames
1388 // we require for bitrate tests. 1421 // we require for bitrate tests.
1389 pos_in_input_stream_ = 0; 1422 pos_in_input_stream_ = 0;
1423 input_pos_rewinded = true;
1390 } 1424 }
1391 1425
1392 if (quality_validator_) 1426 if (quality_validator_)
1393 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_)); 1427 quality_validator_->AddOriginalFrame(CreateFrame(pos_in_input_stream_));
1394 1428
1395 int32_t input_id; 1429 int32_t input_id;
1396 scoped_refptr<VideoFrame> video_frame = 1430 scoped_refptr<VideoFrame> video_frame =
1397 PrepareInputFrame(pos_in_input_stream_, &input_id); 1431 PrepareInputFrame(pos_in_input_stream_, &input_id);
1432 if (!input_pos_rewinded) {
1433 frame_timestamps_.push(video_frame->timestamp());
wuchengli 2016/07/12 05:56:56 We should always push the timestamps. We can use |
shenghao1 2016/07/12 07:40:53 Done.
1434 }
1398 pos_in_input_stream_ += test_stream_->aligned_buffer_size; 1435 pos_in_input_stream_ += test_stream_->aligned_buffer_size;
1399 1436
1400 bool force_keyframe = false; 1437 bool force_keyframe = false;
1401 if (keyframe_period_ && input_id % keyframe_period_ == 0) { 1438 if (keyframe_period_ && input_id % keyframe_period_ == 0) {
1402 force_keyframe = true; 1439 force_keyframe = true;
1403 ++num_keyframes_requested_; 1440 ++num_keyframes_requested_;
1404 } 1441 }
1405 1442
1406 if (input_id == 0) { 1443 if (input_id == 0) {
1407 first_frame_start_time_ = base::TimeTicks::Now(); 1444 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_, 1518 FROM_HERE, base::TimeDelta::FromSeconds(1) / current_framerate_,
1482 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this))); 1519 base::Bind(&VEAClient::OnInputTimer, base::Unretained(this)));
1483 } 1520 }
1484 } else if (num_encoded_frames_ == num_frames_to_encode_) { 1521 } else if (num_encoded_frames_ == num_frames_to_encode_) {
1485 LogPerf(); 1522 LogPerf();
1486 VerifyMinFPS(); 1523 VerifyMinFPS();
1487 VerifyStreamProperties(); 1524 VerifyStreamProperties();
1488 SetState(CS_FINISHED); 1525 SetState(CS_FINISHED);
1489 if (!quality_validator_) 1526 if (!quality_validator_)
1490 SetState(CS_VALIDATED); 1527 SetState(CS_VALIDATED);
1528 if (verify_output_timestamp_) {
1529 // The last timestamp in |frame_timestamps_| won't be popped out.
1530 EXPECT_LE(frame_timestamps_.size(), static_cast<size_t>(1));
wuchengli 2016/07/12 05:56:56 The driver will pass if they don't return the last
shenghao1 2016/07/12 07:40:53 Done.
1531 }
1491 return false; 1532 return false;
1492 } 1533 }
1493 1534
1494 return true; 1535 return true;
1495 } 1536 }
1496 1537
1497 void VEAClient::LogPerf() { 1538 void VEAClient::LogPerf() {
1498 g_env->LogToFile("Measured encoder FPS", 1539 g_env->LogToFile("Measured encoder FPS",
1499 base::StringPrintf("%.3f", frames_per_second())); 1540 base::StringPrintf("%.3f", frames_per_second()));
1500 1541
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 // one input stream; otherwise, one encoder per input stream will be 1621 // one input stream; otherwise, one encoder per input stream will be
1581 // instantiated. 1622 // instantiated.
1582 // - If true, save output to file (provided an output filename was supplied). 1623 // - If true, save output to file (provided an output filename was supplied).
1583 // - Force a keyframe every n frames. 1624 // - Force a keyframe every n frames.
1584 // - Force bitrate; the actual required value is provided as a property 1625 // - Force bitrate; the actual required value is provided as a property
1585 // of the input stream, because it depends on stream type/resolution/etc. 1626 // of the input stream, because it depends on stream type/resolution/etc.
1586 // - If true, measure performance. 1627 // - If true, measure performance.
1587 // - If true, switch bitrate mid-stream. 1628 // - If true, switch bitrate mid-stream.
1588 // - If true, switch framerate mid-stream. 1629 // - If true, switch framerate mid-stream.
1589 // - If true, verify the output frames of encoder. 1630 // - If true, verify the output frames of encoder.
1631 // - If true, verify the timestamps of output frames.
1590 class VideoEncodeAcceleratorTest 1632 class VideoEncodeAcceleratorTest
1591 : public ::testing::TestWithParam< 1633 : public ::testing::TestWithParam<
1592 std::tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; 1634 std::tuple<int, bool, int, bool, bool, bool, bool, bool, bool>> {};
1593 1635
1594 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { 1636 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) {
1595 size_t num_concurrent_encoders = std::get<0>(GetParam()); 1637 size_t num_concurrent_encoders = std::get<0>(GetParam());
1596 const bool save_to_file = std::get<1>(GetParam()); 1638 const bool save_to_file = std::get<1>(GetParam());
1597 const unsigned int keyframe_period = std::get<2>(GetParam()); 1639 const unsigned int keyframe_period = std::get<2>(GetParam());
1598 const bool force_bitrate = std::get<3>(GetParam()); 1640 const bool force_bitrate = std::get<3>(GetParam());
1599 const bool test_perf = std::get<4>(GetParam()); 1641 const bool test_perf = std::get<4>(GetParam());
1600 const bool mid_stream_bitrate_switch = std::get<5>(GetParam()); 1642 const bool mid_stream_bitrate_switch = std::get<5>(GetParam());
1601 const bool mid_stream_framerate_switch = std::get<6>(GetParam()); 1643 const bool mid_stream_framerate_switch = std::get<6>(GetParam());
1602 const bool verify_output = 1644 const bool verify_output =
1603 std::get<7>(GetParam()) || g_env->verify_all_output(); 1645 std::get<7>(GetParam()) || g_env->verify_all_output();
1646 const bool verify_output_timestamp = std::get<8>(GetParam());
1604 1647
1605 ScopedVector<ClientStateNotification<ClientState>> notes; 1648 ScopedVector<ClientStateNotification<ClientState>> notes;
1606 ScopedVector<VEAClient> clients; 1649 ScopedVector<VEAClient> clients;
1607 base::Thread encoder_thread("EncoderThread"); 1650 base::Thread encoder_thread("EncoderThread");
1608 ASSERT_TRUE(encoder_thread.Start()); 1651 ASSERT_TRUE(encoder_thread.Start());
1609 1652
1610 if (g_env->test_streams_.size() > 1) 1653 if (g_env->test_streams_.size() > 1)
1611 num_concurrent_encoders = g_env->test_streams_.size(); 1654 num_concurrent_encoders = g_env->test_streams_.size();
1612 1655
1613 // Create all encoders. 1656 // Create all encoders.
1614 for (size_t i = 0; i < num_concurrent_encoders; i++) { 1657 for (size_t i = 0; i < num_concurrent_encoders; i++) {
1615 size_t test_stream_index = i % g_env->test_streams_.size(); 1658 size_t test_stream_index = i % g_env->test_streams_.size();
1616 // Disregard save_to_file if we didn't get an output filename. 1659 // Disregard save_to_file if we didn't get an output filename.
1617 bool encoder_save_to_file = 1660 bool encoder_save_to_file =
1618 (save_to_file && 1661 (save_to_file &&
1619 !g_env->test_streams_[test_stream_index]->out_filename.empty()); 1662 !g_env->test_streams_[test_stream_index]->out_filename.empty());
1620 1663
1621 notes.push_back(new ClientStateNotification<ClientState>()); 1664 notes.push_back(new ClientStateNotification<ClientState>());
1622 clients.push_back(new VEAClient( 1665 clients.push_back(new VEAClient(
1623 g_env->test_streams_[test_stream_index], notes.back(), 1666 g_env->test_streams_[test_stream_index], notes.back(),
1624 encoder_save_to_file, keyframe_period, force_bitrate, test_perf, 1667 encoder_save_to_file, keyframe_period, force_bitrate, test_perf,
1625 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output)); 1668 mid_stream_bitrate_switch, mid_stream_framerate_switch, verify_output,
1669 verify_output_timestamp));
1626 1670
1627 encoder_thread.task_runner()->PostTask( 1671 encoder_thread.task_runner()->PostTask(
1628 FROM_HERE, base::Bind(&VEAClient::CreateEncoder, 1672 FROM_HERE, base::Bind(&VEAClient::CreateEncoder,
1629 base::Unretained(clients.back()))); 1673 base::Unretained(clients.back())));
1630 } 1674 }
1631 1675
1632 // All encoders must pass through states in this order. 1676 // All encoders must pass through states in this order.
1633 enum ClientState state_transitions[] = { 1677 enum ClientState state_transitions[] = {
1634 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; 1678 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED};
1635 1679
(...skipping 18 matching lines...) Expand all
1654 1698
1655 // This ensures all tasks have finished. 1699 // This ensures all tasks have finished.
1656 encoder_thread.Stop(); 1700 encoder_thread.Stop();
1657 } 1701 }
1658 1702
1659 #if !defined(OS_MACOSX) 1703 #if !defined(OS_MACOSX)
1660 INSTANTIATE_TEST_CASE_P( 1704 INSTANTIATE_TEST_CASE_P(
1661 SimpleEncode, 1705 SimpleEncode,
1662 VideoEncodeAcceleratorTest, 1706 VideoEncodeAcceleratorTest,
1663 ::testing::Values( 1707 ::testing::Values(
1664 std::make_tuple(1, true, 0, false, false, false, false, false), 1708 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1665 std::make_tuple(1, true, 0, false, false, false, false, true))); 1709 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1666 1710
1667 INSTANTIATE_TEST_CASE_P( 1711 INSTANTIATE_TEST_CASE_P(
1668 EncoderPerf, 1712 EncoderPerf,
1669 VideoEncodeAcceleratorTest, 1713 VideoEncodeAcceleratorTest,
1670 ::testing::Values( 1714 ::testing::Values(
1671 std::make_tuple(1, false, 0, false, true, false, false, false))); 1715 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1672 1716
1673 INSTANTIATE_TEST_CASE_P( 1717 INSTANTIATE_TEST_CASE_P(ForceKeyframes,
1674 ForceKeyframes, 1718 VideoEncodeAcceleratorTest,
1675 VideoEncodeAcceleratorTest, 1719 ::testing::Values(std::make_tuple(1,
1676 ::testing::Values( 1720 false,
1677 std::make_tuple(1, false, 10, false, false, false, false, false))); 1721 10,
1722 false,
1723 false,
1724 false,
1725 false,
1726 false,
1727 false)));
1678 1728
1679 INSTANTIATE_TEST_CASE_P( 1729 INSTANTIATE_TEST_CASE_P(
1680 ForceBitrate, 1730 ForceBitrate,
1681 VideoEncodeAcceleratorTest, 1731 VideoEncodeAcceleratorTest,
1682 ::testing::Values( 1732 ::testing::Values(
1683 std::make_tuple(1, false, 0, true, false, false, false, false))); 1733 std::make_tuple(1, false, 0, true, false, false, false, false, false)));
1684 1734
1685 INSTANTIATE_TEST_CASE_P( 1735 INSTANTIATE_TEST_CASE_P(
1686 MidStreamParamSwitchBitrate, 1736 MidStreamParamSwitchBitrate,
1687 VideoEncodeAcceleratorTest, 1737 VideoEncodeAcceleratorTest,
1688 ::testing::Values( 1738 ::testing::Values(
1689 std::make_tuple(1, false, 0, true, false, true, false, false))); 1739 std::make_tuple(1, false, 0, true, false, true, false, false, false)));
1690 1740
1691 INSTANTIATE_TEST_CASE_P( 1741 INSTANTIATE_TEST_CASE_P(
1692 MidStreamParamSwitchFPS, 1742 MidStreamParamSwitchFPS,
1693 VideoEncodeAcceleratorTest, 1743 VideoEncodeAcceleratorTest,
1694 ::testing::Values( 1744 ::testing::Values(
1695 std::make_tuple(1, false, 0, true, false, false, true, false))); 1745 std::make_tuple(1, false, 0, true, false, false, true, false, false)));
1696 1746
1697 INSTANTIATE_TEST_CASE_P( 1747 INSTANTIATE_TEST_CASE_P(
1698 MultipleEncoders, 1748 MultipleEncoders,
1699 VideoEncodeAcceleratorTest, 1749 VideoEncodeAcceleratorTest,
1700 ::testing::Values( 1750 ::testing::Values(
1701 std::make_tuple(3, false, 0, false, false, false, false, false), 1751 std::make_tuple(3, false, 0, false, false, false, false, false, false),
1702 std::make_tuple(3, false, 0, true, false, false, true, false), 1752 std::make_tuple(3, false, 0, true, false, false, true, false, false),
1703 std::make_tuple(3, false, 0, true, false, true, false, false))); 1753 std::make_tuple(3, false, 0, true, false, true, false, false, false)));
1754
1755 INSTANTIATE_TEST_CASE_P(
1756 VerifyTimestamp,
1757 VideoEncodeAcceleratorTest,
1758 ::testing::Values(
1759 std::make_tuple(1, true, 0, false, false, false, false, false, true)));
1760
1704 #else 1761 #else
1705 INSTANTIATE_TEST_CASE_P( 1762 INSTANTIATE_TEST_CASE_P(
1706 SimpleEncode, 1763 SimpleEncode,
1707 VideoEncodeAcceleratorTest, 1764 VideoEncodeAcceleratorTest,
1708 ::testing::Values( 1765 ::testing::Values(
1709 std::make_tuple(1, true, 0, false, false, false, false, false), 1766 std::make_tuple(1, true, 0, false, false, false, false, false, false),
1710 std::make_tuple(1, true, 0, false, false, false, false, true))); 1767 std::make_tuple(1, true, 0, false, false, false, false, true, false)));
1711 1768
1712 INSTANTIATE_TEST_CASE_P( 1769 INSTANTIATE_TEST_CASE_P(
1713 EncoderPerf, 1770 EncoderPerf,
1714 VideoEncodeAcceleratorTest, 1771 VideoEncodeAcceleratorTest,
1715 ::testing::Values( 1772 ::testing::Values(
1716 std::make_tuple(1, false, 0, false, true, false, false, false))); 1773 std::make_tuple(1, false, 0, false, true, false, false, false, false)));
1717 1774
1718 INSTANTIATE_TEST_CASE_P( 1775 INSTANTIATE_TEST_CASE_P(MultipleEncoders,
1719 MultipleEncoders, 1776 VideoEncodeAcceleratorTest,
1720 VideoEncodeAcceleratorTest, 1777 ::testing::Values(std::make_tuple(3,
1721 ::testing::Values( 1778 false,
1722 std::make_tuple(3, false, 0, false, false, false, false, false))); 1779 0,
1780 false,
1781 false,
1782 false,
1783 false,
1784 false,
1785 false)));
1723 #endif 1786 #endif
1724 1787
1725 // TODO(posciak): more tests: 1788 // TODO(posciak): more tests:
1726 // - async FeedEncoderWithOutput 1789 // - async FeedEncoderWithOutput
1727 // - out-of-order return of outputs to encoder 1790 // - out-of-order return of outputs to encoder
1728 // - multiple encoders + decoders 1791 // - multiple encoders + decoders
1729 // - mid-stream encoder_->Destroy() 1792 // - mid-stream encoder_->Destroy()
1730 1793
1731 } // namespace 1794 } // namespace
1732 } // namespace media 1795 } // namespace media
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 1873
1811 media::g_env = 1874 media::g_env =
1812 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( 1875 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>(
1813 testing::AddGlobalTestEnvironment( 1876 testing::AddGlobalTestEnvironment(
1814 new media::VideoEncodeAcceleratorTestEnvironment( 1877 new media::VideoEncodeAcceleratorTestEnvironment(
1815 std::move(test_stream_data), log_path, run_at_fps, 1878 std::move(test_stream_data), log_path, run_at_fps,
1816 needs_encode_latency, verify_all_output))); 1879 needs_encode_latency, verify_all_output)));
1817 1880
1818 return RUN_ALL_TESTS(); 1881 return RUN_ALL_TESTS();
1819 } 1882 }
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