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

📄 g729ev_g729_lpc.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*-------------------------------------------------------------* *  find the sum and diff. pol. F1(z) and F2(z)                * *    F1(z) <--- F1(z)/(1+z**-1) & F2(z) <--- F2(z)/(1-z**-1)  * *                                                             * * f1[0] = 1.0;                                                * * f2[0] = 1.0;                                                * *                                                             * * FOR(i = 0; i< G729EV_G729_NC; i++)                                     * * {                                                           * *   f1[i+1] = a[i+1] + a[M-i] - f1[i] ;                       * *   f2[i+1] = a[i+1] - a[M-i] + f2[i] ;                       * * }                                                           * *-------------------------------------------------------------*/  ovf_coef = 0;  pChebps = G729EV_G729_Chebps_11;#ifdef WMOPS  move16();#endif  f1[0] = 2048;                 /* f1[0] = 1.0 is in Q11 */  f2[0] = 2048;                 /* f2[0] = 1.0 is in Q11 */#ifdef WMOPS  move16();  move16();#endif  FOR(i = 0; i < G729EV_G729_NC; i++)  {    Overflow = 0;#ifdef WMOPS    move16();#endif    t0 = L_mult(a[i + 1], 16384); /* x = (a[i+1] + a[M-i]) >> 1        */    t0 = L_mac(t0, a[G729EV_G729_M - i], 16384);  /*    -> From Q12 to Q11             */    x = extract_h(t0);    if (Overflow != 0)    {      ovf_coef = 1;#ifdef WMOPS      move16();#endif    }    Overflow = 0;#ifdef WMOPS    move16();    move16();#endif    f1[i + 1] = sub(x, f1[i]);  /* f1[i+1] = a[i+1] + a[M-i] - f1[i] */    if (Overflow != 0)    {      ovf_coef = 1;#ifdef WMOPS      move16();#endif    }    Overflow = 0;#ifdef WMOPS    move16();#endif    t0 = L_mult(a[i + 1], 16384); /* x = (a[i+1] - a[M-i]) >> 1        */    t0 = L_msu(t0, a[G729EV_G729_M - i], 16384);  /*    -> From Q12 to Q11             */    x = extract_h(t0);    if (Overflow != 0)    {      ovf_coef = 1;#ifdef WMOPS      move16();#endif    }    Overflow = 0;#ifdef WMOPS    move16();    move16();#endif    f2[i + 1] = add(x, f2[i]);  /* f2[i+1] = a[i+1] - a[M-i] + f2[i] */    if (Overflow != 0)    {      ovf_coef = 1;#ifdef WMOPS      move16();#endif    }  }  IF(ovf_coef != 0)  {    /*printf("===== OVF ovf_coef =====\n"); */    pChebps = G729EV_G729_Chebps_10;    f1[0] = 1024;               /* f1[0] = 1.0 is in Q10 */    f2[0] = 1024;               /* f2[0] = 1.0 is in Q10 */#ifdef WMOPS    move16();    move16();#endif    FOR(i = 0; i < G729EV_G729_NC; i++)    {      t0 = L_mult(a[i + 1], 8192);  /* x = (a[i+1] + a[M-i]) >> 1        */      t0 = L_mac(t0, a[G729EV_G729_M - i], 8192); /*    -> From Q11 to Q10             */      x = extract_h(t0);      f1[i + 1] = sub(x, f1[i]);  /* f1[i+1] = a[i+1] + a[M-i] - f1[i] */      t0 = L_mult(a[i + 1], 8192);  /* x = (a[i+1] - a[M-i]) >> 1        */      t0 = L_msu(t0, a[G729EV_G729_M - i], 8192); /*    -> From Q11 to Q10             */      x = extract_h(t0);      f2[i + 1] = add(x, f2[i]);  /* f2[i+1] = a[i+1] - a[M-i] + f2[i] */#ifdef WMOPS      move16();      move16();#endif    }  }/*-------------------------------------------------------------* * find the LSPs using the Chebichev pol. evaluation           * *-------------------------------------------------------------*/  nf = 0;                       /* number of found frequencies */  ip = 0;                       /* indicator for f1 or f2      */  coef = f1;  xlow = grid[0];  ylow = (*pChebps) (xlow, coef, G729EV_G729_NC);  j = 0;#ifdef WMOPS  move16();  move16();  move16();  move16();  test();#endif  WHILE((sub(nf, G729EV_G729_M) < 0) && (sub(j, G729EV_G729_GRID_POINTS) < 0))  {    j = add(j, 1);    xhigh = xlow;    yhigh = ylow;    xlow = grid[j];    ylow = (*pChebps) (xlow, coef, G729EV_G729_NC);#ifdef WMOPS    move16();    move16();    move16();#endif    L_temp = L_mult(ylow, yhigh);    IF(L_temp <= (Word32) 0)    {      /* divide 4 times the interval */      FOR(i = 0; i < 4; i++)      {        xmid = add(shr(xlow, 1), shr(xhigh, 1));  /* xmid = (xlow + xhigh)/2 */        ymid = (*pChebps) (xmid, coef, G729EV_G729_NC);        L_temp = L_mult(ylow, ymid);        IF(L_temp <= (Word32) 0)        {          yhigh = ymid;          xhigh = xmid;        }        ELSE        {          ylow = ymid;          xlow = xmid;        }#ifdef WMOPS        move16();        move16();#endif      }    /*-------------------------------------------------------------*     * Linear interpolation                                        *     *    xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow);            *     *-------------------------------------------------------------*/      x = sub(xhigh, xlow);      y = sub(yhigh, ylow);      IF(y == 0)      {        xint = xlow;#ifdef WMOPS        move16();#endif      }      ELSE      {        sign = y;#ifdef WMOPS        move16();#endif        y = abs_s(y);        exp = norm_s(y);        y = shl(y, exp);        y = div_s((Word16) 16383, y);        t0 = L_mult(x, y);        t0 = L_shr(t0, sub(20, exp));        y = extract_l(t0);      /* y= (xhigh-xlow)/(yhigh-ylow) in Q11 */        if (sign < 0)          y = negate(y);        t0 = L_mult(ylow, y);   /* result in Q26 */        t0 = L_shr(t0, 11);     /* result in Q15 */        xint = sub(xlow, extract_l(t0));  /* xint = xlow - ylow*y */      }      lsp[nf] = xint;      xlow = xint;#ifdef WMOPS      move16();      move16();#endif      nf = add(nf, 1);      IF(ip == 0)      {        ip = 1;        coef = f2;      }      ELSE      {        ip = 0;        coef = f1;      }      ylow = (*pChebps) (xlow, coef, G729EV_G729_NC);#ifdef WMOPS      move16();      move16();#endif    }  }  /* Check if M roots found */  IF(sub(nf, G729EV_G729_M) < 0)  {    FOR(i = 0; i < G729EV_G729_M; i++)    {      lsp[i] = old_lsp[i];#ifdef WMOPS      move16();#endif    }    /* printf("\n !!Not 10 roots found in Az_lsp()!!!\n"); */  }  return;}/*--------------------------------------------------------------* * function  G729EV_G729_Chebps_11, G729EV_G729_Chebps_10:                              * *           ~~~~~~~~~~~~~~~~~~~~                               * *    Evaluates the Chebichev polynomial series                 * *--------------------------------------------------------------* *                                                              * *  The polynomial order is                                     * *     n = M/2   (M is the prediction order)                    * *  The polynomial is given by                                  * *    C(x) = T_n(x) + f(1)T_n-1(x) + ... +f(n-1)T_1(x) + f(n)/2 * * Arguments:                                                   * *  x:     input value of evaluation; x = cos(frequency) in Q15 * *  f[]:   coefficients of the pol.                             * *                         in Q11(Chebps_11), in Q10(Chebps_10) * *  n:     order of the pol.                                    * *                                                              * * The value of C(x) is returned. (Saturated to +-1.99 in Q14)  * *                                                              * *--------------------------------------------------------------*/Word16 G729EV_G729_Chebps_11(Word16 x, Word16 f[], Word16 n){  Word32    t0;  Word16    i, cheb;  Word16    b0_h, b0_l, b1_h, b1_l, b2_h, b2_l;  /* Note: All computation are done in Q24. */  b2_h = 256;                   /* b2 = 1.0 in Q24 DPF */  b2_l = 0;#ifdef WMOPS  move16();  move16();#endif  t0 = L_mult(x, 512);          /* 2*x in Q24          */  t0 = L_mac(t0, f[1], 4096);   /* + f[1] in Q24       */  L_Extract(t0, &b1_h, &b1_l);  /* b1 = 2*x + f[1]     */  FOR(i = 2; i < n; i++)  {    t0 = Mpy_32_16(b1_h, b1_l, x);  /* t0 = 2.0*x*b1              */    t0 = L_shl(t0, 1);    t0 = L_mac(t0, b2_h, (Word16) - 32768L);  /* t0 = 2.0*x*b1 - b2         */    t0 = L_msu(t0, b2_l, 1);    t0 = L_mac(t0, f[i], 4096);     /* t0 = 2.0*x*b1 - b2 + f[i]; */    L_Extract(t0, &b0_h, &b0_l);    /* b0 = 2.0*x*b1 - b2 + f[i]; */    b2_l = b1_l;                    /* b2 = b1; */    b2_h = b1_h;    b1_l = b0_l;                    /* b1 = b0; */    b1_h = b0_h;#ifdef WMOPS    move16();    move16();    move16();    move16();#endif  }  t0 = Mpy_32_16(b1_h, b1_l, x);  /* t0 = x*b1;              */  t0 = L_mac(t0, b2_h, (Word16) - 32768L);  /* t0 = x*b1 - b2          */  t0 = L_msu(t0, b2_l, 1);  t0 = L_mac(t0, f[i], 2048);   /* t0 = x*b1 - b2 + f[i]/2 */  t0 = L_shl(t0, 6);            /* Q24 to Q30 with saturation */  cheb = extract_h(t0);         /* Result in Q14              */  return (cheb);}Word16 G729EV_G729_Chebps_10(Word16 x, Word16 f[], Word16 n){  Word32    t0;  Word16    i, cheb;  Word16    b0_h, b0_l, b1_h, b1_l, b2_h, b2_l;  /* Note: All computation are done in Q23. */  b2_h = 128;                   /* b2 = 1.0 in Q23 DPF */  b2_l = 0;#ifdef WMOPS  move16();  move16();#endif  t0 = L_mult(x, 256);          /* 2*x in Q23          */  t0 = L_mac(t0, f[1], 4096);   /* + f[1] in Q23       */  L_Extract(t0, &b1_h, &b1_l);  /* b1 = 2*x + f[1]     */  FOR(i = 2; i < n; i++)  {    t0 = Mpy_32_16(b1_h, b1_l, x);  /* t0 = 2.0*x*b1              */    t0 = L_shl(t0, 1);    t0 = L_mac(t0, b2_h, (Word16) - 32768L);  /* t0 = 2.0*x*b1 - b2         */    t0 = L_msu(t0, b2_l, 1);    t0 = L_mac(t0, f[i], 4096);    /* t0 = 2.0*x*b1 - b2 + f[i]; */    L_Extract(t0, &b0_h, &b0_l);   /* b0 = 2.0*x*b1 - b2 + f[i]; */    b2_l = b1_l;                   /* b2 = b1; */    b2_h = b1_h;    b1_l = b0_l;                   /* b1 = b0; */    b1_h = b0_h;#ifdef WMOPS    move16();    move16();    move16();    move16();#endif  }  t0 = Mpy_32_16(b1_h, b1_l, x);  /* t0 = x*b1;              */  t0 = L_mac(t0, b2_h, (Word16) - 32768L);  /* t0 = x*b1 - b2          */  t0 = L_msu(t0, b2_l, 1);  t0 = L_mac(t0, f[i], 2048);     /* t0 = x*b1 - b2 + f[i]/2 */  t0 = L_shl(t0, 7);              /* Q23 to Q30 with saturation */  cheb = extract_h(t0);           /* Result in Q14              */  return (cheb);}

⌨️ 快捷键说明

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