[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 07/08: qtgui: removing malloc/free in fft f
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 07/08: qtgui: removing malloc/free in fft function; doing once in ctor and when fftsize changes, instead. |
Date: |
Thu, 23 Oct 2014 22:03:17 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 6f1913bffaded16d05c475375d2048eb0432bfca
Author: Tom Rondeau <address@hidden>
Date: Thu Oct 23 17:30:04 2014 -0400
qtgui: removing malloc/free in fft function; doing once in ctor and when
fftsize changes, instead.
---
gr-qtgui/lib/freq_sink_c_impl.cc | 20 ++++++++++++++------
gr-qtgui/lib/freq_sink_c_impl.h | 3 ++-
gr-qtgui/lib/freq_sink_f_impl.cc | 19 +++++++++++++------
gr-qtgui/lib/freq_sink_f_impl.h | 3 ++-
4 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index f4614e9..e46b9db 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -87,6 +87,11 @@ namespace gr {
volk_get_alignment());
memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ d_tmpbuflen = (unsigned int)(floor(d_fftsize/2.0));
+ d_tmpbuf = (float*)volk_malloc(sizeof(float)*(d_tmpbuflen + 1),
+ volk_get_alignment());
+
+
d_index = 0;
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back((gr_complex*)volk_malloc(d_fftsize*sizeof(gr_complex),
@@ -116,6 +121,7 @@ namespace gr {
}
delete d_fft;
volk_free(d_fbuf);
+ volk_free(d_tmpbuf);
delete d_argv;
}
@@ -432,12 +438,9 @@ namespace gr {
size, 1.0, size);
// Perform shift operation
- unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*(len + 1));
- memcpy(tmp, &data_out[0], sizeof(float)*(len + 1));
- memcpy(&data_out[0], &data_out[size - len], sizeof(float)*(len));
- memcpy(&data_out[len], tmp, sizeof(float)*(len + 1));
- free(tmp);
+ memcpy(d_tmpbuf, &data_out[0], sizeof(float)*(d_tmpbuflen + 1));
+ memcpy(&data_out[0], &data_out[size - d_tmpbuflen],
sizeof(float)*(d_tmpbuflen));
+ memcpy(&data_out[d_tmpbuflen], d_tmpbuf, sizeof(float)*(d_tmpbuflen +
1));
}
bool
@@ -504,6 +507,11 @@ namespace gr {
volk_get_alignment());
memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ volk_free(d_tmpbuf);
+ d_tmpbuflen = (unsigned int)(floor(d_fftsize/2.0));
+ d_tmpbuf = (float*)volk_malloc(sizeof(float)*(d_tmpbuflen + 1),
+ volk_get_alignment());
+
d_last_time = 0;
set_output_multiple(d_fftsize);
diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h
index dc83f96..b5f9cd3 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.h
+++ b/gr-qtgui/lib/freq_sink_c_impl.h
@@ -38,7 +38,7 @@ namespace gr {
void initialize();
int d_fftsize;
- int d_outputsize;
+ int d_tmpbuflen;
float d_fftavg;
filter::firdes::win_type d_wintype;
std::vector<float> d_window;
@@ -54,6 +54,7 @@ namespace gr {
std::vector<gr_complex*> d_residbufs;
std::vector<double*> d_magbufs;
float *d_fbuf;
+ float *d_tmpbuf;
int d_argc;
char *d_argv;
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
index 14c8ff4..200b009 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.cc
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -87,6 +87,10 @@ namespace gr {
volk_get_alignment());
memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ d_tmpbuflen = (unsigned int)(floor(d_fftsize/2.0));
+ d_tmpbuf = (float*)volk_malloc(sizeof(float)*(d_tmpbuflen + 1),
+ volk_get_alignment());
+
d_index = 0;
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back((float*)volk_malloc(d_fftsize*sizeof(float),
@@ -116,6 +120,7 @@ namespace gr {
}
delete d_fft;
volk_free(d_fbuf);
+ volk_free(d_tmpbuf);
delete d_argv;
}
@@ -438,12 +443,9 @@ namespace gr {
size, 1.0, size);
// Perform shift operation
- unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*(len + 1));
- memcpy(tmp, &data_out[0], sizeof(float)*(len + 1));
- memcpy(&data_out[0], &data_out[size - len], sizeof(float)*len);
- memcpy(&data_out[len], tmp, sizeof(float)*(len + 1));
- free(tmp);
+ memcpy(d_tmpbuf, &data_out[0], sizeof(float)*(d_tmpbuflen + 1));
+ memcpy(&data_out[0], &data_out[size - d_tmpbuflen],
sizeof(float)*d_tmpbuflen);
+ memcpy(&data_out[d_tmpbuflen], d_tmpbuf, sizeof(float)*(d_tmpbuflen +
1));
}
bool
@@ -510,6 +512,11 @@ namespace gr {
volk_get_alignment());
memset(d_fbuf, 0, d_fftsize*sizeof(float));
+ volk_free(d_tmpbuf);
+ d_tmpbuflen = (unsigned int)(floor(d_fftsize/2.0));
+ d_tmpbuf = (float*)volk_malloc(sizeof(float)*(d_tmpbuflen + 1),
+ volk_get_alignment());
+
d_last_time = 0;
set_output_multiple(d_fftsize);
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
index 2794942..1463699 100644
--- a/gr-qtgui/lib/freq_sink_f_impl.h
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -38,7 +38,7 @@ namespace gr {
void initialize();
int d_fftsize;
- int d_outputsize;
+ int d_tmpbuflen;
float d_fftavg;
filter::firdes::win_type d_wintype;
std::vector<float> d_window;
@@ -54,6 +54,7 @@ namespace gr {
std::vector<float*> d_residbufs;
std::vector<double*> d_magbufs;
float *d_fbuf;
+ float *d_tmpbuf;
int d_argc;
char *d_argv;
- [Commit-gnuradio] [gnuradio] branch master updated (d814381 -> 82779dc), git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 04/08: qtgui: fixed comment., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 05/08: qtgui: added triggering to freq sinks., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 07/08: qtgui: removing malloc/free in fft function; doing once in ctor and when fftsize changes, instead.,
git <=
- [Commit-gnuradio] [gnuradio] 06/08: qtgui: removes use of outputsize in freq sinks., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 03/08: qtgui: allow toggle to only show positive half of waterfall spectrum., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 02/08: qtgui: fixed problem with setting fft size and averaging of the float waterfall at runtime., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 01/08: qtgui: allow float freq plot to only plot positive half of spectrum., git, 2014/10/23
- [Commit-gnuradio] [gnuradio] 08/08: Merge branch 'maint', git, 2014/10/23