⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 convolve.c

📁 君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图片解码,浏览,电子书,录音,想学ucos,识货的人就下吧 russblock fmradio explore set
💻 C
字号:
/***********************************************************************************      GSM AMR-NB speech codec   R98   Version 7.6.0   December 12, 2001*                                R99   Version 3.3.0                *                                REL-4 Version 4.1.0                ***********************************************************************************      File             : convolve.c*      Purpose          : Perform the convolution between two vectors x[]*                       : and h[] and write the result in the vector y[].*                       : All vectors are of length L and only the first*                       : L samples of the convolution are computed.**********************************************************************************//**********************************************************************************                         MODULE INCLUDE FILE AND VERSION ID*********************************************************************************/#include "convolve.h"const char convolve_id[] = "@(#)$Id $" convolve_h; /**********************************************************************************                         INCLUDE FILES*********************************************************************************/#include "typedef.h"#include "basic_op.h"#include "count.h"//add for jzmedia accerative instruction sets#ifdef JZ4740_MXU_OPT#include "jzmedia.h"#endif /**********************************************************************************                         LOCAL VARIABLES AND TABLES*********************************************************************************/ /**********************************************************************************                         PUBLIC PROGRAM CODE*********************************************************************************//************************************************************************* * *  FUNCTION:   Convolve * *  PURPOSE: *     Perform the convolution between two vectors x[] and h[] and *     write the result in the vector y[]. All vectors are of length L *     and only the first L samples of the convolution are computed. * *  DESCRIPTION: *     The convolution is given by * *          y[n] = sum_{i=0}^{n} x[i] h[n-i],        n=0,...,L-1 * *************************************************************************/void Convolve (    Word16 x[],        /* (i)     : input vector                           */    Word16 h[],        /* (i)     : impulse response                       */    Word16 y[],        /* (o)     : output vector                          */    Word16 L           /* (i)     : vector size                            */){    Word16 i, n;#ifdef JZ4740_MXU_OPT#define ADD_MASK   0xFFFFFFFC#define REF_MASK   0x03    Word16 *p_x, *p_h, *px_loop, *ph_loop;    Word32 ref_x, ref_h;    Word16 temp_y[2];    p_x = (unsigned int)x & ADD_MASK;     ref_x = ((unsigned int)x & REF_MASK);    if(ref_x == 2){       p_x += 2;    }    p_h = (unsigned int)h & ADD_MASK;     ref_h = ((unsigned int)h & REF_MASK);    if(ref_h == 2){       p_h -= 2;    }    for(n = 0; n < L / 2; n++){       px_loop = p_x - 2;       ph_loop = p_h + 2 * (n + 1);       S32LDD(xr10, px_loop, 0x00);       S32LDD(xr11, ph_loop, 0x00);       D32SLL(xr12, xr0, xr0, xr13,0);       for(i = 1; i <= n; i++){     //calculate y[k]'s value in odd index           S32LDI(xr2, px_loop, 0x04);          S32ALN(xr3, xr2, xr10, ref_x); // xr3 = x[0], x[1];          Q16ADD_AA_WW(xr10, xr2, xr0, xr0);          S32LDI(xr2, ph_loop,    -0x04);          S32ALN(xr4, xr2, xr11, ref_h); //xr4 = h[2*n], h[2*n+1];          Q16ADD_AA_WW(xr11, xr2, xr0, xr0);          D16MAC_AA_LW(xr12, xr3, xr4, xr13);           S32LDD(xr2, ph_loop,    -0x04);          S32ALN(xr5, xr4, xr2, ref_h^2); //xr4 = h[2*n], h[2*n+1];          D16MAC_AA_HW(xr12, xr3, xr5, xr13);        }          S32LDD(xr2, px_loop, 0x04);          S32ALN(xr3, xr2, xr10, ref_x); // xr3 = x[0], x[1];          S32LDD(xr2, ph_loop,    -0x04);          S32ALN(xr4, xr2, xr11, ref_h); //xr4 = h[2*n], h[2*n+1];          D16MAC_AA_LW(xr12, xr3, xr4, xr13);         D16MAC_AA_HW(xr0, xr3,xr4, xr12);       D32SAR(xr1,xr12,xr13,xr2,12);       S32SFL(xr0,xr1,xr2,xr3,3);       S32STD(xr3,temp_y,0x00);       y[(n<<1)]=temp_y[0];       y[(n<<1)+1]=temp_y[1];    }#else    Word32 s;    for (n = 0; n < L; n++)    {        s = 0;                  //move32 ();         for (i = 0; i <= n; i++)        {            s = L_mac (s, x[i], h[n - i]);        }        s = L_shl (s, 3);#if 0        if( y[n] - extract_h(s) != 0){    printf("ref_x = %d, ref_h = %d",ref_x, ref_h);             printf(" y[%d] = %d, %d\n", n, y[n], extract_h(s));             for(n = 0; n < L; n++){                 printf("x[%2d]= %10d; h[%2d]=%10d;\n",n,x[n],n,h[n]);             }             printf(" Abort in function : %s\n", __FUNCTION__);             while(1);         }#endif        y[n] = extract_h (s);   //move16 ();     }#endif    return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -