Libav
tests
checkasm
dcadsp.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Janne Grunau
3
*
4
* This file is part of Libav.
5
*
6
* Libav 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
* Libav 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 Libav; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*/
20
21
#include <math.h>
22
#include <string.h>
23
#include <stdlib.h>
24
25
#include "
libavutil/internal.h
"
26
#include "
libavutil/intfloat.h
"
27
#include "
libavcodec/dca.h
"
28
#include "
libavcodec/dcadsp.h
"
29
#include "
libavcodec/dcadata.h
"
30
31
#include "
checkasm.h
"
32
33
#define randomize_lfe_fir(size) \
34
do { \
35
int i; \
36
for (i = 0; i < size; i++) { \
37
float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \
38
in[i] = f; \
39
} \
40
for (i = 0; i < 256; i++) { \
41
float f = (float)rnd() / (UINT_MAX >> 1) - 1.0f; \
42
coeffs[i] = f; \
43
} \
44
} while (0)
45
46
#define check_lfe_fir(decifactor, eps) \
47
do { \
48
LOCAL_ALIGNED_16(float, in, [256 / decifactor]); \
49
LOCAL_ALIGNED_16(float, out0, [decifactor * 2]); \
50
LOCAL_ALIGNED_16(float, out1, [decifactor * 2]); \
51
LOCAL_ALIGNED_16(float, coeffs, [256]); \
52
int i; \
53
const float * in_ptr = in + (256 / decifactor) - 1; \
54
declare_func(void, float *out, const float *in, const float *coeffs); \
55
/* repeat the test several times */
\
56
for (i = 0; i < 32; i++) { \
57
int j; \
58
memset(out0, 0, sizeof(*out0) * 2 * decifactor); \
59
memset(out1, 0xFF, sizeof(*out1) * 2 * decifactor); \
60
randomize_lfe_fir(256 / decifactor); \
61
call_ref(out0, in_ptr, coeffs); \
62
call_new(out1, in_ptr, coeffs); \
63
for (j = 0; j < 2 * decifactor; j++) { \
64
if (!float_near_abs_eps(out0[j], out1[j], eps)) { \
65
if (0) { \
66
union av_intfloat32 x, y; x.f = out0[j]; y.f = out1[j]; \
67
fprintf(stderr, "%3d: %11g (0x%08x); %11g (0x%08x)\n", \
68
j, x.f, x.i, y.f, y.i); \
69
} \
70
fail(); \
71
break; \
72
} \
73
} \
74
bench_new(out1, in_ptr, coeffs); \
75
} \
76
} while (0)
77
78
void
checkasm_check_dcadsp
(
void
)
79
{
80
DCADSPContext
c;
81
82
ff_dcadsp_init
(&c);
83
84
/* values are limited to {-8, 8} so absolute epsilon is good enough */
85
if
(
check_func
(c.
lfe_fir
[0],
"dca_lfe_fir0"
))
86
check_lfe_fir
(32, 1.0e-6f);
87
88
if
(
check_func
(c.
lfe_fir
[1],
"dca_lfe_fir1"
))
89
check_lfe_fir
(64, 1.0e-6f);
90
91
report
(
"dcadsp"
);
92
}
DCADSPContext::lfe_fir
void(* lfe_fir[2])(float *out, const float *in, const float *coefs)
Definition:
dcadsp.h:31
dca.h
ff_dcadsp_init
av_cold void ff_dcadsp_init(DCADSPContext *s)
Definition:
dcadsp.c:120
checkasm_check_dcadsp
void checkasm_check_dcadsp(void)
Definition:
dcadsp.c:78
report
#define report
Definition:
checkasm.h:83
intfloat.h
checkasm.h
internal.h
common internal API header
check_lfe_fir
#define check_lfe_fir(decifactor, eps)
Definition:
dcadsp.c:46
dcadsp.h
DCADSPContext
Definition:
dcadsp.h:30
check_func
#define check_func(func,...)
Definition:
checkasm.h:72
dcadata.h
Generated on Fri Dec 1 2017 07:11:43 for Libav by
1.8.13