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

Side by Side Diff: unit_test/rotate_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/planar_test.cc ('k') | unit_test/rotate_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 2012 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2012 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 12
13 #include "libyuv/cpu_id.h" 13 #include "libyuv/cpu_id.h"
14 #include "libyuv/rotate_argb.h" 14 #include "libyuv/rotate_argb.h"
15 #include "libyuv/row.h"
16 #include "../unit_test/unit_test.h" 15 #include "../unit_test/unit_test.h"
17 16
18 namespace libyuv { 17 namespace libyuv {
19 18
20 void TestRotateBpp(int src_width, int src_height, 19 void TestRotateBpp(int src_width, int src_height,
21 int dst_width, int dst_height, 20 int dst_width, int dst_height,
22 libyuv::RotationMode mode, 21 libyuv::RotationMode mode,
23 int benchmark_iterations, 22 int benchmark_iterations,
24 int disable_cpu_flags, 23 int disable_cpu_flags,
25 int benchmark_cpu_info, 24 int benchmark_cpu_info,
26 const int kBpp) { 25 const int kBpp) {
27 if (src_width < 1) { 26 if (src_width < 1) {
28 src_width = 1; 27 src_width = 1;
29 } 28 }
30 if (src_height < 1) { 29 if (src_height < 1) {
31 src_height = 1; 30 src_height = 1;
32 } 31 }
33 if (dst_width < 1) { 32 if (dst_width < 1) {
34 dst_width = 1; 33 dst_width = 1;
35 } 34 }
36 if (dst_height < 1) { 35 if (dst_height < 1) {
37 dst_height = 1; 36 dst_height = 1;
38 } 37 }
39 int src_stride_argb = src_width * kBpp; 38 int src_stride_argb = src_width * kBpp;
40 int src_argb_plane_size = src_stride_argb * abs(src_height); 39 int src_argb_plane_size = src_stride_argb * abs(src_height);
41 align_buffer_64(src_argb, src_argb_plane_size); 40 align_buffer_page_end(src_argb, src_argb_plane_size);
42 for (int i = 0; i < src_argb_plane_size; ++i) { 41 for (int i = 0; i < src_argb_plane_size; ++i) {
43 src_argb[i] = fastrand() & 0xff; 42 src_argb[i] = fastrand() & 0xff;
44 } 43 }
45 44
46 int dst_stride_argb = dst_width * kBpp; 45 int dst_stride_argb = dst_width * kBpp;
47 int dst_argb_plane_size = dst_stride_argb * dst_height; 46 int dst_argb_plane_size = dst_stride_argb * dst_height;
48 align_buffer_64(dst_argb_c, dst_argb_plane_size); 47 align_buffer_page_end(dst_argb_c, dst_argb_plane_size);
49 align_buffer_64(dst_argb_opt, dst_argb_plane_size); 48 align_buffer_page_end(dst_argb_opt, dst_argb_plane_size);
50 memset(dst_argb_c, 2, dst_argb_plane_size); 49 memset(dst_argb_c, 2, dst_argb_plane_size);
51 memset(dst_argb_opt, 3, dst_argb_plane_size); 50 memset(dst_argb_opt, 3, dst_argb_plane_size);
52 51
53 if (kBpp == 1) { 52 if (kBpp == 1) {
54 MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization. 53 MaskCpuFlags(disable_cpu_flags); // Disable all CPU optimization.
55 RotatePlane(src_argb, src_stride_argb, 54 RotatePlane(src_argb, src_stride_argb,
56 dst_argb_c, dst_stride_argb, 55 dst_argb_c, dst_stride_argb,
57 src_width, src_height, mode); 56 src_width, src_height, mode);
58 57
59 MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization. 58 MaskCpuFlags(benchmark_cpu_info); // Enable all CPU optimization.
(...skipping 14 matching lines...) Expand all
74 dst_argb_opt, dst_stride_argb, 73 dst_argb_opt, dst_stride_argb,
75 src_width, src_height, mode); 74 src_width, src_height, mode);
76 } 75 }
77 } 76 }
78 77
79 // Rotation should be exact. 78 // Rotation should be exact.
80 for (int i = 0; i < dst_argb_plane_size; ++i) { 79 for (int i = 0; i < dst_argb_plane_size; ++i) {
81 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); 80 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]);
82 } 81 }
83 82
84 free_aligned_buffer_64(dst_argb_c); 83 free_aligned_buffer_page_end(dst_argb_c);
85 free_aligned_buffer_64(dst_argb_opt); 84 free_aligned_buffer_page_end(dst_argb_opt);
86 free_aligned_buffer_64(src_argb); 85 free_aligned_buffer_page_end(src_argb);
87 } 86 }
88 87
89 static void ARGBTestRotate(int src_width, int src_height, 88 static void ARGBTestRotate(int src_width, int src_height,
90 int dst_width, int dst_height, 89 int dst_width, int dst_height,
91 libyuv::RotationMode mode, 90 libyuv::RotationMode mode,
92 int benchmark_iterations, 91 int benchmark_iterations,
93 int disable_cpu_flags, 92 int disable_cpu_flags,
94 int benchmark_cpu_info) { 93 int benchmark_cpu_info) {
95 TestRotateBpp(src_width, src_height, 94 TestRotateBpp(src_width, src_height,
96 dst_width, dst_height, 95 dst_width, dst_height,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 187 }
189 188
190 TEST_F(LibYUVRotateTest, DISABLED_RotatePlane270_Odd) { 189 TEST_F(LibYUVRotateTest, DISABLED_RotatePlane270_Odd) {
191 TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1, 190 TestRotatePlane(benchmark_width_ - 3, benchmark_height_ - 1,
192 benchmark_height_ - 1, benchmark_width_ - 3, 191 benchmark_height_ - 1, benchmark_width_ - 3,
193 kRotate270, benchmark_iterations_, 192 kRotate270, benchmark_iterations_,
194 disable_cpu_flags_, benchmark_cpu_info_); 193 disable_cpu_flags_, benchmark_cpu_info_);
195 } 194 }
196 195
197 } // namespace libyuv 196 } // namespace libyuv
OLDNEW
« no previous file with comments | « unit_test/planar_test.cc ('k') | unit_test/rotate_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698