123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- /*
- ********************************************************************************
- *
- * 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 : lsfwt.c
- * Purpose : Compute LSF weighting factors
- *
- ********************************************************************************
- */
-
-
- /*
- ********************************************************************************
- * MODULE INCLUDE FILE AND VERSION ID
- ********************************************************************************
- */
- #include "lsfwt.h"
- const char lsfwt_id[] = "@(#)$Id $" lsfwt_h;
-
- /*
- ********************************************************************************
- * INCLUDE FILES
- ********************************************************************************
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include "typedef.h"
- #include "basic_op.h"
- #include "count.h"
- #include "cnst.h"
- /*
- ********************************************************************************
- * PUBLIC PROGRAM CODE
- ********************************************************************************
- */
- /****************************************************
- *
- * FUNCTION Lsf_wt *
- * *
- ****************************************************
- * Compute LSF weighting factors *
- * *
- * d[i] = lsf[i+1] - lsf[i-1] *
- * *
- * The weighting factors are approximated by two line segment. *
- * *
- * First segment passes by the following 2 points: *
- * *
- * d[i] = 0Hz wf[i] = 3.347 *
- * d[i] = 450Hz wf[i] = 1.8 *
- * *
- * Second segment passes by the following 2 points: *
- * *
- * d[i] = 450Hz wf[i] = 1.8 *
- * d[i] = 1500Hz wf[i] = 1.0 *
- * *
- * if( d[i] < 450Hz ) *
- * wf[i] = 3.347 - ( (3.347-1.8) / (450-0)) * d[i] *
- * else *
- * wf[i] = 1.8 - ( (1.8-1.0) / (1500-450)) * (d[i] - 450) *
- * *
- * *
- * if( d[i] < 1843) *
- * wf[i] = 3427 - (28160*d[i])>>15 *
- * else *
- * wf[i] = 1843 - (6242*(d[i]-1843))>>15 *
- * *
- *--------------------------------------------------------------------------*/
- void Lsf_wt (
- Word16 *lsf, /* input : LSF vector */
- Word16 *wf) /* output: square of weighting factors */
- {
- Word16 temp;
- Word16 i;
- /* wf[0] = lsf[1] - 0 */
- wf[0] = lsf[1]; move16 ();
- for (i = 1; i < 9; i++)
- {
- wf[i] = sub_ex (lsf[i + 1], lsf[i - 1]); move16 ();
- }
- /* wf[9] = 0.5 - lsf[8] */
- wf[9] = sub_ex (16384, lsf[8]);move16 ();
- for (i = 0; i < 10; i++)
- {
- temp = sub_ex (wf[i], 1843);
- test ();
- if (temp < 0)
- {
- wf[i] = sub_ex (3427, mult_ex (wf[i], 28160)); move16 ();
- }
- else
- {
- wf[i] = sub_ex (1843, mult_ex (temp, 6242)); move16 ();
- }
- wf[i] = shl_ex (wf[i], 3); move16 ();
- }
- return;
- }
|