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

Side by Side Diff: unit_test/scale_argb_test.cc

Issue 2001373002: remove row.h from unittests (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: test csum buffer is aligned Created 4 years, 7 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 | « unit_test/rotate_test.cc ('k') | unit_test/unit_test.h » ('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
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <time.h> 12 #include <time.h>
13 13
14 #include "libyuv/convert_argb.h" 14 #include "libyuv/convert_argb.h"
15 #include "libyuv/cpu_id.h" 15 #include "libyuv/cpu_id.h"
16 #include "libyuv/row.h" // For align_buffer_64
17 #include "libyuv/scale_argb.h" 16 #include "libyuv/scale_argb.h"
18 #include "libyuv/video_common.h" 17 #include "libyuv/video_common.h"
19 #include "../unit_test/unit_test.h" 18 #include "../unit_test/unit_test.h"
20 19
21 namespace libyuv { 20 namespace libyuv {
22 21
23 #define STRINGIZE(line) #line 22 #define STRINGIZE(line) #line
24 #define FILELINESTR(file, line) file ":" STRINGIZE(line) 23 #define FILELINESTR(file, line) file ":" STRINGIZE(line)
25 24
26 // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact. 25 // Test scaling with C vs Opt and return maximum pixel difference. 0 = exact.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 FilterMode f, int benchmark_iterations) { 148 FilterMode f, int benchmark_iterations) {
150 if (!SizeValid(src_width, src_height, dst_width, dst_height)) { 149 if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
151 return 0; 150 return 0;
152 } 151 }
153 152
154 const int b = 128; 153 const int b = 128;
155 int64 src_argb_plane_size = (Abs(src_width) + b * 2) * 154 int64 src_argb_plane_size = (Abs(src_width) + b * 2) *
156 (Abs(src_height) + b * 2) * 4; 155 (Abs(src_height) + b * 2) * 4;
157 int src_stride_argb = (b * 2 + Abs(src_width)) * 4; 156 int src_stride_argb = (b * 2 + Abs(src_width)) * 4;
158 157
159 align_buffer_64(src_argb, src_argb_plane_size); 158 align_buffer_page_end(src_argb, src_argb_plane_size);
160 if (!src_argb) { 159 if (!src_argb) {
161 printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n"); 160 printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
162 return 0; 161 return 0;
163 } 162 }
164 memset(src_argb, 1, src_argb_plane_size); 163 memset(src_argb, 1, src_argb_plane_size);
165 164
166 int64 dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4; 165 int64 dst_argb_plane_size = (dst_width + b * 2) * (dst_height + b * 2) * 4;
167 int dst_stride_argb = (b * 2 + dst_width) * 4; 166 int dst_stride_argb = (b * 2 + dst_width) * 4;
168 167
169 int i, j; 168 int i, j;
170 for (i = b; i < (Abs(src_height) + b); ++i) { 169 for (i = b; i < (Abs(src_height) + b); ++i) {
171 for (j = b; j < (Abs(src_width) + b) * 4; ++j) { 170 for (j = b; j < (Abs(src_width) + b) * 4; ++j) {
172 src_argb[(i * src_stride_argb) + j] = (fastrand() & 0xff); 171 src_argb[(i * src_stride_argb) + j] = (fastrand() & 0xff);
173 } 172 }
174 } 173 }
175 174
176 align_buffer_64(dst_argb_c, dst_argb_plane_size); 175 align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
177 align_buffer_64(dst_argb_opt, dst_argb_plane_size); 176 align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
178 if (!dst_argb_c || !dst_argb_opt) { 177 if (!dst_argb_c || !dst_argb_opt) {
179 printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n"); 178 printf("Skipped. Alloc failed " FILELINESTR(__FILE__, __LINE__) "\n");
180 return 0; 179 return 0;
181 } 180 }
182 memset(dst_argb_c, 2, dst_argb_plane_size); 181 memset(dst_argb_c, 2, dst_argb_plane_size);
183 memset(dst_argb_opt, 3, dst_argb_plane_size); 182 memset(dst_argb_opt, 3, dst_argb_plane_size);
184 183
185 // Do full image, no clipping. 184 // Do full image, no clipping.
186 double c_time = get_time(); 185 double c_time = get_time();
187 ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb, 186 ARGBScale(src_argb + (src_stride_argb * b) + b * 4, src_stride_argb,
(...skipping 21 matching lines...) Expand all
209 for (i = b; i < (dst_height + b); ++i) { 208 for (i = b; i < (dst_height + b); ++i) {
210 for (j = b * 4; j < (dst_width + b) * 4; ++j) { 209 for (j = b * 4; j < (dst_width + b) * 4; ++j) {
211 int abs_diff = Abs(dst_argb_c[(i * dst_stride_argb) + j] - 210 int abs_diff = Abs(dst_argb_c[(i * dst_stride_argb) + j] -
212 dst_argb_opt[(i * dst_stride_argb) + j]); 211 dst_argb_opt[(i * dst_stride_argb) + j]);
213 if (abs_diff > max_diff) { 212 if (abs_diff > max_diff) {
214 max_diff = abs_diff; 213 max_diff = abs_diff;
215 } 214 }
216 } 215 }
217 } 216 }
218 217
219 free_aligned_buffer_64(dst_argb_c); 218 free_aligned_buffer_page_end(dst_argb_c);
220 free_aligned_buffer_64(dst_argb_opt); 219 free_aligned_buffer_page_end(dst_argb_opt);
221 free_aligned_buffer_64(src_argb); 220 free_aligned_buffer_page_end(src_argb);
222 return max_diff; 221 return max_diff;
223 } 222 }
224 223
225 // The following adjustments in dimensions ensure the scale factor will be 224 // The following adjustments in dimensions ensure the scale factor will be
226 // exactly achieved. 225 // exactly achieved.
227 #define DX(x, nom, denom) static_cast<int>((Abs(x) / nom) * nom) 226 #define DX(x, nom, denom) static_cast<int>((Abs(x) / nom) * nom)
228 #define SX(x, nom, denom) static_cast<int>((x / nom) * denom) 227 #define SX(x, nom, denom) static_cast<int>((x / nom) * denom)
229 228
230 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \ 229 #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
231 TEST_F(LibYUVScaleTest, ARGBScaleDownBy##name##_##filter) { \ 230 TEST_F(LibYUVScaleTest, ARGBScaleDownBy##name##_##filter) { \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 const uint8* src_u, int src_stride_u, 314 const uint8* src_u, int src_stride_u,
316 const uint8* src_v, int src_stride_v, 315 const uint8* src_v, int src_stride_v,
317 uint32 src_fourcc, 316 uint32 src_fourcc,
318 int src_width, int src_height, 317 int src_width, int src_height,
319 uint8* dst_argb, int dst_stride_argb, 318 uint8* dst_argb, int dst_stride_argb,
320 uint32 dst_fourcc, 319 uint32 dst_fourcc,
321 int dst_width, int dst_height, 320 int dst_width, int dst_height,
322 int clip_x, int clip_y, 321 int clip_x, int clip_y,
323 int clip_width, int clip_height, 322 int clip_width, int clip_height,
324 enum FilterMode filtering) { 323 enum FilterMode filtering) {
325 324 uint8* argb_buffer = static_cast<uint8*>(malloc(src_width * src_height * 4));
326 uint8* argb_buffer = (uint8*)malloc(src_width * src_height * 4);
327 int r; 325 int r;
328 I420ToARGB(src_y, src_stride_y, 326 I420ToARGB(src_y, src_stride_y,
329 src_u, src_stride_u, 327 src_u, src_stride_u,
330 src_v, src_stride_v, 328 src_v, src_stride_v,
331 argb_buffer, src_width * 4, 329 argb_buffer, src_width * 4,
332 src_width, src_height); 330 src_width, src_height);
333 331
334 r = ARGBScaleClip(argb_buffer, src_width * 4, 332 r = ARGBScaleClip(argb_buffer, src_width * 4,
335 src_width, src_height, 333 src_width, src_height,
336 dst_argb, dst_stride_argb, 334 dst_argb, dst_stride_argb,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 benchmark_height_ * 3 / 2, 453 benchmark_height_ * 3 / 2,
456 benchmark_width_, benchmark_height_, 454 benchmark_width_, benchmark_height_,
457 libyuv::kFilterBilinear, 455 libyuv::kFilterBilinear,
458 benchmark_iterations_, 456 benchmark_iterations_,
459 disable_cpu_flags_, benchmark_cpu_info_); 457 disable_cpu_flags_, benchmark_cpu_info_);
460 EXPECT_LE(diff, 10); 458 EXPECT_LE(diff, 10);
461 } 459 }
462 460
463 461
464 } // namespace libyuv 462 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/rotate_test.cc ('k') | unit_test/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698