ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/vq_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 vq_arm4.h |
| TMBOY | 47:9e361da97763 | 4 | @brief ARM4-optimized vq routine |
| 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_VQ_NBEST |
| TMBOY | 47:9e361da97763 | 36 | void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) |
| TMBOY | 47:9e361da97763 | 37 | { |
| TMBOY | 47:9e361da97763 | 38 | int i,j; |
| TMBOY | 47:9e361da97763 | 39 | for (i=0;i<entries;i+=4) |
| TMBOY | 47:9e361da97763 | 40 | { |
| TMBOY | 47:9e361da97763 | 41 | #if 1 |
| TMBOY | 47:9e361da97763 | 42 | spx_word32_t dist1, dist2, dist3, dist4; |
| TMBOY | 47:9e361da97763 | 43 | int dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8; |
| TMBOY | 47:9e361da97763 | 44 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 45 | "mov %0, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 46 | "mov %1, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 47 | "mov %2, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 48 | "mov %3, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 49 | "mov %10, %4 \n\t" |
| TMBOY | 47:9e361da97763 | 50 | "add %4, %4, %4\n\t" |
| TMBOY | 47:9e361da97763 | 51 | ".vqloop%=:\n\t" |
| TMBOY | 47:9e361da97763 | 52 | "ldrsh %7, [%5], #2 \n\t" |
| TMBOY | 47:9e361da97763 | 53 | "ldrsh %8, [%6] \n\t" |
| TMBOY | 47:9e361da97763 | 54 | "mov %9, %6 \n\t" |
| TMBOY | 47:9e361da97763 | 55 | "mla %0, %7, %8, %0 \n\t" |
| TMBOY | 47:9e361da97763 | 56 | "ldrsh %8, [%9, %4]! \n\t" |
| TMBOY | 47:9e361da97763 | 57 | "mla %1, %7, %8, %1 \n\t" |
| TMBOY | 47:9e361da97763 | 58 | "ldrsh %8, [%9, %4]!\n\t" |
| TMBOY | 47:9e361da97763 | 59 | "mla %2, %7, %8, %2 \n\t" |
| TMBOY | 47:9e361da97763 | 60 | "ldrsh %8, [%9, %4]! \n\t" |
| TMBOY | 47:9e361da97763 | 61 | "mla %3, %7, %8, %3 \n\t" |
| TMBOY | 47:9e361da97763 | 62 | "subs %10, %10, #1 \n\t" |
| TMBOY | 47:9e361da97763 | 63 | "add %6, %6, #2 \n\t" |
| TMBOY | 47:9e361da97763 | 64 | "bne .vqloop%=" |
| TMBOY | 47:9e361da97763 | 65 | : "=r" (dist1), "=r" (dist2), "=r" (dist3), "=r" (dist4), |
| TMBOY | 47:9e361da97763 | 66 | "=r" (dead1), "=r" (dead2), "=r" (codebook), "=r" (dead4), |
| TMBOY | 47:9e361da97763 | 67 | "=r" (dead5), "=r" (dead6), "=r" (dead7) |
| TMBOY | 47:9e361da97763 | 68 | : "4" (len), "5" (in), "6" (codebook) |
| TMBOY | 47:9e361da97763 | 69 | : "cc"); |
| TMBOY | 47:9e361da97763 | 70 | #else |
| TMBOY | 47:9e361da97763 | 71 | dist1=dist2=dist3=dist4=0; |
| TMBOY | 47:9e361da97763 | 72 | /* spx_word32_t dist1=0; |
| TMBOY | 47:9e361da97763 | 73 | spx_word32_t dist2=0; |
| TMBOY | 47:9e361da97763 | 74 | spx_word32_t dist3=0; |
| TMBOY | 47:9e361da97763 | 75 | spx_word32_t dist4=0;*/ |
| TMBOY | 47:9e361da97763 | 76 | for (j=0;j<2;j++) |
| TMBOY | 47:9e361da97763 | 77 | { |
| TMBOY | 47:9e361da97763 | 78 | const spx_word16_t *code = codebook; |
| TMBOY | 47:9e361da97763 | 79 | dist1 = MAC16_16(dist1,in[j],*code); |
| TMBOY | 47:9e361da97763 | 80 | code += len; |
| TMBOY | 47:9e361da97763 | 81 | dist2 = MAC16_16(dist2,in[j],*code); |
| TMBOY | 47:9e361da97763 | 82 | code += len; |
| TMBOY | 47:9e361da97763 | 83 | dist3 = MAC16_16(dist3,in[j],*code); |
| TMBOY | 47:9e361da97763 | 84 | code += len; |
| TMBOY | 47:9e361da97763 | 85 | dist4 = MAC16_16(dist4,in[j],*code); |
| TMBOY | 47:9e361da97763 | 86 | codebook++; |
| TMBOY | 47:9e361da97763 | 87 | } |
| TMBOY | 47:9e361da97763 | 88 | #endif |
| TMBOY | 47:9e361da97763 | 89 | dist1=SUB32(SHR(*E++,1),dist1); |
| TMBOY | 47:9e361da97763 | 90 | if (dist1<*best_dist || i==0) |
| TMBOY | 47:9e361da97763 | 91 | { |
| TMBOY | 47:9e361da97763 | 92 | *best_dist=dist1; |
| TMBOY | 47:9e361da97763 | 93 | *nbest=i; |
| TMBOY | 47:9e361da97763 | 94 | } |
| TMBOY | 47:9e361da97763 | 95 | dist2=SUB32(SHR(*E++,1),dist2); |
| TMBOY | 47:9e361da97763 | 96 | if (dist2<*best_dist) |
| TMBOY | 47:9e361da97763 | 97 | { |
| TMBOY | 47:9e361da97763 | 98 | *best_dist=dist2; |
| TMBOY | 47:9e361da97763 | 99 | *nbest=i+1; |
| TMBOY | 47:9e361da97763 | 100 | } |
| TMBOY | 47:9e361da97763 | 101 | dist3=SUB32(SHR(*E++,1),dist3); |
| TMBOY | 47:9e361da97763 | 102 | if (dist3<*best_dist) |
| TMBOY | 47:9e361da97763 | 103 | { |
| TMBOY | 47:9e361da97763 | 104 | *best_dist=dist3; |
| TMBOY | 47:9e361da97763 | 105 | *nbest=i+2; |
| TMBOY | 47:9e361da97763 | 106 | } |
| TMBOY | 47:9e361da97763 | 107 | dist4=SUB32(SHR(*E++,1),dist4); |
| TMBOY | 47:9e361da97763 | 108 | if (dist4<*best_dist) |
| TMBOY | 47:9e361da97763 | 109 | { |
| TMBOY | 47:9e361da97763 | 110 | *best_dist=dist4; |
| TMBOY | 47:9e361da97763 | 111 | *nbest=i+3; |
| TMBOY | 47:9e361da97763 | 112 | } |
| TMBOY | 47:9e361da97763 | 113 | codebook += 3*len; |
| TMBOY | 47:9e361da97763 | 114 | } |
| TMBOY | 47:9e361da97763 | 115 | } |
