OLD | NEW |
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/basic_types.h" |
14 #include "libyuv/compare.h" | 15 #include "libyuv/compare.h" |
15 #include "libyuv/convert.h" | 16 #include "libyuv/convert.h" |
16 #include "libyuv/convert_argb.h" | 17 #include "libyuv/convert_argb.h" |
17 #include "libyuv/convert_from.h" | 18 #include "libyuv/convert_from.h" |
18 #include "libyuv/convert_from_argb.h" | 19 #include "libyuv/convert_from_argb.h" |
19 #include "libyuv/cpu_id.h" | 20 #include "libyuv/cpu_id.h" |
20 #ifdef HAVE_JPEG | 21 #ifdef HAVE_JPEG |
21 #include "libyuv/mjpeg_decoder.h" | 22 #include "libyuv/mjpeg_decoder.h" |
22 #endif | 23 #endif |
23 #include "libyuv/planar_functions.h" | 24 #include "libyuv/planar_functions.h" |
24 #include "libyuv/rotate.h" | 25 #include "libyuv/rotate.h" |
25 #include "libyuv/row.h" | |
26 #include "libyuv/video_common.h" | 26 #include "libyuv/video_common.h" |
27 #include "../unit_test/unit_test.h" | 27 #include "../unit_test/unit_test.h" |
28 | 28 |
29 namespace libyuv { | 29 namespace libyuv { |
30 | 30 |
31 #define SUBSAMPLE(v, a) ((((v) + (a) - 1)) / (a)) | 31 #define SUBSAMPLE(v, a) ((((v) + (a) - 1)) / (a)) |
32 | 32 |
33 #define TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 33 #define TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
34 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ | 34 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
35 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ | 35 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ |
36 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 36 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
37 const int kHeight = benchmark_height_; \ | 37 const int kHeight = benchmark_height_; \ |
38 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 38 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
39 align_buffer_64(src_u, \ | 39 align_buffer_page_end(src_u, \ |
40 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 40 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
41 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 41 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
42 align_buffer_64(src_v, \ | 42 align_buffer_page_end(src_v, \ |
43 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 43 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
44 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 44 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
45 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 45 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
46 align_buffer_64(dst_u_c, \ | 46 align_buffer_page_end(dst_u_c, \ |
47 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 47 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
48 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 48 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
49 align_buffer_64(dst_v_c, \ | 49 align_buffer_page_end(dst_v_c, \ |
50 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 50 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
51 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 51 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
52 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 52 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
53 align_buffer_64(dst_u_opt, \ | 53 align_buffer_page_end(dst_u_opt, \ |
54 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 54 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
55 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 55 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
56 align_buffer_64(dst_v_opt, \ | 56 align_buffer_page_end(dst_v_opt, \ |
57 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 57 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
58 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 58 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
59 for (int i = 0; i < kHeight; ++i) \ | 59 for (int i = 0; i < kHeight; ++i) \ |
60 for (int j = 0; j < kWidth; ++j) \ | 60 for (int j = 0; j < kWidth; ++j) \ |
61 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ | 61 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
62 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ | 62 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ |
63 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ | 63 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ |
64 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ | 64 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
65 (fastrand() & 0xff); \ | 65 (fastrand() & 0xff); \ |
66 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ | 66 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
67 (fastrand() & 0xff); \ | 67 (fastrand() & 0xff); \ |
68 } \ | 68 } \ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 abs(static_cast<int>(dst_v_c[i * \ | 130 abs(static_cast<int>(dst_v_c[i * \ |
131 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ | 131 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ |
132 static_cast<int>(dst_v_opt[i * \ | 132 static_cast<int>(dst_v_opt[i * \ |
133 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ | 133 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ |
134 if (abs_diff > max_diff) { \ | 134 if (abs_diff > max_diff) { \ |
135 max_diff = abs_diff; \ | 135 max_diff = abs_diff; \ |
136 } \ | 136 } \ |
137 } \ | 137 } \ |
138 } \ | 138 } \ |
139 EXPECT_LE(max_diff, 3); \ | 139 EXPECT_LE(max_diff, 3); \ |
140 free_aligned_buffer_64(dst_y_c); \ | 140 free_aligned_buffer_page_end(dst_y_c); \ |
141 free_aligned_buffer_64(dst_u_c); \ | 141 free_aligned_buffer_page_end(dst_u_c); \ |
142 free_aligned_buffer_64(dst_v_c); \ | 142 free_aligned_buffer_page_end(dst_v_c); \ |
143 free_aligned_buffer_64(dst_y_opt); \ | 143 free_aligned_buffer_page_end(dst_y_opt); \ |
144 free_aligned_buffer_64(dst_u_opt); \ | 144 free_aligned_buffer_page_end(dst_u_opt); \ |
145 free_aligned_buffer_64(dst_v_opt); \ | 145 free_aligned_buffer_page_end(dst_v_opt); \ |
146 free_aligned_buffer_64(src_y); \ | 146 free_aligned_buffer_page_end(src_y); \ |
147 free_aligned_buffer_64(src_u); \ | 147 free_aligned_buffer_page_end(src_u); \ |
148 free_aligned_buffer_64(src_v); \ | 148 free_aligned_buffer_page_end(src_v); \ |
149 } | 149 } |
150 | 150 |
151 #define TESTPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 151 #define TESTPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
152 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ | 152 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ |
153 TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 153 TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
154 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 154 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
155 benchmark_width_ - 4, _Any, +, 0) \ | 155 benchmark_width_ - 4, _Any, +, 0) \ |
156 TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 156 TESTPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
157 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 157 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
158 benchmark_width_, _Unaligned, +, 1) \ | 158 benchmark_width_, _Unaligned, +, 1) \ |
(...skipping 13 matching lines...) Expand all Loading... |
172 TESTPLANARTOP(I420, 2, 2, I411, 4, 1) | 172 TESTPLANARTOP(I420, 2, 2, I411, 4, 1) |
173 TESTPLANARTOP(I420, 2, 2, I420Mirror, 2, 2) | 173 TESTPLANARTOP(I420, 2, 2, I420Mirror, 2, 2) |
174 TESTPLANARTOP(I422, 2, 1, I422, 2, 1) | 174 TESTPLANARTOP(I422, 2, 1, I422, 2, 1) |
175 TESTPLANARTOP(I444, 1, 1, I444, 1, 1) | 175 TESTPLANARTOP(I444, 1, 1, I444, 1, 1) |
176 | 176 |
177 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 177 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
178 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ | 178 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
179 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ | 179 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ |
180 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 180 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
181 const int kHeight = benchmark_height_; \ | 181 const int kHeight = benchmark_height_; \ |
182 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 182 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
183 align_buffer_64(src_u, \ | 183 align_buffer_page_end(src_u, \ |
184 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 184 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
185 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 185 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
186 align_buffer_64(src_v, \ | 186 align_buffer_page_end(src_v, \ |
187 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 187 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
188 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 188 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
189 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 189 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
190 align_buffer_64(dst_uv_c, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ | 190 align_buffer_page_end(dst_uv_c, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ |
191 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 191 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
192 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 192 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
193 align_buffer_64(dst_uv_opt, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ | 193 align_buffer_page_end(dst_uv_opt, SUBSAMPLE(kWidth * 2, SUBSAMP_X) * \ |
194 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 194 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
195 for (int i = 0; i < kHeight; ++i) \ | 195 for (int i = 0; i < kHeight; ++i) \ |
196 for (int j = 0; j < kWidth; ++j) \ | 196 for (int j = 0; j < kWidth; ++j) \ |
197 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ | 197 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
198 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ | 198 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ |
199 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ | 199 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ |
200 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ | 200 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
201 (fastrand() & 0xff); \ | 201 (fastrand() & 0xff); \ |
202 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ | 202 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
203 (fastrand() & 0xff); \ | 203 (fastrand() & 0xff); \ |
204 } \ | 204 } \ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 abs(static_cast<int>(dst_uv_c[i * \ | 248 abs(static_cast<int>(dst_uv_c[i * \ |
249 SUBSAMPLE(kWidth * 2, SUBSAMP_X) + j]) - \ | 249 SUBSAMPLE(kWidth * 2, SUBSAMP_X) + j]) - \ |
250 static_cast<int>(dst_uv_opt[i * \ | 250 static_cast<int>(dst_uv_opt[i * \ |
251 SUBSAMPLE(kWidth * 2, SUBSAMP_X) + j])); \ | 251 SUBSAMPLE(kWidth * 2, SUBSAMP_X) + j])); \ |
252 if (abs_diff > max_diff) { \ | 252 if (abs_diff > max_diff) { \ |
253 max_diff = abs_diff; \ | 253 max_diff = abs_diff; \ |
254 } \ | 254 } \ |
255 } \ | 255 } \ |
256 } \ | 256 } \ |
257 EXPECT_LE(max_diff, 1); \ | 257 EXPECT_LE(max_diff, 1); \ |
258 free_aligned_buffer_64(dst_y_c); \ | 258 free_aligned_buffer_page_end(dst_y_c); \ |
259 free_aligned_buffer_64(dst_uv_c); \ | 259 free_aligned_buffer_page_end(dst_uv_c); \ |
260 free_aligned_buffer_64(dst_y_opt); \ | 260 free_aligned_buffer_page_end(dst_y_opt); \ |
261 free_aligned_buffer_64(dst_uv_opt); \ | 261 free_aligned_buffer_page_end(dst_uv_opt); \ |
262 free_aligned_buffer_64(src_y); \ | 262 free_aligned_buffer_page_end(src_y); \ |
263 free_aligned_buffer_64(src_u); \ | 263 free_aligned_buffer_page_end(src_u); \ |
264 free_aligned_buffer_64(src_v); \ | 264 free_aligned_buffer_page_end(src_v); \ |
265 } | 265 } |
266 | 266 |
267 #define TESTPLANARTOBP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 267 #define TESTPLANARTOBP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
268 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ | 268 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ |
269 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 269 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
270 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 270 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
271 benchmark_width_ - 4, _Any, +, 0) \ | 271 benchmark_width_ - 4, _Any, +, 0) \ |
272 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 272 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
273 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 273 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
274 benchmark_width_, _Unaligned, +, 1) \ | 274 benchmark_width_, _Unaligned, +, 1) \ |
275 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 275 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
276 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 276 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
277 benchmark_width_, _Invert, -, 0) \ | 277 benchmark_width_, _Invert, -, 0) \ |
278 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 278 TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
279 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 279 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
280 benchmark_width_, _Opt, +, 0) | 280 benchmark_width_, _Opt, +, 0) |
281 | 281 |
282 TESTPLANARTOBP(I420, 2, 2, NV12, 2, 2) | 282 TESTPLANARTOBP(I420, 2, 2, NV12, 2, 2) |
283 TESTPLANARTOBP(I420, 2, 2, NV21, 2, 2) | 283 TESTPLANARTOBP(I420, 2, 2, NV21, 2, 2) |
284 | 284 |
285 #define TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 285 #define TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
286 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ | 286 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
287 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ | 287 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ |
288 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 288 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
289 const int kHeight = benchmark_height_; \ | 289 const int kHeight = benchmark_height_; \ |
290 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 290 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
291 align_buffer_64(src_uv, 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 291 align_buffer_page_end(src_uv, 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
292 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 292 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
293 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 293 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
294 align_buffer_64(dst_u_c, \ | 294 align_buffer_page_end(dst_u_c, \ |
295 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 295 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
296 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 296 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
297 align_buffer_64(dst_v_c, \ | 297 align_buffer_page_end(dst_v_c, \ |
298 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 298 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
299 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 299 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
300 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 300 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
301 align_buffer_64(dst_u_opt, \ | 301 align_buffer_page_end(dst_u_opt, \ |
302 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 302 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
303 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 303 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
304 align_buffer_64(dst_v_opt, \ | 304 align_buffer_page_end(dst_v_opt, \ |
305 SUBSAMPLE(kWidth, SUBSAMP_X) * \ | 305 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
306 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 306 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
307 for (int i = 0; i < kHeight; ++i) \ | 307 for (int i = 0; i < kHeight; ++i) \ |
308 for (int j = 0; j < kWidth; ++j) \ | 308 for (int j = 0; j < kWidth; ++j) \ |
309 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ | 309 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
310 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ | 310 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ |
311 for (int j = 0; j < 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ | 311 for (int j = 0; j < 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ |
312 src_uv[(i * 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ | 312 src_uv[(i * 2 * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
313 (fastrand() & 0xff); \ | 313 (fastrand() & 0xff); \ |
314 } \ | 314 } \ |
315 } \ | 315 } \ |
316 memset(dst_y_c, 1, kWidth * kHeight); \ | 316 memset(dst_y_c, 1, kWidth * kHeight); \ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 abs(static_cast<int>(dst_v_c[i * \ | 372 abs(static_cast<int>(dst_v_c[i * \ |
373 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ | 373 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ |
374 static_cast<int>(dst_v_opt[i * \ | 374 static_cast<int>(dst_v_opt[i * \ |
375 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ | 375 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ |
376 if (abs_diff > max_diff) { \ | 376 if (abs_diff > max_diff) { \ |
377 max_diff = abs_diff; \ | 377 max_diff = abs_diff; \ |
378 } \ | 378 } \ |
379 } \ | 379 } \ |
380 } \ | 380 } \ |
381 EXPECT_LE(max_diff, 1); \ | 381 EXPECT_LE(max_diff, 1); \ |
382 free_aligned_buffer_64(dst_y_c); \ | 382 free_aligned_buffer_page_end(dst_y_c); \ |
383 free_aligned_buffer_64(dst_u_c); \ | 383 free_aligned_buffer_page_end(dst_u_c); \ |
384 free_aligned_buffer_64(dst_v_c); \ | 384 free_aligned_buffer_page_end(dst_v_c); \ |
385 free_aligned_buffer_64(dst_y_opt); \ | 385 free_aligned_buffer_page_end(dst_y_opt); \ |
386 free_aligned_buffer_64(dst_u_opt); \ | 386 free_aligned_buffer_page_end(dst_u_opt); \ |
387 free_aligned_buffer_64(dst_v_opt); \ | 387 free_aligned_buffer_page_end(dst_v_opt); \ |
388 free_aligned_buffer_64(src_y); \ | 388 free_aligned_buffer_page_end(src_y); \ |
389 free_aligned_buffer_64(src_uv); \ | 389 free_aligned_buffer_page_end(src_uv); \ |
390 } | 390 } |
391 | 391 |
392 #define TESTBIPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 392 #define TESTBIPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
393 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ | 393 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ |
394 TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 394 TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
395 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 395 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
396 benchmark_width_ - 4, _Any, +, 0) \ | 396 benchmark_width_ - 4, _Any, +, 0) \ |
397 TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 397 TESTBIPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
398 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 398 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
399 benchmark_width_, _Unaligned, +, 1) \ | 399 benchmark_width_, _Unaligned, +, 1) \ |
(...skipping 10 matching lines...) Expand all Loading... |
410 #define ALIGNINT(V, ALIGN) (((V) + (ALIGN) - 1) / (ALIGN) * (ALIGN)) | 410 #define ALIGNINT(V, ALIGN) (((V) + (ALIGN) - 1) / (ALIGN) * (ALIGN)) |
411 | 411 |
412 #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 412 #define TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
413 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ | 413 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ |
414 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 414 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
415 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 415 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
416 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 416 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
417 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 417 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
418 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 418 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
419 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 419 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
420 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 420 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
421 align_buffer_64(src_u, kSizeUV + OFF); \ | 421 align_buffer_page_end(src_u, kSizeUV + OFF); \ |
422 align_buffer_64(src_v, kSizeUV + OFF); \ | 422 align_buffer_page_end(src_v, kSizeUV + OFF); \ |
423 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 423 align_buffer_page_end(dst_argb_c, kStrideB * kHeight + OFF); \ |
424 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 424 align_buffer_page_end(dst_argb_opt, kStrideB * kHeight + OFF); \ |
425 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 425 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
426 src_y[i + OFF] = (fastrand() & 0xff); \ | 426 src_y[i + OFF] = (fastrand() & 0xff); \ |
427 } \ | 427 } \ |
428 for (int i = 0; i < kSizeUV; ++i) { \ | 428 for (int i = 0; i < kSizeUV; ++i) { \ |
429 src_u[i + OFF] = (fastrand() & 0xff); \ | 429 src_u[i + OFF] = (fastrand() & 0xff); \ |
430 src_v[i + OFF] = (fastrand() & 0xff); \ | 430 src_v[i + OFF] = (fastrand() & 0xff); \ |
431 } \ | 431 } \ |
432 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 432 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
433 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 433 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
434 MaskCpuFlags(disable_cpu_flags_); \ | 434 MaskCpuFlags(disable_cpu_flags_); \ |
435 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 435 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
436 src_u + OFF, kStrideUV, \ | 436 src_u + OFF, kStrideUV, \ |
437 src_v + OFF, kStrideUV, \ | 437 src_v + OFF, kStrideUV, \ |
438 dst_argb_c + OFF, kStrideB, \ | 438 dst_argb_c + OFF, kStrideB, \ |
439 kWidth, NEG kHeight); \ | 439 kWidth, NEG kHeight); \ |
440 MaskCpuFlags(benchmark_cpu_info_); \ | 440 MaskCpuFlags(benchmark_cpu_info_); \ |
441 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 441 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
442 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 442 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
443 src_u + OFF, kStrideUV, \ | 443 src_u + OFF, kStrideUV, \ |
444 src_v + OFF, kStrideUV, \ | 444 src_v + OFF, kStrideUV, \ |
445 dst_argb_opt + OFF, kStrideB, \ | 445 dst_argb_opt + OFF, kStrideB, \ |
446 kWidth, NEG kHeight); \ | 446 kWidth, NEG kHeight); \ |
447 } \ | 447 } \ |
448 int max_diff = 0; \ | 448 int max_diff = 0; \ |
449 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 449 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
450 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ | 450 align_buffer_page_end(dst_argb32_c, kWidth * BPP_C * kHeight); \ |
451 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ | 451 align_buffer_page_end(dst_argb32_opt, kWidth * BPP_C * kHeight); \ |
452 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ | 452 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ |
453 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ | 453 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ |
454 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ | 454 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ |
455 dst_argb32_c, kWidth * BPP_C , \ | 455 dst_argb32_c, kWidth * BPP_C , \ |
456 kWidth, kHeight); \ | 456 kWidth, kHeight); \ |
457 FMT_B##To##FMT_C(dst_argb_opt + OFF, kStrideB, \ | 457 FMT_B##To##FMT_C(dst_argb_opt + OFF, kStrideB, \ |
458 dst_argb32_opt, kWidth * BPP_C , \ | 458 dst_argb32_opt, kWidth * BPP_C , \ |
459 kWidth, kHeight); \ | 459 kWidth, kHeight); \ |
460 for (int i = 0; i < kWidth * BPP_C * kHeight; ++i) { \ | 460 for (int i = 0; i < kWidth * BPP_C * kHeight; ++i) { \ |
461 int abs_diff = \ | 461 int abs_diff = \ |
462 abs(static_cast<int>(dst_argb32_c[i]) - \ | 462 abs(static_cast<int>(dst_argb32_c[i]) - \ |
463 static_cast<int>(dst_argb32_opt[i])); \ | 463 static_cast<int>(dst_argb32_opt[i])); \ |
464 if (abs_diff > max_diff) { \ | 464 if (abs_diff > max_diff) { \ |
465 max_diff = abs_diff; \ | 465 max_diff = abs_diff; \ |
466 } \ | 466 } \ |
467 } \ | 467 } \ |
468 EXPECT_LE(max_diff, DIFF); \ | 468 EXPECT_LE(max_diff, DIFF); \ |
469 free_aligned_buffer_64(src_y); \ | 469 free_aligned_buffer_page_end(src_y); \ |
470 free_aligned_buffer_64(src_u); \ | 470 free_aligned_buffer_page_end(src_u); \ |
471 free_aligned_buffer_64(src_v); \ | 471 free_aligned_buffer_page_end(src_v); \ |
472 free_aligned_buffer_64(dst_argb_c); \ | 472 free_aligned_buffer_page_end(dst_argb_c); \ |
473 free_aligned_buffer_64(dst_argb_opt); \ | 473 free_aligned_buffer_page_end(dst_argb_opt); \ |
474 free_aligned_buffer_64(dst_argb32_c); \ | 474 free_aligned_buffer_page_end(dst_argb32_c); \ |
475 free_aligned_buffer_64(dst_argb32_opt); \ | 475 free_aligned_buffer_page_end(dst_argb32_opt); \ |
476 } | 476 } |
477 | 477 |
478 #define TESTPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 478 #define TESTPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
479 YALIGN, DIFF, FMT_C, BPP_C) \ | 479 YALIGN, DIFF, FMT_C, BPP_C) \ |
480 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 480 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
481 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \ | 481 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \ |
482 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 482 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
483 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \ | 483 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \ |
484 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 484 TESTPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
485 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \ | 485 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) | 519 TESTPLANARTOB(J420, 2, 2, J400, 1, 1, 1, 0, ARGB, 4) |
520 | 520 |
521 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 521 #define TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
522 YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \ | 522 YALIGN, W1280, DIFF, N, NEG, OFF, ATTEN) \ |
523 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 523 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
524 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 524 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
525 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 525 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
526 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 526 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
527 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 527 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
528 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 528 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
529 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 529 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
530 align_buffer_64(src_u, kSizeUV + OFF); \ | 530 align_buffer_page_end(src_u, kSizeUV + OFF); \ |
531 align_buffer_64(src_v, kSizeUV + OFF); \ | 531 align_buffer_page_end(src_v, kSizeUV + OFF); \ |
532 align_buffer_64(src_a, kWidth * kHeight + OFF); \ | 532 align_buffer_page_end(src_a, kWidth * kHeight + OFF); \ |
533 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 533 align_buffer_page_end(dst_argb_c, kStrideB * kHeight + OFF); \ |
534 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 534 align_buffer_page_end(dst_argb_opt, kStrideB * kHeight + OFF); \ |
535 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 535 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
536 src_y[i + OFF] = (fastrand() & 0xff); \ | 536 src_y[i + OFF] = (fastrand() & 0xff); \ |
537 src_a[i + OFF] = (fastrand() & 0xff); \ | 537 src_a[i + OFF] = (fastrand() & 0xff); \ |
538 } \ | 538 } \ |
539 for (int i = 0; i < kSizeUV; ++i) { \ | 539 for (int i = 0; i < kSizeUV; ++i) { \ |
540 src_u[i + OFF] = (fastrand() & 0xff); \ | 540 src_u[i + OFF] = (fastrand() & 0xff); \ |
541 src_v[i + OFF] = (fastrand() & 0xff); \ | 541 src_v[i + OFF] = (fastrand() & 0xff); \ |
542 } \ | 542 } \ |
543 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 543 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
544 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 544 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
(...skipping 16 matching lines...) Expand all Loading... |
561 int max_diff = 0; \ | 561 int max_diff = 0; \ |
562 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \ | 562 for (int i = 0; i < kWidth * BPP_B * kHeight; ++i) { \ |
563 int abs_diff = \ | 563 int abs_diff = \ |
564 abs(static_cast<int>(dst_argb_c[i + OFF]) - \ | 564 abs(static_cast<int>(dst_argb_c[i + OFF]) - \ |
565 static_cast<int>(dst_argb_opt[i + OFF])); \ | 565 static_cast<int>(dst_argb_opt[i + OFF])); \ |
566 if (abs_diff > max_diff) { \ | 566 if (abs_diff > max_diff) { \ |
567 max_diff = abs_diff; \ | 567 max_diff = abs_diff; \ |
568 } \ | 568 } \ |
569 } \ | 569 } \ |
570 EXPECT_LE(max_diff, DIFF); \ | 570 EXPECT_LE(max_diff, DIFF); \ |
571 free_aligned_buffer_64(src_y); \ | 571 free_aligned_buffer_page_end(src_y); \ |
572 free_aligned_buffer_64(src_u); \ | 572 free_aligned_buffer_page_end(src_u); \ |
573 free_aligned_buffer_64(src_v); \ | 573 free_aligned_buffer_page_end(src_v); \ |
574 free_aligned_buffer_64(src_a); \ | 574 free_aligned_buffer_page_end(src_a); \ |
575 free_aligned_buffer_64(dst_argb_c); \ | 575 free_aligned_buffer_page_end(dst_argb_c); \ |
576 free_aligned_buffer_64(dst_argb_opt); \ | 576 free_aligned_buffer_page_end(dst_argb_opt); \ |
577 } | 577 } |
578 | 578 |
579 #define TESTQPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 579 #define TESTQPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
580 YALIGN, DIFF) \ | 580 YALIGN, DIFF) \ |
581 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 581 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
582 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, 0) \ | 582 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, 0) \ |
583 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 583 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
584 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, 0) \ | 584 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, 0) \ |
585 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 585 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
586 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, 0) \ | 586 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, 0) \ |
587 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 587 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
588 YALIGN, benchmark_width_, DIFF, _Opt, +, 0, 0) \ | 588 YALIGN, benchmark_width_, DIFF, _Opt, +, 0, 0) \ |
589 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 589 TESTQPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
590 YALIGN, benchmark_width_, DIFF, _Premult, +, 0, 1) | 590 YALIGN, benchmark_width_, DIFF, _Premult, +, 0, 1) |
591 | 591 |
592 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2) | 592 TESTQPLANARTOB(I420Alpha, 2, 2, ARGB, 4, 4, 1, 2) |
593 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2) | 593 TESTQPLANARTOB(I420Alpha, 2, 2, ABGR, 4, 4, 1, 2) |
594 | 594 |
595 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 595 #define TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
596 W1280, DIFF, N, NEG, OFF) \ | 596 W1280, DIFF, N, NEG, OFF) \ |
597 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ | 597 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##N) { \ |
598 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 598 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
599 const int kHeight = benchmark_height_; \ | 599 const int kHeight = benchmark_height_; \ |
600 const int kStrideB = kWidth * BPP_B; \ | 600 const int kStrideB = kWidth * BPP_B; \ |
601 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 601 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
602 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 602 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
603 align_buffer_64(src_uv, \ | 603 align_buffer_page_end(src_uv, \ |
604 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \ | 604 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y) * 2 + OFF); \ |
605 align_buffer_64(dst_argb_c, kStrideB * kHeight); \ | 605 align_buffer_page_end(dst_argb_c, kStrideB * kHeight); \ |
606 align_buffer_64(dst_argb_opt, kStrideB * kHeight); \ | 606 align_buffer_page_end(dst_argb_opt, kStrideB * kHeight); \ |
607 for (int i = 0; i < kHeight; ++i) \ | 607 for (int i = 0; i < kHeight; ++i) \ |
608 for (int j = 0; j < kWidth; ++j) \ | 608 for (int j = 0; j < kWidth; ++j) \ |
609 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ | 609 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
610 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 610 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
611 for (int j = 0; j < kStrideUV * 2; ++j) { \ | 611 for (int j = 0; j < kStrideUV * 2; ++j) { \ |
612 src_uv[i * kStrideUV * 2 + j + OFF] = (fastrand() & 0xff); \ | 612 src_uv[i * kStrideUV * 2 + j + OFF] = (fastrand() & 0xff); \ |
613 } \ | 613 } \ |
614 } \ | 614 } \ |
615 memset(dst_argb_c, 1, kStrideB * kHeight); \ | 615 memset(dst_argb_c, 1, kStrideB * kHeight); \ |
616 memset(dst_argb_opt, 101, kStrideB * kHeight); \ | 616 memset(dst_argb_opt, 101, kStrideB * kHeight); \ |
617 MaskCpuFlags(disable_cpu_flags_); \ | 617 MaskCpuFlags(disable_cpu_flags_); \ |
618 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 618 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
619 src_uv + OFF, kStrideUV * 2, \ | 619 src_uv + OFF, kStrideUV * 2, \ |
620 dst_argb_c, kWidth * BPP_B, \ | 620 dst_argb_c, kWidth * BPP_B, \ |
621 kWidth, NEG kHeight); \ | 621 kWidth, NEG kHeight); \ |
622 MaskCpuFlags(benchmark_cpu_info_); \ | 622 MaskCpuFlags(benchmark_cpu_info_); \ |
623 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 623 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
624 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 624 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
625 src_uv + OFF, kStrideUV * 2, \ | 625 src_uv + OFF, kStrideUV * 2, \ |
626 dst_argb_opt, kWidth * BPP_B, \ | 626 dst_argb_opt, kWidth * BPP_B, \ |
627 kWidth, NEG kHeight); \ | 627 kWidth, NEG kHeight); \ |
628 } \ | 628 } \ |
629 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 629 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
630 align_buffer_64(dst_argb32_c, kWidth * 4 * kHeight); \ | 630 align_buffer_page_end(dst_argb32_c, kWidth * 4 * kHeight); \ |
631 align_buffer_64(dst_argb32_opt, kWidth * 4 * kHeight); \ | 631 align_buffer_page_end(dst_argb32_opt, kWidth * 4 * kHeight); \ |
632 memset(dst_argb32_c, 2, kWidth * 4 * kHeight); \ | 632 memset(dst_argb32_c, 2, kWidth * 4 * kHeight); \ |
633 memset(dst_argb32_opt, 102, kWidth * 4 * kHeight); \ | 633 memset(dst_argb32_opt, 102, kWidth * 4 * kHeight); \ |
634 FMT_B##ToARGB(dst_argb_c, kStrideB, \ | 634 FMT_B##ToARGB(dst_argb_c, kStrideB, \ |
635 dst_argb32_c, kWidth * 4, \ | 635 dst_argb32_c, kWidth * 4, \ |
636 kWidth, kHeight); \ | 636 kWidth, kHeight); \ |
637 FMT_B##ToARGB(dst_argb_opt, kStrideB, \ | 637 FMT_B##ToARGB(dst_argb_opt, kStrideB, \ |
638 dst_argb32_opt, kWidth * 4, \ | 638 dst_argb32_opt, kWidth * 4, \ |
639 kWidth, kHeight); \ | 639 kWidth, kHeight); \ |
640 int max_diff = 0; \ | 640 int max_diff = 0; \ |
641 for (int i = 0; i < kHeight; ++i) { \ | 641 for (int i = 0; i < kHeight; ++i) { \ |
642 for (int j = 0; j < kWidth * 4; ++j) { \ | 642 for (int j = 0; j < kWidth * 4; ++j) { \ |
643 int abs_diff = \ | 643 int abs_diff = \ |
644 abs(static_cast<int>(dst_argb32_c[i * kWidth * 4 + j]) - \ | 644 abs(static_cast<int>(dst_argb32_c[i * kWidth * 4 + j]) - \ |
645 static_cast<int>(dst_argb32_opt[i * kWidth * 4 + j])); \ | 645 static_cast<int>(dst_argb32_opt[i * kWidth * 4 + j])); \ |
646 if (abs_diff > max_diff) { \ | 646 if (abs_diff > max_diff) { \ |
647 max_diff = abs_diff; \ | 647 max_diff = abs_diff; \ |
648 } \ | 648 } \ |
649 } \ | 649 } \ |
650 } \ | 650 } \ |
651 EXPECT_LE(max_diff, DIFF); \ | 651 EXPECT_LE(max_diff, DIFF); \ |
652 free_aligned_buffer_64(src_y); \ | 652 free_aligned_buffer_page_end(src_y); \ |
653 free_aligned_buffer_64(src_uv); \ | 653 free_aligned_buffer_page_end(src_uv); \ |
654 free_aligned_buffer_64(dst_argb_c); \ | 654 free_aligned_buffer_page_end(dst_argb_c); \ |
655 free_aligned_buffer_64(dst_argb_opt); \ | 655 free_aligned_buffer_page_end(dst_argb_opt); \ |
656 free_aligned_buffer_64(dst_argb32_c); \ | 656 free_aligned_buffer_page_end(dst_argb32_c); \ |
657 free_aligned_buffer_64(dst_argb32_opt); \ | 657 free_aligned_buffer_page_end(dst_argb32_opt); \ |
658 } | 658 } |
659 | 659 |
660 #define TESTBIPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF) \ | 660 #define TESTBIPLANARTOB(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, DIFF) \ |
661 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 661 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
662 benchmark_width_ - 4, DIFF, _Any, +, 0) \ | 662 benchmark_width_ - 4, DIFF, _Any, +, 0) \ |
663 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 663 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
664 benchmark_width_, DIFF, _Unaligned, +, 1) \ | 664 benchmark_width_, DIFF, _Unaligned, +, 1) \ |
665 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 665 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
666 benchmark_width_, DIFF, _Invert, -, 0) \ | 666 benchmark_width_, DIFF, _Invert, -, 0) \ |
667 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ | 667 TESTBIPLANARTOBI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, \ |
668 benchmark_width_, DIFF, _Opt, +, 0) | 668 benchmark_width_, DIFF, _Opt, +, 0) |
669 | 669 |
670 TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4, 2) | 670 TESTBIPLANARTOB(NV12, 2, 2, ARGB, 4, 2) |
671 TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) | 671 TESTBIPLANARTOB(NV21, 2, 2, ARGB, 4, 2) |
672 TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) | 672 TESTBIPLANARTOB(NV12, 2, 2, RGB565, 2, 9) |
673 | 673 |
674 #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 674 #define TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
675 W1280, DIFF, N, NEG, OFF) \ | 675 W1280, DIFF, N, NEG, OFF) \ |
676 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ | 676 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ |
677 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 677 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
678 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 678 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
679 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 679 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
680 const int kStride = \ | 680 const int kStride = \ |
681 (kStrideUV * SUBSAMP_X * 8 * BPP_A + 7) / 8; \ | 681 (kStrideUV * SUBSAMP_X * 8 * BPP_A + 7) / 8; \ |
682 align_buffer_64(src_argb, kStride * kHeight + OFF); \ | 682 align_buffer_page_end(src_argb, kStride * kHeight + OFF); \ |
683 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 683 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
684 align_buffer_64(dst_u_c, \ | 684 align_buffer_page_end(dst_u_c, \ |
685 kStrideUV * \ | 685 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
686 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 686 align_buffer_page_end(dst_v_c, \ |
687 align_buffer_64(dst_v_c, \ | 687 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
688 kStrideUV * \ | 688 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
689 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 689 align_buffer_page_end(dst_u_opt, \ |
690 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 690 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
691 align_buffer_64(dst_u_opt, \ | 691 align_buffer_page_end(dst_v_opt, \ |
692 kStrideUV * \ | |
693 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | |
694 align_buffer_64(dst_v_opt, \ | |
695 kStrideUV * \ | 692 kStrideUV * \ |
696 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 693 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
697 memset(dst_y_c, 1, kWidth * kHeight); \ | 694 memset(dst_y_c, 1, kWidth * kHeight); \ |
698 memset(dst_u_c, 2, \ | 695 memset(dst_u_c, 2, \ |
699 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 696 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
700 memset(dst_v_c, 3, \ | 697 memset(dst_v_c, 3, \ |
701 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 698 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
702 memset(dst_y_opt, 101, kWidth * kHeight); \ | 699 memset(dst_y_opt, 101, kWidth * kHeight); \ |
703 memset(dst_u_opt, 102, \ | 700 memset(dst_u_opt, 102, \ |
704 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 701 kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
(...skipping 29 matching lines...) Expand all Loading... |
734 } \ | 731 } \ |
735 } \ | 732 } \ |
736 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ | 733 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
737 for (int j = 0; j < kStrideUV; ++j) { \ | 734 for (int j = 0; j < kStrideUV; ++j) { \ |
738 EXPECT_NEAR(static_cast<int>(dst_v_c[i * \ | 735 EXPECT_NEAR(static_cast<int>(dst_v_c[i * \ |
739 kStrideUV + j]), \ | 736 kStrideUV + j]), \ |
740 static_cast<int>(dst_v_opt[i * \ | 737 static_cast<int>(dst_v_opt[i * \ |
741 kStrideUV + j]), DIFF); \ | 738 kStrideUV + j]), DIFF); \ |
742 } \ | 739 } \ |
743 } \ | 740 } \ |
744 free_aligned_buffer_64(dst_y_c); \ | 741 free_aligned_buffer_page_end(dst_y_c); \ |
745 free_aligned_buffer_64(dst_u_c); \ | 742 free_aligned_buffer_page_end(dst_u_c); \ |
746 free_aligned_buffer_64(dst_v_c); \ | 743 free_aligned_buffer_page_end(dst_v_c); \ |
747 free_aligned_buffer_64(dst_y_opt); \ | 744 free_aligned_buffer_page_end(dst_y_opt); \ |
748 free_aligned_buffer_64(dst_u_opt); \ | 745 free_aligned_buffer_page_end(dst_u_opt); \ |
749 free_aligned_buffer_64(dst_v_opt); \ | 746 free_aligned_buffer_page_end(dst_v_opt); \ |
750 free_aligned_buffer_64(src_argb); \ | 747 free_aligned_buffer_page_end(src_argb); \ |
751 } | 748 } |
752 | 749 |
753 #define TESTATOPLANAR(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 750 #define TESTATOPLANAR(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
754 DIFF) \ | 751 DIFF) \ |
755 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 752 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
756 benchmark_width_ - 4, DIFF, _Any, +, 0) \ | 753 benchmark_width_ - 4, DIFF, _Any, +, 0) \ |
757 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 754 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
758 benchmark_width_, DIFF, _Unaligned, +, 1) \ | 755 benchmark_width_, DIFF, _Unaligned, +, 1) \ |
759 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 756 TESTATOPLANARI(FMT_A, BPP_A, YALIGN, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
760 benchmark_width_, DIFF, _Invert, -, 0) \ | 757 benchmark_width_, DIFF, _Invert, -, 0) \ |
(...skipping 22 matching lines...) Expand all Loading... |
783 TESTATOPLANAR(ARGB, 4, 1, I411, 4, 1, 4) | 780 TESTATOPLANAR(ARGB, 4, 1, I411, 4, 1, 4) |
784 TESTATOPLANAR(ARGB, 4, 1, I422, 2, 1, 2) | 781 TESTATOPLANAR(ARGB, 4, 1, I422, 2, 1, 2) |
785 TESTATOPLANAR(ARGB, 4, 1, I444, 1, 1, 2) | 782 TESTATOPLANAR(ARGB, 4, 1, I444, 1, 1, 2) |
786 TESTATOPLANAR(YUY2, 2, 1, I420, 2, 2, 2) | 783 TESTATOPLANAR(YUY2, 2, 1, I420, 2, 2, 2) |
787 TESTATOPLANAR(UYVY, 2, 1, I420, 2, 2, 2) | 784 TESTATOPLANAR(UYVY, 2, 1, I420, 2, 2, 2) |
788 TESTATOPLANAR(YUY2, 2, 1, I422, 2, 1, 2) | 785 TESTATOPLANAR(YUY2, 2, 1, I422, 2, 1, 2) |
789 TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1, 2) | 786 TESTATOPLANAR(UYVY, 2, 1, I422, 2, 1, 2) |
790 TESTATOPLANAR(I400, 1, 1, I420, 2, 2, 2) | 787 TESTATOPLANAR(I400, 1, 1, I420, 2, 2, 2) |
791 TESTATOPLANAR(J400, 1, 1, J420, 2, 2, 2) | 788 TESTATOPLANAR(J400, 1, 1, J420, 2, 2, 2) |
792 | 789 |
793 #define TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y,\ | 790 #define TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, \ |
794 W1280, N, NEG, OFF) \ | 791 SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
795 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ | 792 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_PLANAR##N) { \ |
796 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 793 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
797 const int kHeight = benchmark_height_; \ | 794 const int kHeight = benchmark_height_; \ |
798 const int kStride = SUBSAMPLE(kWidth, SUB_A) * BPP_A; \ | 795 const int kStride = SUBSAMPLE(kWidth, SUB_A) * BPP_A; \ |
799 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 796 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
800 align_buffer_64(src_argb, kStride * kHeight + OFF); \ | 797 align_buffer_page_end(src_argb, kStride * kHeight + OFF); \ |
801 align_buffer_64(dst_y_c, kWidth * kHeight); \ | 798 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
802 align_buffer_64(dst_uv_c, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 799 align_buffer_page_end(dst_uv_c, \ |
803 align_buffer_64(dst_y_opt, kWidth * kHeight); \ | 800 kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
804 align_buffer_64(dst_uv_opt, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 801 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
| 802 align_buffer_page_end(dst_uv_opt, \ |
| 803 kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
805 for (int i = 0; i < kHeight; ++i) \ | 804 for (int i = 0; i < kHeight; ++i) \ |
806 for (int j = 0; j < kStride; ++j) \ | 805 for (int j = 0; j < kStride; ++j) \ |
807 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ | 806 src_argb[(i * kStride) + j + OFF] = (fastrand() & 0xff); \ |
808 memset(dst_y_c, 1, kWidth * kHeight); \ | 807 memset(dst_y_c, 1, kWidth * kHeight); \ |
809 memset(dst_uv_c, 2, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 808 memset(dst_uv_c, 2, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
810 memset(dst_y_opt, 101, kWidth * kHeight); \ | 809 memset(dst_y_opt, 101, kWidth * kHeight); \ |
811 memset(dst_uv_opt, 102, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ | 810 memset(dst_uv_opt, 102, kStrideUV * 2 * SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
812 MaskCpuFlags(disable_cpu_flags_); \ | 811 MaskCpuFlags(disable_cpu_flags_); \ |
813 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ | 812 FMT_A##To##FMT_PLANAR(src_argb + OFF, kStride, \ |
814 dst_y_c, kWidth, dst_uv_c, kStrideUV * 2, \ | 813 dst_y_c, kWidth, dst_uv_c, kStrideUV * 2, \ |
(...skipping 20 matching lines...) Expand all Loading... |
835 for (int j = 0; j < kStrideUV * 2; ++j) { \ | 834 for (int j = 0; j < kStrideUV * 2; ++j) { \ |
836 int abs_diff = \ | 835 int abs_diff = \ |
837 abs(static_cast<int>(dst_uv_c[i * kStrideUV * 2 + j]) - \ | 836 abs(static_cast<int>(dst_uv_c[i * kStrideUV * 2 + j]) - \ |
838 static_cast<int>(dst_uv_opt[i * kStrideUV * 2 + j])); \ | 837 static_cast<int>(dst_uv_opt[i * kStrideUV * 2 + j])); \ |
839 if (abs_diff > max_diff) { \ | 838 if (abs_diff > max_diff) { \ |
840 max_diff = abs_diff; \ | 839 max_diff = abs_diff; \ |
841 } \ | 840 } \ |
842 } \ | 841 } \ |
843 } \ | 842 } \ |
844 EXPECT_LE(max_diff, 4); \ | 843 EXPECT_LE(max_diff, 4); \ |
845 free_aligned_buffer_64(dst_y_c); \ | 844 free_aligned_buffer_page_end(dst_y_c); \ |
846 free_aligned_buffer_64(dst_uv_c); \ | 845 free_aligned_buffer_page_end(dst_uv_c); \ |
847 free_aligned_buffer_64(dst_y_opt); \ | 846 free_aligned_buffer_page_end(dst_y_opt); \ |
848 free_aligned_buffer_64(dst_uv_opt); \ | 847 free_aligned_buffer_page_end(dst_uv_opt); \ |
849 free_aligned_buffer_64(src_argb); \ | 848 free_aligned_buffer_page_end(src_argb); \ |
850 } | 849 } |
851 | 850 |
852 #define TESTATOBIPLANAR(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ | 851 #define TESTATOBIPLANAR(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ |
853 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 852 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
854 benchmark_width_ - 4, _Any, +, 0) \ | 853 benchmark_width_ - 4, _Any, +, 0) \ |
855 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 854 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
856 benchmark_width_, _Unaligned, +, 1) \ | 855 benchmark_width_, _Unaligned, +, 1) \ |
857 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 856 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
858 benchmark_width_, _Invert, -, 0) \ | 857 benchmark_width_, _Invert, -, 0) \ |
859 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ | 858 TESTATOBIPLANARI(FMT_A, SUB_A, BPP_A, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
860 benchmark_width_, _Opt, +, 0) | 859 benchmark_width_, _Opt, +, 0) |
861 | 860 |
862 TESTATOBIPLANAR(ARGB, 1, 4, NV12, 2, 2) | 861 TESTATOBIPLANAR(ARGB, 1, 4, NV12, 2, 2) |
863 TESTATOBIPLANAR(ARGB, 1, 4, NV21, 2, 2) | 862 TESTATOBIPLANAR(ARGB, 1, 4, NV21, 2, 2) |
864 TESTATOBIPLANAR(YUY2, 2, 4, NV12, 2, 2) | 863 TESTATOBIPLANAR(YUY2, 2, 4, NV12, 2, 2) |
865 TESTATOBIPLANAR(UYVY, 2, 4, NV12, 2, 2) | 864 TESTATOBIPLANAR(UYVY, 2, 4, NV12, 2, 2) |
866 | 865 |
867 #define TESTATOBI(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ | 866 #define TESTATOBI(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ |
868 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, \ | 867 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, \ |
869 W1280, DIFF, N, NEG, OFF) \ | 868 W1280, DIFF, N, NEG, OFF) \ |
870 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##N) { \ | 869 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##N) { \ |
871 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 870 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
872 const int kHeight = benchmark_height_; \ | 871 const int kHeight = benchmark_height_; \ |
873 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ | 872 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ |
874 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ | 873 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ |
875 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ | 874 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ |
876 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ | 875 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ |
877 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ | 876 align_buffer_page_end(src_argb, kStrideA * kHeightA + OFF); \ |
878 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \ | 877 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \ |
879 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \ | 878 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ |
880 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 879 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
881 src_argb[i + OFF] = (fastrand() & 0xff); \ | 880 src_argb[i + OFF] = (fastrand() & 0xff); \ |
882 } \ | 881 } \ |
883 memset(dst_argb_c, 1, kStrideB * kHeightB); \ | 882 memset(dst_argb_c, 1, kStrideB * kHeightB); \ |
884 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ | 883 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ |
885 MaskCpuFlags(disable_cpu_flags_); \ | 884 MaskCpuFlags(disable_cpu_flags_); \ |
886 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ | 885 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ |
887 dst_argb_c, kStrideB, \ | 886 dst_argb_c, kStrideB, \ |
888 kWidth, NEG kHeight); \ | 887 kWidth, NEG kHeight); \ |
889 MaskCpuFlags(benchmark_cpu_info_); \ | 888 MaskCpuFlags(benchmark_cpu_info_); \ |
890 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 889 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
891 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ | 890 FMT_A##To##FMT_B(src_argb + OFF, kStrideA, \ |
892 dst_argb_opt, kStrideB, \ | 891 dst_argb_opt, kStrideB, \ |
893 kWidth, NEG kHeight); \ | 892 kWidth, NEG kHeight); \ |
894 } \ | 893 } \ |
895 int max_diff = 0; \ | 894 int max_diff = 0; \ |
896 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ | 895 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ |
897 int abs_diff = \ | 896 int abs_diff = \ |
898 abs(static_cast<int>(dst_argb_c[i]) - \ | 897 abs(static_cast<int>(dst_argb_c[i]) - \ |
899 static_cast<int>(dst_argb_opt[i])); \ | 898 static_cast<int>(dst_argb_opt[i])); \ |
900 if (abs_diff > max_diff) { \ | 899 if (abs_diff > max_diff) { \ |
901 max_diff = abs_diff; \ | 900 max_diff = abs_diff; \ |
902 } \ | 901 } \ |
903 } \ | 902 } \ |
904 EXPECT_LE(max_diff, DIFF); \ | 903 EXPECT_LE(max_diff, DIFF); \ |
905 free_aligned_buffer_64(src_argb); \ | 904 free_aligned_buffer_page_end(src_argb); \ |
906 free_aligned_buffer_64(dst_argb_c); \ | 905 free_aligned_buffer_page_end(dst_argb_c); \ |
907 free_aligned_buffer_64(dst_argb_opt); \ | 906 free_aligned_buffer_page_end(dst_argb_opt); \ |
908 } | 907 } |
909 | 908 |
910 #define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ | 909 #define TESTATOBRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ |
911 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ | 910 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ |
912 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##_Random) { \ | 911 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##_Random) { \ |
913 for (int times = 0; times < benchmark_iterations_; ++times) { \ | 912 for (int times = 0; times < benchmark_iterations_; ++times) { \ |
914 const int kWidth = (fastrand() & 63) + 1; \ | 913 const int kWidth = (fastrand() & 63) + 1; \ |
915 const int kHeight = (fastrand() & 31) + 1; \ | 914 const int kHeight = (fastrand() & 31) + 1; \ |
916 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ | 915 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ |
917 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ | 916 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 #define TESTATOBDI(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ | 999 #define TESTATOBDI(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ |
1001 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, \ | 1000 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, \ |
1002 W1280, DIFF, N, NEG, OFF) \ | 1001 W1280, DIFF, N, NEG, OFF) \ |
1003 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##Dither##N) { \ | 1002 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##Dither##N) { \ |
1004 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1003 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1005 const int kHeight = benchmark_height_; \ | 1004 const int kHeight = benchmark_height_; \ |
1006 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ | 1005 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ |
1007 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ | 1006 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ |
1008 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ | 1007 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ |
1009 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ | 1008 const int kStrideB = (kWidth * BPP_B + STRIDE_B - 1) / STRIDE_B * STRIDE_B; \ |
1010 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ | 1009 align_buffer_page_end(src_argb, kStrideA * kHeightA + OFF); \ |
1011 align_buffer_64(dst_argb_c, kStrideB * kHeightB); \ | 1010 align_buffer_page_end(dst_argb_c, kStrideB * kHeightB); \ |
1012 align_buffer_64(dst_argb_opt, kStrideB * kHeightB); \ | 1011 align_buffer_page_end(dst_argb_opt, kStrideB * kHeightB); \ |
1013 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 1012 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
1014 src_argb[i + OFF] = (fastrand() & 0xff); \ | 1013 src_argb[i + OFF] = (fastrand() & 0xff); \ |
1015 } \ | 1014 } \ |
1016 memset(dst_argb_c, 1, kStrideB * kHeightB); \ | 1015 memset(dst_argb_c, 1, kStrideB * kHeightB); \ |
1017 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ | 1016 memset(dst_argb_opt, 101, kStrideB * kHeightB); \ |
1018 MaskCpuFlags(disable_cpu_flags_); \ | 1017 MaskCpuFlags(disable_cpu_flags_); \ |
1019 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ | 1018 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ |
1020 dst_argb_c, kStrideB, \ | 1019 dst_argb_c, kStrideB, \ |
1021 NULL, kWidth, NEG kHeight); \ | 1020 NULL, kWidth, NEG kHeight); \ |
1022 MaskCpuFlags(benchmark_cpu_info_); \ | 1021 MaskCpuFlags(benchmark_cpu_info_); \ |
1023 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1022 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1024 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ | 1023 FMT_A##To##FMT_B##Dither(src_argb + OFF, kStrideA, \ |
1025 dst_argb_opt, kStrideB, \ | 1024 dst_argb_opt, kStrideB, \ |
1026 NULL, kWidth, NEG kHeight); \ | 1025 NULL, kWidth, NEG kHeight); \ |
1027 } \ | 1026 } \ |
1028 int max_diff = 0; \ | 1027 int max_diff = 0; \ |
1029 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ | 1028 for (int i = 0; i < kStrideB * kHeightB; ++i) { \ |
1030 int abs_diff = \ | 1029 int abs_diff = \ |
1031 abs(static_cast<int>(dst_argb_c[i]) - \ | 1030 abs(static_cast<int>(dst_argb_c[i]) - \ |
1032 static_cast<int>(dst_argb_opt[i])); \ | 1031 static_cast<int>(dst_argb_opt[i])); \ |
1033 if (abs_diff > max_diff) { \ | 1032 if (abs_diff > max_diff) { \ |
1034 max_diff = abs_diff; \ | 1033 max_diff = abs_diff; \ |
1035 } \ | 1034 } \ |
1036 } \ | 1035 } \ |
1037 EXPECT_LE(max_diff, DIFF); \ | 1036 EXPECT_LE(max_diff, DIFF); \ |
1038 free_aligned_buffer_64(src_argb); \ | 1037 free_aligned_buffer_page_end(src_argb); \ |
1039 free_aligned_buffer_64(dst_argb_c); \ | 1038 free_aligned_buffer_page_end(dst_argb_c); \ |
1040 free_aligned_buffer_64(dst_argb_opt); \ | 1039 free_aligned_buffer_page_end(dst_argb_opt); \ |
1041 } | 1040 } |
1042 | 1041 |
1043 #define TESTATOBDRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ | 1042 #define TESTATOBDRANDOM(FMT_A, BPP_A, STRIDE_A, HEIGHT_A, \ |
1044 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ | 1043 FMT_B, BPP_B, STRIDE_B, HEIGHT_B, DIFF) \ |
1045 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##Dither_Random) { \ | 1044 TEST_F(LibYUVConvertTest, FMT_A##To##FMT_B##Dither_Random) { \ |
1046 for (int times = 0; times < benchmark_iterations_; ++times) { \ | 1045 for (int times = 0; times < benchmark_iterations_; ++times) { \ |
1047 const int kWidth = (fastrand() & 63) + 1; \ | 1046 const int kWidth = (fastrand() & 63) + 1; \ |
1048 const int kHeight = (fastrand() & 31) + 1; \ | 1047 const int kHeight = (fastrand() & 31) + 1; \ |
1049 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ | 1048 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ |
1050 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ | 1049 const int kHeightB = (kHeight + HEIGHT_B - 1) / HEIGHT_B * HEIGHT_B; \ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1100 |
1102 TESTATOBD(ARGB, 4, 4, 1, RGB565, 2, 2, 1, 0) | 1101 TESTATOBD(ARGB, 4, 4, 1, RGB565, 2, 2, 1, 0) |
1103 | 1102 |
1104 #define TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ | 1103 #define TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ |
1105 W1280, N, NEG, OFF) \ | 1104 W1280, N, NEG, OFF) \ |
1106 TEST_F(LibYUVConvertTest, FMT_ATOB##_Symetric##N) { \ | 1105 TEST_F(LibYUVConvertTest, FMT_ATOB##_Symetric##N) { \ |
1107 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1106 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1108 const int kHeight = benchmark_height_; \ | 1107 const int kHeight = benchmark_height_; \ |
1109 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ | 1108 const int kHeightA = (kHeight + HEIGHT_A - 1) / HEIGHT_A * HEIGHT_A; \ |
1110 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ | 1109 const int kStrideA = (kWidth * BPP_A + STRIDE_A - 1) / STRIDE_A * STRIDE_A; \ |
1111 align_buffer_64(src_argb, kStrideA * kHeightA + OFF); \ | 1110 align_buffer_page_end(src_argb, kStrideA * kHeightA + OFF); \ |
1112 align_buffer_64(dst_argb_c, kStrideA * kHeightA); \ | 1111 align_buffer_page_end(dst_argb_c, kStrideA * kHeightA); \ |
1113 align_buffer_64(dst_argb_opt, kStrideA * kHeightA); \ | 1112 align_buffer_page_end(dst_argb_opt, kStrideA * kHeightA); \ |
1114 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 1113 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
1115 src_argb[i + OFF] = (fastrand() & 0xff); \ | 1114 src_argb[i + OFF] = (fastrand() & 0xff); \ |
1116 } \ | 1115 } \ |
1117 memset(dst_argb_c, 1, kStrideA * kHeightA); \ | 1116 memset(dst_argb_c, 1, kStrideA * kHeightA); \ |
1118 memset(dst_argb_opt, 101, kStrideA * kHeightA); \ | 1117 memset(dst_argb_opt, 101, kStrideA * kHeightA); \ |
1119 MaskCpuFlags(disable_cpu_flags_); \ | 1118 MaskCpuFlags(disable_cpu_flags_); \ |
1120 FMT_ATOB(src_argb + OFF, kStrideA, \ | 1119 FMT_ATOB(src_argb + OFF, kStrideA, \ |
1121 dst_argb_c, kStrideA, \ | 1120 dst_argb_c, kStrideA, \ |
1122 kWidth, NEG kHeight); \ | 1121 kWidth, NEG kHeight); \ |
1123 MaskCpuFlags(benchmark_cpu_info_); \ | 1122 MaskCpuFlags(benchmark_cpu_info_); \ |
1124 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1123 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1125 FMT_ATOB(src_argb + OFF, kStrideA, \ | 1124 FMT_ATOB(src_argb + OFF, kStrideA, \ |
1126 dst_argb_opt, kStrideA, \ | 1125 dst_argb_opt, kStrideA, \ |
1127 kWidth, NEG kHeight); \ | 1126 kWidth, NEG kHeight); \ |
1128 } \ | 1127 } \ |
1129 MaskCpuFlags(disable_cpu_flags_); \ | 1128 MaskCpuFlags(disable_cpu_flags_); \ |
1130 FMT_ATOB(dst_argb_c, kStrideA, \ | 1129 FMT_ATOB(dst_argb_c, kStrideA, \ |
1131 dst_argb_c, kStrideA, \ | 1130 dst_argb_c, kStrideA, \ |
1132 kWidth, NEG kHeight); \ | 1131 kWidth, NEG kHeight); \ |
1133 MaskCpuFlags(benchmark_cpu_info_); \ | 1132 MaskCpuFlags(benchmark_cpu_info_); \ |
1134 FMT_ATOB(dst_argb_opt, kStrideA, \ | 1133 FMT_ATOB(dst_argb_opt, kStrideA, \ |
1135 dst_argb_opt, kStrideA, \ | 1134 dst_argb_opt, kStrideA, \ |
1136 kWidth, NEG kHeight); \ | 1135 kWidth, NEG kHeight); \ |
1137 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ | 1136 for (int i = 0; i < kStrideA * kHeightA; ++i) { \ |
1138 EXPECT_EQ(src_argb[i + OFF], dst_argb_opt[i]); \ | 1137 EXPECT_EQ(src_argb[i + OFF], dst_argb_opt[i]); \ |
1139 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); \ | 1138 EXPECT_EQ(dst_argb_c[i], dst_argb_opt[i]); \ |
1140 } \ | 1139 } \ |
1141 free_aligned_buffer_64(src_argb); \ | 1140 free_aligned_buffer_page_end(src_argb); \ |
1142 free_aligned_buffer_64(dst_argb_c); \ | 1141 free_aligned_buffer_page_end(dst_argb_c); \ |
1143 free_aligned_buffer_64(dst_argb_opt); \ | 1142 free_aligned_buffer_page_end(dst_argb_opt); \ |
1144 } | 1143 } |
1145 | 1144 |
1146 #define TESTSYM(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A) \ | 1145 #define TESTSYM(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A) \ |
1147 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ | 1146 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ |
1148 benchmark_width_ - 4, _Any, +, 0) \ | 1147 benchmark_width_ - 4, _Any, +, 0) \ |
1149 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ | 1148 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ |
1150 benchmark_width_, _Unaligned, +, 1) \ | 1149 benchmark_width_, _Unaligned, +, 1) \ |
1151 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ | 1150 TESTSYMI(FMT_ATOB, BPP_A, STRIDE_A, HEIGHT_A, \ |
1152 benchmark_width_, _Opt, +, 0) | 1151 benchmark_width_, _Opt, +, 0) |
1153 | 1152 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 const int kWidth = benchmark_width_; | 1353 const int kWidth = benchmark_width_; |
1355 const int kHeight = benchmark_height_; | 1354 const int kHeight = benchmark_height_; |
1356 const int crop_y = | 1355 const int crop_y = |
1357 ((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1; | 1356 ((benchmark_height_ - (benchmark_height_ * 360 / 480)) / 2 + 1) & ~1; |
1358 const int kDestWidth = benchmark_width_; | 1357 const int kDestWidth = benchmark_width_; |
1359 const int kDestHeight = benchmark_height_ - crop_y * 2; | 1358 const int kDestHeight = benchmark_height_ - crop_y * 2; |
1360 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); | 1359 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); |
1361 const int sample_size = kWidth * kHeight + | 1360 const int sample_size = kWidth * kHeight + |
1362 kStrideUV * | 1361 kStrideUV * |
1363 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; | 1362 SUBSAMPLE(kHeight, SUBSAMP_Y) * 2; |
1364 align_buffer_64(src_y, sample_size); | 1363 align_buffer_page_end(src_y, sample_size); |
1365 uint8* src_uv = src_y + kWidth * kHeight; | 1364 uint8* src_uv = src_y + kWidth * kHeight; |
1366 | 1365 |
1367 align_buffer_64(dst_y, kDestWidth * kDestHeight); | 1366 align_buffer_page_end(dst_y, kDestWidth * kDestHeight); |
1368 align_buffer_64(dst_u, | 1367 align_buffer_page_end(dst_u, |
1369 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1368 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1370 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1369 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1371 align_buffer_64(dst_v, | 1370 align_buffer_page_end(dst_v, |
1372 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1371 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1373 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1372 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1374 | 1373 |
1375 align_buffer_64(dst_y_2, kDestWidth * kDestHeight); | 1374 align_buffer_page_end(dst_y_2, kDestWidth * kDestHeight); |
1376 align_buffer_64(dst_u_2, | 1375 align_buffer_page_end(dst_u_2, |
1377 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1376 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1378 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1377 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1379 align_buffer_64(dst_v_2, | 1378 align_buffer_page_end(dst_v_2, |
1380 SUBSAMPLE(kDestWidth, SUBSAMP_X) * | 1379 SUBSAMPLE(kDestWidth, SUBSAMP_X) * |
1381 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); | 1380 SUBSAMPLE(kDestHeight, SUBSAMP_Y)); |
1382 | 1381 |
1383 for (int i = 0; i < kHeight * kWidth; ++i) { | 1382 for (int i = 0; i < kHeight * kWidth; ++i) { |
1384 src_y[i] = (fastrand() & 0xff); | 1383 src_y[i] = (fastrand() & 0xff); |
1385 } | 1384 } |
1386 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * | 1385 for (int i = 0; i < (SUBSAMPLE(kHeight, SUBSAMP_Y) * |
1387 kStrideUV) * 2; ++i) { | 1386 kStrideUV) * 2; ++i) { |
1388 src_uv[i] = (fastrand() & 0xff); | 1387 src_uv[i] = (fastrand() & 0xff); |
1389 } | 1388 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 EXPECT_EQ(dst_u[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j], | 1424 EXPECT_EQ(dst_u[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j], |
1426 dst_u_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]); | 1425 dst_u_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]); |
1427 } | 1426 } |
1428 } | 1427 } |
1429 for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) { | 1428 for (int i = 0; i < SUBSAMPLE(kDestHeight, SUBSAMP_Y); ++i) { |
1430 for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) { | 1429 for (int j = 0; j < SUBSAMPLE(kDestWidth, SUBSAMP_X); ++j) { |
1431 EXPECT_EQ(dst_v[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j], | 1430 EXPECT_EQ(dst_v[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j], |
1432 dst_v_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]); | 1431 dst_v_2[i * SUBSAMPLE(kDestWidth, SUBSAMP_X) + j]); |
1433 } | 1432 } |
1434 } | 1433 } |
1435 free_aligned_buffer_64(dst_y); | 1434 free_aligned_buffer_page_end(dst_y); |
1436 free_aligned_buffer_64(dst_u); | 1435 free_aligned_buffer_page_end(dst_u); |
1437 free_aligned_buffer_64(dst_v); | 1436 free_aligned_buffer_page_end(dst_v); |
1438 free_aligned_buffer_64(dst_y_2); | 1437 free_aligned_buffer_page_end(dst_y_2); |
1439 free_aligned_buffer_64(dst_u_2); | 1438 free_aligned_buffer_page_end(dst_u_2); |
1440 free_aligned_buffer_64(dst_v_2); | 1439 free_aligned_buffer_page_end(dst_v_2); |
1441 free_aligned_buffer_64(src_y); | 1440 free_aligned_buffer_page_end(src_y); |
1442 } | 1441 } |
1443 | 1442 |
1444 TEST_F(LibYUVConvertTest, TestYToARGB) { | 1443 TEST_F(LibYUVConvertTest, TestYToARGB) { |
1445 uint8 y[32]; | 1444 uint8 y[32]; |
1446 uint8 expectedg[32]; | 1445 uint8 expectedg[32]; |
1447 for (int i = 0; i < 32; ++i) { | 1446 for (int i = 0; i < 32; ++i) { |
1448 y[i] = i * 5 + 17; | 1447 y[i] = i * 5 + 17; |
1449 expectedg[i] = static_cast<int>((y[i] - 16) * 1.164f + 0.5f); | 1448 expectedg[i] = static_cast<int>((y[i] - 16) * 1.164f + 0.5f); |
1450 } | 1449 } |
1451 uint8 argb[32 * 4]; | 1450 uint8 argb[32 * 4]; |
(...skipping 12 matching lines...) Expand all Loading... |
1464 } | 1463 } |
1465 | 1464 |
1466 static const uint8 kNoDither4x4[16] = { | 1465 static const uint8 kNoDither4x4[16] = { |
1467 0, 0, 0, 0, | 1466 0, 0, 0, 0, |
1468 0, 0, 0, 0, | 1467 0, 0, 0, 0, |
1469 0, 0, 0, 0, | 1468 0, 0, 0, 0, |
1470 0, 0, 0, 0, | 1469 0, 0, 0, 0, |
1471 }; | 1470 }; |
1472 | 1471 |
1473 TEST_F(LibYUVConvertTest, TestNoDither) { | 1472 TEST_F(LibYUVConvertTest, TestNoDither) { |
1474 align_buffer_64(src_argb, benchmark_width_ * benchmark_height_ * 4); | 1473 align_buffer_page_end(src_argb, benchmark_width_ * benchmark_height_ * 4); |
1475 align_buffer_64(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); | 1474 align_buffer_page_end(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); |
1476 align_buffer_64(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); | 1475 align_buffer_page_end(dst_rgb565dither, |
| 1476 benchmark_width_ * benchmark_height_ * 2); |
1477 MemRandomize(src_argb, benchmark_width_ * benchmark_height_ * 4); | 1477 MemRandomize(src_argb, benchmark_width_ * benchmark_height_ * 4); |
1478 MemRandomize(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); | 1478 MemRandomize(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); |
1479 MemRandomize(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); | 1479 MemRandomize(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); |
1480 ARGBToRGB565(src_argb, benchmark_width_ * 4, | 1480 ARGBToRGB565(src_argb, benchmark_width_ * 4, |
1481 dst_rgb565, benchmark_width_ * 2, | 1481 dst_rgb565, benchmark_width_ * 2, |
1482 benchmark_width_, benchmark_height_); | 1482 benchmark_width_, benchmark_height_); |
1483 ARGBToRGB565Dither(src_argb, benchmark_width_ * 4, | 1483 ARGBToRGB565Dither(src_argb, benchmark_width_ * 4, |
1484 dst_rgb565dither, benchmark_width_ * 2, | 1484 dst_rgb565dither, benchmark_width_ * 2, |
1485 kNoDither4x4, benchmark_width_, benchmark_height_); | 1485 kNoDither4x4, benchmark_width_, benchmark_height_); |
1486 for (int i = 0; i < benchmark_width_ * benchmark_height_ * 2; ++i) { | 1486 for (int i = 0; i < benchmark_width_ * benchmark_height_ * 2; ++i) { |
1487 EXPECT_EQ(dst_rgb565[i], dst_rgb565dither[i]); | 1487 EXPECT_EQ(dst_rgb565[i], dst_rgb565dither[i]); |
1488 } | 1488 } |
1489 | 1489 |
1490 free_aligned_buffer_64(src_argb); | 1490 free_aligned_buffer_page_end(src_argb); |
1491 free_aligned_buffer_64(dst_rgb565); | 1491 free_aligned_buffer_page_end(dst_rgb565); |
1492 free_aligned_buffer_64(dst_rgb565dither); | 1492 free_aligned_buffer_page_end(dst_rgb565dither); |
1493 } | 1493 } |
1494 | 1494 |
1495 // Ordered 4x4 dither for 888 to 565. Values from 0 to 7. | 1495 // Ordered 4x4 dither for 888 to 565. Values from 0 to 7. |
1496 static const uint8 kDither565_4x4[16] = { | 1496 static const uint8 kDither565_4x4[16] = { |
1497 0, 4, 1, 5, | 1497 0, 4, 1, 5, |
1498 6, 2, 7, 3, | 1498 6, 2, 7, 3, |
1499 1, 5, 0, 4, | 1499 1, 5, 0, 4, |
1500 7, 3, 6, 2, | 1500 7, 3, 6, 2, |
1501 }; | 1501 }; |
1502 | 1502 |
1503 TEST_F(LibYUVConvertTest, TestDither) { | 1503 TEST_F(LibYUVConvertTest, TestDither) { |
1504 align_buffer_64(src_argb, benchmark_width_ * benchmark_height_ * 4); | 1504 align_buffer_page_end(src_argb, benchmark_width_ * benchmark_height_ * 4); |
1505 align_buffer_64(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); | 1505 align_buffer_page_end(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); |
1506 align_buffer_64(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); | 1506 align_buffer_page_end(dst_rgb565dither, |
1507 align_buffer_64(dst_argb, benchmark_width_ * benchmark_height_ * 4); | 1507 benchmark_width_ * benchmark_height_ * 2); |
1508 align_buffer_64(dst_argbdither, benchmark_width_ * benchmark_height_ * 4); | 1508 align_buffer_page_end(dst_argb, benchmark_width_ * benchmark_height_ * 4); |
| 1509 align_buffer_page_end(dst_argbdither, |
| 1510 benchmark_width_ * benchmark_height_ * 4); |
1509 MemRandomize(src_argb, benchmark_width_ * benchmark_height_ * 4); | 1511 MemRandomize(src_argb, benchmark_width_ * benchmark_height_ * 4); |
1510 MemRandomize(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); | 1512 MemRandomize(dst_rgb565, benchmark_width_ * benchmark_height_ * 2); |
1511 MemRandomize(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); | 1513 MemRandomize(dst_rgb565dither, benchmark_width_ * benchmark_height_ * 2); |
1512 MemRandomize(dst_argb, benchmark_width_ * benchmark_height_ * 4); | 1514 MemRandomize(dst_argb, benchmark_width_ * benchmark_height_ * 4); |
1513 MemRandomize(dst_argbdither, benchmark_width_ * benchmark_height_ * 4); | 1515 MemRandomize(dst_argbdither, benchmark_width_ * benchmark_height_ * 4); |
1514 ARGBToRGB565(src_argb, benchmark_width_ * 4, | 1516 ARGBToRGB565(src_argb, benchmark_width_ * 4, |
1515 dst_rgb565, benchmark_width_ * 2, | 1517 dst_rgb565, benchmark_width_ * 2, |
1516 benchmark_width_, benchmark_height_); | 1518 benchmark_width_, benchmark_height_); |
1517 ARGBToRGB565Dither(src_argb, benchmark_width_ * 4, | 1519 ARGBToRGB565Dither(src_argb, benchmark_width_ * 4, |
1518 dst_rgb565dither, benchmark_width_ * 2, | 1520 dst_rgb565dither, benchmark_width_ * 2, |
1519 kDither565_4x4, benchmark_width_, benchmark_height_); | 1521 kDither565_4x4, benchmark_width_, benchmark_height_); |
1520 RGB565ToARGB(dst_rgb565, benchmark_width_ * 2, | 1522 RGB565ToARGB(dst_rgb565, benchmark_width_ * 2, |
1521 dst_argb, benchmark_width_ * 4, | 1523 dst_argb, benchmark_width_ * 4, |
1522 benchmark_width_, benchmark_height_); | 1524 benchmark_width_, benchmark_height_); |
1523 RGB565ToARGB(dst_rgb565dither, benchmark_width_ * 2, | 1525 RGB565ToARGB(dst_rgb565dither, benchmark_width_ * 2, |
1524 dst_argbdither, benchmark_width_ * 4, | 1526 dst_argbdither, benchmark_width_ * 4, |
1525 benchmark_width_, benchmark_height_); | 1527 benchmark_width_, benchmark_height_); |
1526 | 1528 |
1527 for (int i = 0; i < benchmark_width_ * benchmark_height_ * 4; ++i) { | 1529 for (int i = 0; i < benchmark_width_ * benchmark_height_ * 4; ++i) { |
1528 EXPECT_NEAR(dst_argb[i], dst_argbdither[i], 9); | 1530 EXPECT_NEAR(dst_argb[i], dst_argbdither[i], 9); |
1529 } | 1531 } |
1530 free_aligned_buffer_64(src_argb); | 1532 free_aligned_buffer_page_end(src_argb); |
1531 free_aligned_buffer_64(dst_rgb565); | 1533 free_aligned_buffer_page_end(dst_rgb565); |
1532 free_aligned_buffer_64(dst_rgb565dither); | 1534 free_aligned_buffer_page_end(dst_rgb565dither); |
1533 free_aligned_buffer_64(dst_argb); | 1535 free_aligned_buffer_page_end(dst_argb); |
1534 free_aligned_buffer_64(dst_argbdither); | 1536 free_aligned_buffer_page_end(dst_argbdither); |
1535 } | 1537 } |
1536 | 1538 |
1537 #define TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1539 #define TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1538 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ | 1540 YALIGN, W1280, DIFF, N, NEG, OFF, FMT_C, BPP_C) \ |
1539 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##Dither##N) { \ | 1541 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##Dither##N) { \ |
1540 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1542 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1541 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ | 1543 const int kHeight = ALIGNINT(benchmark_height_, YALIGN); \ |
1542 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ | 1544 const int kStrideB = ALIGNINT(kWidth * BPP_B, ALIGN); \ |
1543 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 1545 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
1544 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 1546 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1545 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 1547 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
1546 align_buffer_64(src_u, kSizeUV + OFF); \ | 1548 align_buffer_page_end(src_u, kSizeUV + OFF); \ |
1547 align_buffer_64(src_v, kSizeUV + OFF); \ | 1549 align_buffer_page_end(src_v, kSizeUV + OFF); \ |
1548 align_buffer_64(dst_argb_c, kStrideB * kHeight + OFF); \ | 1550 align_buffer_page_end(dst_argb_c, kStrideB * kHeight + OFF); \ |
1549 align_buffer_64(dst_argb_opt, kStrideB * kHeight + OFF); \ | 1551 align_buffer_page_end(dst_argb_opt, kStrideB * kHeight + OFF); \ |
1550 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1552 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1551 src_y[i + OFF] = (fastrand() & 0xff); \ | 1553 src_y[i + OFF] = (fastrand() & 0xff); \ |
1552 } \ | 1554 } \ |
1553 for (int i = 0; i < kSizeUV; ++i) { \ | 1555 for (int i = 0; i < kSizeUV; ++i) { \ |
1554 src_u[i + OFF] = (fastrand() & 0xff); \ | 1556 src_u[i + OFF] = (fastrand() & 0xff); \ |
1555 src_v[i + OFF] = (fastrand() & 0xff); \ | 1557 src_v[i + OFF] = (fastrand() & 0xff); \ |
1556 } \ | 1558 } \ |
1557 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ | 1559 memset(dst_argb_c + OFF, 1, kStrideB * kHeight); \ |
1558 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ | 1560 memset(dst_argb_opt + OFF, 101, kStrideB * kHeight); \ |
1559 MaskCpuFlags(disable_cpu_flags_); \ | 1561 MaskCpuFlags(disable_cpu_flags_); \ |
1560 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ | 1562 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ |
1561 src_u + OFF, kStrideUV, \ | 1563 src_u + OFF, kStrideUV, \ |
1562 src_v + OFF, kStrideUV, \ | 1564 src_v + OFF, kStrideUV, \ |
1563 dst_argb_c + OFF, kStrideB, \ | 1565 dst_argb_c + OFF, kStrideB, \ |
1564 NULL, kWidth, NEG kHeight); \ | 1566 NULL, kWidth, NEG kHeight); \ |
1565 MaskCpuFlags(benchmark_cpu_info_); \ | 1567 MaskCpuFlags(benchmark_cpu_info_); \ |
1566 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1568 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1567 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ | 1569 FMT_PLANAR##To##FMT_B##Dither(src_y + OFF, kWidth, \ |
1568 src_u + OFF, kStrideUV, \ | 1570 src_u + OFF, kStrideUV, \ |
1569 src_v + OFF, kStrideUV, \ | 1571 src_v + OFF, kStrideUV, \ |
1570 dst_argb_opt + OFF, kStrideB, \ | 1572 dst_argb_opt + OFF, kStrideB, \ |
1571 NULL, kWidth, NEG kHeight); \ | 1573 NULL, kWidth, NEG kHeight); \ |
1572 } \ | 1574 } \ |
1573 int max_diff = 0; \ | 1575 int max_diff = 0; \ |
1574 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ | 1576 /* Convert to ARGB so 565 is expanded to bytes that can be compared. */ \ |
1575 align_buffer_64(dst_argb32_c, kWidth * BPP_C * kHeight); \ | 1577 align_buffer_page_end(dst_argb32_c, kWidth * BPP_C * kHeight); \ |
1576 align_buffer_64(dst_argb32_opt, kWidth * BPP_C * kHeight); \ | 1578 align_buffer_page_end(dst_argb32_opt, kWidth * BPP_C * kHeight); \ |
1577 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ | 1579 memset(dst_argb32_c, 2, kWidth * BPP_C * kHeight); \ |
1578 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ | 1580 memset(dst_argb32_opt, 102, kWidth * BPP_C * kHeight); \ |
1579 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ | 1581 FMT_B##To##FMT_C(dst_argb_c + OFF, kStrideB, \ |
1580 dst_argb32_c, kWidth * BPP_C , \ | 1582 dst_argb32_c, kWidth * BPP_C , \ |
1581 kWidth, kHeight); \ | 1583 kWidth, kHeight); \ |
1582 FMT_B##To##FMT_C(dst_argb_opt + OFF, kStrideB, \ | 1584 FMT_B##To##FMT_C(dst_argb_opt + OFF, kStrideB, \ |
1583 dst_argb32_opt, kWidth * BPP_C , \ | 1585 dst_argb32_opt, kWidth * BPP_C , \ |
1584 kWidth, kHeight); \ | 1586 kWidth, kHeight); \ |
1585 for (int i = 0; i < kWidth * BPP_C * kHeight; ++i) { \ | 1587 for (int i = 0; i < kWidth * BPP_C * kHeight; ++i) { \ |
1586 int abs_diff = \ | 1588 int abs_diff = \ |
1587 abs(static_cast<int>(dst_argb32_c[i]) - \ | 1589 abs(static_cast<int>(dst_argb32_c[i]) - \ |
1588 static_cast<int>(dst_argb32_opt[i])); \ | 1590 static_cast<int>(dst_argb32_opt[i])); \ |
1589 if (abs_diff > max_diff) { \ | 1591 if (abs_diff > max_diff) { \ |
1590 max_diff = abs_diff; \ | 1592 max_diff = abs_diff; \ |
1591 } \ | 1593 } \ |
1592 } \ | 1594 } \ |
1593 EXPECT_LE(max_diff, DIFF); \ | 1595 EXPECT_LE(max_diff, DIFF); \ |
1594 free_aligned_buffer_64(src_y); \ | 1596 free_aligned_buffer_page_end(src_y); \ |
1595 free_aligned_buffer_64(src_u); \ | 1597 free_aligned_buffer_page_end(src_u); \ |
1596 free_aligned_buffer_64(src_v); \ | 1598 free_aligned_buffer_page_end(src_v); \ |
1597 free_aligned_buffer_64(dst_argb_c); \ | 1599 free_aligned_buffer_page_end(dst_argb_c); \ |
1598 free_aligned_buffer_64(dst_argb_opt); \ | 1600 free_aligned_buffer_page_end(dst_argb_opt); \ |
1599 free_aligned_buffer_64(dst_argb32_c); \ | 1601 free_aligned_buffer_page_end(dst_argb32_c); \ |
1600 free_aligned_buffer_64(dst_argb32_opt); \ | 1602 free_aligned_buffer_page_end(dst_argb32_opt); \ |
1601 } | 1603 } |
1602 | 1604 |
1603 #define TESTPLANARTOBD(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1605 #define TESTPLANARTOBD(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1604 YALIGN, DIFF, FMT_C, BPP_C) \ | 1606 YALIGN, DIFF, FMT_C, BPP_C) \ |
1605 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1607 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1606 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \ | 1608 YALIGN, benchmark_width_ - 4, DIFF, _Any, +, 0, FMT_C, BPP_C) \ |
1607 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1609 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1608 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \ | 1610 YALIGN, benchmark_width_, DIFF, _Unaligned, +, 1, FMT_C, BPP_C) \ |
1609 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1611 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1610 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \ | 1612 YALIGN, benchmark_width_, DIFF, _Invert, -, 0, FMT_C, BPP_C) \ |
1611 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ | 1613 TESTPLANARTOBID(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, BPP_B, ALIGN, \ |
1612 YALIGN, benchmark_width_, DIFF, _Opt, +, 0, FMT_C, BPP_C) | 1614 YALIGN, benchmark_width_, DIFF, _Opt, +, 0, FMT_C, BPP_C) |
1613 | 1615 |
1614 TESTPLANARTOBD(I420, 2, 2, RGB565, 2, 2, 1, 9, ARGB, 4) | 1616 TESTPLANARTOBD(I420, 2, 2, RGB565, 2, 2, 1, 9, ARGB, 4) |
1615 | 1617 |
1616 #define TESTPTOB(NAME, UYVYTOI420, UYVYTONV12) \ | 1618 #define TESTPTOB(NAME, UYVYTOI420, UYVYTONV12) \ |
1617 TEST_F(LibYUVConvertTest, NAME) { \ | 1619 TEST_F(LibYUVConvertTest, NAME) { \ |
1618 const int kWidth = benchmark_width_; \ | 1620 const int kWidth = benchmark_width_; \ |
1619 const int kHeight = benchmark_height_; \ | 1621 const int kHeight = benchmark_height_; \ |
1620 \ | 1622 \ |
1621 align_buffer_64(orig_uyvy, \ | 1623 align_buffer_page_end(orig_uyvy, \ |
1622 4 * SUBSAMPLE(kWidth, 2) * kHeight); \ | 1624 4 * SUBSAMPLE(kWidth, 2) * kHeight); \ |
1623 align_buffer_64(orig_y, kWidth * kHeight); \ | 1625 align_buffer_page_end(orig_y, kWidth * kHeight); \ |
1624 align_buffer_64(orig_u, \ | 1626 align_buffer_page_end(orig_u, \ |
1625 SUBSAMPLE(kWidth, 2) * \ | 1627 SUBSAMPLE(kWidth, 2) * \ |
1626 SUBSAMPLE(kHeight, 2)); \ | 1628 SUBSAMPLE(kHeight, 2)); \ |
1627 align_buffer_64(orig_v, \ | 1629 align_buffer_page_end(orig_v, \ |
1628 SUBSAMPLE(kWidth, 2) * \ | 1630 SUBSAMPLE(kWidth, 2) * \ |
1629 SUBSAMPLE(kHeight, 2)); \ | 1631 SUBSAMPLE(kHeight, 2)); \ |
1630 \ | 1632 \ |
1631 align_buffer_64(dst_y_orig, kWidth * kHeight); \ | 1633 align_buffer_page_end(dst_y_orig, kWidth * kHeight); \ |
1632 align_buffer_64(dst_uv_orig, 2 * \ | 1634 align_buffer_page_end(dst_uv_orig, 2 * \ |
1633 SUBSAMPLE(kWidth, 2) * \ | 1635 SUBSAMPLE(kWidth, 2) * \ |
1634 SUBSAMPLE(kHeight, 2)); \ | 1636 SUBSAMPLE(kHeight, 2)); \ |
1635 \ | 1637 \ |
1636 align_buffer_64(dst_y, kWidth * kHeight); \ | 1638 align_buffer_page_end(dst_y, kWidth * kHeight); \ |
1637 align_buffer_64(dst_uv, 2 * \ | 1639 align_buffer_page_end(dst_uv, 2 * \ |
1638 SUBSAMPLE(kWidth, 2) * \ | 1640 SUBSAMPLE(kWidth, 2) * \ |
1639 SUBSAMPLE(kHeight, 2)); \ | 1641 SUBSAMPLE(kHeight, 2)); \ |
1640 \ | 1642 \ |
1641 MemRandomize(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \ | 1643 MemRandomize(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2) * kHeight); \ |
1642 \ | 1644 \ |
1643 /* Convert UYVY to NV12 in 2 steps for reference */ \ | 1645 /* Convert UYVY to NV12 in 2 steps for reference */ \ |
1644 libyuv::UYVYTOI420(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), \ | 1646 libyuv::UYVYTOI420(orig_uyvy, 4 * SUBSAMPLE(kWidth, 2), \ |
1645 orig_y, kWidth, \ | 1647 orig_y, kWidth, \ |
1646 orig_u, SUBSAMPLE(kWidth, 2), \ | 1648 orig_u, SUBSAMPLE(kWidth, 2), \ |
1647 orig_v, SUBSAMPLE(kWidth, 2), \ | 1649 orig_v, SUBSAMPLE(kWidth, 2), \ |
(...skipping 16 matching lines...) Expand all Loading... |
1664 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1666 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1665 EXPECT_EQ(orig_y[i], dst_y[i]); \ | 1667 EXPECT_EQ(orig_y[i], dst_y[i]); \ |
1666 } \ | 1668 } \ |
1667 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1669 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1668 EXPECT_EQ(dst_y_orig[i], dst_y[i]); \ | 1670 EXPECT_EQ(dst_y_orig[i], dst_y[i]); \ |
1669 } \ | 1671 } \ |
1670 for (int i = 0; i < 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2); ++i) { \ | 1672 for (int i = 0; i < 2 * SUBSAMPLE(kWidth, 2) * SUBSAMPLE(kHeight, 2); ++i) { \ |
1671 EXPECT_EQ(dst_uv_orig[i], dst_uv[i]); \ | 1673 EXPECT_EQ(dst_uv_orig[i], dst_uv[i]); \ |
1672 } \ | 1674 } \ |
1673 \ | 1675 \ |
1674 free_aligned_buffer_64(orig_uyvy); \ | 1676 free_aligned_buffer_page_end(orig_uyvy); \ |
1675 free_aligned_buffer_64(orig_y); \ | 1677 free_aligned_buffer_page_end(orig_y); \ |
1676 free_aligned_buffer_64(orig_u); \ | 1678 free_aligned_buffer_page_end(orig_u); \ |
1677 free_aligned_buffer_64(orig_v); \ | 1679 free_aligned_buffer_page_end(orig_v); \ |
1678 free_aligned_buffer_64(dst_y_orig); \ | 1680 free_aligned_buffer_page_end(dst_y_orig); \ |
1679 free_aligned_buffer_64(dst_uv_orig); \ | 1681 free_aligned_buffer_page_end(dst_uv_orig); \ |
1680 free_aligned_buffer_64(dst_y); \ | 1682 free_aligned_buffer_page_end(dst_y); \ |
1681 free_aligned_buffer_64(dst_uv); \ | 1683 free_aligned_buffer_page_end(dst_uv); \ |
1682 } | 1684 } |
1683 | 1685 |
1684 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) | 1686 TESTPTOB(TestYUY2ToNV12, YUY2ToI420, YUY2ToNV12) |
1685 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) | 1687 TESTPTOB(TestUYVYToNV12, UYVYToI420, UYVYToNV12) |
1686 | 1688 |
1687 #define TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1689 #define TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1688 W1280, N, NEG, OFF, FMT_C, BPP_C) \ | 1690 W1280, N, NEG, OFF, FMT_C, BPP_C) \ |
1689 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ | 1691 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ |
1690 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1692 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1691 const int kHeight = benchmark_height_; \ | 1693 const int kHeight = benchmark_height_; \ |
1692 const int kStrideB = SUBSAMPLE(kWidth, SUB_B) * BPP_B; \ | 1694 const int kStrideB = SUBSAMPLE(kWidth, SUB_B) * BPP_B; \ |
1693 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ | 1695 const int kStrideUV = SUBSAMPLE(kWidth, SUBSAMP_X); \ |
1694 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 1696 const int kSizeUV = kStrideUV * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1695 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 1697 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
1696 align_buffer_64(src_u, kSizeUV + OFF); \ | 1698 align_buffer_page_end(src_u, kSizeUV + OFF); \ |
1697 align_buffer_64(src_v, kSizeUV + OFF); \ | 1699 align_buffer_page_end(src_v, kSizeUV + OFF); \ |
1698 align_buffer_64(dst_argb_b, kStrideB * kHeight + OFF); \ | 1700 align_buffer_page_end(dst_argb_b, kStrideB * kHeight + OFF); \ |
1699 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1701 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1700 src_y[i + OFF] = (fastrand() & 0xff); \ | 1702 src_y[i + OFF] = (fastrand() & 0xff); \ |
1701 } \ | 1703 } \ |
1702 for (int i = 0; i < kSizeUV; ++i) { \ | 1704 for (int i = 0; i < kSizeUV; ++i) { \ |
1703 src_u[i + OFF] = (fastrand() & 0xff); \ | 1705 src_u[i + OFF] = (fastrand() & 0xff); \ |
1704 src_v[i + OFF] = (fastrand() & 0xff); \ | 1706 src_v[i + OFF] = (fastrand() & 0xff); \ |
1705 } \ | 1707 } \ |
1706 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ | 1708 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ |
1707 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1709 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1708 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 1710 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
1709 src_u + OFF, kStrideUV, \ | 1711 src_u + OFF, kStrideUV, \ |
1710 src_v + OFF, kStrideUV, \ | 1712 src_v + OFF, kStrideUV, \ |
1711 dst_argb_b + OFF, kStrideB, \ | 1713 dst_argb_b + OFF, kStrideB, \ |
1712 kWidth, NEG kHeight); \ | 1714 kWidth, NEG kHeight); \ |
1713 } \ | 1715 } \ |
1714 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ | 1716 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ |
1715 const int kStrideC = kWidth * BPP_C; \ | 1717 const int kStrideC = kWidth * BPP_C; \ |
1716 align_buffer_64(dst_argb_c, kStrideC * kHeight + OFF); \ | 1718 align_buffer_page_end(dst_argb_c, kStrideC * kHeight + OFF); \ |
1717 align_buffer_64(dst_argb_bc, kStrideC * kHeight + OFF); \ | 1719 align_buffer_page_end(dst_argb_bc, kStrideC * kHeight + OFF); \ |
1718 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ | 1720 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ |
1719 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ | 1721 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ |
1720 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ | 1722 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ |
1721 src_u + OFF, kStrideUV, \ | 1723 src_u + OFF, kStrideUV, \ |
1722 src_v + OFF, kStrideUV, \ | 1724 src_v + OFF, kStrideUV, \ |
1723 dst_argb_c + OFF, kStrideC, \ | 1725 dst_argb_c + OFF, kStrideC, \ |
1724 kWidth, NEG kHeight); \ | 1726 kWidth, NEG kHeight); \ |
1725 /* Convert B to C */ \ | 1727 /* Convert B to C */ \ |
1726 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ | 1728 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ |
1727 dst_argb_bc + OFF, kStrideC, \ | 1729 dst_argb_bc + OFF, kStrideC, \ |
1728 kWidth, kHeight); \ | 1730 kWidth, kHeight); \ |
1729 for (int i = 0; i < kStrideC * kHeight; ++i) { \ | 1731 for (int i = 0; i < kStrideC * kHeight; ++i) { \ |
1730 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ | 1732 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ |
1731 } \ | 1733 } \ |
1732 free_aligned_buffer_64(src_y); \ | 1734 free_aligned_buffer_page_end(src_y); \ |
1733 free_aligned_buffer_64(src_u); \ | 1735 free_aligned_buffer_page_end(src_u); \ |
1734 free_aligned_buffer_64(src_v); \ | 1736 free_aligned_buffer_page_end(src_v); \ |
1735 free_aligned_buffer_64(dst_argb_b); \ | 1737 free_aligned_buffer_page_end(dst_argb_b); \ |
1736 free_aligned_buffer_64(dst_argb_c); \ | 1738 free_aligned_buffer_page_end(dst_argb_c); \ |
1737 free_aligned_buffer_64(dst_argb_bc); \ | 1739 free_aligned_buffer_page_end(dst_argb_bc); \ |
1738 } | 1740 } |
1739 | 1741 |
1740 #define TESTPLANARTOE(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1742 #define TESTPLANARTOE(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1741 FMT_C, BPP_C) \ | 1743 FMT_C, BPP_C) \ |
1742 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1744 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1743 benchmark_width_ - 4, _Any, +, 0, FMT_C, BPP_C) \ | 1745 benchmark_width_ - 4, _Any, +, 0, FMT_C, BPP_C) \ |
1744 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1746 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1745 benchmark_width_, _Unaligned, +, 1, FMT_C, BPP_C) \ | 1747 benchmark_width_, _Unaligned, +, 1, FMT_C, BPP_C) \ |
1746 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1748 TESTPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1747 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C) \ | 1749 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C) \ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 TESTPLANARTOE(I422, 2, 1, UYVY, 2, 4, ARGB, 4) | 1784 TESTPLANARTOE(I422, 2, 1, UYVY, 2, 4, ARGB, 4) |
1783 | 1785 |
1784 #define TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1786 #define TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1785 W1280, N, NEG, OFF, FMT_C, BPP_C, ATTEN) \ | 1787 W1280, N, NEG, OFF, FMT_C, BPP_C, ATTEN) \ |
1786 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ | 1788 TEST_F(LibYUVConvertTest, FMT_PLANAR##To##FMT_B##_##FMT_C##N) { \ |
1787 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 1789 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
1788 const int kHeight = benchmark_height_; \ | 1790 const int kHeight = benchmark_height_; \ |
1789 const int kStrideB = SUBSAMPLE(kWidth, SUB_B) * BPP_B; \ | 1791 const int kStrideB = SUBSAMPLE(kWidth, SUB_B) * BPP_B; \ |
1790 const int kSizeUV = \ | 1792 const int kSizeUV = \ |
1791 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ | 1793 SUBSAMPLE(kWidth, SUBSAMP_X) * SUBSAMPLE(kHeight, SUBSAMP_Y); \ |
1792 align_buffer_64(src_y, kWidth * kHeight + OFF); \ | 1794 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
1793 align_buffer_64(src_u, kSizeUV + OFF); \ | 1795 align_buffer_page_end(src_u, kSizeUV + OFF); \ |
1794 align_buffer_64(src_v, kSizeUV + OFF); \ | 1796 align_buffer_page_end(src_v, kSizeUV + OFF); \ |
1795 align_buffer_64(src_a, kWidth * kHeight + OFF); \ | 1797 align_buffer_page_end(src_a, kWidth * kHeight + OFF); \ |
1796 align_buffer_64(dst_argb_b, kStrideB * kHeight + OFF); \ | 1798 align_buffer_page_end(dst_argb_b, kStrideB * kHeight + OFF); \ |
1797 for (int i = 0; i < kWidth * kHeight; ++i) { \ | 1799 for (int i = 0; i < kWidth * kHeight; ++i) { \ |
1798 src_y[i + OFF] = (fastrand() & 0xff); \ | 1800 src_y[i + OFF] = (fastrand() & 0xff); \ |
1799 src_a[i + OFF] = (fastrand() & 0xff); \ | 1801 src_a[i + OFF] = (fastrand() & 0xff); \ |
1800 } \ | 1802 } \ |
1801 for (int i = 0; i < kSizeUV; ++i) { \ | 1803 for (int i = 0; i < kSizeUV; ++i) { \ |
1802 src_u[i + OFF] = (fastrand() & 0xff); \ | 1804 src_u[i + OFF] = (fastrand() & 0xff); \ |
1803 src_v[i + OFF] = (fastrand() & 0xff); \ | 1805 src_v[i + OFF] = (fastrand() & 0xff); \ |
1804 } \ | 1806 } \ |
1805 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ | 1807 memset(dst_argb_b + OFF, 1, kStrideB * kHeight); \ |
1806 for (int i = 0; i < benchmark_iterations_; ++i) { \ | 1808 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
1807 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ | 1809 FMT_PLANAR##To##FMT_B(src_y + OFF, kWidth, \ |
1808 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1810 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1809 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1811 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1810 src_a + OFF, kWidth, \ | 1812 src_a + OFF, kWidth, \ |
1811 dst_argb_b + OFF, kStrideB, \ | 1813 dst_argb_b + OFF, kStrideB, \ |
1812 kWidth, NEG kHeight, ATTEN); \ | 1814 kWidth, NEG kHeight, ATTEN); \ |
1813 } \ | 1815 } \ |
1814 int max_diff = 0; \ | 1816 int max_diff = 0; \ |
1815 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ | 1817 /* Convert to a 3rd format in 1 step and 2 steps and compare */ \ |
1816 const int kStrideC = kWidth * BPP_C; \ | 1818 const int kStrideC = kWidth * BPP_C; \ |
1817 align_buffer_64(dst_argb_c, kStrideC * kHeight + OFF); \ | 1819 align_buffer_page_end(dst_argb_c, kStrideC * kHeight + OFF); \ |
1818 align_buffer_64(dst_argb_bc, kStrideC * kHeight + OFF); \ | 1820 align_buffer_page_end(dst_argb_bc, kStrideC * kHeight + OFF); \ |
1819 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ | 1821 memset(dst_argb_c + OFF, 2, kStrideC * kHeight); \ |
1820 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ | 1822 memset(dst_argb_bc + OFF, 3, kStrideC * kHeight); \ |
1821 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ | 1823 FMT_PLANAR##To##FMT_C(src_y + OFF, kWidth, \ |
1822 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1824 src_u + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1823 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ | 1825 src_v + OFF, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
1824 src_a + OFF, kWidth, \ | 1826 src_a + OFF, kWidth, \ |
1825 dst_argb_c + OFF, kStrideC, \ | 1827 dst_argb_c + OFF, kStrideC, \ |
1826 kWidth, NEG kHeight, ATTEN); \ | 1828 kWidth, NEG kHeight, ATTEN); \ |
1827 /* Convert B to C */ \ | 1829 /* Convert B to C */ \ |
1828 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ | 1830 FMT_B##To##FMT_C(dst_argb_b + OFF, kStrideB, \ |
1829 dst_argb_bc + OFF, kStrideC, \ | 1831 dst_argb_bc + OFF, kStrideC, \ |
1830 kWidth, kHeight); \ | 1832 kWidth, kHeight); \ |
1831 for (int i = 0; i < kStrideC * kHeight; ++i) { \ | 1833 for (int i = 0; i < kStrideC * kHeight; ++i) { \ |
1832 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ | 1834 EXPECT_EQ(dst_argb_c[i + OFF], dst_argb_bc[i + OFF]); \ |
1833 } \ | 1835 } \ |
1834 free_aligned_buffer_64(src_y); \ | 1836 free_aligned_buffer_page_end(src_y); \ |
1835 free_aligned_buffer_64(src_u); \ | 1837 free_aligned_buffer_page_end(src_u); \ |
1836 free_aligned_buffer_64(src_v); \ | 1838 free_aligned_buffer_page_end(src_v); \ |
1837 free_aligned_buffer_64(src_a); \ | 1839 free_aligned_buffer_page_end(src_a); \ |
1838 free_aligned_buffer_64(dst_argb_b); \ | 1840 free_aligned_buffer_page_end(dst_argb_b); \ |
1839 free_aligned_buffer_64(dst_argb_c); \ | 1841 free_aligned_buffer_page_end(dst_argb_c); \ |
1840 free_aligned_buffer_64(dst_argb_bc); \ | 1842 free_aligned_buffer_page_end(dst_argb_bc); \ |
1841 } | 1843 } |
1842 | 1844 |
1843 #define TESTQPLANARTOE(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1845 #define TESTQPLANARTOE(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1844 FMT_C, BPP_C) \ | 1846 FMT_C, BPP_C) \ |
1845 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1847 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1846 benchmark_width_ - 4, _Any, +, 0, FMT_C, BPP_C, 0) \ | 1848 benchmark_width_ - 4, _Any, +, 0, FMT_C, BPP_C, 0) \ |
1847 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1849 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1848 benchmark_width_, _Unaligned, +, 1, FMT_C, BPP_C, 0) \ | 1850 benchmark_width_, _Unaligned, +, 1, FMT_C, BPP_C, 0) \ |
1849 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1851 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1850 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ | 1852 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ |
1851 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1853 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1852 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ | 1854 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ |
1853 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1855 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1854 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) | 1856 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) |
1855 | 1857 |
1856 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4) | 1858 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4) |
1857 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4) | 1859 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4) |
1858 | 1860 |
1859 } // namespace libyuv | 1861 } // namespace libyuv |
OLD | NEW |