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 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 TESTPLANARTOP(I422, 2, 1, I420, 2, 2) | 167 TESTPLANARTOP(I422, 2, 1, I420, 2, 2) |
168 TESTPLANARTOP(I444, 1, 1, I420, 2, 2) | 168 TESTPLANARTOP(I444, 1, 1, I420, 2, 2) |
169 TESTPLANARTOP(I411, 4, 1, I420, 2, 2) | 169 TESTPLANARTOP(I411, 4, 1, I420, 2, 2) |
170 TESTPLANARTOP(I420, 2, 2, I422, 2, 1) | 170 TESTPLANARTOP(I420, 2, 2, I422, 2, 1) |
171 TESTPLANARTOP(I420, 2, 2, I444, 1, 1) | 171 TESTPLANARTOP(I420, 2, 2, I444, 1, 1) |
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 |
| 178 |
| 179 // Test Android 420 to I420 |
| 180 |
| 181 #define TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 182 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
| 183 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ |
| 184 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
| 185 const int kHeight = benchmark_height_; \ |
| 186 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
| 187 align_buffer_page_end(src_u, \ |
| 188 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
| 189 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
| 190 align_buffer_page_end(src_v, \ |
| 191 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
| 192 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
| 193 align_buffer_page_end(dst_y_c, kWidth * kHeight); \ |
| 194 align_buffer_page_end(dst_u_c, \ |
| 195 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 196 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 197 align_buffer_page_end(dst_v_c, \ |
| 198 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 199 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 200 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ |
| 201 align_buffer_page_end(dst_u_opt, \ |
| 202 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 203 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 204 align_buffer_page_end(dst_v_opt, \ |
| 205 SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 206 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 207 for (int i = 0; i < kHeight; ++i) \ |
| 208 for (int j = 0; j < kWidth; ++j) \ |
| 209 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ |
| 210 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ |
| 211 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ |
| 212 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
| 213 (fastrand() & 0xff); \ |
| 214 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ |
| 215 (fastrand() & 0xff); \ |
| 216 } \ |
| 217 } \ |
| 218 memset(dst_y_c, 1, kWidth * kHeight); \ |
| 219 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 220 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 221 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 222 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 223 memset(dst_y_opt, 101, kWidth * kHeight); \ |
| 224 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 225 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 226 memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \ |
| 227 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ |
| 228 MaskCpuFlags(disable_cpu_flags_); \ |
| 229 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ |
| 230 src_u + OFF, \ |
| 231 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ |
| 232 src_v + OFF, \ |
| 233 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ |
| 234 1, \ |
| 235 dst_y_c, kWidth, \ |
| 236 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 237 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 238 kWidth, NEG kHeight); \ |
| 239 MaskCpuFlags(benchmark_cpu_info_); \ |
| 240 for (int i = 0; i < benchmark_iterations_; ++i) { \ |
| 241 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ |
| 242 src_u + OFF, \ |
| 243 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ |
| 244 src_v + OFF, \ |
| 245 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ |
| 246 1, \ |
| 247 dst_y_opt, kWidth, \ |
| 248 dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 249 dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ |
| 250 kWidth, NEG kHeight); \ |
| 251 } \ |
| 252 int max_diff = 0; \ |
| 253 for (int i = 0; i < kHeight; ++i) { \ |
| 254 for (int j = 0; j < kWidth; ++j) { \ |
| 255 int abs_diff = \ |
| 256 abs(static_cast<int>(dst_y_c[i * kWidth + j]) - \ |
| 257 static_cast<int>(dst_y_opt[i * kWidth + j])); \ |
| 258 if (abs_diff > max_diff) { \ |
| 259 max_diff = abs_diff; \ |
| 260 } \ |
| 261 } \ |
| 262 } \ |
| 263 EXPECT_EQ(0, max_diff); \ |
| 264 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
| 265 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \ |
| 266 int abs_diff = \ |
| 267 abs(static_cast<int>(dst_u_c[i * \ |
| 268 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ |
| 269 static_cast<int>(dst_u_opt[i * \ |
| 270 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ |
| 271 if (abs_diff > max_diff) { \ |
| 272 max_diff = abs_diff; \ |
| 273 } \ |
| 274 } \ |
| 275 } \ |
| 276 EXPECT_LE(max_diff, 3); \ |
| 277 for (int i = 0; i < SUBSAMPLE(kHeight, SUBSAMP_Y); ++i) { \ |
| 278 for (int j = 0; j < SUBSAMPLE(kWidth, SUBSAMP_X); ++j) { \ |
| 279 int abs_diff = \ |
| 280 abs(static_cast<int>(dst_v_c[i * \ |
| 281 SUBSAMPLE(kWidth, SUBSAMP_X) + j]) - \ |
| 282 static_cast<int>(dst_v_opt[i * \ |
| 283 SUBSAMPLE(kWidth, SUBSAMP_X) + j])); \ |
| 284 if (abs_diff > max_diff) { \ |
| 285 max_diff = abs_diff; \ |
| 286 } \ |
| 287 } \ |
| 288 } \ |
| 289 EXPECT_LE(max_diff, 3); \ |
| 290 free_aligned_buffer_page_end(dst_y_c); \ |
| 291 free_aligned_buffer_page_end(dst_u_c); \ |
| 292 free_aligned_buffer_page_end(dst_v_c); \ |
| 293 free_aligned_buffer_page_end(dst_y_opt); \ |
| 294 free_aligned_buffer_page_end(dst_u_opt); \ |
| 295 free_aligned_buffer_page_end(dst_v_opt); \ |
| 296 free_aligned_buffer_page_end(src_y); \ |
| 297 free_aligned_buffer_page_end(src_u); \ |
| 298 free_aligned_buffer_page_end(src_v); \ |
| 299 } |
| 300 |
| 301 #define TESTAPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 302 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ |
| 303 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 304 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
| 305 benchmark_width_ - 4, _Any, +, 0) \ |
| 306 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 307 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
| 308 benchmark_width_, _Unaligned, +, 1) \ |
| 309 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 310 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
| 311 benchmark_width_, _Invert, -, 0) \ |
| 312 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
| 313 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ |
| 314 benchmark_width_, _Opt, +, 0) |
| 315 |
| 316 TESTAPLANARTOP(Android420, 2, 2, I420, 2, 2) |
| 317 |
| 318 |
177 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ | 319 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ |
178 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ | 320 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ |
179 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ | 321 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ |
180 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ | 322 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ |
181 const int kHeight = benchmark_height_; \ | 323 const int kHeight = benchmark_height_; \ |
182 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ | 324 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ |
183 align_buffer_page_end(src_u, \ | 325 align_buffer_page_end(src_u, \ |
184 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ | 326 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ |
185 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ | 327 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ |
186 align_buffer_page_end(src_v, \ | 328 align_buffer_page_end(src_v, \ |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ | 1994 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ |
1853 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1995 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1854 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ | 1996 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ |
1855 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ | 1997 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ |
1856 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) | 1998 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) |
1857 | 1999 |
1858 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4) | 2000 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4) |
1859 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4) | 2001 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4) |
1860 | 2002 |
1861 } // namespace libyuv | 2003 } // namespace libyuv |
OLD | NEW |