FFmpeg
Loading...
Searching...
No Matches
tests
checkasm
af_afir.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 "config.h"
20
21
#include <
float.h
>
22
#include <stdint.h>
23
#include <stdio.h>
24
#include <string.h>
25
26
#include "
libavfilter/af_afirdsp.h
"
27
#include "
libavutil/internal.h
"
28
#include "
libavutil/mem_internal.h
"
29
#include "
checkasm.h
"
30
31
#define LEN 256
32
33
static
void
test_fcmul_add
(
AudioFIRDSPContext
*fir)
34
{
35
#define BUF_SIZE LEN*2+8
36
LOCAL_ALIGNED_32
(
float
,
src0
, [
BUF_SIZE
]);
37
LOCAL_ALIGNED_32
(
float
,
src1
, [
BUF_SIZE
]);
38
LOCAL_ALIGNED_32
(
float
,
src2
, [
BUF_SIZE
]);
39
40
randomize_stddev
(
src0
,
BUF_SIZE
, 10.0);
41
randomize_stddev
(
src1
,
BUF_SIZE
, 10.0);
42
randomize_stddev
(
src2
,
BUF_SIZE
, 10.0);
43
44
if
(
check_func
(fir->
fcmul_add
,
"fcmul_add"
)) {
45
LOCAL_ALIGNED_32
(
float
, cdst, [
BUF_SIZE
]);
46
LOCAL_ALIGNED_32
(
float
, odst, [
BUF_SIZE
]);
47
int
i
;
48
49
declare_func
(
void
,
float
*sum,
const
float
*t,
const
float
*
c
,
50
ptrdiff_t
len
);
51
52
memcpy(cdst,
src0
, (
BUF_SIZE
) *
sizeof
(
float
));
53
memcpy(odst,
src0
, (
BUF_SIZE
) *
sizeof
(
float
));
54
call_ref
(cdst,
src1
,
src2
,
LEN
);
55
call_new
(odst,
src1
,
src2
,
LEN
);
56
for
(
i
= 0;
i
<=
LEN
*2;
i
++) {
57
int
idx =
i
& ~1;
58
float
cre =
src2
[idx];
59
float
cim =
src2
[idx + 1];
60
float
tre =
src1
[idx];
61
float
tim =
src1
[idx + 1];
62
double
t =
fabs
(
src0
[
i
]) +
63
fabs
(tre) +
fabs
(tim) +
fabs
(cre) +
fabs
(cim) +
64
fabs
(tre * cre) +
fabs
(tim * cim) +
65
fabs
(tre * cim) +
fabs
(tim * cre) +
66
fabs
(tre * cre - tim * cim) +
67
fabs
(tre * cim + tim * cre) +
68
fabs
(cdst[
i
]) + 1.0;
69
if
(!
float_near_abs_eps
(cdst[
i
], odst[
i
], t * 2 * FLT_EPSILON)) {
70
fprintf(stderr,
"%d: %- .12f - %- .12f = % .12g\n"
,
71
i
, cdst[
i
], odst[
i
], cdst[
i
] - odst[
i
]);
72
fail
();
73
break
;
74
}
75
}
76
memcpy(odst,
src0
, (
BUF_SIZE
) *
sizeof
(
float
));
77
bench_new
(odst,
src1
,
src2
,
LEN
);
78
}
79
80
report
(
"fcmul_add"
);
81
}
82
83
static
void
test_dcmul_add
(
AudioFIRDSPContext
*fir)
84
{
85
#define BUF_SIZE LEN*2+8
86
LOCAL_ALIGNED_32
(
double
,
src0
, [
BUF_SIZE
]);
87
LOCAL_ALIGNED_32
(
double
,
src1
, [
BUF_SIZE
]);
88
LOCAL_ALIGNED_32
(
double
,
src2
, [
BUF_SIZE
]);
89
90
randomize_stddev_dbl
(
src0
,
BUF_SIZE
, 10.0);
91
randomize_stddev_dbl
(
src1
,
BUF_SIZE
, 10.0);
92
randomize_stddev_dbl
(
src2
,
BUF_SIZE
, 10.0);
93
94
if
(
check_func
(fir->
dcmul_add
,
"dcmul_add"
)) {
95
LOCAL_ALIGNED_32
(
double
, cdst, [
BUF_SIZE
]);
96
LOCAL_ALIGNED_32
(
double
, odst, [
BUF_SIZE
]);
97
int
i
;
98
99
declare_func
(
void
,
double
*sum,
const
double
*t,
const
double
*
c
,
100
ptrdiff_t
len
);
101
102
memcpy(cdst,
src0
, (
BUF_SIZE
) *
sizeof
(
double
));
103
memcpy(odst,
src0
, (
BUF_SIZE
) *
sizeof
(
double
));
104
call_ref
(cdst,
src1
,
src2
,
LEN
);
105
call_new
(odst,
src1
,
src2
,
LEN
);
106
for
(
i
= 0;
i
<=
LEN
*2;
i
++) {
107
int
idx =
i
& ~1;
108
double
cre =
src2
[idx];
109
double
cim =
src2
[idx + 1];
110
double
tre =
src1
[idx];
111
double
tim =
src1
[idx + 1];
112
double
t =
fabs
(
src0
[
i
]) +
113
fabs
(tre) +
fabs
(tim) +
fabs
(cre) +
fabs
(cim) +
114
fabs
(tre * cre) +
fabs
(tim * cim) +
115
fabs
(tre * cim) +
fabs
(tim * cre) +
116
fabs
(tre * cre - tim * cim) +
117
fabs
(tre * cim + tim * cre) +
118
fabs
(cdst[
i
]) + 1.0;
119
if
(!
double_near_abs_eps
(cdst[
i
], odst[
i
], t * 2 * FLT_EPSILON)) {
120
fprintf(stderr,
"%d: %- .12f - %- .12f = % .12g\n"
,
121
i
, cdst[
i
], odst[
i
], cdst[
i
] - odst[
i
]);
122
fail
();
123
break
;
124
}
125
}
126
memcpy(odst,
src0
, (
BUF_SIZE
) *
sizeof
(
double
));
127
bench_new
(odst,
src1
,
src2
,
LEN
);
128
}
129
130
report
(
"dcmul_add"
);
131
}
132
133
134
void
checkasm_check_afir
(
void
)
135
{
136
AudioFIRDSPContext
fir = { 0 };
137
138
ff_afir_init
(&fir);
139
test_fcmul_add
(&fir);
140
test_dcmul_add
(&fir);
141
}
af_afirdsp.h
ff_afir_init
static av_unused void ff_afir_init(AudioFIRDSPContext *dsp)
Definition
af_afirdsp.h:73
LEN
#define LEN
i
#define i(width, name, range_min, range_max)
Definition
cbs_h264.c:63
checkasm.h
randomize_stddev
#define randomize_stddev(buf, size, stddev)
Definition
checkasm.h:139
randomize_stddev_dbl
#define randomize_stddev_dbl(buf, size, stddev)
Definition
checkasm.h:141
fabs
static __device__ float fabs(float a)
Definition
cuda_runtime.h:182
float.h
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
float_near_abs_eps
#define float_near_abs_eps
Definition
utils.h:449
report
#define report
Definition
test.h:480
double_near_abs_eps
#define double_near_abs_eps
Definition
utils.h:454
src2
const pixel * src2
Definition
h264pred_template.c:421
internal.h
common internal API header
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
AudioFIRDSPContext
Definition
af_afirdsp.h:29
AudioFIRDSPContext::fcmul_add
void(* fcmul_add)(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition
af_afirdsp.h:30
AudioFIRDSPContext::dcmul_add
void(* dcmul_add)(double *sum, const double *t, const double *c, ptrdiff_t len)
Definition
af_afirdsp.h:32
checkasm_check_afir
void checkasm_check_afir(void)
Definition
af_afir.c:134
test_fcmul_add
static void test_fcmul_add(AudioFIRDSPContext *fir)
Definition
af_afir.c:33
test_dcmul_add
static void test_dcmul_add(AudioFIRDSPContext *fir)
Definition
af_afir.c:83
src1
#define src1
Definition
h264pred.c:141
src0
#define src0
Definition
h264pred.c:140
len
int len
Definition
vorbis_enc_data.h:426
c
static double c[64]
Definition
vsrc_mptestsrc.c:89
Generated on Sun Aug 23 2026 19:21:01 for FFmpeg by
1.13.2