ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/ltp_arm4.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | /* Copyright (C) 2004 Jean-Marc Valin */ |
| TMBOY | 47:9e361da97763 | 2 | /** |
| TMBOY | 47:9e361da97763 | 3 | @file ltp_arm4.h |
| TMBOY | 47:9e361da97763 | 4 | @brief Long-Term Prediction functions (ARM4 version) |
| TMBOY | 47:9e361da97763 | 5 | */ |
| TMBOY | 47:9e361da97763 | 6 | /* |
| TMBOY | 47:9e361da97763 | 7 | Redistribution and use in source and binary forms, with or without |
| TMBOY | 47:9e361da97763 | 8 | modification, are permitted provided that the following conditions |
| TMBOY | 47:9e361da97763 | 9 | are met: |
| TMBOY | 47:9e361da97763 | 10 | |
| TMBOY | 47:9e361da97763 | 11 | - Redistributions of source code must retain the above copyright |
| TMBOY | 47:9e361da97763 | 12 | notice, this list of conditions and the following disclaimer. |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | - Redistributions in binary form must reproduce the above copyright |
| TMBOY | 47:9e361da97763 | 15 | notice, this list of conditions and the following disclaimer in the |
| TMBOY | 47:9e361da97763 | 16 | documentation and/or other materials provided with the distribution. |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its |
| TMBOY | 47:9e361da97763 | 19 | contributors may be used to endorse or promote products derived from |
| TMBOY | 47:9e361da97763 | 20 | this software without specific prior written permission. |
| TMBOY | 47:9e361da97763 | 21 | |
| TMBOY | 47:9e361da97763 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| TMBOY | 47:9e361da97763 | 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| TMBOY | 47:9e361da97763 | 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| TMBOY | 47:9e361da97763 | 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| TMBOY | 47:9e361da97763 | 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| TMBOY | 47:9e361da97763 | 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| TMBOY | 47:9e361da97763 | 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| TMBOY | 47:9e361da97763 | 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| TMBOY | 47:9e361da97763 | 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| TMBOY | 47:9e361da97763 | 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| TMBOY | 47:9e361da97763 | 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| TMBOY | 47:9e361da97763 | 33 | */ |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | #define OVERRIDE_INNER_PROD |
| TMBOY | 47:9e361da97763 | 36 | spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) |
| TMBOY | 47:9e361da97763 | 37 | { |
| TMBOY | 47:9e361da97763 | 38 | spx_word32_t sum1=0,sum2=0; |
| TMBOY | 47:9e361da97763 | 39 | spx_word16_t *deadx, *deady; |
| TMBOY | 47:9e361da97763 | 40 | int deadlen, dead1, dead2, dead3, dead4, dead5, dead6; |
| TMBOY | 47:9e361da97763 | 41 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 42 | "\tldrsh %5, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 43 | "\tldrsh %6, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 44 | ".inner_prod_loop%=:\n" |
| TMBOY | 47:9e361da97763 | 45 | "\tsub %7, %7, %7\n" |
| TMBOY | 47:9e361da97763 | 46 | "\tsub %10, %10, %10\n" |
| TMBOY | 47:9e361da97763 | 47 | |
| TMBOY | 47:9e361da97763 | 48 | "\tldrsh %8, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 49 | "\tldrsh %9, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 50 | "\tmla %7, %5, %6, %7\n" |
| TMBOY | 47:9e361da97763 | 51 | "\tldrsh %5, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 52 | "\tldrsh %6, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 53 | "\tmla %10, %8, %9, %10\n" |
| TMBOY | 47:9e361da97763 | 54 | "\tldrsh %8, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 55 | "\tldrsh %9, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 56 | "\tmla %7, %5, %6, %7\n" |
| TMBOY | 47:9e361da97763 | 57 | "\tldrsh %5, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 58 | "\tldrsh %6, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 59 | "\tmla %10, %8, %9, %10\n" |
| TMBOY | 47:9e361da97763 | 60 | |
| TMBOY | 47:9e361da97763 | 61 | "\tldrsh %8, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 62 | "\tldrsh %9, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 63 | "\tmla %7, %5, %6, %7\n" |
| TMBOY | 47:9e361da97763 | 64 | "\tldrsh %5, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 65 | "\tldrsh %6, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 66 | "\tmla %10, %8, %9, %10\n" |
| TMBOY | 47:9e361da97763 | 67 | "\tldrsh %8, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 68 | "\tldrsh %9, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 69 | "\tmla %7, %5, %6, %7\n" |
| TMBOY | 47:9e361da97763 | 70 | "\tldrsh %5, [%0], #2 \n" |
| TMBOY | 47:9e361da97763 | 71 | "\tldrsh %6, [%1], #2 \n" |
| TMBOY | 47:9e361da97763 | 72 | "\tmla %10, %8, %9, %10\n" |
| TMBOY | 47:9e361da97763 | 73 | |
| TMBOY | 47:9e361da97763 | 74 | "\tsubs %4, %4, #1\n" |
| TMBOY | 47:9e361da97763 | 75 | "\tadd %2, %2, %7, asr #5\n" |
| TMBOY | 47:9e361da97763 | 76 | "\tadd %3, %3, %10, asr #5\n" |
| TMBOY | 47:9e361da97763 | 77 | "\tbne .inner_prod_loop%=\n" |
| TMBOY | 47:9e361da97763 | 78 | : "=r" (deadx), "=r" (deady), "+r" (sum1), "+r" (sum2), |
| TMBOY | 47:9e361da97763 | 79 | "=r" (deadlen), "=r" (dead1), "=r" (dead2), "=r" (dead3), |
| TMBOY | 47:9e361da97763 | 80 | "=r" (dead4), "=r" (dead5), "=r" (dead6) |
| TMBOY | 47:9e361da97763 | 81 | : "0" (x), "1" (y), "4" (len>>3) |
| TMBOY | 47:9e361da97763 | 82 | : "cc" |
| TMBOY | 47:9e361da97763 | 83 | ); |
| TMBOY | 47:9e361da97763 | 84 | return (sum1+sum2)>>1; |
| TMBOY | 47:9e361da97763 | 85 | } |
| TMBOY | 47:9e361da97763 | 86 | |
| TMBOY | 47:9e361da97763 | 87 | #define OVERRIDE_PITCH_XCORR |
| TMBOY | 47:9e361da97763 | 88 | void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) |
| TMBOY | 47:9e361da97763 | 89 | { |
| TMBOY | 47:9e361da97763 | 90 | int i,j; |
| TMBOY | 47:9e361da97763 | 91 | for (i=0;i<nb_pitch;i+=4) |
| TMBOY | 47:9e361da97763 | 92 | { |
| TMBOY | 47:9e361da97763 | 93 | /* Compute correlation*/ |
| TMBOY | 47:9e361da97763 | 94 | //corr[nb_pitch-1-i]=inner_prod(x, _y+i, len); |
| TMBOY | 47:9e361da97763 | 95 | spx_word32_t sum1=0; |
| TMBOY | 47:9e361da97763 | 96 | spx_word32_t sum2=0; |
| TMBOY | 47:9e361da97763 | 97 | spx_word32_t sum3=0; |
| TMBOY | 47:9e361da97763 | 98 | spx_word32_t sum4=0; |
| TMBOY | 47:9e361da97763 | 99 | const spx_word16_t *y = _y+i; |
| TMBOY | 47:9e361da97763 | 100 | const spx_word16_t *x = _x; |
| TMBOY | 47:9e361da97763 | 101 | spx_word32_t y0, y1, y2, y3; |
| TMBOY | 47:9e361da97763 | 102 | y0=*y++; |
| TMBOY | 47:9e361da97763 | 103 | y1=*y++; |
| TMBOY | 47:9e361da97763 | 104 | y2=*y++; |
| TMBOY | 47:9e361da97763 | 105 | y3=*y++; |
| TMBOY | 47:9e361da97763 | 106 | for (j=0;j<len;j+=4) |
| TMBOY | 47:9e361da97763 | 107 | { |
| TMBOY | 47:9e361da97763 | 108 | spx_word32_t part1, part2, part3, part4, x0; |
| TMBOY | 47:9e361da97763 | 109 | spx_word32_t dead1; |
| TMBOY | 47:9e361da97763 | 110 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 111 | #ifdef SHORTCUTS |
| TMBOY | 47:9e361da97763 | 112 | "\tldrsh %10, [%8], #4 \n" |
| TMBOY | 47:9e361da97763 | 113 | "\tmul %4, %10, %0 \n" |
| TMBOY | 47:9e361da97763 | 114 | "\tldrsh %15, [%8], #4 \n" |
| TMBOY | 47:9e361da97763 | 115 | "\tmul %5, %10, %1 \n" |
| TMBOY | 47:9e361da97763 | 116 | "\tldrsh %0, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 117 | "\tmul %6, %10, %2 \n" |
| TMBOY | 47:9e361da97763 | 118 | "\tldrsh %1, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 119 | "\tmul %7, %10, %3 \n" |
| TMBOY | 47:9e361da97763 | 120 | |
| TMBOY | 47:9e361da97763 | 121 | |
| TMBOY | 47:9e361da97763 | 122 | "\tmla %4, %15, %2, %4 \n" |
| TMBOY | 47:9e361da97763 | 123 | "\tldrsh %2, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 124 | "\tmla %5, %15, %3, %5 \n" |
| TMBOY | 47:9e361da97763 | 125 | "\tldrsh %3, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 126 | "\tmla %6, %15, %0, %6 \n" |
| TMBOY | 47:9e361da97763 | 127 | "\tmla %7, %15, %1, %7 \n" |
| TMBOY | 47:9e361da97763 | 128 | |
| TMBOY | 47:9e361da97763 | 129 | #else |
| TMBOY | 47:9e361da97763 | 130 | "\tldrsh %10, [%8], #2 \n" |
| TMBOY | 47:9e361da97763 | 131 | "\tmul %4, %10, %0 \n" |
| TMBOY | 47:9e361da97763 | 132 | "\tmul %5, %10, %1 \n" |
| TMBOY | 47:9e361da97763 | 133 | "\tmul %6, %10, %2 \n" |
| TMBOY | 47:9e361da97763 | 134 | "\tmul %7, %10, %3 \n" |
| TMBOY | 47:9e361da97763 | 135 | |
| TMBOY | 47:9e361da97763 | 136 | "\tldrsh %10, [%8], #2 \n" |
| TMBOY | 47:9e361da97763 | 137 | "\tldrsh %0, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 138 | "\tmla %4, %10, %1, %4 \n" |
| TMBOY | 47:9e361da97763 | 139 | "\tmla %5, %10, %2, %5 \n" |
| TMBOY | 47:9e361da97763 | 140 | "\tmla %6, %10, %3, %6 \n" |
| TMBOY | 47:9e361da97763 | 141 | "\tmla %7, %10, %0, %7 \n" |
| TMBOY | 47:9e361da97763 | 142 | |
| TMBOY | 47:9e361da97763 | 143 | "\tldrsh %10, [%8], #2 \n" |
| TMBOY | 47:9e361da97763 | 144 | "\tldrsh %1, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 145 | "\tmla %4, %10, %2, %4 \n" |
| TMBOY | 47:9e361da97763 | 146 | "\tmla %5, %10, %3, %5 \n" |
| TMBOY | 47:9e361da97763 | 147 | "\tmla %6, %10, %0, %6 \n" |
| TMBOY | 47:9e361da97763 | 148 | "\tmla %7, %10, %1, %7 \n" |
| TMBOY | 47:9e361da97763 | 149 | |
| TMBOY | 47:9e361da97763 | 150 | "\tldrsh %10, [%8], #2 \n" |
| TMBOY | 47:9e361da97763 | 151 | "\tldrsh %2, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 152 | "\tmla %4, %10, %3, %4 \n" |
| TMBOY | 47:9e361da97763 | 153 | "\tmla %5, %10, %0, %5 \n" |
| TMBOY | 47:9e361da97763 | 154 | "\tmla %6, %10, %1, %6 \n" |
| TMBOY | 47:9e361da97763 | 155 | "\tmla %7, %10, %2, %7 \n" |
| TMBOY | 47:9e361da97763 | 156 | |
| TMBOY | 47:9e361da97763 | 157 | "\tldrsh %3, [%9], #2 \n" |
| TMBOY | 47:9e361da97763 | 158 | #endif |
| TMBOY | 47:9e361da97763 | 159 | |
| TMBOY | 47:9e361da97763 | 160 | "\tldr %10, %11 \n" |
| TMBOY | 47:9e361da97763 | 161 | "\tldr %15, %12 \n" |
| TMBOY | 47:9e361da97763 | 162 | "\tadd %4, %10, %4, asr #6 \n" |
| TMBOY | 47:9e361da97763 | 163 | "\tstr %4, %11 \n" |
| TMBOY | 47:9e361da97763 | 164 | "\tldr %10, %13 \n" |
| TMBOY | 47:9e361da97763 | 165 | "\tadd %5, %15, %5, asr #6 \n" |
| TMBOY | 47:9e361da97763 | 166 | "\tstr %5, %12 \n" |
| TMBOY | 47:9e361da97763 | 167 | "\tldr %15, %14 \n" |
| TMBOY | 47:9e361da97763 | 168 | "\tadd %6, %10, %6, asr #6 \n" |
| TMBOY | 47:9e361da97763 | 169 | "\tadd %7, %15, %7, asr #6 \n" |
| TMBOY | 47:9e361da97763 | 170 | "\tstr %6, %13 \n" |
| TMBOY | 47:9e361da97763 | 171 | "\tstr %7, %14 \n" |
| TMBOY | 47:9e361da97763 | 172 | |
| TMBOY | 47:9e361da97763 | 173 | : "+r" (y0), "+r" (y1), "+r" (y2), "+r" (y3), |
| TMBOY | 47:9e361da97763 | 174 | "=r" (part1), "=r" (part2), "=r" (part3), "=r" (part4), |
| TMBOY | 47:9e361da97763 | 175 | "+r" (x), "+r" (y), "=r" (x0), "+m" (sum1), |
| TMBOY | 47:9e361da97763 | 176 | "+m" (sum2), "+m" (sum3), "+m" (sum4), "=r" (dead1) |
| TMBOY | 47:9e361da97763 | 177 | : |
| TMBOY | 47:9e361da97763 | 178 | : "cc", "memory" |
| TMBOY | 47:9e361da97763 | 179 | ); |
| TMBOY | 47:9e361da97763 | 180 | } |
| TMBOY | 47:9e361da97763 | 181 | corr[nb_pitch-1-i]=sum1; |
| TMBOY | 47:9e361da97763 | 182 | corr[nb_pitch-2-i]=sum2; |
| TMBOY | 47:9e361da97763 | 183 | corr[nb_pitch-3-i]=sum3; |
| TMBOY | 47:9e361da97763 | 184 | corr[nb_pitch-4-i]=sum4; |
| TMBOY | 47:9e361da97763 | 185 | } |
| TMBOY | 47:9e361da97763 | 186 | |
| TMBOY | 47:9e361da97763 | 187 | } |
