FFmpeg
vorbisdsp.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 
23 #include "libavutil/mem_internal.h"
24 
25 #include "libavcodec/vorbisdsp.h"
26 
27 #include "checkasm.h"
28 
29 #define LEN 512
30 
31 #define randomize_buffer(buf) \
32 do { \
33  double bmg[2], stddev = 10.0, mean = 0.0; \
34  \
35  for (int i = 0; i < LEN; 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_inverse_coupling(void)
43 {
44  LOCAL_ALIGNED_16(float, src0, [LEN]);
45  LOCAL_ALIGNED_16(float, src1, [LEN]);
46  LOCAL_ALIGNED_16(float, cdst, [LEN]);
47  LOCAL_ALIGNED_16(float, odst, [LEN]);
48  LOCAL_ALIGNED_16(float, cdst1, [LEN]);
49  LOCAL_ALIGNED_16(float, odst1, [LEN]);
50 
51  declare_func(void, float *av_restrict mag, float *av_restrict ang,
52  ptrdiff_t blocksize);
53 
56 
57  memcpy(cdst, src0, LEN * sizeof(*src0));
58  memcpy(cdst1, src1, LEN * sizeof(*src1));
59  memcpy(odst, src0, LEN * sizeof(*src0));
60  memcpy(odst1, src1, LEN * sizeof(*src1));
61 
62  call_ref(cdst, cdst1, LEN);
63  call_new(odst, odst1, LEN);
64  for (int i = 0; i < LEN; i++) {
65  if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON) ||
66  !float_near_abs_eps(cdst1[i], odst1[i], FLT_EPSILON)) {
67  fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
68  i, cdst[i], odst[i], cdst[i] - odst[i]);
69  fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
70  i, cdst1[i], odst1[i], cdst1[i] - odst1[i]);
71  fail();
72  break;
73  }
74  }
76 }
77 
79 {
80  VorbisDSPContext dsp;
81 
82  ff_vorbisdsp_init(&dsp);
83 
84  if (check_func(dsp.vorbis_inverse_coupling, "inverse_coupling"))
86  report("inverse_coupling");
87 }
checkasm_check_vorbisdsp
void checkasm_check_vorbisdsp(void)
Definition: vorbisdsp.c:78
mem_internal.h
src1
const pixel * src1
Definition: h264pred_template.c:421
float_near_abs_eps
int float_near_abs_eps(float a, float b, float eps)
Definition: checkasm.c:362
check_func
#define check_func(func,...)
Definition: checkasm.h:129
float.h
call_ref
#define call_ref(...)
Definition: checkasm.h:144
fail
#define fail()
Definition: checkasm.h:138
checkasm.h
VorbisDSPContext
Definition: vorbisdsp.h:24
LEN
#define LEN
Definition: vorbisdsp.c:29
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:129
call_new
#define call_new(...)
Definition: checkasm.h:226
VorbisDSPContext::vorbis_inverse_coupling
void(* vorbis_inverse_coupling)(float *mag, float *ang, ptrdiff_t blocksize)
Definition: vorbisdsp.h:26
vorbisdsp.h
randomize_buffer
#define randomize_buffer(buf)
Definition: vorbisdsp.c:31
report
#define report
Definition: checkasm.h:141
bench_new
#define bench_new(...)
Definition: checkasm.h:291
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
test_inverse_coupling
static void test_inverse_coupling(void)
Definition: vorbisdsp.c:42
ff_vorbisdsp_init
av_cold void ff_vorbisdsp_init(VorbisDSPContext *dsp)
Definition: vorbisdsp.c:46
src0
const pixel *const src0
Definition: h264pred_template.c:420
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:133