Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 } | 196 } |
| 197 | 197 |
| 198 void deallocate(pointer p, size_type n) { | 198 void deallocate(pointer p, size_type n) { |
| 199 base::AlignedFree(static_cast<void*>(p)); | 199 base::AlignedFree(static_cast<void*>(p)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 size_type max_size() const { | 202 size_type max_size() const { |
| 203 return std::numeric_limits<size_t>::max() / sizeof(T); | 203 return std::numeric_limits<size_t>::max() / sizeof(T); |
| 204 } | 204 } |
| 205 }; | 205 }; |
| 206 typedef std::vector<char, AlignedAllocator<char, kPlatformBufferAlignment>> | |
| 207 AlignedCharVector; | |
| 206 | 208 |
| 207 struct TestStream { | 209 struct TestStream { |
| 208 TestStream() | 210 TestStream() |
| 209 : num_frames(0), | 211 : num_frames(0), |
| 210 aligned_buffer_size(0), | 212 aligned_buffer_size(0), |
| 211 requested_bitrate(0), | 213 requested_bitrate(0), |
| 212 requested_framerate(0), | 214 requested_framerate(0), |
| 213 requested_subsequent_bitrate(0), | 215 requested_subsequent_bitrate(0), |
| 214 requested_subsequent_framerate(0) {} | 216 requested_subsequent_framerate(0) {} |
| 215 ~TestStream() {} | 217 ~TestStream() {} |
| 216 | 218 |
| 217 gfx::Size visible_size; | 219 gfx::Size visible_size; |
| 218 gfx::Size coded_size; | 220 gfx::Size coded_size; |
| 219 unsigned int num_frames; | 221 unsigned int num_frames; |
| 220 | 222 |
| 221 // Original unaligned input file name provided as an argument to the test. | 223 // Original unaligned input file name provided as an argument to the test. |
| 222 // And the file must be an I420 (YUV planar) raw stream. | 224 // And the file must be an I420 (YUV planar) raw stream. |
| 223 std::string in_filename; | 225 std::string in_filename; |
| 224 | 226 |
| 225 // A vector used to prepare aligned input buffers of |in_filename|. This | 227 // A vector used to prepare aligned input buffers of |in_filename|. This |
| 226 // makes sure starting addresses of YUV planes are aligned to | 228 // makes sure starting addresses of YUV planes are aligned to |
| 227 // kPlatformBufferAlignment bytes. | 229 // kPlatformBufferAlignment bytes. |
| 228 std::vector<char, AlignedAllocator<char, kPlatformBufferAlignment>> | 230 AlignedCharVector aligned_in_file_data; |
| 229 aligned_in_file_data; | |
| 230 | 231 |
| 231 // Byte size of a frame of |aligned_in_file_data|. | 232 // Byte size of a frame of |aligned_in_file_data|. |
| 232 size_t aligned_buffer_size; | 233 size_t aligned_buffer_size; |
| 233 | 234 |
| 234 // Byte size for each aligned plane of a frame. | 235 // Byte size for each aligned plane of a frame. |
| 235 std::vector<size_t> aligned_plane_size; | 236 std::vector<size_t> aligned_plane_size; |
| 236 | 237 |
| 237 std::string out_filename; | 238 std::string out_filename; |
| 238 VideoCodecProfile requested_profile; | 239 VideoCodecProfile requested_profile; |
| 239 unsigned int requested_bitrate; | 240 unsigned int requested_bitrate; |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 } | 868 } |
| 868 } | 869 } |
| 869 } | 870 } |
| 870 | 871 |
| 871 // Divide the difference by the size of frame. | 872 // Divide the difference by the size of frame. |
| 872 difference /= VideoFrame::AllocationSize(kInputFormat, visible_size); | 873 difference /= VideoFrame::AllocationSize(kInputFormat, visible_size); |
| 873 EXPECT_TRUE(difference <= kDecodeSimilarityThreshold) | 874 EXPECT_TRUE(difference <= kDecodeSimilarityThreshold) |
| 874 << "difference = " << difference << " > decode similarity threshold"; | 875 << "difference = " << difference << " > decode similarity threshold"; |
| 875 } | 876 } |
| 876 | 877 |
| 877 class VEAClient : public VideoEncodeAccelerator::Client { | 878 // Base class for VEAClient's |
|
wuchengli
2016/11/29 07:14:47
s/VEAClient's/all VEA clients in this file/
I fee
hywu1
2016/11/29 08:42:22
Done.
| |
| 879 class VEAClientBase : public VideoEncodeAccelerator::Client { | |
| 880 public: | |
| 881 void NotifyError(VideoEncodeAccelerator::Error error) override { | |
| 882 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 883 SetState(CS_ERROR); | |
| 884 } | |
| 885 | |
| 886 protected: | |
| 887 VEAClientBase(ClientStateNotification<ClientState>* note) | |
| 888 : note_(note), next_output_buffer_id_(0) {} | |
| 889 | |
| 890 bool has_encoder() { return encoder_.get(); } | |
| 891 | |
| 892 virtual void SetState(ClientState new_state) = 0; | |
| 893 | |
| 894 std::unique_ptr<VideoEncodeAccelerator> encoder_; | |
| 895 | |
| 896 // Used to notify another thread about the state. VEAClientBase does not own | |
| 897 // this. | |
| 898 ClientStateNotification<ClientState>* note_; | |
| 899 | |
| 900 // All methods of this class should be run on the same thread. | |
| 901 base::ThreadChecker thread_checker_; | |
| 902 | |
| 903 ScopedVector<base::SharedMemory> output_shms_; | |
| 904 int32_t next_output_buffer_id_; | |
| 905 }; | |
| 906 | |
| 907 class VEAClient : public VEAClientBase { | |
| 878 public: | 908 public: |
| 879 VEAClient(TestStream* test_stream, | 909 VEAClient(TestStream* test_stream, |
| 880 ClientStateNotification<ClientState>* note, | 910 ClientStateNotification<ClientState>* note, |
| 881 bool save_to_file, | 911 bool save_to_file, |
| 882 unsigned int keyframe_period, | 912 unsigned int keyframe_period, |
| 883 bool force_bitrate, | 913 bool force_bitrate, |
| 884 bool test_perf, | 914 bool test_perf, |
| 885 bool mid_stream_bitrate_switch, | 915 bool mid_stream_bitrate_switch, |
| 886 bool mid_stream_framerate_switch, | 916 bool mid_stream_framerate_switch, |
| 887 bool verify_output, | 917 bool verify_output, |
| 888 bool verify_output_timestamp); | 918 bool verify_output_timestamp); |
| 889 ~VEAClient() override; | 919 ~VEAClient() override; |
| 890 void CreateEncoder(); | 920 void CreateEncoder(); |
| 891 void DestroyEncoder(); | 921 void DestroyEncoder(); |
| 892 | 922 |
| 893 void TryToSetupEncodeOnSeperateThread(); | 923 void TryToSetupEncodeOnSeperateThread(); |
| 894 void DestroyEncodeOnSeperateThread(); | 924 void DestroyEncodeOnSeperateThread(); |
| 895 | 925 |
| 896 // VideoDecodeAccelerator::Client implementation. | 926 // VideoDecodeAccelerator::Client implementation. |
| 897 void RequireBitstreamBuffers(unsigned int input_count, | 927 void RequireBitstreamBuffers(unsigned int input_count, |
| 898 const gfx::Size& input_coded_size, | 928 const gfx::Size& input_coded_size, |
| 899 size_t output_buffer_size) override; | 929 size_t output_buffer_size) override; |
| 900 void BitstreamBufferReady(int32_t bitstream_buffer_id, | 930 void BitstreamBufferReady(int32_t bitstream_buffer_id, |
| 901 size_t payload_size, | 931 size_t payload_size, |
| 902 bool key_frame, | 932 bool key_frame, |
| 903 base::TimeDelta timestamp) override; | 933 base::TimeDelta timestamp) override; |
| 904 void NotifyError(VideoEncodeAccelerator::Error error) override; | |
| 905 | 934 |
| 906 private: | 935 private: |
| 907 void BitstreamBufferReadyOnMainThread(int32_t bitstream_buffer_id, | 936 void BitstreamBufferReadyOnMainThread(int32_t bitstream_buffer_id, |
| 908 size_t payload_size, | 937 size_t payload_size, |
| 909 bool key_frame, | 938 bool key_frame, |
| 910 base::TimeDelta timestamp); | 939 base::TimeDelta timestamp); |
| 911 bool has_encoder() { return encoder_.get(); } | |
| 912 | 940 |
| 913 // Return the number of encoded frames per second. | 941 // Return the number of encoded frames per second. |
| 914 double frames_per_second(); | 942 double frames_per_second(); |
| 915 | 943 |
| 916 void SetState(ClientState new_state); | 944 void SetState(ClientState new_state) override; |
| 917 | 945 |
| 918 // Set current stream parameters to given |bitrate| at |framerate|. | 946 // Set current stream parameters to given |bitrate| at |framerate|. |
| 919 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); | 947 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); |
| 920 | 948 |
| 921 // Called when encoder is done with a VideoFrame. | 949 // Called when encoder is done with a VideoFrame. |
| 922 void InputNoLongerNeededCallback(int32_t input_id); | 950 void InputNoLongerNeededCallback(int32_t input_id); |
| 923 | 951 |
| 924 // Feed the encoder with one input frame. | 952 // Feed the encoder with one input frame. |
| 925 void FeedEncoderWithOneInput(); | 953 void FeedEncoderWithOneInput(); |
| 926 | 954 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 // Called when the quality validator has decoded all the frames. | 999 // Called when the quality validator has decoded all the frames. |
| 972 void DecodeCompleted(); | 1000 void DecodeCompleted(); |
| 973 | 1001 |
| 974 // Called when the quality validator fails to decode a frame. | 1002 // Called when the quality validator fails to decode a frame. |
| 975 void DecodeFailed(); | 1003 void DecodeFailed(); |
| 976 | 1004 |
| 977 // Verify that the output timestamp matches input timestamp. | 1005 // Verify that the output timestamp matches input timestamp. |
| 978 void VerifyOutputTimestamp(base::TimeDelta timestamp); | 1006 void VerifyOutputTimestamp(base::TimeDelta timestamp); |
| 979 | 1007 |
| 980 ClientState state_; | 1008 ClientState state_; |
| 981 std::unique_ptr<VideoEncodeAccelerator> encoder_; | |
| 982 | 1009 |
| 983 TestStream* test_stream_; | 1010 TestStream* test_stream_; |
| 984 | 1011 |
| 985 // Used to notify another thread about the state. VEAClient does not own this. | |
| 986 ClientStateNotification<ClientState>* note_; | |
| 987 | |
| 988 // Ids assigned to VideoFrames. | 1012 // Ids assigned to VideoFrames. |
| 989 std::set<int32_t> inputs_at_client_; | 1013 std::set<int32_t> inputs_at_client_; |
| 990 int32_t next_input_id_; | 1014 int32_t next_input_id_; |
| 991 | 1015 |
| 992 // Encode start time of all encoded frames. The position in the vector is the | 1016 // Encode start time of all encoded frames. The position in the vector is the |
| 993 // frame input id. | 1017 // frame input id. |
| 994 std::vector<base::TimeTicks> encode_start_time_; | 1018 std::vector<base::TimeTicks> encode_start_time_; |
| 995 // The encode latencies of all encoded frames. We define encode latency as the | 1019 // The encode latencies of all encoded frames. We define encode latency as the |
| 996 // time delay from input of each VideoFrame (VEA::Encode()) to output of the | 1020 // time delay from input of each VideoFrame (VEA::Encode()) to output of the |
| 997 // corresponding BitstreamBuffer (VEA::Client::BitstreamBufferReady()). | 1021 // corresponding BitstreamBuffer (VEA::Client::BitstreamBufferReady()). |
| 998 std::vector<base::TimeDelta> encode_latencies_; | 1022 std::vector<base::TimeDelta> encode_latencies_; |
| 999 | 1023 |
| 1000 // Ids for output BitstreamBuffers. | 1024 // Ids for output BitstreamBuffers. |
| 1001 typedef std::map<int32_t, base::SharedMemory*> IdToSHM; | 1025 typedef std::map<int32_t, base::SharedMemory*> IdToSHM; |
| 1002 ScopedVector<base::SharedMemory> output_shms_; | |
| 1003 IdToSHM output_buffers_at_client_; | 1026 IdToSHM output_buffers_at_client_; |
| 1004 int32_t next_output_buffer_id_; | |
| 1005 | 1027 |
| 1006 // Current offset into input stream. | 1028 // Current offset into input stream. |
| 1007 off_t pos_in_input_stream_; | 1029 off_t pos_in_input_stream_; |
| 1008 gfx::Size input_coded_size_; | 1030 gfx::Size input_coded_size_; |
| 1009 // Requested by encoder. | 1031 // Requested by encoder. |
| 1010 unsigned int num_required_input_buffers_; | 1032 unsigned int num_required_input_buffers_; |
| 1011 size_t output_buffer_size_; | 1033 size_t output_buffer_size_; |
| 1012 | 1034 |
| 1013 // Number of frames to encode. This may differ from the number of frames in | 1035 // Number of frames to encode. This may differ from the number of frames in |
| 1014 // stream if we need more frames for bitrate tests. | 1036 // stream if we need more frames for bitrate tests. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1062 | 1084 |
| 1063 // Used to validate the encoded frame quality. | 1085 // Used to validate the encoded frame quality. |
| 1064 std::unique_ptr<VideoFrameQualityValidator> quality_validator_; | 1086 std::unique_ptr<VideoFrameQualityValidator> quality_validator_; |
| 1065 | 1087 |
| 1066 // The time when the first frame is submitted for encode. | 1088 // The time when the first frame is submitted for encode. |
| 1067 base::TimeTicks first_frame_start_time_; | 1089 base::TimeTicks first_frame_start_time_; |
| 1068 | 1090 |
| 1069 // The time when the last encoded frame is ready. | 1091 // The time when the last encoded frame is ready. |
| 1070 base::TimeTicks last_frame_ready_time_; | 1092 base::TimeTicks last_frame_ready_time_; |
| 1071 | 1093 |
| 1072 // All methods of this class should be run on the same thread. | |
| 1073 base::ThreadChecker thread_checker_; | |
| 1074 | |
| 1075 // Requested bitrate in bits per second. | 1094 // Requested bitrate in bits per second. |
| 1076 unsigned int requested_bitrate_; | 1095 unsigned int requested_bitrate_; |
| 1077 | 1096 |
| 1078 // Requested initial framerate. | 1097 // Requested initial framerate. |
| 1079 unsigned int requested_framerate_; | 1098 unsigned int requested_framerate_; |
| 1080 | 1099 |
| 1081 // Bitrate to switch to in the middle of the stream. | 1100 // Bitrate to switch to in the middle of the stream. |
| 1082 unsigned int requested_subsequent_bitrate_; | 1101 unsigned int requested_subsequent_bitrate_; |
| 1083 | 1102 |
| 1084 // Framerate to switch to in the middle of the stream. | 1103 // Framerate to switch to in the middle of the stream. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1115 VEAClient::VEAClient(TestStream* test_stream, | 1134 VEAClient::VEAClient(TestStream* test_stream, |
| 1116 ClientStateNotification<ClientState>* note, | 1135 ClientStateNotification<ClientState>* note, |
| 1117 bool save_to_file, | 1136 bool save_to_file, |
| 1118 unsigned int keyframe_period, | 1137 unsigned int keyframe_period, |
| 1119 bool force_bitrate, | 1138 bool force_bitrate, |
| 1120 bool test_perf, | 1139 bool test_perf, |
| 1121 bool mid_stream_bitrate_switch, | 1140 bool mid_stream_bitrate_switch, |
| 1122 bool mid_stream_framerate_switch, | 1141 bool mid_stream_framerate_switch, |
| 1123 bool verify_output, | 1142 bool verify_output, |
| 1124 bool verify_output_timestamp) | 1143 bool verify_output_timestamp) |
| 1125 : state_(CS_CREATED), | 1144 : VEAClientBase(note), |
| 1145 state_(CS_CREATED), | |
| 1126 test_stream_(test_stream), | 1146 test_stream_(test_stream), |
| 1127 note_(note), | |
| 1128 next_input_id_(0), | 1147 next_input_id_(0), |
| 1129 next_output_buffer_id_(0), | |
| 1130 pos_in_input_stream_(0), | 1148 pos_in_input_stream_(0), |
| 1131 num_required_input_buffers_(0), | 1149 num_required_input_buffers_(0), |
| 1132 output_buffer_size_(0), | 1150 output_buffer_size_(0), |
| 1133 num_frames_to_encode_(0), | 1151 num_frames_to_encode_(0), |
| 1134 num_encoded_frames_(0), | 1152 num_encoded_frames_(0), |
| 1135 num_frames_since_last_check_(0), | 1153 num_frames_since_last_check_(0), |
| 1136 seen_keyframe_in_this_buffer_(false), | 1154 seen_keyframe_in_this_buffer_(false), |
| 1137 save_to_file_(save_to_file), | 1155 save_to_file_(save_to_file), |
| 1138 keyframe_period_(keyframe_period), | 1156 keyframe_period_(keyframe_period), |
| 1139 num_keyframes_requested_(0), | 1157 num_keyframes_requested_(0), |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1397 size_t payload_size, | 1415 size_t payload_size, |
| 1398 bool key_frame, | 1416 bool key_frame, |
| 1399 base::TimeDelta timestamp) { | 1417 base::TimeDelta timestamp) { |
| 1400 ASSERT_TRUE(encode_task_runner_->BelongsToCurrentThread()); | 1418 ASSERT_TRUE(encode_task_runner_->BelongsToCurrentThread()); |
| 1401 main_thread_task_runner_->PostTask( | 1419 main_thread_task_runner_->PostTask( |
| 1402 FROM_HERE, base::Bind(&VEAClient::BitstreamBufferReadyOnMainThread, | 1420 FROM_HERE, base::Bind(&VEAClient::BitstreamBufferReadyOnMainThread, |
| 1403 base::Unretained(this), bitstream_buffer_id, | 1421 base::Unretained(this), bitstream_buffer_id, |
| 1404 payload_size, key_frame, timestamp)); | 1422 payload_size, key_frame, timestamp)); |
| 1405 } | 1423 } |
| 1406 | 1424 |
| 1407 void VEAClient::NotifyError(VideoEncodeAccelerator::Error error) { | |
| 1408 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1409 SetState(CS_ERROR); | |
| 1410 } | |
| 1411 | |
| 1412 void VEAClient::BitstreamBufferReadyOnMainThread(int32_t bitstream_buffer_id, | 1425 void VEAClient::BitstreamBufferReadyOnMainThread(int32_t bitstream_buffer_id, |
| 1413 size_t payload_size, | 1426 size_t payload_size, |
| 1414 bool key_frame, | 1427 bool key_frame, |
| 1415 base::TimeDelta timestamp) { | 1428 base::TimeDelta timestamp) { |
| 1416 DCHECK(thread_checker_.CalledOnValidThread()); | 1429 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1417 | 1430 |
| 1418 ASSERT_LE(payload_size, output_buffer_size_); | 1431 ASSERT_LE(payload_size, output_buffer_size_); |
| 1419 | 1432 |
| 1420 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id); | 1433 IdToSHM::iterator it = output_buffers_at_client_.find(bitstream_buffer_id); |
| 1421 ASSERT_NE(it, output_buffers_at_client_.end()); | 1434 ASSERT_NE(it, output_buffers_at_client_.end()); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1752 IvfFrameHeader header = {}; | 1765 IvfFrameHeader header = {}; |
| 1753 | 1766 |
| 1754 header.frame_size = static_cast<uint32_t>(frame_size); | 1767 header.frame_size = static_cast<uint32_t>(frame_size); |
| 1755 header.timestamp = frame_index; | 1768 header.timestamp = frame_index; |
| 1756 header.ByteSwap(); | 1769 header.ByteSwap(); |
| 1757 EXPECT_TRUE(base::AppendToFile( | 1770 EXPECT_TRUE(base::AppendToFile( |
| 1758 base::FilePath::FromUTF8Unsafe(test_stream_->out_filename), | 1771 base::FilePath::FromUTF8Unsafe(test_stream_->out_filename), |
| 1759 reinterpret_cast<char*>(&header), sizeof(header))); | 1772 reinterpret_cast<char*>(&header), sizeof(header))); |
| 1760 } | 1773 } |
| 1761 | 1774 |
| 1762 // This client is only used to make sure the encoder does not return an encoded | 1775 // Base class for simple VEAClient's |
|
wuchengli
2016/11/29 07:14:47
s/VEAClient's/VEA clients/
hywu1
2016/11/29 08:42:22
Done.
| |
| 1763 // frame before getting any input. | 1776 class SimpleVEAClientBase : public VEAClientBase { |
| 1764 class VEANoInputClient : public VideoEncodeAccelerator::Client { | |
| 1765 public: | 1777 public: |
| 1766 explicit VEANoInputClient(ClientStateNotification<ClientState>* note); | |
| 1767 ~VEANoInputClient() override; | |
| 1768 void CreateEncoder(); | 1778 void CreateEncoder(); |
| 1769 void DestroyEncoder(); | 1779 void DestroyEncoder(); |
| 1770 | 1780 |
| 1771 // VideoDecodeAccelerator::Client implementation. | 1781 // VideoDecodeAccelerator::Client implementation. |
| 1772 void RequireBitstreamBuffers(unsigned int input_count, | 1782 void RequireBitstreamBuffers(unsigned int input_count, |
| 1773 const gfx::Size& input_coded_size, | 1783 const gfx::Size& input_coded_size, |
| 1774 size_t output_buffer_size) override; | 1784 size_t output_buffer_size) override; |
| 1775 void BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 1776 size_t payload_size, | |
| 1777 bool key_frame, | |
| 1778 base::TimeDelta timestamp) override; | |
| 1779 void NotifyError(VideoEncodeAccelerator::Error error) override; | |
| 1780 | 1785 |
| 1781 private: | 1786 protected: |
| 1782 bool has_encoder() { return encoder_.get(); } | 1787 SimpleVEAClientBase(ClientStateNotification<ClientState>* note, |
| 1788 const int width, | |
| 1789 const int height); | |
| 1783 | 1790 |
| 1784 void SetState(ClientState new_state); | 1791 void SetState(ClientState new_state) override; |
| 1785 | 1792 |
| 1786 // Provide the encoder with a new output buffer. | 1793 // Provide the encoder with a new output buffer. |
| 1787 void FeedEncoderWithOutput(base::SharedMemory* shm, size_t output_size); | 1794 void FeedEncoderWithOutput(base::SharedMemory* shm, size_t output_size); |
| 1788 | 1795 |
| 1789 std::unique_ptr<VideoEncodeAccelerator> encoder_; | 1796 const int width_; |
| 1790 | 1797 const int height_; |
| 1791 // Used to notify another thread about the state. VEAClient does not own this. | 1798 const int bitrate_; |
| 1792 ClientStateNotification<ClientState>* note_; | 1799 const int fps_; |
| 1793 | |
| 1794 // All methods of this class should be run on the same thread. | |
| 1795 base::ThreadChecker thread_checker_; | |
| 1796 | |
| 1797 // Ids for output BitstreamBuffers. | |
| 1798 ScopedVector<base::SharedMemory> output_shms_; | |
| 1799 int32_t next_output_buffer_id_; | |
| 1800 | |
| 1801 // The timer used to monitor the encoder doesn't return an output buffer in | |
| 1802 // a period of time. | |
| 1803 std::unique_ptr<base::Timer> timer_; | |
| 1804 }; | 1800 }; |
| 1805 | 1801 |
| 1806 VEANoInputClient::VEANoInputClient(ClientStateNotification<ClientState>* note) | 1802 SimpleVEAClientBase::SimpleVEAClientBase( |
| 1807 : note_(note), next_output_buffer_id_(0) { | 1803 ClientStateNotification<ClientState>* note, |
| 1804 const int width, | |
| 1805 const int height) | |
| 1806 : VEAClientBase(note), | |
| 1807 width_(width), | |
| 1808 height_(height), | |
| 1809 bitrate_(200000), | |
| 1810 fps_(30) { | |
| 1808 thread_checker_.DetachFromThread(); | 1811 thread_checker_.DetachFromThread(); |
| 1809 } | 1812 } |
| 1810 | 1813 |
| 1811 VEANoInputClient::~VEANoInputClient() { | 1814 void SimpleVEAClientBase::CreateEncoder() { |
| 1812 LOG_ASSERT(!has_encoder()); | |
| 1813 } | |
| 1814 | |
| 1815 void VEANoInputClient::CreateEncoder() { | |
| 1816 DCHECK(thread_checker_.CalledOnValidThread()); | 1815 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1817 LOG_ASSERT(!has_encoder()); | 1816 LOG_ASSERT(!has_encoder()); |
| 1818 LOG_ASSERT(g_env->test_streams_.size()); | 1817 LOG_ASSERT(g_env->test_streams_.size()); |
| 1819 | 1818 |
| 1820 const int kDefaultWidth = 320; | |
| 1821 const int kDefaultHeight = 240; | |
| 1822 const int kDefaultBitrate = 200000; | |
| 1823 const int kDefaultFps = 30; | |
| 1824 | |
| 1825 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { | 1819 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { |
| 1826 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), | 1820 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), |
| 1827 CreateMFVEA()}; | 1821 CreateMFVEA()}; |
| 1828 | 1822 |
| 1829 // The test case is no input. Use default visible size, bitrate, and fps. | 1823 gfx::Size visible_size(width_, height_); |
| 1830 gfx::Size visible_size(kDefaultWidth, kDefaultHeight); | |
| 1831 for (auto& encoder : encoders) { | 1824 for (auto& encoder : encoders) { |
| 1832 if (!encoder) | 1825 if (!encoder) |
| 1833 continue; | 1826 continue; |
| 1834 encoder_ = std::move(encoder); | 1827 encoder_ = std::move(encoder); |
| 1835 if (encoder_->Initialize(kInputFormat, visible_size, | 1828 if (encoder_->Initialize(kInputFormat, visible_size, |
| 1836 g_env->test_streams_[0]->requested_profile, | 1829 g_env->test_streams_[0]->requested_profile, |
| 1837 kDefaultBitrate, this)) { | 1830 bitrate_, this)) { |
| 1838 encoder_->RequestEncodingParametersChange(kDefaultBitrate, kDefaultFps); | 1831 encoder_->RequestEncodingParametersChange(bitrate_, fps_); |
| 1839 SetState(CS_INITIALIZED); | 1832 SetState(CS_INITIALIZED); |
| 1840 return; | 1833 return; |
| 1841 } | 1834 } |
| 1842 } | 1835 } |
| 1843 encoder_.reset(); | 1836 encoder_.reset(); |
| 1844 LOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed"; | 1837 LOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed"; |
| 1845 SetState(CS_ERROR); | 1838 SetState(CS_ERROR); |
| 1846 } | 1839 } |
| 1847 | 1840 |
| 1848 void VEANoInputClient::DestroyEncoder() { | 1841 void SimpleVEAClientBase::DestroyEncoder() { |
| 1849 DCHECK(thread_checker_.CalledOnValidThread()); | 1842 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1850 if (!has_encoder()) | 1843 if (!has_encoder()) |
| 1851 return; | 1844 return; |
| 1852 // Clear the objects that should be destroyed on the same thread as creation. | 1845 // Clear the objects that should be destroyed on the same thread as creation. |
| 1853 encoder_.reset(); | 1846 encoder_.reset(); |
| 1854 timer_.reset(); | |
| 1855 } | 1847 } |
| 1856 | 1848 |
| 1857 void VEANoInputClient::RequireBitstreamBuffers( | 1849 void SimpleVEAClientBase::SetState(ClientState new_state) { |
| 1850 DVLOG(4) << "Changing state to " << new_state; | |
| 1851 note_->Notify(new_state); | |
| 1852 } | |
| 1853 | |
| 1854 void SimpleVEAClientBase::RequireBitstreamBuffers( | |
| 1858 unsigned int input_count, | 1855 unsigned int input_count, |
| 1859 const gfx::Size& input_coded_size, | 1856 const gfx::Size& input_coded_size, |
| 1860 size_t output_size) { | 1857 size_t output_size) { |
| 1861 DCHECK(thread_checker_.CalledOnValidThread()); | 1858 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1862 SetState(CS_ENCODING); | 1859 SetState(CS_ENCODING); |
| 1863 ASSERT_GT(output_size, 0UL); | 1860 ASSERT_GT(output_size, 0UL); |
| 1864 | 1861 |
| 1865 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { | 1862 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { |
| 1866 base::SharedMemory* shm = new base::SharedMemory(); | 1863 base::SharedMemory* shm = new base::SharedMemory(); |
| 1867 LOG_ASSERT(shm->CreateAndMapAnonymous(output_size)); | 1864 LOG_ASSERT(shm->CreateAndMapAnonymous(output_size)); |
| 1868 output_shms_.push_back(shm); | 1865 output_shms_.push_back(shm); |
| 1869 FeedEncoderWithOutput(shm, output_size); | 1866 FeedEncoderWithOutput(shm, output_size); |
| 1870 } | 1867 } |
| 1868 } | |
| 1869 | |
| 1870 void SimpleVEAClientBase::FeedEncoderWithOutput(base::SharedMemory* shm, | |
| 1871 size_t output_size) { | |
| 1872 if (!has_encoder()) | |
| 1873 return; | |
| 1874 | |
| 1875 base::SharedMemoryHandle dup_handle; | |
| 1876 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); | |
| 1877 | |
| 1878 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, | |
| 1879 output_size); | |
| 1880 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); | |
| 1881 } | |
| 1882 | |
| 1883 // This client is only used to make sure the encoder does not return an encoded | |
| 1884 // frame before getting any input. | |
| 1885 class VEANoInputClient : public SimpleVEAClientBase { | |
| 1886 public: | |
| 1887 explicit VEANoInputClient(ClientStateNotification<ClientState>* note); | |
| 1888 ~VEANoInputClient() override; | |
| 1889 void DestroyEncoder(); | |
| 1890 | |
| 1891 // VideoDecodeAccelerator::Client implementation. | |
| 1892 void RequireBitstreamBuffers(unsigned int input_count, | |
| 1893 const gfx::Size& input_coded_size, | |
| 1894 size_t output_buffer_size) override; | |
| 1895 void BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 1896 size_t payload_size, | |
| 1897 bool key_frame, | |
| 1898 base::TimeDelta timestamp) override; | |
| 1899 | |
| 1900 private: | |
| 1901 // The timer used to monitor the encoder doesn't return an output buffer in | |
| 1902 // a period of time. | |
| 1903 std::unique_ptr<base::Timer> timer_; | |
| 1904 }; | |
| 1905 | |
| 1906 VEANoInputClient::VEANoInputClient(ClientStateNotification<ClientState>* note) | |
| 1907 : SimpleVEAClientBase(note, 320, 240) {} | |
| 1908 | |
| 1909 VEANoInputClient::~VEANoInputClient() { | |
| 1910 LOG_ASSERT(!has_encoder()); | |
|
wuchengli
2016/11/29 07:14:47
Can we move this to ~VEAClientBase()? Same for lin
hywu1
2016/11/29 08:42:22
Done.
| |
| 1911 } | |
| 1912 | |
| 1913 void VEANoInputClient::DestroyEncoder() { | |
| 1914 SimpleVEAClientBase::DestroyEncoder(); | |
| 1915 // Clear the objects that should be destroyed on the same thread as creation. | |
| 1916 encoder_.reset(); | |
|
wuchengli
2016/11/29 07:14:46
encoder_.reset(); is already done in SimpleVEAClie
hywu1
2016/11/29 08:42:22
Fixed. It is to free the timer: timer_.reset()
| |
| 1917 } | |
| 1918 | |
| 1919 void VEANoInputClient::RequireBitstreamBuffers( | |
| 1920 unsigned int input_count, | |
| 1921 const gfx::Size& input_coded_size, | |
| 1922 size_t output_size) { | |
| 1923 SimpleVEAClientBase::RequireBitstreamBuffers(input_count, input_coded_size, | |
| 1924 output_size); | |
| 1925 | |
| 1871 // Timer is used to make sure there is no output frame in 100ms. | 1926 // Timer is used to make sure there is no output frame in 100ms. |
| 1872 timer_.reset(new base::Timer(FROM_HERE, | 1927 timer_.reset(new base::Timer(FROM_HERE, |
| 1873 base::TimeDelta::FromMilliseconds(100), | 1928 base::TimeDelta::FromMilliseconds(100), |
| 1874 base::Bind(&VEANoInputClient::SetState, | 1929 base::Bind(&VEANoInputClient::SetState, |
| 1875 base::Unretained(this), CS_FINISHED), | 1930 base::Unretained(this), CS_FINISHED), |
| 1876 false)); | 1931 false)); |
| 1877 timer_->Reset(); | 1932 timer_->Reset(); |
| 1878 } | 1933 } |
| 1879 | 1934 |
| 1880 void VEANoInputClient::BitstreamBufferReady(int32_t bitstream_buffer_id, | 1935 void VEANoInputClient::BitstreamBufferReady(int32_t bitstream_buffer_id, |
| 1881 size_t payload_size, | 1936 size_t payload_size, |
| 1882 bool key_frame, | 1937 bool key_frame, |
| 1883 base::TimeDelta timestamp) { | 1938 base::TimeDelta timestamp) { |
| 1884 DCHECK(thread_checker_.CalledOnValidThread()); | 1939 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1885 SetState(CS_ERROR); | 1940 SetState(CS_ERROR); |
| 1886 } | 1941 } |
| 1887 | 1942 |
| 1888 void VEANoInputClient::NotifyError(VideoEncodeAccelerator::Error error) { | 1943 // This client is only used to test input frame with the size of U and V planes |
| 1889 DCHECK(thread_checker_.CalledOnValidThread()); | 1944 // unaligned to cache line. |
| 1890 SetState(CS_ERROR); | 1945 // To have both width and height divisible by 16 but not 32 will make the size |
| 1946 // of U/V plane (width * height / 4) unaligned to 128-byte cache line. | |
| 1947 class VEACacheLineUnalignedInputClient : public SimpleVEAClientBase { | |
| 1948 public: | |
| 1949 explicit VEACacheLineUnalignedInputClient( | |
| 1950 ClientStateNotification<ClientState>* note); | |
| 1951 ~VEACacheLineUnalignedInputClient() override; | |
| 1952 | |
| 1953 // VideoDecodeAccelerator::Client implementation. | |
| 1954 void RequireBitstreamBuffers(unsigned int input_count, | |
| 1955 const gfx::Size& input_coded_size, | |
| 1956 size_t output_buffer_size) override; | |
| 1957 void BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 1958 size_t payload_size, | |
| 1959 bool key_frame, | |
| 1960 base::TimeDelta timestamp) override; | |
| 1961 | |
| 1962 private: | |
| 1963 // Feed the encoder with one input frame. | |
| 1964 void FeedEncoderWithOneInput(const gfx::Size& input_coded_size); | |
| 1965 }; | |
| 1966 | |
| 1967 VEACacheLineUnalignedInputClient::VEACacheLineUnalignedInputClient( | |
| 1968 ClientStateNotification<ClientState>* note) | |
| 1969 : SimpleVEAClientBase(note, 368, 368) { | |
| 1970 } // 368 is divisible by 16 but not 32 | |
| 1971 | |
| 1972 VEACacheLineUnalignedInputClient::~VEACacheLineUnalignedInputClient() { | |
| 1973 LOG_ASSERT(!has_encoder()); | |
| 1891 } | 1974 } |
| 1892 | 1975 |
| 1893 void VEANoInputClient::SetState(ClientState new_state) { | 1976 void VEACacheLineUnalignedInputClient::RequireBitstreamBuffers( |
| 1894 DVLOG(4) << "Changing state to " << new_state; | 1977 unsigned int input_count, |
| 1895 note_->Notify(new_state); | 1978 const gfx::Size& input_coded_size, |
| 1979 size_t output_size) { | |
| 1980 SimpleVEAClientBase::RequireBitstreamBuffers(input_count, input_coded_size, | |
| 1981 output_size); | |
| 1982 | |
| 1983 FeedEncoderWithOneInput(input_coded_size); | |
| 1896 } | 1984 } |
| 1897 | 1985 |
| 1898 void VEANoInputClient::FeedEncoderWithOutput(base::SharedMemory* shm, | 1986 void VEACacheLineUnalignedInputClient::BitstreamBufferReady( |
| 1899 size_t output_size) { | 1987 int32_t bitstream_buffer_id, |
| 1988 size_t payload_size, | |
| 1989 bool key_frame, | |
| 1990 base::TimeDelta timestamp) { | |
| 1991 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1992 // It's enough to encode just one frame. If plane size is not aligned, | |
| 1993 // VideoEncodeAccelerator::Encode will fail. | |
| 1994 SetState(CS_FINISHED); | |
| 1995 } | |
| 1996 | |
| 1997 void VEACacheLineUnalignedInputClient::FeedEncoderWithOneInput( | |
| 1998 const gfx::Size& input_coded_size) { | |
| 1900 if (!has_encoder()) | 1999 if (!has_encoder()) |
| 1901 return; | 2000 return; |
| 1902 | 2001 |
| 1903 base::SharedMemoryHandle dup_handle; | 2002 AlignedCharVector aligned_plane[] = { |
| 1904 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); | 2003 AlignedCharVector( |
| 2004 VideoFrame::PlaneSize(kInputFormat, 0, input_coded_size).GetArea()), | |
| 2005 AlignedCharVector( | |
| 2006 VideoFrame::PlaneSize(kInputFormat, 1, input_coded_size).GetArea()), | |
| 2007 AlignedCharVector( | |
| 2008 VideoFrame::PlaneSize(kInputFormat, 2, input_coded_size).GetArea())}; | |
| 2009 uint8_t* frame_data_y = reinterpret_cast<uint8_t*>(&aligned_plane[0][0]); | |
| 2010 uint8_t* frame_data_u = reinterpret_cast<uint8_t*>(&aligned_plane[1][0]); | |
| 2011 uint8_t* frame_data_v = reinterpret_cast<uint8_t*>(&aligned_plane[2][0]); | |
| 1905 | 2012 |
| 1906 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, | 2013 scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapExternalYuvData( |
| 1907 output_size); | 2014 kInputFormat, input_coded_size, gfx::Rect(input_coded_size), |
| 1908 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); | 2015 input_coded_size, input_coded_size.width(), input_coded_size.width() / 2, |
| 2016 input_coded_size.width() / 2, frame_data_y, frame_data_u, frame_data_v, | |
| 2017 base::TimeDelta().FromMilliseconds(base::Time::kMillisecondsPerSecond / | |
| 2018 fps_)); | |
| 2019 | |
| 2020 encoder_->Encode(video_frame, false); | |
| 1909 } | 2021 } |
| 1910 | 2022 |
| 1911 // Test parameters: | 2023 // Test parameters: |
| 1912 // - Number of concurrent encoders. The value takes effect when there is only | 2024 // - Number of concurrent encoders. The value takes effect when there is only |
| 1913 // one input stream; otherwise, one encoder per input stream will be | 2025 // one input stream; otherwise, one encoder per input stream will be |
| 1914 // instantiated. | 2026 // instantiated. |
| 1915 // - If true, save output to file (provided an output filename was supplied). | 2027 // - If true, save output to file (provided an output filename was supplied). |
| 1916 // - Force a keyframe every n frames. | 2028 // - Force a keyframe every n frames. |
| 1917 // - Force bitrate; the actual required value is provided as a property | 2029 // - Force bitrate; the actual required value is provided as a property |
| 1918 // of the input stream, because it depends on stream type/resolution/etc. | 2030 // of the input stream, because it depends on stream type/resolution/etc. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1984 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 2096 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
| 1985 encoder_thread.task_runner()->PostTask( | 2097 encoder_thread.task_runner()->PostTask( |
| 1986 FROM_HERE, | 2098 FROM_HERE, |
| 1987 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 2099 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
| 1988 } | 2100 } |
| 1989 | 2101 |
| 1990 // This ensures all tasks have finished. | 2102 // This ensures all tasks have finished. |
| 1991 encoder_thread.Stop(); | 2103 encoder_thread.Stop(); |
| 1992 } | 2104 } |
| 1993 | 2105 |
| 2106 // Test parameters: | |
| 2107 // - Test type | |
| 2108 // 0: No input test | |
| 2109 // 1: Cache line-unaligned test | |
| 2110 class VideoEncodeAcceleratorSimpleTest : public ::testing::TestWithParam<int> { | |
| 2111 }; | |
| 2112 | |
| 2113 template <class TestClient> | |
| 2114 void SimpleTestFunc() { | |
| 2115 std::unique_ptr<ClientStateNotification<ClientState>> note( | |
| 2116 new ClientStateNotification<ClientState>()); | |
| 2117 std::unique_ptr<TestClient> client(new TestClient(note.get())); | |
| 2118 base::Thread encoder_thread("EncoderThread"); | |
| 2119 ASSERT_TRUE(encoder_thread.Start()); | |
| 2120 | |
| 2121 encoder_thread.task_runner()->PostTask( | |
| 2122 FROM_HERE, | |
| 2123 base::Bind(&TestClient::CreateEncoder, base::Unretained(client.get()))); | |
| 2124 | |
| 2125 // Encoder must pass through states in this order. | |
| 2126 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, | |
| 2127 CS_FINISHED}; | |
| 2128 | |
| 2129 for (const auto& state : state_transitions) { | |
| 2130 EXPECT_EQ(state, note->Wait()); | |
| 2131 } | |
| 2132 | |
| 2133 encoder_thread.task_runner()->PostTask( | |
| 2134 FROM_HERE, | |
| 2135 base::Bind(&TestClient::DestroyEncoder, base::Unretained(client.get()))); | |
| 2136 | |
| 2137 // This ensures all tasks have finished. | |
| 2138 encoder_thread.Stop(); | |
| 2139 } | |
| 2140 | |
| 2141 TEST_P(VideoEncodeAcceleratorSimpleTest, TestSimpleEncode) { | |
| 2142 const int test_type = GetParam(); | |
| 2143 | |
| 2144 if (test_type == 0) | |
| 2145 SimpleTestFunc<VEANoInputClient>(); | |
| 2146 else if (test_type == 1) | |
| 2147 SimpleTestFunc<VEACacheLineUnalignedInputClient>(); | |
|
wuchengli
2016/11/29 07:14:46
else
ASSERT(0) << "Invalid test type=" << test_t
hywu1
2016/11/29 08:42:22
Done.
| |
| 2148 } | |
| 2149 | |
| 1994 #if defined(OS_CHROMEOS) | 2150 #if defined(OS_CHROMEOS) |
| 1995 INSTANTIATE_TEST_CASE_P( | 2151 INSTANTIATE_TEST_CASE_P( |
| 1996 SimpleEncode, | 2152 SimpleEncode, |
| 1997 VideoEncodeAcceleratorTest, | 2153 VideoEncodeAcceleratorTest, |
| 1998 ::testing::Values( | 2154 ::testing::Values( |
| 1999 std::make_tuple(1, true, 0, false, false, false, false, false, false), | 2155 std::make_tuple(1, true, 0, false, false, false, false, false, false), |
| 2000 std::make_tuple(1, true, 0, false, false, false, false, true, false))); | 2156 std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| 2001 | 2157 |
| 2002 INSTANTIATE_TEST_CASE_P( | 2158 INSTANTIATE_TEST_CASE_P( |
| 2003 EncoderPerf, | 2159 EncoderPerf, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2042 std::make_tuple(3, false, 0, false, false, false, false, false, false), | 2198 std::make_tuple(3, false, 0, false, false, false, false, false, false), |
| 2043 std::make_tuple(3, false, 0, true, false, false, true, false, false), | 2199 std::make_tuple(3, false, 0, true, false, false, true, false, false), |
| 2044 std::make_tuple(3, false, 0, true, false, true, false, false, false))); | 2200 std::make_tuple(3, false, 0, true, false, true, false, false, false))); |
| 2045 | 2201 |
| 2046 INSTANTIATE_TEST_CASE_P( | 2202 INSTANTIATE_TEST_CASE_P( |
| 2047 VerifyTimestamp, | 2203 VerifyTimestamp, |
| 2048 VideoEncodeAcceleratorTest, | 2204 VideoEncodeAcceleratorTest, |
| 2049 ::testing::Values( | 2205 ::testing::Values( |
| 2050 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | 2206 std::make_tuple(1, false, 0, false, false, false, false, false, true))); |
| 2051 | 2207 |
| 2052 TEST(VEANoInputTest, CheckOutput) { | 2208 INSTANTIATE_TEST_CASE_P(NoInputTest, |
| 2053 std::unique_ptr<ClientStateNotification<ClientState>> note( | 2209 VideoEncodeAcceleratorSimpleTest, |
| 2054 new ClientStateNotification<ClientState>()); | 2210 ::testing::Values(0)); |
| 2055 std::unique_ptr<VEANoInputClient> client(new VEANoInputClient(note.get())); | |
| 2056 base::Thread encoder_thread("EncoderThread"); | |
| 2057 ASSERT_TRUE(encoder_thread.Start()); | |
| 2058 | 2211 |
| 2059 encoder_thread.task_runner()->PostTask( | 2212 INSTANTIATE_TEST_CASE_P(CacheLineUnalignedInputTest, |
| 2060 FROM_HERE, base::Bind(&VEANoInputClient::CreateEncoder, | 2213 VideoEncodeAcceleratorSimpleTest, |
| 2061 base::Unretained(client.get()))); | 2214 ::testing::Values(1)); |
| 2062 | |
| 2063 // Encoder must pass through states in this order. | |
| 2064 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, | |
| 2065 CS_FINISHED}; | |
| 2066 | |
| 2067 for (const auto& state : state_transitions) { | |
| 2068 ASSERT_EQ(state, note->Wait()); | |
| 2069 } | |
| 2070 | |
| 2071 encoder_thread.task_runner()->PostTask( | |
| 2072 FROM_HERE, base::Bind(&VEANoInputClient::DestroyEncoder, | |
| 2073 base::Unretained(client.get()))); | |
| 2074 | |
| 2075 // This ensures all tasks have finished. | |
| 2076 encoder_thread.Stop(); | |
| 2077 } | |
| 2078 | 2215 |
| 2079 #elif defined(OS_MACOSX) || defined(OS_WIN) | 2216 #elif defined(OS_MACOSX) || defined(OS_WIN) |
| 2080 INSTANTIATE_TEST_CASE_P( | 2217 INSTANTIATE_TEST_CASE_P( |
| 2081 SimpleEncode, | 2218 SimpleEncode, |
| 2082 VideoEncodeAcceleratorTest, | 2219 VideoEncodeAcceleratorTest, |
| 2083 ::testing::Values( | 2220 ::testing::Values( |
| 2084 std::make_tuple(1, true, 0, false, false, false, false, false, false), | 2221 std::make_tuple(1, true, 0, false, false, false, false, false, false), |
| 2085 std::make_tuple(1, true, 0, false, false, false, false, true, false))); | 2222 std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| 2086 | 2223 |
| 2087 INSTANTIATE_TEST_CASE_P( | 2224 INSTANTIATE_TEST_CASE_P( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2199 | 2336 |
| 2200 media::g_env = | 2337 media::g_env = |
| 2201 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2338 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 2202 testing::AddGlobalTestEnvironment( | 2339 testing::AddGlobalTestEnvironment( |
| 2203 new media::VideoEncodeAcceleratorTestEnvironment( | 2340 new media::VideoEncodeAcceleratorTestEnvironment( |
| 2204 std::move(test_stream_data), log_path, run_at_fps, | 2341 std::move(test_stream_data), log_path, run_at_fps, |
| 2205 needs_encode_latency, verify_all_output))); | 2342 needs_encode_latency, verify_all_output))); |
| 2206 | 2343 |
| 2207 return RUN_ALL_TESTS(); | 2344 return RUN_ALL_TESTS(); |
| 2208 } | 2345 } |
| OLD | NEW |