| 1 |
/* Copyright (C) 2004 Jean-Marc Valin */ |
| 2 |
/** |
| 3 |
@file filters_arm4.h |
| 4 |
@brief Various analysis/synthesis filters (ARM4 version) |
| 5 |
*/ |
| 6 |
/* |
| 7 |
Redistribution and use in source and binary forms, with or without |
| 8 |
modification, are permitted provided that the following conditions |
| 9 |
are met: |
| 10 |
|
| 11 |
- Redistributions of source code must retain the above copyright |
| 12 |
notice, this list of conditions and the following disclaimer. |
| 13 |
|
| 14 |
- Redistributions in binary form must reproduce the above copyright |
| 15 |
notice, this list of conditions and the following disclaimer in the |
| 16 |
documentation and/or other materials provided with the distribution. |
| 17 |
|
| 18 |
- Neither the name of the Xiph.org Foundation nor the names of its |
| 19 |
contributors may be used to endorse or promote products derived from |
| 20 |
this software without specific prior written permission. |
| 21 |
|
| 22 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
| 26 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 27 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 28 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 29 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 30 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
*/ |
| 34 |
|
| 35 |
#define OVERRIDE_NORMALIZE16 |
| 36 |
int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len) |
| 37 |
{ |
| 38 |
spx_sig_t max_val=1; |
| 39 |
int sig_shift; |
| 40 |
int dead1, dead2, dead3, dead4, dead5, dead6; |
| 41 |
|
| 42 |
__asm__ __volatile__ ( |
| 43 |
"\tmov %1, #1 \n" |
| 44 |
"\tmov %3, #0 \n" |
| 45 |
|
| 46 |
".normalize16loop1%=: \n" |
| 47 |
|
| 48 |
"\tldr %4, [%0], #4 \n" |
| 49 |
"\tcmp %4, %1 \n" |
| 50 |
"\tmovgt %1, %4 \n" |
| 51 |
"\tcmp %4, %3 \n" |
| 52 |
"\tmovlt %3, %4 \n" |
| 53 |
|
| 54 |
"\tsubs %2, %2, #1 \n" |
| 55 |
"\tbne .normalize16loop1%=\n" |
| 56 |
|
| 57 |
"\trsb %3, %3, #0 \n" |
| 58 |
"\tcmp %1, %3 \n" |
| 59 |
"\tmovlt %1, %3 \n" |
| 60 |
: "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4), |
| 61 |
"=r" (dead5), "=r" (dead6) |
| 62 |
: "0" (x), "2" (len) |
| 63 |
: "cc"); |
| 64 |
|
| 65 |
sig_shift=0; |
| 66 |
while (max_val>max_scale) |
| 67 |
{ |
| 68 |
sig_shift++; |
| 69 |
max_val >>= 1; |
| 70 |
} |
| 71 |
|
| 72 |
__asm__ __volatile__ ( |
| 73 |
".normalize16loop%=: \n" |
| 74 |
|
| 75 |
"\tldr %4, [%0], #4 \n" |
| 76 |
"\tldr %5, [%0], #4 \n" |
| 77 |
"\tmov %4, %4, asr %3 \n" |
| 78 |
"\tstrh %4, [%1], #2 \n" |
| 79 |
"\tldr %4, [%0], #4 \n" |
| 80 |
"\tmov %5, %5, asr %3 \n" |
| 81 |
"\tstrh %5, [%1], #2 \n" |
| 82 |
"\tldr %5, [%0], #4 \n" |
| 83 |
"\tmov %4, %4, asr %3 \n" |
| 84 |
"\tstrh %4, [%1], #2 \n" |
| 85 |
"\tsubs %2, %2, #1 \n" |
| 86 |
"\tmov %5, %5, asr %3 \n" |
| 87 |
"\tstrh %5, [%1], #2 \n" |
| 88 |
|
| 89 |
"\tbgt .normalize16loop%=\n" |
| 90 |
: "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4), |
| 91 |
"=r" (dead5), "=r" (dead6) |
| 92 |
: "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift) |
| 93 |
: "cc", "memory"); |
| 94 |
return sig_shift; |
| 95 |
} |
| 96 |
|