| 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 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 // Wait for |note| to report a state and if it's not |expected_state| then | 1249 // Wait for |note| to report a state and if it's not |expected_state| then |
| 1250 // assert |client| has deleted its decoder. | 1250 // assert |client| has deleted its decoder. |
| 1251 static void AssertWaitForStateOrDeleted( | 1251 static void AssertWaitForStateOrDeleted( |
| 1252 ClientStateNotification<ClientState>* note, | 1252 ClientStateNotification<ClientState>* note, |
| 1253 GLRenderingVDAClient* client, | 1253 GLRenderingVDAClient* client, |
| 1254 ClientState expected_state) { | 1254 ClientState expected_state) { |
| 1255 ClientState state = note->Wait(); | 1255 ClientState state = note->Wait(); |
| 1256 if (state == expected_state) | 1256 if (state == expected_state) |
| 1257 return; | 1257 return; |
| 1258 ASSERT_TRUE(client->decoder_deleted()) | 1258 ASSERT_TRUE(client->decoder_deleted()) |
| 1259 << "Decoder not deleted but Wait() returned " << state << ", instead of " | 1259 << "Decoder not deleted but Wait() returned " << state |
| 1260 << expected_state; | 1260 << ", instead of " << expected_state; |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 // We assert a minimal number of concurrent decoders we expect to succeed. | 1263 // We assert a minimal number of concurrent decoders we expect to succeed. |
| 1264 // Different platforms can support more concurrent decoders, so we don't assert | 1264 // Different platforms can support more concurrent decoders, so we don't assert |
| 1265 // failure above this. | 1265 // failure above this. |
| 1266 enum { kMinSupportedNumConcurrentDecoders = 3 }; | 1266 enum { kMinSupportedNumConcurrentDecoders = 3 }; |
| 1267 | 1267 |
| 1268 // Test the most straightforward case possible: data is decoded from a single | 1268 // Test the most straightforward case possible: data is decoded from a single |
| 1269 // chunk and rendered to the screen. | 1269 // chunk and rendered to the screen. |
| 1270 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { | 1270 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 ClientStateNotification<ClientState>* note = | 1310 ClientStateNotification<ClientState>* note = |
| 1311 new ClientStateNotification<ClientState>(); | 1311 new ClientStateNotification<ClientState>(); |
| 1312 notes[index] = note; | 1312 notes[index] = note; |
| 1313 | 1313 |
| 1314 int delay_after_frame_num = std::numeric_limits<int>::max(); | 1314 int delay_after_frame_num = std::numeric_limits<int>::max(); |
| 1315 if (test_reuse_delay && | 1315 if (test_reuse_delay && |
| 1316 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { | 1316 kMaxFramesToDelayReuse * 2 < video_file->num_frames) { |
| 1317 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; | 1317 delay_after_frame_num = video_file->num_frames - kMaxFramesToDelayReuse; |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 GLRenderingVDAClient* client = new GLRenderingVDAClient( | 1320 GLRenderingVDAClient* client = |
| 1321 index, &rendering_helper_, note, video_file->data_str, | 1321 new GLRenderingVDAClient(index, |
| 1322 num_in_flight_decodes, num_play_throughs, | 1322 &rendering_helper_, |
| 1323 video_file->reset_after_frame_num, delete_decoder_state, | 1323 note, |
| 1324 video_file->width, video_file->height, video_file->profile, | 1324 video_file->data_str, |
| 1325 g_fake_decoder, suppress_rendering, delay_after_frame_num, 0, | 1325 num_in_flight_decodes, |
| 1326 render_as_thumbnails); | 1326 num_play_throughs, |
| 1327 video_file->reset_after_frame_num, |
| 1328 delete_decoder_state, |
| 1329 video_file->width, |
| 1330 video_file->height, |
| 1331 video_file->profile, |
| 1332 g_fake_decoder, |
| 1333 suppress_rendering, |
| 1334 delay_after_frame_num, |
| 1335 0, |
| 1336 render_as_thumbnails); |
| 1327 | 1337 |
| 1328 clients[index] = client; | 1338 clients[index] = client; |
| 1329 helper_params.window_sizes.push_back( | 1339 helper_params.window_sizes.push_back( |
| 1330 render_as_thumbnails | 1340 render_as_thumbnails |
| 1331 ? kThumbnailsPageSize | 1341 ? kThumbnailsPageSize |
| 1332 : gfx::Size(video_file->width, video_file->height)); | 1342 : gfx::Size(video_file->width, video_file->height)); |
| 1333 } | 1343 } |
| 1334 | 1344 |
| 1335 InitializeRenderingHelper(helper_params); | 1345 InitializeRenderingHelper(helper_params); |
| 1336 | 1346 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 | 1432 |
| 1423 std::vector<std::string> golden_md5s; | 1433 std::vector<std::string> golden_md5s; |
| 1424 std::string md5_string = base::MD5String( | 1434 std::string md5_string = base::MD5String( |
| 1425 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); | 1435 base::StringPiece(reinterpret_cast<char*>(&rgb[0]), rgb.size())); |
| 1426 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); | 1436 ReadGoldenThumbnailMD5s(test_video_files_[0], &golden_md5s); |
| 1427 std::vector<std::string>::iterator match = | 1437 std::vector<std::string>::iterator match = |
| 1428 find(golden_md5s.begin(), golden_md5s.end(), md5_string); | 1438 find(golden_md5s.begin(), golden_md5s.end(), md5_string); |
| 1429 if (match == golden_md5s.end()) { | 1439 if (match == golden_md5s.end()) { |
| 1430 // Convert raw RGB into PNG for export. | 1440 // Convert raw RGB into PNG for export. |
| 1431 std::vector<unsigned char> png; | 1441 std::vector<unsigned char> png; |
| 1432 gfx::PNGCodec::Encode(&rgb[0], gfx::PNGCodec::FORMAT_RGB, | 1442 gfx::PNGCodec::Encode(&rgb[0], |
| 1443 gfx::PNGCodec::FORMAT_RGB, |
| 1433 kThumbnailsPageSize, | 1444 kThumbnailsPageSize, |
| 1434 kThumbnailsPageSize.width() * 3, true, | 1445 kThumbnailsPageSize.width() * 3, |
| 1435 std::vector<gfx::PNGCodec::Comment>(), &png); | 1446 true, |
| 1447 std::vector<gfx::PNGCodec::Comment>(), |
| 1448 &png); |
| 1436 | 1449 |
| 1437 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; | 1450 LOG(ERROR) << "Unknown thumbnails MD5: " << md5_string; |
| 1438 | 1451 |
| 1439 base::FilePath filepath(test_video_files_[0]->file_name); | 1452 base::FilePath filepath(test_video_files_[0]->file_name); |
| 1440 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); | 1453 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".bad_thumbnails")); |
| 1441 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); | 1454 filepath = filepath.AddExtension(FILE_PATH_LITERAL(".png")); |
| 1442 int num_bytes = base::WriteFile( | 1455 int num_bytes = base::WriteFile( |
| 1443 filepath, reinterpret_cast<char*>(&png[0]), png.size()); | 1456 filepath, reinterpret_cast<char*>(&png[0]), png.size()); |
| 1444 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); | 1457 ASSERT_EQ(num_bytes, static_cast<int>(png.size())); |
| 1445 } | 1458 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { | 1601 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { |
| 1589 RenderingHelperParams helper_params; | 1602 RenderingHelperParams helper_params; |
| 1590 | 1603 |
| 1591 // Disable rendering by setting the rendering_fps = 0. | 1604 // Disable rendering by setting the rendering_fps = 0. |
| 1592 helper_params.rendering_fps = 0; | 1605 helper_params.rendering_fps = 0; |
| 1593 helper_params.warm_up_iterations = 0; | 1606 helper_params.warm_up_iterations = 0; |
| 1594 helper_params.render_as_thumbnails = false; | 1607 helper_params.render_as_thumbnails = false; |
| 1595 | 1608 |
| 1596 ClientStateNotification<ClientState>* note = | 1609 ClientStateNotification<ClientState>* note = |
| 1597 new ClientStateNotification<ClientState>(); | 1610 new ClientStateNotification<ClientState>(); |
| 1598 GLRenderingVDAClient* client = new GLRenderingVDAClient( | 1611 GLRenderingVDAClient* client = |
| 1599 0, &rendering_helper_, note, test_video_files_[0]->data_str, 1, 1, | 1612 new GLRenderingVDAClient(0, |
| 1600 test_video_files_[0]->reset_after_frame_num, CS_RESET, | 1613 &rendering_helper_, |
| 1601 test_video_files_[0]->width, test_video_files_[0]->height, | 1614 note, |
| 1602 test_video_files_[0]->profile, g_fake_decoder, true, | 1615 test_video_files_[0]->data_str, |
| 1603 std::numeric_limits<int>::max(), kWebRtcDecodeCallsPerSecond, | 1616 1, |
| 1604 false /* render_as_thumbnail */); | 1617 1, |
| 1618 test_video_files_[0]->reset_after_frame_num, |
| 1619 CS_RESET, |
| 1620 test_video_files_[0]->width, |
| 1621 test_video_files_[0]->height, |
| 1622 test_video_files_[0]->profile, |
| 1623 g_fake_decoder, |
| 1624 true, |
| 1625 std::numeric_limits<int>::max(), |
| 1626 kWebRtcDecodeCallsPerSecond, |
| 1627 false /* render_as_thumbnail */); |
| 1605 helper_params.window_sizes.push_back( | 1628 helper_params.window_sizes.push_back( |
| 1606 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); | 1629 gfx::Size(test_video_files_[0]->width, test_video_files_[0]->height)); |
| 1607 InitializeRenderingHelper(helper_params); | 1630 InitializeRenderingHelper(helper_params); |
| 1608 CreateAndStartDecoder(client, note); | 1631 CreateAndStartDecoder(client, note); |
| 1609 WaitUntilDecodeFinish(note); | 1632 WaitUntilDecodeFinish(note); |
| 1610 | 1633 |
| 1611 base::TimeDelta decode_time_median = client->decode_time_median(); | 1634 base::TimeDelta decode_time_median = client->decode_time_median(); |
| 1612 std::string output_string = | 1635 std::string output_string = |
| 1613 base::StringPrintf("Decode time median: %" PRId64 " us", | 1636 base::StringPrintf("Decode time median: %" PRId64 " us", |
| 1614 decode_time_median.InMicroseconds()); | 1637 decode_time_median.InMicroseconds()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 media::VaapiWrapper::PreSandboxInitialization(); | 1735 media::VaapiWrapper::PreSandboxInitialization(); |
| 1713 #endif | 1736 #endif |
| 1714 | 1737 |
| 1715 media::g_env = | 1738 media::g_env = |
| 1716 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( | 1739 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( |
| 1717 testing::AddGlobalTestEnvironment( | 1740 testing::AddGlobalTestEnvironment( |
| 1718 new media::VideoDecodeAcceleratorTestEnvironment())); | 1741 new media::VideoDecodeAcceleratorTestEnvironment())); |
| 1719 | 1742 |
| 1720 return RUN_ALL_TESTS(); | 1743 return RUN_ALL_TESTS(); |
| 1721 } | 1744 } |
| OLD | NEW |