123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*
- ********************************************************************************
- *
- * 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 : lsp_lsf.c
- * Purpose : Lsp_lsf: Transformation lsp to lsf
- * : Lsf_lsp: Transformation lsf to lsp
- *
- ********************************************************************************
- */
- /*
- ********************************************************************************
- * MODULE INCLUDE FILE AND VERSION ID
- ********************************************************************************
- */
- #include "lsp_lsf.h"
- const char lsp_lsf_id[] = "@(#)$Id $" lsp_lsf_h;
-
- /*
- ********************************************************************************
- * INCLUDE FILES
- ********************************************************************************
- */
- #include "typedef.h"
- #include "basic_op.h"
- #include "count.h"
-
- /*
- ********************************************************************************
- * LOCAL VARIABLES AND TABLES
- ********************************************************************************
- */
- #include "lsp_lsf.tab" /* Look-up table for transformations */
-
- /*
- ********************************************************************************
- * PUBLIC PROGRAM CODE
- ********************************************************************************
- */
- /*************************************************************************
- *
- * FUNCTIONS: Lsp_lsf and Lsf_lsp
- *
- * PURPOSE:
- * Lsp_lsf: Transformation lsp to lsf
- * Lsf_lsp: Transformation lsf to lsp
- *
- * DESCRIPTION:
- * lsp[i] = cos(2*pi*lsf[i]) and lsf[i] = arccos(lsp[i])/(2*pi)
- *
- * The transformation from lsp[i] to lsf[i] and lsf[i] to lsp[i] are
- * approximated by a look-up table and interpolation.
- *
- *************************************************************************/
- void Lsf_lsp (
- Word16 lsf[], /* (i) : lsf[m] normalized (range: 0.0<=val<=0.5) */
- Word16 lsp[], /* (o) : lsp[m] (range: -1<=val<1) */
- Word16 m /* (i) : LPC order */
- )
- {
- Word16 i, ind, offset;
- Word32 L_tmp;
- for (i = 0; i < m; i++)
- {
- ind = shr_ex (lsf[i], 8); /* ind = b8-b15 of lsf[i] */
- offset = lsf[i] & 0x00ff; logic16 (); /* offset = b0-b7 of lsf[i] */
- /* lsp[i] = table[ind]+ ((table[ind+1]-table[ind])*offset) / 256 */
- L_tmp = L_mult_ex (sub_ex (table[ind + 1], table[ind]), offset);
- lsp[i] = add_ex (table[ind], extract_l_ex (L_shr_ex (L_tmp, 9)));
- move16 ();
- }
- return;
- }
- void Lsp_lsf (
- Word16 lsp[], /* (i) : lsp[m] (range: -1<=val<1) */
- Word16 lsf[], /* (o) : lsf[m] normalized (range: 0.0<=val<=0.5) */
- Word16 m /* (i) : LPC order */
- )
- {
- Word16 i, ind;
- Word32 L_tmp;
- ind = 63; move16 (); /* begin at end of table -1 */
- for (i = m - 1; i >= 0; i--)
- {
- /* find value in table that is just greater than lsp[i] */
- test ();
- while (sub_ex (table[ind], lsp[i]) < 0)
- {
- ind--;
- test ();
- }
- /* acos(lsp[i])= ind*256 + ( ( lsp[i]-table[ind] ) *
- slope[ind] )/4096 */
- L_tmp = L_mult_ex (sub_ex (lsp[i], table[ind]), slope[ind]);
- /*(lsp[i]-table[ind])*slope[ind])>>12*/
- lsf[i] = round_ex (L_shl_ex (L_tmp, 3)); move16 ();
- lsf[i] = add_ex (lsf[i], shl_ex (ind, 8)); move16 ();
- }
- return;
- }
|