1 /* Copyright (C) 2006 David Rowe */
5 @brief Various compatibility routines for Speex (Blackfin version)
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
12 - Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
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.
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.
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.
36 #define OVERRIDE_LSP_QUANT
37 #ifdef OVERRIDE_LSP_QUANT
40 Note http://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
41 well tell you all the magic resgister constraints used below
47 const signed char *cdbk,
53 spx_word32_t best_dist=1<<30;
58 " %0 = 1 (X);\n\t" /* %0: best_dist */
60 " %1 = 0 (X);\n\t" /* %1: best_i */
61 " P2 = %3\n\t" /* P2: ptr to cdbk */
62 " R5 = 0;\n\t" /* R5: best cb entry */
64 " R0 = %5;\n\t" /* set up circ addr */
67 " I0 = %2;\n\t" /* %2: &x[0] */
70 " R2.L = W [I0++];\n\t"
71 " LSETUP (1f, 2f) LC0 = %4;\n\t"
72 "1: R3 = 0;\n\t" /* R3: dist */
73 " LSETUP (3f, 4f) LC1 = %5;\n\t"
74 "3: R1 = B [P2++] (X);\n\t"
76 " R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t"
77 " R0 = R0.L*R0.L;\n\t"
78 "4: R3 = R3 + R0;\n\t"
85 : "=&d" (best_dist), "=&d" (best_id)
86 : "a" (x), "b" (cdbk), "a" (nbVec), "a" (nbDim)
87 : "I0", "P2", "R0", "R1", "R2", "R3", "R5", "L0", "B0", "A0"
90 for (j=0;j<nbDim;j++) {
91 x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));
97 #define OVERRIDE_LSP_WEIGHT_QUANT
98 #ifdef OVERRIDE_LSP_WEIGHT_QUANT
101 Note http://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
102 well tell you all the magic resgister constraints used below
106 static int lsp_weight_quant(
108 spx_word16_t *weight,
109 const signed char *cdbk,
115 spx_word32_t best_dist=1<<30;
120 " %0 = 1 (X);\n\t" /* %0: best_dist */
122 " %1 = 0 (X);\n\t" /* %1: best_i */
123 " P2 = %4\n\t" /* P2: ptr to cdbk */
124 " R5 = 0;\n\t" /* R5: best cb entry */
126 " R0 = %6;\n\t" /* set up circ addr */
130 " I0 = %2;\n\t" /* %2: &x[0] */
131 " I1 = %3;\n\t" /* %3: &weight[0] */
135 " LSETUP (1f, 2f) LC0 = %5;\n\t"
136 "1: R3 = 0 (X);\n\t" /* R3: dist */
137 " LSETUP (3f, 4f) LC1 = %6;\n\t"
138 "3: R0.L = W [I0++] || R2.L = W [I1++];\n\t"
139 " R1 = B [P2++] (X);\n\t"
141 " R0.L = R0.L - R1.L;\n\t"
142 " R0 = R0.L*R0.L;\n\t"
143 " A1 = R2.L*R0.L (M,IS);\n\t"
144 " A1 = A1 >>> 16;\n\t"
145 " R1 = (A1 += R2.L*R0.H) (IS);\n\t"
146 "4: R3 = R3 + R1;\n\t"
154 : "=&d" (best_dist), "=&d" (best_id)
155 : "a" (x), "a" (weight), "b" (cdbk), "a" (nbVec), "a" (nbDim)
156 : "I0", "I1", "P2", "R0", "R1", "R2", "R3", "R5", "A1",
157 "L0", "L1", "B0", "B1"
160 for (j=0;j<nbDim;j++) {
161 x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5));