ex

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lsp_bfin.h Source File

lsp_bfin.h

Go to the documentation of this file.
00001 /* Copyright (C) 2006 David Rowe */
00002 /**
00003    @file lsp_bfin.h
00004    @author David Rowe
00005    @brief LSP routines optimised for the Blackfin
00006 */
00007 /*
00008    Redistribution and use in source and binary forms, with or without
00009    modification, are permitted provided that the following conditions
00010    are met:
00011    
00012    - Redistributions of source code must retain the above copyright
00013    notice, this list of conditions and the following disclaimer.
00014    
00015    - Redistributions in binary form must reproduce the above copyright
00016    notice, this list of conditions and the following disclaimer in the
00017    documentation and/or other materials provided with the distribution.
00018    
00019    - Neither the name of the Xiph.org Foundation nor the names of its
00020    contributors may be used to endorse or promote products derived from
00021    this software without specific prior written permission.
00022    
00023    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
00027    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00028    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00029    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00030    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00031    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00032    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00033    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 
00036 #define OVERRIDE_CHEB_POLY_EVA
00037 #ifdef OVERRIDE_CHEB_POLY_EVA
00038 static inline spx_word32_t cheb_poly_eva(
00039   spx_word16_t *coef, /* P or Q coefs in Q13 format               */
00040   spx_word16_t     x, /* cos of freq (-1.0 to 1.0) in Q14 format  */
00041   int              m, /* LPC order/2                              */
00042   char         *stack
00043 )
00044 {
00045     spx_word32_t sum;
00046 
00047    __asm__ __volatile__
00048      (
00049       "P0 = %2;\n\t"           /* P0: coef[m], coef[m-1],..., coef[0] */
00050       "R4 = 8192;\n\t"         /* R4: rounding constant               */
00051       "R2 = %1;\n\t"           /* R2: x  */
00052 
00053       "R5 = -16383;\n\t"
00054       "R2 = MAX(R2,R5);\n\t"
00055       "R5 = 16383;\n\t"
00056       "R2 = MIN(R2,R5);\n\t"
00057 
00058       "R3 = W[P0--] (X);\n\t"  /* R3: sum */
00059       "R5 = W[P0--] (X);\n\t"
00060       "R5 = R5.L * R2.L (IS);\n\t"
00061       "R5 = R5 + R4;\n\t"
00062       "R5 >>>= 14;\n\t"
00063       "R3 = R3 + R5;\n\t" 
00064       
00065       "R0 = R2;\n\t"           /* R0: b0 */
00066       "R1 = 16384;\n\t"        /* R1: b1 */
00067       "LOOP cpe%= LC0 = %3;\n\t"
00068       "LOOP_BEGIN cpe%=;\n\t"
00069         "P1 = R0;\n\t" 
00070         "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t"
00071         "R0 >>>= 13;\n\t"
00072         "R0 = R0 - R1;\n\t"
00073         "R1 = P1;\n\t"
00074         "R5 = R5.L * R0.L (IS);\n\t"
00075         "R5 = R5 + R4;\n\t"
00076         "R5 >>>= 14;\n\t"
00077         "R3 = R3 + R5;\n\t"
00078       "LOOP_END cpe%=;\n\t"
00079       "%0 = R3;\n\t"
00080       : "=&d" (sum)
00081       : "a" (x), "a" (&coef[m]), "a" (m-1)
00082       : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1"
00083       );
00084     return sum;
00085 }
00086 #endif
00087 
00088 
00089