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