ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cb_search_arm4.h Source File

cb_search_arm4.h

Go to the documentation of this file.
00001 /* Copyright (C) 2004 Jean-Marc Valin */
00002 /**
00003    @file cb_search_arm4.h
00004    @brief Fixed codebook functions (ARM4 version)
00005 */
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 /* This optimization is temporaly disabled until it is fixed to account for the fact 
00036    that "r" is now a 16-bit array */
00037 #if 0
00038 #define OVERRIDE_COMPUTE_WEIGHTED_CODEBOOK
00039 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)
00040 {
00041    int i, j, k;
00042   //const signed char *shape;
00043    for (i=0;i<shape_cb_size;i+=4)
00044    {
00045 
00046       //shape = shape_cb;
00047       E[0]=0;
00048       E[1]=0;
00049       E[2]=0;
00050       E[3]=0;
00051 
00052       /* Compute codeword response using convolution with impulse response */
00053       for(j=0;j<subvect_size;j++)
00054       {
00055 #if 1
00056           spx_word16_t *res;
00057           res = resp+j;
00058           spx_word32_t resj0,resj1,resj2,resj3;
00059           spx_word32_t dead1, dead2, dead3, dead4, dead5, dead6, dead7, dead8;
00060           __asm__ __volatile__ (
00061                 "mov %0, #0 \n\t"
00062                 "mov %1, #0 \n\t"
00063                 "mov %2, #0 \n\t"
00064                 "mov %3, #0 \n\t"
00065                 ".weighted%=: \n\t"
00066                 "ldrsb %8, [%6] \n\t"
00067                 "ldr %10, [%5], #-4 \n\t"
00068                 "mov %9, %6 \n\t"
00069                 "ldrsb %11, [%9, %7]! \n\t"
00070                 "mla %0, %10, %8, %0 \n\t"
00071                 "ldrsb %8, [%9, %7]! \n\t"
00072                 "mla %1, %10, %11, %1 \n\t"
00073                 "ldrsb %11, [%9, %7]! \n\t"
00074                 "mla %2, %10, %8, %2 \n\t"
00075                 "subs %4, %4, #1 \n\t"
00076                 "mla %3, %10, %11, %3 \n\t"
00077                 "add %6, %6, #1 \n\t"
00078                 "bne .weighted%= \n\t"
00079             : "=r" (resj0), "=r" (resj1), "=r" (resj2), "=r" (resj3),
00080           "=r" (dead1), "=r" (dead2), "=r" (dead3), "=r" (dead4),
00081           "=r" (dead5), "=r" (dead6), "=r" (dead7), "=r" (dead8)
00082             : "4" (j+1), "5" (r+j), "6" (shape_cb), "7" (subvect_size)
00083             : "cc", "memory");
00084 #else
00085           spx_word16_t *res;
00086           res = resp+j;
00087           spx_word32_t resj0=0;
00088           spx_word32_t resj1=0;
00089           spx_word32_t resj2=0;
00090           spx_word32_t resj3=0;
00091           for (k=0;k<=j;k++)
00092           {
00093              const signed char *shape=shape_cb+k;
00094              resj0 = MAC16_16(resj0,*shape,r[j-k]);
00095              shape += subvect_size;
00096              resj1 = MAC16_16(resj1,*shape,r[j-k]);
00097              shape += subvect_size;
00098              resj2 = MAC16_16(resj2,*shape,r[j-k]);
00099              shape += subvect_size;
00100              resj3 = MAC16_16(resj3,*shape,r[j-k]);
00101              shape += subvect_size;
00102           }
00103 #endif
00104 
00105 #ifdef FIXED_POINT
00106           resj0 = SHR(resj0, 11);
00107           resj1 = SHR(resj1, 11);
00108           resj2 = SHR(resj2, 11);
00109           resj3 = SHR(resj3, 11);
00110 #else
00111           resj0 *= 0.03125;
00112           resj1 *= 0.03125;
00113           resj2 *= 0.03125;
00114           resj3 *= 0.03125;
00115 #endif
00116 
00117           /* Compute codeword energy */
00118           E[0]=ADD32(E[0],MULT16_16(resj0,resj0));
00119           E[1]=ADD32(E[1],MULT16_16(resj1,resj1));
00120           E[2]=ADD32(E[2],MULT16_16(resj2,resj2));
00121           E[3]=ADD32(E[3],MULT16_16(resj3,resj3));
00122           *res = resj0;
00123           res += subvect_size;
00124           *res = resj1;
00125           res += subvect_size;
00126           *res = resj2;
00127           res += subvect_size;
00128           *res = resj3;
00129           res += subvect_size;
00130       }
00131       resp += subvect_size<<2;
00132       shape_cb += subvect_size<<2;
00133       E+=4;
00134    }
00135 
00136 }
00137 #endif