FreeCalypso > hg > gsm-codec-lib
comparison libgsmefr/vad.c @ 111:756605c4850f
libgsmefr: vad.c compiles
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 29 Nov 2022 04:16:33 +0000 |
| parents | 913fe3c11890 |
| children | 1c108dd5b33f |
comparison
equal
deleted
inserted
replaced
| 110:913fe3c11890 | 111:756605c4850f |
|---|---|
| 38 * Periodicity detection routine (called by the speech encoder): | 38 * Periodicity detection routine (called by the speech encoder): |
| 39 * periodicity_detection() | 39 * periodicity_detection() |
| 40 * | 40 * |
| 41 **************************************************************************/ | 41 **************************************************************************/ |
| 42 | 42 |
| 43 #include "gsm_efr.h" | |
| 43 #include "typedef.h" | 44 #include "typedef.h" |
| 45 #include "namespace.h" | |
| 44 #include "cnst.h" | 46 #include "cnst.h" |
| 45 #include "basic_op.h" | 47 #include "basic_op.h" |
| 46 #include "oper_32b.h" | 48 #include "oper_32b.h" |
| 47 #include "count.h" | 49 #include "no_count.h" |
| 48 #include "vad.h" | 50 #include "vad.h" |
| 51 #include "enc_state.h" | |
| 49 | 52 |
| 50 /* Constants of VAD hangover addition */ | 53 /* Constants of VAD hangover addition */ |
| 51 | 54 |
| 52 #define HANGCONST 10 | 55 #define HANGCONST 10 |
| 53 #define BURSTCONST 3 | 56 #define BURSTCONST 3 |
| 76 /* Constants of tone detection */ | 79 /* Constants of tone detection */ |
| 77 | 80 |
| 78 #define FREQTH 3189 | 81 #define FREQTH 3189 |
| 79 #define PREDTH 1464 | 82 #define PREDTH 1464 |
| 80 | 83 |
| 81 /* Static variables of VAD */ | 84 /* forward declarations for internal functions */ |
| 82 | 85 |
| 83 static Word16 rvad[9], scal_rvad; | 86 static void energy_computation ( |
| 84 static Pfloat thvad; | 87 Word16 r_h[], |
| 85 static Word32 L_sacf[27]; | 88 Word16 scal_acf, |
| 86 static Word32 L_sav0[36]; | 89 Word16 rvad[], |
| 87 static Word16 pt_sacf, pt_sav0; | 90 Word16 scal_rvad, |
| 88 static Word32 L_lastdm; | 91 Pfloat * acf0, |
| 89 static Word16 adaptcount; | 92 Pfloat * pvad |
| 90 static Word16 burstcount, hangcount; | 93 ); |
| 91 static Word16 oldlagcount, veryoldlagcount, oldlag; | 94 |
| 92 | 95 static void acf_averaging ( |
| 93 Word16 ptch; | 96 struct EFR_encoder_state *st, |
| 97 Word16 r_h[], | |
| 98 Word16 r_l[], | |
| 99 Word16 scal_acf, | |
| 100 Word32 L_av0[], | |
| 101 Word32 L_av1[] | |
| 102 ); | |
| 103 | |
| 104 static void predictor_values ( | |
| 105 Word32 L_av1[], | |
| 106 Word16 rav1[], | |
| 107 Word16 *scal_rav1 | |
| 108 ); | |
| 109 | |
| 110 static void schur_recursion ( | |
| 111 Word32 L_av1[], | |
| 112 Word16 vpar[] | |
| 113 ); | |
| 114 | |
| 115 static void step_up ( | |
| 116 Word16 np, | |
| 117 Word16 vpar[], | |
| 118 Word16 aav1[] | |
| 119 ); | |
| 120 | |
| 121 static void compute_rav1 ( | |
| 122 Word16 aav1[], | |
| 123 Word16 rav1[], | |
| 124 Word16 *scal_rav1 | |
| 125 ); | |
| 126 | |
| 127 static Word16 spectral_comparison ( | |
| 128 struct EFR_encoder_state *st, | |
| 129 Word16 rav1[], | |
| 130 Word16 scal_rav1, | |
| 131 Word32 L_av0[] | |
| 132 ); | |
| 133 | |
| 134 static void threshold_adaptation ( | |
| 135 struct EFR_encoder_state *st, | |
| 136 Word16 stat, | |
| 137 Word16 ptch, | |
| 138 Word16 tone, | |
| 139 Word16 rav1[], | |
| 140 Word16 scal_rav1, | |
| 141 Pfloat pvad, | |
| 142 Pfloat acf0, | |
| 143 Word16 rvad[], | |
| 144 Word16 *scal_rvad, | |
| 145 Pfloat * thvad | |
| 146 ); | |
| 147 | |
| 148 static void tone_detection ( | |
| 149 Word16 rc[], | |
| 150 Word16 *tone | |
| 151 ); | |
| 152 | |
| 153 static Word16 vad_decision ( | |
| 154 Pfloat pvad, | |
| 155 Pfloat thvad | |
| 156 ); | |
| 157 | |
| 158 static Word16 vad_hangover ( | |
| 159 struct EFR_encoder_state *st, | |
| 160 Word16 vvad | |
| 161 ); | |
| 94 | 162 |
| 95 /************************************************************************* | 163 /************************************************************************* |
| 96 * | 164 * |
| 97 * FUNCTION NAME: vad_reset | 165 * FUNCTION NAME: vad_reset |
| 98 * | 166 * |
| 99 * PURPOSE: Resets the static variables of the VAD to their | 167 * PURPOSE: Resets the static variables of the VAD to their |
| 100 * initial values | 168 * initial values |
| 101 * | 169 * |
| 102 *************************************************************************/ | 170 *************************************************************************/ |
| 103 | 171 |
| 104 void vad_reset () | 172 void vad_reset (struct EFR_encoder_state *st) |
| 105 { | 173 { |
| 174 struct vad_state *vst = &st->vad; | |
| 106 Word16 i; | 175 Word16 i; |
| 107 | 176 |
| 108 /* Initialize rvad variables */ | 177 /* Initialize rvad variables */ |
| 109 rvad[0] = 0x6000; | 178 vst->rvad[0] = 0x6000; |
| 110 for (i = 1; i < 9; i++) | 179 for (i = 1; i < 9; i++) |
| 111 { | 180 { |
| 112 rvad[i] = 0; | 181 vst->rvad[i] = 0; |
| 113 } | 182 } |
| 114 scal_rvad = 7; | 183 vst->scal_rvad = 7; |
| 115 | 184 |
| 116 /* Initialize threshold level */ | 185 /* Initialize threshold level */ |
| 117 thvad.e = 20; /*** exponent ***/ | 186 vst->thvad.e = 20; /*** exponent ***/ |
| 118 thvad.m = 27083; /*** mantissa ***/ | 187 vst->thvad.m = 27083; /*** mantissa ***/ |
| 119 | 188 |
| 120 /* Initialize ACF averaging variables */ | 189 /* Initialize ACF averaging variables */ |
| 121 for (i = 0; i < 27; i++) | 190 for (i = 0; i < 27; i++) |
| 122 { | 191 { |
| 123 L_sacf[i] = 0L; | 192 vst->L_sacf[i] = 0L; |
| 124 } | 193 } |
| 125 for (i = 0; i < 36; i++) | 194 for (i = 0; i < 36; i++) |
| 126 { | 195 { |
| 127 L_sav0[i] = 0L; | 196 vst->L_sav0[i] = 0L; |
| 128 } | 197 } |
| 129 pt_sacf = 0; | 198 vst->pt_sacf = 0; |
| 130 pt_sav0 = 0; | 199 vst->pt_sav0 = 0; |
| 131 | 200 |
| 132 /* Initialize spectral comparison variable */ | 201 /* Initialize spectral comparison variable */ |
| 133 L_lastdm = 0L; | 202 vst->L_lastdm = 0L; |
| 134 | 203 |
| 135 /* Initialize threshold adaptation variable */ | 204 /* Initialize threshold adaptation variable */ |
| 136 adaptcount = 0; | 205 vst->adaptcount = 0; |
| 137 | 206 |
| 138 /* Initialize VAD hangover addition variables */ | 207 /* Initialize VAD hangover addition variables */ |
| 139 burstcount = 0; | 208 vst->burstcount = 0; |
| 140 hangcount = -1; | 209 vst->hangcount = -1; |
| 141 | 210 |
| 142 /* Initialize periodicity detection variables */ | 211 /* Initialize periodicity detection variables */ |
| 143 oldlagcount = 0; | 212 vst->oldlagcount = 0; |
| 144 veryoldlagcount = 0; | 213 vst->veryoldlagcount = 0; |
| 145 oldlag = 18; | 214 vst->oldlag = 18; |
| 146 | 215 |
| 147 ptch = 1; | 216 st->ptch = 1; |
| 148 | 217 |
| 149 return; | 218 return; |
| 150 } | 219 } |
| 151 | 220 |
| 152 /**************************************************************************** | 221 /**************************************************************************** |
| 167 * RETURN VALUE: vad decision | 236 * RETURN VALUE: vad decision |
| 168 * | 237 * |
| 169 ***************************************************************************/ | 238 ***************************************************************************/ |
| 170 | 239 |
| 171 Word16 vad_computation ( | 240 Word16 vad_computation ( |
| 241 struct EFR_encoder_state *st, | |
| 172 Word16 r_h[], | 242 Word16 r_h[], |
| 173 Word16 r_l[], | 243 Word16 r_l[], |
| 174 Word16 scal_acf, | 244 Word16 scal_acf, |
| 175 Word16 rc[], | 245 Word16 rc[], |
| 176 Word16 ptch | 246 Word16 ptch |
| 177 ) | 247 ) |
| 178 { | 248 { |
| 249 struct vad_state *vst = &st->vad; | |
| 179 Word32 L_av0[9], L_av1[9]; | 250 Word32 L_av0[9], L_av1[9]; |
| 180 Word16 vad, vvad, rav1[9], scal_rav1, stat, tone; | 251 Word16 vad, vvad, rav1[9], scal_rav1, stat, tone; |
| 181 Pfloat acf0, pvad; | 252 Pfloat acf0, pvad; |
| 182 | 253 |
| 183 energy_computation (r_h, scal_acf, rvad, scal_rvad, &acf0, &pvad); | 254 energy_computation (r_h, scal_acf, vst->rvad, vst->scal_rvad, &acf0, &pvad); |
| 184 acf_averaging (r_h, r_l, scal_acf, L_av0, L_av1); | 255 acf_averaging (st, r_h, r_l, scal_acf, L_av0, L_av1); |
| 185 predictor_values (L_av1, rav1, &scal_rav1); | 256 predictor_values (L_av1, rav1, &scal_rav1); |
| 186 stat = spectral_comparison (rav1, scal_rav1, L_av0); move16 (); | 257 stat = spectral_comparison (st, rav1, scal_rav1, L_av0); |
| 187 tone_detection (rc, &tone); | 258 tone_detection (rc, &tone); |
| 188 threshold_adaptation (stat, ptch, tone, rav1, scal_rav1, pvad, acf0, | 259 threshold_adaptation (st, stat, ptch, tone, rav1, scal_rav1, pvad, acf0, |
| 189 rvad, &scal_rvad, &thvad); | 260 vst->rvad, &vst->scal_rvad, &vst->thvad); |
| 190 vvad = vad_decision (pvad, thvad); move16 (); | 261 vvad = vad_decision (pvad, vst->thvad); |
| 191 vad = vad_hangover (vvad); move16 (); | 262 vad = vad_hangover (st, vvad); |
| 192 | 263 |
| 193 return vad; | 264 return vad; |
| 194 } | 265 } |
| 195 | 266 |
| 196 /**************************************************************************** | 267 /**************************************************************************** |
| 276 * RETURN VALUE: none | 347 * RETURN VALUE: none |
| 277 * | 348 * |
| 278 ***************************************************************************/ | 349 ***************************************************************************/ |
| 279 | 350 |
| 280 void acf_averaging ( | 351 void acf_averaging ( |
| 352 struct EFR_encoder_state *st, | |
| 281 Word16 r_h[], | 353 Word16 r_h[], |
| 282 Word16 r_l[], | 354 Word16 r_l[], |
| 283 Word16 scal_acf, | 355 Word16 scal_acf, |
| 284 Word32 L_av0[], | 356 Word32 L_av0[], |
| 285 Word32 L_av1[] | 357 Word32 L_av1[] |
| 286 ) | 358 ) |
| 287 { | 359 { |
| 360 struct vad_state *vst = &st->vad; | |
| 288 Word32 L_temp; | 361 Word32 L_temp; |
| 289 Word16 scale; | 362 Word16 scale; |
| 290 Word16 i; | 363 Word16 i; |
| 291 | 364 |
| 292 scale = add (9, scal_acf); | 365 scale = add (9, scal_acf); |
| 293 | 366 |
| 294 for (i = 0; i <= 8; i++) | 367 for (i = 0; i <= 8; i++) |
| 295 { | 368 { |
| 296 L_temp = L_shr (L_Comp (r_h[i], r_l[i]), scale); | 369 L_temp = L_shr (L_Comp (r_h[i], r_l[i]), scale); |
| 297 L_av0[i] = L_add (L_sacf[i], L_temp); move32 (); | 370 L_av0[i] = L_add (vst->L_sacf[i], L_temp); |
| 298 L_av0[i] = L_add (L_sacf[i + 9], L_av0[i]); move32 (); | 371 L_av0[i] = L_add (vst->L_sacf[i + 9], L_av0[i]); |
| 299 L_av0[i] = L_add (L_sacf[i + 18], L_av0[i]); move32 (); | 372 L_av0[i] = L_add (vst->L_sacf[i + 18], L_av0[i]); |
| 300 L_sacf[pt_sacf + i] = L_temp; move32 (); | 373 vst->L_sacf[vst->pt_sacf + i] = L_temp; |
| 301 L_av1[i] = L_sav0[pt_sav0 + i]; move32 (); | 374 L_av1[i] = vst->L_sav0[vst->pt_sav0 + i]; |
| 302 L_sav0[pt_sav0 + i] = L_av0[i]; move32 (); | 375 vst->L_sav0[vst->pt_sav0 + i] = L_av0[i]; |
| 303 } | 376 } |
| 304 | 377 |
| 305 /* Update the array pointers */ | 378 /* Update the array pointers */ |
| 306 | 379 |
| 307 test (); | 380 if (sub (vst->pt_sacf, 18) == 0) |
| 308 if (sub (pt_sacf, 18) == 0) | 381 { |
| 309 { | 382 vst->pt_sacf = 0; |
| 310 pt_sacf = 0; move16 (); | |
| 311 } | 383 } |
| 312 else | 384 else |
| 313 { | 385 { |
| 314 pt_sacf = add (pt_sacf, 9); | 386 vst->pt_sacf = add (vst->pt_sacf, 9); |
| 315 } | 387 } |
| 316 | 388 |
| 317 test (); | 389 if (sub (vst->pt_sav0, 27) == 0) |
| 318 if (sub (pt_sav0, 27) == 0) | 390 { |
| 319 { | 391 vst->pt_sav0 = 0; |
| 320 pt_sav0 = 0; move16 (); | |
| 321 } | 392 } |
| 322 else | 393 else |
| 323 { | 394 { |
| 324 pt_sav0 = add (pt_sav0, 9); | 395 vst->pt_sav0 = add (vst->pt_sav0, 9); |
| 325 } | 396 } |
| 326 | 397 |
| 327 return; | 398 return; |
| 328 } | 399 } |
| 329 | 400 |
| 583 * RETURN VALUE: flag to indicate spectral stationarity | 654 * RETURN VALUE: flag to indicate spectral stationarity |
| 584 * | 655 * |
| 585 ***************************************************************************/ | 656 ***************************************************************************/ |
| 586 | 657 |
| 587 Word16 spectral_comparison ( | 658 Word16 spectral_comparison ( |
| 659 struct EFR_encoder_state *st, | |
| 588 Word16 rav1[], | 660 Word16 rav1[], |
| 589 Word16 scal_rav1, | 661 Word16 scal_rav1, |
| 590 Word32 L_av0[] | 662 Word32 L_av0[] |
| 591 ) | 663 ) |
| 592 { | 664 { |
| 665 struct vad_state *vst = &st->vad; | |
| 593 Word32 L_dm, L_sump, L_temp; | 666 Word32 L_dm, L_sump, L_temp; |
| 594 Word16 stat, sav0[9], shift, divshift, temp; | 667 Word16 stat, sav0[9], shift, divshift, temp; |
| 595 Word16 i; | 668 Word16 i; |
| 596 | 669 |
| 597 /*** Re-normalize L_av0[0..8] ***/ | 670 /*** Re-normalize L_av0[0..8] ***/ |
| 684 L_dm = L_add (L_dm, L_shl (L_deposit_l (rav1[0]), 11)); | 757 L_dm = L_add (L_dm, L_shl (L_deposit_l (rav1[0]), 11)); |
| 685 L_dm = L_shr (L_dm, scal_rav1); | 758 L_dm = L_shr (L_dm, scal_rav1); |
| 686 | 759 |
| 687 /*** Compute the difference and save L_dm ***/ | 760 /*** Compute the difference and save L_dm ***/ |
| 688 | 761 |
| 689 L_temp = L_sub (L_dm, L_lastdm); | 762 L_temp = L_sub (L_dm, vst->L_lastdm); |
| 690 L_lastdm = L_dm; move32 (); | 763 vst->L_lastdm = L_dm; |
| 691 | 764 |
| 692 test (); | 765 test (); |
| 693 if (L_temp < 0L) | 766 if (L_temp < 0L) |
| 694 { | 767 { |
| 695 L_temp = L_negate (L_temp); | 768 L_temp = L_negate (L_temp); |
| 734 * RETURN VALUE: none | 807 * RETURN VALUE: none |
| 735 * | 808 * |
| 736 ***************************************************************************/ | 809 ***************************************************************************/ |
| 737 | 810 |
| 738 void threshold_adaptation ( | 811 void threshold_adaptation ( |
| 812 struct EFR_encoder_state *st, | |
| 739 Word16 stat, | 813 Word16 stat, |
| 740 Word16 ptch, | 814 Word16 ptch, |
| 741 Word16 tone, | 815 Word16 tone, |
| 742 Word16 rav1[], | 816 Word16 rav1[], |
| 743 Word16 scal_rav1, | 817 Word16 scal_rav1, |
| 746 Word16 rvad[], | 820 Word16 rvad[], |
| 747 Word16 *scal_rvad, | 821 Word16 *scal_rvad, |
| 748 Pfloat * thvad | 822 Pfloat * thvad |
| 749 ) | 823 ) |
| 750 { | 824 { |
| 825 struct vad_state *vst = &st->vad; | |
| 751 Word16 comp, comp2; | 826 Word16 comp, comp2; |
| 752 Word32 L_temp; | 827 Word32 L_temp; |
| 753 Word16 temp; | 828 Word16 temp; |
| 754 Pfloat p_temp; | 829 Pfloat p_temp; |
| 755 Word16 i; | 830 Word16 i; |
| 794 comp = 1; move16 (); | 869 comp = 1; move16 (); |
| 795 } | 870 } |
| 796 test (); | 871 test (); |
| 797 if (sub (comp, 1) == 0) | 872 if (sub (comp, 1) == 0) |
| 798 { | 873 { |
| 799 adaptcount = 0; move16 (); | 874 vst->adaptcount = 0; |
| 800 return; | 875 return; |
| 801 } | 876 } |
| 802 /*** Increment adaptcount ***/ | 877 /*** Increment adaptcount ***/ |
| 803 | 878 |
| 804 adaptcount = add (adaptcount, 1); | 879 vst->adaptcount = add (vst->adaptcount, 1); |
| 805 test (); | 880 if (sub (vst->adaptcount, 8) <= 0) |
| 806 if (sub (adaptcount, 8) <= 0) | |
| 807 { | 881 { |
| 808 return; | 882 return; |
| 809 } | 883 } |
| 810 /*** computation of thvad-(thvad/dec) ***/ | 884 /*** computation of thvad-(thvad/dec) ***/ |
| 811 | 885 |
| 967 rvad[i] = rav1[i]; move16 (); | 1041 rvad[i] = rav1[i]; move16 (); |
| 968 } | 1042 } |
| 969 | 1043 |
| 970 /*** Set adaptcount to adp + 1 ***/ | 1044 /*** Set adaptcount to adp + 1 ***/ |
| 971 | 1045 |
| 972 adaptcount = 9; move16 (); | 1046 vst->adaptcount = 9; |
| 973 | 1047 |
| 974 return; | 1048 return; |
| 975 } | 1049 } |
| 976 | 1050 |
| 977 /**************************************************************************** | 1051 /**************************************************************************** |
| 1114 * RETURN VALUE: vad decision after hangover is added | 1188 * RETURN VALUE: vad decision after hangover is added |
| 1115 * | 1189 * |
| 1116 ***************************************************************************/ | 1190 ***************************************************************************/ |
| 1117 | 1191 |
| 1118 Word16 vad_hangover ( | 1192 Word16 vad_hangover ( |
| 1193 struct EFR_encoder_state *st, | |
| 1119 Word16 vvad | 1194 Word16 vvad |
| 1120 ) | 1195 ) |
| 1121 { | 1196 { |
| 1122 test (); | 1197 struct vad_state *vst = &st->vad; |
| 1198 | |
| 1123 if (sub (vvad, 1) == 0) | 1199 if (sub (vvad, 1) == 0) |
| 1124 { | 1200 { |
| 1125 burstcount = add (burstcount, 1); | 1201 vst->burstcount = add (vst->burstcount, 1); |
| 1126 } | 1202 } |
| 1127 else | 1203 else |
| 1128 { | 1204 { |
| 1129 burstcount = 0; move16 (); | 1205 vst->burstcount = 0; |
| 1130 } | 1206 } |
| 1131 | 1207 |
| 1132 test (); | 1208 if (sub (vst->burstcount, BURSTCONST) >= 0) |
| 1133 if (sub (burstcount, BURSTCONST) >= 0) | 1209 { |
| 1134 { | 1210 vst->hangcount = HANGCONST; |
| 1135 hangcount = HANGCONST; move16 (); | 1211 vst->burstcount = BURSTCONST; |
| 1136 burstcount = BURSTCONST;move16 (); | 1212 } |
| 1137 } | 1213 if (vst->hangcount >= 0) |
| 1138 test (); | 1214 { |
| 1139 if (hangcount >= 0) | 1215 vst->hangcount = sub (vst->hangcount, 1); |
| 1140 { | |
| 1141 hangcount = sub (hangcount, 1); | |
| 1142 return 1; /* vad = 1 */ | 1216 return 1; /* vad = 1 */ |
| 1143 } | 1217 } |
| 1144 return vvad; /* vad = vvad */ | 1218 return vvad; /* vad = vvad */ |
| 1145 } | 1219 } |
| 1146 | 1220 |
| 1158 * RETURN VALUE: none | 1232 * RETURN VALUE: none |
| 1159 * | 1233 * |
| 1160 ***************************************************************************/ | 1234 ***************************************************************************/ |
| 1161 | 1235 |
| 1162 void periodicity_update ( | 1236 void periodicity_update ( |
| 1163 Word16 lags[], | 1237 struct EFR_encoder_state *st, |
| 1164 Word16 *ptch | 1238 Word16 lags[] |
| 1165 ) | 1239 ) |
| 1166 { | 1240 { |
| 1241 struct vad_state *vst = &st->vad; | |
| 1167 Word16 minlag, maxlag, lagcount, temp; | 1242 Word16 minlag, maxlag, lagcount, temp; |
| 1168 Word16 i; | 1243 Word16 i; |
| 1169 | 1244 |
| 1170 /*** Run loop for the two halves in the frame ***/ | 1245 /*** Run loop for the two halves in the frame ***/ |
| 1171 | 1246 |
| 1172 lagcount = 0; move16 (); | 1247 lagcount = 0; |
| 1173 | 1248 |
| 1174 for (i = 0; i <= 1; i++) | 1249 for (i = 0; i <= 1; i++) |
| 1175 { | 1250 { |
| 1176 /*** Search the maximum and minimum of consecutive lags ***/ | 1251 /*** Search the maximum and minimum of consecutive lags ***/ |
| 1177 | 1252 |
| 1178 test (); | 1253 if (sub (vst->oldlag, lags[i]) > 0) |
| 1179 if (sub (oldlag, lags[i]) > 0) | 1254 { |
| 1180 { | 1255 minlag = lags[i]; |
| 1181 minlag = lags[i]; move16 (); | 1256 maxlag = vst->oldlag; |
| 1182 maxlag = oldlag; move16 (); | |
| 1183 } | 1257 } |
| 1184 else | 1258 else |
| 1185 { | 1259 { |
| 1186 minlag = oldlag; move16 (); | 1260 minlag = vst->oldlag; |
| 1187 maxlag = lags[i]; move16 (); | 1261 maxlag = lags[i]; |
| 1188 } | 1262 } |
| 1189 | 1263 |
| 1190 temp = sub (maxlag, minlag); | 1264 temp = sub (maxlag, minlag); |
| 1191 | 1265 |
| 1192 test (); | |
| 1193 if (sub (temp, LTHRESH) < 0) | 1266 if (sub (temp, LTHRESH) < 0) |
| 1194 { | 1267 { |
| 1195 lagcount = add (lagcount, 1); | 1268 lagcount = add (lagcount, 1); |
| 1196 } | 1269 } |
| 1197 /*** Save the current LTP lag ***/ | 1270 /*** Save the current LTP lag ***/ |
| 1198 | 1271 |
| 1199 oldlag = lags[i]; move16 (); | 1272 vst->oldlag = lags[i]; |
| 1200 } | 1273 } |
| 1201 | 1274 |
| 1202 /*** Update the veryoldlagcount and oldlagcount ***/ | 1275 /*** Update the veryoldlagcount and oldlagcount ***/ |
| 1203 | 1276 |
| 1204 veryoldlagcount = oldlagcount; | 1277 vst->veryoldlagcount = vst->oldlagcount; |
| 1205 move16 (); | 1278 vst->oldlagcount = lagcount; |
| 1206 oldlagcount = lagcount; move16 (); | |
| 1207 | 1279 |
| 1208 /*** Make ptch decision ready for next frame ***/ | 1280 /*** Make ptch decision ready for next frame ***/ |
| 1209 | 1281 |
| 1210 temp = add (oldlagcount, veryoldlagcount); | 1282 temp = add (vst->oldlagcount, vst->veryoldlagcount); |
| 1211 | 1283 |
| 1212 test (); | |
| 1213 if (sub (temp, NTHRESH) >= 0) | 1284 if (sub (temp, NTHRESH) >= 0) |
| 1214 { | 1285 { |
| 1215 *ptch = 1; move16 (); | 1286 st->ptch = 1; |
| 1216 } | 1287 } |
| 1217 else | 1288 else |
| 1218 { | 1289 { |
| 1219 *ptch = 0; move16 (); | 1290 st->ptch = 0; |
| 1220 } | 1291 } |
| 1221 | 1292 |
| 1222 return; | 1293 return; |
| 1223 } | 1294 } |
