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

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

Issue 1286913002: add ConvertYUVAToARGBRow_MMX to media_perftests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: full path for includes 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"
15 16
16 namespace media { 17 namespace media {
17 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) 18 #if !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY)
18 // Size of raw image. 19 // Size of raw image.
19 static const int kSourceWidth = 640; 20 static const int kSourceWidth = 640;
20 static const int kSourceHeight = 360; 21 static const int kSourceHeight = 360;
21 static const int kSourceYSize = kSourceWidth * kSourceHeight; 22 static const int kSourceYSize = kSourceWidth * kSourceHeight;
22 static const int kSourceUOffset = kSourceYSize; 23 static const int kSourceUOffset = kSourceYSize;
23 static const int kSourceVOffset = kSourceYSize * 5 / 4; 24 static const int kSourceVOffset = kSourceYSize * 5 / 4;
24 static const int kBpp = 4; 25 static const int kBpp = 4;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 CHECK_EQ(bytes_read, kYUV12Size); 58 CHECK_EQ(bytes_read, kYUV12Size);
58 } 59 }
59 60
60 scoped_ptr<uint8[]> yuv_bytes_; 61 scoped_ptr<uint8[]> yuv_bytes_;
61 scoped_ptr<uint8[]> rgb_bytes_converted_; 62 scoped_ptr<uint8[]> rgb_bytes_converted_;
62 63
63 private: 64 private:
64 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest); 65 DISALLOW_COPY_AND_ASSIGN(YUVConvertPerfTest);
65 }; 66 };
66 67
68 TEST_F(YUVConvertPerfTest, I422ToARGBRow_SSSE3) {
69 ASSERT_TRUE(base::CPU().has_ssse3());
fbarchard 2015/08/12 23:27:05 Is assert ok?
DaleCurtis 2015/08/13 00:46:40 If the bots pass, then yes. It'll be obvious if th
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
67 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) { 89 TEST_F(YUVConvertPerfTest, ConvertYUVToRGB32Row_SSE) {
68 ASSERT_TRUE(base::CPU().has_sse()); 90 ASSERT_TRUE(base::CPU().has_sse());
69 91
70 base::TimeTicks start = base::TimeTicks::Now(); 92 base::TimeTicks start = base::TimeTicks::Now();
71 for (int i = 0; i < kPerfTestIterations; ++i) { 93 for (int i = 0; i < kPerfTestIterations; ++i) {
72 for (int row = 0; row < kSourceHeight; ++row) { 94 for (int row = 0; row < kSourceHeight; ++row) {
73 int chroma_row = row / 2; 95 int chroma_row = row / 2;
74 ConvertYUVToRGB32Row_SSE( 96 ConvertYUVToRGB32Row_SSE(
75 yuv_bytes_.get() + row * kSourceWidth, 97 yuv_bytes_.get() + row * kSourceWidth,
76 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 98 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
77 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 99 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
78 rgb_bytes_converted_.get(), 100 rgb_bytes_converted_.get(),
79 kWidth, 101 kWidth,
80 GetLookupTable(YV12)); 102 GetLookupTable(YV12));
81 } 103 }
82 } 104 }
105 media::EmptyRegisterState();
83 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 106 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
84 perf_test::PrintResult( 107 perf_test::PrintResult(
85 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE", 108 "yuv_convert_perftest", "", "ConvertYUVToRGB32Row_SSE",
86 kPerfTestIterations / total_time_seconds, "runs/s", true); 109 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 }
87 media::EmptyRegisterState(); 129 media::EmptyRegisterState();
fbarchard 2015/08/12 23:27:05 media::EmptyRegisterState() does emms, which allow
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);
88 } 134 }
89 135
90 // 64-bit release + component builds on Windows are too smart and optimizes 136 // 64-bit release + component builds on Windows are too smart and optimizes
91 // away the function being tested. 137 // away the function being tested.
92 #if defined(OS_WIN) && (defined(ARCH_CPU_X86) || !defined(COMPONENT_BUILD)) 138 #if defined(OS_WIN) && (defined(ARCH_CPU_X86) || !defined(COMPONENT_BUILD))
93 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) { 139 TEST_F(YUVConvertPerfTest, ScaleYUVToRGB32Row_SSE) {
94 ASSERT_TRUE(base::CPU().has_sse()); 140 ASSERT_TRUE(base::CPU().has_sse());
95 141
96 const int kSourceDx = 80000; // This value means a scale down. 142 const int kSourceDx = 80000; // This value means a scale down.
97 143
98 base::TimeTicks start = base::TimeTicks::Now(); 144 base::TimeTicks start = base::TimeTicks::Now();
99 for (int i = 0; i < kPerfTestIterations; ++i) { 145 for (int i = 0; i < kPerfTestIterations; ++i) {
100 for (int row = 0; row < kSourceHeight; ++row) { 146 for (int row = 0; row < kSourceHeight; ++row) {
101 int chroma_row = row / 2; 147 int chroma_row = row / 2;
102 ScaleYUVToRGB32Row_SSE( 148 ScaleYUVToRGB32Row_SSE(
103 yuv_bytes_.get() + row * kSourceWidth, 149 yuv_bytes_.get() + row * kSourceWidth,
104 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 150 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
105 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 151 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
106 rgb_bytes_converted_.get(), 152 rgb_bytes_converted_.get(),
107 kWidth, 153 kWidth,
108 kSourceDx, 154 kSourceDx,
109 GetLookupTable(YV12)); 155 GetLookupTable(YV12));
110 } 156 }
111 } 157 }
158 media::EmptyRegisterState();
112 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 159 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
113 perf_test::PrintResult( 160 perf_test::PrintResult(
114 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE", 161 "yuv_convert_perftest", "", "ScaleYUVToRGB32Row_SSE",
115 kPerfTestIterations / total_time_seconds, "runs/s", true); 162 kPerfTestIterations / total_time_seconds, "runs/s", true);
116 media::EmptyRegisterState();
117 } 163 }
118 164
119 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) { 165 TEST_F(YUVConvertPerfTest, LinearScaleYUVToRGB32Row_SSE) {
120 ASSERT_TRUE(base::CPU().has_sse()); 166 ASSERT_TRUE(base::CPU().has_sse());
121 167
122 const int kSourceDx = 80000; // This value means a scale down. 168 const int kSourceDx = 80000; // This value means a scale down.
123 169
124 base::TimeTicks start = base::TimeTicks::Now(); 170 base::TimeTicks start = base::TimeTicks::Now();
125 for (int i = 0; i < kPerfTestIterations; ++i) { 171 for (int i = 0; i < kPerfTestIterations; ++i) {
126 for (int row = 0; row < kSourceHeight; ++row) { 172 for (int row = 0; row < kSourceHeight; ++row) {
127 int chroma_row = row / 2; 173 int chroma_row = row / 2;
128 LinearScaleYUVToRGB32Row_SSE( 174 LinearScaleYUVToRGB32Row_SSE(
129 yuv_bytes_.get() + row * kSourceWidth, 175 yuv_bytes_.get() + row * kSourceWidth,
130 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2), 176 yuv_bytes_.get() + kSourceUOffset + (chroma_row * kSourceWidth / 2),
131 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2), 177 yuv_bytes_.get() + kSourceVOffset + (chroma_row * kSourceWidth / 2),
132 rgb_bytes_converted_.get(), 178 rgb_bytes_converted_.get(),
133 kWidth, 179 kWidth,
134 kSourceDx, 180 kSourceDx,
135 GetLookupTable(YV12)); 181 GetLookupTable(YV12));
136 } 182 }
137 } 183 }
184 media::EmptyRegisterState();
138 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF(); 185 double total_time_seconds = (base::TimeTicks::Now() - start).InSecondsF();
139 perf_test::PrintResult( 186 perf_test::PrintResult(
140 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE", 187 "yuv_convert_perftest", "", "LinearScaleYUVToRGB32Row_SSE",
141 kPerfTestIterations / total_time_seconds, "runs/s", true); 188 kPerfTestIterations / total_time_seconds, "runs/s", true);
142 media::EmptyRegisterState();
143 } 189 }
144 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD) 190 #endif // defined(OS_WIN) && (ARCH_CPU_X86 || COMPONENT_BUILD)
145 191
146 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY) 192 #endif // !defined(ARCH_CPU_ARM_FAMILY) && !defined(ARCH_CPU_MIPS_FAMILY)
147 193
148 } // namespace media 194 } // 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