| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len) |
| 33 |
{ |
| 34 |
spx_word32_t sum1=0,sum2=0; |
| 35 |
spx_word16_t *deadx, *deady; |
| 36 |
int deadlen, dead1, dead2, dead3, dead4, dead5, dead6; |
| 37 |
__asm__ __volatile__ ( |
| 38 |
"\tldrsh %5, [%0], #2 \n" |
| 39 |
"\tldrsh %6, [%1], #2 \n" |
| 40 |
".inner_prod_loop%=:\n" |
| 41 |
"\tsub %7, %7, %7\n" |
| 42 |
"\tsub %10, %10, %10\n" |
| 43 |
|
| 44 |
"\tldrsh %8, [%0], #2 \n" |
| 45 |
"\tldrsh %9, [%1], #2 \n" |
| 46 |
"\tmla %7, %5, %6, %7\n" |
| 47 |
"\tldrsh %5, [%0], #2 \n" |
| 48 |
"\tldrsh %6, [%1], #2 \n" |
| 49 |
"\tmla %10, %8, %9, %10\n" |
| 50 |
"\tldrsh %8, [%0], #2 \n" |
| 51 |
"\tldrsh %9, [%1], #2 \n" |
| 52 |
"\tmla %7, %5, %6, %7\n" |
| 53 |
"\tldrsh %5, [%0], #2 \n" |
| 54 |
"\tldrsh %6, [%1], #2 \n" |
| 55 |
"\tmla %10, %8, %9, %10\n" |
| 56 |
|
| 57 |
"\tldrsh %8, [%0], #2 \n" |
| 58 |
"\tldrsh %9, [%1], #2 \n" |
| 59 |
"\tmla %7, %5, %6, %7\n" |
| 60 |
"\tldrsh %5, [%0], #2 \n" |
| 61 |
"\tldrsh %6, [%1], #2 \n" |
| 62 |
"\tmla %10, %8, %9, %10\n" |
| 63 |
"\tldrsh %8, [%0], #2 \n" |
| 64 |
"\tldrsh %9, [%1], #2 \n" |
| 65 |
"\tmla %7, %5, %6, %7\n" |
| 66 |
"\tldrsh %5, [%0], #2 \n" |
| 67 |
"\tldrsh %6, [%1], #2 \n" |
| 68 |
"\tmla %10, %8, %9, %10\n" |
| 69 |
|
| 70 |
"\tsubs %4, %4, #1\n" |
| 71 |
"\tadd %2, %2, %7, asr #5\n" |
| 72 |
"\tadd %3, %3, %10, asr #5\n" |
| 73 |
"\tbne .inner_prod_loop%=\n" |
| 74 |
: "=r" (deadx), "=r" (deady), "=r" (sum1), "=r" (sum2), "=r" (deadlen), |
| 75 |
"=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6) |
| 76 |
: "0" (x), "1" (y), "2" (sum1), "3" (sum2), "4" (len>>3) |
| 77 |
: "cc" |
| 78 |
); |
| 79 |
return (sum1+sum2)>>1; |
| 80 |
} |
| 81 |
|
| 82 |
static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack) |
| 83 |
{ |
| 84 |
int i,j; |
| 85 |
for (i=0;i<nb_pitch;i+=4) |
| 86 |
{ |
| 87 |
|
| 88 |
|
| 89 |
spx_word32_t sum1=0; |
| 90 |
spx_word32_t sum2=0; |
| 91 |
spx_word32_t sum3=0; |
| 92 |
spx_word32_t sum4=0; |
| 93 |
const spx_word16_t *y = _y+i; |
| 94 |
const spx_word16_t *x = _x; |
| 95 |
spx_word32_t y0, y1, y2, y3; |
| 96 |
y0=*y++; |
| 97 |
y1=*y++; |
| 98 |
y2=*y++; |
| 99 |
y3=*y++; |
| 100 |
for (j=0;j<len;j+=4) |
| 101 |
{ |
| 102 |
spx_word32_t part1, part2, part3, part4, x0; |
| 103 |
spx_word32_t dead1; |
| 104 |
__asm__ __volatile__ ( |
| 105 |
#ifdef SHORTCUTS |
| 106 |
"\tldrsh %10, [%8], #4 \n" |
| 107 |
"\tmul %4, %10, %0 \n" |
| 108 |
"\tldrsh %15, [%8], #4 \n" |
| 109 |
"\tmul %5, %10, %1 \n" |
| 110 |
"\tldrsh %0, [%9], #2 \n" |
| 111 |
"\tmul %6, %10, %2 \n" |
| 112 |
"\tldrsh %1, [%9], #2 \n" |
| 113 |
"\tmul %7, %10, %3 \n" |
| 114 |
|
| 115 |
|
| 116 |
"\tmla %4, %15, %2, %4 \n" |
| 117 |
"\tldrsh %2, [%9], #2 \n" |
| 118 |
"\tmla %5, %15, %3, %5 \n" |
| 119 |
"\tldrsh %3, [%9], #2 \n" |
| 120 |
"\tmla %6, %15, %0, %6 \n" |
| 121 |
"\tmla %7, %15, %1, %7 \n" |
| 122 |
|
| 123 |
#else |
| 124 |
"\tldrsh %10, [%8], #2 \n" |
| 125 |
"\tmul %4, %10, %0 \n" |
| 126 |
"\tmul %5, %10, %1 \n" |
| 127 |
"\tmul %6, %10, %2 \n" |
| 128 |
"\tmul %7, %10, %3 \n" |
| 129 |
|
| 130 |
"\tldrsh %10, [%8], #2 \n" |
| 131 |
"\tldrsh %0, [%9], #2 \n" |
| 132 |
"\tmla %4, %10, %1, %4 \n" |
| 133 |
"\tmla %5, %10, %2, %5 \n" |
| 134 |
"\tmla %6, %10, %3, %6 \n" |
| 135 |
"\tmla %7, %10, %0, %7 \n" |
| 136 |
|
| 137 |
"\tldrsh %10, [%8], #2 \n" |
| 138 |
"\tldrsh %1, [%9], #2 \n" |
| 139 |
"\tmla %4, %10, %2, %4 \n" |
| 140 |
"\tmla %5, %10, %3, %5 \n" |
| 141 |
"\tmla %6, %10, %0, %6 \n" |
| 142 |
"\tmla %7, %10, %1, %7 \n" |
| 143 |
|
| 144 |
"\tldrsh %10, [%8], #2 \n" |
| 145 |
"\tldrsh %2, [%9], #2 \n" |
| 146 |
"\tmla %4, %10, %3, %4 \n" |
| 147 |
"\tmla %5, %10, %0, %5 \n" |
| 148 |
"\tmla %6, %10, %1, %6 \n" |
| 149 |
"\tmla %7, %10, %2, %7 \n" |
| 150 |
|
| 151 |
"\tldrsh %3, [%9], #2 \n" |
| 152 |
#endif |
| 153 |
|
| 154 |
"\tldr %10, %11 \n" |
| 155 |
"\tldr %15, %12 \n" |
| 156 |
"\tadd %4, %10, %4, asr #6 \n" |
| 157 |
"\tstr %4, %11 \n" |
| 158 |
"\tldr %10, %13 \n" |
| 159 |
"\tadd %5, %15, %5, asr #6 \n" |
| 160 |
"\tstr %5, %12 \n" |
| 161 |
"\tldr %15, %14 \n" |
| 162 |
"\tadd %6, %10, %6, asr #6 \n" |
| 163 |
"\tadd %7, %15, %7, asr #6 \n" |
| 164 |
"\tstr %6, %13 \n" |
| 165 |
"\tstr %7, %14 \n" |
| 166 |
|
| 167 |
: "=r" (y0), "=r" (y1), "=r" (y2), "=r" (y3), |
| 168 |
"=r" (part1), "=r" (part2), "=r" (part3), "=r" (part4), |
| 169 |
"=r" (x), "=r" (y), "=r" (x0), |
| 170 |
"=m" (sum1), "=m" (sum2), "=m" (sum3), "=m" (sum4), "=r" (dead1) |
| 171 |
: "0" (y0), "1" (y1), "2" (y2), "3" (y3), |
| 172 |
"8" (x), "9" (y), |
| 173 |
"11" (sum1), "12" (sum2), "13" (sum3), "14" (sum4) |
| 174 |
: "cc", "memory" |
| 175 |
); |
| 176 |
} |
| 177 |
corr[nb_pitch-1-i]=sum1; |
| 178 |
corr[nb_pitch-2-i]=sum2; |
| 179 |
corr[nb_pitch-3-i]=sum3; |
| 180 |
corr[nb_pitch-4-i]=sum4; |
| 181 |
} |
| 182 |
|
| 183 |
} |