webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
mdct.h
Go to the documentation of this file.
1 /* Copyright (c) 2007-2008 CSIRO
2  Copyright (c) 2007-2008 Xiph.Org Foundation
3  Written by Jean-Marc Valin */
4 /*
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  - Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  - Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 /* This is a simple MDCT implementation that uses a N/4 complex FFT
30  to do most of the work. It should be relatively straightforward to
31  plug in pretty much and FFT here.
32 
33  This replaces the Vorbis FFT (and uses the exact same API), which
34  was a bit too messy and that was ending up duplicating code
35  (might as well use the same FFT everywhere).
36 
37  The algorithm is similar to (and inspired from) Fabrice Bellard's
38  MDCT implementation in FFMPEG, but has differences in signs, ordering
39  and scaling in many places.
40 */
41 
42 #ifndef MDCT_H
43 #define MDCT_H
44 
45 #include "opus_defines.h"
46 #include "kiss_fft.h"
47 #include "arch.h"
48 
49 typedef struct {
50  int n;
51  int maxshift;
52  const kiss_fft_state *kfft[4];
53  const kiss_twiddle_scalar * OPUS_RESTRICT trig;
54 } mdct_lookup;
55 
56 #if defined(HAVE_ARM_NE10)
57 #include "arm/mdct_arm.h"
58 #endif
59 
60 
61 int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch);
62 void clt_mdct_clear(mdct_lookup *l, int arch);
63 
66  kiss_fft_scalar * OPUS_RESTRICT out,
67  const opus_val16 *window, int overlap,
68  int shift, int stride, int arch);
69 
73  kiss_fft_scalar * OPUS_RESTRICT out,
74  const opus_val16 * OPUS_RESTRICT window,
75  int overlap, int shift, int stride, int arch);
76 
77 #if !defined(OVERRIDE_OPUS_MDCT)
78 /* Is run-time CPU detection enabled on this platform? */
79 #if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10)
80 
81 extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(
82  const mdct_lookup *l, kiss_fft_scalar *in,
83  kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window,
84  int overlap, int shift, int stride, int arch);
85 
86 #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
87  ((*CLT_MDCT_FORWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \
88  _window, _overlap, _shift, \
89  _stride, _arch))
90 
91 extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(
92  const mdct_lookup *l, kiss_fft_scalar *in,
93  kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window,
94  int overlap, int shift, int stride, int arch);
95 
96 #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
97  (*CLT_MDCT_BACKWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \
98  _window, _overlap, _shift, \
99  _stride, _arch)
100 
101 #else /* if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) */
102 
103 #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
104  clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch)
105 
106 #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
107  clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch)
108 
109 #endif /* end if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */
110 #endif /* end if !defined(OVERRIDE_OPUS_MDCT) */
111 
112 #endif
void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *OPUS_RESTRICT out, const opus_val16 *OPUS_RESTRICT window, int overlap, int shift, int stride, int arch)
Definition: mdct.c:242
void clt_mdct_clear(mdct_lookup *l, int arch)
#define OPUS_ARCHMASK
Definition: cpu_support.h:63
Definition: kiss_fft.h:86
Opus reference implementation constants.
float opus_val16
Definition: arch.h:148
void
Definition: AVFoundationCFSoftLinking.h:81
int int * out
Definition: gcc-loops.cpp:206
int maxshift
Definition: mdct.h:51
#define kiss_fft_scalar
Definition: kiss_fft.h:59
void shift(ExecState *exec, JSObject *thisObj, unsigned header, unsigned currentCount, unsigned resultCount, unsigned length)
Definition: ArrayPrototype.cpp:291
#define N
Definition: gcc-loops.cpp:14
string arch
Definition: runtests.py:65
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:934
void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *OPUS_RESTRICT out, const opus_val16 *window, int overlap, int shift, int stride, int arch)
Definition: mdct.c:119
int n
Definition: mdct.h:50
const kiss_twiddle_scalar *OPUS_RESTRICT trig
Definition: mdct.h:53
Various architecture definitions for CELT.
int clt_mdct_init(mdct_lookup *l, int N, int maxshift, int arch)
Definition: mdct.h:49
EGLImageKHR EGLint EGLint EGLint * stride
Definition: eglext.h:851
#define kiss_twiddle_scalar
Definition: kiss_fft.h:60