FreeCalypso > hg > gsm-codec-lib
view libtwamr/lsfwt.c @ 478:936a08cc73ce
doc/AMR-library-API: describe the decoder
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 19 May 2024 21:32:31 +0000 |
parents | 8861f41e4507 |
children |
line wrap: on
line source
/* ******************************************************************************** * * 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 "namespace.h" #include "lsfwt.h" /* ******************************************************************************** * INCLUDE FILES ******************************************************************************** */ #include "typedef.h" #include "basic_op.h" #include "no_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 (lsf[i + 1], lsf[i - 1]); move16 (); } /* wf[9] = 0.5 - lsf[8] */ wf[9] = sub (16384, lsf[8]);move16 (); for (i = 0; i < 10; i++) { temp = sub (wf[i], 1843); test (); if (temp < 0) { wf[i] = sub (3427, mult (wf[i], 28160)); move16 (); } else { wf[i] = sub (1843, mult (temp, 6242)); move16 (); } wf[i] = shl (wf[i], 3); move16 (); } return; }