media/libopus/celt/pitch.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Copyright (c) 2007-2008 CSIRO
michael@0 2 Copyright (c) 2007-2009 Xiph.Org Foundation
michael@0 3 Written by Jean-Marc Valin */
michael@0 4 /**
michael@0 5 @file pitch.h
michael@0 6 @brief Pitch analysis
michael@0 7 */
michael@0 8
michael@0 9 /*
michael@0 10 Redistribution and use in source and binary forms, with or without
michael@0 11 modification, are permitted provided that the following conditions
michael@0 12 are met:
michael@0 13
michael@0 14 - Redistributions of source code must retain the above copyright
michael@0 15 notice, this list of conditions and the following disclaimer.
michael@0 16
michael@0 17 - Redistributions in binary form must reproduce the above copyright
michael@0 18 notice, this list of conditions and the following disclaimer in the
michael@0 19 documentation and/or other materials provided with the distribution.
michael@0 20
michael@0 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
michael@0 25 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
michael@0 26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
michael@0 27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
michael@0 28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
michael@0 29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
michael@0 30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
michael@0 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 32 */
michael@0 33
michael@0 34 #ifndef PITCH_H
michael@0 35 #define PITCH_H
michael@0 36
michael@0 37 #include "modes.h"
michael@0 38 #include "cpu_support.h"
michael@0 39
michael@0 40 #if defined(__SSE__) && !defined(FIXED_POINT)
michael@0 41 #include "x86/pitch_sse.h"
michael@0 42 #endif
michael@0 43
michael@0 44 #if defined(OPUS_ARM_ASM) && defined(FIXED_POINT)
michael@0 45 # include "arm/pitch_arm.h"
michael@0 46 #endif
michael@0 47
michael@0 48 void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp,
michael@0 49 int len, int C, int arch);
michael@0 50
michael@0 51 void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y,
michael@0 52 int len, int max_pitch, int *pitch, int arch);
michael@0 53
michael@0 54 opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod,
michael@0 55 int N, int *T0, int prev_period, opus_val16 prev_gain);
michael@0 56
michael@0 57 /* OPT: This is the kernel you really want to optimize. It gets used a lot
michael@0 58 by the prefilter and by the PLC. */
michael@0 59 #ifndef OVERRIDE_XCORR_KERNEL
michael@0 60 static OPUS_INLINE void xcorr_kernel(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len)
michael@0 61 {
michael@0 62 int j;
michael@0 63 opus_val16 y_0, y_1, y_2, y_3;
michael@0 64 celt_assert(len>=3);
michael@0 65 y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */
michael@0 66 y_0=*y++;
michael@0 67 y_1=*y++;
michael@0 68 y_2=*y++;
michael@0 69 for (j=0;j<len-3;j+=4)
michael@0 70 {
michael@0 71 opus_val16 tmp;
michael@0 72 tmp = *x++;
michael@0 73 y_3=*y++;
michael@0 74 sum[0] = MAC16_16(sum[0],tmp,y_0);
michael@0 75 sum[1] = MAC16_16(sum[1],tmp,y_1);
michael@0 76 sum[2] = MAC16_16(sum[2],tmp,y_2);
michael@0 77 sum[3] = MAC16_16(sum[3],tmp,y_3);
michael@0 78 tmp=*x++;
michael@0 79 y_0=*y++;
michael@0 80 sum[0] = MAC16_16(sum[0],tmp,y_1);
michael@0 81 sum[1] = MAC16_16(sum[1],tmp,y_2);
michael@0 82 sum[2] = MAC16_16(sum[2],tmp,y_3);
michael@0 83 sum[3] = MAC16_16(sum[3],tmp,y_0);
michael@0 84 tmp=*x++;
michael@0 85 y_1=*y++;
michael@0 86 sum[0] = MAC16_16(sum[0],tmp,y_2);
michael@0 87 sum[1] = MAC16_16(sum[1],tmp,y_3);
michael@0 88 sum[2] = MAC16_16(sum[2],tmp,y_0);
michael@0 89 sum[3] = MAC16_16(sum[3],tmp,y_1);
michael@0 90 tmp=*x++;
michael@0 91 y_2=*y++;
michael@0 92 sum[0] = MAC16_16(sum[0],tmp,y_3);
michael@0 93 sum[1] = MAC16_16(sum[1],tmp,y_0);
michael@0 94 sum[2] = MAC16_16(sum[2],tmp,y_1);
michael@0 95 sum[3] = MAC16_16(sum[3],tmp,y_2);
michael@0 96 }
michael@0 97 if (j++<len)
michael@0 98 {
michael@0 99 opus_val16 tmp = *x++;
michael@0 100 y_3=*y++;
michael@0 101 sum[0] = MAC16_16(sum[0],tmp,y_0);
michael@0 102 sum[1] = MAC16_16(sum[1],tmp,y_1);
michael@0 103 sum[2] = MAC16_16(sum[2],tmp,y_2);
michael@0 104 sum[3] = MAC16_16(sum[3],tmp,y_3);
michael@0 105 }
michael@0 106 if (j++<len)
michael@0 107 {
michael@0 108 opus_val16 tmp=*x++;
michael@0 109 y_0=*y++;
michael@0 110 sum[0] = MAC16_16(sum[0],tmp,y_1);
michael@0 111 sum[1] = MAC16_16(sum[1],tmp,y_2);
michael@0 112 sum[2] = MAC16_16(sum[2],tmp,y_3);
michael@0 113 sum[3] = MAC16_16(sum[3],tmp,y_0);
michael@0 114 }
michael@0 115 if (j<len)
michael@0 116 {
michael@0 117 opus_val16 tmp=*x++;
michael@0 118 y_1=*y++;
michael@0 119 sum[0] = MAC16_16(sum[0],tmp,y_2);
michael@0 120 sum[1] = MAC16_16(sum[1],tmp,y_3);
michael@0 121 sum[2] = MAC16_16(sum[2],tmp,y_0);
michael@0 122 sum[3] = MAC16_16(sum[3],tmp,y_1);
michael@0 123 }
michael@0 124 }
michael@0 125 #endif /* OVERRIDE_XCORR_KERNEL */
michael@0 126
michael@0 127 #ifndef OVERRIDE_DUAL_INNER_PROD
michael@0 128 static OPUS_INLINE void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
michael@0 129 int N, opus_val32 *xy1, opus_val32 *xy2)
michael@0 130 {
michael@0 131 int i;
michael@0 132 opus_val32 xy01=0;
michael@0 133 opus_val32 xy02=0;
michael@0 134 for (i=0;i<N;i++)
michael@0 135 {
michael@0 136 xy01 = MAC16_16(xy01, x[i], y01[i]);
michael@0 137 xy02 = MAC16_16(xy02, x[i], y02[i]);
michael@0 138 }
michael@0 139 *xy1 = xy01;
michael@0 140 *xy2 = xy02;
michael@0 141 }
michael@0 142 #endif
michael@0 143
michael@0 144 #ifdef FIXED_POINT
michael@0 145 opus_val32
michael@0 146 #else
michael@0 147 void
michael@0 148 #endif
michael@0 149 celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y,
michael@0 150 opus_val32 *xcorr, int len, int max_pitch);
michael@0 151
michael@0 152 #if !defined(OVERRIDE_PITCH_XCORR)
michael@0 153 /*Is run-time CPU detection enabled on this platform?*/
michael@0 154 # if defined(OPUS_HAVE_RTCD)
michael@0 155 extern
michael@0 156 # if defined(FIXED_POINT)
michael@0 157 opus_val32
michael@0 158 # else
michael@0 159 void
michael@0 160 # endif
michael@0 161 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *,
michael@0 162 const opus_val16 *, opus_val32 *, int, int);
michael@0 163
michael@0 164 # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
michael@0 165 ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \
michael@0 166 xcorr, len, max_pitch))
michael@0 167 # else
michael@0 168 # define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \
michael@0 169 ((void)(arch),celt_pitch_xcorr_c(_x, _y, xcorr, len, max_pitch))
michael@0 170 # endif
michael@0 171 #endif
michael@0 172
michael@0 173 #endif

mercurial