bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
vq_bfin.h
Go to the documentation of this file.
00001 /* Copyright (C) 2005 Analog Devices */ 00002 /** 00003 @file vq_bfin.h 00004 @author Jean-Marc Valin 00005 @brief Blackfin-optimized vq routine 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_VQ_NBEST 00037 void vq_nbest(spx_word16_t *in, const spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist, char *stack) 00038 { 00039 if (N==1) 00040 { 00041 best_dist[0] = 2147483647; 00042 { 00043 spx_word32_t dist; 00044 __asm__ __volatile__ 00045 ( 00046 "LC0 = %8;\n\t" 00047 "R2 = 0;\n\t" 00048 "I0 = %6;\n\t" 00049 "B0 = %6;\n\t" 00050 "L0 = %9;\n\t" 00051 "LOOP entries_loop%= LC0;\n\t" 00052 "LOOP_BEGIN entries_loop%=;\n\t" 00053 "%0 = [%4++];\n\t" 00054 "%0 >>= 1;\n\t" 00055 "A0 = %0;\n\t" 00056 "R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" 00057 "LOOP vq_loop%= LC1 = %5;\n\t" 00058 "LOOP_BEGIN vq_loop%=;\n\t" 00059 "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%7] || R1.L = W[I0++];\n\t" 00060 "LOOP_END vq_loop%=;\n\t" 00061 "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" 00062 "cc = %0 < %2;\n\t" 00063 "if cc %2 = %0;\n\t" 00064 "if cc %3 = R2;\n\t" 00065 "R2 += 1;\n\t" 00066 "LOOP_END entries_loop%=;\n\t" 00067 : "=&D" (dist), "=&a" (codebook), "=&d" (best_dist[0]), "=&d" (nbest[0]), "=&a" (E) 00068 : "a" (len-1), "a" (in), "a" (2), "d" (entries), "d" (len<<1), "1" (codebook), "4" (E), "2" (best_dist[0]), "3" (nbest[0]) 00069 : "R0", "R1", "R2", "I0", "L0", "B0", "A0", "cc", "memory" 00070 ); 00071 } 00072 } else { 00073 int i,k,used; 00074 used = 0; 00075 for (i=0;i<entries;i++) 00076 { 00077 spx_word32_t dist; 00078 __asm__ 00079 ( 00080 "%0 >>= 1;\n\t" 00081 "A0 = %0;\n\t" 00082 "I0 = %3;\n\t" 00083 "L0 = 0;\n\t" 00084 "R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" 00085 "LOOP vq_loop%= LC0 = %2;\n\t" 00086 "LOOP_BEGIN vq_loop%=;\n\t" 00087 "%0 = (A0 -= R0.L*R1.L) (IS) || R0.L = W[%1++%4] || R1.L = W[I0++];\n\t" 00088 "LOOP_END vq_loop%=;\n\t" 00089 "%0 = (A0 -= R0.L*R1.L) (IS);\n\t" 00090 : "=D" (dist), "=a" (codebook) 00091 : "a" (len-1), "a" (in), "a" (2), "1" (codebook), "0" (E[i]) 00092 : "R0", "R1", "I0", "L0", "A0" 00093 ); 00094 if (i<N || dist<best_dist[N-1]) 00095 { 00096 for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--) 00097 { 00098 best_dist[k]=best_dist[k-1]; 00099 nbest[k] = nbest[k-1]; 00100 } 00101 best_dist[k]=dist; 00102 nbest[k]=i; 00103 used++; 00104 } 00105 } 00106 } 00107 }
Generated on Tue Jul 12 2022 16:28:54 by 1.7.2