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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 790 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, |
791 weak_vda_, picture_buffer_id), | 791 weak_vda_, picture_buffer_id), |
792 kReuseDelay); | 792 kReuseDelay); |
793 } else { | 793 } else { |
794 decoder_->ReusePictureBuffer(picture_buffer_id); | 794 decoder_->ReusePictureBuffer(picture_buffer_id); |
795 } | 795 } |
796 } | 796 } |
797 | 797 |
798 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 798 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
799 int32_t bitstream_buffer_id) { | 799 int32_t bitstream_buffer_id) { |
800 if (decoder_deleted()) | |
801 return; | |
802 | |
800 // TODO(fischman): this test currently relies on this notification to make | 803 // TODO(fischman): this test currently relies on this notification to make |
801 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 804 // 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 | 805 // guarantee this, so stop relying on it (and remove the notifications from |
803 // VaapiVideoDecodeAccelerator::FinishReset()). | 806 // VaapiVideoDecodeAccelerator::FinishReset()). |
804 ++num_done_bitstream_buffers_; | 807 ++num_done_bitstream_buffers_; |
805 --outstanding_decodes_; | 808 --outstanding_decodes_; |
806 | 809 |
807 // Flush decoder after all BitstreamBuffers are processed. | 810 // Flush decoder after all BitstreamBuffers are processed. |
808 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 811 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
809 // TODO(owenlin): We should not have to check the number of | 812 // TODO(owenlin): We should not have to check the number of |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 } | 910 } |
908 | 911 |
909 void GLRenderingVDAClient::DeleteDecoder() { | 912 void GLRenderingVDAClient::DeleteDecoder() { |
910 if (decoder_deleted()) | 913 if (decoder_deleted()) |
911 return; | 914 return; |
912 weak_vda_ptr_factory_->InvalidateWeakPtrs(); | 915 weak_vda_ptr_factory_->InvalidateWeakPtrs(); |
913 decoder_.reset(); | 916 decoder_.reset(); |
914 base::STLClearObject(&encoded_data_); | 917 base::STLClearObject(&encoded_data_); |
915 active_textures_.clear(); | 918 active_textures_.clear(); |
916 | 919 |
917 // Cascade through the rest of the states to simplify test code below. | 920 // Set state to CS_DESTROYED after decoder is deleted. |
918 for (int i = state_ + 1; i < CS_MAX; ++i) | 921 SetState(CS_DESTROYED); |
919 SetState(static_cast<ClientState>(i)); | |
920 } | 922 } |
921 | 923 |
922 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, | 924 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, |
923 size_t* end_pos) { | 925 size_t* end_pos) { |
924 if (profile_ < H264PROFILE_MAX) { | 926 if (profile_ < H264PROFILE_MAX) { |
925 *end_pos = start_pos; | 927 *end_pos = start_pos; |
926 while (*end_pos + 4 < encoded_data_.size()) { | 928 while (*end_pos + 4 < encoded_data_.size()) { |
927 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame | 929 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame |
928 return GetBytesForNextFragment(*end_pos, end_pos); | 930 return GetBytesForNextFragment(*end_pos, end_pos); |
929 GetBytesForNextNALU(*end_pos, end_pos); | 931 GetBytesForNextNALU(*end_pos, end_pos); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1111 void WaitUntilIdle(); | 1113 void WaitUntilIdle(); |
1112 void OutputLogFile(const base::FilePath::CharType* log_path, | 1114 void OutputLogFile(const base::FilePath::CharType* log_path, |
1113 const std::string& content); | 1115 const std::string& content); |
1114 | 1116 |
1115 TestFilesVector test_video_files_; | 1117 TestFilesVector test_video_files_; |
1116 RenderingHelper rendering_helper_; | 1118 RenderingHelper rendering_helper_; |
1117 | 1119 |
1118 protected: | 1120 protected: |
1119 // Must be static because this method may run after the destructor. | 1121 // Must be static because this method may run after the destructor. |
1120 template <typename T> | 1122 template <typename T> |
1121 static void Delete(std::unique_ptr<T> item) { | 1123 static void Delete(T item) { |
1122 // |item| is cleared when the scope of this function is left. | 1124 // |item| is cleared when the scope of this function is left. |
1123 } | 1125 } |
1124 | 1126 |
1125 private: | 1127 private: |
1126 // Required for Thread to work. Not used otherwise. | 1128 // Required for Thread to work. Not used otherwise. |
1127 base::ShadowingAtExitManager at_exit_manager_; | 1129 base::ShadowingAtExitManager at_exit_manager_; |
1128 | 1130 |
1129 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); | 1131 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); |
1130 }; | 1132 }; |
1131 | 1133 |
1132 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} | 1134 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} |
1133 | 1135 |
1134 void VideoDecodeAcceleratorTest::SetUp() { | 1136 void VideoDecodeAcceleratorTest::SetUp() { |
1135 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 1137 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
1136 } | 1138 } |
1137 | 1139 |
1138 void VideoDecodeAcceleratorTest::TearDown() { | 1140 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( | 1141 g_env->GetRenderingTaskRunner()->PostTask( |
1143 FROM_HERE, | 1142 FROM_HERE, |
1144 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files))); | 1143 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files_))); |
1145 | 1144 |
1146 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 1145 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
1147 base::WaitableEvent::InitialState::NOT_SIGNALED); | 1146 base::WaitableEvent::InitialState::NOT_SIGNALED); |
1148 g_env->GetRenderingTaskRunner()->PostTask( | 1147 g_env->GetRenderingTaskRunner()->PostTask( |
1149 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, | 1148 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, |
1150 base::Unretained(&rendering_helper_), &done)); | 1149 base::Unretained(&rendering_helper_), &done)); |
1151 done.Wait(); | 1150 done.Wait(); |
1152 | 1151 |
1153 rendering_helper_.TearDown(); | 1152 rendering_helper_.TearDown(); |
1154 } | 1153 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1273 // instantiated. | 1272 // instantiated. |
1274 // - Number of concurrent in-flight Decode() calls per decoder. | 1273 // - Number of concurrent in-flight Decode() calls per decoder. |
1275 // - Number of play-throughs. | 1274 // - Number of play-throughs. |
1276 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1275 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
1277 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1276 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
1278 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1277 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
1279 // - whether the video frames are rendered as thumbnails. | 1278 // - whether the video frames are rendered as thumbnails. |
1280 class VideoDecodeAcceleratorParamTest | 1279 class VideoDecodeAcceleratorParamTest |
1281 : public VideoDecodeAcceleratorTest, | 1280 : public VideoDecodeAcceleratorTest, |
1282 public ::testing::WithParamInterface< | 1281 public ::testing::WithParamInterface< |
1283 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; | 1282 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> { |
1283 protected: | |
1284 using NotesVector = | |
1285 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; | |
1286 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; | |
1287 | |
1288 void TearDown() override; | |
1289 | |
1290 NotesVector notes_; | |
1291 ClientsVector clients_; | |
1292 }; | |
1293 | |
1294 void VideoDecodeAcceleratorParamTest::TearDown() { | |
1295 // |clients_| must be deleted first because |clients_| use |notes_|. | |
1296 g_env->GetRenderingTaskRunner()->PostTask( | |
1297 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients_))); | |
1298 | |
1299 g_env->GetRenderingTaskRunner()->PostTask( | |
1300 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(¬es_))); | |
1301 | |
1302 WaitUntilIdle(); | |
1303 | |
1304 // Do VideoDecodeAcceleratorTest clean-up after deleting clients and notes. | |
1305 VideoDecodeAcceleratorTest::TearDown(); | |
1306 } | |
1284 | 1307 |
1285 // Wait for |note| to report a state and if it's not |expected_state| then | 1308 // Wait for |note| to report a state and if it's not |expected_state| then |
1286 // assert |client| has deleted its decoder. | 1309 // assert |client| has deleted its decoder. |
1287 static void AssertWaitForStateOrDeleted( | 1310 static void AssertWaitForStateOrDeleted( |
1288 ClientStateNotification<ClientState>* note, | 1311 ClientStateNotification<ClientState>* note, |
1289 GLRenderingVDAClient* client, | 1312 GLRenderingVDAClient* client, |
1290 ClientState expected_state) { | 1313 ClientState expected_state) { |
1314 // Skip waiting state if decoder is already deleted of |client|. | |
wuchengli
2017/01/11 07:39:12
decoder of |client| is already deleted.
| |
1315 if (client->decoder_deleted()) | |
1316 return; | |
1291 ClientState state = note->Wait(); | 1317 ClientState state = note->Wait(); |
1292 if (state == expected_state) | 1318 if (state == expected_state) |
1293 return; | 1319 return; |
1294 ASSERT_TRUE(client->decoder_deleted()) | 1320 ASSERT_TRUE(client->decoder_deleted()) |
1295 << "Decoder not deleted but Wait() returned " << state | 1321 << "Decoder not deleted but Wait() returned " << state |
1296 << ", instead of " << expected_state; | 1322 << ", instead of " << expected_state; |
1297 } | 1323 } |
1298 | 1324 |
1299 // We assert a minimal number of concurrent decoders we expect to succeed. | 1325 // We assert a minimal number of concurrent decoders we expect to succeed. |
1300 // Different platforms can support more concurrent decoders, so we don't assert | 1326 // Different platforms can support more concurrent decoders, so we don't assert |
(...skipping 16 matching lines...) Expand all Loading... | |
1317 | 1343 |
1318 if (g_num_play_throughs > 0) | 1344 if (g_num_play_throughs > 0) |
1319 num_play_throughs = g_num_play_throughs; | 1345 num_play_throughs = g_num_play_throughs; |
1320 | 1346 |
1321 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, | 1347 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, |
1322 &test_video_files_); | 1348 &test_video_files_); |
1323 | 1349 |
1324 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. | 1350 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. |
1325 const bool suppress_rendering = g_rendering_fps == 0; | 1351 const bool suppress_rendering = g_rendering_fps == 0; |
1326 | 1352 |
1327 using NotesVector = | 1353 notes_.resize(num_concurrent_decoders); |
1328 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; | 1354 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 | 1355 |
1333 RenderingHelperParams helper_params; | 1356 RenderingHelperParams helper_params; |
1334 helper_params.rendering_fps = g_rendering_fps; | 1357 helper_params.rendering_fps = g_rendering_fps; |
1335 helper_params.warm_up_iterations = g_rendering_warm_up; | 1358 helper_params.warm_up_iterations = g_rendering_warm_up; |
1336 helper_params.render_as_thumbnails = render_as_thumbnails; | 1359 helper_params.render_as_thumbnails = render_as_thumbnails; |
1337 if (render_as_thumbnails) { | 1360 if (render_as_thumbnails) { |
1338 // Only one decoder is supported with thumbnail rendering | 1361 // Only one decoder is supported with thumbnail rendering |
1339 LOG_ASSERT(num_concurrent_decoders == 1U); | 1362 LOG_ASSERT(num_concurrent_decoders == 1U); |
1340 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1363 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
1341 helper_params.thumbnail_size = kThumbnailSize; | 1364 helper_params.thumbnail_size = kThumbnailSize; |
1342 } | 1365 } |
1343 | 1366 |
1344 // First kick off all the decoders. | 1367 // First kick off all the decoders. |
1345 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1368 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1346 TestVideoFile* video_file = | 1369 TestVideoFile* video_file = |
1347 test_video_files_[index % test_video_files_.size()].get(); | 1370 test_video_files_[index % test_video_files_.size()].get(); |
1348 std::unique_ptr<ClientStateNotification<ClientState>> note = | 1371 std::unique_ptr<ClientStateNotification<ClientState>> note = |
1349 base::MakeUnique<ClientStateNotification<ClientState>>(); | 1372 base::MakeUnique<ClientStateNotification<ClientState>>(); |
1350 notes[index] = std::move(note); | 1373 notes_[index] = std::move(note); |
1351 | 1374 |
1352 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1375 int delay_after_frame_num = std::numeric_limits<int>::max(); |
1353 if (test_reuse_delay && | 1376 if (test_reuse_delay && |
1354 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1377 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
1355 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1378 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
1356 } | 1379 } |
1357 | 1380 |
1358 std::unique_ptr<GLRenderingVDAClient> client = | 1381 std::unique_ptr<GLRenderingVDAClient> client = |
1359 base::MakeUnique<GLRenderingVDAClient>( | 1382 base::MakeUnique<GLRenderingVDAClient>( |
1360 index, &rendering_helper_, notes[index].get(), video_file->data_str, | 1383 index, &rendering_helper_, notes_[index].get(), |
1361 num_in_flight_decodes, num_play_throughs, | 1384 video_file->data_str, num_in_flight_decodes, num_play_throughs, |
1362 video_file->reset_after_frame_num, delete_decoder_state, | 1385 video_file->reset_after_frame_num, delete_decoder_state, |
1363 video_file->width, video_file->height, video_file->profile, | 1386 video_file->width, video_file->height, video_file->profile, |
1364 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, | 1387 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, |
1365 render_as_thumbnails); | 1388 render_as_thumbnails); |
1366 | 1389 |
1367 clients[index] = std::move(client); | 1390 clients_[index] = std::move(client); |
1368 helper_params.window_sizes.push_back( | 1391 helper_params.window_sizes.push_back( |
1369 render_as_thumbnails | 1392 render_as_thumbnails |
1370 ? kThumbnailsPageSize | 1393 ? kThumbnailsPageSize |
1371 : gfx::Size(video_file->width, video_file->height)); | 1394 : gfx::Size(video_file->width, video_file->height)); |
1372 } | 1395 } |
1373 | 1396 |
1374 InitializeRenderingHelper(helper_params); | 1397 InitializeRenderingHelper(helper_params); |
1375 | 1398 |
1376 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1399 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1377 CreateAndStartDecoder(clients[index].get(), notes[index].get()); | 1400 CreateAndStartDecoder(clients_[index].get(), notes_[index].get()); |
1378 } | 1401 } |
1379 | 1402 |
1380 // Then wait for all the decodes to finish. | 1403 // Then wait for all the decodes to finish. |
1381 // Only check performance & correctness later if we play through only once. | 1404 // Only check performance & correctness later if we play through only once. |
1382 bool skip_performance_and_correctness_checks = num_play_throughs > 1; | 1405 bool skip_performance_and_correctness_checks = num_play_throughs > 1; |
1383 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1406 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1384 ClientStateNotification<ClientState>* note = notes[i].get(); | 1407 ClientStateNotification<ClientState>* note = notes_[i].get(); |
1385 ClientState state = note->Wait(); | 1408 ClientState state = note->Wait(); |
1386 if (state != CS_INITIALIZED) { | 1409 if (state != CS_INITIALIZED) { |
1387 skip_performance_and_correctness_checks = true; | 1410 skip_performance_and_correctness_checks = true; |
1388 // We expect initialization to fail only when more than the supported | 1411 // We expect initialization to fail only when more than the supported |
1389 // number of decoders is instantiated. Assert here that something else | 1412 // number of decoders is instantiated. Assert here that something else |
1390 // didn't trigger failure. | 1413 // didn't trigger failure. |
1391 ASSERT_GT(num_concurrent_decoders, | 1414 ASSERT_GT(num_concurrent_decoders, |
1392 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); | 1415 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); |
1393 continue; | 1416 continue; |
1394 } | 1417 } |
1395 ASSERT_EQ(state, CS_INITIALIZED); | |
1396 for (int n = 0; n < num_play_throughs; ++n) { | 1418 for (int n = 0; n < num_play_throughs; ++n) { |
1397 // For play-throughs other than the first, we expect initialization to | 1419 // For play-throughs other than the first, we expect initialization to |
1398 // succeed unconditionally. | 1420 // succeed unconditionally. |
1399 if (n > 0) { | 1421 if (n > 0) { |
1400 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( | 1422 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( |
1401 note, clients[i].get(), CS_INITIALIZED)); | 1423 note, clients_[i].get(), CS_INITIALIZED)); |
1402 } | 1424 } |
1403 // InitializeDone kicks off decoding inside the client, so we just need to | 1425 // InitializeDone kicks off decoding inside the client, so we just need to |
1404 // wait for Flush. | 1426 // wait for Flush. |
1405 ASSERT_NO_FATAL_FAILURE( | 1427 ASSERT_NO_FATAL_FAILURE( |
1406 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHING)); | 1428 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHING)); |
1407 ASSERT_NO_FATAL_FAILURE( | 1429 ASSERT_NO_FATAL_FAILURE( |
1408 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHED)); | 1430 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHED)); |
1409 // FlushDone requests Reset(). | 1431 // FlushDone requests Reset(). |
1410 ASSERT_NO_FATAL_FAILURE( | 1432 ASSERT_NO_FATAL_FAILURE( |
1411 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESETTING)); | 1433 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESETTING)); |
1412 } | 1434 } |
1413 ASSERT_NO_FATAL_FAILURE( | 1435 ASSERT_NO_FATAL_FAILURE( |
1414 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESET)); | 1436 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESET)); |
1415 // ResetDone requests Destroy(). | 1437 // ResetDone requests Destroy(). |
1416 ASSERT_NO_FATAL_FAILURE( | 1438 ASSERT_NO_FATAL_FAILURE( |
1417 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_DESTROYED)); | 1439 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_DESTROYED)); |
1418 } | 1440 } |
1419 // Finally assert that decoding went as expected. | 1441 // Finally assert that decoding went as expected. |
1420 for (size_t i = 0; | 1442 for (size_t i = 0; |
1421 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; | 1443 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; |
1422 ++i) { | 1444 ++i) { |
1423 // We can only make performance/correctness assertions if the decoder was | 1445 // We can only make performance/correctness assertions if the decoder was |
1424 // allowed to finish. | 1446 // allowed to finish. |
1425 if (delete_decoder_state < CS_FLUSHED) | 1447 if (delete_decoder_state < CS_FLUSHED) |
1426 continue; | 1448 continue; |
1427 GLRenderingVDAClient* client = clients[i].get(); | 1449 GLRenderingVDAClient* client = clients_[i].get(); |
1428 TestVideoFile* video_file = | 1450 TestVideoFile* video_file = |
1429 test_video_files_[i % test_video_files_.size()].get(); | 1451 test_video_files_[i % test_video_files_.size()].get(); |
1430 if (video_file->num_frames > 0) { | 1452 if (video_file->num_frames > 0) { |
1431 // Expect the decoded frames may be more than the video frames as frames | 1453 // Expect the decoded frames may be more than the video frames as frames |
1432 // could still be returned until resetting done. | 1454 // could still be returned until resetting done. |
1433 if (video_file->reset_after_frame_num > 0) | 1455 if (video_file->reset_after_frame_num > 0) |
1434 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); | 1456 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); |
1435 else | 1457 else |
1436 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); | 1458 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); |
1437 } | 1459 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 std::vector<gfx::PNGCodec::Comment>(), | 1500 std::vector<gfx::PNGCodec::Comment>(), |
1479 &png); | 1501 &png); |
1480 | 1502 |
1481 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1503 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
1482 | 1504 |
1483 base::FilePath filepath(test_video_files_[0]->file_name); | 1505 base::FilePath filepath(test_video_files_[0]->file_name); |
1484 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1506 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
1485 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1507 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
1486 int num_bytes = base::WriteFile( | 1508 int num_bytes = base::WriteFile( |
1487 filepath, reinterpret_cast<char*>(&png[0]), png.size()); | 1509 filepath, reinterpret_cast<char*>(&png[0]), png.size()); |
1488 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1510 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); |
1489 } | 1511 } |
1490 ASSERT_NE(match, golden_md5s.end()); | 1512 EXPECT_NE(match, golden_md5s.end()); |
1491 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | 1513 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; |
1492 } | 1514 } |
1493 | 1515 |
1494 // Output the frame delivery time to file | 1516 // Output the frame delivery time to file |
1495 // We can only make performance/correctness assertions if the decoder was | 1517 // We can only make performance/correctness assertions if the decoder was |
1496 // allowed to finish. | 1518 // allowed to finish. |
1497 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1519 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
1498 base::File output_file( | 1520 base::File output_file( |
1499 base::FilePath(g_output_log), | 1521 base::FilePath(g_output_log), |
1500 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 1522 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
1501 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1523 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1502 clients[i]->OutputFrameDeliveryTimes(&output_file); | 1524 clients_[i]->OutputFrameDeliveryTimes(&output_file); |
1503 } | 1525 } |
1504 } | 1526 } |
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 }; | 1527 }; |
1520 | 1528 |
1521 // Test that replay after EOS works fine. | 1529 // Test that replay after EOS works fine. |
1522 INSTANTIATE_TEST_CASE_P( | 1530 INSTANTIATE_TEST_CASE_P( |
1523 ReplayAfterEOS, | 1531 ReplayAfterEOS, |
1524 VideoDecodeAcceleratorParamTest, | 1532 VideoDecodeAcceleratorParamTest, |
1525 ::testing::Values( | 1533 ::testing::Values( |
1526 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1534 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); |
1527 | 1535 |
1528 // Test that Reset() before the first Decode() works fine. | 1536 // Test that Reset() before the first Decode() works fine. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1825 | 1833 |
1826 media::g_env = | 1834 media::g_env = |
1827 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1835 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
1828 testing::AddGlobalTestEnvironment( | 1836 testing::AddGlobalTestEnvironment( |
1829 new media::VideoDecodeAcceleratorTestEnvironment())); | 1837 new media::VideoDecodeAcceleratorTestEnvironment())); |
1830 | 1838 |
1831 return base::LaunchUnitTestsSerially( | 1839 return base::LaunchUnitTestsSerially( |
1832 argc, argv, | 1840 argc, argv, |
1833 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | 1841 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); |
1834 } | 1842 } |
OLD | NEW |