ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/libspeex/cb_search_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 cb_search_arm4.h |
| TMBOY | 47:9e361da97763 | 4 | @brief Fixed codebook 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 | /* This optimization is temporaly disabled until it is fixed to account for the fact |
| TMBOY | 47:9e361da97763 | 36 | that "r" is now a 16-bit array */ |
| TMBOY | 47:9e361da97763 | 37 | #if 0 |
| TMBOY | 47:9e361da97763 | 38 | #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK |
| TMBOY | 47:9e361da97763 | 39 | static void compute_weighted_codebook(const signed char *shape_cb, const spx_word16_t *r, spx_word16_t *resp, spx_word16_t *resp2, spx_word32_t *E, int shape_cb_size, int subvect_size, char *stack) |
| TMBOY | 47:9e361da97763 | 40 | { |
| TMBOY | 47:9e361da97763 | 41 | int i, j, k; |
| TMBOY | 47:9e361da97763 | 42 | //const signed char *shape; |
| TMBOY | 47:9e361da97763 | 43 | for (i=0;i<shape_cb_size;i+=4) |
| TMBOY | 47:9e361da97763 | 44 | { |
| TMBOY | 47:9e361da97763 | 45 | |
| TMBOY | 47:9e361da97763 | 46 | //shape = shape_cb; |
| TMBOY | 47:9e361da97763 | 47 | E[0]=0; |
| TMBOY | 47:9e361da97763 | 48 | E[1]=0; |
| TMBOY | 47:9e361da97763 | 49 | E[2]=0; |
| TMBOY | 47:9e361da97763 | 50 | E[3]=0; |
| TMBOY | 47:9e361da97763 | 51 | |
| TMBOY | 47:9e361da97763 | 52 | /* Compute codeword response using convolution with impulse response */ |
| TMBOY | 47:9e361da97763 | 53 | for(j=0;j<subvect_size;j++) |
| TMBOY | 47:9e361da97763 | 54 | { |
| TMBOY | 47:9e361da97763 | 55 | #if 1 |
| TMBOY | 47:9e361da97763 | 56 | spx_word16_t *res; |
| TMBOY | 47:9e361da97763 | 57 | res = resp+j; |
| TMBOY | 47:9e361da97763 | 58 | spx_word32_t resj0,resj1,resj2,resj3; |
| TMBOY | 47:9e361da97763 | 59 | spx_word32_t dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8; |
| TMBOY | 47:9e361da97763 | 60 | __asm__ __volatile__ ( |
| TMBOY | 47:9e361da97763 | 61 | "mov %0, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 62 | "mov %1, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 63 | "mov %2, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 64 | "mov %3, #0 \n\t" |
| TMBOY | 47:9e361da97763 | 65 | ".weighted%=: \n\t" |
| TMBOY | 47:9e361da97763 | 66 | "ldrsb %8, [%6] \n\t" |
| TMBOY | 47:9e361da97763 | 67 | "ldr %10, [%5], #-4 \n\t" |
| TMBOY | 47:9e361da97763 | 68 | "mov %9, %6 \n\t" |
| TMBOY | 47:9e361da97763 | 69 | "ldrsb %11, [%9, %7]! \n\t" |
| TMBOY | 47:9e361da97763 | 70 | "mla %0, %10, %8, %0 \n\t" |
| TMBOY | 47:9e361da97763 | 71 | "ldrsb %8, [%9, %7]! \n\t" |
| TMBOY | 47:9e361da97763 | 72 | "mla %1, %10, %11, %1 \n\t" |
| TMBOY | 47:9e361da97763 | 73 | "ldrsb %11, [%9, %7]! \n\t" |
| TMBOY | 47:9e361da97763 | 74 | "mla %2, %10, %8, %2 \n\t" |
| TMBOY | 47:9e361da97763 | 75 | "subs %4, %4, #1 \n\t" |
| TMBOY | 47:9e361da97763 | 76 | "mla %3, %10, %11, %3 \n\t" |
| TMBOY | 47:9e361da97763 | 77 | "add %6, %6, #1 \n\t" |
| TMBOY | 47:9e361da97763 | 78 | "bne .weighted%= \n\t" |
| TMBOY | 47:9e361da97763 | 79 | : "=r" (resj0), "=r" (resj1), "=r" (resj2), "=r" (resj3), |
| TMBOY | 47:9e361da97763 | 80 | "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), |
| TMBOY | 47:9e361da97763 | 81 | "=r" (dead5), "=r" (dead6), "=r" (dead7), "=r" (dead8) |
| TMBOY | 47:9e361da97763 | 82 | : "4" (j+1), "5" (r+j), "6" (shape_cb), "7" (subvect_size) |
| TMBOY | 47:9e361da97763 | 83 | : "cc", "memory"); |
| TMBOY | 47:9e361da97763 | 84 | #else |
| TMBOY | 47:9e361da97763 | 85 | spx_word16_t *res; |
| TMBOY | 47:9e361da97763 | 86 | res = resp+j; |
| TMBOY | 47:9e361da97763 | 87 | spx_word32_t resj0=0; |
| TMBOY | 47:9e361da97763 | 88 | spx_word32_t resj1=0; |
| TMBOY | 47:9e361da97763 | 89 | spx_word32_t resj2=0; |
| TMBOY | 47:9e361da97763 | 90 | spx_word32_t resj3=0; |
| TMBOY | 47:9e361da97763 | 91 | for (k=0;k<=j;k++) |
| TMBOY | 47:9e361da97763 | 92 | { |
| TMBOY | 47:9e361da97763 | 93 | const signed char *shape=shape_cb+k; |
| TMBOY | 47:9e361da97763 | 94 | resj0 = MAC16_16(resj0,*shape,r[j-k]); |
| TMBOY | 47:9e361da97763 | 95 | shape += subvect_size; |
| TMBOY | 47:9e361da97763 | 96 | resj1 = MAC16_16(resj1,*shape,r[j-k]); |
| TMBOY | 47:9e361da97763 | 97 | shape += subvect_size; |
| TMBOY | 47:9e361da97763 | 98 | resj2 = MAC16_16(resj2,*shape,r[j-k]); |
| TMBOY | 47:9e361da97763 | 99 | shape += subvect_size; |
| TMBOY | 47:9e361da97763 | 100 | resj3 = MAC16_16(resj3,*shape,r[j-k]); |
| TMBOY | 47:9e361da97763 | 101 | shape += subvect_size; |
| TMBOY | 47:9e361da97763 | 102 | } |
| TMBOY | 47:9e361da97763 | 103 | #endif |
| TMBOY | 47:9e361da97763 | 104 | |
| TMBOY | 47:9e361da97763 | 105 | #ifdef FIXED_POINT |
| TMBOY | 47:9e361da97763 | 106 | resj0 = SHR(resj0, 11); |
| TMBOY | 47:9e361da97763 | 107 | resj1 = SHR(resj1, 11); |
| TMBOY | 47:9e361da97763 | 108 | resj2 = SHR(resj2, 11); |
| TMBOY | 47:9e361da97763 | 109 | resj3 = SHR(resj3, 11); |
| TMBOY | 47:9e361da97763 | 110 | #else |
| TMBOY | 47:9e361da97763 | 111 | resj0 *= 0.03125; |
| TMBOY | 47:9e361da97763 | 112 | resj1 *= 0.03125; |
| TMBOY | 47:9e361da97763 | 113 | resj2 *= 0.03125; |
| TMBOY | 47:9e361da97763 | 114 | resj3 *= 0.03125; |
| TMBOY | 47:9e361da97763 | 115 | #endif |
| TMBOY | 47:9e361da97763 | 116 | |
| TMBOY | 47:9e361da97763 | 117 | /* Compute codeword energy */ |
| TMBOY | 47:9e361da97763 | 118 | E[0]=ADD32(E[0],MULT16_16(resj0,resj0)); |
| TMBOY | 47:9e361da97763 | 119 | E[1]=ADD32(E[1],MULT16_16(resj1,resj1)); |
| TMBOY | 47:9e361da97763 | 120 | E[2]=ADD32(E[2],MULT16_16(resj2,resj2)); |
| TMBOY | 47:9e361da97763 | 121 | E[3]=ADD32(E[3],MULT16_16(resj3,resj3)); |
| TMBOY | 47:9e361da97763 | 122 | *res = resj0; |
| TMBOY | 47:9e361da97763 | 123 | res += subvect_size; |
| TMBOY | 47:9e361da97763 | 124 | *res = resj1; |
| TMBOY | 47:9e361da97763 | 125 | res += subvect_size; |
| TMBOY | 47:9e361da97763 | 126 | *res = resj2; |
| TMBOY | 47:9e361da97763 | 127 | res += subvect_size; |
| TMBOY | 47:9e361da97763 | 128 | *res = resj3; |
| TMBOY | 47:9e361da97763 | 129 | res += subvect_size; |
| TMBOY | 47:9e361da97763 | 130 | } |
| TMBOY | 47:9e361da97763 | 131 | resp += subvect_size<<2; |
| TMBOY | 47:9e361da97763 | 132 | shape_cb += subvect_size<<2; |
| TMBOY | 47:9e361da97763 | 133 | E+=4; |
| TMBOY | 47:9e361da97763 | 134 | } |
| TMBOY | 47:9e361da97763 | 135 | |
| TMBOY | 47:9e361da97763 | 136 | } |
| TMBOY | 47:9e361da97763 | 137 | #endif |
