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

Side by Side Diff: unit_test/convert_test.cc

Issue 2146733002: Test nv21 layout of Android420ToI420 function. (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: yuv3 test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/convert.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 177 // Test Android 420 to I420
180 178 #define TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, \
181 #define TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 179 SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
182 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ 180 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF, \
183 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ 181 PN, OFF_U, OFF_V) \
182 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##_##PN##N) {\
184 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 183 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
185 const int kHeight = benchmark_height_; \ 184 const int kHeight = benchmark_height_; \
185 const int kSizeUV = SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \
186 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); \
186 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ 187 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \
187 align_buffer_page_end(src_u, \ 188 align_buffer_page_end(src_uv, kSizeUV * ((PIXEL_STRIDE == 3) ? 3 : 2) + OFF);\
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); \ 189 align_buffer_page_end(dst_y_c, kWidth * kHeight); \
194 align_buffer_page_end(dst_u_c, \ 190 align_buffer_page_end(dst_u_c, \
195 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 191 SUBSAMPLE(kWidth, SUBSAMP_X) * \
196 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 192 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
197 align_buffer_page_end(dst_v_c, \ 193 align_buffer_page_end(dst_v_c, \
198 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 194 SUBSAMPLE(kWidth, SUBSAMP_X) * \
199 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 195 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
200 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \ 196 align_buffer_page_end(dst_y_opt, kWidth * kHeight); \
201 align_buffer_page_end(dst_u_opt, \ 197 align_buffer_page_end(dst_u_opt, \
202 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 198 SUBSAMPLE(kWidth, SUBSAMP_X) * \
203 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 199 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
204 align_buffer_page_end(dst_v_opt, \ 200 align_buffer_page_end(dst_v_opt, \
205 SUBSAMPLE(kWidth, SUBSAMP_X) * \ 201 SUBSAMPLE(kWidth, SUBSAMP_X) * \
206 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 202 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
203 uint8* src_u = src_uv + OFF_U; \
204 uint8* src_v = src_uv + (PIXEL_STRIDE == 1 ? kSizeUV : OFF_V); \
205 int src_stride_uv = SUBSAMPLE(kWidth, SUBSAMP_X) * PIXEL_STRIDE; \
207 for (int i = 0; i < kHeight; ++i) \ 206 for (int i = 0; i < kHeight; ++i) \
208 for (int j = 0; j < kWidth; ++j) \ 207 for (int j = 0; j < kWidth; ++j) \
209 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \ 208 src_y[i * kWidth + j + OFF] = (fastrand() & 0xff); \
210 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \ 209 for (int i = 0; i < SUBSAMPLE(kHeight, SRC_SUBSAMP_Y); ++i) { \
211 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \ 210 for (int j = 0; j < SUBSAMPLE(kWidth, SRC_SUBSAMP_X); ++j) { \
212 src_u[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 211 src_u[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
213 (fastrand() & 0xff); \ 212 (fastrand() & 0xff); \
214 src_v[(i * SUBSAMPLE(kWidth, SRC_SUBSAMP_X)) + j + OFF] = \ 213 src_v[(i * src_stride_uv) + j * PIXEL_STRIDE + OFF] = \
215 (fastrand() & 0xff); \ 214 (fastrand() & 0xff); \
216 } \ 215 } \
217 } \ 216 } \
218 memset(dst_y_c, 1, kWidth * kHeight); \ 217 memset(dst_y_c, 1, kWidth * kHeight); \
219 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 218 memset(dst_u_c, 2, SUBSAMPLE(kWidth, SUBSAMP_X) * \
220 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 219 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
221 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 220 memset(dst_v_c, 3, SUBSAMPLE(kWidth, SUBSAMP_X) * \
222 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 221 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
223 memset(dst_y_opt, 101, kWidth * kHeight); \ 222 memset(dst_y_opt, 101, kWidth * kHeight); \
224 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 223 memset(dst_u_opt, 102, SUBSAMPLE(kWidth, SUBSAMP_X) * \
225 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 224 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
226 memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \ 225 memset(dst_v_opt, 103, SUBSAMPLE(kWidth, SUBSAMP_X) * \
227 SUBSAMPLE(kHeight, SUBSAMP_Y)); \ 226 SUBSAMPLE(kHeight, SUBSAMP_Y)); \
228 MaskCpuFlags(disable_cpu_flags_); \ 227 MaskCpuFlags(disable_cpu_flags_); \
229 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ 228 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
230 src_u + OFF, \ 229 src_u + OFF, \
231 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ 230 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
232 src_v + OFF, \ 231 src_v + OFF, \
233 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ 232 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
234 1, \ 233 PIXEL_STRIDE, \
235 dst_y_c, kWidth, \ 234 dst_y_c, kWidth, \
236 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ 235 dst_u_c, SUBSAMPLE(kWidth, SUBSAMP_X), \
237 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \ 236 dst_v_c, SUBSAMPLE(kWidth, SUBSAMP_X), \
238 kWidth, NEG kHeight); \ 237 kWidth, NEG kHeight); \
239 MaskCpuFlags(benchmark_cpu_info_); \ 238 MaskCpuFlags(benchmark_cpu_info_); \
240 for (int i = 0; i < benchmark_iterations_; ++i) { \ 239 for (int i = 0; i < benchmark_iterations_; ++i) { \
241 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \ 240 SRC_FMT_PLANAR##To##FMT_PLANAR(src_y + OFF, kWidth, \
242 src_u + OFF, \ 241 src_u + OFF, \
243 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ 242 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
244 src_v + OFF, \ 243 src_v + OFF, \
245 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \ 244 SUBSAMPLE(kWidth, SRC_SUBSAMP_X), \
246 1, \ 245 PIXEL_STRIDE, \
247 dst_y_opt, kWidth, \ 246 dst_y_opt, kWidth, \
248 dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ 247 dst_u_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \
249 dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \ 248 dst_v_opt, SUBSAMPLE(kWidth, SUBSAMP_X), \
250 kWidth, NEG kHeight); \ 249 kWidth, NEG kHeight); \
251 } \ 250 } \
252 int max_diff = 0; \ 251 int max_diff = 0; \
253 for (int i = 0; i < kHeight; ++i) { \ 252 for (int i = 0; i < kHeight; ++i) { \
254 for (int j = 0; j < kWidth; ++j) { \ 253 for (int j = 0; j < kWidth; ++j) { \
255 int abs_diff = \ 254 int abs_diff = \
256 abs(static_cast<int>(dst_y_c[i * kWidth + j]) - \ 255 abs(static_cast<int>(dst_y_c[i * kWidth + j]) - \
(...skipping 30 matching lines...) Expand all
287 } \ 286 } \
288 } \ 287 } \
289 EXPECT_LE(max_diff, 3); \ 288 EXPECT_LE(max_diff, 3); \
290 free_aligned_buffer_page_end(dst_y_c); \ 289 free_aligned_buffer_page_end(dst_y_c); \
291 free_aligned_buffer_page_end(dst_u_c); \ 290 free_aligned_buffer_page_end(dst_u_c); \
292 free_aligned_buffer_page_end(dst_v_c); \ 291 free_aligned_buffer_page_end(dst_v_c); \
293 free_aligned_buffer_page_end(dst_y_opt); \ 292 free_aligned_buffer_page_end(dst_y_opt); \
294 free_aligned_buffer_page_end(dst_u_opt); \ 293 free_aligned_buffer_page_end(dst_u_opt); \
295 free_aligned_buffer_page_end(dst_v_opt); \ 294 free_aligned_buffer_page_end(dst_v_opt); \
296 free_aligned_buffer_page_end(src_y); \ 295 free_aligned_buffer_page_end(src_y); \
297 free_aligned_buffer_page_end(src_u); \ 296 free_aligned_buffer_page_end(src_uv); \
298 free_aligned_buffer_page_end(src_v); \
299 } 297 }
300 298
301 #define TESTAPLANARTOP(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 299 #define TESTAPLANARTOP(SRC_FMT_PLANAR, PN, PIXEL_STRIDE, OFF_U, OFF_V, \
300 SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
302 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \ 301 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y) \
303 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 302 TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
304 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ 303 SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
305 benchmark_width_ - 4, _Any, +, 0) \ 304 benchmark_width_ - 4, _Any, +, 0, PN, OFF_U, OFF_V) \
306 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 305 TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
307 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ 306 SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
308 benchmark_width_, _Unaligned, +, 1) \ 307 benchmark_width_, _Unaligned, +, 1, PN, OFF_U, OFF_V) \
309 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 308 TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
310 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ 309 SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
311 benchmark_width_, _Invert, -, 0) \ 310 benchmark_width_, _Invert, -, 0, PN, OFF_U, OFF_V) \
312 TESTAPLANARTOPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 311 TESTAPLANARTOPI(SRC_FMT_PLANAR, PIXEL_STRIDE, SRC_SUBSAMP_X, \
313 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \ 312 SRC_SUBSAMP_Y, FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, \
314 benchmark_width_, _Opt, +, 0) 313 benchmark_width_, _Opt, +, 0, PN, OFF_U, OFF_V)
315 314
316 TESTAPLANARTOP(Android420, 2, 2, I420, 2, 2) 315 TESTAPLANARTOP(Android420, I420, 1, 0, 0, 2, 2, I420, 2, 2)
317 316 TESTAPLANARTOP(Android420, NV12, 2, 0, 1, 2, 2, I420, 2, 2)
317 TESTAPLANARTOP(Android420, NV21, 2, 1, 0, 2, 2, I420, 2, 2)
318 TESTAPLANARTOP(Android420, YUV3, 3, 0, 1, 2, 2, I420, 2, 2)
318 319
319 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \ 320 #define TESTPLANARTOBPI(SRC_FMT_PLANAR, SRC_SUBSAMP_X, SRC_SUBSAMP_Y, \
320 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \ 321 FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, W1280, N, NEG, OFF) \
321 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \ 322 TEST_F(LibYUVConvertTest, SRC_FMT_PLANAR##To##FMT_PLANAR##N) { \
322 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \ 323 const int kWidth = ((W1280) > 0) ? (W1280) : 1; \
323 const int kHeight = benchmark_height_; \ 324 const int kHeight = benchmark_height_; \
324 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \ 325 align_buffer_page_end(src_y, kWidth * kHeight + OFF); \
325 align_buffer_page_end(src_u, \ 326 align_buffer_page_end(src_u, \
326 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \ 327 SUBSAMPLE(kWidth, SRC_SUBSAMP_X) * \
327 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \ 328 SUBSAMPLE(kHeight, SRC_SUBSAMP_Y) + OFF); \
(...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \ 1995 benchmark_width_, _Invert, -, 0, FMT_C, BPP_C, 0) \
1995 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ 1996 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \
1996 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \ 1997 benchmark_width_, _Opt, +, 0, FMT_C, BPP_C, 0) \
1997 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \ 1998 TESTQPLANARTOEI(FMT_PLANAR, SUBSAMP_X, SUBSAMP_Y, FMT_B, SUB_B, BPP_B, \
1998 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1) 1999 benchmark_width_, _Premult, +, 0, FMT_C, BPP_C, 1)
1999 2000
2000 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4) 2001 TESTQPLANARTOE(I420Alpha, 2, 2, ARGB, 1, 4, ABGR, 4)
2001 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4) 2002 TESTQPLANARTOE(I420Alpha, 2, 2, ABGR, 1, 4, ARGB, 4)
2002 2003
2003 } // namespace libyuv 2004 } // namespace libyuv
OLDNEW
« no previous file with comments | « source/convert.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698