bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
quant_lsp_bfin.h
Go to the documentation of this file.
00001 /* Copyright (C) 2006 David Rowe */ 00002 /** 00003 @file quant_lsp_bfin.h 00004 @author David Rowe 00005 @brief Various compatibility routines for Speex (Blackfin version) 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_LSP_QUANT 00037 #ifdef OVERRIDE_LSP_QUANT 00038 00039 /* 00040 Note http://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html 00041 well tell you all the magic resgister constraints used below 00042 for gcc in-line asm. 00043 */ 00044 00045 static int lsp_quant( 00046 spx_word16_t *x, 00047 const signed char *cdbk, 00048 int nbVec, 00049 int nbDim 00050 ) 00051 { 00052 int j; 00053 spx_word32_t best_dist=1<<30; 00054 int best_id=0; 00055 00056 __asm__ __volatile__ 00057 ( 00058 " %0 = 1 (X);\n\t" /* %0: best_dist */ 00059 " %0 <<= 30;\n\t" 00060 " %1 = 0 (X);\n\t" /* %1: best_i */ 00061 " P2 = %3\n\t" /* P2: ptr to cdbk */ 00062 " R5 = 0;\n\t" /* R5: best cb entry */ 00063 00064 " R0 = %5;\n\t" /* set up circ addr */ 00065 " R0 <<= 1;\n\t" 00066 " L0 = R0;\n\t" 00067 " I0 = %2;\n\t" /* %2: &x[0] */ 00068 " B0 = %2;\n\t" 00069 00070 " R2.L = W [I0++];\n\t" 00071 " LSETUP (lq1, lq2) LC0 = %4;\n\t" 00072 "lq1: R3 = 0;\n\t" /* R3: dist */ 00073 " LSETUP (lq3, lq4) LC1 = %5;\n\t" 00074 "lq3: R1 = B [P2++] (X);\n\t" 00075 " R1 <<= 5;\n\t" 00076 " R0.L = R2.L - R1.L || R2.L = W [I0++];\n\t" 00077 " R0 = R0.L*R0.L;\n\t" 00078 "lq4: R3 = R3 + R0;\n\t" 00079 00080 " cc =R3<%0;\n\t" 00081 " if cc %0=R3;\n\t" 00082 " if cc %1=R5;\n\t" 00083 "lq2: R5 += 1;\n\t" 00084 " L0 = 0;\n\t" 00085 : "=&d" (best_dist), "=&d" (best_id) 00086 : "a" (x), "b" (cdbk), "a" (nbVec), "a" (nbDim) 00087 : "I0", "P2", "R0", "R1", "R2", "R3", "R5", "L0", "B0", "A0" 00088 ); 00089 00090 for (j=0;j<nbDim;j++) { 00091 x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5)); 00092 } 00093 return best_id; 00094 } 00095 #endif 00096 00097 #define OVERRIDE_LSP_WEIGHT_QUANT 00098 #ifdef OVERRIDE_LSP_WEIGHT_QUANT 00099 00100 /* 00101 Note http://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html 00102 well tell you all the magic resgister constraints used below 00103 for gcc in-line asm. 00104 */ 00105 00106 static int lsp_weight_quant( 00107 spx_word16_t *x, 00108 spx_word16_t *weight, 00109 const signed char *cdbk, 00110 int nbVec, 00111 int nbDim 00112 ) 00113 { 00114 int j; 00115 spx_word32_t best_dist=1<<30; 00116 int best_id=0; 00117 00118 __asm__ __volatile__ 00119 ( 00120 " %0 = 1 (X);\n\t" /* %0: best_dist */ 00121 " %0 <<= 30;\n\t" 00122 " %1 = 0 (X);\n\t" /* %1: best_i */ 00123 " P2 = %4\n\t" /* P2: ptr to cdbk */ 00124 " R5 = 0;\n\t" /* R5: best cb entry */ 00125 00126 " R0 = %6;\n\t" /* set up circ addr */ 00127 " R0 <<= 1;\n\t" 00128 " L0 = R0;\n\t" 00129 " L1 = R0;\n\t" 00130 " I0 = %2;\n\t" /* %2: &x[0] */ 00131 " I1 = %3;\n\t" /* %3: &weight[0] */ 00132 " B0 = %2;\n\t" 00133 " B1 = %3;\n\t" 00134 00135 " LSETUP (lwq1, lwq2) LC0 = %5;\n\t" 00136 "lwq1: R3 = 0 (X);\n\t" /* R3: dist */ 00137 " LSETUP (lwq3, lwq4) LC1 = %6;\n\t" 00138 "lwq3: R0.L = W [I0++] || R2.L = W [I1++];\n\t" 00139 " R1 = B [P2++] (X);\n\t" 00140 " R1 <<= 5;\n\t" 00141 " R0.L = R0.L - R1.L;\n\t" 00142 " R0 = R0.L*R0.L;\n\t" 00143 " A1 = R2.L*R0.L (M,IS);\n\t" 00144 " A1 = A1 >>> 16;\n\t" 00145 " R1 = (A1 += R2.L*R0.H) (IS);\n\t" 00146 "lwq4: R3 = R3 + R1;\n\t" 00147 00148 " cc =R3<%0;\n\t" 00149 " if cc %0=R3;\n\t" 00150 " if cc %1=R5;\n\t" 00151 "lwq2: R5 += 1;\n\t" 00152 " L0 = 0;\n\t" 00153 " L1 = 0;\n\t" 00154 : "=&d" (best_dist), "=&d" (best_id) 00155 : "a" (x), "a" (weight), "b" (cdbk), "a" (nbVec), "a" (nbDim) 00156 : "I0", "I1", "P2", "R0", "R1", "R2", "R3", "R5", "A1", 00157 "L0", "L1", "B0", "B1" 00158 ); 00159 00160 for (j=0;j<nbDim;j++) { 00161 x[j] = SUB16(x[j],SHL16((spx_word16_t)cdbk[best_id*nbDim+j],5)); 00162 } 00163 return best_id; 00164 } 00165 #endif
Generated on Tue Jul 12 2022 16:28:53 by 1.7.2