Commit | Line | Data |
---|---|---|
72b9787e JB |
1 | /***************************************************************************** |
2 | * Copyright (C) 2013 x265 project | |
3 | * | |
4 | * Authors: Deepthi Devaki <deepthidevaki@multicorewareinc.com>, | |
5 | * Rajesh Paulraj <rajesh@multicorewareinc.com> | |
6 | * Praveen Kumar Tiwari <praveen@multicorewareinc.com> | |
7 | * Min Chen <chenm003@163.com> <min.chen@multicorewareinc.com> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. | |
22 | * | |
23 | * This program is also available under a commercial proprietary license. | |
24 | * For more information, contact us at license @ x265.com. | |
25 | *****************************************************************************/ | |
26 | ||
27 | #include "common.h" | |
28 | #include "ipfilterharness.h" | |
29 | ||
30 | using namespace x265; | |
31 | ||
32 | IPFilterHarness::IPFilterHarness() | |
33 | { | |
34 | /* [0] --- Random values | |
35 | * [1] --- Minimum | |
36 | * [2] --- Maximum */ | |
37 | for (int i = 0; i < TEST_BUF_SIZE; i++) | |
38 | { | |
39 | pixel_test_buff[0][i] = rand() & PIXEL_MAX; | |
40 | short_test_buff[0][i] = (rand() % (2 * SMAX)) - SMAX; | |
41 | ||
42 | pixel_test_buff[1][i] = PIXEL_MIN; | |
43 | short_test_buff[1][i] = SMIN; | |
44 | ||
45 | pixel_test_buff[2][i] = PIXEL_MAX; | |
46 | short_test_buff[2][i] = SMAX; | |
47 | } | |
48 | ||
49 | memset(IPF_C_output_p, 0xCD, TEST_BUF_SIZE * sizeof(pixel)); | |
50 | memset(IPF_vec_output_p, 0xCD, TEST_BUF_SIZE * sizeof(pixel)); | |
51 | memset(IPF_C_output_s, 0xCD, TEST_BUF_SIZE * sizeof(int16_t)); | |
52 | memset(IPF_vec_output_s, 0xCD, TEST_BUF_SIZE * sizeof(int16_t)); | |
53 | ||
54 | int pixelMax = (1 << X265_DEPTH) - 1; | |
55 | int shortMax = (1 << 15) - 1; | |
56 | for (int i = 0; i < TEST_BUF_SIZE; i++) | |
57 | { | |
58 | pixel_buff[i] = (pixel)(rand() & pixelMax); | |
59 | int isPositive = (rand() & 1) ? 1 : -1; | |
60 | short_buff[i] = (int16_t)(isPositive * (rand() & shortMax)); | |
61 | } | |
62 | } | |
63 | ||
64 | bool IPFilterHarness::check_IPFilter_primitive(filter_p2s_t ref, filter_p2s_t opt, int isChroma, int csp) | |
65 | { | |
66 | intptr_t rand_srcStride; | |
67 | int min_size = isChroma ? 2 : 4; | |
68 | int max_size = isChroma ? (MAX_CU_SIZE >> 1) : MAX_CU_SIZE; | |
69 | ||
70 | if (isChroma && (csp == X265_CSP_I444)) | |
71 | { | |
72 | min_size = 4; | |
73 | max_size = MAX_CU_SIZE; | |
74 | } | |
75 | ||
76 | for (int i = 0; i < ITERS; i++) | |
77 | { | |
78 | int index = i % TEST_CASES; | |
79 | int rand_height = (int16_t)rand() % 100; | |
80 | int rand_width = (int16_t)rand() % 100; | |
81 | ||
82 | rand_srcStride = rand_width + rand() % 100; | |
83 | if (rand_srcStride < rand_width) | |
84 | rand_srcStride = rand_width; | |
85 | ||
86 | rand_width &= ~(min_size - 1); | |
87 | rand_width = Clip3(min_size, max_size, rand_width); | |
88 | ||
89 | rand_height &= ~(min_size - 1); | |
90 | rand_height = Clip3(min_size, max_size, rand_height); | |
91 | ||
92 | ref(pixel_test_buff[index], | |
93 | rand_srcStride, | |
94 | IPF_C_output_s, | |
95 | rand_width, | |
96 | rand_height); | |
97 | ||
98 | checked(opt, pixel_test_buff[index], | |
99 | rand_srcStride, | |
100 | IPF_vec_output_s, | |
101 | rand_width, | |
102 | rand_height); | |
103 | ||
104 | if (memcmp(IPF_vec_output_s, IPF_C_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
105 | return false; | |
106 | ||
107 | reportfail(); | |
108 | } | |
109 | ||
110 | return true; | |
111 | } | |
112 | ||
113 | bool IPFilterHarness::check_IPFilterChroma_primitive(filter_pp_t ref, filter_pp_t opt) | |
114 | { | |
115 | intptr_t rand_srcStride, rand_dstStride; | |
116 | ||
117 | for (int i = 0; i < ITERS; i++) | |
118 | { | |
119 | int index = i % TEST_CASES; | |
120 | ||
121 | for (int coeffIdx = 0; coeffIdx < 8; coeffIdx++) | |
122 | { | |
123 | rand_srcStride = rand() % 100 + 2; | |
124 | rand_dstStride = rand() % 100 + 64; | |
125 | ||
126 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride, | |
127 | rand_srcStride, | |
128 | IPF_vec_output_p, | |
129 | rand_dstStride, | |
130 | coeffIdx); | |
131 | ||
132 | ref(pixel_test_buff[index] + 3 * rand_srcStride, | |
133 | rand_srcStride, | |
134 | IPF_C_output_p, | |
135 | rand_dstStride, | |
136 | coeffIdx); | |
137 | ||
138 | if (memcmp(IPF_vec_output_p, IPF_C_output_p, TEST_BUF_SIZE * sizeof(pixel))) | |
139 | return false; | |
140 | ||
141 | reportfail(); | |
142 | } | |
143 | } | |
144 | ||
145 | return true; | |
146 | } | |
147 | ||
148 | bool IPFilterHarness::check_IPFilterChroma_ps_primitive(filter_ps_t ref, filter_ps_t opt) | |
149 | { | |
150 | intptr_t rand_srcStride, rand_dstStride; | |
151 | ||
152 | for (int i = 0; i < ITERS; i++) | |
153 | { | |
154 | int index = i % TEST_CASES; | |
155 | ||
156 | for (int coeffIdx = 0; coeffIdx < 8; coeffIdx++) | |
157 | { | |
158 | rand_srcStride = rand() % 100; | |
159 | rand_dstStride = rand() % 100 + 64; | |
160 | ||
161 | ref(pixel_test_buff[index] + 3 * rand_srcStride, | |
162 | rand_srcStride, | |
163 | IPF_C_output_s, | |
164 | rand_dstStride, | |
165 | coeffIdx); | |
166 | ||
167 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride, | |
168 | rand_srcStride, | |
169 | IPF_vec_output_s, | |
170 | rand_dstStride, | |
171 | coeffIdx); | |
172 | ||
173 | if (memcmp(IPF_vec_output_s, IPF_C_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
174 | return false; | |
175 | ||
176 | reportfail(); | |
177 | } | |
178 | } | |
179 | ||
180 | return true; | |
181 | } | |
182 | ||
183 | bool IPFilterHarness::check_IPFilterChroma_hps_primitive(filter_hps_t ref, filter_hps_t opt) | |
184 | { | |
185 | intptr_t rand_srcStride, rand_dstStride; | |
186 | ||
187 | for (int i = 0; i < ITERS; i++) | |
188 | { | |
189 | int index = i % TEST_CASES; | |
190 | ||
191 | for (int coeffIdx = 0; coeffIdx < 8; coeffIdx++) | |
192 | { | |
193 | // 0 : Interpolate W x H, 1 : Interpolate W x (H + 7) | |
194 | for (int isRowExt = 0; isRowExt < 2; isRowExt++) | |
195 | { | |
196 | rand_srcStride = rand() % 100 + 2; | |
197 | rand_dstStride = rand() % 100 + 64; | |
198 | ||
199 | ref(pixel_test_buff[index] + 3 * rand_srcStride, | |
200 | rand_srcStride, | |
201 | IPF_C_output_s, | |
202 | rand_dstStride, | |
203 | coeffIdx, | |
204 | isRowExt); | |
205 | ||
206 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride, | |
207 | rand_srcStride, | |
208 | IPF_vec_output_s, | |
209 | rand_dstStride, | |
210 | coeffIdx, | |
211 | isRowExt); | |
212 | ||
213 | if (memcmp(IPF_vec_output_s, IPF_C_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
214 | return false; | |
215 | ||
216 | reportfail(); | |
217 | } | |
218 | } | |
219 | } | |
220 | ||
221 | return true; | |
222 | } | |
223 | ||
224 | bool IPFilterHarness::check_IPFilterChroma_sp_primitive(filter_sp_t ref, filter_sp_t opt) | |
225 | { | |
226 | intptr_t rand_srcStride, rand_dstStride; | |
227 | ||
228 | for (int i = 0; i < ITERS; i++) | |
229 | { | |
230 | int index = i % TEST_CASES; | |
231 | ||
232 | for (int coeffIdx = 0; coeffIdx < 8; coeffIdx++) | |
233 | { | |
234 | rand_srcStride = rand() % 100; | |
235 | rand_dstStride = rand() % 100 + 64; | |
236 | ||
237 | ref(short_test_buff[index] + 3 * rand_srcStride, | |
238 | rand_srcStride, | |
239 | IPF_C_output_p, | |
240 | rand_dstStride, | |
241 | coeffIdx); | |
242 | ||
243 | checked(opt, short_test_buff[index] + 3 * rand_srcStride, | |
244 | rand_srcStride, | |
245 | IPF_vec_output_p, | |
246 | rand_dstStride, | |
247 | coeffIdx); | |
248 | ||
249 | if (memcmp(IPF_vec_output_p, IPF_C_output_p, TEST_BUF_SIZE * sizeof(pixel))) | |
250 | return false; | |
251 | ||
252 | reportfail(); | |
253 | } | |
254 | } | |
255 | ||
256 | return true; | |
257 | } | |
258 | ||
259 | bool IPFilterHarness::check_IPFilterChroma_ss_primitive(filter_ss_t ref, filter_ss_t opt) | |
260 | { | |
261 | intptr_t rand_srcStride, rand_dstStride; | |
262 | ||
263 | for (int i = 0; i < ITERS; i++) | |
264 | { | |
265 | int index = i % TEST_CASES; | |
266 | ||
267 | for (int coeffIdx = 0; coeffIdx < 8; coeffIdx++) | |
268 | { | |
269 | rand_srcStride = rand() % 100; | |
270 | rand_dstStride = rand() % 100 + 64; | |
271 | ||
272 | ref(short_test_buff[index] + 3 * rand_srcStride, | |
273 | rand_srcStride, | |
274 | IPF_C_output_s, | |
275 | rand_dstStride, | |
276 | coeffIdx); | |
277 | ||
278 | checked(opt, short_test_buff[index] + 3 * rand_srcStride, | |
279 | rand_srcStride, | |
280 | IPF_vec_output_s, | |
281 | rand_dstStride, | |
282 | coeffIdx); | |
283 | ||
284 | if (memcmp(IPF_C_output_s, IPF_vec_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
285 | return false; | |
286 | ||
287 | reportfail(); | |
288 | } | |
289 | } | |
290 | ||
291 | return true; | |
292 | } | |
293 | ||
294 | bool IPFilterHarness::check_IPFilterLuma_primitive(filter_pp_t ref, filter_pp_t opt) | |
295 | { | |
296 | intptr_t rand_srcStride, rand_dstStride; | |
297 | ||
298 | for (int i = 0; i < ITERS; i++) | |
299 | { | |
300 | int index = i % TEST_CASES; | |
301 | ||
302 | for (int coeffIdx = 0; coeffIdx < 4; coeffIdx++) | |
303 | { | |
304 | rand_srcStride = rand() % 100; | |
305 | rand_dstStride = rand() % 100 + 64; | |
306 | ||
307 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride + 6, | |
308 | rand_srcStride, | |
309 | IPF_vec_output_p, | |
310 | rand_dstStride, | |
311 | coeffIdx); | |
312 | ||
313 | ref(pixel_test_buff[index] + 3 * rand_srcStride + 6, | |
314 | rand_srcStride, | |
315 | IPF_C_output_p, | |
316 | rand_dstStride, | |
317 | coeffIdx); | |
318 | ||
319 | if (memcmp(IPF_vec_output_p, IPF_C_output_p, TEST_BUF_SIZE)) | |
320 | return false; | |
321 | ||
322 | reportfail(); | |
323 | } | |
324 | } | |
325 | ||
326 | return true; | |
327 | } | |
328 | ||
329 | bool IPFilterHarness::check_IPFilterLuma_ps_primitive(filter_ps_t ref, filter_ps_t opt) | |
330 | { | |
331 | intptr_t rand_srcStride, rand_dstStride; | |
332 | ||
333 | for (int i = 0; i < ITERS; i++) | |
334 | { | |
335 | int index = i % TEST_CASES; | |
336 | ||
337 | for (int coeffIdx = 0; coeffIdx < 4; coeffIdx++) | |
338 | { | |
339 | rand_srcStride = rand() % 100; | |
340 | rand_dstStride = rand() % 100 + 64; | |
341 | ||
342 | ref(pixel_test_buff[index] + 3 * rand_srcStride, | |
343 | rand_srcStride, | |
344 | IPF_C_output_s, | |
345 | rand_dstStride, | |
346 | coeffIdx); | |
347 | ||
348 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride, | |
349 | rand_srcStride, | |
350 | IPF_vec_output_s, | |
351 | rand_dstStride, | |
352 | coeffIdx); | |
353 | ||
354 | if (memcmp(IPF_vec_output_s, IPF_C_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
355 | return false; | |
356 | ||
357 | reportfail(); | |
358 | } | |
359 | } | |
360 | ||
361 | return true; | |
362 | } | |
363 | ||
364 | bool IPFilterHarness::check_IPFilterLuma_hps_primitive(filter_hps_t ref, filter_hps_t opt) | |
365 | { | |
366 | intptr_t rand_srcStride, rand_dstStride; | |
367 | ||
368 | for (int i = 0; i < ITERS; i++) | |
369 | { | |
370 | int index = i % TEST_CASES; | |
371 | ||
372 | for (int coeffIdx = 0; coeffIdx < 4; coeffIdx++) | |
373 | { | |
374 | // 0 : Interpolate W x H, 1 : Interpolate W x (H + 7) | |
375 | for (int isRowExt = 0; isRowExt < 2; isRowExt++) | |
376 | { | |
377 | rand_srcStride = rand() % 100; | |
378 | rand_dstStride = rand() % 100 + 64; | |
379 | ||
380 | ref(pixel_test_buff[index] + 3 * rand_srcStride + 6, | |
381 | rand_srcStride, | |
382 | IPF_C_output_s, | |
383 | rand_dstStride, | |
384 | coeffIdx, | |
385 | isRowExt); | |
386 | ||
387 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride + 6, | |
388 | rand_srcStride, | |
389 | IPF_vec_output_s, | |
390 | rand_dstStride, | |
391 | coeffIdx, | |
392 | isRowExt); | |
393 | ||
394 | if (memcmp(IPF_vec_output_s, IPF_C_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
395 | return false; | |
396 | ||
397 | reportfail(); | |
398 | } | |
399 | } | |
400 | } | |
401 | ||
402 | return true; | |
403 | } | |
404 | ||
405 | bool IPFilterHarness::check_IPFilterLuma_sp_primitive(filter_sp_t ref, filter_sp_t opt) | |
406 | { | |
407 | intptr_t rand_srcStride, rand_dstStride; | |
408 | ||
409 | for (int i = 0; i < ITERS; i++) | |
410 | { | |
411 | int index = i % TEST_CASES; | |
412 | ||
413 | for (int coeffIdx = 0; coeffIdx < 4; coeffIdx++) | |
414 | { | |
415 | rand_srcStride = rand() % 100; | |
416 | rand_dstStride = rand() % 100 + 64; | |
417 | ||
418 | ref(short_test_buff[index] + 3 * rand_srcStride, | |
419 | rand_srcStride, | |
420 | IPF_C_output_p, | |
421 | rand_dstStride, | |
422 | coeffIdx); | |
423 | ||
424 | checked(opt, short_test_buff[index] + 3 * rand_srcStride, | |
425 | rand_srcStride, | |
426 | IPF_vec_output_p, | |
427 | rand_dstStride, | |
428 | coeffIdx); | |
429 | ||
430 | if (memcmp(IPF_vec_output_p, IPF_C_output_p, TEST_BUF_SIZE * sizeof(pixel))) | |
431 | return false; | |
432 | ||
433 | reportfail(); | |
434 | } | |
435 | } | |
436 | ||
437 | return true; | |
438 | } | |
439 | ||
440 | bool IPFilterHarness::check_IPFilterLuma_ss_primitive(filter_ss_t ref, filter_ss_t opt) | |
441 | { | |
442 | intptr_t rand_srcStride, rand_dstStride; | |
443 | ||
444 | for (int i = 0; i < ITERS; i++) | |
445 | { | |
446 | int index = i % TEST_CASES; | |
447 | ||
448 | for (int coeffIdx = 0; coeffIdx < 4; coeffIdx++) | |
449 | { | |
450 | rand_srcStride = rand() % 100; | |
451 | rand_dstStride = rand() % 100 + 64; | |
452 | ||
453 | ref(short_test_buff[index] + 3 * rand_srcStride, | |
454 | rand_srcStride, | |
455 | IPF_C_output_s, | |
456 | rand_dstStride, | |
457 | coeffIdx); | |
458 | ||
459 | checked(opt, short_test_buff[index] + 3 * rand_srcStride, | |
460 | rand_srcStride, | |
461 | IPF_vec_output_s, | |
462 | rand_dstStride, | |
463 | coeffIdx); | |
464 | ||
465 | if (memcmp(IPF_C_output_s, IPF_vec_output_s, TEST_BUF_SIZE * sizeof(int16_t))) | |
466 | return false; | |
467 | ||
468 | reportfail(); | |
469 | } | |
470 | } | |
471 | ||
472 | return true; | |
473 | } | |
474 | ||
475 | bool IPFilterHarness::check_IPFilterLumaHV_primitive(filter_hv_pp_t ref, filter_hv_pp_t opt) | |
476 | { | |
477 | intptr_t rand_srcStride, rand_dstStride; | |
478 | ||
479 | for (int i = 0; i < ITERS; i++) | |
480 | { | |
481 | int index = i % TEST_CASES; | |
482 | ||
483 | for (int coeffIdxX = 0; coeffIdxX < 4; coeffIdxX++) | |
484 | { | |
485 | for (int coeffIdxY = 0; coeffIdxY < 4; coeffIdxY++) | |
486 | { | |
487 | rand_srcStride = rand() % 100; | |
488 | rand_dstStride = rand() % 100 + 64; | |
489 | ||
490 | ref(pixel_test_buff[index] + 3 * rand_srcStride, | |
491 | rand_srcStride, | |
492 | IPF_C_output_p, | |
493 | rand_dstStride, | |
494 | coeffIdxX, | |
495 | coeffIdxY); | |
496 | ||
497 | checked(opt, pixel_test_buff[index] + 3 * rand_srcStride, | |
498 | rand_srcStride, | |
499 | IPF_vec_output_p, | |
500 | rand_dstStride, | |
501 | coeffIdxX, | |
502 | coeffIdxY); | |
503 | ||
504 | if (memcmp(IPF_vec_output_p, IPF_C_output_p, TEST_BUF_SIZE * sizeof(pixel))) | |
505 | return false; | |
506 | ||
507 | reportfail(); | |
508 | } | |
509 | } | |
510 | } | |
511 | ||
512 | return true; | |
513 | } | |
514 | ||
515 | bool IPFilterHarness::testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt) | |
516 | { | |
517 | if (opt.luma_p2s) | |
518 | { | |
519 | // last parameter does not matter in case of luma | |
520 | if (!check_IPFilter_primitive(ref.luma_p2s, opt.luma_p2s, 0, 1)) | |
521 | { | |
522 | printf("luma_p2s failed\n"); | |
523 | return false; | |
524 | } | |
525 | } | |
526 | ||
527 | for (int value = 0; value < NUM_LUMA_PARTITIONS; value++) | |
528 | { | |
529 | if (opt.luma_hpp[value]) | |
530 | { | |
531 | if (!check_IPFilterLuma_primitive(ref.luma_hpp[value], opt.luma_hpp[value])) | |
532 | { | |
533 | printf("luma_hpp[%s]", lumaPartStr[value]); | |
534 | return false; | |
535 | } | |
536 | } | |
537 | if (opt.luma_hps[value]) | |
538 | { | |
539 | if (!check_IPFilterLuma_hps_primitive(ref.luma_hps[value], opt.luma_hps[value])) | |
540 | { | |
541 | printf("luma_hps[%s]", lumaPartStr[value]); | |
542 | return false; | |
543 | } | |
544 | } | |
545 | if (opt.luma_vpp[value]) | |
546 | { | |
547 | if (!check_IPFilterLuma_primitive(ref.luma_vpp[value], opt.luma_vpp[value])) | |
548 | { | |
549 | printf("luma_vpp[%s]", lumaPartStr[value]); | |
550 | return false; | |
551 | } | |
552 | } | |
553 | if (opt.luma_vps[value]) | |
554 | { | |
555 | if (!check_IPFilterLuma_ps_primitive(ref.luma_vps[value], opt.luma_vps[value])) | |
556 | { | |
557 | printf("luma_vps[%s]", lumaPartStr[value]); | |
558 | return false; | |
559 | } | |
560 | } | |
561 | if (opt.luma_vsp[value]) | |
562 | { | |
563 | if (!check_IPFilterLuma_sp_primitive(ref.luma_vsp[value], opt.luma_vsp[value])) | |
564 | { | |
565 | printf("luma_vsp[%s]", lumaPartStr[value]); | |
566 | return false; | |
567 | } | |
568 | } | |
569 | if (opt.luma_vss[value]) | |
570 | { | |
571 | if (!check_IPFilterLuma_ss_primitive(ref.luma_vss[value], opt.luma_vss[value])) | |
572 | { | |
573 | printf("luma_vss[%s]", lumaPartStr[value]); | |
574 | return false; | |
575 | } | |
576 | } | |
577 | if (opt.luma_hvpp[value]) | |
578 | { | |
579 | if (!check_IPFilterLumaHV_primitive(ref.luma_hvpp[value], opt.luma_hvpp[value])) | |
580 | { | |
581 | printf("luma_hvpp[%s]", lumaPartStr[value]); | |
582 | return false; | |
583 | } | |
584 | } | |
585 | } | |
586 | ||
587 | for (int csp = X265_CSP_I420; csp < X265_CSP_COUNT; csp++) | |
588 | { | |
b53f7c52 | 589 | if (opt.chroma[csp].p2s) |
72b9787e | 590 | { |
b53f7c52 | 591 | if (!check_IPFilter_primitive(ref.chroma[csp].p2s, opt.chroma[csp].p2s, 1, csp)) |
72b9787e JB |
592 | { |
593 | printf("chroma_p2s[%s]", x265_source_csp_names[csp]); | |
594 | return false; | |
595 | } | |
596 | } | |
597 | for (int value = 0; value < NUM_CHROMA_PARTITIONS; value++) | |
598 | { | |
599 | if (opt.chroma[csp].filter_hpp[value]) | |
600 | { | |
601 | if (!check_IPFilterChroma_primitive(ref.chroma[csp].filter_hpp[value], opt.chroma[csp].filter_hpp[value])) | |
602 | { | |
603 | printf("chroma_hpp[%s]", chromaPartStr[csp][value]); | |
604 | return false; | |
605 | } | |
606 | } | |
607 | if (opt.chroma[csp].filter_hps[value]) | |
608 | { | |
609 | if (!check_IPFilterChroma_hps_primitive(ref.chroma[csp].filter_hps[value], opt.chroma[csp].filter_hps[value])) | |
610 | { | |
611 | printf("chroma_hps[%s]", chromaPartStr[csp][value]); | |
612 | return false; | |
613 | } | |
614 | } | |
615 | if (opt.chroma[csp].filter_vpp[value]) | |
616 | { | |
617 | if (!check_IPFilterChroma_primitive(ref.chroma[csp].filter_vpp[value], opt.chroma[csp].filter_vpp[value])) | |
618 | { | |
619 | printf("chroma_vpp[%s]", chromaPartStr[csp][value]); | |
620 | return false; | |
621 | } | |
622 | } | |
623 | if (opt.chroma[csp].filter_vps[value]) | |
624 | { | |
625 | if (!check_IPFilterChroma_ps_primitive(ref.chroma[csp].filter_vps[value], opt.chroma[csp].filter_vps[value])) | |
626 | { | |
627 | printf("chroma_vps[%s]", chromaPartStr[csp][value]); | |
628 | return false; | |
629 | } | |
630 | } | |
631 | if (opt.chroma[csp].filter_vsp[value]) | |
632 | { | |
633 | if (!check_IPFilterChroma_sp_primitive(ref.chroma[csp].filter_vsp[value], opt.chroma[csp].filter_vsp[value])) | |
634 | { | |
635 | printf("chroma_vsp[%s]", chromaPartStr[csp][value]); | |
636 | return false; | |
637 | } | |
638 | } | |
639 | if (opt.chroma[csp].filter_vss[value]) | |
640 | { | |
641 | if (!check_IPFilterChroma_ss_primitive(ref.chroma[csp].filter_vss[value], opt.chroma[csp].filter_vss[value])) | |
642 | { | |
643 | printf("chroma_vss[%s]", chromaPartStr[csp][value]); | |
644 | return false; | |
645 | } | |
646 | } | |
647 | } | |
648 | } | |
649 | ||
650 | return true; | |
651 | } | |
652 | ||
653 | void IPFilterHarness::measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt) | |
654 | { | |
655 | int height = 64; | |
656 | int width = 64; | |
657 | int16_t srcStride = 96; | |
658 | int16_t dstStride = 96; | |
659 | int maxVerticalfilterHalfDistance = 3; | |
660 | ||
661 | if (opt.luma_p2s) | |
662 | { | |
663 | printf("luma_p2s\t"); | |
664 | REPORT_SPEEDUP(opt.luma_p2s, ref.luma_p2s, | |
665 | pixel_buff, srcStride, IPF_vec_output_s, width, height); | |
666 | } | |
667 | ||
668 | for (int value = 0; value < NUM_LUMA_PARTITIONS; value++) | |
669 | { | |
670 | if (opt.luma_hpp[value]) | |
671 | { | |
672 | printf("luma_hpp[%s]\t", lumaPartStr[value]); | |
673 | REPORT_SPEEDUP(opt.luma_hpp[value], ref.luma_hpp[value], | |
674 | pixel_buff + srcStride, srcStride, IPF_vec_output_p, dstStride, 1); | |
675 | } | |
676 | ||
677 | if (opt.luma_hps[value]) | |
678 | { | |
679 | printf("luma_hps[%s]\t", lumaPartStr[value]); | |
680 | REPORT_SPEEDUP(opt.luma_hps[value], ref.luma_hps[value], | |
681 | pixel_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
682 | IPF_vec_output_s, dstStride, 1, 1); | |
683 | } | |
684 | ||
685 | if (opt.luma_vpp[value]) | |
686 | { | |
687 | printf("luma_vpp[%s]\t", lumaPartStr[value]); | |
688 | REPORT_SPEEDUP(opt.luma_vpp[value], ref.luma_vpp[value], | |
689 | pixel_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
690 | IPF_vec_output_p, dstStride, 1); | |
691 | } | |
692 | ||
693 | if (opt.luma_vps[value]) | |
694 | { | |
695 | printf("luma_vps[%s]\t", lumaPartStr[value]); | |
696 | REPORT_SPEEDUP(opt.luma_vps[value], ref.luma_vps[value], | |
697 | pixel_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
698 | IPF_vec_output_s, dstStride, 1); | |
699 | } | |
700 | ||
701 | if (opt.luma_vsp[value]) | |
702 | { | |
703 | printf("luma_vsp[%s]\t", lumaPartStr[value]); | |
704 | REPORT_SPEEDUP(opt.luma_vsp[value], ref.luma_vsp[value], | |
705 | short_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
706 | IPF_vec_output_p, dstStride, 1); | |
707 | } | |
708 | ||
709 | if (opt.luma_vss[value]) | |
710 | { | |
711 | printf("luma_vss[%s]\t", lumaPartStr[value]); | |
712 | REPORT_SPEEDUP(opt.luma_vss[value], ref.luma_vss[value], | |
713 | short_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
714 | IPF_vec_output_s, dstStride, 1); | |
715 | } | |
716 | ||
717 | if (opt.luma_hvpp[value]) | |
718 | { | |
719 | printf("luma_hv [%s]\t", lumaPartStr[value]); | |
720 | REPORT_SPEEDUP(opt.luma_hvpp[value], ref.luma_hvpp[value], | |
721 | pixel_buff + 3 * srcStride, srcStride, IPF_vec_output_p, srcStride, 1, 3); | |
722 | } | |
723 | } | |
724 | ||
725 | for (int csp = X265_CSP_I420; csp < X265_CSP_COUNT; csp++) | |
726 | { | |
727 | printf("= Color Space %s =\n", x265_source_csp_names[csp]); | |
b53f7c52 | 728 | if (opt.chroma[csp].p2s) |
72b9787e JB |
729 | { |
730 | printf("chroma_p2s\t"); | |
b53f7c52 | 731 | REPORT_SPEEDUP(opt.chroma[csp].p2s, ref.chroma[csp].p2s, |
72b9787e JB |
732 | pixel_buff, srcStride, IPF_vec_output_s, width, height); |
733 | } | |
734 | for (int value = 0; value < NUM_CHROMA_PARTITIONS; value++) | |
735 | { | |
736 | if (opt.chroma[csp].filter_hpp[value]) | |
737 | { | |
738 | printf("chroma_hpp[%s]", chromaPartStr[csp][value]); | |
739 | REPORT_SPEEDUP(opt.chroma[csp].filter_hpp[value], ref.chroma[csp].filter_hpp[value], | |
740 | pixel_buff + srcStride, srcStride, IPF_vec_output_p, dstStride, 1); | |
741 | } | |
742 | if (opt.chroma[csp].filter_hps[value]) | |
743 | { | |
744 | printf("chroma_hps[%s]", chromaPartStr[csp][value]); | |
745 | REPORT_SPEEDUP(opt.chroma[csp].filter_hps[value], ref.chroma[csp].filter_hps[value], | |
746 | pixel_buff + srcStride, srcStride, IPF_vec_output_s, dstStride, 1, 1); | |
747 | } | |
748 | if (opt.chroma[csp].filter_vpp[value]) | |
749 | { | |
750 | printf("chroma_vpp[%s]", chromaPartStr[csp][value]); | |
751 | REPORT_SPEEDUP(opt.chroma[csp].filter_vpp[value], ref.chroma[csp].filter_vpp[value], | |
752 | pixel_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
753 | IPF_vec_output_p, dstStride, 1); | |
754 | } | |
755 | if (opt.chroma[csp].filter_vps[value]) | |
756 | { | |
757 | printf("chroma_vps[%s]", chromaPartStr[csp][value]); | |
758 | REPORT_SPEEDUP(opt.chroma[csp].filter_vps[value], ref.chroma[csp].filter_vps[value], | |
759 | pixel_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
760 | IPF_vec_output_s, dstStride, 1); | |
761 | } | |
762 | if (opt.chroma[csp].filter_vsp[value]) | |
763 | { | |
764 | printf("chroma_vsp[%s]", chromaPartStr[csp][value]); | |
765 | REPORT_SPEEDUP(opt.chroma[csp].filter_vsp[value], ref.chroma[csp].filter_vsp[value], | |
766 | short_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
767 | IPF_vec_output_p, dstStride, 1); | |
768 | } | |
769 | if (opt.chroma[csp].filter_vss[value]) | |
770 | { | |
771 | printf("chroma_vss[%s]", chromaPartStr[csp][value]); | |
772 | REPORT_SPEEDUP(opt.chroma[csp].filter_vss[value], ref.chroma[csp].filter_vss[value], | |
773 | short_buff + maxVerticalfilterHalfDistance * srcStride, srcStride, | |
774 | IPF_vec_output_s, dstStride, 1); | |
775 | } | |
776 | } | |
777 | } | |
778 | } |