Fix logaveragepower_cf for FFT sizes below 16384
This commit is contained in:
parent
8cbf028732
commit
38d567d96e
2 changed files with 10 additions and 14 deletions
22
csdr.c
22
csdr.c
|
@ -1344,27 +1344,23 @@ int main(int argc, char *argv[])
|
||||||
sscanf(argv[3],"%d",&fft_size);
|
sscanf(argv[3],"%d",&fft_size);
|
||||||
sscanf(argv[4],"%d",&avgnumber);
|
sscanf(argv[4],"%d",&avgnumber);
|
||||||
|
|
||||||
if(!getbufsize()) return -2; //dummy
|
float *input = malloc(sizeof(float)*2 * fft_size);
|
||||||
if(!sendbufsize(initialize_buffers())) return -2;
|
float *output = malloc(sizeof(float) * fft_size);
|
||||||
|
|
||||||
if(fft_size != the_bufsize) return -2;
|
add_db -= 10.0*log10(avgnumber);
|
||||||
|
|
||||||
//fprintf(stderr, "logaveragepower_cf %f %d=%d %d\n", add_db, fft_size, the_bufsize, avgnumber);
|
|
||||||
add_db -= 10*log10(avgnumber);
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int i,n;
|
int i,n;
|
||||||
for(i = 0; i < the_bufsize; i++) {
|
for(i = 0; i < fft_size; i++) {
|
||||||
output_buffer[i] = 0;
|
output[i] = 0;
|
||||||
}
|
}
|
||||||
FEOF_CHECK;
|
FEOF_CHECK;
|
||||||
for(n = 0; n < avgnumber; n++) {
|
for(n = 0; n < avgnumber; n++) {
|
||||||
FREAD_C;
|
fread (input, sizeof(float)*2, fft_size, stdin);
|
||||||
//fprintf(stderr, "averaged %d\n", n);
|
accumulate_power_cf((complexf*)input, output, fft_size);
|
||||||
accumulate_power_cf((complexf*)input_buffer, output_buffer, the_bufsize);
|
|
||||||
}
|
}
|
||||||
log_ff(NULL, output_buffer, the_bufsize, add_db);
|
log_ff(output, output, fft_size, add_db);
|
||||||
FWRITE_R;
|
fwrite (output, sizeof(float), fft_size, stdout);
|
||||||
TRY_YIELD;
|
TRY_YIELD;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -979,7 +979,7 @@ void accumulate_power_cf(complexf* input, float* output, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_ff(float* input, float* output, int size, float add_db) {
|
void log_ff(float* input, float* output, int size, float add_db) {
|
||||||
for(int i=0;i<size;i++) output[i]=log10(output[i]); //@logpower_cf: pass 2
|
for(int i=0;i<size;i++) output[i]=log10(input[i]); //@logpower_cf: pass 2
|
||||||
|
|
||||||
for(int i=0;i<size;i++) output[i]=10*output[i]+add_db; //@logpower_cf: pass 3
|
for(int i=0;i<size;i++) output[i]=10*output[i]+add_db; //@logpower_cf: pass 3
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue