Fixed output_size (there were a bunch of zeros in the output).

This commit is contained in:
ha7ilm 2015-11-18 17:47:18 +01:00
parent 175c700cc9
commit a6cf61d60b
4 changed files with 11 additions and 9 deletions

6
csdr.c
View file

@ -1714,7 +1714,7 @@ int main(int argc, char *argv[])
fastddc_print(&ddc); fastddc_print(&ddc);
if(!initialize_buffers()) return -2; if(!initialize_buffers()) return -2;
sendbufsize(ddc.output_size); sendbufsize(ddc.post_input_size/ddc.post_decimation); //TODO not exactly correct
//prepare making the filter and doing FFT on it //prepare making the filter and doing FFT on it
complexf* taps=(complexf*)calloc(sizeof(complexf),ddc.fft_size); //initialize to zero complexf* taps=(complexf*)calloc(sizeof(complexf),ddc.fft_size); //initialize to zero
@ -1735,7 +1735,7 @@ int main(int argc, char *argv[])
//alloc. buffers //alloc. buffers
complexf* input = (complexf*)fft_malloc(sizeof(complexf)*ddc.fft_size); complexf* input = (complexf*)fft_malloc(sizeof(complexf)*ddc.fft_size);
complexf* output = (complexf*)fft_malloc(sizeof(complexf)*ddc.output_size); complexf* output = (complexf*)fft_malloc(sizeof(complexf)*ddc.post_input_size);
decimating_shift_addition_status_t shift_stat; decimating_shift_addition_status_t shift_stat;
bzero(&shift_stat, sizeof(shift_stat)); bzero(&shift_stat, sizeof(shift_stat));
@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
FEOF_CHECK; FEOF_CHECK;
fread(input, sizeof(complexf), ddc.fft_size, stdin); fread(input, sizeof(complexf), ddc.fft_size, stdin);
shift_stat = fastddc_inv_cc(input, output, &ddc, plan_inverse, taps_fft, shift_stat); shift_stat = fastddc_inv_cc(input, output, &ddc, plan_inverse, taps_fft, shift_stat);
fwrite(output, sizeof(complexf), ddc.output_size, stdout); fwrite(output, sizeof(complexf), shift_stat.output_size, stdout);
TRY_YIELD; TRY_YIELD;
} }
} }

View file

@ -63,7 +63,7 @@ int fastddc_init(fastddc_t* ddc, float transition_bw, int decimation, float shif
//Overlap is scraped, not added //Overlap is scraped, not added
ddc->scrape=ddc->overlap_length/ddc->pre_decimation; ddc->scrape=ddc->overlap_length/ddc->pre_decimation;
ddc->output_size=ddc->fft_inv_size-ddc->scrape; ddc->post_input_size=ddc->fft_inv_size-ddc->scrape;
return ddc->fft_size<=2; //returns true on error return ddc->fft_size<=2; //returns true on error
} }
@ -76,13 +76,13 @@ void fastddc_print(fastddc_t* ddc)
" overlap :: (overlap_length = %d) = taps_length - 1, taps_real_length = %d\n" " overlap :: (overlap_length = %d) = taps_length - 1, taps_real_length = %d\n"
" decimation :: decimation = (pre_decimation = %d) * (post_decimation = %d), fft_inv_size = %d\n" " decimation :: decimation = (pre_decimation = %d) * (post_decimation = %d), fft_inv_size = %d\n"
" shift :: startbin = %d, offsetbin = %d, v = %d, pre_shift = %g, post_shift = %g\n" " shift :: startbin = %d, offsetbin = %d, v = %d, pre_shift = %g, post_shift = %g\n"
" o&s :: output_size = %d, scrape = %d\n" " o&s :: post_input_size = %d, scrape = %d\n"
, ,
ddc->fft_size, ddc->taps_length, ddc->input_size, ddc->fft_size, ddc->taps_length, ddc->input_size,
ddc->overlap_length, ddc->taps_real_length, ddc->overlap_length, ddc->taps_real_length,
ddc->pre_decimation, ddc->post_decimation, ddc->fft_inv_size, ddc->pre_decimation, ddc->post_decimation, ddc->fft_inv_size,
ddc->startbin, ddc->offsetbin, ddc->v, ddc->pre_shift, ddc->post_shift, ddc->startbin, ddc->offsetbin, ddc->v, ddc->pre_shift, ddc->post_shift,
ddc->output_size, ddc->scrape ); ddc->post_input_size, ddc->scrape );
} }
void fft_swap_sides(complexf* io, int fft_size) void fft_swap_sides(complexf* io, int fft_size)
@ -138,6 +138,8 @@ decimating_shift_addition_status_t fastddc_inv_cc(complexf* input, complexf* out
//Overlap is scraped, not added //Overlap is scraped, not added
//Shift correction //Shift correction
shift_addition_data_t dsadata=decimating_shift_addition_init(ddc->post_shift, ddc->post_decimation); //this could be optimized (passed as parameter), but we would not win too much at all shift_addition_data_t dsadata=decimating_shift_addition_init(ddc->post_shift, ddc->post_decimation); //this could be optimized (passed as parameter), but we would not win too much at all
shift_stat=decimating_shift_addition_cc(inv_output+ddc->scrape, output, ddc->output_size, dsadata, ddc->post_decimation, shift_stat); shift_stat=decimating_shift_addition_cc(inv_output+ddc->scrape, output, ddc->post_input_size, dsadata, ddc->post_decimation, shift_stat);
//memcpy(inv_output+ddc->scrape,
return shift_stat; return shift_stat;
} }

View file

@ -12,7 +12,7 @@ typedef struct fastddc_s
int fft_size; int fft_size;
int fft_inv_size; int fft_inv_size;
int input_size; int input_size;
int output_size; int post_input_size;
float pre_shift; float pre_shift;
int startbin; //for pre_shift int startbin; //for pre_shift
int v; //step for pre_shift int v; //step for pre_shift

View file

@ -281,7 +281,7 @@
</param> </param>
<param> <param>
<key>commandline</key> <key>commandline</key>
<value>csdr fastddc_fwd_cc 10 | csdr fastddc_apply_cc 10 0.1 | csdr floatdump_f 2&gt;&amp;1 | head -n 100</value> <value>csdr fastddc_fwd_cc 10 | csdr fastddc_inv_cc 10 0.1</value>
</param> </param>
<param> <param>
<key>comment</key> <key>comment</key>