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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 base::SPLIT_WANT_ALL); | 210 base::SPLIT_WANT_ALL); |
211 // Check these are legitimate MD5s. | 211 // Check these are legitimate MD5s. |
212 for (const std::string& md5_string : *md5_strings) { | 212 for (const std::string& md5_string : *md5_strings) { |
213 // Ignore the empty string added by SplitString | 213 // Ignore the empty string added by SplitString |
214 if (!md5_string.length()) | 214 if (!md5_string.length()) |
215 continue; | 215 continue; |
216 // Ignore comments | 216 // Ignore comments |
217 if (md5_string.at(0) == '#') | 217 if (md5_string.at(0) == '#') |
218 continue; | 218 continue; |
219 | 219 |
220 LOG_ASSERT(static_cast<int>(md5_string.length()) == kMD5StringLength) | 220 LOG_IF(ERROR, static_cast<int>(md5_string.length()) != kMD5StringLength) |
221 << md5_string; | 221 << "MD5 length error: " << md5_string; |
222 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), | 222 bool hex_only = std::count_if(md5_string.begin(), md5_string.end(), |
223 isxdigit) == kMD5StringLength; | 223 isxdigit) == kMD5StringLength; |
224 LOG_ASSERT(hex_only) << md5_string; | 224 LOG_IF(ERROR, !hex_only) << "MD5 includes non-hex char: " << md5_string; |
225 } | 225 } |
226 LOG_ASSERT(md5_strings->size() >= 1U) << " MD5 checksum file (" | 226 LOG_IF(ERROR, md5_strings->empty()) << " MD5 checksum file (" |
227 << filepath.MaybeAsASCII() | 227 << filepath.MaybeAsASCII() |
228 << ") missing or empty."; | 228 << ") missing or empty."; |
229 } | 229 } |
230 | 230 |
231 // State of the GLRenderingVDAClient below. Order matters here as the test | 231 // State of the GLRenderingVDAClient below. Order matters here as the test |
232 // makes assumptions about it. | 232 // makes assumptions about it. |
233 enum ClientState { | 233 enum ClientState { |
234 CS_CREATED = 0, | 234 CS_CREATED = 0, |
235 CS_DECODER_SET = 1, | 235 CS_DECODER_SET = 1, |
236 CS_INITIALIZED = 2, | 236 CS_INITIALIZED = 2, |
237 CS_FLUSHING = 3, | 237 CS_FLUSHING = 3, |
238 CS_FLUSHED = 4, | 238 CS_FLUSHED = 4, |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, | 801 FROM_HERE, base::Bind(&VideoDecodeAccelerator::ReusePictureBuffer, |
802 weak_vda_, picture_buffer_id), | 802 weak_vda_, picture_buffer_id), |
803 kReuseDelay); | 803 kReuseDelay); |
804 } else { | 804 } else { |
805 decoder_->ReusePictureBuffer(picture_buffer_id); | 805 decoder_->ReusePictureBuffer(picture_buffer_id); |
806 } | 806 } |
807 } | 807 } |
808 | 808 |
809 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( | 809 void GLRenderingVDAClient::NotifyEndOfBitstreamBuffer( |
810 int32_t bitstream_buffer_id) { | 810 int32_t bitstream_buffer_id) { |
| 811 if (decoder_deleted()) |
| 812 return; |
| 813 |
811 // TODO(fischman): this test currently relies on this notification to make | 814 // TODO(fischman): this test currently relies on this notification to make |
812 // forward progress during a Reset(). But the VDA::Reset() API doesn't | 815 // forward progress during a Reset(). But the VDA::Reset() API doesn't |
813 // guarantee this, so stop relying on it (and remove the notifications from | 816 // guarantee this, so stop relying on it (and remove the notifications from |
814 // VaapiVideoDecodeAccelerator::FinishReset()). | 817 // VaapiVideoDecodeAccelerator::FinishReset()). |
815 ++num_done_bitstream_buffers_; | 818 ++num_done_bitstream_buffers_; |
816 --outstanding_decodes_; | 819 --outstanding_decodes_; |
817 | 820 |
818 // Flush decoder after all BitstreamBuffers are processed. | 821 // Flush decoder after all BitstreamBuffers are processed. |
819 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { | 822 if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) { |
820 // TODO(owenlin): We should not have to check the number of | 823 // TODO(owenlin): We should not have to check the number of |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 } | 921 } |
919 | 922 |
920 void GLRenderingVDAClient::DeleteDecoder() { | 923 void GLRenderingVDAClient::DeleteDecoder() { |
921 if (decoder_deleted()) | 924 if (decoder_deleted()) |
922 return; | 925 return; |
923 weak_vda_ptr_factory_->InvalidateWeakPtrs(); | 926 weak_vda_ptr_factory_->InvalidateWeakPtrs(); |
924 decoder_.reset(); | 927 decoder_.reset(); |
925 base::STLClearObject(&encoded_data_); | 928 base::STLClearObject(&encoded_data_); |
926 active_textures_.clear(); | 929 active_textures_.clear(); |
927 | 930 |
928 // Cascade through the rest of the states to simplify test code below. | 931 // Set state to CS_DESTROYED after decoder is deleted. |
929 for (int i = state_ + 1; i < CS_MAX; ++i) | 932 SetState(CS_DESTROYED); |
930 SetState(static_cast<ClientState>(i)); | |
931 } | 933 } |
932 | 934 |
933 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, | 935 std::string GLRenderingVDAClient::GetBytesForFirstFragment(size_t start_pos, |
934 size_t* end_pos) { | 936 size_t* end_pos) { |
935 if (profile_ < H264PROFILE_MAX) { | 937 if (profile_ < H264PROFILE_MAX) { |
936 *end_pos = start_pos; | 938 *end_pos = start_pos; |
937 while (*end_pos + 4 < encoded_data_.size()) { | 939 while (*end_pos + 4 < encoded_data_.size()) { |
938 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame | 940 if ((encoded_data_[*end_pos + 4] & 0x1f) == 0x7) // SPS start frame |
939 return GetBytesForNextFragment(*end_pos, end_pos); | 941 return GetBytesForNextFragment(*end_pos, end_pos); |
940 GetBytesForNextNALU(*end_pos, end_pos); | 942 GetBytesForNextNALU(*end_pos, end_pos); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 void WaitUntilIdle(); | 1124 void WaitUntilIdle(); |
1123 void OutputLogFile(const base::FilePath::CharType* log_path, | 1125 void OutputLogFile(const base::FilePath::CharType* log_path, |
1124 const std::string& content); | 1126 const std::string& content); |
1125 | 1127 |
1126 TestFilesVector test_video_files_; | 1128 TestFilesVector test_video_files_; |
1127 RenderingHelper rendering_helper_; | 1129 RenderingHelper rendering_helper_; |
1128 | 1130 |
1129 protected: | 1131 protected: |
1130 // Must be static because this method may run after the destructor. | 1132 // Must be static because this method may run after the destructor. |
1131 template <typename T> | 1133 template <typename T> |
1132 static void Delete(std::unique_ptr<T> item) { | 1134 static void Delete(T item) { |
1133 // |item| is cleared when the scope of this function is left. | 1135 // |item| is cleared when the scope of this function is left. |
1134 } | 1136 } |
1135 | 1137 |
1136 private: | 1138 private: |
1137 // Required for Thread to work. Not used otherwise. | 1139 // Required for Thread to work. Not used otherwise. |
1138 base::ShadowingAtExitManager at_exit_manager_; | 1140 base::ShadowingAtExitManager at_exit_manager_; |
1139 | 1141 |
1140 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); | 1142 DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorTest); |
1141 }; | 1143 }; |
1142 | 1144 |
1143 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} | 1145 VideoDecodeAcceleratorTest::VideoDecodeAcceleratorTest() {} |
1144 | 1146 |
1145 void VideoDecodeAcceleratorTest::SetUp() { | 1147 void VideoDecodeAcceleratorTest::SetUp() { |
1146 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); | 1148 ParseAndReadTestVideoData(g_test_video_data, &test_video_files_); |
1147 } | 1149 } |
1148 | 1150 |
1149 void VideoDecodeAcceleratorTest::TearDown() { | 1151 void VideoDecodeAcceleratorTest::TearDown() { |
1150 std::unique_ptr<TestFilesVector> test_video_files(new TestFilesVector); | |
1151 test_video_files->swap(test_video_files_); | |
1152 | |
1153 g_env->GetRenderingTaskRunner()->PostTask( | 1152 g_env->GetRenderingTaskRunner()->PostTask( |
1154 FROM_HERE, | 1153 FROM_HERE, |
1155 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files))); | 1154 base::Bind(&Delete<TestFilesVector>, base::Passed(&test_video_files_))); |
1156 | 1155 |
1157 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 1156 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
1158 base::WaitableEvent::InitialState::NOT_SIGNALED); | 1157 base::WaitableEvent::InitialState::NOT_SIGNALED); |
1159 g_env->GetRenderingTaskRunner()->PostTask( | 1158 g_env->GetRenderingTaskRunner()->PostTask( |
1160 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, | 1159 FROM_HERE, base::Bind(&RenderingHelper::UnInitialize, |
1161 base::Unretained(&rendering_helper_), &done)); | 1160 base::Unretained(&rendering_helper_), &done)); |
1162 done.Wait(); | 1161 done.Wait(); |
1163 | 1162 |
1164 rendering_helper_.TearDown(); | 1163 rendering_helper_.TearDown(); |
1165 } | 1164 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 // instantiated. | 1283 // instantiated. |
1285 // - Number of concurrent in-flight Decode() calls per decoder. | 1284 // - Number of concurrent in-flight Decode() calls per decoder. |
1286 // - Number of play-throughs. | 1285 // - Number of play-throughs. |
1287 // - reset_after_frame_num: see GLRenderingVDAClient ctor. | 1286 // - reset_after_frame_num: see GLRenderingVDAClient ctor. |
1288 // - delete_decoder_phase: see GLRenderingVDAClient ctor. | 1287 // - delete_decoder_phase: see GLRenderingVDAClient ctor. |
1289 // - whether to test slow rendering by delaying ReusePictureBuffer(). | 1288 // - whether to test slow rendering by delaying ReusePictureBuffer(). |
1290 // - whether the video frames are rendered as thumbnails. | 1289 // - whether the video frames are rendered as thumbnails. |
1291 class VideoDecodeAcceleratorParamTest | 1290 class VideoDecodeAcceleratorParamTest |
1292 : public VideoDecodeAcceleratorTest, | 1291 : public VideoDecodeAcceleratorTest, |
1293 public ::testing::WithParamInterface< | 1292 public ::testing::WithParamInterface< |
1294 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; | 1293 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> { |
| 1294 protected: |
| 1295 using NotesVector = |
| 1296 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; |
| 1297 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; |
| 1298 |
| 1299 void TearDown() override; |
| 1300 |
| 1301 NotesVector notes_; |
| 1302 ClientsVector clients_; |
| 1303 }; |
| 1304 |
| 1305 void VideoDecodeAcceleratorParamTest::TearDown() { |
| 1306 // |clients_| must be deleted first because |clients_| use |notes_|. |
| 1307 g_env->GetRenderingTaskRunner()->PostTask( |
| 1308 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients_))); |
| 1309 |
| 1310 g_env->GetRenderingTaskRunner()->PostTask( |
| 1311 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(¬es_))); |
| 1312 |
| 1313 WaitUntilIdle(); |
| 1314 |
| 1315 // Do VideoDecodeAcceleratorTest clean-up after deleting clients and notes. |
| 1316 VideoDecodeAcceleratorTest::TearDown(); |
| 1317 } |
1295 | 1318 |
1296 // Wait for |note| to report a state and if it's not |expected_state| then | 1319 // Wait for |note| to report a state and if it's not |expected_state| then |
1297 // assert |client| has deleted its decoder. | 1320 // assert |client| has deleted its decoder. |
1298 static void AssertWaitForStateOrDeleted( | 1321 static void AssertWaitForStateOrDeleted( |
1299 ClientStateNotification<ClientState>* note, | 1322 ClientStateNotification<ClientState>* note, |
1300 GLRenderingVDAClient* client, | 1323 GLRenderingVDAClient* client, |
1301 ClientState expected_state) { | 1324 ClientState expected_state) { |
| 1325 // Skip waiting state if decoder of |client| is already deleted. |
| 1326 if (client->decoder_deleted()) |
| 1327 return; |
1302 ClientState state = note->Wait(); | 1328 ClientState state = note->Wait(); |
1303 if (state == expected_state) | 1329 if (state == expected_state) |
1304 return; | 1330 return; |
1305 ASSERT_TRUE(client->decoder_deleted()) | 1331 ASSERT_TRUE(client->decoder_deleted()) |
1306 << "Decoder not deleted but Wait() returned " << state | 1332 << "Decoder not deleted but Wait() returned " << state |
1307 << ", instead of " << expected_state; | 1333 << ", instead of " << expected_state; |
1308 } | 1334 } |
1309 | 1335 |
1310 // We assert a minimal number of concurrent decoders we expect to succeed. | 1336 // We assert a minimal number of concurrent decoders we expect to succeed. |
1311 // Different platforms can support more concurrent decoders, so we don't assert | 1337 // Different platforms can support more concurrent decoders, so we don't assert |
(...skipping 16 matching lines...) Expand all Loading... |
1328 | 1354 |
1329 if (g_num_play_throughs > 0) | 1355 if (g_num_play_throughs > 0) |
1330 num_play_throughs = g_num_play_throughs; | 1356 num_play_throughs = g_num_play_throughs; |
1331 | 1357 |
1332 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, | 1358 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, |
1333 &test_video_files_); | 1359 &test_video_files_); |
1334 | 1360 |
1335 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. | 1361 // Suppress GL rendering for all tests when the "--rendering_fps" is 0. |
1336 const bool suppress_rendering = g_rendering_fps == 0; | 1362 const bool suppress_rendering = g_rendering_fps == 0; |
1337 | 1363 |
1338 using NotesVector = | 1364 notes_.resize(num_concurrent_decoders); |
1339 std::vector<std::unique_ptr<ClientStateNotification<ClientState>>>; | 1365 clients_.resize(num_concurrent_decoders); |
1340 using ClientsVector = std::vector<std::unique_ptr<GLRenderingVDAClient>>; | |
1341 NotesVector notes(num_concurrent_decoders); | |
1342 ClientsVector clients(num_concurrent_decoders); | |
1343 | 1366 |
1344 RenderingHelperParams helper_params; | 1367 RenderingHelperParams helper_params; |
1345 helper_params.rendering_fps = g_rendering_fps; | 1368 helper_params.rendering_fps = g_rendering_fps; |
1346 helper_params.warm_up_iterations = g_rendering_warm_up; | 1369 helper_params.warm_up_iterations = g_rendering_warm_up; |
1347 helper_params.render_as_thumbnails = render_as_thumbnails; | 1370 helper_params.render_as_thumbnails = render_as_thumbnails; |
1348 if (render_as_thumbnails) { | 1371 if (render_as_thumbnails) { |
1349 // Only one decoder is supported with thumbnail rendering | 1372 // Only one decoder is supported with thumbnail rendering |
1350 LOG_ASSERT(num_concurrent_decoders == 1U); | 1373 LOG_ASSERT(num_concurrent_decoders == 1U); |
1351 helper_params.thumbnails_page_size = kThumbnailsPageSize; | 1374 helper_params.thumbnails_page_size = kThumbnailsPageSize; |
1352 helper_params.thumbnail_size = kThumbnailSize; | 1375 helper_params.thumbnail_size = kThumbnailSize; |
1353 } | 1376 } |
1354 | 1377 |
1355 // First kick off all the decoders. | 1378 // First kick off all the decoders. |
1356 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1379 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1357 TestVideoFile* video_file = | 1380 TestVideoFile* video_file = |
1358 test_video_files_[index % test_video_files_.size()].get(); | 1381 test_video_files_[index % test_video_files_.size()].get(); |
1359 std::unique_ptr<ClientStateNotification<ClientState>> note = | 1382 std::unique_ptr<ClientStateNotification<ClientState>> note = |
1360 base::MakeUnique<ClientStateNotification<ClientState>>(); | 1383 base::MakeUnique<ClientStateNotification<ClientState>>(); |
1361 notes[index] = std::move(note); | 1384 notes_[index] = std::move(note); |
1362 | 1385 |
1363 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1386 int delay_after_frame_num = std::numeric_limits<int>::max(); |
1364 if (test_reuse_delay && | 1387 if (test_reuse_delay && |
1365 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1388 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
1366 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1389 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
1367 } | 1390 } |
1368 | 1391 |
1369 std::unique_ptr<GLRenderingVDAClient> client = | 1392 std::unique_ptr<GLRenderingVDAClient> client = |
1370 base::MakeUnique<GLRenderingVDAClient>( | 1393 base::MakeUnique<GLRenderingVDAClient>( |
1371 index, &rendering_helper_, notes[index].get(), video_file->data_str, | 1394 index, &rendering_helper_, notes_[index].get(), |
1372 num_in_flight_decodes, num_play_throughs, | 1395 video_file->data_str, num_in_flight_decodes, num_play_throughs, |
1373 video_file->reset_after_frame_num, delete_decoder_state, | 1396 video_file->reset_after_frame_num, delete_decoder_state, |
1374 video_file->width, video_file->height, video_file->profile, | 1397 video_file->width, video_file->height, video_file->profile, |
1375 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, | 1398 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, |
1376 render_as_thumbnails); | 1399 render_as_thumbnails); |
1377 | 1400 |
1378 clients[index] = std::move(client); | 1401 clients_[index] = std::move(client); |
1379 helper_params.window_sizes.push_back( | 1402 helper_params.window_sizes.push_back( |
1380 render_as_thumbnails | 1403 render_as_thumbnails |
1381 ? kThumbnailsPageSize | 1404 ? kThumbnailsPageSize |
1382 : gfx::Size(video_file->width, video_file->height)); | 1405 : gfx::Size(video_file->width, video_file->height)); |
1383 } | 1406 } |
1384 | 1407 |
1385 InitializeRenderingHelper(helper_params); | 1408 InitializeRenderingHelper(helper_params); |
1386 | 1409 |
1387 for (size_t index = 0; index < num_concurrent_decoders; ++index) { | 1410 for (size_t index = 0; index < num_concurrent_decoders; ++index) { |
1388 CreateAndStartDecoder(clients[index].get(), notes[index].get()); | 1411 CreateAndStartDecoder(clients_[index].get(), notes_[index].get()); |
1389 } | 1412 } |
1390 | 1413 |
1391 // Then wait for all the decodes to finish. | 1414 // Then wait for all the decodes to finish. |
1392 // Only check performance & correctness later if we play through only once. | 1415 // Only check performance & correctness later if we play through only once. |
1393 bool skip_performance_and_correctness_checks = num_play_throughs > 1; | 1416 bool skip_performance_and_correctness_checks = num_play_throughs > 1; |
1394 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1417 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1395 ClientStateNotification<ClientState>* note = notes[i].get(); | 1418 ClientStateNotification<ClientState>* note = notes_[i].get(); |
1396 ClientState state = note->Wait(); | 1419 ClientState state = note->Wait(); |
1397 if (state != CS_INITIALIZED) { | 1420 if (state != CS_INITIALIZED) { |
1398 skip_performance_and_correctness_checks = true; | 1421 skip_performance_and_correctness_checks = true; |
1399 // We expect initialization to fail only when more than the supported | 1422 // We expect initialization to fail only when more than the supported |
1400 // number of decoders is instantiated. Assert here that something else | 1423 // number of decoders is instantiated. Assert here that something else |
1401 // didn't trigger failure. | 1424 // didn't trigger failure. |
1402 ASSERT_GT(num_concurrent_decoders, | 1425 ASSERT_GT(num_concurrent_decoders, |
1403 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); | 1426 static_cast<size_t>(kMinSupportedNumConcurrentDecoders)); |
1404 continue; | 1427 continue; |
1405 } | 1428 } |
1406 ASSERT_EQ(state, CS_INITIALIZED); | |
1407 for (int n = 0; n < num_play_throughs; ++n) { | 1429 for (int n = 0; n < num_play_throughs; ++n) { |
1408 // For play-throughs other than the first, we expect initialization to | 1430 // For play-throughs other than the first, we expect initialization to |
1409 // succeed unconditionally. | 1431 // succeed unconditionally. |
1410 if (n > 0) { | 1432 if (n > 0) { |
1411 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( | 1433 ASSERT_NO_FATAL_FAILURE(AssertWaitForStateOrDeleted( |
1412 note, clients[i].get(), CS_INITIALIZED)); | 1434 note, clients_[i].get(), CS_INITIALIZED)); |
1413 } | 1435 } |
1414 // InitializeDone kicks off decoding inside the client, so we just need to | 1436 // InitializeDone kicks off decoding inside the client, so we just need to |
1415 // wait for Flush. | 1437 // wait for Flush. |
1416 ASSERT_NO_FATAL_FAILURE( | 1438 ASSERT_NO_FATAL_FAILURE( |
1417 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHING)); | 1439 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHING)); |
1418 ASSERT_NO_FATAL_FAILURE( | 1440 ASSERT_NO_FATAL_FAILURE( |
1419 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_FLUSHED)); | 1441 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_FLUSHED)); |
1420 // FlushDone requests Reset(). | 1442 // FlushDone requests Reset(). |
1421 ASSERT_NO_FATAL_FAILURE( | 1443 ASSERT_NO_FATAL_FAILURE( |
1422 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESETTING)); | 1444 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESETTING)); |
1423 } | 1445 } |
1424 ASSERT_NO_FATAL_FAILURE( | 1446 ASSERT_NO_FATAL_FAILURE( |
1425 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_RESET)); | 1447 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_RESET)); |
1426 // ResetDone requests Destroy(). | 1448 // ResetDone requests Destroy(). |
1427 ASSERT_NO_FATAL_FAILURE( | 1449 ASSERT_NO_FATAL_FAILURE( |
1428 AssertWaitForStateOrDeleted(note, clients[i].get(), CS_DESTROYED)); | 1450 AssertWaitForStateOrDeleted(note, clients_[i].get(), CS_DESTROYED)); |
1429 } | 1451 } |
1430 // Finally assert that decoding went as expected. | 1452 // Finally assert that decoding went as expected. |
1431 for (size_t i = 0; | 1453 for (size_t i = 0; |
1432 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; | 1454 i < num_concurrent_decoders && !skip_performance_and_correctness_checks; |
1433 ++i) { | 1455 ++i) { |
1434 // We can only make performance/correctness assertions if the decoder was | 1456 // We can only make performance/correctness assertions if the decoder was |
1435 // allowed to finish. | 1457 // allowed to finish. |
1436 if (delete_decoder_state < CS_FLUSHED) | 1458 if (delete_decoder_state < CS_FLUSHED) |
1437 continue; | 1459 continue; |
1438 GLRenderingVDAClient* client = clients[i].get(); | 1460 GLRenderingVDAClient* client = clients_[i].get(); |
1439 TestVideoFile* video_file = | 1461 TestVideoFile* video_file = |
1440 test_video_files_[i % test_video_files_.size()].get(); | 1462 test_video_files_[i % test_video_files_.size()].get(); |
1441 if (video_file->num_frames > 0) { | 1463 if (video_file->num_frames > 0) { |
1442 // Expect the decoded frames may be more than the video frames as frames | 1464 // Expect the decoded frames may be more than the video frames as frames |
1443 // could still be returned until resetting done. | 1465 // could still be returned until resetting done. |
1444 if (video_file->reset_after_frame_num > 0) | 1466 if (video_file->reset_after_frame_num > 0) |
1445 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); | 1467 EXPECT_GE(client->num_decoded_frames(), video_file->num_frames); |
1446 else | 1468 else |
1447 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); | 1469 EXPECT_EQ(client->num_decoded_frames(), video_file->num_frames); |
1448 } | 1470 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 &png); | 1512 &png); |
1491 | 1513 |
1492 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1514 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
1493 | 1515 |
1494 base::FilePath filepath(test_video_files_[0]->file_name); | 1516 base::FilePath filepath(test_video_files_[0]->file_name); |
1495 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1517 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
1496 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1518 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
1497 int num_bytes = | 1519 int num_bytes = |
1498 base::WriteFile(GetTestDataFile(filepath), | 1520 base::WriteFile(GetTestDataFile(filepath), |
1499 reinterpret_cast<char*>(&png[0]), png.size()); | 1521 reinterpret_cast<char*>(&png[0]), png.size()); |
1500 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1522 EXPECT_EQ(num_bytes, static_cast<int>(png.size())); |
1501 } | 1523 } |
1502 ASSERT_NE(match, golden_md5s.end()); | 1524 EXPECT_NE(match, golden_md5s.end()); |
1503 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; | 1525 EXPECT_EQ(alpha_solid, true) << "RGBA frame had incorrect alpha"; |
1504 } | 1526 } |
1505 | 1527 |
1506 // Output the frame delivery time to file | 1528 // Output the frame delivery time to file |
1507 // We can only make performance/correctness assertions if the decoder was | 1529 // We can only make performance/correctness assertions if the decoder was |
1508 // allowed to finish. | 1530 // allowed to finish. |
1509 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { | 1531 if (g_output_log != NULL && delete_decoder_state >= CS_FLUSHED) { |
1510 base::File output_file( | 1532 base::File output_file( |
1511 base::FilePath(g_output_log), | 1533 base::FilePath(g_output_log), |
1512 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 1534 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
1513 for (size_t i = 0; i < num_concurrent_decoders; ++i) { | 1535 for (size_t i = 0; i < num_concurrent_decoders; ++i) { |
1514 clients[i]->OutputFrameDeliveryTimes(&output_file); | 1536 clients_[i]->OutputFrameDeliveryTimes(&output_file); |
1515 } | 1537 } |
1516 } | 1538 } |
1517 | |
1518 std::unique_ptr<ClientsVector> clients2(new ClientsVector); | |
1519 clients2->swap(clients); | |
1520 std::unique_ptr<NotesVector> notes2(new NotesVector); | |
1521 notes2->swap(notes); | |
1522 | |
1523 // |clients| must be deleted first because |clients| use |notes2|. | |
1524 g_env->GetRenderingTaskRunner()->PostTask( | |
1525 FROM_HERE, base::Bind(&Delete<ClientsVector>, base::Passed(&clients2))); | |
1526 | |
1527 g_env->GetRenderingTaskRunner()->PostTask( | |
1528 FROM_HERE, base::Bind(&Delete<NotesVector>, base::Passed(¬es2))); | |
1529 | |
1530 WaitUntilIdle(); | |
1531 }; | 1539 }; |
1532 | 1540 |
1533 // Test that replay after EOS works fine. | 1541 // Test that replay after EOS works fine. |
1534 INSTANTIATE_TEST_CASE_P( | 1542 INSTANTIATE_TEST_CASE_P( |
1535 ReplayAfterEOS, | 1543 ReplayAfterEOS, |
1536 VideoDecodeAcceleratorParamTest, | 1544 VideoDecodeAcceleratorParamTest, |
1537 ::testing::Values( | 1545 ::testing::Values( |
1538 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); | 1546 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); |
1539 | 1547 |
1540 // Test that Reset() before the first Decode() works fine. | 1548 // Test that Reset() before the first Decode() works fine. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1849 |
1842 media::g_env = | 1850 media::g_env = |
1843 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1851 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
1844 testing::AddGlobalTestEnvironment( | 1852 testing::AddGlobalTestEnvironment( |
1845 new media::VideoDecodeAcceleratorTestEnvironment())); | 1853 new media::VideoDecodeAcceleratorTestEnvironment())); |
1846 | 1854 |
1847 return base::LaunchUnitTestsSerially( | 1855 return base::LaunchUnitTestsSerially( |
1848 argc, argv, | 1856 argc, argv, |
1849 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | 1857 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); |
1850 } | 1858 } |
OLD | NEW |