2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/macros.h"
26 #include "libavutil/mem_internal.h"
27 #include "libavcodec/vp6data.h"
28 #include "libavcodec/vp56dsp.h"
30 #define randomize_buffer(buf) \
32 for (size_t k = 0; k < (sizeof(buf) & ~3); k += 4) \
33 AV_WN32A(buf + k, rnd()); \
34 for (size_t k = sizeof(buf) & ~3; k < sizeof(buf); ++k) \
39 void checkasm_check_vp6dsp(void)
47 SRC_ROWS
= SRC_ROWS_ABOVE
+ BLOCK_SIZE_1D
+ SRC_ROWS_BELOW
,
48 SRC_ROW_SIZE
= SRC_COLS_LEFT
+ BLOCK_SIZE_1D
+ SRC_COLS_RIGHT
,
49 MAX_STRIDE
= 64, ///< arbitrary
50 SRC_BUF_SIZE
= (SRC_ROWS
- 1) * MAX_STRIDE
+ SRC_ROW_SIZE
+ 7 /* to vary misalignment */,
51 DST_BUF_SIZE
= (BLOCK_SIZE_1D
- 1) * MAX_STRIDE
+ BLOCK_SIZE_1D
,
55 ff_vp6dsp_init(&vp6dsp
);
57 declare_func(void, uint8_t *dst
, const uint8_t *src
, ptrdiff_t stride
,
58 const int16_t *h_weights
, const int16_t *v_weights
);
60 if (check_func(vp6dsp
.vp6_filter_diag4
, "filter_diag4")) {
61 DECLARE_ALIGNED(8, uint8_t, dstbuf_ref
)[DST_BUF_SIZE
];
62 DECLARE_ALIGNED(8, uint8_t, dstbuf_new
)[DST_BUF_SIZE
];
63 DECLARE_ALIGNED(8, uint8_t, srcbuf
)[SRC_BUF_SIZE
];
65 randomize_buffer(dstbuf_ref
);
66 randomize_buffer(srcbuf
);
67 memcpy(dstbuf_new
, dstbuf_ref
, sizeof(dstbuf_new
));
69 ptrdiff_t stride
= (rnd() % (MAX_STRIDE
/ 16) + 1) * 16;
70 const uint8_t *src
= srcbuf
+ SRC_COLS_LEFT
+ rnd() % 8U;
71 uint8_t *dst_new
= dstbuf_new
, *dst_ref
= dstbuf_ref
;
74 dst_new
+= (BLOCK_SIZE_1D
- 1) * stride
;
75 dst_ref
+= (BLOCK_SIZE_1D
- 1) * stride
;
76 src
+= (SRC_ROWS
- 1) * stride
;
79 src
+= SRC_ROWS_ABOVE
* stride
;
81 unsigned select
= rnd() % FF_ARRAY_ELEMS(vp6_block_copy_filter
);
82 unsigned x8
= 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter
[0]) - 1);
83 unsigned y8
= 1 + rnd() % (FF_ARRAY_ELEMS(vp6_block_copy_filter
[0]) - 1);
84 const int16_t *h_weights
= vp6_block_copy_filter
[select
][x8
];
85 const int16_t *v_weights
= vp6_block_copy_filter
[select
][y8
];
87 call_ref(dst_ref
, src
, stride
, h_weights
, v_weights
);
88 call_new(dst_new
, src
, stride
, h_weights
, v_weights
);
89 if (memcmp(dstbuf_new
, dstbuf_ref
, sizeof(dstbuf_new
)))
91 bench_new(dst_new
, src
, stride
, h_weights
, v_weights
);