filters_arm4.h

Go to the documentation of this file.
00001 /* Copyright (C) 2004 Jean-Marc Valin */
00006 /*
00007    Redistribution and use in source and binary forms, with or without
00008    modification, are permitted provided that the following conditions
00009    are met:
00010    
00011    - Redistributions of source code must retain the above copyright
00012    notice, this list of conditions and the following disclaimer.
00013    
00014    - Redistributions in binary form must reproduce the above copyright
00015    notice, this list of conditions and the following disclaimer in the
00016    documentation and/or other materials provided with the distribution.
00017    
00018    - Neither the name of the Xiph.org Foundation nor the names of its
00019    contributors may be used to endorse or promote products derived from
00020    this software without specific prior written permission.
00021    
00022    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00026    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00028    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00029    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00030    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00031    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00032    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 */
00034 
00035 #define OVERRIDE_NORMALIZE16
00036 int normalize16(const spx_sig_t *x, spx_word16_t *y, int max_scale, int len)
00037 {
00038    int i;
00039    spx_sig_t max_val=1;
00040    int sig_shift;
00041    int dead1, dead2, dead3, dead4, dead5, dead6;
00042 
00043    __asm__ __volatile__ (
00044          "\tmov %1, #1 \n"
00045          "\tmov %3, #0 \n"
00046 
00047          ".normalize16loop1%=: \n"
00048 
00049          "\tldr %4, [%0], #4 \n"
00050          "\tcmps %4, %1 \n"
00051          "\tmovgt %1, %4 \n"
00052          "\tcmps %4, %3 \n"
00053          "\tmovlt %3, %4 \n"
00054 
00055          "\tsubs %2, %2, #1 \n"
00056          "\tbne .normalize16loop1%=\n"
00057 
00058          "\trsb %3, %3, #0 \n"
00059          "\tcmp %1, %3 \n"
00060          "\tmovlt %1, %3 \n"
00061    : "=r" (dead1), "=r" (max_val), "=r" (dead3), "=r" (dead4),
00062    "=r" (dead5), "=r" (dead6)
00063    : "0" (x), "2" (len)
00064    : "cc");
00065 
00066    sig_shift=0;
00067    while (max_val>max_scale)
00068    {
00069       sig_shift++;
00070       max_val >>= 1;
00071    }
00072    
00073    __asm__ __volatile__ (
00074          ".normalize16loop%=: \n"
00075 
00076          "\tldr %4, [%0], #4 \n"
00077          "\tldr %5, [%0], #4 \n"
00078          "\tmov %4, %4, asr %3 \n"
00079          "\tstrh %4, [%1], #2 \n"
00080          "\tldr %4, [%0], #4 \n"
00081          "\tmov %5, %5, asr %3 \n"
00082          "\tstrh %5, [%1], #2 \n"
00083          "\tldr %5, [%0], #4 \n"
00084          "\tmov %4, %4, asr %3 \n"
00085          "\tstrh %4, [%1], #2 \n"
00086          "\tsubs %2, %2, #1 \n"
00087          "\tmov %5, %5, asr %3 \n"
00088          "\tstrh %5, [%1], #2 \n"
00089 
00090          "\tbge .normalize16loop%=\n"
00091    : "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
00092    "=r" (dead5), "=r" (dead6)
00093    : "0" (x), "1" (y), "2" (len>>2), "3" (sig_shift)
00094    : "cc", "memory");
00095    return sig_shift;
00096 }
00097 
00098 #define OVERRIDE_FILTER_MEM2
00099 void filter_mem2(const spx_sig_t *x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
00100 {
00101    int i,j;
00102    spx_sig_t xi,yi,nyi;
00103 
00104    for (i=0;i<N;i++)
00105    {
00106       int deadm, deadn, deadd, deadidx, x1, y1, dead1, dead2, dead3, dead4, dead5, dead6;
00107       xi=SATURATE(x[i],805306368);
00108       yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
00109       nyi = -yi;
00110       y[i] = yi;
00111       __asm__ __volatile__ (
00112             "\tldrsh %6, [%1], #2\n"
00113             "\tsmull %8, %9, %4, %6\n"
00114 #ifdef SHORTCUTS
00115             "\tldrsh %6, [%2], #2\n"
00116             "\tldr %10, [%0, #4]\n"
00117             "\tmov %8, %8, lsr #15\n"
00118             "\tsmull %7, %11, %5, %6\n"
00119             "\tldrsh %6, [%1], #2\n"
00120             "\tadd %8, %8, %9, lsl #17\n"
00121             "\tadd %10, %10, %8\n"
00122             "\tsmull %8, %9, %4, %6\n"
00123             "\tadd %10, %10, %7, lsr #15\n"
00124             "\tadd %10, %10, %11, lsl #17\n"
00125             "\tstr %10, [%0], #4 \n"
00126 
00127             "\tldrsh %6, [%2], #2\n"
00128             "\tldr %10, [%0, #4]\n"
00129             "\tmov %8, %8, lsr #15\n"
00130             "\tsmull %7, %11, %5, %6\n"
00131             "\tldrsh %6, [%1], #2\n"
00132             "\tadd %8, %8, %9, lsl #17\n"
00133             "\tadd %10, %10, %8\n"
00134             "\tsmull %8, %9, %4, %6\n"
00135             "\tadd %10, %10, %7, lsr #15\n"
00136             "\tadd %10, %10, %11, lsl #17\n"
00137             "\tstr %10, [%0], #4 \n"
00138 
00139             "\tldrsh %6, [%2], #2\n"
00140             "\tldr %10, [%0, #4]\n"
00141             "\tmov %8, %8, lsr #15\n"
00142             "\tsmull %7, %11, %5, %6\n"
00143             "\tldrsh %6, [%1], #2\n"
00144             "\tadd %8, %8, %9, lsl #17\n"
00145             "\tadd %10, %10, %8\n"
00146             "\tsmull %8, %9, %4, %6\n"
00147             "\tadd %10, %10, %7, lsr #15\n"
00148             "\tadd %10, %10, %11, lsl #17\n"
00149             "\tstr %10, [%0], #4 \n"
00150 
00151             "\tldrsh %6, [%2], #2\n"
00152             "\tldr %10, [%0, #4]\n"
00153             "\tmov %8, %8, lsr #15\n"
00154             "\tsmull %7, %11, %5, %6\n"
00155             "\tldrsh %6, [%1], #2\n"
00156             "\tadd %8, %8, %9, lsl #17\n"
00157             "\tadd %10, %10, %8\n"
00158             "\tsmull %8, %9, %4, %6\n"
00159             "\tadd %10, %10, %7, lsr #15\n"
00160             "\tadd %10, %10, %11, lsl #17\n"
00161             "\tstr %10, [%0], #4 \n"
00162 
00163             "\tldrsh %6, [%2], #2\n"
00164             "\tldr %10, [%0, #4]\n"
00165             "\tmov %8, %8, lsr #15\n"
00166             "\tsmull %7, %11, %5, %6\n"
00167             "\tldrsh %6, [%1], #2\n"
00168             "\tadd %8, %8, %9, lsl #17\n"
00169             "\tadd %10, %10, %8\n"
00170             "\tsmull %8, %9, %4, %6\n"
00171             "\tadd %10, %10, %7, lsr #15\n"
00172             "\tadd %10, %10, %11, lsl #17\n"
00173             "\tstr %10, [%0], #4 \n"
00174 
00175             "\tldrsh %6, [%2], #2\n"
00176             "\tldr %10, [%0, #4]\n"
00177             "\tmov %8, %8, lsr #15\n"
00178             "\tsmull %7, %11, %5, %6\n"
00179             "\tldrsh %6, [%1], #2\n"
00180             "\tadd %8, %8, %9, lsl #17\n"
00181             "\tadd %10, %10, %8\n"
00182             "\tsmull %8, %9, %4, %6\n"
00183             "\tadd %10, %10, %7, lsr #15\n"
00184             "\tadd %10, %10, %11, lsl #17\n"
00185             "\tstr %10, [%0], #4 \n"
00186 
00187             "\tldrsh %6, [%2], #2\n"
00188             "\tldr %10, [%0, #4]\n"
00189             "\tmov %8, %8, lsr #15\n"
00190             "\tsmull %7, %11, %5, %6\n"
00191             "\tldrsh %6, [%1], #2\n"
00192             "\tadd %8, %8, %9, lsl #17\n"
00193             "\tadd %10, %10, %8\n"
00194             "\tsmull %8, %9, %4, %6\n"
00195             "\tadd %10, %10, %7, lsr #15\n"
00196             "\tadd %10, %10, %11, lsl #17\n"
00197             "\tstr %10, [%0], #4 \n"
00198 
00199             "\tldrsh %6, [%2], #2\n"
00200             "\tldr %10, [%0, #4]\n"
00201             "\tmov %8, %8, lsr #15\n"
00202             "\tsmull %7, %11, %5, %6\n"
00203             "\tldrsh %6, [%1], #2\n"
00204             "\tadd %8, %8, %9, lsl #17\n"
00205             "\tadd %10, %10, %8\n"
00206             "\tsmull %8, %9, %4, %6\n"
00207             "\tadd %10, %10, %7, lsr #15\n"
00208             "\tadd %10, %10, %11, lsl #17\n"
00209             "\tstr %10, [%0], #4 \n"
00210 
00211             "\tldrsh %6, [%2], #2\n"
00212             "\tldr %10, [%0, #4]\n"
00213             "\tmov %8, %8, lsr #15\n"
00214             "\tsmull %7, %11, %5, %6\n"
00215             "\tldrsh %6, [%1], #2\n"
00216             "\tadd %8, %8, %9, lsl #17\n"
00217             "\tadd %10, %10, %8\n"
00218             "\tsmull %8, %9, %4, %6\n"
00219             "\tadd %10, %10, %7, lsr #15\n"
00220             "\tadd %10, %10, %11, lsl #17\n"
00221             "\tstr %10, [%0], #4 \n"
00222 
00223 
00224 #else
00225             ".filterloop%=: \n"
00226             "\tldrsh %6, [%2], #2\n"
00227             "\tldr %10, [%0, #4]\n"
00228             "\tmov %8, %8, lsr #15\n"
00229             "\tsmull %7, %11, %5, %6\n"
00230             "\tadd %8, %8, %9, lsl #17\n"
00231             "\tldrsh %6, [%1], #2\n"
00232             "\tadd %10, %10, %8\n"
00233             "\tsmull %8, %9, %4, %6\n"
00234             "\tadd %10, %10, %7, lsr #15\n"
00235             "\tsubs %3, %3, #1\n"
00236             "\tadd %10, %10, %11, lsl #17\n"
00237             "\tstr %10, [%0], #4 \n"
00238             "\t bne .filterloop%=\n"
00239 #endif
00240             "\tmov %8, %8, lsr #15\n"
00241             "\tadd %10, %8, %9, lsl #17\n"
00242             "\tldrsh %6, [%2], #2\n"
00243             "\tsmull %8, %9, %5, %6\n"
00244             "\tadd %10, %10, %8, lsr #15\n"
00245             "\tadd %10, %10, %9, lsl #17\n"
00246             "\tstr %10, [%0], #4 \n"
00247 
00248          : "=r" (deadm), "=r" (deadn), "=r" (deadd), "=r" (deadidx),
00249       "=r" (xi), "=r" (nyi), "=r" (dead1), "=r" (dead2),
00250       "=r" (dead3), "=r" (dead4), "=r" (dead5), "=r" (dead6)
00251          : "0" (mem), "1" (num), "2" (den), "3" (ord-1), "4" (xi), "5" (nyi)
00252          : "cc", "memory");
00253    
00254    }
00255 }
00256 
00257 #define OVERRIDE_IIR_MEM2
00258 void iir_mem2(const spx_sig_t *x, const spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
00259 {
00260    int i,j;
00261    spx_sig_t xi,yi,nyi;
00262 
00263    for (i=0;i<N;i++)
00264    {
00265       int deadm, deadd, deadidx, dead1, dead2, dead3, dead4, dead5, dead6;
00266       xi=SATURATE(x[i],805306368);
00267       yi = SATURATE(ADD32(xi, SHL(mem[0],2)),805306368);
00268       nyi = -yi;
00269       y[i] = yi;
00270       __asm__ __volatile__ (
00271             "\tldrsh %4, [%1], #2\n"
00272             "\tsmull %5, %6, %3, %4\n"
00273 
00274 #ifdef SHORTCUTS
00275                         
00276             "\tldrsh %4, [%1], #2\n"
00277             "\tmov %5, %5, lsr #15\n"
00278             "\tldr %7, [%0, #4]\n"
00279             "\tadd %8, %5, %6, lsl #17\n"
00280             "\tsmull %5, %6, %3, %4\n"
00281             "\tadd %7, %7, %8\n"
00282             "\tstr %7, [%0], #4 \n"
00283 
00284                  
00285             "\tldrsh %4, [%1], #2\n"
00286             "\tmov %5, %5, lsr #15\n"
00287             "\tldr %9, [%0, #4]\n"
00288             "\tadd %8, %5, %6, lsl #17\n"
00289             "\tsmull %5, %6, %3, %4\n"
00290             "\tadd %9, %9, %8\n"
00291             "\tstr %9, [%0], #4 \n"
00292 
00293             "\tldrsh %4, [%1], #2\n"
00294             "\tmov %5, %5, lsr #15\n"
00295             "\tldr %7, [%0, #4]\n"
00296             "\tadd %8, %5, %6, lsl #17\n"
00297             "\tsmull %5, %6, %3, %4\n"
00298             "\tadd %7, %7, %8\n"
00299             "\tstr %7, [%0], #4 \n"
00300 
00301             
00302             "\tldrsh %4, [%1], #2\n"
00303             "\tmov %5, %5, lsr #15\n"
00304             "\tldr %9, [%0, #4]\n"
00305             "\tadd %8, %5, %6, lsl #17\n"
00306             "\tsmull %5, %6, %3, %4\n"
00307             "\tadd %9, %9, %8\n"
00308             "\tstr %9, [%0], #4 \n"
00309 
00310             "\tldrsh %4, [%1], #2\n"
00311             "\tmov %5, %5, lsr #15\n"
00312             "\tldr %7, [%0, #4]\n"
00313             "\tadd %8, %5, %6, lsl #17\n"
00314             "\tsmull %5, %6, %3, %4\n"
00315             "\tadd %7, %7, %8\n"
00316             "\tstr %7, [%0], #4 \n"
00317 
00318             
00319             "\tldrsh %4, [%1], #2\n"
00320             "\tmov %5, %5, lsr #15\n"
00321             "\tldr %9, [%0, #4]\n"
00322             "\tadd %8, %5, %6, lsl #17\n"
00323             "\tsmull %5, %6, %3, %4\n"
00324             "\tadd %9, %9, %8\n"
00325             "\tstr %9, [%0], #4 \n"
00326 
00327             "\tldrsh %4, [%1], #2\n"
00328             "\tmov %5, %5, lsr #15\n"
00329             "\tldr %7, [%0, #4]\n"
00330             "\tadd %8, %5, %6, lsl #17\n"
00331             "\tsmull %5, %6, %3, %4\n"
00332             "\tadd %7, %7, %8\n"
00333             "\tstr %7, [%0], #4 \n"
00334 
00335             
00336             "\tldrsh %4, [%1], #2\n"
00337             "\tmov %5, %5, lsr #15\n"
00338             "\tldr %9, [%0, #4]\n"
00339             "\tadd %8, %5, %6, lsl #17\n"
00340             "\tsmull %5, %6, %3, %4\n"
00341             "\tadd %9, %9, %8\n"
00342             "\tstr %9, [%0], #4 \n"
00343 
00344             "\tldrsh %4, [%1], #2\n"
00345             "\tmov %5, %5, lsr #15\n"
00346             "\tldr %7, [%0, #4]\n"
00347             "\tadd %8, %5, %6, lsl #17\n"
00348             "\tsmull %5, %6, %3, %4\n"
00349             "\tadd %7, %7, %8\n"
00350             "\tstr %7, [%0], #4 \n"
00351 
00352             
00353             
00354 #else
00355             ".iirloop%=: \n"
00356             "\tldr %7, [%0, #4]\n"
00357 
00358             "\tldrsh %4, [%1], #2\n"
00359             "\tmov %5, %5, lsr #15\n"
00360             "\tadd %8, %5, %6, lsl #17\n"
00361             "\tsmull %5, %6, %3, %4\n"
00362             "\tadd %7, %7, %8\n"
00363             "\tstr %7, [%0], #4 \n"
00364             "\tsubs %2, %2, #1\n"
00365             "\t bne .iirloop%=\n"
00366             
00367 #endif
00368             "\tmov %5, %5, lsr #15\n"
00369             "\tadd %7, %5, %6, lsl #17\n"
00370             "\tstr %7, [%0], #4 \n"
00371 
00372          : "=r" (deadm), "=r" (deadd), "=r" (deadidx), "=r" (nyi),
00373       "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
00374       "=r" (dead5), "=r" (dead6)
00375          : "0" (mem), "1" (den), "2" (ord-1), "3" (nyi)
00376          : "cc", "memory");
00377    
00378    }
00379 }

Generated on Fri Jan 2 13:28:35 2009 for speex by  doxygen 1.4.6