FFmpeg
4.4.4
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
24
#include "
libavfilter/af_afir.h
"
25
#include "
libavutil/internal.h
"
26
#include "
libavutil/mem_internal.h
"
27
#include "
checkasm.h
"
28
29
#define LEN 256
30
31
#define randomize_buffer(buf) \
32
do { \
33
int i; \
34
double bmg[2], stddev = 10.0, mean = 0.0; \
35
\
36
for (i = 0; i < LEN*2+8; i += 2) { \
37
av_bmg_get(&checkasm_lfg, bmg); \
38
buf[i] = bmg[0] * stddev + mean; \
39
buf[i + 1] = bmg[1] * stddev + mean; \
40
} \
41
} while(0);
42
43
static
void
test_fcmul_add
(
const
float
*
src0
,
const
float
*
src1
,
const
float
*src2)
44
{
45
LOCAL_ALIGNED_32
(
float
, cdst, [
LEN
*2+8]);
46
LOCAL_ALIGNED_32
(
float
, odst, [
LEN
*2+8]);
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
, (
LEN
*2+8) *
sizeof
(
float
));
53
memcpy(odst,
src0
, (
LEN
*2+8) *
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
, (
LEN
*2+8) *
sizeof
(
float
));
77
bench_new
(odst,
src1
, src2,
LEN
);
78
}
79
80
void
checkasm_check_afir
(
void
)
81
{
82
LOCAL_ALIGNED_32
(
float
,
src0
, [
LEN
*2+8]);
83
LOCAL_ALIGNED_32
(
float
,
src1
, [
LEN
*2+8]);
84
LOCAL_ALIGNED_32
(
float
, src2, [
LEN
*2+8]);
85
AudioFIRDSPContext
fir = { 0 };
86
87
ff_afir_init
(&fir);
88
89
randomize_buffer
(
src0
);
90
randomize_buffer
(
src1
);
91
randomize_buffer
(src2);
92
93
if
(
check_func
(fir.
fcmul_add
,
"fcmul_add"
))
94
test_fcmul_add
(
src0
,
src1
, src2);
95
report
(
"fcmul_add"
);
96
}
af_afir.h
float_near_abs_eps
int float_near_abs_eps(float a, float b, float eps)
Definition:
checkasm.c:327
checkasm.h
call_new
#define call_new(...)
Definition:
checkasm.h:211
check_func
#define check_func(func,...)
Definition:
checkasm.h:124
call_ref
#define call_ref(...)
Definition:
checkasm.h:139
fail
#define fail()
Definition:
checkasm.h:133
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:128
report
#define report
Definition:
checkasm.h:136
bench_new
#define bench_new(...)
Definition:
checkasm.h:271
config.h
fabs
static __device__ float fabs(float a)
Definition:
cuda_runtime.h:182
float.h
i
int i
Definition:
input.c:407
ff_afir_init
void ff_afir_init(AudioFIRDSPContext *dsp)
Definition:
af_afir.c:826
internal.h
common internal API header
mem_internal.h
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition:
mem_internal.h:136
AudioFIRDSPContext
Definition:
af_afir.h:56
AudioFIRDSPContext::fcmul_add
void(* fcmul_add)(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition:
af_afir.h:57
LEN
#define LEN
Definition:
af_afir.c:29
checkasm_check_afir
void checkasm_check_afir(void)
Definition:
af_afir.c:80
test_fcmul_add
static void test_fcmul_add(const float *src0, const float *src1, const float *src2)
Definition:
af_afir.c:43
randomize_buffer
#define randomize_buffer(buf)
Definition:
af_afir.c:31
src1
#define src1
Definition:
h264pred.c:140
src0
#define src0
Definition:
h264pred.c:139
len
int len
Definition:
vorbis_enc_data.h:452
c
static double c[64]
Definition:
vsrc_mptestsrc.c:92
Generated on Fri Apr 14 2023 15:41:56 for FFmpeg by
1.9.1