# HG changeset patch # User Mychaela Falconia # Date 1714966706 0 # Node ID 8861f41e450759b6239cb0fcf5a60cbcc8de6358 # Parent a01de4e4054058acefc5d62093125ad4962cfff5 libtwamr: integrate lsfwt.c diff -r a01de4e40540 -r 8861f41e4507 libtwamr/Makefile --- a/libtwamr/Makefile Mon May 06 03:22:07 2024 +0000 +++ b/libtwamr/Makefile Mon May 06 03:38:26 2024 +0000 @@ -7,8 +7,8 @@ d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o dec_gain.o dec_lag3.o \ dec_lag6.o dhf_check.o dhf_tables.o e_homing.o ec_gains.o enc_lag3.o \ enc_lag6.o ex_ctrl.o g_adapt.o g_code.o g_pitch.o gains_tab.o gc_pred.o\ - gmed_n.o graytab.o inv_sqrt.o log2.o lsp_lsf.o oper_32b.o pow2.o \ - prmno.o q_gain_c.o q_gain_p.o q_plsf3_tab.o q_plsf5_tab.o \ + gmed_n.o graytab.o inv_sqrt.o log2.o lsfwt.o lsp_lsf.o oper_32b.o \ + pow2.o prmno.o q_gain_c.o q_gain_p.o q_plsf3_tab.o q_plsf5_tab.o \ qua_gain_tab.o reorder.o s10_8pf.o set_sign.o sqrt_l.o tls_flags.o \ window.o HDRS= namespace.h diff -r a01de4e40540 -r 8861f41e4507 libtwamr/lsfwt.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/lsfwt.c Mon May 06 03:38:26 2024 +0000 @@ -0,0 +1,104 @@ +/* +******************************************************************************** +* +* 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; +} diff -r a01de4e40540 -r 8861f41e4507 libtwamr/lsfwt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/lsfwt.h Mon May 06 03:38:26 2024 +0000 @@ -0,0 +1,36 @@ +/* +******************************************************************************** +* +* 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.h +* Purpose : Compute LSF weighting factors +* +******************************************************************************** +*/ +#ifndef lsfwt_h +#define lsfwt_h "$Id $" + +/* +******************************************************************************** +* INCLUDE FILES +******************************************************************************** +*/ +#include "typedef.h" +#include "cnst.h" + +/* +******************************************************************************** +* DECLARATION OF PROTOTYPES +******************************************************************************** +*/ + +void Lsf_wt ( + Word16 *lsf, /* input : LSF vector */ + Word16 *wf); /* output: square of weighting factors */ + +#endif diff -r a01de4e40540 -r 8861f41e4507 libtwamr/namespace.list --- a/libtwamr/namespace.list Mon May 06 03:22:07 2024 +0000 +++ b/libtwamr/namespace.list Mon May 06 03:38:26 2024 +0000 @@ -22,7 +22,7 @@ D_plsf_reset D_plsf_5 D_plsf_3 Init_D_plsf_3 Enc_lag3 Enc_lag6 Ex_ctrl G_code G_pitch -Lsf_lsp Lsp_lsf Reorder_lsf +Lsf_lsp Lsp_lsf Reorder_lsf Lsf_wt agc agc2 agc_reset pseudonoise build_CN_code build_CN_param