FFmpeg
tests
checkasm
vp6dsp.c
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
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.
8
*
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.
13
*
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.
17
*/
18
19
#include <assert.h>
20
#include <stddef.h>
21
#include <string.h>
22
23
#include "
checkasm.h
"
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
"
29
30
#define randomize_buffer(buf) \
31
do { \
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) \
35
buf[k] = rnd(); \
36
} while (0)
37
38
39
void
checkasm_check_vp6dsp
(
void
)
40
{
41
enum
{
42
BLOCK_SIZE_1D = 8,
43
SRC_ROWS_ABOVE = 1,
44
SRC_ROWS_BELOW = 2,
45
SRC_COLS_LEFT = 1,
46
SRC_COLS_RIGHT = 2,
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,
52
};
53
VP6DSPContext
vp6dsp;
54
55
ff_vp6dsp_init
(&vp6dsp);
56
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);
59
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
];
64
65
randomize_buffer
(dstbuf_ref);
66
randomize_buffer
(srcbuf);
67
memcpy(dstbuf_new, dstbuf_ref,
sizeof
(dstbuf_new));
68
69
ptrdiff_t
stride
= (
rnd
() % (
MAX_STRIDE
/ 16) + 1) * 16;
70
const
uint8_t *
src
= srcbuf + SRC_COLS_LEFT +
rnd
() % 8
U
;
71
uint8_t *dst_new = dstbuf_new, *dst_ref = dstbuf_ref;
72
73
if
(
rnd
() & 1) {
74
dst_new += (BLOCK_SIZE_1D - 1) *
stride
;
75
dst_ref += (BLOCK_SIZE_1D - 1) *
stride
;
76
src
+= (SRC_ROWS - 1) *
stride
;
77
stride
*= -1;
78
}
79
src
+= SRC_ROWS_ABOVE *
stride
;
80
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];
86
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)))
90
fail
();
91
bench_new
(dst_new,
src
,
stride
, h_weights, v_weights);
92
}
93
}
SRC_BUF_SIZE
#define SRC_BUF_SIZE
Definition:
hash.c:26
vp6_block_copy_filter
static const int16_t vp6_block_copy_filter[17][8][4]
Definition:
vp6data.h:162
mem_internal.h
VP6DSPContext
Definition:
vp56dsp.h:32
check_func
#define check_func(func,...)
Definition:
checkasm.h:199
call_ref
#define call_ref(...)
Definition:
checkasm.h:214
macros.h
fail
#define fail()
Definition:
checkasm.h:208
VP6DSPContext::vp6_filter_diag4
void(* vp6_filter_diag4)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, const int16_t *h_weights, const int16_t *v_weights)
Definition:
vp56dsp.h:33
checkasm.h
rnd
#define rnd()
Definition:
checkasm.h:192
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition:
sinewin_tablegen.c:29
intreadwrite.h
call_new
#define call_new(...)
Definition:
checkasm.h:317
checkasm_check_vp6dsp
void checkasm_check_vp6dsp(void)
Definition:
vp6dsp.c:39
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition:
mem_internal.h:104
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition:
dsp.h:87
randomize_buffer
#define randomize_buffer(buf)
Definition:
vp6dsp.c:30
vp56dsp.h
bench_new
#define bench_new(...)
Definition:
checkasm.h:402
ff_vp6dsp_init
av_cold void ff_vp6dsp_init(VP6DSPContext *s)
Definition:
vp6dsp.c:63
DST_BUF_SIZE
#define DST_BUF_SIZE
Definition:
hash.c:27
U
#define U(x)
Definition:
vpx_arith.h:37
MAX_STRIDE
#define MAX_STRIDE
Definition:
hpeldsp.c:31
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:203
vp6data.h
stride
#define stride
Definition:
h264pred_template.c:536
src
#define src
Definition:
vp8dsp.c:248
Generated on Fri Nov 28 2025 19:22:35 for FFmpeg by
1.8.17