annotate src/opus-1.3/celt/mdct.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 /* Copyright (c) 2007-2008 CSIRO
Chris@69 2 Copyright (c) 2007-2008 Xiph.Org Foundation
Chris@69 3 Written by Jean-Marc Valin */
Chris@69 4 /*
Chris@69 5 Redistribution and use in source and binary forms, with or without
Chris@69 6 modification, are permitted provided that the following conditions
Chris@69 7 are met:
Chris@69 8
Chris@69 9 - Redistributions of source code must retain the above copyright
Chris@69 10 notice, this list of conditions and the following disclaimer.
Chris@69 11
Chris@69 12 - Redistributions in binary form must reproduce the above copyright
Chris@69 13 notice, this list of conditions and the following disclaimer in the
Chris@69 14 documentation and/or other materials provided with the distribution.
Chris@69 15
Chris@69 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@69 17 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@69 18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@69 19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
Chris@69 20 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@69 21 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@69 22 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@69 23 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@69 24 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@69 25 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@69 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@69 27 */
Chris@69 28
Chris@69 29 /* This is a simple MDCT implementation that uses a N/4 complex FFT
Chris@69 30 to do most of the work. It should be relatively straightforward to
Chris@69 31 plug in pretty much and FFT here.
Chris@69 32
Chris@69 33 This replaces the Vorbis FFT (and uses the exact same API), which
Chris@69 34 was a bit too messy and that was ending up duplicating code
Chris@69 35 (might as well use the same FFT everywhere).
Chris@69 36
Chris@69 37 The algorithm is similar to (and inspired from) Fabrice Bellard's
Chris@69 38 MDCT implementation in FFMPEG, but has differences in signs, ordering
Chris@69 39 and scaling in many places.
Chris@69 40 */
Chris@69 41
Chris@69 42 #ifndef MDCT_H
Chris@69 43 #define MDCT_H
Chris@69 44
Chris@69 45 #include "opus_defines.h"
Chris@69 46 #include "kiss_fft.h"
Chris@69 47 #include "arch.h"
Chris@69 48
Chris@69 49 typedef struct {
Chris@69 50 int n;
Chris@69 51 int maxshift;
Chris@69 52 const kiss_fft_state *kfft[4];
Chris@69 53 const kiss_twiddle_scalar * OPUS_RESTRICT trig;
Chris@69 54 } mdct_lookup;
Chris@69 55
Chris@69 56 #if defined(HAVE_ARM_NE10)
Chris@69 57 #include "arm/mdct_arm.h"
Chris@69 58 #endif
Chris@69 59
Chris@69 60
Chris@69 61 int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch);
Chris@69 62 void clt_mdct_clear(mdct_lookup *l, int arch);
Chris@69 63
Chris@69 64 /** Compute a forward MDCT and scale by 4/N, trashes the input array */
Chris@69 65 void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in,
Chris@69 66 kiss_fft_scalar * OPUS_RESTRICT out,
Chris@69 67 const opus_val16 *window, int overlap,
Chris@69 68 int shift, int stride, int arch);
Chris@69 69
Chris@69 70 /** Compute a backward MDCT (no scaling) and performs weighted overlap-add
Chris@69 71 (scales implicitly by 1/2) */
Chris@69 72 void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in,
Chris@69 73 kiss_fft_scalar * OPUS_RESTRICT out,
Chris@69 74 const opus_val16 * OPUS_RESTRICT window,
Chris@69 75 int overlap, int shift, int stride, int arch);
Chris@69 76
Chris@69 77 #if !defined(OVERRIDE_OPUS_MDCT)
Chris@69 78 /* Is run-time CPU detection enabled on this platform? */
Chris@69 79 #if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10)
Chris@69 80
Chris@69 81 extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(
Chris@69 82 const mdct_lookup *l, kiss_fft_scalar *in,
Chris@69 83 kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window,
Chris@69 84 int overlap, int shift, int stride, int arch);
Chris@69 85
Chris@69 86 #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
Chris@69 87 ((*CLT_MDCT_FORWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \
Chris@69 88 _window, _overlap, _shift, \
Chris@69 89 _stride, _arch))
Chris@69 90
Chris@69 91 extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(
Chris@69 92 const mdct_lookup *l, kiss_fft_scalar *in,
Chris@69 93 kiss_fft_scalar * OPUS_RESTRICT out, const opus_val16 *window,
Chris@69 94 int overlap, int shift, int stride, int arch);
Chris@69 95
Chris@69 96 #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
Chris@69 97 (*CLT_MDCT_BACKWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \
Chris@69 98 _window, _overlap, _shift, \
Chris@69 99 _stride, _arch)
Chris@69 100
Chris@69 101 #else /* if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) */
Chris@69 102
Chris@69 103 #define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
Chris@69 104 clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch)
Chris@69 105
Chris@69 106 #define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \
Chris@69 107 clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch)
Chris@69 108
Chris@69 109 #endif /* end if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */
Chris@69 110 #endif /* end if !defined(OVERRIDE_OPUS_MDCT) */
Chris@69 111
Chris@69 112 #endif