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 #include <algorithm> | 8 #include <algorithm> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
49 #if defined(ARCH_CPU_ARMEL) || (defined(USE_OZONE) && defined(USE_V4L2_CODEC)) | 49 #if defined(ARCH_CPU_ARMEL) || (defined(USE_OZONE) && defined(USE_V4L2_CODEC)) |
50 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 50 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
51 #endif | 51 #endif |
52 #if defined(ARCH_CPU_X86_FAMILY) | 52 #if defined(ARCH_CPU_X86_FAMILY) |
53 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 53 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
54 #include "content/common/gpu/media/vaapi_wrapper.h" | 54 #include "content/common/gpu/media/vaapi_wrapper.h" |
55 // Status has been defined as int in Xlib.h. | 55 // Status has been defined as int in Xlib.h. |
56 #undef Status | 56 #undef Status |
57 #endif // defined(ARCH_CPU_X86_FAMILY) | 57 #endif // defined(ARCH_CPU_X86_FAMILY) |
58 #elif defined(OS_MACOSX) | |
59 #include "content/common/gpu/media/vt_video_encode_accelerator_mac.h" | |
58 #else | 60 #else |
59 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. | 61 #error The VideoEncodeAcceleratorUnittest is not supported on this platform. |
60 #endif | 62 #endif |
61 | 63 |
62 using media::VideoEncodeAccelerator; | 64 using media::VideoEncodeAccelerator; |
63 | 65 |
64 namespace content { | 66 namespace content { |
65 namespace { | 67 namespace { |
66 | 68 |
67 const media::VideoPixelFormat kInputFormat = media::PIXEL_FORMAT_I420; | 69 const media::VideoPixelFormat kInputFormat = media::PIXEL_FORMAT_I420; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // Further parameters are optional (need to provide preceding positional | 121 // Further parameters are optional (need to provide preceding positional |
120 // parameters if a specific subsequent parameter is required): | 122 // parameters if a specific subsequent parameter is required): |
121 // - |requested_bitrate| requested bitrate in bits per second. | 123 // - |requested_bitrate| requested bitrate in bits per second. |
122 // - |requested_framerate| requested initial framerate. | 124 // - |requested_framerate| requested initial framerate. |
123 // - |requested_subsequent_bitrate| bitrate to switch to in the middle of the | 125 // - |requested_subsequent_bitrate| bitrate to switch to in the middle of the |
124 // stream. | 126 // stream. |
125 // - |requested_subsequent_framerate| framerate to switch to in the middle | 127 // - |requested_subsequent_framerate| framerate to switch to in the middle |
126 // of the stream. | 128 // of the stream. |
127 // Bitrate is only forced for tests that test bitrate. | 129 // Bitrate is only forced for tests that test bitrate. |
128 const char* g_default_in_filename = "bear_320x192_40frames.yuv"; | 130 const char* g_default_in_filename = "bear_320x192_40frames.yuv"; |
131 #if !defined(OS_MACOSX) | |
129 const char* g_default_in_parameters = ":320:192:1:out.h264:200000"; | 132 const char* g_default_in_parameters = ":320:192:1:out.h264:200000"; |
133 #else | |
134 const char* g_default_in_parameters = ":320:192:0:out.h264:200000"; | |
135 #endif | |
130 | 136 |
131 // Enabled by including a --fake_encoder flag to the command line invoking the | 137 // Enabled by including a --fake_encoder flag to the command line invoking the |
132 // test. | 138 // test. |
133 bool g_fake_encoder = false; | 139 bool g_fake_encoder = false; |
134 | 140 |
135 // Environment to store test stream data for all test cases. | 141 // Environment to store test stream data for all test cases. |
136 class VideoEncodeAcceleratorTestEnvironment; | 142 class VideoEncodeAcceleratorTestEnvironment; |
137 VideoEncodeAcceleratorTestEnvironment* g_env; | 143 VideoEncodeAcceleratorTestEnvironment* g_env; |
138 | 144 |
139 // The number of frames to be encoded. This variable is set by the switch | 145 // The number of frames to be encoded. This variable is set by the switch |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
803 | 809 |
804 private: | 810 private: |
805 bool has_encoder() { return encoder_.get(); } | 811 bool has_encoder() { return encoder_.get(); } |
806 | 812 |
807 // Return the number of encoded frames per second. | 813 // Return the number of encoded frames per second. |
808 double frames_per_second(); | 814 double frames_per_second(); |
809 | 815 |
810 scoped_ptr<media::VideoEncodeAccelerator> CreateFakeVEA(); | 816 scoped_ptr<media::VideoEncodeAccelerator> CreateFakeVEA(); |
811 scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); | 817 scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); |
812 scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); | 818 scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); |
819 scoped_ptr<media::VideoEncodeAccelerator> CreateVTVEA(); | |
813 | 820 |
814 void SetState(ClientState new_state); | 821 void SetState(ClientState new_state); |
815 | 822 |
816 // Set current stream parameters to given |bitrate| at |framerate|. | 823 // Set current stream parameters to given |bitrate| at |framerate|. |
817 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); | 824 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); |
818 | 825 |
819 // Called when encoder is done with a VideoFrame. | 826 // Called when encoder is done with a VideoFrame. |
820 void InputNoLongerNeededCallback(int32_t input_id); | 827 void InputNoLongerNeededCallback(int32_t input_id); |
821 | 828 |
822 // Feed the encoder with one input frame. | 829 // Feed the encoder with one input frame. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 } | 1071 } |
1065 | 1072 |
1066 scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVaapiVEA() { | 1073 scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVaapiVEA() { |
1067 scoped_ptr<media::VideoEncodeAccelerator> encoder; | 1074 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
1068 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 1075 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
1069 encoder.reset(new VaapiVideoEncodeAccelerator()); | 1076 encoder.reset(new VaapiVideoEncodeAccelerator()); |
1070 #endif | 1077 #endif |
1071 return encoder; | 1078 return encoder; |
1072 } | 1079 } |
1073 | 1080 |
1081 scoped_ptr<media::VideoEncodeAccelerator> VEAClient::CreateVTVEA() { | |
1082 scoped_ptr<media::VideoEncodeAccelerator> encoder; | |
1083 #if defined(OS_MACOSX) | |
1084 encoder.reset(new VTVideoEncodeAccelerator()); | |
1085 #endif | |
1086 return encoder; | |
1087 } | |
1088 | |
1074 void VEAClient::CreateEncoder() { | 1089 void VEAClient::CreateEncoder() { |
1075 DCHECK(thread_checker_.CalledOnValidThread()); | 1090 DCHECK(thread_checker_.CalledOnValidThread()); |
1076 LOG_ASSERT(!has_encoder()); | 1091 LOG_ASSERT(!has_encoder()); |
1077 | 1092 |
1078 scoped_ptr<media::VideoEncodeAccelerator> encoders[] = { | 1093 scoped_ptr<media::VideoEncodeAccelerator> encoders[] = { |
1079 CreateFakeVEA(), | 1094 CreateFakeVEA(), |
1080 CreateV4L2VEA(), | 1095 CreateV4L2VEA(), |
1081 CreateVaapiVEA() | 1096 CreateVaapiVEA(), |
1097 CreateVTVEA() | |
1082 }; | 1098 }; |
1083 | 1099 |
1084 DVLOG(1) << "Profile: " << test_stream_->requested_profile | 1100 DVLOG(1) << "Profile: " << test_stream_->requested_profile |
1085 << ", initial bitrate: " << requested_bitrate_; | 1101 << ", initial bitrate: " << requested_bitrate_; |
1086 | 1102 |
1087 for (size_t i = 0; i < arraysize(encoders); ++i) { | 1103 for (size_t i = 0; i < arraysize(encoders); ++i) { |
1088 if (!encoders[i]) | 1104 if (!encoders[i]) |
1089 continue; | 1105 continue; |
1090 encoder_ = std::move(encoders[i]); | 1106 encoder_ = std::move(encoders[i]); |
1091 SetState(CS_ENCODER_SET); | 1107 SetState(CS_ENCODER_SET); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 1658 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
1643 encoder_thread.message_loop()->PostTask( | 1659 encoder_thread.message_loop()->PostTask( |
1644 FROM_HERE, | 1660 FROM_HERE, |
1645 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 1661 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
1646 } | 1662 } |
1647 | 1663 |
1648 // This ensures all tasks have finished. | 1664 // This ensures all tasks have finished. |
1649 encoder_thread.Stop(); | 1665 encoder_thread.Stop(); |
1650 } | 1666 } |
1651 | 1667 |
1668 #if !defined(OS_MACOSX) | |
1652 INSTANTIATE_TEST_CASE_P( | 1669 INSTANTIATE_TEST_CASE_P( |
1653 SimpleEncode, | 1670 SimpleEncode, |
1654 VideoEncodeAcceleratorTest, | 1671 VideoEncodeAcceleratorTest, |
1655 ::testing::Values( | 1672 ::testing::Values( |
1656 base::MakeTuple(1, true, 0, false, false, false, false, false), | 1673 base::MakeTuple(1, true, 0, false, false, false, false, false), |
1657 base::MakeTuple(1, true, 0, false, false, false, false, true))); | 1674 base::MakeTuple(1, true, 0, false, false, false, false, true))); |
1658 | 1675 |
1659 INSTANTIATE_TEST_CASE_P( | 1676 INSTANTIATE_TEST_CASE_P( |
1660 EncoderPerf, | 1677 EncoderPerf, |
1661 VideoEncodeAcceleratorTest, | 1678 VideoEncodeAcceleratorTest, |
(...skipping 24 matching lines...) Expand all Loading... | |
1686 ::testing::Values( | 1703 ::testing::Values( |
1687 base::MakeTuple(1, false, 0, true, false, false, true, false))); | 1704 base::MakeTuple(1, false, 0, true, false, false, true, false))); |
1688 | 1705 |
1689 INSTANTIATE_TEST_CASE_P( | 1706 INSTANTIATE_TEST_CASE_P( |
1690 MultipleEncoders, | 1707 MultipleEncoders, |
1691 VideoEncodeAcceleratorTest, | 1708 VideoEncodeAcceleratorTest, |
1692 ::testing::Values( | 1709 ::testing::Values( |
1693 base::MakeTuple(3, false, 0, false, false, false, false, false), | 1710 base::MakeTuple(3, false, 0, false, false, false, false, false), |
1694 base::MakeTuple(3, false, 0, true, false, false, true, false), | 1711 base::MakeTuple(3, false, 0, true, false, false, true, false), |
1695 base::MakeTuple(3, false, 0, true, false, true, false, false))); | 1712 base::MakeTuple(3, false, 0, true, false, true, false, false))); |
1713 #else | |
1714 INSTANTIATE_TEST_CASE_P( | |
miu
2016/02/10 21:04:56
BTW--Will these tests run in the waterfall? IIRC,
emircan
2016/02/11 09:22:09
I changed content/content_tests.gypi to build this
miu
2016/02/11 21:09:40
I'm not sure about this one. I think it has depen
Pawel Osciak
2016/02/18 11:16:14
We have a short raw stream in Chromium tree that c
| |
1715 SimpleEncode, | |
1716 VideoEncodeAcceleratorTest, | |
1717 ::testing::Values( | |
1718 base::MakeTuple(1, true, 0, false, false, false, false, false))); | |
1719 | |
1720 INSTANTIATE_TEST_CASE_P( | |
1721 EncoderPerf, | |
1722 VideoEncodeAcceleratorTest, | |
1723 ::testing::Values( | |
1724 base::MakeTuple(1, false, 0, false, true, false, false, false))); | |
1725 | |
1726 INSTANTIATE_TEST_CASE_P( | |
1727 MultipleEncoders, | |
1728 VideoEncodeAcceleratorTest, | |
1729 ::testing::Values( | |
1730 base::MakeTuple(3, false, 0, false, false, false, false, false))); | |
1731 #endif | |
1696 | 1732 |
1697 // TODO(posciak): more tests: | 1733 // TODO(posciak): more tests: |
1698 // - async FeedEncoderWithOutput | 1734 // - async FeedEncoderWithOutput |
1699 // - out-of-order return of outputs to encoder | 1735 // - out-of-order return of outputs to encoder |
1700 // - multiple encoders + decoders | 1736 // - multiple encoders + decoders |
1701 // - mid-stream encoder_->Destroy() | 1737 // - mid-stream encoder_->Destroy() |
1702 | 1738 |
1703 } // namespace | 1739 } // namespace |
1704 } // namespace content | 1740 } // namespace content |
1705 | 1741 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1783 | 1819 |
1784 content::g_env = | 1820 content::g_env = |
1785 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( | 1821 reinterpret_cast<content::VideoEncodeAcceleratorTestEnvironment*>( |
1786 testing::AddGlobalTestEnvironment( | 1822 testing::AddGlobalTestEnvironment( |
1787 new content::VideoEncodeAcceleratorTestEnvironment( | 1823 new content::VideoEncodeAcceleratorTestEnvironment( |
1788 std::move(test_stream_data), log_path, run_at_fps, | 1824 std::move(test_stream_data), log_path, run_at_fps, |
1789 needs_encode_latency, verify_all_output))); | 1825 needs_encode_latency, verify_all_output))); |
1790 | 1826 |
1791 return RUN_ALL_TESTS(); | 1827 return RUN_ALL_TESTS(); |
1792 } | 1828 } |
OLD | NEW |