comparison libgsmefr/dec_lag6.c @ 65:cb080ec1817e

libgsmefr: dec_lag6.c compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 26 Nov 2022 02:50:06 +0000
parents 49dd1ac8e75b
children f387ee919f2c
comparison
equal deleted inserted replaced
64:1cc2968f883f 65:cb080ec1817e
14 * that a transmission error occurred. In this case, the pitch lag from 14 * that a transmission error occurred. In this case, the pitch lag from
15 * previous subframe is used. 15 * previous subframe is used.
16 * 16 *
17 *************************************************************************/ 17 *************************************************************************/
18 18
19 #include "gsm_efr.h"
19 #include "typedef.h" 20 #include "typedef.h"
21 #include "namespace.h"
20 #include "basic_op.h" 22 #include "basic_op.h"
21 #include "count.h" 23 #include "no_count.h"
24 #include "codec.h"
25 #include "cnst.h"
26 #include "dec_state.h"
22 27
23 /* Old integer lag */ 28 Word16 Dec_lag6 ( /* output: return integer pitch lag */
24 29 struct EFR_decoder_state *st,
25 Word16 old_T0;
26
27 Word16
28 Dec_lag6 ( /* output: return integer pitch lag */
29 Word16 index, /* input : received pitch index */ 30 Word16 index, /* input : received pitch index */
30 Word16 pit_min, /* input : minimum pitch lag */ 31 Word16 pit_min, /* input : minimum pitch lag */
31 Word16 pit_max, /* input : maximum pitch lag */ 32 Word16 pit_max, /* input : maximum pitch lag */
32 Word16 i_subfr, /* input : subframe flag */ 33 Word16 i_subfr, /* input : subframe flag */
33 Word16 L_frame_by2,/* input : speech frame size divided by 2 */ 34 Word16 L_frame_by2,/* input : speech frame size divided by 2 */
34 Word16 *T0_frac, /* output: fractional part of pitch lag */ 35 Word16 *T0_frac, /* output: fractional part of pitch lag */
35 Word16 bfi /* input : bad frame indicator */ 36 Word16 bfi, /* input : bad frame indicator */
37 Word16 *T0_min,
38 Word16 *T0_max
36 ) 39 )
37 { 40 {
38 Word16 pit_flag; 41 Word16 pit_flag;
39 Word16 T0, i; 42 Word16 T0, i;
40 static Word16 T0_min, T0_max;
41 43
42 pit_flag = i_subfr; move16 (); /* flag for 1st or 3rd subframe */ 44 pit_flag = i_subfr; move16 (); /* flag for 1st or 3rd subframe */
43 test (); 45 test ();
44 if (sub (i_subfr, L_frame_by2) == 0) 46 if (sub (i_subfr, L_frame_by2) == 0)
45 { 47 {
68 } 70 }
69 } 71 }
70 else 72 else
71 /* bfi == 1 */ 73 /* bfi == 1 */
72 { 74 {
73 T0 = old_T0; move16 (); 75 T0 = st->old_T0;
74 *T0_frac = 0; move16 (); 76 *T0_frac = 0;
75 } 77 }
76 78
77 /* find T0_min and T0_max for 2nd (or 4th) subframe */ 79 /* find T0_min and T0_max for 2nd (or 4th) subframe */
78 80
79 T0_min = sub (T0, 5); 81 *T0_min = sub (T0, 5);
80 test (); 82 if (sub (*T0_min, pit_min) < 0)
81 if (sub (T0_min, pit_min) < 0)
82 { 83 {
83 T0_min = pit_min; move16 (); 84 *T0_min = pit_min;
84 } 85 }
85 T0_max = add (T0_min, 9); 86 *T0_max = add (*T0_min, 9);
86 test (); 87 if (sub (*T0_max, pit_max) > 0)
87 if (sub (T0_max, pit_max) > 0)
88 { 88 {
89 T0_max = pit_max; move16 (); 89 *T0_max = pit_max;
90 T0_min = sub (T0_max, 9); 90 *T0_min = sub (*T0_max, 9);
91 } 91 }
92 } 92 }
93 else 93 else
94 /* second or fourth subframe */ 94 /* second or fourth subframe */
95 { 95 {
97 /* if bfi == 0 decode pitch */ 97 /* if bfi == 0 decode pitch */
98 if ((bfi == 0) && (sub (index, 61) < 0)) 98 if ((bfi == 0) && (sub (index, 61) < 0))
99 { 99 {
100 /* i = (index+5)/6 - 1 */ 100 /* i = (index+5)/6 - 1 */
101 i = sub (mult (add (index, 5), 5462), 1); 101 i = sub (mult (add (index, 5), 5462), 1);
102 T0 = add (i, T0_min); 102 T0 = add (i, *T0_min);
103 i = add (add (i, i), i); 103 i = add (add (i, i), i);
104 *T0_frac = sub (sub (index, 3), add (i, i)); 104 *T0_frac = sub (sub (index, 3), add (i, i));
105 move16 ();
106 } 105 }
107 else 106 else
108 /* bfi == 1 OR index >= 61 */ 107 /* bfi == 1 OR index >= 61 */
109 { 108 {
110 T0 = old_T0; move16 (); 109 T0 = st->old_T0;
111 *T0_frac = 0; move16 (); 110 *T0_frac = 0;
112 } 111 }
113 } 112 }
114 113
115 old_T0 = T0; move16 (); 114 st->old_T0 = T0;
116 115
117 return T0; 116 return T0;
118 } 117 }