1 /*
2 * Copyright (c) 2023-2024 Nuo Mi
3 * Copyright (c) 2023-2024 Wu Jianhua
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #include <string.h>
23
28
32
33 static const uint32_t
pixel_mask[] = { 0xffffffff, 0x03ff03ff, 0x0fff0fff, 0x3fff3fff, 0xffffffff };
34 static const int sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
35
36 #define SIZEOF_PIXEL ((bit_depth + 7) / 8)
37 #define PIXEL_STRIDE (MAX_CTU_SIZE * 2)
38 #define EXTRA_BEFORE 3
40 #define SRC_EXTRA (EXTRA_BEFORE + EXTRA_AFTER) * 2
41 #define SRC_BUF_SIZE (PIXEL_STRIDE + SRC_EXTRA) * (PIXEL_STRIDE + SRC_EXTRA)
42 #define DST_BUF_SIZE (MAX_CTU_SIZE * MAX_CTU_SIZE * 2)
43 #define SRC_OFFSET ((PIXEL_STRIDE + EXTRA_BEFORE * 2) * EXTRA_BEFORE)
44
45 #define randomize_buffers(buf0, buf1, size, mask) \
46 do { \
47 int k; \
48 for (k = 0; k < size; k += 4 / sizeof(*buf0)) { \
49 uint32_t r = rnd() & mask; \
50 AV_WN32A(buf0 + k, r); \
51 AV_WN32A(buf1 + k, r); \
52 } \
53 } while (0)
54
55 #define randomize_pixels(buf0, buf1, size) \
56 do { \
57 uint32_t mask = pixel_mask[(bit_depth - 8) >> 1]; \
58 randomize_buffers(buf0, buf1, size, mask); \
59 } while (0)
60
61 #define randomize_avg_src(buf0, buf1, size) \
62 do { \
63 uint32_t mask = 0x3fff3fff; \
64 randomize_buffers(buf0, buf1, size, mask); \
65 } while (0)
66
67 #define randomize_prof_src(buf0, buf1, size) \
68 do { \
69 const int shift = 14 - bit_depth; \
70 const int mask16 = 0x3fff >> shift << shift; \
71 uint32_t mask = (mask16 << 16) | mask16; \
72 randomize_buffers(buf0, buf1, size, mask); \
73 } while (0)
74
76 {
82
85
89 for (
int i = 0;
i < 2;
i++) {
90 for (int j = 0; j < 2; j++) {
94 const int mx =
rnd() % 16;
95 const int my =
rnd() % 16;
99 switch ((j << 1) |
i) {
100 case 0:
type =
"put_luma_pixels";
break;
// 0 0
101 case 1:
type =
"put_luma_h";
break;
// 0 1
102 case 2:
type =
"put_luma_v";
break;
// 1 0
103 case 3:
type =
"put_luma_hv";
break;
// 1 1
104 }
114 }
115 }
116 }
117 }
118 }
119 }
121 }
122
124 {
129
133 const int8_t *
hf,
const int8_t *
vf,
int width);
134
138 for (
int i = 0;
i < 2;
i++) {
139 for (int j = 0; j < 2; j++) {
148
149 switch ((j << 1) |
i) {
150 case 0:
type =
"put_uni_pixels";
break;
// 0 0
151 case 1:
type =
"put_uni_h";
break;
// 0 1
152 case 2:
type =
"put_uni_v";
break;
// 1 0
153 case 3:
type =
"put_uni_hv";
break;
// 1 1
154 }
155
165 }
166 }
167 }
168 }
169 }
170 }
172 }
173
175 {
181
183 const int height,
const int8_t *
hf,
const int8_t *
vf,
const int width);
184
188 for (
int i = 0;
i < 2;
i++) {
189 for (int j = 0; j < 2; j++) {
198 switch ((j << 1) |
i) {
199 case 0:
type =
"put_chroma_pixels";
break;
// 0 0
200 case 1:
type =
"put_chroma_h";
break;
// 0 1
201 case 2:
type =
"put_chroma_v";
break;
// 1 0
202 case 3:
type =
"put_chroma_hv";
break;
// 1 1
203 }
213 }
214 }
215 }
216 }
217 }
218 }
220 }
221
223 {
228
232 const int8_t *
hf,
const int8_t *
vf,
int width);
233
237 for (
int i = 0;
i < 2;
i++) {
238 for (int j = 0; j < 2; j++) {
247
248 switch ((j << 1) |
i) {
249 case 0:
type =
"put_uni_pixels";
break;
// 0 0
250 case 1:
type =
"put_uni_h";
break;
// 0 1
251 case 2:
type =
"put_uni_v";
break;
// 1 0
252 case 3:
type =
"put_uni_hv";
break;
// 1 1
253 }
254
264 }
265 }
266 }
267 }
268 }
269 }
271 }
272
273 #define AVG_SRC_BUF_SIZE (MAX_CTU_SIZE * MAX_CTU_SIZE)
274 #define AVG_DST_BUF_SIZE (MAX_PB_SIZE * MAX_PB_SIZE * 2)
275
277 {
285
292 {
304 }
305 }
306 {
309 int denom, int w0, int w1, int o0, int o1);
310 {
311 const int denom =
rnd() % 8;
312 const int w0 =
rnd() % 256 - 128;
313 const int w1 =
rnd() % 256 - 128;
314 const int o0 =
rnd() % 256 - 128;
315 const int o1 =
rnd() % 256 - 128;
319
320 call_ref(dst0,
MAX_CTU_SIZE *
SIZEOF_PIXEL, src00, src01,
w,
h, denom, w0, w1, o0, o1);
321 call_new(dst1,
MAX_CTU_SIZE *
SIZEOF_PIXEL, src10, src11,
w,
h, denom, w0, w1, o0, o1);
325 bench_new(dst0,
MAX_CTU_SIZE *
SIZEOF_PIXEL, src00, src01,
w,
h, denom, w0, w1, o0, o1);
326 }
327 }
328 }
329 }
330 }
331 }
333 }
334
337 {
342 const int dst_stride =
MAX_PB_SIZE *
sizeof(int16_t);
343
347
351 for (
int i = 0;
i < 2;
i++) {
352 for (int j = 0; j < 2; j++) {
353 for (
int h = 8;
h <= 16;
h *= 2) {
354 for (
int w = 8;
w <= 16;
w *= 2) {
360
362 continue;
363
364 switch ((j << 1) |
i) {
365 case 0:
type =
"dmvr";
break;
// 0 0
366 case 1:
type =
"dmvr_h";
break;
// 0 1
367 case 2:
type =
"dmvr_v";
break;
// 1 0
368 case 3:
type =
"dmvr_hv";
break;
// 1 1
369 }
370
376 for (
int k = 0; k <
pred_h; k++) {
377 if (memcmp(dst0 + k * dst_stride, dst1 + k * dst_stride, pred_w * sizeof(int16_t))) {
379 break;
380 }
381 }
382
384 }
385 }
386 }
387 }
388 }
389 }
391 }
392
393 #define BDOF_BLOCK_SIZE 16
394 #define BDOF_SRC_SIZE (MAX_PB_SIZE* (BDOF_BLOCK_SIZE + 2))
395 #define BDOF_SRC_OFFSET (MAX_PB_SIZE + 1)
396 #define BDOF_DST_SIZE (BDOF_BLOCK_SIZE * BDOF_BLOCK_SIZE * 2)
398 {
405
407 declare_func(
void, uint8_t *
dst, ptrdiff_t dst_stride,
const int16_t *
src0,
const int16_t *
src1,
int block_w,
int block_h);
408
411
415 for (
int h = 8;
h <= 16;
h *= 2) {
416 for (
int w = 8;
w <= 16;
w *= 2) {
418 continue;
427 }
428 }
429 }
430 }
432 }
433
435 {
440 declare_func(
int,
const int16_t *
src0,
const int16_t *
src1,
int dx,
int dy,
int block_w,
int block_h);
441
444 for (
int h = 8;
h <= 16;
h *= 2) {
445 for (
int w = 8;
w <= 16;
w *= 2) {
446 for(int offy = 0; offy <= 4; offy++) {
447 for(int offx = 0; offx <= 4; offx++) {
449 continue;
450
452 int result0;
453 int result1;
454
457
458 if (result1 != result0)
460 if(offx == 0 && offy == 0)
462 }
463 }
464 }
465 }
466 }
467
469 }
470
472 {
481 }