FFmpeg
Loading...
Searching...
No Matches
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
27#include "libavutil/internal.h"
29#include "checkasm.h"
30
31#define LEN 256
32
34{
35#define BUF_SIZE LEN*2+8
39
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
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
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
135{
136 AudioFIRDSPContext fir = { 0 };
137
138 ff_afir_init(&fir);
139 test_fcmul_add(&fir);
140 test_dcmul_add(&fir);
141}
static av_unused void ff_afir_init(AudioFIRDSPContext *dsp)
Definition af_afirdsp.h:73
#define LEN
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define randomize_stddev(buf, size, stddev)
Definition checkasm.h:139
#define randomize_stddev_dbl(buf, size, stddev)
Definition checkasm.h:141
static __device__ float fabs(float a)
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define float_near_abs_eps
Definition utils.h:449
#define report
Definition test.h:480
#define double_near_abs_eps
Definition utils.h:454
const pixel * src2
common internal API header
#define LOCAL_ALIGNED_32(t, v,...)
#define BUF_SIZE
Definition setpts.c:159
void(* fcmul_add)(float *sum, const float *t, const float *c, ptrdiff_t len)
Definition af_afirdsp.h:30
void(* dcmul_add)(double *sum, const double *t, const double *c, ptrdiff_t len)
Definition af_afirdsp.h:32
void checkasm_check_afir(void)
Definition af_afir.c:134
static void test_fcmul_add(AudioFIRDSPContext *fir)
Definition af_afir.c:33
static void test_dcmul_add(AudioFIRDSPContext *fir)
Definition af_afir.c:83
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
int len
static double c[64]