Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Side by Side Diff: media/gpu/video_decode_accelerator_unittest.cc

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 // to be written sequentially and wait for the decode client to see certain 11 // to be written sequentially and wait for the decode client to see certain
12 // state transitions. 12 // state transitions.
13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation 13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation
14 // - Finally actual TEST cases are at the bottom of this file, using the above 14 // - Finally actual TEST cases are at the bottom of this file, using the above
15 // infrastructure. 15 // infrastructure.
16 16
17 #include <fcntl.h> 17 #include <fcntl.h>
18 #include <stddef.h> 18 #include <stddef.h>
19 #include <stdint.h> 19 #include <stdint.h>
20 #include <sys/stat.h> 20 #include <sys/stat.h>
21 #include <sys/types.h> 21 #include <sys/types.h>
22 22
23 #include <algorithm> 23 #include <algorithm>
24 #include <deque> 24 #include <deque>
25 #include <map> 25 #include <map>
26 #include <memory> 26 #include <memory>
27 #include <tuple>
27 #include <utility> 28 #include <utility>
28 29
29 #include "base/at_exit.h" 30 #include "base/at_exit.h"
30 #include "base/bind.h" 31 #include "base/bind.h"
31 #include "base/callback_helpers.h" 32 #include "base/callback_helpers.h"
32 #include "base/command_line.h" 33 #include "base/command_line.h"
33 #include "base/files/file.h" 34 #include "base/files/file.h"
34 #include "base/files/file_util.h" 35 #include "base/files/file_util.h"
35 #include "base/format_macros.h" 36 #include "base/format_macros.h"
36 #include "base/macros.h" 37 #include "base/macros.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #include "ui/ozone/public/ozone_gpu_test_helper.h" 81 #include "ui/ozone/public/ozone_gpu_test_helper.h"
81 #include "ui/ozone/public/ozone_platform.h" 82 #include "ui/ozone/public/ozone_platform.h"
82 #include "ui/ozone/public/surface_factory_ozone.h" 83 #include "ui/ozone/public/surface_factory_ozone.h"
83 #endif // defined(USE_OZONE) 84 #endif // defined(USE_OZONE)
84 85
85 using media::VideoDecodeAccelerator; 86 using media::VideoDecodeAccelerator;
86 87
87 namespace media { 88 namespace media {
88 namespace { 89 namespace {
89 90
90 using base::MakeTuple;
91
92 // Values optionally filled in from flags; see main() below. 91 // Values optionally filled in from flags; see main() below.
93 // The syntax of multiple test videos is: 92 // The syntax of multiple test videos is:
94 // test-video1;test-video2;test-video3 93 // test-video1;test-video2;test-video3
95 // where only the first video is required and other optional videos would be 94 // where only the first video is required and other optional videos would be
96 // decoded by concurrent decoders. 95 // decoded by concurrent decoders.
97 // The syntax of each test-video is: 96 // The syntax of each test-video is:
98 // filename:width:height:numframes:numfragments:minFPSwithRender:minFPSnoRender 97 // filename:width:height:numframes:numfragments:minFPSwithRender:minFPSnoRender
99 // where only the first field is required. Value details: 98 // where only the first field is required. Value details:
100 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8/9 stream. 99 // - |filename| must be an h264 Annex B (NAL) stream or an IVF VP8/9 stream.
101 // - |width| and |height| are in pixels. 100 // - |width| and |height| are in pixels.
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 // instantiated. 1234 // instantiated.
1236 // - Number of concurrent in-flight Decode() calls per decoder. 1235 // - Number of concurrent in-flight Decode() calls per decoder.
1237 // - Number of play-throughs. 1236 // - Number of play-throughs.
1238 // - reset_after_frame_num: see GLRenderingVDAClient ctor. 1237 // - reset_after_frame_num: see GLRenderingVDAClient ctor.
1239 // - delete_decoder_phase: see GLRenderingVDAClient ctor. 1238 // - delete_decoder_phase: see GLRenderingVDAClient ctor.
1240 // - whether to test slow rendering by delaying ReusePictureBuffer(). 1239 // - whether to test slow rendering by delaying ReusePictureBuffer().
1241 // - whether the video frames are rendered as thumbnails. 1240 // - whether the video frames are rendered as thumbnails.
1242 class VideoDecodeAcceleratorParamTest 1241 class VideoDecodeAcceleratorParamTest
1243 : public VideoDecodeAcceleratorTest, 1242 : public VideoDecodeAcceleratorTest,
1244 public ::testing::WithParamInterface< 1243 public ::testing::WithParamInterface<
1245 base::Tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {}; 1244 std::tuple<int, int, int, ResetPoint, ClientState, bool, bool>> {};
1246 1245
1247 // Wait for |note| to report a state and if it's not |expected_state| then 1246 // Wait for |note| to report a state and if it's not |expected_state| then
1248 // assert |client| has deleted its decoder. 1247 // assert |client| has deleted its decoder.
1249 static void AssertWaitForStateOrDeleted( 1248 static void AssertWaitForStateOrDeleted(
1250 ClientStateNotification<ClientState>* note, 1249 ClientStateNotification<ClientState>* note,
1251 GLRenderingVDAClient* client, 1250 GLRenderingVDAClient* client,
1252 ClientState expected_state) { 1251 ClientState expected_state) {
1253 ClientState state = note->Wait(); 1252 ClientState state = note->Wait();
1254 if (state == expected_state) 1253 if (state == expected_state)
1255 return; 1254 return;
1256 ASSERT_TRUE(client->decoder_deleted()) 1255 ASSERT_TRUE(client->decoder_deleted())
1257 << "Decoder not deleted but Wait() returned " << state 1256 << "Decoder not deleted but Wait() returned " << state
1258 << ", instead of " << expected_state; 1257 << ", instead of " << expected_state;
1259 } 1258 }
1260 1259
1261 // We assert a minimal number of concurrent decoders we expect to succeed. 1260 // We assert a minimal number of concurrent decoders we expect to succeed.
1262 // Different platforms can support more concurrent decoders, so we don't assert 1261 // Different platforms can support more concurrent decoders, so we don't assert
1263 // failure above this. 1262 // failure above this.
1264 enum { kMinSupportedNumConcurrentDecoders = 3 }; 1263 enum { kMinSupportedNumConcurrentDecoders = 3 };
1265 1264
1266 // Test the most straightforward case possible: data is decoded from a single 1265 // Test the most straightforward case possible: data is decoded from a single
1267 // chunk and rendered to the screen. 1266 // chunk and rendered to the screen.
1268 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) { 1267 TEST_P(VideoDecodeAcceleratorParamTest, TestSimpleDecode) {
1269 size_t num_concurrent_decoders = base::get<0>(GetParam()); 1268 size_t num_concurrent_decoders = std::get<0>(GetParam());
1270 const size_t num_in_flight_decodes = base::get<1>(GetParam()); 1269 const size_t num_in_flight_decodes = std::get<1>(GetParam());
1271 int num_play_throughs = base::get<2>(GetParam()); 1270 int num_play_throughs = std::get<2>(GetParam());
1272 const int reset_point = base::get<3>(GetParam()); 1271 const int reset_point = std::get<3>(GetParam());
1273 const int delete_decoder_state = base::get<4>(GetParam()); 1272 const int delete_decoder_state = std::get<4>(GetParam());
1274 bool test_reuse_delay = base::get<5>(GetParam()); 1273 bool test_reuse_delay = std::get<5>(GetParam());
1275 const bool render_as_thumbnails = base::get<6>(GetParam()); 1274 const bool render_as_thumbnails = std::get<6>(GetParam());
1276 1275
1277 if (test_video_files_.size() > 1) 1276 if (test_video_files_.size() > 1)
1278 num_concurrent_decoders = test_video_files_.size(); 1277 num_concurrent_decoders = test_video_files_.size();
1279 1278
1280 if (g_num_play_throughs > 0) 1279 if (g_num_play_throughs > 0)
1281 num_play_throughs = g_num_play_throughs; 1280 num_play_throughs = g_num_play_throughs;
1282 1281
1283 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point, 1282 UpdateTestVideoFileParams(num_concurrent_decoders, reset_point,
1284 &test_video_files_); 1283 &test_video_files_);
1285 1284
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 std::vector<ClientStateNotification<ClientState>*>>, 1479 std::vector<ClientStateNotification<ClientState>*>>,
1481 &notes)); 1480 &notes));
1482 WaitUntilIdle(); 1481 WaitUntilIdle();
1483 }; 1482 };
1484 1483
1485 // Test that replay after EOS works fine. 1484 // Test that replay after EOS works fine.
1486 INSTANTIATE_TEST_CASE_P( 1485 INSTANTIATE_TEST_CASE_P(
1487 ReplayAfterEOS, 1486 ReplayAfterEOS,
1488 VideoDecodeAcceleratorParamTest, 1487 VideoDecodeAcceleratorParamTest,
1489 ::testing::Values( 1488 ::testing::Values(
1490 MakeTuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false))); 1489 std::make_tuple(1, 1, 4, END_OF_STREAM_RESET, CS_RESET, false, false)));
1491 1490
1492 // Test that Reset() before the first Decode() works fine. 1491 // Test that Reset() before the first Decode() works fine.
1493 INSTANTIATE_TEST_CASE_P( 1492 INSTANTIATE_TEST_CASE_P(ResetBeforeDecode,
1494 ResetBeforeDecode, 1493 VideoDecodeAcceleratorParamTest,
1495 VideoDecodeAcceleratorParamTest, 1494 ::testing::Values(std::make_tuple(1,
1496 ::testing::Values( 1495 1,
1497 MakeTuple(1, 1, 1, START_OF_STREAM_RESET, CS_RESET, false, false))); 1496 1,
1497 START_OF_STREAM_RESET,
1498 CS_RESET,
1499 false,
1500 false)));
1498 1501
1499 // Test Reset() immediately after Decode() containing config info. 1502 // Test Reset() immediately after Decode() containing config info.
1500 INSTANTIATE_TEST_CASE_P( 1503 INSTANTIATE_TEST_CASE_P(
1501 ResetAfterFirstConfigInfo, 1504 ResetAfterFirstConfigInfo,
1502 VideoDecodeAcceleratorParamTest, 1505 VideoDecodeAcceleratorParamTest,
1503 ::testing::Values(MakeTuple(1, 1506 ::testing::Values(std::make_tuple(1,
1504 1, 1507 1,
1505 1, 1508 1,
1506 RESET_AFTER_FIRST_CONFIG_INFO, 1509 RESET_AFTER_FIRST_CONFIG_INFO,
1507 CS_RESET, 1510 CS_RESET,
1508 false, 1511 false,
1509 false))); 1512 false)));
1510 1513
1511 // Test that Reset() mid-stream works fine and doesn't affect decoding even when 1514 // Test that Reset() mid-stream works fine and doesn't affect decoding even when
1512 // Decode() calls are made during the reset. 1515 // Decode() calls are made during the reset.
1513 INSTANTIATE_TEST_CASE_P( 1516 INSTANTIATE_TEST_CASE_P(
1514 MidStreamReset, 1517 MidStreamReset,
1515 VideoDecodeAcceleratorParamTest, 1518 VideoDecodeAcceleratorParamTest,
1516 ::testing::Values( 1519 ::testing::Values(
1517 MakeTuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false))); 1520 std::make_tuple(1, 1, 1, MID_STREAM_RESET, CS_RESET, false, false)));
1518 1521
1519 INSTANTIATE_TEST_CASE_P( 1522 INSTANTIATE_TEST_CASE_P(
1520 SlowRendering, 1523 SlowRendering,
1521 VideoDecodeAcceleratorParamTest, 1524 VideoDecodeAcceleratorParamTest,
1522 ::testing::Values( 1525 ::testing::Values(
1523 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false))); 1526 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, true, false)));
1524 1527
1525 // Test that Destroy() mid-stream works fine (primarily this is testing that no 1528 // Test that Destroy() mid-stream works fine (primarily this is testing that no
1526 // crashes occur). 1529 // crashes occur).
1527 INSTANTIATE_TEST_CASE_P( 1530 INSTANTIATE_TEST_CASE_P(
1528 TearDownTiming, 1531 TearDownTiming,
1529 VideoDecodeAcceleratorParamTest, 1532 VideoDecodeAcceleratorParamTest,
1530 ::testing::Values( 1533 ::testing::Values(
1531 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_DECODER_SET, false, false), 1534 std::make_tuple(1,
1532 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_INITIALIZED, false, false), 1535 1,
1533 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHING, false, false), 1536 1,
1534 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false), 1537 END_OF_STREAM_RESET,
1535 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESETTING, false, false), 1538 CS_DECODER_SET,
1536 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1539 false,
1537 MakeTuple(1, 1540 false),
1538 1, 1541 std::make_tuple(1,
1539 1, 1542 1,
1540 END_OF_STREAM_RESET, 1543 1,
1541 static_cast<ClientState>(-1), 1544 END_OF_STREAM_RESET,
1542 false, 1545 CS_INITIALIZED,
1543 false), 1546 false,
1544 MakeTuple(1, 1547 false),
1545 1, 1548 std::make_tuple(1,
1546 1, 1549 1,
1547 END_OF_STREAM_RESET, 1550 1,
1548 static_cast<ClientState>(-10), 1551 END_OF_STREAM_RESET,
1549 false, 1552 CS_FLUSHING,
1550 false), 1553 false,
1551 MakeTuple(1, 1554 false),
1552 1, 1555 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_FLUSHED, false, false),
1553 1, 1556 std::make_tuple(1,
1554 END_OF_STREAM_RESET, 1557 1,
1555 static_cast<ClientState>(-100), 1558 1,
1556 false, 1559 END_OF_STREAM_RESET,
1557 false))); 1560 CS_RESETTING,
1561 false,
1562 false),
1563 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1564 std::make_tuple(1,
1565 1,
1566 1,
1567 END_OF_STREAM_RESET,
1568 static_cast<ClientState>(-1),
1569 false,
1570 false),
1571 std::make_tuple(1,
1572 1,
1573 1,
1574 END_OF_STREAM_RESET,
1575 static_cast<ClientState>(-10),
1576 false,
1577 false),
1578 std::make_tuple(1,
1579 1,
1580 1,
1581 END_OF_STREAM_RESET,
1582 static_cast<ClientState>(-100),
1583 false,
1584 false)));
1558 1585
1559 // Test that decoding various variation works with multiple in-flight decodes. 1586 // Test that decoding various variation works with multiple in-flight decodes.
1560 INSTANTIATE_TEST_CASE_P( 1587 INSTANTIATE_TEST_CASE_P(
1561 DecodeVariations, 1588 DecodeVariations,
1562 VideoDecodeAcceleratorParamTest, 1589 VideoDecodeAcceleratorParamTest,
1563 ::testing::Values( 1590 ::testing::Values(
1564 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1591 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1565 MakeTuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false), 1592 std::make_tuple(1, 10, 1, END_OF_STREAM_RESET, CS_RESET, false, false),
1566 // Tests queuing. 1593 // Tests queuing.
1567 MakeTuple(1, 15, 1, END_OF_STREAM_RESET, CS_RESET, false, false))); 1594 std::make_tuple(1,
1595 15,
1596 1,
1597 END_OF_STREAM_RESET,
1598 CS_RESET,
1599 false,
1600 false)));
1568 1601
1569 // Find out how many concurrent decoders can go before we exhaust system 1602 // Find out how many concurrent decoders can go before we exhaust system
1570 // resources. 1603 // resources.
1571 INSTANTIATE_TEST_CASE_P(ResourceExhaustion, 1604 INSTANTIATE_TEST_CASE_P(
1572 VideoDecodeAcceleratorParamTest, 1605 ResourceExhaustion,
1573 ::testing::Values( 1606 VideoDecodeAcceleratorParamTest,
1574 // +0 hack below to promote enum to int. 1607 ::testing::Values(
1575 MakeTuple(kMinSupportedNumConcurrentDecoders + 0, 1608 // +0 hack below to promote enum to int.
1576 1, 1609 std::make_tuple(kMinSupportedNumConcurrentDecoders + 0,
1577 1, 1610 1,
1578 END_OF_STREAM_RESET, 1611 1,
1579 CS_RESET, 1612 END_OF_STREAM_RESET,
1580 false, 1613 CS_RESET,
1581 false), 1614 false,
1582 MakeTuple(kMinSupportedNumConcurrentDecoders + 1, 1615 false),
1583 1, 1616 std::make_tuple(kMinSupportedNumConcurrentDecoders + 1,
1584 1, 1617 1,
1585 END_OF_STREAM_RESET, 1618 1,
1586 CS_RESET, 1619 END_OF_STREAM_RESET,
1587 false, 1620 CS_RESET,
1588 false))); 1621 false,
1622 false)));
1589 1623
1590 // Thumbnailing test 1624 // Thumbnailing test
1591 INSTANTIATE_TEST_CASE_P( 1625 INSTANTIATE_TEST_CASE_P(
1592 Thumbnail, 1626 Thumbnail,
1593 VideoDecodeAcceleratorParamTest, 1627 VideoDecodeAcceleratorParamTest,
1594 ::testing::Values( 1628 ::testing::Values(
1595 MakeTuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true))); 1629 std::make_tuple(1, 1, 1, END_OF_STREAM_RESET, CS_RESET, false, true)));
1596 1630
1597 // Measure the median of the decode time when VDA::Decode is called 30 times per 1631 // Measure the median of the decode time when VDA::Decode is called 30 times per
1598 // second. 1632 // second.
1599 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) { 1633 TEST_F(VideoDecodeAcceleratorTest, TestDecodeTimeMedian) {
1600 RenderingHelperParams helper_params; 1634 RenderingHelperParams helper_params;
1601 1635
1602 // Disable rendering by setting the rendering_fps = 0. 1636 // Disable rendering by setting the rendering_fps = 0.
1603 helper_params.rendering_fps = 0; 1637 helper_params.rendering_fps = 0;
1604 helper_params.warm_up_iterations = 0; 1638 helper_params.warm_up_iterations = 0;
1605 helper_params.render_as_thumbnails = false; 1639 helper_params.render_as_thumbnails = false;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 media::VaapiWrapper::PreSandboxInitialization(); 1767 media::VaapiWrapper::PreSandboxInitialization();
1734 #endif 1768 #endif
1735 1769
1736 media::g_env = 1770 media::g_env =
1737 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>( 1771 reinterpret_cast<media::VideoDecodeAcceleratorTestEnvironment*>(
1738 testing::AddGlobalTestEnvironment( 1772 testing::AddGlobalTestEnvironment(
1739 new media::VideoDecodeAcceleratorTestEnvironment())); 1773 new media::VideoDecodeAcceleratorTestEnvironment()));
1740 1774
1741 return RUN_ALL_TESTS(); 1775 return RUN_ALL_TESTS();
1742 } 1776 }
OLDNEW
« no previous file with comments | « media/gpu/android_video_encode_accelerator.cc ('k') | media/gpu/video_encode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698