comparison libtwamr/int_lsf.c @ 382:693ea1d5cf1e

libtwamr: integrate int_lsf.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 05:45:31 +0000
parents
children
comparison
equal deleted inserted replaced
381:32bc48faec4b 382:693ea1d5cf1e
1 /*
2 ********************************************************************************
3 *
4 * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
5 * R99 Version 3.3.0
6 * REL-4 Version 4.1.0
7 *
8 ********************************************************************************
9 *
10 * File : int_lsf.c
11 *
12 ********************************************************************************
13 */
14 /*
15 ********************************************************************************
16 * MODULE INCLUDE FILE AND VERSION ID
17 ********************************************************************************
18 */
19 #include "namespace.h"
20 #include "int_lsf.h"
21
22 /*
23 ********************************************************************************
24 * INCLUDE FILES
25 ********************************************************************************
26 */
27 #include "typedef.h"
28 #include "basic_op.h"
29 #include "no_count.h"
30 #include "cnst.h"
31
32 /*
33 ********************************************************************************
34 * LOCAL VARIABLES AND TABLES
35 ********************************************************************************
36 */
37 /*
38 *--------------------------------------*
39 * Constants (defined in cnst.h) *
40 *--------------------------------------*
41 * M : LSF order *
42 *--------------------------------------*
43 */
44
45 /*
46 ********************************************************************************
47 * PUBLIC PROGRAM CODE
48 ********************************************************************************
49 */
50
51 /*
52 **************************************************************************
53 *
54 * Function : Int_lsf
55 * Purpose : Interpolates the LSFs for selected subframe
56 * Description : The 20 ms speech frame is divided into 4 subframes.
57 * The LSFs are interpolated at the 1st, 2nd and 3rd
58 * subframe and only forwarded at the 4th subframe.
59 *
60 * |------|------|------|------|
61 * sf1 sf2 sf3 sf4
62 * F0 F1
63 *
64 * sf1: 3/4 F0 + 1/4 F1 sf3: 1/4 F0 + 3/4 F1
65 * sf2: 1/2 F0 + 1/2 F1 sf4: F1
66 * Returns : void
67 *
68 **************************************************************************
69 */
70 void Int_lsf(
71 Word16 lsf_old[], /* i : LSF vector at the 4th SF of past frame */
72 Word16 lsf_new[], /* i : LSF vector at the 4th SF of present frame */
73 Word16 i_subfr, /* i : Pointer to current sf (equal to 0,40,80 or 120) */
74 Word16 lsf_out[] /* o : interpolated LSF parameters for current sf */
75 )
76 {
77 Word16 i;
78
79 if ( i_subfr == 0 )
80 {
81 test ();
82 for (i = 0; i < M; i++) {
83 lsf_out[i] = add(sub(lsf_old[i], shr(lsf_old[i], 2)), shr(lsf_new[i], 2));
84 move16 ();
85 }
86 }
87 else if ( sub(i_subfr, 40) == 0 )
88 {
89 test (); test ();
90 for (i = 0; i < M; i++) {
91 lsf_out[i] = add(shr(lsf_old[i],1), shr(lsf_new[i], 1) );
92 move16 ();
93 }
94 }
95 else if ( sub(i_subfr, 80) == 0 )
96 {
97 test (); test (); test ();
98 for (i = 0; i < M; i++) {
99 lsf_out[i] = add(shr(lsf_old[i], 2), sub(lsf_new[i], shr(lsf_new[i], 2)));
100 move16 ();
101 }
102 }
103 else if ( sub(i_subfr, 120) == 0 )
104 {
105 test (); test (); test (); test ();
106 for (i = 0; i < M; i++) {
107 lsf_out[i] = lsf_new[i]; move16 ();
108 }
109 }
110
111 return;
112 }