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

Side by Side Diff: media/base/yuv_convert_perftest.cc

Issue 1288223003: Revert of add ConvertYUVAToARGBRow_MMX to media_perftests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/cpu.h" 6 #include "base/cpu.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "media/base/simd/convert_yuv_to_rgb.h" 11 #include "media/base/simd/convert_yuv_to_rgb.h"
12 #include "media/base/yuv_convert.h" 12 #include "media/base/yuv_convert.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/perf/perf_test.h" 14 #include "testing/perf/perf_test.h"
15 #include "third_party/libyuv/include/libyuv/row.h"
16 15
17 namespace media { 16 namespace media {
18 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) 17 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY)
19 // Size of raw image. 18 // Size of raw image.
20 static const int kSourceWidth = 640; 19 static const int kSourceWidth = 640;
21 static const int kSourceHeight = 360; 20 static const int kSourceHeight = 360;
22 static const int kSourceYSize = kSourceWidth * kSourceHeight; 21 static const int kSourceYSize = kSourceWidth * kSourceHeight;
23 static const int kSourceUOffset = kSourceYSize; 22 static const int kSourceUOffset = kSourceYSize;
24 static const int kSourceVOffset = kSourceYSize * 5 / 4; 23 static const int kSourceVOffset = kSourceYSize * 5 / 4;
25 static const int kBpp = 4; 24 static const int kBpp = 4;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 CHECK_EQ(bytes_read, kYUV12Size); 57 CHECK_EQ(bytes_read, kYUV12Size);
59 } 58 }
60 59
61 scoped_ptr<uint8[]> yuv_bytes_; 60 scoped_ptr<uint8[]> yuv_bytes_;
62 scoped_ptr<uint8[]> rgb_bytes_converted_; 61 scoped_ptr<uint8[]> rgb_bytes_converted_;
63 62
64 private: 63 private:
65 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); 64 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest);
66 }; 65 };
67 66
68 TEST_F(YUVConvertPerfTest, I422ToARGBRow_SSSE3) {
69 ASSERT_TRUE(base::CPU().has_ssse3());
70
71 base::TimeTicks start = base::TimeTicks::Now();
72 for (int i = 0; i < kPerfTestIterations; ++i) {
73 for (int row = 0; row < kSourceHeight; ++row) {
74 int chroma_row = row / 2;
75 libyuv::I422ToARGBRow_SSSE3(
76 yuv_bytes_.get() + row * kSourceWidth,
77 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
78 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
79 rgb_bytes_converted_.get(),
80 kWidth);
81 }
82 }
83 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
84 perf_test::PrintResult(
85 "yuv_convert_perftest", "", "I422ToARGBRow_SSSE3",
86 kPerfTestIterations / total_time_seconds, "runs/s", true);
87 }
88
89 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { 67 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) {
90 ASSERT_TRUE(base::CPU().has_sse()); 68 ASSERT_TRUE(base::CPU().has_sse());
91 69
92 base::TimeTicks start = base::TimeTicks::Now(); 70 base::TimeTicks start = base::TimeTicks::Now();
93 for (int i = 0; i < kPerfTestIterations; ++i) { 71 for (int i = 0; i < kPerfTestIterations; ++i) {
94 for (int row = 0; row < kSourceHeight; ++row) { 72 for (int row = 0; row < kSourceHeight; ++row) {
95 int chroma_row = row / 2; 73 int chroma_row = row / 2;
96 ConvertYUVToRGB32Row_SSE( 74 ConvertYUVToRGB32Row_SSE(
97 yuv_bytes_.get() + row * kSourceWidth, 75 yuv_bytes_.get() + row * kSourceWidth,
98 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 76 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
99 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 77 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
100 rgb_bytes_converted_.get(), 78 rgb_bytes_converted_.get(),
101 kWidth, 79 kWidth,
102 GetLookupTable(YV12)); 80 GetLookupTable(YV12));
103 } 81 }
104 } 82 }
105 media::EmptyRegisterState();
106 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 83 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
107 perf_test::PrintResult( 84 perf_test::PrintResult(
108 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", 85 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE",
109 kPerfTestIterations / total_time_seconds, "runs/s", true); 86 kPerfTestIterations / total_time_seconds, "runs/s", true);
110 }
111
112 TEST_F(YUVConvertPerfTest, ConvertYUVAToARGBRow_MMX) {
113 ASSERT_TRUE(base::CPU().has_sse());
114
115 base::TimeTicks start = base::TimeTicks::Now();
116 for (int i = 0; i < kPerfTestIterations; ++i) {
117 for (int row = 0; row < kSourceHeight; ++row) {
118 int chroma_row = row / 2;
119 ConvertYUVAToARGBRow_MMX(
120 yuv_bytes_.get() + row * kSourceWidth,
121 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
122 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
123 yuv_bytes_.get() + row * kSourceWidth, // hack: use luma for alpha
124 rgb_bytes_converted_.get(),
125 kWidth,
126 GetLookupTable(YV12));
127 }
128 }
129 media::EmptyRegisterState(); 87 media::EmptyRegisterState();
130 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
131 perf_test::PrintResult(
132 "yuv_convert_perftest", "", "ConvertYUVAToARGBRow_MMX",
133 kPerfTestIterations / total_time_seconds, "runs/s", true);
134 } 88 }
135 89
136 // 64-bit release + component builds on Windows are too smart and optimizes 90 // 64-bit release + component builds on Windows are too smart and optimizes
137 // away the function being tested. 91 // away the function being tested.
138 #if defined(OS_WIN) && (defined(ARCH_CPU_X86) || !defined(COMPONENT_BUILD)) 92 #if defined(OS_WIN) && (defined(ARCH_CPU_X86) || !defined(COMPONENT_BUILD))
139 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { 93 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) {
140 ASSERT_TRUE(base::CPU().has_sse()); 94 ASSERT_TRUE(base::CPU().has_sse());
141 95
142 const int kSourceDx = 80000; // This value means a scale down. 96 const int kSourceDx = 80000; // This value means a scale down.
143 97
144 base::TimeTicks start = base::TimeTicks::Now(); 98 base::TimeTicks start = base::TimeTicks::Now();
145 for (int i = 0; i < kPerfTestIterations; ++i) { 99 for (int i = 0; i < kPerfTestIterations; ++i) {
146 for (int row = 0; row < kSourceHeight; ++row) { 100 for (int row = 0; row < kSourceHeight; ++row) {
147 int chroma_row = row / 2; 101 int chroma_row = row / 2;
148 ScaleYUVToRGB32Row_SSE( 102 ScaleYUVToRGB32Row_SSE(
149 yuv_bytes_.get() + row * kSourceWidth, 103 yuv_bytes_.get() + row * kSourceWidth,
150 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 104 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
151 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 105 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
152 rgb_bytes_converted_.get(), 106 rgb_bytes_converted_.get(),
153 kWidth, 107 kWidth,
154 kSourceDx, 108 kSourceDx,
155 GetLookupTable(YV12)); 109 GetLookupTable(YV12));
156 } 110 }
157 } 111 }
158 media::EmptyRegisterState();
159 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 112 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
160 perf_test::PrintResult( 113 perf_test::PrintResult(
161 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", 114 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE",
162 kPerfTestIterations / total_time_seconds, "runs/s", true); 115 kPerfTestIterations / total_time_seconds, "runs/s", true);
116 media::EmptyRegisterState();
163 } 117 }
164 118
165 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { 119 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) {
166 ASSERT_TRUE(base::CPU().has_sse()); 120 ASSERT_TRUE(base::CPU().has_sse());
167 121
168 const int kSourceDx = 80000; // This value means a scale down. 122 const int kSourceDx = 80000; // This value means a scale down.
169 123
170 base::TimeTicks start = base::TimeTicks::Now(); 124 base::TimeTicks start = base::TimeTicks::Now();
171 for (int i = 0; i < kPerfTestIterations; ++i) { 125 for (int i = 0; i < kPerfTestIterations; ++i) {
172 for (int row = 0; row < kSourceHeight; ++row) { 126 for (int row = 0; row < kSourceHeight; ++row) {
173 int chroma_row = row / 2; 127 int chroma_row = row / 2;
174 LinearScaleYUVToRGB32Row_SSE( 128 LinearScaleYUVToRGB32Row_SSE(
175 yuv_bytes_.get() + row * kSourceWidth, 129 yuv_bytes_.get() + row * kSourceWidth,
176 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 130 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
177 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 131 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
178 rgb_bytes_converted_.get(), 132 rgb_bytes_converted_.get(),
179 kWidth, 133 kWidth,
180 kSourceDx, 134 kSourceDx,
181 GetLookupTable(YV12)); 135 GetLookupTable(YV12));
182 } 136 }
183 } 137 }
184 media::EmptyRegisterState();
185 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 138 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
186 perf_test::PrintResult( 139 perf_test::PrintResult(
187 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", 140 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE",
188 kPerfTestIterations / total_time_seconds, "runs/s", true); 141 kPerfTestIterations / total_time_seconds, "runs/s", true);
142 media::EmptyRegisterState();
189 } 143 }
190 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD) 144 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD)
191 145
192 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) 146 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY)
193 147
194 } // namespace media 148 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698