OLD | NEW |
1 /* Copyright (c) 2007-2008 CSIRO | 1 /* Copyright (c) 2007-2008 CSIRO |
2 Copyright (c) 2007-2009 Xiph.Org Foundation | 2 Copyright (c) 2007-2009 Xiph.Org Foundation |
3 Written by Jean-Marc Valin */ | 3 Written by Jean-Marc Valin */ |
4 /** | 4 /** |
5 @file pitch.h | 5 @file pitch.h |
6 @brief Pitch analysis | 6 @brief Pitch analysis |
7 */ | 7 */ |
8 | 8 |
9 /* | 9 /* |
10 Redistribution and use in source and binary forms, with or without | 10 Redistribution and use in source and binary forms, with or without |
(...skipping 18 matching lines...) Expand all Loading... |
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 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. | 31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 */ | 32 */ |
33 | 33 |
34 #ifndef PITCH_H | 34 #ifndef PITCH_H |
35 #define PITCH_H | 35 #define PITCH_H |
36 | 36 |
37 #include "modes.h" | 37 #include "modes.h" |
38 | 38 |
| 39 #if defined(__SSE__) && !defined(FIXED_POINT) |
| 40 #include "x86/pitch_sse.h" |
| 41 #endif |
| 42 |
39 void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
_lp, | 43 void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
_lp, |
40 int len, int C); | 44 int len, int C); |
41 | 45 |
42 void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR
ICT y, | 46 void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTR
ICT y, |
43 int len, int max_pitch, int *pitch); | 47 int len, int max_pitch, int *pitch); |
44 | 48 |
45 opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, | 49 opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, |
46 int N, int *T0, int prev_period, opus_val16 prev_gain); | 50 int N, int *T0, int prev_period, opus_val16 prev_gain); |
47 | 51 |
| 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, c
onst 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 } |
48 #endif | 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 |
| 145 #endif |
OLD | NEW |