OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
8 // Win/EGL. | 8 // Win/EGL. |
9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 base::SPLIT_WANT_ALL); | 199 base::SPLIT_WANT_ALL); |
200 // Check these are legitimate MD5s. | 200 // Check these are legitimate MD5s. |
201 for (const std::string& md5_string : *md5_strings) { | 201 for (const std::string& md5_string : *md5_strings) { |
202 // Ignore the empty string added by SplitString | 202 // Ignore the empty string added by SplitString |
203 if (!md5_string.length()) | 203 if (!md5_string.length()) |
204 continue; | 204 continue; |
205 // Ignore comments | 205 // Ignore comments |
206 if (md5_string.at(0) == '#') | 206 if (md5_string.at(0) == '#') |
207 continue; | 207 continue; |
208 | 208 |
209 LOG_ASSERT(static_cast<int>(md5_string.length()) == kMD5StringLength) | 209 LOG_IF(ERROR, static_cast<int>(md5_string.length()) != kMD5StringLength) |
210 << md5_string; | 210 << "MD5 length error: " << md5_string; |
211 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), | 211 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), |
212 isxdigit) == kMD5StringLength; | 212 isxdigit) == kMD5StringLength; |
213 LOG_ASSERT(hex_only) << md5_string; | 213 LOG_IF(ERROR, !hex_only) << "MD5 includes non-hex char: " << md5_string; |
214 } | 214 } |
215 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" | 215 LOG_IF(ERROR, md5_strings->empty()) << " MD5 checksum file (" |
216 << filepath.MaybeAsASCII() | 216 << filepath.MaybeAsASCII() |
217 << ") missing or empty."; | 217 << ") missing or empty."; |
218 } | 218 } |
219 | 219 |
220 // State of the GLRenderingVDAClient below. Order matters here as the test | 220 // State of the GLRenderingVDAClient below. Order matters here as the test |
221 // makes assumptions about it. | 221 // makes assumptions about it. |
222 enum ClientState { | 222 enum ClientState { |
223 CS_CREATED = 0, | 223 CS_CREATED = 0, |
224 CS_DECODER_SET = 1, | 224 CS_DECODER_SET = 1, |
225 CS_INITIALIZED = 2, | 225 CS_INITIALIZED = 2, |
226 CS_FLUSHING = 3, | 226 CS_FLUSHING = 3, |
227 CS_FLUSHED = 4, | 227 CS_FLUSHED = 4, |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 } | 775 } |
776 | 776 |
777 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { | 777 void GLRenderingVDAClient::ReturnPicture(int32_t picture_buffer_id) { |
778 if (decoder_deleted()) | 778 if (decoder_deleted()) |
779 return; | 779 return; |
780 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); | 780 LOG_ASSERT(1U == pending_textures_.erase(picture_buffer_id)); |
781 | 781 |
782 if (pending_textures_.empty() && state_ == CS_RESETTING) { | 782 if (pending_textures_.empty() && state_ == CS_RESETTING) { |
783 SetState(CS_RESET); | 783 SetState(CS_RESET); |
784 DeleteDecoder(); | 784 DeleteDecoder(); |
785 // Cascade through the rest of the states to simplify test code below. | |
786 for (int i = state_ + 1; i < CS_MAX; ++i) | |
787 SetState(static_cast<ClientState>(i)); | |
785 return; | 788 return; |
786 } | 789 } |
787 | 790 |
788 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { | 791 if (num_decoded_frames_ > delay_reuse_after_frame_num_) { |
789 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 792 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
790 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 793 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, |
791 weak_vda_, picture_buffer_id), | 794 weak_vda_, picture_buffer_id), |
792 kReuseDelay); | 795 kReuseDelay); |
793 } else { | 796 } else { |
794 decoder_->ReusePictureBuffer(picture_buffer_id); | 797 decoder_->ReusePictureBuffer(picture_buffer_id); |
795 } | 798 } |
796 } | 799 } |
797 | 800 |
798 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 801 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
799 int32_t bitstream_buffer_id) { | 802 int32_t bitstream_buffer_id) { |
803 if (decoder_deleted()) | |
804 return; | |
805 | |
800 // TODO(fischman): this test currently relies on this notification to make | 806 // TODO(fischman): this test currently relies on this notification to make |
801 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 807 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
802 // guarantee this, so stop relying on it (and remove the notifications from | 808 // guarantee this, so stop relying on it (and remove the notifications from |
803 // VaapiVideoDecodeAccelerator::FinishReset()). | 809 // VaapiVideoDecodeAccelerator::FinishReset()). |
804 ++num_done_bitstream_buffers_; | 810 ++num_done_bitstream_buffers_; |
805 --outstanding_decodes_; | 811 --outstanding_decodes_; |
806 | 812 |
807 // Flush decoder after all BitstreamBuffers are processed. | 813 // Flush decoder after all BitstreamBuffers are processed. |
808 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 814 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
809 // TODO(owenlin): We should not have to check the number of | 815 // TODO(owenlin): We should not have to check the number of |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 encoded_data_next_pos_to_decode_ = 0; | 856 encoded_data_next_pos_to_decode_ = 0; |
851 FinishInitialization(); | 857 FinishInitialization(); |
852 return; | 858 return; |
853 } | 859 } |
854 | 860 |
855 rendering_helper_->Flush(window_id_); | 861 rendering_helper_->Flush(window_id_); |
856 | 862 |
857 if (pending_textures_.empty()) { | 863 if (pending_textures_.empty()) { |
858 SetState(CS_RESET); | 864 SetState(CS_RESET); |
859 DeleteDecoder(); | 865 DeleteDecoder(); |
866 // Cascade through the rest of the states to simplify test code below. | |
867 for (int i = state_ + 1; i < CS_MAX; ++i) | |
868 SetState(static_cast<ClientState>(i)); | |
860 } | 869 } |
861 } | 870 } |
862 | 871 |
863 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { | 872 void GLRenderingVDAClient::NotifyError(VideoDecodeAccelerator::Error error) { |
864 SetState(CS_ERROR); | 873 SetState(CS_ERROR); |
865 } | 874 } |
866 | 875 |
867 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { | 876 void GLRenderingVDAClient::OutputFrameDeliveryTimes(base::File* output) { |
868 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", | 877 std::string s = base::StringPrintf("frame count: %" PRIuS "\n", |
869 frame_delivery_times_.size()); | 878 frame_delivery_times_.size()); |
(...skipping 11 matching lines...) Expand all Loading... | |
881 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 && | 890 return encoded[pos] == 0 && encoded[pos + 1] == 0 && encoded[pos + 2] == 0 && |
882 encoded[pos + 3] == 1; | 891 encoded[pos + 3] == 1; |
883 } | 892 } |
884 | 893 |
885 void GLRenderingVDAClient::SetState(ClientState new_state) { | 894 void GLRenderingVDAClient::SetState(ClientState new_state) { |
886 note_->Notify(new_state); | 895 note_->Notify(new_state); |
887 state_ = new_state; | 896 state_ = new_state; |
888 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { | 897 if (!remaining_play_throughs_ && new_state == delete_decoder_state_) { |
889 LOG_ASSERT(!decoder_deleted()); | 898 LOG_ASSERT(!decoder_deleted()); |
890 DeleteDecoder(); | 899 DeleteDecoder(); |
900 // Cascade through the rest of the states to simplify test code below. | |
901 for (int i = delete_decoder_state_ + 1; i < CS_MAX; ++i) | |
johnylin1
2017/01/10 14:01:55
This change makes us need to call SetState() insid
| |
902 SetState(static_cast<ClientState>(i)); | |
891 } | 903 } |
892 } | 904 } |
893 | 905 |
894 void GLRenderingVDAClient::FinishInitialization() { | 906 void GLRenderingVDAClient::FinishInitialization() { |
895 SetState(CS_INITIALIZED); | 907 SetState(CS_INITIALIZED); |
896 initialize_done_ticks_ = base::TimeTicks::Now(); | 908 initialize_done_ticks_ = base::TimeTicks::Now(); |
897 | 909 |
898 if (reset_after_frame_num_ == START_OF_STREAM_RESET) { | 910 if (reset_after_frame_num_ == START_OF_STREAM_RESET) { |
899 reset_after_frame_num_ = MID_STREAM_RESET; | 911 reset_after_frame_num_ = MID_STREAM_RESET; |
900 decoder_->Reset(); | 912 decoder_->Reset(); |
901 return; | 913 return; |
902 } | 914 } |
903 | 915 |
904 for (int i = 0; i < num_in_flight_decodes_; ++i) | 916 for (int i = 0; i < num_in_flight_decodes_; ++i) |
905 DecodeNextFragment(); | 917 DecodeNextFragment(); |
906 DCHECK_EQ(outstanding_decodes_, num_in_flight_decodes_); | 918 DCHECK_EQ(outstanding_decodes_, num_in_flight_decodes_); |
907 } | 919 } |
908 | 920 |
909 void GLRenderingVDAClient::DeleteDecoder() { | 921 void GLRenderingVDAClient::DeleteDecoder() { |
910 if (decoder_deleted()) | 922 if (decoder_deleted()) |
911 return; | 923 return; |
912 weak_vda_ptr_factory_->InvalidateWeakPtrs(); | 924 weak_vda_ptr_factory_->InvalidateWeakPtrs(); |
913 decoder_.reset(); | 925 decoder_.reset(); |
914 base::STLClearObject(&encoded_data_); | 926 base::STLClearObject(&encoded_data_); |
915 active_textures_.clear(); | 927 active_textures_.clear(); |
916 | |
917 // Cascade through the rest of the states to simplify test code below. | |
918 for (int i = state_ + 1; i < CS_MAX; ++i) | |
919 SetState(static_cast<ClientState>(i)); | |
920 } | 928 } |
921 | 929 |
922 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, | 930 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, |
923 size_t* end_pos) { | 931 size_t* end_pos) { |
924 if (profile_ < H264PROFILE_MAX) { | 932 if (profile_ < H264PROFILE_MAX) { |
925 *end_pos = start_pos; | 933 *end_pos = start_pos; |
926 while (*end_pos + 4 < encoded_data_.size()) { | 934 while (*end_pos + 4 < encoded_data_.size()) { |
927 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame | 935 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame |
928 return GetBytesForNextFragment(*end_pos, end_pos); | 936 return GetBytesForNextFragment(*end_pos, end_pos); |
929 GetBytesForNextNALU(*end_pos, end_pos); | 937 GetBytesForNextNALU(*end_pos, end_pos); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1041 BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle, | 1049 BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle, |
1042 next_fragment_size); | 1050 next_fragment_size); |
1043 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); | 1051 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); |
1044 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. | 1052 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. |
1045 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; | 1053 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; |
1046 decoder_->Decode(bitstream_buffer); | 1054 decoder_->Decode(bitstream_buffer); |
1047 ++outstanding_decodes_; | 1055 ++outstanding_decodes_; |
1048 if (!remaining_play_throughs_ && | 1056 if (!remaining_play_throughs_ && |
1049 -delete_decoder_state_ == next_bitstream_buffer_id_) { | 1057 -delete_decoder_state_ == next_bitstream_buffer_id_) { |
1050 DeleteDecoder(); | 1058 DeleteDecoder(); |
1059 // Cascade through the rest of the states to simplify test code below. | |
1060 for (int i = state_ + 1; i < CS_MAX; ++i) | |
1061 SetState(static_cast<ClientState>(i)); | |
1051 } | 1062 } |
1052 | 1063 |
1053 if (reset_here) { | 1064 if (reset_here) { |
1054 reset_after_frame_num_ = MID_STREAM_RESET; | 1065 reset_after_frame_num_ = MID_STREAM_RESET; |
1055 decoder_->Reset(); | 1066 decoder_->Reset(); |
1056 // Restart from the beginning to re-Decode() the SPS we just sent. | 1067 // Restart from the beginning to re-Decode() the SPS we just sent. |
1057 encoded_data_next_pos_to_decode_ = 0; | 1068 encoded_data_next_pos_to_decode_ = 0; |
1058 } else { | 1069 } else { |
1059 encoded_data_next_pos_to_decode_ = end_pos; | 1070 encoded_data_next_pos_to_decode_ = end_pos; |
1060 } | 1071 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 void WaitUntilIdle(); | 1122 void WaitUntilIdle(); |
1112 void OutputLogFile(const base::FilePath::CharType* log_path, | 1123 void OutputLogFile(const base::FilePath::CharType* log_path, |
1113 const std::string& content); | 1124 const std::string& content); |
1114 | 1125 |
1115 TestFilesVector test_video_files_; | 1126 TestFilesVector test_video_files_; |
1116 RenderingHelper rendering_helper_; | 1127 RenderingHelper rendering_helper_; |
1117 | 1128 |
1118 protected: | 1129 protected: |
1119 // Must be static because this method may run after the destructor. | 1130 // Must be static because this method may run after the destructor. |
1120 template <typename T> | 1131 template <typename T> |
1121 static void Delete(std::unique_ptr<T> item) { | 1132 static void Delete(T item) { |
1122 // |item| is cleared when the scope of this function is left. | 1133 // |item| is cleared when the scope of this function is left. |
1123 } | 1134 } |
1124 | 1135 |
1125 private: | 1136 private: |
1126 // Required for Thread to work. Not used otherwise. | 1137 // Required for Thread to work. Not used otherwise. |
1127 base::ShadowingAtExitManager at_exit_manager_; | 1138 base::ShadowingAtExitManager at_exit_manager_; |
1128 | 1139 |
1129 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); | 1140 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); |
1130 }; | 1141 }; |
1131 | 1142 |
1132 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} | 1143 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} |
1133 | 1144 |
1134 void VideoDecodeAcceleratorTest::SetUp() { | 1145 void VideoDecodeAcceleratorTest::SetUp() { |
1135 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 1146 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
1136 } | 1147 } |
1137 | 1148 |
1138 void VideoDecodeAcceleratorTest::TearDown() { | 1149 void VideoDecodeAcceleratorTest::TearDown() { |
1139 std::unique_ptr<TestFilesVector> test_video_files(new TestFilesVector); | |
1140 test_video_files->swap(test_video_files_); | |
1141 | |
1142 g_env->GetRenderingTaskRunner()->PostTask( | 1150 g_env->GetRenderingTaskRunner()->PostTask( |
1143 FROM_HERE, | 1151 FROM_HERE, |
1144 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files))); | 1152 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files_))); |
1145 | 1153 |
1146 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 1154 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
1147 base::WaitableEvent::InitialState::NOT_SIGNALED); | 1155 base::WaitableEvent::InitialState::NOT_SIGNALED); |
1148 g_env->GetRenderingTaskRunner()->PostTask( | 1156 g_env->GetRenderingTaskRunner()->PostTask( |
1149 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, | 1157 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, |
1150 base::Unretained(&rendering_helper_), &done)); | 1158 base::Unretained(&rendering_helper_), &done)); |
1151 done.Wait(); | 1159 done.Wait(); |
1152 | 1160 |
1153 rendering_helper_.TearDown(); | 1161 rendering_helper_.TearDown(); |
1154 } | 1162 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 // instantiated. | 1281 // instantiated. |
1274 // - Number of concurrent in-flight Decode() calls per decoder. | 1282 // - Number of concurrent in-flight Decode() calls per decoder. |
1275 // - Number of play-throughs. | 1283 // - Number of play-throughs. |
1276 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1284 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
1277 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1285 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
1278 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1286 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
1279 // - whether the video frames are rendered as thumbnails. | 1287 // - whether the video frames are rendered as thumbnails. |
1280 class VideoDecodeAcceleratorParamTest | 1288 class VideoDecodeAcceleratorParamTest |
1281 : public VideoDecodeAcceleratorTest, | 1289 : public VideoDecodeAcceleratorTest, |
1282 public ::testing::WithParamInterface< | 1290 public ::testing::WithParamInterface< |
1283 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; | 1291 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> { |
1292 protected: | |
1293 using NotesVector = | |
1294 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; | |
1295 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; | |
1296 | |
1297 void TearDown() override; | |
1298 | |
1299 NotesVector notes_; | |
1300 ClientsVector clients_; | |
1301 }; | |
1302 | |
1303 void VideoDecodeAcceleratorParamTest::TearDown() { | |
1304 // |clients_| must be deleted first because |clients_| use |notes_|. | |
1305 g_env->GetRenderingTaskRunner()->PostTask( | |
1306 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients_))); | |
1307 | |
1308 g_env->GetRenderingTaskRunner()->PostTask( | |
1309 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(¬es_))); | |
1310 | |
1311 WaitUntilIdle(); | |
1312 | |
1313 // Do VideoDecodeAcceleratorTest clean-up after deleting clients and notes. | |
1314 VideoDecodeAcceleratorTest::TearDown(); | |
1315 } | |
1284 | 1316 |
1285 // Wait for |note| to report a state and if it's not |expected_state| then | 1317 // Wait for |note| to report a state and if it's not |expected_state| then |
1286 // assert |client| has deleted its decoder. | 1318 // assert |client| has deleted its decoder. |
1287 static void AssertWaitForStateOrDeleted( | 1319 static void AssertWaitForStateOrDeleted( |
1288 ClientStateNotification<ClientState>* note, | 1320 ClientStateNotification<ClientState>* note, |
1289 GLRenderingVDAClient* client, | 1321 GLRenderingVDAClient* client, |
1290 ClientState expected_state) { | 1322 ClientState expected_state) { |
1291 ClientState state = note->Wait(); | 1323 ClientState state = note->Wait(); |
1292 if (state == expected_state) | 1324 if (state == expected_state) |
1293 return; | 1325 return; |
(...skipping 23 matching lines...) Expand all Loading... | |
1317 | 1349 |
1318 if (g_num_play_throughs > 0) | 1350 if (g_num_play_throughs > 0) |
1319 num_play_throughs = g_num_play_throughs; | 1351 num_play_throughs = g_num_play_throughs; |
1320 | 1352 |
1321 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, | 1353 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, |
1322 &test_video_files_); | 1354 &test_video_files_); |
1323 | 1355 |
1324 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. | 1356 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. |
1325 const bool suppress_rendering = g_rendering_fps == 0; | 1357 const bool suppress_rendering = g_rendering_fps == 0; |
1326 | 1358 |
1327 using NotesVector = | 1359 notes_.resize(num_concurrent_decoders); |
1328 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; | 1360 clients_.resize(num_concurrent_decoders); |
1329 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; | |
1330 NotesVector notes(num_concurrent_decoders); | |
1331 ClientsVector clients(num_concurrent_decoders); | |
1332 | 1361 |
1333 RenderingHelperParams helper_params; | 1362 RenderingHelperParams helper_params; |
1334 helper_params.rendering_fps = g_rendering_fps; | 1363 helper_params.rendering_fps = g_rendering_fps; |
1335 helper_params.warm_up_iterations = g_rendering_warm_up; | 1364 helper_params.warm_up_iterations = g_rendering_warm_up; |
1336 helper_params.render_as_thumbnails = render_as_thumbnails; | 1365 helper_params.render_as_thumbnails = render_as_thumbnails; |
1337 if (render_as_thumbnails) { | 1366 if (render_as_thumbnails) { |
1338 // Only one decoder is supported with thumbnail rendering | 1367 // Only one decoder is supported with thumbnail rendering |
1339 LOG_ASSERT(num_concurrent_decoders == 1U); | 1368 LOG_ASSERT(num_concurrent_decoders == 1U); |
1340 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1369 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
1341 helper_params.thumbnail_size = kThumbnailSize; | 1370 helper_params.thumbnail_size = kThumbnailSize; |
1342 } | 1371 } |
1343 | 1372 |
1344 // First kick off all the decoders. | 1373 // First kick off all the decoders. |
1345 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1374 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1346 TestVideoFile* video_file = | 1375 TestVideoFile* video_file = |
1347 test_video_files_[index % test_video_files_.size()].get(); | 1376 test_video_files_[index % test_video_files_.size()].get(); |
1348 std::unique_ptr<ClientStateNotification<ClientState>> note = | 1377 std::unique_ptr<ClientStateNotification<ClientState>> note = |
1349 base::MakeUnique<ClientStateNotification<ClientState>>(); | 1378 base::MakeUnique<ClientStateNotification<ClientState>>(); |
1350 notes[index] = std::move(note); | 1379 notes_[index] = std::move(note); |
1351 | 1380 |
1352 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1381 int delay_after_frame_num = std::numeric_limits<int>::max(); |
1353 if (test_reuse_delay && | 1382 if (test_reuse_delay && |
1354 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1383 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
1355 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1384 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
1356 } | 1385 } |
1357 | 1386 |
1358 std::unique_ptr<GLRenderingVDAClient> client = | 1387 std::unique_ptr<GLRenderingVDAClient> client = |
1359 base::MakeUnique<GLRenderingVDAClient>( | 1388 base::MakeUnique<GLRenderingVDAClient>( |
1360 index, &rendering_helper_, notes[index].get(), video_file->data_str, | 1389 index, &rendering_helper_, notes_[index].get(), |
1361 num_in_flight_decodes, num_play_throughs, | 1390 video_file->data_str, num_in_flight_decodes, num_play_throughs, |
1362 video_file->reset_after_frame_num, delete_decoder_state, | 1391 video_file->reset_after_frame_num, delete_decoder_state, |
1363 video_file->width, video_file->height, video_file->profile, | 1392 video_file->width, video_file->height, video_file->profile, |
1364 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, | 1393 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, |
1365 render_as_thumbnails); | 1394 render_as_thumbnails); |
1366 | 1395 |
1367 clients[index] = std::move(client); | 1396 clients_[index] = std::move(client); |
1368 helper_params.window_sizes.push_back( | 1397 helper_params.window_sizes.push_back( |
1369 render_as_thumbnails | 1398 render_as_thumbnails |
1370 ? kThumbnailsPageSize | 1399 ? kThumbnailsPageSize |
1371 : gfx::Size(video_file->width, video_file->height)); | 1400 : gfx::Size(video_file->width, video_file->height)); |
1372 } | 1401 } |
1373 | 1402 |
1374 InitializeRenderingHelper(helper_params); | 1403 InitializeRenderingHelper(helper_params); |
1375 | 1404 |
1376 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1405 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1377 CreateAndStartDecoder(clients[index].get(), notes[index].get()); | 1406 CreateAndStartDecoder(clients_[index].get(), notes_[index].get()); |
1378 } | 1407 } |
1379 | 1408 |
1380 // Then wait for all the decodes to finish. | 1409 // Then wait for all the decodes to finish. |
1381 // Only check performance & correctness later if we play through only once. | 1410 // Only check performance & correctness later if we play through only once. |
1382 bool skip_performance_and_correctness_checks = num_play_throughs > 1; | 1411 bool skip_performance_and_correctness_checks = num_play_throughs > 1; |
1383 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1412 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1384 ClientStateNotification<ClientState>* note = notes[i].get(); | 1413 ClientStateNotification<ClientState>* note = notes_[i].get(); |
1385 ClientState state = note->Wait(); | 1414 ClientState state = note->Wait(); |
1386 if (state != CS_INITIALIZED) { | 1415 if (state != CS_INITIALIZED) { |
1387 skip_performance_and_correctness_checks = true; | 1416 skip_performance_and_correctness_checks = true; |
1388 // We expect initialization to fail only when more than the supported | 1417 // We expect initialization to fail only when more than the supported |
1389 // number of decoders is instantiated. Assert here that something else | 1418 // number of decoders is instantiated. Assert here that something else |
1390 // didn't trigger failure. | 1419 // didn't trigger failure. |
1391 ASSERT_GT(num_concurrent_decoders, | 1420 ASSERT_GT(num_concurrent_decoders, |
1392 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); | 1421 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); |
1393 continue; | 1422 continue; |
1394 } | 1423 } |
1395 ASSERT_EQ(state, CS_INITIALIZED); | |
1396 for (int n = 0; n < num_play_throughs; ++n) { | 1424 for (int n = 0; n < num_play_throughs; ++n) { |
1397 // For play-throughs other than the first, we expect initialization to | 1425 // For play-throughs other than the first, we expect initialization to |
1398 // succeed unconditionally. | 1426 // succeed unconditionally. |
1399 if (n > 0) { | 1427 if (n > 0) { |
1400 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( | 1428 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( |
1401 note, clients[i].get(), CS_INITIALIZED)); | 1429 note, clients_[i].get(), CS_INITIALIZED)); |
1402 } | 1430 } |
1403 // InitializeDone kicks off decoding inside the client, so we just need to | 1431 // InitializeDone kicks off decoding inside the client, so we just need to |
1404 // wait for Flush. | 1432 // wait for Flush. |
1405 ASSERT_NO_FATAL_FAILURE( | 1433 ASSERT_NO_FATAL_FAILURE( |
1406 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHING)); | 1434 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHING)); |
1407 ASSERT_NO_FATAL_FAILURE( | 1435 ASSERT_NO_FATAL_FAILURE( |
1408 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHED)); | 1436 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHED)); |
1409 // FlushDone requests Reset(). | 1437 // FlushDone requests Reset(). |
1410 ASSERT_NO_FATAL_FAILURE( | 1438 ASSERT_NO_FATAL_FAILURE( |
1411 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESETTING)); | 1439 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESETTING)); |
1412 } | 1440 } |
1413 ASSERT_NO_FATAL_FAILURE( | 1441 ASSERT_NO_FATAL_FAILURE( |
1414 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESET)); | 1442 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESET)); |
1415 // ResetDone requests Destroy(). | 1443 // ResetDone requests Destroy(). |
1416 ASSERT_NO_FATAL_FAILURE( | 1444 ASSERT_NO_FATAL_FAILURE( |
1417 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_DESTROYED)); | 1445 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_DESTROYED)); |
1418 } | 1446 } |
1419 // Finally assert that decoding went as expected. | 1447 // Finally assert that decoding went as expected. |
1420 for (size_t i = 0; | 1448 for (size_t i = 0; |
1421 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; | 1449 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; |
1422 ++i) { | 1450 ++i) { |
1423 // We can only make performance/correctness assertions if the decoder was | 1451 // We can only make performance/correctness assertions if the decoder was |
1424 // allowed to finish. | 1452 // allowed to finish. |
1425 if (delete_decoder_state < CS_FLUSHED) | 1453 if (delete_decoder_state < CS_FLUSHED) |
1426 continue; | 1454 continue; |
1427 GLRenderingVDAClient* client = clients[i].get(); | 1455 GLRenderingVDAClient* client = clients_[i].get(); |
1428 TestVideoFile* video_file = | 1456 TestVideoFile* video_file = |
1429 test_video_files_[i % test_video_files_.size()].get(); | 1457 test_video_files_[i % test_video_files_.size()].get(); |
1430 if (video_file->num_frames > 0) { | 1458 if (video_file->num_frames > 0) { |
1431 // Expect the decoded frames may be more than the video frames as frames | 1459 // Expect the decoded frames may be more than the video frames as frames |
1432 // could still be returned until resetting done. | 1460 // could still be returned until resetting done. |
1433 if (video_file->reset_after_frame_num > 0) | 1461 if (video_file->reset_after_frame_num > 0) |
1434 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); | 1462 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); |
1435 else | 1463 else |
1436 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); | 1464 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); |
1437 } | 1465 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 std::vector<gfx::PNGCodec::Comment>(), | 1506 std::vector<gfx::PNGCodec::Comment>(), |
1479 &png); | 1507 &png); |
1480 | 1508 |
1481 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1509 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
1482 | 1510 |
1483 base::FilePath filepath(test_video_files_[0]->file_name); | 1511 base::FilePath filepath(test_video_files_[0]->file_name); |
1484 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1512 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
1485 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1513 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
1486 int num_bytes = base::WriteFile( | 1514 int num_bytes = base::WriteFile( |
1487 filepath, reinterpret_cast<char*>(&png[0]), png.size()); | 1515 filepath, reinterpret_cast<char*>(&png[0]), png.size()); |
1488 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1516 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); |
1489 } | 1517 } |
1490 ASSERT_NE(match, golden_md5s.end()); | 1518 EXPECT_NE(match, golden_md5s.end()); |
1491 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | 1519 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; |
1492 } | 1520 } |
1493 | 1521 |
1494 // Output the frame delivery time to file | 1522 // Output the frame delivery time to file |
1495 // We can only make performance/correctness assertions if the decoder was | 1523 // We can only make performance/correctness assertions if the decoder was |
1496 // allowed to finish. | 1524 // allowed to finish. |
1497 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1525 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
1498 base::File output_file( | 1526 base::File output_file( |
1499 base::FilePath(g_output_log), | 1527 base::FilePath(g_output_log), |
1500 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 1528 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
1501 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1529 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1502 clients[i]->OutputFrameDeliveryTimes(&output_file); | 1530 clients_[i]->OutputFrameDeliveryTimes(&output_file); |
1503 } | 1531 } |
1504 } | 1532 } |
1505 | |
1506 std::unique_ptr<ClientsVector> clients2(new ClientsVector); | |
1507 clients2->swap(clients); | |
1508 std::unique_ptr<NotesVector> notes2(new NotesVector); | |
1509 notes2->swap(notes); | |
1510 | |
1511 // |clients| must be deleted first because |clients| use |notes2|. | |
1512 g_env->GetRenderingTaskRunner()->PostTask( | |
1513 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients2))); | |
1514 | |
1515 g_env->GetRenderingTaskRunner()->PostTask( | |
1516 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(¬es2))); | |
1517 | |
1518 WaitUntilIdle(); | |
1519 }; | 1533 }; |
1520 | 1534 |
1521 // Test that replay after EOS works fine. | 1535 // Test that replay after EOS works fine. |
1522 INSTANTIATE_TEST_CASE_P( | 1536 INSTANTIATE_TEST_CASE_P( |
1523 ReplayAfterEOS, | 1537 ReplayAfterEOS, |
1524 VideoDecodeAcceleratorParamTest, | 1538 VideoDecodeAcceleratorParamTest, |
1525 ::testing::Values( | 1539 ::testing::Values( |
1526 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1540 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); |
1527 | 1541 |
1528 // Test that Reset() before the first Decode() works fine. | 1542 // Test that Reset() before the first Decode() works fine. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1825 | 1839 |
1826 media::g_env = | 1840 media::g_env = |
1827 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1841 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
1828 testing::AddGlobalTestEnvironment( | 1842 testing::AddGlobalTestEnvironment( |
1829 new media::VideoDecodeAcceleratorTestEnvironment())); | 1843 new media::VideoDecodeAcceleratorTestEnvironment())); |
1830 | 1844 |
1831 return base::LaunchUnitTestsSerially( | 1845 return base::LaunchUnitTestsSerially( |
1832 argc, argv, | 1846 argc, argv, |
1833 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | 1847 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); |
1834 } | 1848 } |
OLD | NEW |