diff --git a/modules/transforms/transform_fft/function_info.cpp b/modules/transforms/transform_fft/function_info.cpp index 9ca69c0669cac156c7f3d22f55f313f8fe0a3ce5..6c2172c803533bd49a22699eaadd093ec7ce55bd 100644 --- a/modules/transforms/transform_fft/function_info.cpp +++ b/modules/transforms/transform_fft/function_info.cpp @@ -24,12 +24,19 @@ const char * g_info = "{\n\ \"tooltip\":\"0=Real,1=Complex\",\n\ \"default\":0\n\ },\n\ - \"mod:\":{\n\ + \"frame_span\":{\n\ + \"type\":\"int\",\n\ + \"tooltip\":\"Frame Span (count) between each fft calc. Slower CPU need larger spans.\",\n\ + \"range\":\">=1\",\n\ + \"default\":16\n\ + },\n\ + \"mod\":{\n\ \"type\":\"int\",\n\ - \"tooltip\":\"0=frame,1=continous\",\n\ + \"tooltip\":\"WorkingMod\",\n\ + \"range\":\"0=Frame,1=Continous\",\n\ \"default\":0\n\ },\n\ - \"fftsize\":{\n\ + \"fftsize\":{\n\ \"type\":\"int\",\n\ \"tooltip\":\"fft size\",\n\ \"default\":1024\n\ diff --git a/modules/transforms/transform_fft/main.cpp b/modules/transforms/transform_fft/main.cpp index 6e8d1c17dc022c8ee47f3d9609c5e13dbae4c269..1675cdf4204b4f2b970087fd206fb116e114a77f 100644 --- a/modules/transforms/transform_fft/main.cpp +++ b/modules/transforms/transform_fft/main.cpp @@ -48,12 +48,12 @@ int main(int argc , char * argv[]) } else if (args.contains("function"/*,"tranform_fft"*/))//正常运行模式 { - unsigned int imod = args.toUInt("mod",0); - if (!imod) - ret = do_fftw(args); - else - ret = do_fftw_continous(args); - } + unsigned int imod = args.toUInt("mod",0); + if (!imod) + ret = do_fftw(args); + else + ret = do_fftw_continous(args); + } else { fprintf(stderr,"Error:Function does not exits."); @@ -72,14 +72,15 @@ int do_fftw(const cmdlineParser & args) unsigned int instance = args.toInt("instance",0); unsigned int isource = args.toInt("signal",0); unsigned int FFT = args.toInt("FFT",0); - unsigned int Spec = args.toInt("Spec",0); - unsigned int itmstamp_in = args.toUInt("tmstamp_in",0); + unsigned int Spec = args.toInt("Spec",0); + unsigned int itmstamp_in = args.toUInt("tmstamp_in",0); unsigned int itmstamp_out = args.toUInt("tmstamp_out",0); - unsigned int itypes = args.toUInt("input_type",0);//0=real,1=complex - //工作模式 - const int sptype = args.toInt("sptype",0); fprintf(stderr,"sptype is %d.",sptype); + unsigned int itypes = args.toUInt("input_type",0);//0=real,1=complex + const unsigned int frame_span = args.toInt("frame_span",1)>0?args.toInt("frame_span",1):1; + //工作模式 + const int sptype = args.toInt("sptype",0); fprintf(stderr,"sptype is %d.",sptype); - int channels = args.toInt("channels",1); + int channels = args.toInt("channels",1); if (channels<1) channels = 1; @@ -90,8 +91,7 @@ int do_fftw(const cmdlineParser & args) fprintf(stderr,"fftsize must >16."); return res; } - - fflush(stderr); + fflush(stderr); try{ //判断参数合法性 @@ -148,7 +148,10 @@ int do_fftw(const cmdlineParser & args) const unsigned long long llts = map_tmst_outside[header.path_id]; push_subject(itmstamp_out,header.path_id,sizeof(unsigned long long),(const unsigned char *)&llts); } - } + } + + if (map_tmst_inside[header.path_id]++%frame_span) + continue; const unsigned char * pdta = packagedta.data(); //Normalizer @@ -328,7 +331,6 @@ int do_fftw(const cmdlineParser & args) push_subject(FFT,header.path_id,fftsize*sizeof(double)/(itypes==0?2:1),(const unsigned char *)vec_fft_abs.data()); if (Spec>0) push_subject(Spec,header.path_id,fftsize*sizeof(double),(const unsigned char *)out); - ++map_tmst_inside[header.path_id]; } } @@ -359,6 +361,8 @@ int do_fftw_continous(const cmdlineParser & args) unsigned int FFT = args.toInt("FFT",0); unsigned int Spec = args.toInt("Spec",0); unsigned int itmstamp_in = args.toUInt("tmstamp_in",0); + const unsigned int frame_span = args.toInt("frame_span",1)>0?args.toInt("frame_span",1):1; + unsigned int itypes = args.toUInt("input_type",0);//0=real,1=complex //工作模式 const int sptype = args.toInt("sptype",0); fprintf(stderr,"sptype is %d.",sptype); @@ -394,6 +398,7 @@ int do_fftw_continous(const cmdlineParser & args) //Ring buf unordered_map > map_buf_inside; unordered_map map_buf_pos,map_buf_deal; + unordered_map cal_cnt; for (int i=0;i(2*RingSize); map_buf_pos[header.path_id] = 0; map_buf_deal[header.path_id] = 0; + cal_cnt[header.path_id] = 0; } + if (cal_cnt[header.path_id]++%frame_span) + continue; const unsigned char * pdta = packagedta.data(); //Normalizer