| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <inttypes.h> | 5 #include <inttypes.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 // - If true, save output to file (provided an output filename was supplied). | 1565 // - If true, save output to file (provided an output filename was supplied). |
| 1566 // - Force a keyframe every n frames. | 1566 // - Force a keyframe every n frames. |
| 1567 // - Force bitrate; the actual required value is provided as a property | 1567 // - Force bitrate; the actual required value is provided as a property |
| 1568 // of the input stream, because it depends on stream type/resolution/etc. | 1568 // of the input stream, because it depends on stream type/resolution/etc. |
| 1569 // - If true, measure performance. | 1569 // - If true, measure performance. |
| 1570 // - If true, switch bitrate mid-stream. | 1570 // - If true, switch bitrate mid-stream. |
| 1571 // - If true, switch framerate mid-stream. | 1571 // - If true, switch framerate mid-stream. |
| 1572 // - If true, verify the output frames of encoder. | 1572 // - If true, verify the output frames of encoder. |
| 1573 class VideoEncodeAcceleratorTest | 1573 class VideoEncodeAcceleratorTest |
| 1574 : public ::testing::TestWithParam< | 1574 : public ::testing::TestWithParam< |
| 1575 base::Tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; | 1575 std::tuple<int, bool, int, bool, bool, bool, bool, bool>> {}; |
| 1576 | 1576 |
| 1577 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { | 1577 TEST_P(VideoEncodeAcceleratorTest, TestSimpleEncode) { |
| 1578 size_t num_concurrent_encoders = base::get<0>(GetParam()); | 1578 size_t num_concurrent_encoders = std::get<0>(GetParam()); |
| 1579 const bool save_to_file = base::get<1>(GetParam()); | 1579 const bool save_to_file = std::get<1>(GetParam()); |
| 1580 const unsigned int keyframe_period = base::get<2>(GetParam()); | 1580 const unsigned int keyframe_period = std::get<2>(GetParam()); |
| 1581 const bool force_bitrate = base::get<3>(GetParam()); | 1581 const bool force_bitrate = std::get<3>(GetParam()); |
| 1582 const bool test_perf = base::get<4>(GetParam()); | 1582 const bool test_perf = std::get<4>(GetParam()); |
| 1583 const bool mid_stream_bitrate_switch = base::get<5>(GetParam()); | 1583 const bool mid_stream_bitrate_switch = std::get<5>(GetParam()); |
| 1584 const bool mid_stream_framerate_switch = base::get<6>(GetParam()); | 1584 const bool mid_stream_framerate_switch = std::get<6>(GetParam()); |
| 1585 const bool verify_output = | 1585 const bool verify_output = |
| 1586 base::get<7>(GetParam()) || g_env->verify_all_output(); | 1586 std::get<7>(GetParam()) || g_env->verify_all_output(); |
| 1587 | 1587 |
| 1588 ScopedVector<ClientStateNotification<ClientState>> notes; | 1588 ScopedVector<ClientStateNotification<ClientState>> notes; |
| 1589 ScopedVector<VEAClient> clients; | 1589 ScopedVector<VEAClient> clients; |
| 1590 base::Thread encoder_thread("EncoderThread"); | 1590 base::Thread encoder_thread("EncoderThread"); |
| 1591 ASSERT_TRUE(encoder_thread.Start()); | 1591 ASSERT_TRUE(encoder_thread.Start()); |
| 1592 | 1592 |
| 1593 if (g_env->test_streams_.size() > 1) | 1593 if (g_env->test_streams_.size() > 1) |
| 1594 num_concurrent_encoders = g_env->test_streams_.size(); | 1594 num_concurrent_encoders = g_env->test_streams_.size(); |
| 1595 | 1595 |
| 1596 // Create all encoders. | 1596 // Create all encoders. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 | 1637 |
| 1638 // This ensures all tasks have finished. | 1638 // This ensures all tasks have finished. |
| 1639 encoder_thread.Stop(); | 1639 encoder_thread.Stop(); |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 #if !defined(OS_MACOSX) | 1642 #if !defined(OS_MACOSX) |
| 1643 INSTANTIATE_TEST_CASE_P( | 1643 INSTANTIATE_TEST_CASE_P( |
| 1644 SimpleEncode, | 1644 SimpleEncode, |
| 1645 VideoEncodeAcceleratorTest, | 1645 VideoEncodeAcceleratorTest, |
| 1646 ::testing::Values( | 1646 ::testing::Values( |
| 1647 base::MakeTuple(1, true, 0, false, false, false, false, false), | 1647 std::make_tuple(1, true, 0, false, false, false, false, false), |
| 1648 base::MakeTuple(1, true, 0, false, false, false, false, true))); | 1648 std::make_tuple(1, true, 0, false, false, false, false, true))); |
| 1649 | 1649 |
| 1650 INSTANTIATE_TEST_CASE_P( | 1650 INSTANTIATE_TEST_CASE_P( |
| 1651 EncoderPerf, | 1651 EncoderPerf, |
| 1652 VideoEncodeAcceleratorTest, | 1652 VideoEncodeAcceleratorTest, |
| 1653 ::testing::Values( | 1653 ::testing::Values( |
| 1654 base::MakeTuple(1, false, 0, false, true, false, false, false))); | 1654 std::make_tuple(1, false, 0, false, true, false, false, false))); |
| 1655 | 1655 |
| 1656 INSTANTIATE_TEST_CASE_P( | 1656 INSTANTIATE_TEST_CASE_P( |
| 1657 ForceKeyframes, | 1657 ForceKeyframes, |
| 1658 VideoEncodeAcceleratorTest, | 1658 VideoEncodeAcceleratorTest, |
| 1659 ::testing::Values( | 1659 ::testing::Values( |
| 1660 base::MakeTuple(1, false, 10, false, false, false, false, false))); | 1660 std::make_tuple(1, false, 10, false, false, false, false, false))); |
| 1661 | 1661 |
| 1662 INSTANTIATE_TEST_CASE_P( | 1662 INSTANTIATE_TEST_CASE_P( |
| 1663 ForceBitrate, | 1663 ForceBitrate, |
| 1664 VideoEncodeAcceleratorTest, | 1664 VideoEncodeAcceleratorTest, |
| 1665 ::testing::Values( | 1665 ::testing::Values( |
| 1666 base::MakeTuple(1, false, 0, true, false, false, false, false))); | 1666 std::make_tuple(1, false, 0, true, false, false, false, false))); |
| 1667 | 1667 |
| 1668 INSTANTIATE_TEST_CASE_P( | 1668 INSTANTIATE_TEST_CASE_P( |
| 1669 MidStreamParamSwitchBitrate, | 1669 MidStreamParamSwitchBitrate, |
| 1670 VideoEncodeAcceleratorTest, | 1670 VideoEncodeAcceleratorTest, |
| 1671 ::testing::Values( | 1671 ::testing::Values( |
| 1672 base::MakeTuple(1, false, 0, true, false, true, false, false))); | 1672 std::make_tuple(1, false, 0, true, false, true, false, false))); |
| 1673 | 1673 |
| 1674 INSTANTIATE_TEST_CASE_P( | 1674 INSTANTIATE_TEST_CASE_P( |
| 1675 MidStreamParamSwitchFPS, | 1675 MidStreamParamSwitchFPS, |
| 1676 VideoEncodeAcceleratorTest, | 1676 VideoEncodeAcceleratorTest, |
| 1677 ::testing::Values( | 1677 ::testing::Values( |
| 1678 base::MakeTuple(1, false, 0, true, false, false, true, false))); | 1678 std::make_tuple(1, false, 0, true, false, false, true, false))); |
| 1679 | 1679 |
| 1680 INSTANTIATE_TEST_CASE_P( | 1680 INSTANTIATE_TEST_CASE_P( |
| 1681 MultipleEncoders, | 1681 MultipleEncoders, |
| 1682 VideoEncodeAcceleratorTest, | 1682 VideoEncodeAcceleratorTest, |
| 1683 ::testing::Values( | 1683 ::testing::Values( |
| 1684 base::MakeTuple(3, false, 0, false, false, false, false, false), | 1684 std::make_tuple(3, false, 0, false, false, false, false, false), |
| 1685 base::MakeTuple(3, false, 0, true, false, false, true, false), | 1685 std::make_tuple(3, false, 0, true, false, false, true, false), |
| 1686 base::MakeTuple(3, false, 0, true, false, true, false, false))); | 1686 std::make_tuple(3, false, 0, true, false, true, false, false))); |
| 1687 #else | 1687 #else |
| 1688 INSTANTIATE_TEST_CASE_P( | 1688 INSTANTIATE_TEST_CASE_P( |
| 1689 SimpleEncode, | 1689 SimpleEncode, |
| 1690 VideoEncodeAcceleratorTest, | 1690 VideoEncodeAcceleratorTest, |
| 1691 ::testing::Values( | 1691 ::testing::Values( |
| 1692 base::MakeTuple(1, true, 0, false, false, false, false, false), | 1692 std::make_tuple(1, true, 0, false, false, false, false, false), |
| 1693 base::MakeTuple(1, true, 0, false, false, false, false, true))); | 1693 std::make_tuple(1, true, 0, false, false, false, false, true))); |
| 1694 | 1694 |
| 1695 INSTANTIATE_TEST_CASE_P( | 1695 INSTANTIATE_TEST_CASE_P( |
| 1696 EncoderPerf, | 1696 EncoderPerf, |
| 1697 VideoEncodeAcceleratorTest, | 1697 VideoEncodeAcceleratorTest, |
| 1698 ::testing::Values( | 1698 ::testing::Values( |
| 1699 base::MakeTuple(1, false, 0, false, true, false, false, false))); | 1699 std::make_tuple(1, false, 0, false, true, false, false, false))); |
| 1700 | 1700 |
| 1701 INSTANTIATE_TEST_CASE_P( | 1701 INSTANTIATE_TEST_CASE_P( |
| 1702 MultipleEncoders, | 1702 MultipleEncoders, |
| 1703 VideoEncodeAcceleratorTest, | 1703 VideoEncodeAcceleratorTest, |
| 1704 ::testing::Values( | 1704 ::testing::Values( |
| 1705 base::MakeTuple(3, false, 0, false, false, false, false, false))); | 1705 std::make_tuple(3, false, 0, false, false, false, false, false))); |
| 1706 #endif | 1706 #endif |
| 1707 | 1707 |
| 1708 // TODO(posciak): more tests: | 1708 // TODO(posciak): more tests: |
| 1709 // - async FeedEncoderWithOutput | 1709 // - async FeedEncoderWithOutput |
| 1710 // - out-of-order return of outputs to encoder | 1710 // - out-of-order return of outputs to encoder |
| 1711 // - multiple encoders + decoders | 1711 // - multiple encoders + decoders |
| 1712 // - mid-stream encoder_->Destroy() | 1712 // - mid-stream encoder_->Destroy() |
| 1713 | 1713 |
| 1714 } // namespace | 1714 } // namespace |
| 1715 } // namespace media | 1715 } // namespace media |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 | 1793 |
| 1794 media::g_env = | 1794 media::g_env = |
| 1795 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 1795 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 1796 testing::AddGlobalTestEnvironment( | 1796 testing::AddGlobalTestEnvironment( |
| 1797 new media::VideoEncodeAcceleratorTestEnvironment( | 1797 new media::VideoEncodeAcceleratorTestEnvironment( |
| 1798 std::move(test_stream_data), log_path, run_at_fps, | 1798 std::move(test_stream_data), log_path, run_at_fps, |
| 1799 needs_encode_latency, verify_all_output))); | 1799 needs_encode_latency, verify_all_output))); |
| 1800 | 1800 |
| 1801 return RUN_ALL_TESTS(); | 1801 return RUN_ALL_TESTS(); |
| 1802 } | 1802 } |
| OLD | NEW |