50
50
#include "bpfb.h"
51
51
#include "newamp1.h"
52
52
#include "lpcnet_freq.h"
53
+ #include "sd.h"
53
54
54
55
void synth_one_frame (int n_samp , codec2_fftr_cfg fftr_inv_cfg , short buf [], MODEL * model , float Sn_ [], float Pn [], int prede , float * de_mem , float gain );
55
56
void print_help (const struct option * long_options , int num_opts , char * argv []);
@@ -70,7 +71,7 @@ int main(int argc, char *argv[])
70
71
71
72
int lpc_model = 0 , order = LPC_ORD ;
72
73
int lsp = 0 , lspd = 0 , lspvq = 0 ;
73
- int lspjvm = 0 ;
74
+ int lspjmv = 0 ;
74
75
int prede = 0 ;
75
76
int postfilt ;
76
77
int hand_voicing = 0 , hi = 0 , simlpcpf = 0 , modelin = 0 , modelout = 0 ;
@@ -92,7 +93,7 @@ int main(int argc, char *argv[])
92
93
FILE * fam = NULL , * fWo = NULL ;
93
94
FILE * faw = NULL ;
94
95
FILE * fhm = NULL ;
95
- FILE * fjvm = NULL ;
96
+ FILE * fjmv = NULL ;
96
97
FILE * flspEWov = NULL ;
97
98
FILE * ften_ms_centre = NULL ;
98
99
FILE * fmodelout = NULL ;
@@ -133,7 +134,7 @@ int main(int argc, char *argv[])
133
134
{ "lsp" , no_argument , & lsp , 1 },
134
135
{ "lspd" , no_argument , & lspd , 1 },
135
136
{ "lspvq" , no_argument , & lspvq , 1 },
136
- { "lspjvm " , no_argument , & lspjvm , 1 },
137
+ { "lspjmv " , no_argument , & lspjmv , 1 },
137
138
{ "phase0" , no_argument , & phase0 , 1 },
138
139
{ "postfilter" , no_argument , & postfilt , 1 },
139
140
{ "hand_voicing" , required_argument , & hand_voicing , 1 },
@@ -282,7 +283,7 @@ int main(int argc, char *argv[])
282
283
exit (1 );
283
284
}
284
285
} else if (strcmp (long_options [option_index ].name , "dump_pitch_e" ) == 0 ) {
285
- if ((fjvm = fopen (optarg ,"wt" )) == NULL ) {
286
+ if ((fjmv = fopen (optarg ,"wt" )) == NULL ) {
286
287
fprintf (stderr , "Error opening pitch & energy dump file: %s: %s.\n" ,
287
288
optarg , strerror (errno ));
288
289
exit (1 );
@@ -399,7 +400,7 @@ int main(int argc, char *argv[])
399
400
} else if (strcmp (optarg ,"1200" ) == 0 ) {
400
401
lpc_model = 1 ;
401
402
scalar_quant_Wo_e = 1 ;
402
- lspjvm = 1 ;
403
+ lspjmv = 1 ;
403
404
phase0 = 1 ;
404
405
postfilt = 1 ;
405
406
decimate = 4 ;
@@ -497,7 +498,8 @@ int main(int argc, char *argv[])
497
498
COMP Aw [FFT_ENC ];
498
499
COMP H [MAX_AMP ];
499
500
500
-
501
+ float sd_sum = 0.0 ; int sd_frames = 0 ;
502
+
501
503
for (i = 0 ; i < m_pitch ; i ++ ) {
502
504
Sn [i ] = 1.0 ;
503
505
Sn_pre [i ] = 1.0 ;
@@ -677,7 +679,7 @@ int main(int argc, char *argv[])
677
679
#endif
678
680
679
681
if (dump_pitch_e )
680
- fprintf (fjvm , "%f %f %d " , model .Wo , snr , model .voiced );
682
+ fprintf (fjmv , "%f %f %d " , model .Wo , snr , model .voiced );
681
683
682
684
#ifdef DUMP
683
685
dump_snr (snr );
@@ -701,6 +703,7 @@ int main(int argc, char *argv[])
701
703
\*------------------------------------------------------------*/
702
704
703
705
if (lpc_model ) {
706
+ float ak_ [LPC_ORD + 1 ];
704
707
705
708
e = speech_to_uq_lsps (lsps , ak , Sn , w , m_pitch , order );
706
709
for (i = 0 ; i < order ; i ++ )
@@ -712,7 +715,7 @@ int main(int argc, char *argv[])
712
715
#endif
713
716
714
717
if (dump_pitch_e )
715
- fprintf (fjvm , "%f\n" , e );
718
+ fprintf (fjmv , "%f\n" , e );
716
719
717
720
#ifdef DUMP
718
721
dump_lsp (lsps );
@@ -724,26 +727,33 @@ int main(int argc, char *argv[])
724
727
encode_lsps_scalar (lsp_indexes , lsps , LPC_ORD );
725
728
decode_lsps_scalar (lsps_ , lsp_indexes , LPC_ORD );
726
729
bw_expand_lsps (lsps_ , LPC_ORD , 50.0 , 100.0 );
727
- lsp_to_lpc (lsps_ , ak , LPC_ORD );
730
+ lsp_to_lpc (lsps_ , ak_ , LPC_ORD );
728
731
}
729
732
730
733
if (lspd ) {
731
734
encode_lspds_scalar (lsp_indexes , lsps , LPC_ORD );
732
735
decode_lspds_scalar (lsps_ , lsp_indexes , LPC_ORD );
733
- lsp_to_lpc (lsps_ , ak , LPC_ORD );
736
+ lsp_to_lpc (lsps_ , ak_ , LPC_ORD );
734
737
}
735
738
736
- if (lspjvm ) {
739
+ if (lspjmv ) {
737
740
/* Jean-Marc's multi-stage, split VQ */
738
- lspjvm_quantise (lsps , lsps_ , LPC_ORD );
741
+ lspjmv_quantise (lsps , lsps_ , LPC_ORD );
739
742
{
740
743
float lsps_bw [LPC_ORD ];
741
744
memcpy (lsps_bw , lsps_ , sizeof (float )* order );
742
745
bw_expand_lsps (lsps_bw , LPC_ORD , 50.0 , 100.0 );
743
- lsp_to_lpc (lsps_bw , ak , LPC_ORD );
746
+ lsp_to_lpc (lsps_bw , ak_ , LPC_ORD );
744
747
}
745
748
}
746
749
750
+ if (lsp || lspd || lspjmv ) {
751
+ sd_sum += spectral_dist (ak , ak_ , LPC_ORD , fft_fwd_cfg , FFT_ENC );
752
+ sd_frames ++ ;
753
+ }
754
+
755
+ memcpy (ak , ak_ , (LPC_ORD + 1 )* sizeof (float ));
756
+
747
757
if (scalar_quant_Wo_e ) {
748
758
e = decode_energy (encode_energy (e , E_BITS ), E_BITS );
749
759
model .Wo = decode_Wo (& c2const , encode_Wo (& c2const , model .Wo , WO_BITS ), WO_BITS );
@@ -1068,7 +1078,9 @@ int main(int argc, char *argv[])
1068
1078
fclose (fout );
1069
1079
1070
1080
if (lpc_model ) {
1071
- fprintf (stderr , "SNR av = %5.2f dB\n" , sum_snr /frames );
1081
+ fprintf (stderr , "LPC->{Am} SNR av: %5.2f dB over %d frames\n" , sum_snr /frames , frames );
1082
+ if (lsp || lspd || lspjmv )
1083
+ fprintf (stderr , "LSP quantiser SD: %5.2f dB*dB over %d frames\n" , sd_sum /sd_frames , sd_frames );
1072
1084
}
1073
1085
if (newamp1vq ) {
1074
1086
fprintf (stderr , "var: %3.2f dB*dB\n" , se /nse );
@@ -1087,7 +1099,7 @@ int main(int argc, char *argv[])
1087
1099
if (fWo != NULL ) fclose (fWo );
1088
1100
if (faw != NULL ) fclose (faw );
1089
1101
if (fhm != NULL ) fclose (fhm );
1090
- if (fjvm != NULL ) fclose (fjvm );
1102
+ if (fjmv != NULL ) fclose (fjmv );
1091
1103
if (flspEWov != NULL ) fclose (flspEWov );
1092
1104
if (fphasenn != NULL ) fclose (fphasenn );
1093
1105
if (frateK != NULL ) fclose (frateK );
0 commit comments