# HG changeset patch # User Mychaela Falconia # Date 1715022430 0 # Node ID df14b0c17e6d4ec986fd55fac9beb13932a3e3eb # Parent 9b699f30e6f3d1f72bf73b084ce1926b40aecdbd libtwamr: integrate pred_lt.c diff -r 9b699f30e6f3 -r df14b0c17e6d libtwamr/Makefile --- a/libtwamr/Makefile Mon May 06 19:02:44 2024 +0000 +++ b/libtwamr/Makefile Mon May 06 19:07:10 2024 +0000 @@ -10,10 +10,10 @@ gc_pred.o gmed_n.o graytab.o hp_max.o int_lpc.o int_lsf.o inter_36.o \ inv_sqrt.o lag_wind.o levinson.o log2.o lpc.o lsfwt.o lsp.o lsp_avg.o \ lsp_az.o lsp_lsf.o lsp_tab.o mac_32.o oper_32b.o ph_disp.o pitch_fr.o \ - post_pro.o pow2.o pre_big.o pre_proc.o prmno.o q_gain_c.o q_gain_p.o \ - q_plsf.o q_plsf3_tab.o q_plsf5_tab.o q_plsf_3.o q_plsf_5.o qgain475.o \ - qgain795.o qua_gain.o qua_gain_tab.o reorder.o residu.o s10_8pf.o \ - set_sign.o sqrt_l.o syn_filt.o tls_flags.o weight_a.o window.o + post_pro.o pow2.o pre_big.o pre_proc.o pred_lt.o prmno.o q_gain_c.o \ + q_gain_p.o q_plsf.o q_plsf3_tab.o q_plsf5_tab.o q_plsf_3.o q_plsf_5.o \ + qgain475.o qgain795.o qua_gain.o qua_gain_tab.o reorder.o residu.o \ + s10_8pf.o set_sign.o sqrt_l.o syn_filt.o tls_flags.o weight_a.o window.o HDRS= namespace.h LIB= libtwamr.a diff -r 9b699f30e6f3 -r df14b0c17e6d libtwamr/namespace.list --- a/libtwamr/namespace.list Mon May 06 19:02:44 2024 +0000 +++ b/libtwamr/namespace.list Mon May 06 19:07:10 2024 +0000 @@ -30,6 +30,7 @@ Pitch_fr Pitch_fr_reset Pre_Process Pre_Process_reset Post_Process Post_Process_reset +Pred_lt_3or6 Q_plsf_reset Q_plsf_3 Q_plsf_5 Qua_gain Residu Syn_filt Weight_Ai diff -r 9b699f30e6f3 -r df14b0c17e6d libtwamr/pred_lt.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/pred_lt.c Mon May 06 19:07:10 2024 +0000 @@ -0,0 +1,132 @@ +/* +******************************************************************************** +* +* 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 : pred_lt.c +* Purpose : Compute the result of long term prediction +* +******************************************************************************** +*/ + +/* +******************************************************************************** +* MODULE INCLUDE FILE AND VERSION ID +******************************************************************************** +*/ +#include "namespace.h" +#include "pred_lt.h" + +/* +******************************************************************************** +* INCLUDE FILES +******************************************************************************** +*/ +#include "typedef.h" +#include "basic_op.h" +#include "no_count.h" +#include "cnst.h" + +/* +******************************************************************************** +* LOCAL VARIABLES AND TABLES +******************************************************************************** +*/ +#define UP_SAMP_MAX 6 +#define L_INTER10 (L_INTERPOL-1) +#define FIR_SIZE (UP_SAMP_MAX*L_INTER10+1) + +/* 1/6 resolution interpolation filter (-3 dB at 3600 Hz) */ +/* Note: the 1/3 resolution filter is simply a subsampled + * version of the 1/6 resolution filter, i.e. it uses + * every second coefficient: + * + * inter_3l[k] = inter_6[2*k], 0 <= k <= 3*L_INTER10 + */ +static const Word16 inter_6[FIR_SIZE] = +{ + 29443, + 28346, 25207, 20449, 14701, 8693, 3143, + -1352, -4402, -5865, -5850, -4673, -2783, + -672, 1211, 2536, 3130, 2991, 2259, + 1170, 0, -1001, -1652, -1868, -1666, + -1147, -464, 218, 756, 1060, 1099, + 904, 550, 135, -245, -514, -634, + -602, -451, -231, 0, 191, 308, + 340, 296, 198, 78, -36, -120, + -163, -165, -132, -79, -19, 34, + 73, 91, 89, 70, 38, 0 +}; + +/* +******************************************************************************** +* PUBLIC PROGRAM CODE +******************************************************************************** +*/ +/************************************************************************* + * + * FUNCTION: Pred_lt_3or6() + * + * PURPOSE: Compute the result of long term prediction with fractional + * interpolation of resolution 1/3 or 1/6. (Interpolated past + * excitation). + * + * DESCRIPTION: + * The past excitation signal at the given delay is interpolated at + * the given fraction to build the adaptive codebook excitation. + * On return exc[0..L_subfr-1] contains the interpolated signal + * (adaptive codebook excitation). + * + *************************************************************************/ +void Pred_lt_3or6 ( + Word16 exc[], /* in/out: excitation buffer */ + Word16 T0, /* input : integer pitch lag */ + Word16 frac, /* input : fraction of lag */ + Word16 L_subfr, /* input : subframe size */ + Word16 flag3 /* input : if set, upsampling rate = 3 (6 otherwise) */ +) +{ + Word16 i, j, k; + Word16 *x0, *x1, *x2; + const Word16 *c1, *c2; + Word32 s; + + x0 = &exc[-T0]; move16 (); + + frac = negate (frac); + test(); + if (flag3 != 0) + { + frac = shl (frac, 1); /* inter_3l[k] = inter_6[2*k] -> k' = 2*k */ + } + + test (); + if (frac < 0) + { + frac = add (frac, UP_SAMP_MAX); + x0--; + } + + for (j = 0; j < L_subfr; j++) + { + x1 = x0++; move16 (); + x2 = x0; move16 (); + c1 = &inter_6[frac]; + c2 = &inter_6[sub (UP_SAMP_MAX, frac)]; + + s = 0; move32 (); + for (i = 0, k = 0; i < L_INTER10; i++, k += UP_SAMP_MAX) + { + s = L_mac (s, x1[-i], c1[k]); + s = L_mac (s, x2[i], c2[k]); + } + + exc[j] = round (s); move16 (); + } + + return; +} diff -r 9b699f30e6f3 -r df14b0c17e6d libtwamr/pred_lt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/pred_lt.h Mon May 06 19:07:10 2024 +0000 @@ -0,0 +1,46 @@ +/* +******************************************************************************** +* +* 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 : pred_lt.h +* Purpose : Compute the result of long term prediction. +* +* +******************************************************************************** +*/ +#ifndef pred_lt_h +#define pred_lt_h "$Id $" + +/* +******************************************************************************** +* INCLUDE FILES +******************************************************************************** +*/ +#include "typedef.h" + +/* +******************************************************************************** +* DEFINITION OF DATA TYPES +******************************************************************************** +*/ + +/* +******************************************************************************** +* DECLARATION OF PROTOTYPES +******************************************************************************** +*/ + +void Pred_lt_3or6 ( + Word16 exc[], /* in/out: excitation buffer */ + Word16 T0, /* input : integer pitch lag */ + Word16 frac, /* input : fraction of lag */ + Word16 L_subfr, /* input : subframe size */ + Word16 flag3 /* input : if set, upsampling rate = 3 (6 otherwise) */ +); + +#endif