ex

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

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

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