FFmpeg
4.2.1
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 "
checkasm.h
"
27
28
#define LEN 256
29
30
#define randomize_buffer(buf) \
31
do { \
32
int i; \
33
double bmg[2], stddev = 10.0, mean = 0.0; \
34
\
35
for (i = 0; i < LEN*2+8; i += 2) { \
36
av_bmg_get(&checkasm_lfg, bmg); \
37
buf[i] = bmg[0] * stddev + mean; \
38
buf[i + 1] = bmg[1] * stddev + mean; \
39
} \
40
} while(0);
41
42
static
void
test_fcmul_add
(
const
float
*
src0
,
const
float
*
src1
,
const
float
*src2)
43
{
44
LOCAL_ALIGNED_32
(
float
, cdst, [
LEN
*2+8]);
45
LOCAL_ALIGNED_32
(
float
, odst, [
LEN
*2+8]);
46
int
i
;
47
48
declare_func
(
void
,
float
*sum,
const
float
*t,
const
float
*
c
,
49
ptrdiff_t
len
);
50
51
memcpy(cdst, src0, (
LEN
*2+8) *
sizeof
(
float
));
52
memcpy(odst, src0, (
LEN
*2+8) *
sizeof
(
float
));
53
call_ref
(cdst, src1, src2,
LEN
);
54
call_new
(odst, src1, src2,
LEN
);
55
for
(i = 0; i <=
LEN
*2; i++) {
56
if
(!
float_near_abs_eps
(cdst[i], odst[i], 6.2e-05)) {
57
fprintf(stderr,
"%d: %- .12f - %- .12f = % .12g\n"
,
58
i, cdst[i], odst[i], cdst[i] - odst[i]);
59
fail
();
60
break
;
61
}
62
}
63
memcpy(odst, src0, (
LEN
*2+8) *
sizeof
(
float
));
64
bench_new
(odst, src1, src2,
LEN
);
65
}
66
67
void
checkasm_check_afir
(
void
)
68
{
69
LOCAL_ALIGNED_32
(
float
,
src0
, [
LEN
*2+8]);
70
LOCAL_ALIGNED_32
(
float
,
src1
, [
LEN
*2+8]);
71
LOCAL_ALIGNED_32
(
float
, src2, [
LEN
*2+8]);
72
AudioFIRDSPContext
fir = { 0 };
73
74
ff_afir_init
(&fir);
75
76
randomize_buffer
(
src0
);
77
randomize_buffer
(
src1
);
78
randomize_buffer
(src2);
79
80
if
(
check_func
(fir.
fcmul_add
,
"fcmul_add"
))
81
test_fcmul_add
(
src0
,
src1
, src2);
82
report
(
"fcmul_add"
);
83
}
checkasm_check_afir
void checkasm_check_afir(void)
Definition:
af_afir.c:67
test_fcmul_add
static void test_fcmul_add(const float *src0, const float *src1, const float *src2)
Definition:
af_afir.c:42
report
#define report
Definition:
checkasm.h:123
float_near_abs_eps
int float_near_abs_eps(float a, float b, float eps)
Definition:
checkasm.c:306
float.h
i
#define i(width, name, range_min, range_max)
Definition:
cbs_h2645.c:259
checkasm.h
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:115
AudioFIRDSPContext
Definition:
af_afir.h:56
fail
#define fail()
Definition:
checkasm.h:120
internal.h
common internal API header
AudioFIRDSPContext::fcmul_add
void(* fcmul_add)(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition:
af_afir.h:57
ff_afir_init
void ff_afir_init(AudioFIRDSPContext *dsp)
Definition:
af_afir.c:756
call_ref
#define call_ref(...)
Definition:
checkasm.h:126
src1
#define src1
Definition:
h264pred.c:139
LEN
#define LEN
Definition:
af_afir.c:28
randomize_buffer
#define randomize_buffer(buf)
Definition:
af_afir.c:30
check_func
#define check_func(func,...)
Definition:
checkasm.h:111
src0
#define src0
Definition:
h264pred.c:138
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition:
internal.h:137
af_afir.h
c
static double c[64]
Definition:
vsrc_mptestsrc.c:87
len
int len
Definition:
vorbis_enc_data.h:452
bench_new
#define bench_new(...)
Definition:
checkasm.h:253
call_new
#define call_new(...)
Definition:
checkasm.h:193
Generated on Thu Sep 26 2019 14:53:49 for FFmpeg by
1.8.13