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

📄 g729ev_tdac_lib_vq.c

📁 最新的ITU-T的宽带语音编解码标准G.729.1,是对原先的G.729的最好的调整.码流输出速率可以进行自适应调整.满足未来通信要求.希望对大家有所帮助.
💻 C
📖 第 1 页 / 共 2 页
字号:
    {      ps = L_mac(ps, *ptr1++, *ptr2++); /* 14Q16 * 2 */    }    /* select survivor */    IF(L_sub(ps, dist_max) > 0)    {      ivq = k;      dist_max = ps;#if(WMOPS)      move16();      move16();#endif    }  }  *ILead = ivq;#if(WMOPS)  move16();#endif  return;}/*--------------------------------------------------------------------------* *  Function  G729EV_TDAC_getInfoLead()                                     * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                       * *  Get leader information                                                  * *--------------------------------------------------------------------------*/Word16 G729EV_TDAC_getInfoLead(Word16 dim,            /* (i)     dimension */                               Word16 ilead,          /* (i)     index of leader */                               Word16 ** ptr_nb_val,  /* (o)     pointer to weights */                               Word16 ** ptr_val,     /* (o)     pointer to alphabet */                               UWord32 * offset,      /* (o)     cardinality offset */                               Word16 * nb_sgn        /* (o)     number of signs */    ){  const Word16 *leader;  Word16   *p_val, *p_nb_val;  Word16    nb_val, dim_leader, jlead;  Word16    i, delta;  /* search the dimension of the non zero components */  jlead = *(G729EV_MAIN_adListLead[dim] + ilead);  dim_leader = G729EV_MAIN_dim_leader[jlead];  /* get the information on the leader */  *nb_sgn = dim_leader;  delta = G729EV_MAIN_delta_leader[jlead];  leader = G729EV_MAIN_adLeader_norm[dim_leader] + delta; /* pointer incrementation */#if(WMOPS)  move16();  move16();  move16();  move16();#endif  p_val = (Word16 *) * ptr_val;  p_nb_val = (Word16 *) * ptr_nb_val;  *p_val = *leader++;  *p_nb_val = (Word16) 1;  nb_val = (Word16) 1;#if(WMOPS)  move16();  move16();  move16();#endif  FOR(i = 1; i < dim_leader; i++)  {    IF(sub(*leader, *p_val) != 0)    {      p_val++;      p_nb_val++;      nb_val = add(nb_val, 1);      *p_val = *leader;      *p_nb_val = (Word16) 1;#if(WMOPS)      move16();      move16();#endif    }    ELSE    {      *p_nb_val = add(*p_nb_val, 1);    }    leader++;  }  *offset = *(G729EV_MAIN_adOffsetLead[dim] + ilead);  return (nb_val);}/*--------------------------------------------------------------------------* *  Function  G729EV_TDAC_prod_prm_fact()                                   * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     * *  Compute integer from its prime decomposition                            * *--------------------------------------------------------------------------*/Word32 G729EV_TDAC_prod_prm_fact(Word16 * exp /* (i)     exponents to prime factors */    ){  Word32    A, B, C, L_prod, tmp32;  Word16    pow3, pow5, pow7, pow11, pow13;  Word16    B_lo, A_lo, A_hi, C_lo, C_hi;  /* get powers of prime factors 3, 5, 7, 11 and 13 */  pow3 = G729EV_TDAC_tab_pow3[exp[1]];  pow5 = G729EV_TDAC_tab_pow5[exp[2]];  pow7 = G729EV_TDAC_tab_pow7[exp[3]];  pow11 = G729EV_TDAC_tab_pow11[exp[4]];  pow13 = G729EV_TDAC_tab_pow13[exp[5]];#if(WMOPS)  move16();  move16();  move16();  move16();  move16();#endif  /* compute product */  A = L_mult(pow3, pow5);       /* *2 */  B = L_mult(pow11, pow13);     /* *2 */  B_lo = extract_l(B);  C = L_mult(pow7, B_lo);       /* *4 */  C = L_shr(C, 2);  A_lo = extract_l(A & 0x7FFF);  A_hi = extract_l(L_shr(A, 15));  C_lo = extract_l(C & 0x7FFF);  C_hi = extract_l(L_shr(C, 15));  tmp32 = L_mult(A_lo, C_hi);  tmp32 = L_shl(tmp32, 15);  L_prod = L_mac(tmp32, A_lo, C_lo);  tmp32 = L_mult(A_hi, C_lo);  tmp32 = L_shl(tmp32, 15);  L_prod = L_add(L_prod, tmp32);  L_prod = L_shr(L_prod, 2);  /* shift for prime 2 */  L_prod = L_shl(L_prod, exp[0]);  return (L_prod);}/*--------------------------------------------------------------------------* *  Function  G729EV_TDAC_inv_schalk()                                      * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                        * *  Decode permutation rank computed by Schalkwijk's formula                * *--------------------------------------------------------------------------*/void G729EV_TDAC_inv_schalk(UWord32 UL_rank,  /* (i)     permutation rank */                            Word16 n,         /* (i)     dimension */                            Word16 ind_lead,  /* (i)     index of leader */                            Word16 * y        /* (o)     permuted leader */    ){  UWord32   L_prod;  UWord32   mem_I, offset_lead;  Word32    L_rank;  const Word16 *ptr, *ptr_fact;  Word16    prod_fact[G729EV_TDAC_MAX_NB_PRM_FACT];  Word16    fact[G729EV_TDAC_MAX_NB_PRM_FACT];  Word16    exp[G729EV_TDAC_MAX_NB_PRM_FACT];  Word16    A[G729EV_TDAC_N_NBC + 1];  Word16    tab_sgn[G729EV_TDAC_N_NBC];  Word16    offset_sgn[G729EV_TDAC_N_NBC + 1];  Word16    w[G729EV_TDAC_N_NBC + 1];  Word16    tab_values_online[G729EV_TDAC_N_NBC];  Word16    tab_nb_values_online[G729EV_TDAC_N_NBC];  Word16    k, i, nb_val, d, nb_prm_fact;  Word16    nb_sgn, sum_w;  Word16    j;  Word16    delta;  Word16    tmp;  Word16   *ptr_sgn, *ptr_val, *ptr_nb_val;  ptr_val = tab_values_online;  ptr_nb_val = tab_nb_values_online;  /* get pointers to alphabet (values) and weight of sequence and size of alphabet, dimension of leader  */  nb_val = (Word16) G729EV_TDAC_getInfoLead(n, ind_lead, &ptr_nb_val, &ptr_val, &offset_lead, &nb_sgn);  /* initalize weight (w), alphabet (A)  */  j = (Word16) 0;#if(WMOPS)  move16();#endif  FOR(d = 0; d < nb_val; d++)  {    w[d] = ptr_nb_val[d];    A[d] = ptr_val[d];    j = add(j, w[d]);    offset_sgn[d] = j;          /*(store for sign decoding) */#if(WMOPS)    move16();    move16();    move16();#endif  }  i = sub(n, nb_sgn);           /* if n > dimension of leader, add 0 in the alphabet */  IF(i > 0)  {    w[nb_val] = i;    A[nb_val] = (Word16) 0;    j = add(j, w[nb_val]);    offset_sgn[nb_val] = j;     /* for sign decoding */    nb_val = add(nb_val, 1);#if(WMOPS)    move16();    move16();    move16();#endif  }  /*sign decoding (the sign positions are in the coordinate system of the absolute leader)  */  ptr_sgn = tab_sgn + sub(nb_sgn, 1);  FOR(i = 0; i < nb_sgn; i++)  {    IF(L_sub((UL_rank & 0x01), 1) == 0)    {      *ptr_sgn-- = (Word16) 1;  /* not -1 because no mult but if/negate */    }    ELSE    {      *ptr_sgn-- = (Word16) 0;  /* not 0, because no mult but if/negate */    }#if(WMOPS)    move16();#endif    UL_rank = L_shr(UL_rank, 1);  }  FOR(i = nb_sgn; i < n; i++)  {    tab_sgn[i] = (Word16) 0;#if(WMOPS)    move16();#endif  }    /*------------- decode the rank of permutation of the absolute leader  */  /* >>>>>>>>>>>>>>>>> switched to signed arithmetic */  L_rank = UL_rank;             /*(variable is renamed for the sake of clarity) */#if(WMOPS)  move32();#endif  /* get the number of prime factorsf */  nb_prm_fact = G729EV_TDAC_tab_nb_prm_fact[n];#if(WMOPS)  move16();#endif  FOR(i = nb_prm_fact; i < G729EV_TDAC_MAX_NB_PRM_FACT; i++)  {    exp[i] = (Word16) 0;#if(WMOPS)    move16();#endif  }  /*set prod_fact=prod_i (w^i!) for k=0  */  /* to save complexity, this initialization could be computed in advance except for the zero letter */  i = w[0];  delta = G729EV_TDAC_delta_decomp_val[i];  ptr = G729EV_TDAC_tab_decomp_fact + delta;  /* pointer incrementation */#if(WMOPS)  move16();  move16();#endif  FOR(i = 0; i < nb_prm_fact; i++)  {    prod_fact[i] = *ptr++;#if(WMOPS)    move16();#endif  }  FOR(d = 1; d < nb_val; d++)  {    i = w[d];    delta = G729EV_TDAC_delta_decomp_val[i];    ptr = G729EV_TDAC_tab_decomp_fact + delta;  /* pointer incrementation */#if(WMOPS)    move16();    move16();#endif    FOR(i = 0; i < nb_prm_fact; i++)    {      prod_fact[i] = add(prod_fact[i], *ptr++);    }  }  /* determine the values of d_k, k=1,..,n (with the notations of Lamblin88)  */  FOR(k = 0; k < n; k++)  {    /* initialize d_k */    d = (Word16) 0;    L_prod = (UWord32) 0;#if(WMOPS)    move16();    move32();#endif    /* increment d_k to avoid useless evaluation of the formula */    WHILE(w[d] == 0)    {      d = add(d, 1);    }    IF(L_rank > 0)    {      /* initialize prime decomposition of factorial */      delta = G729EV_TDAC_delta_decomp_val[(n - (k + 1))];      ptr_fact = G729EV_TDAC_tab_decomp_fact + delta; /* pointer incrementation */#if(WMOPS)      move16();#endif      FOR(i = 0; i < nb_prm_fact; i++)      {        fact[i] = *ptr_fact++;#if(WMOPS)        move16();#endif      }      /* increment d_k until fact*sum_w/prod_fact is superior to rank */      sum_w = (Word16) 0;#if(WMOPS)      move16();#endif      DO      {        mem_I = L_prod;#if(WMOPS)        move32();#endif        /* compute L_prod = fact*sum_w/prod_fact */        sum_w = add(sum_w, w[d]);        delta = G729EV_TDAC_delta_decomp_val[sum_w];        ptr = G729EV_TDAC_tab_decomp_val + delta; /* pointer incrementation */#if(WMOPS)        move16();#endif        FOR(i = 0; i < nb_prm_fact; i++)        {          tmp = add(fact[i], *ptr++);          exp[i] = sub(tmp, prod_fact[i]);#if(WMOPS)          move16();#endif        }        L_prod = G729EV_TDAC_prod_prm_fact(exp);#if(WMOPS)        move16();#endif        d = add(d, 1);      }      WHILE(L_sub(L_rank, L_prod) >= 0);      d = sub(d, 1);      /* retrieve the last value */      L_prod = mem_I;#if(WMOPS)      move32();#endif    }    /* set value y[k] */    j = sub(offset_sgn[d], w[d]);    IF(tab_sgn[j] > 0)          /* y[k] = A[d] * tab_sgn[d] if tab_sgn = -1 for negative, 0 for positive */    {      y[k] = negate(A[d]);      /* warning: mult(3,-1) = -1 -> mult is replaced by if and negate */    }    ELSE    {      y[k] = A[d];    }#if(WMOPS)    move16();#endif    /* update rank */    L_rank = L_sub(L_rank, L_prod);    /* update prod_fact */    i = w[d];#if(WMOPS)    move16();#endif    IF(sub(i, 1) > 0)    {      delta = G729EV_TDAC_delta_decomp_val[i];      ptr = G729EV_TDAC_tab_decomp_val + delta; /* pointer incrementation */#if(WMOPS)      move16();#endif      FOR(i = 0; i < nb_prm_fact; i++)      {        prod_fact[i] = sub(prod_fact[i], *ptr++);#if(WMOPS)        move16();#endif      }    }    /* update weight */    w[d] = sub(w[d], 1);#if(WMOPS)    move16();#endif  }}/*--------------------------------------------------------------------------* *  Function  G729EV_TDAC_prod_prm_fact()                                   * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     * *  Search for codebook in dimension dim with rate < n bits                 * *--------------------------------------------------------------------------*/Word16 G729EV_TDAC_SearchPrev(Word16 n,   /* (i)     number of bits */                              Word16 dim  /* (i)     dimension */    ){  const Word16 *ptr;  Word16    i, idic_sup, tmp;  ptr = G729EV_MAIN_adRate[dim];  idic_sup = sub(G729EV_MAIN_NbDic[dim], 1);  FOR(i = idic_sup; i > 0; i--)  {    tmp = sub(ptr[i], n);    if (tmp < 0)    {      return (ptr[i]);    }  }  return (ptr[0]);}/*--------------------------------------------------------------------------* *  Function  G729EV_TDAC_prod_prm_fact()                                   * *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                     * *  Select codebook in dimension dim with closest rate to n bits            * *--------------------------------------------------------------------------*/Word16 G729EV_TDAC_SelectCbk(Word16 nbit, /* (i)     number of bits */                             Word16 dim   /* (i)     dimension */    ){  const Word16 *ptr;  Word16    nb, tmp;  Word16    i, imin, dif, difmin;  ptr = G729EV_MAIN_adRate[dim];  nb = G729EV_MAIN_NbDic[dim];  imin = (Word16) 0;#if(WMOPS)  move16();  move16();#endif  difmin = sub(ptr[0], nbit);  if (difmin < 0)  {    difmin = negate(difmin);  }  FOR(i = 1; i < nb; i++)  {    dif = sub(ptr[i], nbit);    if (dif < 0)    {      dif = negate(dif);    }    tmp = sub(dif, difmin);    IF(tmp < 0)    {      difmin = dif;      imin = i;#if(WMOPS)      move16();      move16();#endif    }  }  return (ptr[imin]);}

⌨️ 快捷键说明

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