1 /* Copyright (C) 2006 David Rowe */ 2 /** 3 @file lsp_bfin.h 4 @author David Rowe 5 @brief LSP routines optimised for the Blackfin 6 */ 7 /* 8 Redistribution and use in source and binary forms, with or without 9 modification, are permitted provided that the following conditions 10 are met: 11 12 - Redistributions of source code must retain the above copyright 13 notice, this list of conditions and the following disclaimer. 14 15 - Redistributions in binary form must reproduce the above copyright 16 notice, this list of conditions and the following disclaimer in the 17 documentation and/or other materials provided with the distribution. 18 19 - Neither the name of the Xiph.org Foundation nor the names of its 20 contributors may be used to endorse or promote products derived from 21 this software without specific prior written permission. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #define OVERRIDE_CHEB_POLY_EVA 37 #ifdef OVERRIDE_CHEB_POLY_EVA 38 static inline spx_word32_t cheb_poly_eva( 39 spx_word16_t *coef, /* P or Q coefs in Q13 format */ 40 spx_word16_t x, /* cos of freq (-1.0 to 1.0) in Q14 format */ 41 int m, /* LPC order/2 */ 42 char *stack 43 ) 44 { 45 spx_word32_t sum; 46 47 __asm__ __volatile__ 48 ( 49 "P0 = %2;\n\t" /* P0: coef[m], coef[m-1],..., coef[0] */ 50 "R4 = 8192;\n\t" /* R4: rounding constant */ 51 "R2 = %1;\n\t" /* R2: x */ 52 53 "R5 = -16383;\n\t" 54 "R2 = MAX(R2,R5);\n\t" 55 "R5 = 16383;\n\t" 56 "R2 = MIN(R2,R5);\n\t" 57 58 "R3 = W[P0--] (X);\n\t" /* R3: sum */ 59 "R5 = W[P0--] (X);\n\t" 60 "R5 = R5.L * R2.L (IS);\n\t" 61 "R5 = R5 + R4;\n\t" 62 "R5 >>>= 14;\n\t" 63 "R3 = R3 + R5;\n\t" 64 65 "R0 = R2;\n\t" /* R0: b0 */ 66 "R1 = 16384;\n\t" /* R1: b1 */ 67 "LOOP cpe%= LC0 = %3;\n\t" 68 "LOOP_BEGIN cpe%=;\n\t" 69 "P1 = R0;\n\t" 70 "R0 = R2.L * R0.L (IS) || R5 = W[P0--] (X);\n\t" 71 "R0 >>>= 13;\n\t" 72 "R0 = R0 - R1;\n\t" 73 "R1 = P1;\n\t" 74 "R5 = R5.L * R0.L (IS);\n\t" 75 "R5 = R5 + R4;\n\t" 76 "R5 >>>= 14;\n\t" 77 "R3 = R3 + R5;\n\t" 78 "LOOP_END cpe%=;\n\t" 79 "%0 = R3;\n\t" 80 : "=&d" (sum) 81 : "a" (x), "a" (&coef[m]), "a" (m-1) 82 : "R0", "R1", "R3", "R2", "R4", "R5", "P0", "P1" 83 ); 84 return sum; 85 } 86 #endif 87 88 89 90