comparison libgsmefr/vad.c @ 203:1c108dd5b33f

libgsmefr/vad.c: perf opt
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 04 Jan 2023 06:04:45 +0000
parents 756605c4850f
children
comparison
equal deleted inserted replaced
202:0faf23a9286f 203:1c108dd5b33f
375 vst->L_sav0[vst->pt_sav0 + i] = L_av0[i]; 375 vst->L_sav0[vst->pt_sav0 + i] = L_av0[i];
376 } 376 }
377 377
378 /* Update the array pointers */ 378 /* Update the array pointers */
379 379
380 if (sub (vst->pt_sacf, 18) == 0) 380 if (vst->pt_sacf == 18)
381 { 381 {
382 vst->pt_sacf = 0; 382 vst->pt_sacf = 0;
383 } 383 }
384 else 384 else
385 { 385 {
386 vst->pt_sacf = add (vst->pt_sacf, 9); 386 vst->pt_sacf += 9;
387 } 387 }
388 388
389 if (sub (vst->pt_sav0, 27) == 0) 389 if (vst->pt_sav0 == 27)
390 { 390 {
391 vst->pt_sav0 = 0; 391 vst->pt_sav0 = 0;
392 } 392 }
393 else 393 else
394 { 394 {
395 vst->pt_sav0 = add (vst->pt_sav0, 9); 395 vst->pt_sav0 += 9;
396 } 396 }
397 397
398 return; 398 return;
399 } 399 }
400 400
486 486
487 for (n = 0; n < 8; n++) 487 for (n = 0; n < 8; n++)
488 { 488 {
489 test (); 489 test ();
490 if ((pp[0] == 0) || 490 if ((pp[0] == 0) ||
491 (sub (pp[0], abs_s (pp[1])) < 0)) 491 (pp[0] < abs_s (pp[1])))
492 { 492 {
493 for (i = n; i < 8; i++) 493 for (i = n; i < 8; i++)
494 { 494 {
495 vpar[i] = 0; move16 (); 495 vpar[i] = 0; move16 ();
496 } 496 }
502 if (pp[1] > 0) 502 if (pp[1] > 0)
503 { 503 {
504 vpar[n] = negate (vpar[n]); move16 (); 504 vpar[n] = negate (vpar[n]); move16 ();
505 } 505 }
506 test (); 506 test ();
507 if (sub (n, 7) == 0) 507 if (n == 7)
508 { 508 {
509 return; 509 return;
510 } 510 }
511 /*** Schur recursion: ***/ 511 /*** Schur recursion: ***/
512 512
717 sav0[0] = shl (sav0[0], 3); move16 (); 717 sav0[0] = shl (sav0[0], 3); move16 ();
718 shift = norm_l (L_temp); 718 shift = norm_l (L_temp);
719 temp = extract_h (L_shl (L_temp, shift)); 719 temp = extract_h (L_shl (L_temp, shift));
720 720
721 test (); 721 test ();
722 if (sub (sav0[0], temp) >= 0) 722 if (sav0[0] >= temp)
723 { 723 {
724 divshift = 0; move16 (); 724 divshift = 0; move16 ();
725 temp = div_s (temp, sav0[0]); 725 temp = div_s (temp, sav0[0]);
726 } 726 }
727 else 727 else
730 temp = sub (temp, sav0[0]); 730 temp = sub (temp, sav0[0]);
731 temp = div_s (temp, sav0[0]); 731 temp = div_s (temp, sav0[0]);
732 } 732 }
733 733
734 test (); 734 test ();
735 if (sub (divshift, 1) == 0) 735 if (divshift == 1)
736 { 736 {
737 L_dm = 0x8000L; move32 (); 737 L_dm = 0x8000L; move32 ();
738 } 738 }
739 else 739 else
740 { 740 {
832 comp = 0; move16 (); 832 comp = 0; move16 ();
833 833
834 /*** Test if acf0 < pth; if yes set thvad to plev ***/ 834 /*** Test if acf0 < pth; if yes set thvad to plev ***/
835 835
836 test (); 836 test ();
837 if (sub (acf0.e, E_PTH) < 0) 837 if (acf0.e < E_PTH)
838 { 838 {
839 comp = 1; move16 (); 839 comp = 1; move16 ();
840 } 840 }
841 test (); test (); 841 test (); test ();
842 if ((sub (acf0.e, E_PTH) == 0) && (sub (acf0.m, M_PTH) < 0)) 842 if ((acf0.e == E_PTH) && (acf0.m < M_PTH))
843 { 843 {
844 comp = 1; move16 (); 844 comp = 1; move16 ();
845 } 845 }
846 test (); 846 test ();
847 if (sub (comp, 1) == 0) 847 if (comp == 1)
848 { 848 {
849 thvad->e = E_PLEV; move16 (); 849 thvad->e = E_PLEV; move16 ();
850 thvad->m = M_PLEV; move16 (); 850 thvad->m = M_PLEV; move16 ();
851 851
852 return; 852 return;
853 } 853 }
854 /*** Test if an adaption is required ***/ 854 /*** Test if an adaption is required ***/
855 855
856 test (); 856 test ();
857 if (sub (ptch, 1) == 0) 857 if (ptch == 1)
858 { 858 {
859 comp = 1; move16 (); 859 comp = 1; move16 ();
860 } 860 }
861 test (); 861 test ();
862 if (stat == 0) 862 if (stat == 0)
863 { 863 {
864 comp = 1; move16 (); 864 comp = 1; move16 ();
865 } 865 }
866 test (); 866 test ();
867 if (sub (tone, 1) == 0) 867 if (tone == 1)
868 { 868 {
869 comp = 1; move16 (); 869 comp = 1; move16 ();
870 } 870 }
871 test (); 871 test ();
872 if (sub (comp, 1) == 0) 872 if (comp == 1)
873 { 873 {
874 vst->adaptcount = 0; 874 vst->adaptcount = 0;
875 return; 875 return;
876 } 876 }
877 /*** Increment adaptcount ***/ 877 /*** Increment adaptcount ***/
878 878
879 vst->adaptcount = add (vst->adaptcount, 1); 879 vst->adaptcount = add (vst->adaptcount, 1);
880 if (sub (vst->adaptcount, 8) <= 0) 880 if (vst->adaptcount <= 8)
881 { 881 {
882 return; 882 return;
883 } 883 }
884 /*** computation of thvad-(thvad/dec) ***/ 884 /*** computation of thvad-(thvad/dec) ***/
885 885
886 thvad->m = sub (thvad->m, shr (thvad->m, 5)); move16 (); 886 thvad->m = sub (thvad->m, shr (thvad->m, 5)); move16 ();
887 887
888 test (); 888 test ();
889 if (sub (thvad->m, 0x4000) < 0) 889 if (thvad->m < 0x4000)
890 { 890 {
891 thvad->m = shl (thvad->m, 1); move16 (); 891 thvad->m = shl (thvad->m, 1); move16 ();
892 thvad->e = sub (thvad->e, 1); move16 (); 892 thvad->e = sub (thvad->e, 1); move16 ();
893 } 893 }
894 /*** computation of pvad*fac ***/ 894 /*** computation of pvad*fac ***/
906 p_temp.m = extract_l (L_temp); move16 (); 906 p_temp.m = extract_l (L_temp); move16 ();
907 907
908 /*** test if thvad < pvad*fac ***/ 908 /*** test if thvad < pvad*fac ***/
909 909
910 test (); 910 test ();
911 if (sub (thvad->e, p_temp.e) < 0) 911 if (thvad->e < p_temp.e)
912 { 912 {
913 comp = 1; move16 (); 913 comp = 1; move16 ();
914 } 914 }
915 test (); test (); 915 test (); test ();
916 if ((sub (thvad->e, p_temp.e) == 0) && 916 if ((thvad->e == p_temp.e) &&
917 (sub (thvad->m, p_temp.m) < 0)) 917 (thvad->m < p_temp.m))
918 { 918 {
919 comp = 1; move16 (); 919 comp = 1; move16 ();
920 } 920 }
921 /*** compute minimum(thvad+(thvad/inc), pvad*fac) when comp = 1 ***/ 921 /*** compute minimum(thvad+(thvad/inc), pvad*fac) when comp = 1 ***/
922 922
923 test (); 923 test ();
924 if (sub (comp, 1) == 0) 924 if (comp == 1)
925 { 925 {
926 /*** compute thvad + (thvad/inc) ***/ 926 /*** compute thvad + (thvad/inc) ***/
927 927
928 L_temp = L_add (L_deposit_l (thvad->m), 928 L_temp = L_add (L_deposit_l (thvad->m),
929 L_deposit_l (shr (thvad->m, 4))); 929 L_deposit_l (shr (thvad->m, 4)));
930 930
931 test (); 931 test ();
932 if (L_sub (L_temp, 0x7fffL) > 0) 932 if (L_temp > 0x7fffL)
933 { 933 {
934 thvad->m = extract_l (L_shr (L_temp, 1)); move16 (); 934 thvad->m = extract_l (L_shr (L_temp, 1)); move16 ();
935 thvad->e = add (thvad->e, 1); move16 (); 935 thvad->e = add (thvad->e, 1); move16 ();
936 } 936 }
937 else 937 else
940 } 940 }
941 941
942 comp2 = 0; move16 (); 942 comp2 = 0; move16 ();
943 943
944 test (); 944 test ();
945 if (sub (p_temp.e, thvad->e) < 0) 945 if (p_temp.e < thvad->e)
946 { 946 {
947 comp2 = 1; move16 (); 947 comp2 = 1; move16 ();
948 } 948 }
949 test (); test (); 949 test (); test ();
950 if ((sub (p_temp.e, thvad->e) == 0) && 950 if ((p_temp.e == thvad->e) &&
951 (sub (p_temp.m, thvad->m) < 0)) 951 (p_temp.m < thvad->m))
952 { 952 {
953 comp2 = 1; move16 (); 953 comp2 = 1; move16 ();
954 } 954 }
955 test (); 955 test ();
956 if (sub (comp2, 1) == 0) 956 if (comp2 == 1)
957 { 957 {
958 thvad->e = p_temp.e;move16 (); 958 thvad->e = p_temp.e;move16 ();
959 thvad->m = p_temp.m;move16 (); 959 thvad->m = p_temp.m;move16 ();
960 } 960 }
961 } 961 }
962 /*** compute pvad + margin ***/ 962 /*** compute pvad + margin ***/
963 963
964 test (); 964 test ();
965 if (sub (pvad.e, E_MARGIN) == 0) 965 if (pvad.e == E_MARGIN)
966 { 966 {
967 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (M_MARGIN)); 967 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (M_MARGIN));
968 p_temp.m = extract_l (L_shr (L_temp, 1)); move16 (); 968 p_temp.m = extract_l (L_shr (L_temp, 1)); move16 ();
969 p_temp.e = add (pvad.e, 1); move16 (); 969 p_temp.e = add (pvad.e, 1); move16 ();
970 } 970 }
971 else 971 else
972 { 972 {
973 test (); 973 test ();
974 if (sub (pvad.e, E_MARGIN) > 0) 974 if (pvad.e > E_MARGIN)
975 { 975 {
976 temp = sub (pvad.e, E_MARGIN); 976 temp = sub (pvad.e, E_MARGIN);
977 temp = shr (M_MARGIN, temp); 977 temp = shr (M_MARGIN, temp);
978 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (temp)); 978 L_temp = L_add (L_deposit_l (pvad.m), L_deposit_l (temp));
979 979
980 test (); 980 test ();
981 if (L_sub (L_temp, 0x7fffL) > 0) 981 if (L_temp > 0x7fffL)
982 { 982 {
983 p_temp.e = add (pvad.e, 1); move16 (); 983 p_temp.e = add (pvad.e, 1); move16 ();
984 p_temp.m = extract_l (L_shr (L_temp, 1)); 984 p_temp.m = extract_l (L_shr (L_temp, 1));
985 move16 (); 985 move16 ();
986 } 986 }
995 temp = sub (E_MARGIN, pvad.e); 995 temp = sub (E_MARGIN, pvad.e);
996 temp = shr (pvad.m, temp); 996 temp = shr (pvad.m, temp);
997 L_temp = L_add (L_deposit_l (M_MARGIN), L_deposit_l (temp)); 997 L_temp = L_add (L_deposit_l (M_MARGIN), L_deposit_l (temp));
998 998
999 test (); 999 test ();
1000 if (L_sub (L_temp, 0x7fffL) > 0) 1000 if (L_temp > 0x7fffL)
1001 { 1001 {
1002 p_temp.e = add (E_MARGIN, 1); move16 (); 1002 p_temp.e = add (E_MARGIN, 1); move16 ();
1003 p_temp.m = extract_l (L_shr (L_temp, 1)); 1003 p_temp.m = extract_l (L_shr (L_temp, 1));
1004 move16 (); 1004 move16 ();
1005 } 1005 }
1014 /*** Test if thvad > pvad + margin ***/ 1014 /*** Test if thvad > pvad + margin ***/
1015 1015
1016 comp = 0; move16 (); 1016 comp = 0; move16 ();
1017 1017
1018 test (); 1018 test ();
1019 if (sub (thvad->e, p_temp.e) > 0) 1019 if (thvad->e > p_temp.e)
1020 { 1020 {
1021 comp = 1; move16 (); 1021 comp = 1; move16 ();
1022 } 1022 }
1023 test (); test (); 1023 test (); test ();
1024 if ((sub (thvad->e, p_temp.e) == 0) && 1024 if ((thvad->e == p_temp.e) &&
1025 (sub (thvad->m, p_temp.m) > 0)) 1025 (thvad->m > p_temp.m))
1026 { 1026 {
1027 comp = 1; move16 (); 1027 comp = 1; move16 ();
1028 } 1028 }
1029 test (); 1029 test ();
1030 if (sub (comp, 1) == 0) 1030 if (comp == 1)
1031 { 1031 {
1032 thvad->e = p_temp.e; move16 (); 1032 thvad->e = p_temp.e; move16 ();
1033 thvad->m = p_temp.m; move16 (); 1033 thvad->m = p_temp.m; move16 ();
1034 } 1034 }
1035 /*** Normalise and retain rvad[0..8] in memory ***/ 1035 /*** Normalise and retain rvad[0..8] in memory ***/
1155 ) 1155 )
1156 { 1156 {
1157 Word16 vvad; 1157 Word16 vvad;
1158 1158
1159 test (); test (); test (); 1159 test (); test (); test ();
1160 if (sub (pvad.e, thvad.e) > 0) 1160 if (pvad.e > thvad.e)
1161 { 1161 {
1162 vvad = 1; move16 (); 1162 vvad = 1; move16 ();
1163 } 1163 }
1164 else if ((sub (pvad.e, thvad.e) == 0) && 1164 else if ((pvad.e == thvad.e) &&
1165 (sub (pvad.m, thvad.m) > 0)) 1165 (pvad.m > thvad.m))
1166 { 1166 {
1167 vvad = 1; move16 (); 1167 vvad = 1; move16 ();
1168 } 1168 }
1169 else 1169 else
1170 { 1170 {
1194 Word16 vvad 1194 Word16 vvad
1195 ) 1195 )
1196 { 1196 {
1197 struct vad_state *vst = &st->vad; 1197 struct vad_state *vst = &st->vad;
1198 1198
1199 if (sub (vvad, 1) == 0) 1199 if (vvad == 1)
1200 { 1200 {
1201 vst->burstcount = add (vst->burstcount, 1); 1201 vst->burstcount++;
1202 } 1202 }
1203 else 1203 else
1204 { 1204 {
1205 vst->burstcount = 0; 1205 vst->burstcount = 0;
1206 } 1206 }
1207 1207
1208 if (sub (vst->burstcount, BURSTCONST) >= 0) 1208 if (vst->burstcount >= BURSTCONST)
1209 { 1209 {
1210 vst->hangcount = HANGCONST; 1210 vst->hangcount = HANGCONST;
1211 vst->burstcount = BURSTCONST; 1211 vst->burstcount = BURSTCONST;
1212 } 1212 }
1213 if (vst->hangcount >= 0) 1213 if (vst->hangcount >= 0)
1214 { 1214 {
1215 vst->hangcount = sub (vst->hangcount, 1); 1215 vst->hangcount--;
1216 return 1; /* vad = 1 */ 1216 return 1; /* vad = 1 */
1217 } 1217 }
1218 return vvad; /* vad = vvad */ 1218 return vvad; /* vad = vvad */
1219 } 1219 }
1220 1220
1248 1248
1249 for (i = 0; i <= 1; i++) 1249 for (i = 0; i <= 1; i++)
1250 { 1250 {
1251 /*** Search the maximum and minimum of consecutive lags ***/ 1251 /*** Search the maximum and minimum of consecutive lags ***/
1252 1252
1253 if (sub (vst->oldlag, lags[i]) > 0) 1253 if (vst->oldlag > lags[i])
1254 { 1254 {
1255 minlag = lags[i]; 1255 minlag = lags[i];
1256 maxlag = vst->oldlag; 1256 maxlag = vst->oldlag;
1257 } 1257 }
1258 else 1258 else
1261 maxlag = lags[i]; 1261 maxlag = lags[i];
1262 } 1262 }
1263 1263
1264 temp = sub (maxlag, minlag); 1264 temp = sub (maxlag, minlag);
1265 1265
1266 if (sub (temp, LTHRESH) < 0) 1266 if (temp < LTHRESH)
1267 { 1267 {
1268 lagcount = add (lagcount, 1); 1268 lagcount = add (lagcount, 1);
1269 } 1269 }
1270 /*** Save the current LTP lag ***/ 1270 /*** Save the current LTP lag ***/
1271 1271
1279 1279
1280 /*** Make ptch decision ready for next frame ***/ 1280 /*** Make ptch decision ready for next frame ***/
1281 1281
1282 temp = add (vst->oldlagcount, vst->veryoldlagcount); 1282 temp = add (vst->oldlagcount, vst->veryoldlagcount);
1283 1283
1284 if (sub (temp, NTHRESH) >= 0) 1284 if (temp >= NTHRESH)
1285 { 1285 {
1286 st->ptch = 1; 1286 st->ptch = 1;
1287 } 1287 }
1288 else 1288 else
1289 { 1289 {