ltp_bfin.h
资源名称:tcpmp.rar [点击查看]
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:6k
源码类别:
Windows CE
开发平台:
C/C++
- /* Copyright (C) 2005 Analog Devices
- Author: Jean-Marc Valin
- File: ltp_bfin.h
- Long-Term Prediction functions (Blackfin version)
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- - Neither the name of the Xiph.org Foundation nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #define OVERRIDE_INNER_PROD
- static spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len)
- {
- spx_word32_t sum=0;
- __asm__ __volatile__ (
- "P0 = %3;nt"
- "P1 = %1;nt"
- "P2 = %2;nt"
- "I0 = P1;nt"
- "I1 = P2;nt"
- "L0 = 0;nt"
- "L1 = 0;nt"
- "A0 = 0;nt"
- "R0.L = W[I0++] || R1.L = W[I1++];nt"
- "LOOP inner%= LC0 = P0;nt"
- "LOOP_BEGIN inner%=;nt"
- "A0 += R0.L*R1.L (IS) || R0.L = W[I0++] || R1.L = W[I1++];nt"
- "LOOP_END inner%=;nt"
- "A0 += R0.L*R1.L (IS);nt"
- "A0 = A0 >>> 6;nt"
- "R0 = A0;nt"
- "%0 = R0;nt"
- : "=m" (sum)
- : "m" (x), "m" (y), "d" (len-1)
- : "P0", "P1", "P2", "R0", "R1", "A0", "I0", "I1", "L0", "L1", "R3"
- );
- return sum;
- }
- #define OVERRIDE_PITCH_XCORR
- static void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack)
- {
- corr += nb_pitch - 1;
- __asm__ __volatile__ (
- "P2 = %0;nt"
- "I0 = P2;nt" /* x in I0 */
- "B0 = P2;nt" /* x in B0 */
- "R0 = %3;nt" /* len in R0 */
- "P3 = %3;nt"
- "P3 += -2;nt" /* len in R0 */
- "P4 = %4;nt" /* nb_pitch in R0 */
- "R1 = R0 << 1;nt" /* number of bytes in x */
- "L0 = R1;nt"
- "P0 = %1;nt"
- "P1 = %2;nt"
- "B1 = P1;nt"
- "L1 = 0;nt" /*Disable looping on I1*/
- "r0 = [I0++];nt"
- "LOOP pitch%= LC0 = P4 >> 1;nt"
- "LOOP_BEGIN pitch%=;nt"
- "I1 = P0;nt"
- "A1 = A0 = 0;nt"
- "R1 = [I1++];nt"
- "LOOP inner_prod%= LC1 = P3 >> 1;nt"
- "LOOP_BEGIN inner_prod%=;nt"
- "A0 += R0.L*R1.L , A1 += R0.L*R1.H (is) || R1.L = W[I1++];nt"
- "A0 += R0.H*R1.H , A1 += R0.H*R1.L (is) || R1.H = W[I1++] || R0 = [I0++];nt"
- "LOOP_END inner_prod%=;nt"
- "A0 += R0.L*R1.L , A1 += R0.L*R1.H (is) || R1.L = W[I1++];nt"
- "A0 += R0.H*R1.H , A1 += R0.H*R1.L (is) || R0 = [I0++];nt"
- "A0 = A0 >>> 6;nt"
- "A1 = A1 >>> 6;nt"
- "R2 = A0, R3 = A1;nt"
- "[P1--] = r2;nt"
- "[P1--] = r3;nt"
- "P0 += 4;nt"
- "LOOP_END pitch%=;nt"
- "L0 = 0;nt"
- : : "m" (_x), "m" (_y), "m" (corr), "m" (len), "m" (nb_pitch)
- : "A0", "A1", "P0", "P1", "P2", "P3", "P4", "R0", "R1", "R2", "R3", "I0", "I1", "L0", "L1", "B0", "B1", "memory"
- );
- }
- #define OVERRIDE_COMPUTE_PITCH_ERROR
- static inline spx_word32_t compute_pitch_error(spx_word32_t *C, spx_word16_t *g, spx_word16_t pitch_control)
- {
- spx_word32_t sum;
- __asm__ __volatile__
- (
- "A0 = A1 = 0;nt"
- "R0 = [%1++];nt"
- "R1.L = %2.L*%5.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %3.L*%5.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %4.L*%5.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 += R1.L*R0.H (IS), A1 += R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %2.L*%3.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %4.L*%3.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %4.L*%2.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %2.L*%2.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %3.L*%3.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS) || R0 = [%1++];nt"
- "R1.L = %4.L*%4.L (IS);nt"
- "R0 <<= 1;nt"
- "A0 -= R1.L*R0.H (IS), A1 -= R1.L*R0.L (M,IS);nt"
- "A1 = A1 >>> 16;nt"
- "A0 += A1;nt"
- "%0 = A0;nt"
- : "=&D" (sum), "=a" (C)
- : "d" (g[0]), "d" (g[1]), "d" (g[2]), "d" (pitch_control), "1" (C)
- : "R0", "R1", "R2", "A0"
- );
- return sum;
- }