FFmpeg
Loading...
Searching...
No Matches
tests
checkasm
llvidencdsp.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2016 Alexandra Hájková
3
*
4
* This file is part of FFmpeg.
5
*
6
* FFmpeg is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* FFmpeg is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*/
20
21
#include <string.h>
22
23
#include "
libavutil/common.h
"
24
#include "
libavutil/intreadwrite.h
"
25
#include "
libavutil/mem_internal.h
"
26
27
#include "
libavcodec/lossless_videoencdsp.h
"
28
29
#include "
checkasm.h
"
30
31
#define randomize_buffers(buf, size) \
32
do { \
33
for (size_t j = 0; j < (size & ~3); j += 4) \
34
AV_WN32(buf + j, rnd()); \
35
for (size_t j = size & ~3; j < size; ++j) \
36
buf[j] = rnd(); \
37
} while (0)
38
39
static
const
struct
{uint8_t
w
,
h
,
s
;}
planes
[] = {
40
{16,16,16}, {21,23,25}, {32,17,48}, {15,128,16}, {128,127,128}
41
};
42
43
#define MAX_STRIDE 128
44
#define MAX_HEIGHT 127
45
46
static
void
check_diff_bytes
(
LLVidEncDSPContext
*
c
)
47
{
48
int
i
;
49
LOCAL_ALIGNED_32
(uint8_t, dst0, [
MAX_STRIDE
]);
50
LOCAL_ALIGNED_32
(uint8_t, dst1, [
MAX_STRIDE
]);
51
LOCAL_ALIGNED_32
(uint8_t,
src0
, [
MAX_STRIDE
]);
52
LOCAL_ALIGNED_32
(uint8_t,
src1
, [
MAX_STRIDE
]);
53
LOCAL_ALIGNED_32
(uint8_t,
src2
, [
MAX_STRIDE
]);
54
LOCAL_ALIGNED_32
(uint8_t, src3, [
MAX_STRIDE
]);
55
56
declare_func
(
void
, uint8_t *
dst
,
const
uint8_t *
src1
,
57
const
uint8_t *
src2
, intptr_t
w
);
58
59
memset(dst0, 0,
MAX_STRIDE
);
60
memset(dst1, 0,
MAX_STRIDE
);
61
randomize_buffers
(
src0
,
MAX_STRIDE
);
62
memcpy(
src1
,
src0
,
MAX_STRIDE
);
63
randomize_buffers
(
src2
,
MAX_STRIDE
);
64
memcpy(src3,
src2
,
MAX_STRIDE
);
65
66
if
(
check_func
(
c
->diff_bytes,
"diff_bytes"
)) {
67
for
(
i
= 0;
i
< 5;
i
++) {
68
call_ref
(dst0,
src0
,
src2
,
planes
[
i
].
w
);
69
call_new
(dst1,
src1
, src3,
planes
[
i
].
w
);
70
if
(memcmp(dst0, dst1,
planes
[
i
].
w
))
71
fail
();
72
}
73
bench_new
(dst1,
src0
,
src2
,
planes
[4].
w
);
74
}
75
}
76
77
static
void
check_sub_median_pred
(
LLVidEncDSPContext
*
c
)
78
{
79
enum
{
80
BUF_SIZE
=
MAX_STRIDE
+ 15
/* to test misalignment */
81
};
82
uint8_t dst_ref[
BUF_SIZE
], dst_new[
BUF_SIZE
];
83
uint8_t
src1
[
BUF_SIZE
],
src2
[
BUF_SIZE
];
84
85
declare_func
(
void
, uint8_t *
dst
,
const
uint8_t *
src1
,
86
const
uint8_t *
src2
, intptr_t
w
,
87
int
*
left
,
int
*left_top);
88
89
if
(
check_func
(
c
->sub_median_pred,
"sub_median_pred"
)) {
90
size_t
width
= 1 +
rnd
() %
MAX_STRIDE
;
91
size_t
offset
=
rnd
() & 0xF;
92
int
left_ref =
rnd
() & 0xFF, top_ref =
rnd
() & 0xFF;
93
int
left_new = left_ref, top_new = top_ref;
94
95
memset(dst_ref, 0,
sizeof
(dst_ref));
96
memset(dst_new, 0,
sizeof
(dst_new));
97
98
randomize_buffers
(
src1
,
sizeof
(
src1
));
99
randomize_buffers
(
src2
,
sizeof
(
src2
));
100
101
call_ref
(dst_ref +
offset
,
src1
+
offset
,
src2
+
offset
,
width
, &left_ref, &top_ref);
102
call_new
(dst_new +
offset
,
src1
+
offset
,
src2
+
offset
,
width
, &left_new, &top_new);
103
if
(left_new != left_ref || top_ref != top_new ||
104
memcmp(dst_ref, dst_new,
width
+
offset
))
105
fail
();
106
bench_new
(dst_new,
src1
,
src2
,
MAX_STRIDE
, &left_new, &top_new);
107
}
108
}
109
110
static
void
check_sub_left_pred
(
LLVidEncDSPContext
*
c
)
111
{
112
LOCAL_ALIGNED_32
(uint8_t, dst0, [
MAX_STRIDE
*
MAX_HEIGHT
]);
113
LOCAL_ALIGNED_32
(uint8_t, dst1, [
MAX_STRIDE
*
MAX_HEIGHT
]);
114
LOCAL_ALIGNED_32
(uint8_t,
src
, [
MAX_STRIDE
*
MAX_HEIGHT
]);
115
116
declare_func
(
void
, uint8_t *
dst
,
const
uint8_t *
src
,
117
ptrdiff_t
stride
, ptrdiff_t
width
,
int
height
);
118
119
if
(
check_func
(
c
->sub_left_predict,
"sub_left_predict"
)) {
120
randomize_buffers
(
src
,
MAX_STRIDE
*
MAX_HEIGHT
);
121
122
for
(
size_t
i
= 0;
i
<
FF_ARRAY_ELEMS
(
planes
);
i
++) {
123
memset(dst0, 0,
MAX_STRIDE
*
MAX_HEIGHT
);
124
memset(dst1, 0,
MAX_STRIDE
*
MAX_HEIGHT
);
125
call_ref
(dst0,
src
,
planes
[
i
].
s
,
planes
[
i
].
w
,
planes
[
i
].
h
);
126
call_new
(dst1,
src
,
planes
[
i
].
s
,
planes
[
i
].
w
,
planes
[
i
].
h
);
127
if
(memcmp(dst0, dst1,
planes
[
i
].
w
*
planes
[
i
].
h
))
128
fail
();
129
}
130
bench_new
(dst1,
src
,
planes
[4].
s
,
planes
[4].
w
,
planes
[4].
h
);
131
}
132
}
133
134
void
checkasm_check_llvidencdsp
(
void
)
135
{
136
LLVidEncDSPContext
c
;
137
ff_llvidencdsp_init
(&
c
);
138
139
check_diff_bytes
(&
c
);
140
report
(
"diff_bytes"
);
141
142
check_sub_median_pred
(&
c
);
143
report
(
"sub_median_pred"
);
144
145
check_sub_left_pred
(&
c
);
146
report
(
"sub_left_predict"
);
147
}
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition
dsp.h:87
left
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
Definition
bitstream_template.h:170
i
#define i(width, name, range_min, range_max)
Definition
cbs_h264.c:63
s
#define s(width, name)
Definition
cbs_vp9.c:198
checkasm.h
rnd
#define rnd
Definition
checkasm.h:136
common.h
common internal and external API header
declare_func
#define declare_func
Definition
test.h:489
fail
#define fail
Definition
test.h:479
bench_new
#define bench_new
Definition
test.h:487
check_func
#define check_func
Definition
test.h:481
call_new
#define call_new
Definition
test.h:486
call_ref
#define call_ref
Definition
test.h:485
report
#define report
Definition
test.h:480
src2
const pixel * src2
Definition
h264pred_template.c:421
intreadwrite.h
offset
unsigned offset
Definition
libaomenc.c:763
check_sub_left_pred
static void check_sub_left_pred(LLVidEncDSPContext *c)
Definition
llvidencdsp.c:110
planes
static const struct @257111027162314367033347246032313251342043035002 planes[]
checkasm_check_llvidencdsp
void checkasm_check_llvidencdsp(void)
Definition
llvidencdsp.c:134
randomize_buffers
#define randomize_buffers(buf, size)
Definition
llvidencdsp.c:31
check_diff_bytes
static void check_diff_bytes(LLVidEncDSPContext *c)
Definition
llvidencdsp.c:46
check_sub_median_pred
static void check_sub_median_pred(LLVidEncDSPContext *c)
Definition
llvidencdsp.c:77
w
uint8_t w
Definition
llvidencdsp.c:39
ff_llvidencdsp_init
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
Definition
lossless_videoencdsp.c:100
lossless_videoencdsp.h
mem_internal.h
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition
mem_internal.h:132
BUF_SIZE
#define BUF_SIZE
Definition
setpts.c:159
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition
sinewin_tablegen.c:29
LLVidEncDSPContext
Definition
lossless_videoencdsp.h:25
stride
#define stride
Definition
h264pred_template.c:536
src1
#define src1
Definition
h264pred.c:141
src0
#define src0
Definition
h264pred.c:140
MAX_HEIGHT
#define MAX_HEIGHT
Definition
hpeldsp.c:30
MAX_STRIDE
#define MAX_STRIDE
Definition
hpeldsp.c:31
src
#define src
Definition
vp8dsp.c:248
height
#define height
Definition
dsp.h:89
width
#define width
Definition
dsp.h:89
h
h
Definition
vp9dsp_template.c:2070
c
static double c[64]
Definition
vsrc_mptestsrc.c:89
Generated on Sun Aug 16 2026 20:21:05 for FFmpeg by
1.13.2