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

Side by Side Diff: unit_test/compare_test.cc

Issue 2414763002: Cast for clang-cl 64 bit build warnings in unittests (Closed)
Patch Set: bump version Created 4 years, 2 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 | « include/libyuv/version.h ('k') | unit_test/convert_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 uint32 fourcc; 150 uint32 fourcc;
151 const int kMaxTest = benchmark_width_ * benchmark_height_ * 4; 151 const int kMaxTest = benchmark_width_ * benchmark_height_ * 4;
152 align_buffer_page_end(src_a, kMaxTest); 152 align_buffer_page_end(src_a, kMaxTest);
153 for (int i = 0; i < kMaxTest; ++i) { 153 for (int i = 0; i < kMaxTest; ++i) {
154 src_a[i] = 255; 154 src_a[i] = 255;
155 } 155 }
156 156
157 src_a[0] = 0; 157 src_a[0] = 0;
158 fourcc = ARGBDetect(src_a, benchmark_width_ * 4, 158 fourcc = ARGBDetect(src_a, benchmark_width_ * 4,
159 benchmark_width_, benchmark_height_); 159 benchmark_width_, benchmark_height_);
160 EXPECT_EQ(libyuv::FOURCC_BGRA, fourcc); 160 EXPECT_EQ(static_cast<uint32>(libyuv::FOURCC_BGRA), fourcc);
161 src_a[0] = 255; 161 src_a[0] = 255;
162 src_a[3] = 0; 162 src_a[3] = 0;
163 fourcc = ARGBDetect(src_a, benchmark_width_ * 4, 163 fourcc = ARGBDetect(src_a, benchmark_width_ * 4,
164 benchmark_width_, benchmark_height_); 164 benchmark_width_, benchmark_height_);
165 EXPECT_EQ(libyuv::FOURCC_ARGB, fourcc); 165 EXPECT_EQ(static_cast<uint32>(libyuv::FOURCC_ARGB), fourcc);
166 src_a[3] = 255; 166 src_a[3] = 255;
167 167
168 for (int i = 0; i < benchmark_iterations_; ++i) { 168 for (int i = 0; i < benchmark_iterations_; ++i) {
169 fourcc = ARGBDetect(src_a, benchmark_width_ * 4, 169 fourcc = ARGBDetect(src_a, benchmark_width_ * 4,
170 benchmark_width_, benchmark_height_); 170 benchmark_width_, benchmark_height_);
171 } 171 }
172 EXPECT_EQ(0, fourcc); 172 EXPECT_EQ(0u, fourcc);
173 173
174 free_aligned_buffer_page_end(src_a); 174 free_aligned_buffer_page_end(src_a);
175 } 175 }
176 176
177 TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Unaligned) { 177 TEST_F(LibYUVBaseTest, BenchmarkARGBDetect_Unaligned) {
178 uint32 fourcc; 178 uint32 fourcc;
179 const int kMaxTest = benchmark_width_ * benchmark_height_ * 4 + 1; 179 const int kMaxTest = benchmark_width_ * benchmark_height_ * 4 + 1;
180 align_buffer_page_end(src_a, kMaxTest); 180 align_buffer_page_end(src_a, kMaxTest);
181 for (int i = 1; i < kMaxTest; ++i) { 181 for (int i = 1; i < kMaxTest; ++i) {
182 src_a[i] = 255; 182 src_a[i] = 255;
183 } 183 }
184 184
185 src_a[0 + 1] = 0; 185 src_a[0 + 1] = 0;
186 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, 186 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
187 benchmark_width_, benchmark_height_); 187 benchmark_width_, benchmark_height_);
188 EXPECT_EQ(libyuv::FOURCC_BGRA, fourcc); 188 EXPECT_EQ(static_cast<uint32>(libyuv::FOURCC_BGRA), fourcc);
189 src_a[0 + 1] = 255; 189 src_a[0 + 1] = 255;
190 src_a[3 + 1] = 0; 190 src_a[3 + 1] = 0;
191 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, 191 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
192 benchmark_width_, benchmark_height_); 192 benchmark_width_, benchmark_height_);
193 EXPECT_EQ(libyuv::FOURCC_ARGB, fourcc); 193 EXPECT_EQ(static_cast<uint32>(libyuv::FOURCC_ARGB), fourcc);
194 src_a[3 + 1] = 255; 194 src_a[3 + 1] = 255;
195 195
196 for (int i = 0; i < benchmark_iterations_; ++i) { 196 for (int i = 0; i < benchmark_iterations_; ++i) {
197 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4, 197 fourcc = ARGBDetect(src_a + 1, benchmark_width_ * 4,
198 benchmark_width_, benchmark_height_); 198 benchmark_width_, benchmark_height_);
199 } 199 }
200 EXPECT_EQ(0, fourcc); 200 EXPECT_EQ(0u, fourcc);
201 201
202 free_aligned_buffer_page_end(src_a); 202 free_aligned_buffer_page_end(src_a);
203 } 203 }
204 TEST_F(LibYUVBaseTest, BenchmarkSumSquareError_Opt) { 204 TEST_F(LibYUVBaseTest, BenchmarkSumSquareError_Opt) {
205 const int kMaxWidth = 4096 * 3; 205 const int kMaxWidth = 4096 * 3;
206 align_buffer_page_end(src_a, kMaxWidth); 206 align_buffer_page_end(src_a, kMaxWidth);
207 align_buffer_page_end(src_b, kMaxWidth); 207 align_buffer_page_end(src_b, kMaxWidth);
208 memset(src_a, 0, kMaxWidth); 208 memset(src_a, 0, kMaxWidth);
209 memset(src_b, 0, kMaxWidth); 209 memset(src_b, 0, kMaxWidth);
210 210
211 memcpy(src_a, "test0123test4567", 16); 211 memcpy(src_a, "test0123test4567", 16);
212 memcpy(src_b, "tick0123tock4567", 16); 212 memcpy(src_b, "tick0123tock4567", 16);
213 uint64 h1 = ComputeSumSquareError(src_a, src_b, 16); 213 uint64 h1 = ComputeSumSquareError(src_a, src_b, 16);
214 EXPECT_EQ(790u, h1); 214 EXPECT_EQ(790u, h1);
215 215
216 for (int i = 0; i < kMaxWidth; ++i) { 216 for (int i = 0; i < kMaxWidth; ++i) {
217 src_a[i] = i; 217 src_a[i] = i;
218 src_b[i] = i; 218 src_b[i] = i;
219 } 219 }
220 memset(src_a, 0, kMaxWidth); 220 memset(src_a, 0, kMaxWidth);
221 memset(src_b, 0, kMaxWidth); 221 memset(src_b, 0, kMaxWidth);
222 222
223 int count = benchmark_iterations_ * 223 int count = benchmark_iterations_ *
224 ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth); 224 ((benchmark_width_ * benchmark_height_ + kMaxWidth - 1) / kMaxWidth);
225 for (int i = 0; i < count; ++i) { 225 for (int i = 0; i < count; ++i) {
226 h1 = ComputeSumSquareError(src_a, src_b, kMaxWidth); 226 h1 = ComputeSumSquareError(src_a, src_b, kMaxWidth);
227 } 227 }
228 228
229 EXPECT_EQ(0, h1); 229 EXPECT_EQ(0u, h1);
230 230
231 free_aligned_buffer_page_end(src_a); 231 free_aligned_buffer_page_end(src_a);
232 free_aligned_buffer_page_end(src_b); 232 free_aligned_buffer_page_end(src_b);
233 } 233 }
234 234
235 TEST_F(LibYUVBaseTest, SumSquareError) { 235 TEST_F(LibYUVBaseTest, SumSquareError) {
236 const int kMaxWidth = 4096 * 3; 236 const int kMaxWidth = 4096 * 3;
237 align_buffer_page_end(src_a, kMaxWidth); 237 align_buffer_page_end(src_a, kMaxWidth);
238 align_buffer_page_end(src_b, kMaxWidth); 238 align_buffer_page_end(src_b, kMaxWidth);
239 memset(src_a, 0, kMaxWidth); 239 memset(src_a, 0, kMaxWidth);
240 memset(src_b, 0, kMaxWidth); 240 memset(src_b, 0, kMaxWidth);
241 241
242 uint64 err; 242 uint64 err;
243 err = ComputeSumSquareError(src_a, src_b, kMaxWidth); 243 err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
244 244
245 EXPECT_EQ(0, err); 245 EXPECT_EQ(0u, err);
246 246
247 memset(src_a, 1, kMaxWidth); 247 memset(src_a, 1, kMaxWidth);
248 err = ComputeSumSquareError(src_a, src_b, kMaxWidth); 248 err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
249 249
250 EXPECT_EQ(err, kMaxWidth); 250 EXPECT_EQ(static_cast<int>(err), kMaxWidth);
251 251
252 memset(src_a, 190, kMaxWidth); 252 memset(src_a, 190, kMaxWidth);
253 memset(src_b, 193, kMaxWidth); 253 memset(src_b, 193, kMaxWidth);
254 err = ComputeSumSquareError(src_a, src_b, kMaxWidth); 254 err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
255 255
256 EXPECT_EQ(kMaxWidth * 3 * 3, err); 256 EXPECT_EQ(static_cast<int>(err), kMaxWidth * 3 * 3);
257 257
258 for (int i = 0; i < kMaxWidth; ++i) { 258 for (int i = 0; i < kMaxWidth; ++i) {
259 src_a[i] = (fastrand() & 0xff); 259 src_a[i] = (fastrand() & 0xff);
260 src_b[i] = (fastrand() & 0xff); 260 src_b[i] = (fastrand() & 0xff);
261 } 261 }
262 262
263 MaskCpuFlags(disable_cpu_flags_); 263 MaskCpuFlags(disable_cpu_flags_);
264 uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth); 264 uint64 c_err = ComputeSumSquareError(src_a, src_b, kMaxWidth);
265 265
266 MaskCpuFlags(benchmark_cpu_info_); 266 MaskCpuFlags(benchmark_cpu_info_);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 if (kSrcWidth > 8 && kSrcHeight > 8) { 505 if (kSrcWidth > 8 && kSrcHeight > 8) {
506 EXPECT_EQ(opt_err, c_err); 506 EXPECT_EQ(opt_err, c_err);
507 } 507 }
508 508
509 free_aligned_buffer_page_end(src_a); 509 free_aligned_buffer_page_end(src_a);
510 free_aligned_buffer_page_end(src_b); 510 free_aligned_buffer_page_end(src_b);
511 } 511 }
512 512
513 } // namespace libyuv 513 } // namespace libyuv
OLDNEW
« no previous file with comments | « include/libyuv/version.h ('k') | unit_test/convert_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698