summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/.gitignore15
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt10
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am26
-rw-r--r--gnuradio-core/src/lib/general/general.i16
-rw-r--r--gnuradio-core/src/lib/general/general_generated.i10
-rw-r--r--gnuradio-core/src/lib/general/gr_add_ff.cc66
-rw-r--r--gnuradio-core/src/lib/general/gr_add_ff.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_add_ff.i32
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.cc38
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.h11
-rw-r--r--gnuradio-core/src/lib/general/gr_burst_tagger.i4
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.cc39
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.h14
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_float.i7
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_short.cc64
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_short.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_char_to_short.i30
-rw-r--r--gnuradio-core/src/lib/general/gr_complex_to_xxx.cc79
-rw-r--r--gnuradio-core/src/lib/general/gr_complex_to_xxx.h5
-rw-r--r--gnuradio-core/src/lib/general/gr_conjugate_cc.cc27
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.cc89
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.h20
-rw-r--r--gnuradio-core/src/lib/general/gr_delay.i2
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.cc22
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.h13
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc.i12
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc27
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h15
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.cc27
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.h17
-rw-r--r--gnuradio-core/src/lib/general/gr_fft_vfc.i12
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_char.cc39
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_char.h16
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_char.i9
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_int.cc55
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_int.h16
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_int.i9
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_short.cc39
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_short.h15
-rw-r--r--gnuradio-core/src/lib/general/gr_float_to_short.i9
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.cc27
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.h16
-rw-r--r--gnuradio-core/src/lib/general/gr_int_to_float.i8
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_cc.cc69
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_cc.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_cc.i32
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc69
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h57
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i32
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_cc.cc80
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_cc.h60
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_cc.i33
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.cc80
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.h60
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_const_ff.i33
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_ff.cc69
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_ff.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_multiply_ff.i32
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_char.cc67
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_char.h56
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_char.i31
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_float.cc38
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_float.h18
-rw-r--r--gnuradio-core/src/lib/general/gr_short_to_float.i9
-rw-r--r--gnuradio-core/src/lib/general/gri_fft.cc70
-rw-r--r--gnuradio-core/src/lib/general/gri_fft.h39
-rw-r--r--gnuradio-core/src/lib/general/gri_float_to_int.cc4
-rw-r--r--gnuradio-core/src/lib/general/gri_float_to_int.h2
68 files changed, 2038 insertions, 233 deletions
diff --git a/gnuradio-core/src/lib/general/.gitignore b/gnuradio-core/src/lib/general/.gitignore
index 4f3696f58..795dc793c 100644
--- a/gnuradio-core/src/lib/general/.gitignore
+++ b/gnuradio-core/src/lib/general/.gitignore
@@ -125,9 +125,6 @@
/gr_add_const_vss.cc
/gr_add_const_vss.h
/gr_add_const_vss.i
-/gr_add_ff.cc
-/gr_add_ff.h
-/gr_add_ff.i
/gr_add_ii.cc
/gr_add_ii.h
/gr_add_ii.i
@@ -158,24 +155,12 @@
/gr_divide_ss.cc
/gr_divide_ss.h
/gr_divide_ss.i
-/gr_multiply_cc.cc
-/gr_multiply_cc.h
-/gr_multiply_cc.i
-/gr_multiply_const_cc.cc
-/gr_multiply_const_cc.h
-/gr_multiply_const_cc.i
-/gr_multiply_const_ff.cc
-/gr_multiply_const_ff.h
-/gr_multiply_const_ff.i
/gr_multiply_const_ii.cc
/gr_multiply_const_ii.h
/gr_multiply_const_ii.i
/gr_multiply_const_ss.cc
/gr_multiply_const_ss.h
/gr_multiply_const_ss.i
-/gr_multiply_ff.cc
-/gr_multiply_ff.h
-/gr_multiply_ff.i
/gr_multiply_ii.cc
/gr_multiply_ii.h
/gr_multiply_ii.i
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 6ecaa930a..2bc639cd3 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Free Software Foundation, Inc.
+# Copyright 2010-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -178,6 +178,7 @@ endif(ENABLE_PYTHON)
########################################################################
set(gr_core_general_triple_threats
complex_vec_test
+ gr_add_ff
gr_additive_scrambler_bb
gr_agc_cc
gr_agc_ff
@@ -187,6 +188,7 @@ set(gr_core_general_triple_threats
gr_bin_statistics_f
gr_bytes_to_syms
gr_char_to_float
+ gr_char_to_short
gr_check_counting_s
gr_check_lfsr_32k_s
gr_complex_to_interleaved_short
@@ -229,6 +231,11 @@ set(gr_core_general_triple_threats
gr_kludge_copy
gr_lfsr_32k_source_s
gr_map_bb
+ gr_multiply_cc
+ gr_multiply_ff
+ gr_multiply_const_cc
+ gr_multiply_const_ff
+ gr_multiply_conjugate_cc
gr_nlog10_ff
gr_nop
gr_null_sink
@@ -256,6 +263,7 @@ set(gr_core_general_triple_threats
gr_rms_ff
gr_repeat
gr_short_to_float
+ gr_short_to_char
gr_simple_correlator
gr_simple_framer
gr_simple_squelch_cc
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 0122932cf..5b4a702e1 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2001,2002,2004,2006,2007,2008,2009 Free Software Foundation, Inc.
+# Copyright 2001,2002,2004,2006-2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -37,6 +37,7 @@ EXTRA_DIST += \
libgeneral_la_SOURCES = \
complex_vec_test.cc \
+ gr_add_ff.cc \
gr_additive_scrambler_bb.cc \
gr_agc_cc.cc \
gr_agc_ff.cc \
@@ -46,6 +47,7 @@ libgeneral_la_SOURCES = \
gr_bin_statistics_f.cc \
gr_bytes_to_syms.cc \
gr_char_to_float.cc \
+ gr_char_to_short.cc \
gr_check_counting_s.cc \
gr_check_lfsr_32k_s.cc \
gr_circular_file.cc \
@@ -93,6 +95,11 @@ libgeneral_la_SOURCES = \
gr_lfsr_32k_source_s.cc \
gr_map_bb.cc \
gr_misc.cc \
+ gr_multiply_cc.cc \
+ gr_multiply_ff.cc \
+ gr_multiply_const_cc.cc \
+ gr_multiply_const_ff.cc \
+ gr_multiply_conjugate_cc.cc \
gr_nlog10_ff.cc \
gr_nop.cc \
gr_null_sink.cc \
@@ -122,6 +129,7 @@ libgeneral_la_SOURCES = \
gr_reverse.cc \
gr_rms_cf.cc \
gr_rms_ff.cc \
+ gr_short_to_char.cc \
gr_short_to_float.cc \
gr_int_to_float.cc \
gr_simple_correlator.cc \
@@ -187,6 +195,7 @@ grinclude_HEADERS = \
gr_core_api.h \
complex_vec_test.h \
gr_additive_scrambler_bb.h \
+ gr_add_ff.h \
gr_agc_cc.h \
gr_agc_ff.h \
gr_agc2_cc.h \
@@ -195,6 +204,7 @@ grinclude_HEADERS = \
gr_bin_statistics_f.h \
gr_bytes_to_syms.h \
gr_char_to_float.h \
+ gr_char_to_short.h \
gr_check_counting_s.h \
gr_check_lfsr_32k_s.h \
gr_circular_file.h \
@@ -246,6 +256,11 @@ grinclude_HEADERS = \
gr_map_bb.h \
gr_math.h \
gr_misc.h \
+ gr_multiply_cc.h \
+ gr_multiply_ff.h \
+ gr_multiply_const_cc.h \
+ gr_multiply_const_ff.h \
+ gr_multiply_conjugate_cc.h \
gr_nco.h \
gr_nlog10_ff.h \
gr_nop.h \
@@ -276,6 +291,7 @@ grinclude_HEADERS = \
gr_reverse.h \
gr_rms_cf.h \
gr_rms_ff.h \
+ gr_short_to_char.h \
gr_short_to_float.h \
gr_int_to_float.h \
gr_simple_correlator.h \
@@ -353,6 +369,7 @@ swiginclude_HEADERS = \
complex_vec_test.i \
general.i \
gr_additive_scrambler_bb.i \
+ gr_add_ff.i \
gr_agc_cc.i \
gr_agc_ff.i \
gr_agc2_cc.i \
@@ -361,6 +378,7 @@ swiginclude_HEADERS = \
gr_bin_statistics_f.i \
gr_bytes_to_syms.i \
gr_char_to_float.i \
+ gr_char_to_short.i \
gr_check_counting_s.i \
gr_check_lfsr_32k_s.i \
gr_complex_to_interleaved_short.i \
@@ -403,6 +421,11 @@ swiginclude_HEADERS = \
gr_kludge_copy.i \
gr_lfsr_32k_source_s.i \
gr_map_bb.i \
+ gr_multiply_cc.i \
+ gr_multiply_ff.i \
+ gr_multiply_const_cc.i \
+ gr_multiply_const_ff.i \
+ gr_multiply_conjugate_cc.i \
gr_nlog10_ff.i \
gr_nop.i \
gr_null_sink.i \
@@ -430,6 +453,7 @@ swiginclude_HEADERS = \
gr_rms_cf.i \
gr_rms_ff.i \
gr_repeat.i \
+ gr_short_to_char.i \
gr_short_to_float.i \
gr_simple_correlator.i \
gr_simple_framer.i \
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 5a701bf80..89738b01a 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -44,8 +44,10 @@
#include <gr_float_to_char.h>
#include <gr_float_to_uchar.h>
#include <gr_short_to_float.h>
+#include <gr_short_to_char.h>
#include <gr_int_to_float.h>
#include <gr_char_to_float.h>
+#include <gr_char_to_short.h>
#include <gr_uchar_to_float.h>
#include <gr_frequency_modulator_fc.h>
#include <gr_phase_modulator_fc.h>
@@ -104,6 +106,11 @@
#include <gr_diff_decoder_bb.h>
#include <gr_framer_sink_1.h>
#include <gr_map_bb.h>
+#include <gr_multiply_cc.h>
+#include <gr_multiply_ff.h>
+#include <gr_multiply_const_cc.h>
+#include <gr_multiply_const_ff.h>
+#include <gr_multiply_conjugate_cc.h>
#include <gr_feval.h>
#include <gr_pwr_squelch_cc.h>
#include <gr_pwr_squelch_ff.h>
@@ -134,6 +141,7 @@
#include <gr_burst_tagger.h>
#include <gr_cpm.h>
#include <gr_correlate_access_code_tag_bb.h>
+#include <gr_add_ff.h>
%}
%include "gri_control_loop.i"
@@ -158,8 +166,10 @@
%include "gr_float_to_char.i"
%include "gr_float_to_uchar.i"
%include "gr_short_to_float.i"
+%include "gr_short_to_char.i"
%include "gr_int_to_float.i"
%include "gr_char_to_float.i"
+%include "gr_char_to_short.i"
%include "gr_uchar_to_float.i"
%include "gr_frequency_modulator_fc.i"
%include "gr_phase_modulator_fc.i"
@@ -218,6 +228,11 @@
%include "gr_diff_decoder_bb.i"
%include "gr_framer_sink_1.i"
%include "gr_map_bb.i"
+%include "gr_multiply_cc.i"
+%include "gr_multiply_ff.i"
+%include "gr_multiply_const_cc.i"
+%include "gr_multiply_const_ff.i"
+%include "gr_multiply_conjugate_cc.i"
%include "gr_feval.i"
%include "gr_pwr_squelch_cc.i"
%include "gr_pwr_squelch_ff.i"
@@ -248,3 +263,4 @@
%include "gr_burst_tagger.i"
%include "gr_cpm.i"
%include "gr_correlate_access_code_tag_bb.i"
+%include "gr_add_ff.i"
diff --git a/gnuradio-core/src/lib/general/general_generated.i b/gnuradio-core/src/lib/general/general_generated.i
index a41f30a3d..e12f2b0ec 100644
--- a/gnuradio-core/src/lib/general/general_generated.i
+++ b/gnuradio-core/src/lib/general/general_generated.i
@@ -12,7 +12,6 @@
#include <gr_add_const_vff.h>
#include <gr_add_const_vii.h>
#include <gr_add_const_vss.h>
-#include <gr_add_ff.h>
#include <gr_add_ii.h>
#include <gr_add_ss.h>
#include <gr_add_vcc.h>
@@ -29,16 +28,12 @@
#include <gr_divide_ff.h>
#include <gr_divide_ii.h>
#include <gr_divide_ss.h>
-#include <gr_multiply_cc.h>
-#include <gr_multiply_const_cc.h>
-#include <gr_multiply_const_ff.h>
#include <gr_multiply_const_ii.h>
#include <gr_multiply_const_ss.h>
#include <gr_multiply_const_vcc.h>
#include <gr_multiply_const_vff.h>
#include <gr_multiply_const_vii.h>
#include <gr_multiply_const_vss.h>
-#include <gr_multiply_ff.h>
#include <gr_multiply_ii.h>
#include <gr_multiply_ss.h>
#include <gr_multiply_vcc.h>
@@ -89,7 +84,6 @@
%include <gr_add_const_vff.i>
%include <gr_add_const_vii.i>
%include <gr_add_const_vss.i>
-%include <gr_add_ff.i>
%include <gr_add_ii.i>
%include <gr_add_ss.i>
%include <gr_add_vcc.i>
@@ -106,16 +100,12 @@
%include <gr_divide_ff.i>
%include <gr_divide_ii.i>
%include <gr_divide_ss.i>
-%include <gr_multiply_cc.i>
-%include <gr_multiply_const_cc.i>
-%include <gr_multiply_const_ff.i>
%include <gr_multiply_const_ii.i>
%include <gr_multiply_const_ss.i>
%include <gr_multiply_const_vcc.i>
%include <gr_multiply_const_vff.i>
%include <gr_multiply_const_vii.i>
%include <gr_multiply_const_vss.i>
-%include <gr_multiply_ff.i>
%include <gr_multiply_ii.i>
%include <gr_multiply_ss.i>
%include <gr_multiply_vcc.i>
diff --git a/gnuradio-core/src/lib/general/gr_add_ff.cc b/gnuradio-core/src/lib/general/gr_add_ff.cc
new file mode 100644
index 000000000..fc5455c98
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_add_ff.cc
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_add_ff.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_add_ff_sptr
+gr_make_add_ff(size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_add_ff(vlen));
+}
+
+gr_add_ff::gr_add_ff (size_t vlen)
+ : gr_sync_block("add_ff",
+ gr_make_io_signature (1, -1, sizeof(float)*vlen),
+ gr_make_io_signature (1, 1, sizeof(float)*vlen)),
+ d_vlen (vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_add_ff::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(float));
+ if(is_unaligned()) {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_add_32f_u(out, out, (const float*)input_items[i], noi);
+ }
+ else {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_add_32f_a(out, out, (const float*)input_items[i], noi);
+ }
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_add_ff.h b/gnuradio-core/src/lib/general/gr_add_ff.h
new file mode 100644
index 000000000..6421f8da2
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_add_ff.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_ADD_FF_H
+#define INCLUDED_GR_ADD_FF_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_add_ff;
+typedef boost::shared_ptr<gr_add_ff> gr_add_ff_sptr;
+
+GR_CORE_API gr_add_ff_sptr
+gr_make_add_ff (size_t vlen=1);
+
+/*!
+ * \brief Add streams of complex values
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_add_ff : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_add_ff_sptr
+ gr_make_add_ff (size_t vlen);
+ gr_add_ff (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_ADD_FF_H */
diff --git a/gnuradio-core/src/lib/general/gr_add_ff.i b/gnuradio-core/src/lib/general/gr_add_ff.i
new file mode 100644
index 000000000..3c30640b1
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_add_ff.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,add_ff)
+
+gr_add_ff_sptr
+gr_make_add_ff (size_t vlen=1);
+
+class gr_add_ff : public gr_sync_block
+{
+public:
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.cc b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
index 4b3847b08..bd713d663 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.cc
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.cc
@@ -43,10 +43,39 @@ gr_burst_tagger::gr_burst_tagger(size_t itemsize)
std::stringstream str;
str << name() << unique_id();
- d_key = pmt::pmt_string_to_symbol("burst");
+ d_true_key = pmt::pmt_string_to_symbol("burst");
+ d_true_value = pmt::PMT_T;
+
+ d_false_key = pmt::pmt_string_to_symbol("burst");
+ d_false_value = pmt::PMT_F;
+
d_id = pmt::pmt_string_to_symbol(str.str());
}
+void
+gr_burst_tagger::set_true_tag (const std::string &key, bool value)
+{
+ d_true_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_true_value = pmt::PMT_T;
+ }
+ else {
+ d_true_value = pmt::PMT_F;
+ }
+}
+
+void
+gr_burst_tagger::set_false_tag (const std::string &key, bool value)
+{
+ d_false_key = pmt::pmt_string_to_symbol(key);
+ if(value == true) {
+ d_false_value = pmt::PMT_T;
+ }
+ else {
+ d_false_value = pmt::PMT_F;
+ }
+}
+
gr_burst_tagger::~gr_burst_tagger()
{
}
@@ -66,18 +95,15 @@ gr_burst_tagger::work(int noutput_items,
if(trigger[i] > 0) {
if(d_state == false) {
d_state = true;
- pmt::pmt_t value = pmt::PMT_T;
- add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id);
}
}
else {
if(d_state == true) {
d_state = false;
- pmt::pmt_t value = pmt::PMT_F;
- add_item_tag(0, nitems_written(0)+i, d_key, value, d_id);
+ add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id);
}
}
}
-
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h
index 7547ba9cc..663a146f2 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.h
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h
@@ -40,14 +40,21 @@ class GR_CORE_API gr_burst_tagger : public gr_sync_block
{
size_t d_itemsize;
bool d_state;
- pmt::pmt_t d_key;
+ pmt::pmt_t d_true_key;
+ pmt::pmt_t d_true_value;
+
+ pmt::pmt_t d_false_key;
+ pmt::pmt_t d_false_value;
+
pmt::pmt_t d_id;
-
+
friend GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize);
gr_burst_tagger(size_t itemsize);
public:
~gr_burst_tagger();
+ void set_true_tag (const std::string &key, bool value);
+ void set_false_tag (const std::string &key, bool value);
int work(int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.i b/gnuradio-core/src/lib/general/gr_burst_tagger.i
index ebf1eea8c..868941fc6 100644
--- a/gnuradio-core/src/lib/general/gr_burst_tagger.i
+++ b/gnuradio-core/src/lib/general/gr_burst_tagger.i
@@ -28,4 +28,8 @@ class gr_burst_tagger : public gr_sync_block
{
private:
gr_burst_tagger(size_t itemsize);
+
+ public:
+ void set_true_tag(const std::string &key, bool value);
+ void set_false_tag(const std::string &key, bool value);
};
diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc
index e68f8d208..ffe8ee4a1 100644
--- a/gnuradio-core/src/lib/general/gr_char_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_char_to_float.cc
@@ -26,30 +26,47 @@
#include <gr_char_to_float.h>
#include <gr_io_signature.h>
-#include <gri_char_to_float.h>
+#include <volk/volk.h>
gr_char_to_float_sptr
-gr_make_char_to_float ()
+gr_make_char_to_float (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_char_to_float ());
+ return gnuradio::get_initial_sptr(new gr_char_to_float (vlen, scale));
}
-gr_char_to_float::gr_char_to_float ()
+gr_char_to_float::gr_char_to_float (size_t vlen, float scale)
: gr_sync_block ("gr_char_to_float",
- gr_make_io_signature (1, 1, sizeof (char)),
- gr_make_io_signature (1, 1, sizeof (float)))
+ gr_make_io_signature (1, 1, sizeof (char)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_char_to_float::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_char_to_float::set_scale(float scale)
+{
+ d_scale = scale;
}
int
gr_char_to_float::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- const char *in = (const char *) input_items[0];
+ const int8_t *in = (const int8_t *) input_items[0];
float *out = (float *) output_items[0];
- gri_char_to_float (in, out, noutput_items);
-
+ // Note: the unaligned benchmarked much faster than the aligned
+ volk_8i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items);
+
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h
index b20d2066f..4ad8e59a8 100644
--- a/gnuradio-core/src/lib/general/gr_char_to_float.h
+++ b/gnuradio-core/src/lib/general/gr_char_to_float.h
@@ -30,7 +30,7 @@ class gr_char_to_float;
typedef boost::shared_ptr<gr_char_to_float> gr_char_to_float_sptr;
GR_CORE_API gr_char_to_float_sptr
-gr_make_char_to_float ();
+gr_make_char_to_float (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of chars to a stream of float
@@ -39,10 +39,18 @@ gr_make_char_to_float ();
class GR_CORE_API gr_char_to_float : public gr_sync_block
{
- friend GR_CORE_API gr_char_to_float_sptr gr_make_char_to_float ();
- gr_char_to_float ();
+ private:
+ friend GR_CORE_API gr_char_to_float_sptr
+ gr_make_char_to_float (size_t vlen, float scale);
+ gr_char_to_float (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.i b/gnuradio-core/src/lib/general/gr_char_to_float.i
index 0403b621d..65ad861f2 100644
--- a/gnuradio-core/src/lib/general/gr_char_to_float.i
+++ b/gnuradio-core/src/lib/general/gr_char_to_float.i
@@ -22,9 +22,12 @@
GR_SWIG_BLOCK_MAGIC(gr,char_to_float)
-gr_char_to_float_sptr gr_make_char_to_float ();
+gr_char_to_float_sptr
+gr_make_char_to_float (size_t vlen=1, float scale=1);
class gr_char_to_float : public gr_sync_block
{
- gr_char_to_float ();
+public:
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.cc b/gnuradio-core/src/lib/general/gr_char_to_short.cc
new file mode 100644
index 000000000..8b6cd0be1
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_char_to_short.cc
@@ -0,0 +1,64 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_char_to_short.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_char_to_short_sptr
+gr_make_char_to_short (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_char_to_short (vlen));
+}
+
+gr_char_to_short::gr_char_to_short (size_t vlen)
+ : gr_sync_block ("gr_char_to_short",
+ gr_make_io_signature (1, 1, sizeof (char)*vlen),
+ gr_make_io_signature (1, 1, sizeof (short)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(char);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_char_to_short::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const int8_t *in = (const int8_t *) input_items[0];
+ int16_t *out = (int16_t *) output_items[0];
+
+ if(is_unaligned()) {
+ volk_8i_convert_16i_u(out, in, d_vlen*noutput_items);
+ }
+ else {
+ volk_8i_convert_16i_a(out, in, d_vlen*noutput_items);
+ }
+
+ return noutput_items;
+}
diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h
new file mode 100644
index 000000000..58f9a62b0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_char_to_short.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_CHAR_TO_SHORT_H
+#define INCLUDED_GR_CHAR_TO_SHORT_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_char_to_short;
+typedef boost::shared_ptr<gr_char_to_short> gr_char_to_short_sptr;
+
+GR_CORE_API gr_char_to_short_sptr
+gr_make_char_to_short (size_t vlen=1);
+
+/*!
+ * \brief Convert stream of chars to a stream of float
+ * \ingroup converter_blk
+ */
+
+class GR_CORE_API gr_char_to_short : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_char_to_short_sptr
+ gr_make_char_to_short (size_t vlen);
+ gr_char_to_short (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_CHAR_TO_SHORT_H */
diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.i b/gnuradio-core/src/lib/general/gr_char_to_short.i
new file mode 100644
index 000000000..48ddbf26b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_char_to_short.i
@@ -0,0 +1,30 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,char_to_short)
+
+gr_char_to_short_sptr gr_make_char_to_short (size_t vlen=1);
+
+class gr_char_to_short : public gr_sync_block
+{
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
index a59c127f3..108a92835 100644
--- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
+++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,6 +27,7 @@
#include <gr_complex_to_xxx.h>
#include <gr_io_signature.h>
#include <gr_math.h>
+#include <volk/volk.h>
// ----------------------------------------------------------------
@@ -42,6 +43,9 @@ gr_complex_to_float::gr_complex_to_float (unsigned int vlen)
gr_make_io_signature (1, 2, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -56,16 +60,26 @@ gr_complex_to_float::work (int noutput_items,
switch (output_items.size ()){
case 1:
- for (int i = 0; i < noi; i++){
- out0[i] = in[i].real ();
+ if(is_unaligned()) {
+ for (int i = 0; i < noi; i++){
+ out0[i] = in[i].real ();
+ }
+ }
+ else {
+ volk_32fc_deinterleave_real_32f_a(out0, in, noi);
}
break;
case 2:
out1 = (float *) output_items[1];
- for (int i = 0; i < noi; i++){
- out0[i] = in[i].real ();
- out1[i] = in[i].imag ();
+ if(is_unaligned()) {
+ for (int i = 0; i < noi; i++){
+ out0[i] = in[i].real ();
+ out1[i] = in[i].imag ();
+ }
+ }
+ else {
+ volk_32fc_deinterleave_32f_x2_a(out0, out1, in, noi);
}
break;
@@ -90,6 +104,9 @@ gr_complex_to_real::gr_complex_to_real (unsigned int vlen)
gr_make_io_signature (1, 1, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -101,9 +118,15 @@ gr_complex_to_real::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++){
- out[i] = in[i].real ();
+ if(is_unaligned()) {
+ for (int i = 0; i < noi; i++){
+ out[i] = in[i].real ();
+ }
+ }
+ else {
+ volk_32fc_deinterleave_real_32f_a(out, in, noi);
}
+
return noutput_items;
}
@@ -121,6 +144,9 @@ gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen)
gr_make_io_signature (1, 1, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -132,9 +158,15 @@ gr_complex_to_imag::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++){
- out[i] = in[i].imag ();
+ if(is_unaligned()) {
+ for (int i = 0; i < noi; i++){
+ out[i] = in[i].imag ();
+ }
+ }
+ else {
+ volk_32fc_deinterleave_imag_32f_a(out, in, noi);
}
+
return noutput_items;
}
@@ -152,6 +184,9 @@ gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen)
gr_make_io_signature (1, 1, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -163,9 +198,9 @@ gr_complex_to_mag::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++){
- out[i] = std::abs (in[i]);
- }
+ // turned out to be faster than aligned/unaligned switching
+ volk_32fc_magnitude_32f_u(out, in, noi);
+
return noutput_items;
}
@@ -183,6 +218,9 @@ gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen)
gr_make_io_signature (1, 1, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -194,11 +232,13 @@ gr_complex_to_mag_squared::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
- for (int i = 0; i < noi; i++){
- const float __x = in[i].real();
- const float __y = in[i].imag();
- out[i] = __x * __x + __y * __y;
+ if(is_unaligned()) {
+ volk_32fc_magnitude_squared_32f_u(out, in, noi);
+ }
+ else {
+ volk_32fc_magnitude_squared_32f_a(out, in, noi);
}
+
return noutput_items;
}
@@ -216,6 +256,9 @@ gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen)
gr_make_io_signature (1, 1, sizeof (float) * vlen)),
d_vlen(vlen)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -227,9 +270,11 @@ gr_complex_to_arg::work (int noutput_items,
float *out = (float *) output_items[0];
int noi = noutput_items * d_vlen;
+ // The fast_atan2f is faster than Volk
for (int i = 0; i < noi; i++){
// out[i] = std::arg (in[i]);
out[i] = gr_fast_atan2f(in[i]);
}
+
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h
index 166403259..232071323 100644
--- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h
+++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h
@@ -109,10 +109,11 @@ class GR_CORE_API gr_complex_to_imag : public gr_sync_block
*/
class GR_CORE_API gr_complex_to_mag : public gr_sync_block
{
- friend GR_CORE_API gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen);
+ friend GR_CORE_API gr_complex_to_mag_sptr
+ gr_make_complex_to_mag (unsigned int vlen);
gr_complex_to_mag (unsigned int vlen);
- unsigned int d_vlen;
+ unsigned int d_vlen;
public:
virtual int work (int noutput_items,
diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
index 59c3bae89..d2b20ffe6 100644
--- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
+++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc
@@ -28,6 +28,7 @@
#include <gr_conjugate_cc.h>
#include <gr_io_signature.h>
+#include <volk/volk.h>
gr_conjugate_cc_sptr
gr_make_conjugate_cc ()
@@ -40,6 +41,9 @@ gr_conjugate_cc::gr_conjugate_cc ()
gr_make_io_signature (1, 1, sizeof (gr_complex)),
gr_make_io_signature (1, 1, sizeof (gr_complex)))
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(alignment_multiple);
}
int
@@ -50,26 +54,11 @@ gr_conjugate_cc::work (int noutput_items,
gr_complex *iptr = (gr_complex *) input_items[0];
gr_complex *optr = (gr_complex *) output_items[0];
- int size = noutput_items;
-
- while (size >= 8){
- optr[0] = conj(iptr[0]);
- optr[1] = conj(iptr[1]);
- optr[2] = conj(iptr[2]);
- optr[3] = conj(iptr[3]);
- optr[4] = conj(iptr[4]);
- optr[5] = conj(iptr[5]);
- optr[6] = conj(iptr[6]);
- optr[7] = conj(iptr[7]);
- size -= 8;
- optr += 8;
- iptr += 8;
+ if(is_unaligned()) {
+ volk_32fc_conjugate_32fc_u(optr, iptr, noutput_items);
}
-
- while (size-- > 0) {
- *optr = conj(*iptr);
- iptr++;
- optr++;
+ else {
+ volk_32fc_conjugate_32fc_a(optr, iptr, noutput_items);
}
return noutput_items;
diff --git a/gnuradio-core/src/lib/general/gr_delay.cc b/gnuradio-core/src/lib/general/gr_delay.cc
index b06346f59..aedd461f8 100644
--- a/gnuradio-core/src/lib/general/gr_delay.cc
+++ b/gnuradio-core/src/lib/general/gr_delay.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007,2010 Free Software Foundation, Inc.
+ * Copyright 2007,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -35,30 +35,95 @@ gr_make_delay (size_t itemsize, int delay)
}
gr_delay::gr_delay (size_t itemsize, int delay)
- : gr_sync_block ("delay",
- gr_make_io_signature (1, -1, itemsize),
- gr_make_io_signature (1, -1, itemsize)),
+ : gr_block ("delay",
+ gr_make_io_signature (1, -1, itemsize),
+ gr_make_io_signature (1, -1, itemsize)),
d_itemsize(itemsize)
{
set_delay(delay);
+ d_delta = 0;
+}
+
+void
+gr_delay::forecast (int noutput_items, gr_vector_int &ninput_items_required)
+{
+ // make sure all inputs have noutput_items available
+ unsigned ninputs = ninput_items_required.size ();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = noutput_items;
+}
+
+void
+gr_delay::set_delay (int d)
+{
+ // only set a new delta if there is a change in the delay; this
+ // protects from quickly-repeated calls to this function that would
+ // end with d_delta=0.
+ if(d != delay()) {
+ gruel::scoped_lock l(d_mutex_delay);
+ int old = delay();
+ set_history(d+1);
+ d_delta += delay() - old;
+ }
}
int
-gr_delay::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+gr_delay::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
+ gruel::scoped_lock l(d_mutex_delay);
assert(input_items.size() == output_items.size());
const char *iptr;
char *optr;
+ int cons, ret;
- for(size_t i = 0; i < input_items.size(); i++) {
- iptr = (const char *) input_items[i];
- optr = (char *) output_items[i];
+ // No change in delay; just memcpy ins to outs
+ if(d_delta == 0) {
+ for(size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char *) input_items[i];
+ optr = (char *) output_items[i];
+ std::memcpy(optr, iptr, noutput_items*d_itemsize);
+ }
+ cons = noutput_items;
+ ret = noutput_items;
+ }
- memcpy(optr, iptr, noutput_items*d_itemsize);
+ // Skip over d_delta items on the input
+ else if(d_delta < 0) {
+ int n_to_copy, n_adj;
+ int delta = -d_delta;
+ n_to_copy = std::max(0, noutput_items-delta);
+ n_adj = std::min(delta, noutput_items);
+ for(size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char *) input_items[i];
+ optr = (char *) output_items[i];
+ std::memcpy(optr, iptr+delta*d_itemsize, n_to_copy*d_itemsize);
+ }
+ cons = noutput_items;
+ ret = n_to_copy;
+ delta -= n_adj;
+ d_delta = -delta;
}
- return noutput_items;
+ //produce but not consume (inserts zeros)
+ else { // d_delta > 0
+ int n_from_input, n_padding;
+ n_from_input = std::max(0, noutput_items-d_delta);
+ n_padding = std::min(d_delta, noutput_items);
+ for(size_t i = 0; i < input_items.size(); i++) {
+ iptr = (const char *) input_items[i];
+ optr = (char *) output_items[i];
+ std::memset(optr, 0, n_padding*d_itemsize);
+ std::memcpy(optr, iptr, n_from_input*d_itemsize);
+ }
+ cons = n_from_input;
+ ret = noutput_items;
+ d_delta -= n_padding;
+ }
+
+ consume_each(cons);
+ return ret;
}
diff --git a/gnuradio-core/src/lib/general/gr_delay.h b/gnuradio-core/src/lib/general/gr_delay.h
index 14de9af1f..55f525c38 100644
--- a/gnuradio-core/src/lib/general/gr_delay.h
+++ b/gnuradio-core/src/lib/general/gr_delay.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,7 +24,8 @@
#define INCLUDED_GR_DELAY_H
#include <gr_core_api.h>
-#include <gr_sync_block.h>
+#include <gr_block.h>
+#include <gruel/thread.h>
class gr_delay;
typedef boost::shared_ptr<gr_delay> gr_delay_sptr;
@@ -35,21 +36,26 @@ GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay);
* \brief delay the input by a certain number of samples
* \ingroup misc_blk
*/
-class GR_CORE_API gr_delay : public gr_sync_block
+class GR_CORE_API gr_delay : public gr_block
{
friend GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay);
gr_delay (size_t itemsize, int delay);
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
size_t d_itemsize;
+ int d_delta;
+ gruel::mutex d_mutex_delay;
public:
int delay () const { return history()-1; }
- void set_delay (int delay) { set_history(delay+1); }
+ void set_delay (int delay);
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
#endif
diff --git a/gnuradio-core/src/lib/general/gr_delay.i b/gnuradio-core/src/lib/general/gr_delay.i
index a527d008f..2e62a222f 100644
--- a/gnuradio-core/src/lib/general/gr_delay.i
+++ b/gnuradio-core/src/lib/general/gr_delay.i
@@ -24,7 +24,7 @@ GR_SWIG_BLOCK_MAGIC(gr,delay)
gr_delay_sptr gr_make_delay (size_t itemsize, int delay);
-class gr_delay : public gr_sync_block
+class gr_delay : public gr_block
{
private:
gr_delay (size_t itemsize, int delay);
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.cc b/gnuradio-core/src/lib/general/gr_fft_vcc.cc
index d07f6fa07..f744acb93 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.cc
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2007,2008,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -32,9 +32,12 @@
#include <string.h>
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> &window, bool shift)
+gr_make_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift, int nthreads)
{
- return gr_make_fft_vcc_fftw(fft_size, forward, window, shift);
+ return gr_make_fft_vcc_fftw(fft_size, forward,
+ window, shift, nthreads);
}
gr_fft_vcc::gr_fft_vcc (const std::string &name,
@@ -62,3 +65,16 @@ gr_fft_vcc::set_window(const std::vector<float> &window)
else
return false;
}
+
+void
+gr_fft_vcc::set_nthreads(int n)
+{
+ throw std::runtime_error("gr_fft_vcc::set_nthreads not implemented.");
+}
+
+int
+gr_fft_vcc::nthreads() const
+{
+ throw std::runtime_error("gr_fft_vcc::nthreads not implemented.");
+ return 0;
+}
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h
index a7c8e1162..ceabeb681 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.h
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2007,2008 Free Software Foundation, Inc.
+ * Copyright 2004,2007,2008,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,9 @@ class gr_fft_vcc;
typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr;
GR_CORE_API gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false);
+gr_make_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift=false, int nthreads=1);
/*!
* \brief Compute forward or reverse FFT. complex vector in / complex vector out.
@@ -42,7 +44,9 @@ class GR_CORE_API gr_fft_vcc : public gr_sync_block
{
protected:
friend GR_CORE_API gr_fft_vcc_sptr
- gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift);
+ gr_make_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift);
unsigned int d_fft_size;
std::vector<float> d_window;
@@ -55,6 +59,9 @@ protected:
public:
~gr_fft_vcc ();
+ virtual void set_nthreads(int n);
+ virtual int nthreads() const;
+
bool set_window(const std::vector<float> &window);
};
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.i b/gnuradio-core/src/lib/general/gr_fft_vcc.i
index f35316e70..26d8b89a3 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc.i
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2007,2008,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,13 +23,19 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vcc)
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift=false);
+gr_make_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift=false, int nthreads=1);
class gr_fft_vcc : public gr_sync_block
{
protected:
- gr_fft_vcc (int fft_size, bool forward, const std::vector<float> &window, bool shift);
+ gr_fft_vcc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift);
public:
bool set_window(const std::vector<float> &window);
+ void set_nthreads(int n);
+ int nthreads() const;
};
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc
index 8a6b2fe8a..a99beb965 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc
@@ -31,16 +31,21 @@
#include <string.h>
gr_fft_vcc_sptr
-gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift)
+gr_make_fft_vcc_fftw (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift, int nthreads)
{
- return gnuradio::get_initial_sptr(new gr_fft_vcc_fftw (fft_size, forward, window, shift));
+ return gnuradio::get_initial_sptr(new gr_fft_vcc_fftw
+ (fft_size, forward, window,
+ shift, nthreads));
}
gr_fft_vcc_fftw::gr_fft_vcc_fftw (int fft_size, bool forward,
- const std::vector<float> &window, bool shift)
+ const std::vector<float> &window,
+ bool shift, int nthreads)
: gr_fft_vcc("fft_vcc_fftw", fft_size, forward, window, shift)
{
- d_fft = new gri_fft_complex (d_fft_size, forward);
+ d_fft = new gri_fft_complex (d_fft_size, forward, nthreads);
}
gr_fft_vcc_fftw::~gr_fft_vcc_fftw ()
@@ -48,6 +53,18 @@ gr_fft_vcc_fftw::~gr_fft_vcc_fftw ()
delete d_fft;
}
+void
+gr_fft_vcc_fftw::set_nthreads(int n)
+{
+ d_fft->set_nthreads(n);
+}
+
+int
+gr_fft_vcc_fftw::nthreads() const
+{
+ return d_fft->nthreads();
+}
+
int
gr_fft_vcc_fftw::work (int noutput_items,
gr_vector_const_void_star &input_items,
@@ -70,7 +87,7 @@ gr_fft_vcc_fftw::work (int noutput_items,
if(!d_forward && d_shift){
unsigned int offset = (!d_forward && d_shift)?(d_fft_size/2):0;
int fft_m_offset = d_fft_size - offset;
- for (unsigned int i = 0; i < offset; i++) // apply window
+ for (int i = 0; i < offset; i++) // apply window
dst[i+fft_m_offset] = in[i] * d_window[i];
for (unsigned int i = offset; i < d_fft_size; i++) // apply window
dst[i-offset] = in[i] * d_window[i];
diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h
index 8535d133c..82b7512d7 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h
+++ b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h
@@ -29,7 +29,9 @@
class gri_fft_complex;
GR_CORE_API gr_fft_vcc_sptr
-gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift=false);
+gr_make_fft_vcc_fftw (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift=false, int nthreads=1);
/*!
* \brief Compute forward or reverse FFT. complex vector in / complex vector out.
@@ -40,15 +42,22 @@ gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &wind
class GR_CORE_API gr_fft_vcc_fftw : public gr_fft_vcc
{
friend GR_CORE_API gr_fft_vcc_sptr
- gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift);
+ gr_make_fft_vcc_fftw (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift, int nthreads);
gri_fft_complex *d_fft;
- gr_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift);
+ gr_fft_vcc_fftw (int fft_size, bool forward,
+ const std::vector<float> &window,
+ bool shift, int nthreads=1);
public:
~gr_fft_vcc_fftw ();
+ void set_nthreads(int n);
+ int nthreads() const;
+
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc
index 561c63740..5fbe732dc 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,12 +40,17 @@
gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
+gr_make_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads)
{
- return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, window));
+ return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward,
+ window, nthreads));
}
-gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
+gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads)
: gr_sync_block ("fft_vfc",
gr_make_io_signature (1, 1, fft_size * sizeof (float)),
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))),
@@ -56,7 +61,7 @@ gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &wi
throw std::invalid_argument ("fft_vfc: forward must == true");
}
- d_fft = new gri_fft_complex (d_fft_size, forward);
+ d_fft = new gri_fft_complex (d_fft_size, forward, nthreads);
set_window(window);
}
@@ -66,6 +71,18 @@ gr_fft_vfc::~gr_fft_vfc ()
delete d_fft;
}
+void
+gr_fft_vfc::set_nthreads(int n)
+{
+ d_fft->set_nthreads(n);
+}
+
+int
+gr_fft_vfc::nthreads() const
+{
+ return d_fft->nthreads();
+}
+
int
gr_fft_vfc::work (int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h
index 6cf6b9037..84ae08f08 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.h
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -32,7 +32,9 @@ class gr_fft_vfc;
typedef boost::shared_ptr<gr_fft_vfc> gr_fft_vfc_sptr;
GR_CORE_API gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
+gr_make_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads=1);
/*!
* \brief Compute forward FFT. float vector in / complex vector out.
@@ -42,17 +44,24 @@ gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
class GR_CORE_API gr_fft_vfc : public gr_sync_block
{
friend GR_CORE_API gr_fft_vfc_sptr
- gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
+ gr_make_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads);
unsigned int d_fft_size;
std::vector<float> d_window;
gri_fft_complex *d_fft;
- gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
+ gr_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads=1);
public:
~gr_fft_vfc ();
+ void set_nthreads(int n);
+ int nthreads() const;
+
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.i b/gnuradio-core/src/lib/general/gr_fft_vfc.i
index 149745b58..4783ae1fe 100644
--- a/gnuradio-core/src/lib/general/gr_fft_vfc.i
+++ b/gnuradio-core/src/lib/general/gr_fft_vfc.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,14 +23,20 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vfc)
gr_fft_vfc_sptr
-gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> &window)
+gr_make_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads=1)
throw(std::exception);
class gr_fft_vfc : public gr_sync_block
{
protected:
- gr_fft_vfc (int fft_size, bool forward, const std::vector<float> &window);
+ gr_fft_vfc (int fft_size, bool forward,
+ const std::vector<float> &window,
+ int nthreads=1);
public:
bool set_window(const std::vector<float> &window);
+ void set_nthreads(int n);
+ int nthreads() const;
};
diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc
index 88b9d276e..14635ff71 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_char.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,19 +26,35 @@
#include <gr_float_to_char.h>
#include <gr_io_signature.h>
-#include <gri_float_to_char.h>
+#include <volk/volk.h>
gr_float_to_char_sptr
-gr_make_float_to_char ()
+gr_make_float_to_char (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_float_to_char ());
+ return gnuradio::get_initial_sptr(new gr_float_to_char (vlen, scale));
}
-gr_float_to_char::gr_float_to_char ()
+gr_float_to_char::gr_float_to_char (size_t vlen, float scale)
: gr_sync_block ("gr_float_to_char",
- gr_make_io_signature (1, 1, sizeof (float)),
- gr_make_io_signature (1, 1, sizeof (char)))
+ gr_make_io_signature (1, 1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (char)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(char);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_float_to_char::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_float_to_char::set_scale(float scale)
+{
+ d_scale = scale;
}
int
@@ -47,9 +63,14 @@ gr_float_to_char::work (int noutput_items,
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
- char *out = (char *) output_items[0];
+ int8_t *out = (int8_t *) output_items[0];
- gri_float_to_char (in, out, noutput_items);
+ if(is_unaligned()) {
+ volk_32f_s32f_convert_8i_u(out, in, d_scale, d_vlen*noutput_items);
+ }
+ else {
+ volk_32f_s32f_convert_8i_a(out, in, d_scale, d_vlen*noutput_items);
+ }
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h
index 434e2e9d0..c88645a18 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_char.h
+++ b/gnuradio-core/src/lib/general/gr_float_to_char.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,7 @@ class gr_float_to_char;
typedef boost::shared_ptr<gr_float_to_char> gr_float_to_char_sptr;
GR_CORE_API gr_float_to_char_sptr
-gr_make_float_to_char ();
+gr_make_float_to_char (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of float to a stream of char
@@ -39,10 +39,18 @@ gr_make_float_to_char ();
class GR_CORE_API gr_float_to_char : public gr_sync_block
{
- friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char ();
- gr_float_to_char ();
+ private:
+ friend GR_CORE_API gr_float_to_char_sptr gr_make_float_to_char
+ (size_t vlen, float scale);
+ gr_float_to_char (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.i b/gnuradio-core/src/lib/general/gr_float_to_char.i
index 05b206554..a1c88750f 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_char.i
+++ b/gnuradio-core/src/lib/general/gr_float_to_char.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,9 +22,12 @@
GR_SWIG_BLOCK_MAGIC(gr,float_to_char)
-gr_float_to_char_sptr gr_make_float_to_char ();
+gr_float_to_char_sptr
+gr_make_float_to_char (size_t vlen=1, float scale=1);
class gr_float_to_char : public gr_sync_block
{
- gr_float_to_char ();
+public:
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.cc b/gnuradio-core/src/lib/general/gr_float_to_int.cc
index 2349de8cb..b69591043 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_int.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_int.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,32 +27,63 @@
#include <gr_float_to_int.h>
#include <gr_io_signature.h>
#include <gri_float_to_int.h>
+#include <volk/volk.h>
gr_float_to_int_sptr
-gr_make_float_to_int ()
+gr_make_float_to_int (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_float_to_int ());
+ return gnuradio::get_initial_sptr(new gr_float_to_int (vlen, scale));
}
-gr_float_to_int::gr_float_to_int ()
+gr_float_to_int::gr_float_to_int (size_t vlen, float scale)
: gr_sync_block ("gr_float_to_int",
- gr_make_io_signature (1, 1, sizeof (float)),
- gr_make_io_signature (1, 1, sizeof (int)))
+ gr_make_io_signature (1, 1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (int)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(int);
+ set_alignment(alignment_multiple);
}
+float
+gr_float_to_int::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_float_to_int::set_scale(float scale)
+{
+ d_scale = scale;
+}
int
gr_float_to_int::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
+ // Disable the Volk for now. There is a problem for large 32-bit ints that
+ // are not properly represented by the precisions of a single float, which
+ // can cause wrapping from large, positive numbers to negative.
+ // In gri_float_to_int, the value is first promoted to a 64-bit
+ // value, clipped, then converted to a float.
+#if 0
+ const float *in = (const float *) input_items[0];
+ int32_t *out = (int32_t *) output_items[0];
+
+ if(is_unaligned()) {
+ volk_32f_s32f_convert_32i_u(out, in, d_scale, d_vlen*noutput_items);
+ }
+ else {
+ volk_32f_s32f_convert_32i_a(out, in, d_scale, d_vlen*noutput_items);
+ }
+#else
const float *in = (const float *) input_items[0];
int *out = (int *) output_items[0];
- gri_float_to_int (in, out, noutput_items);
+ gri_float_to_int (in, out, d_scale, d_vlen*noutput_items);
+
+#endif
return noutput_items;
}
-
-
-
diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h
index 3324ed110..0b42c0aab 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_int.h
+++ b/gnuradio-core/src/lib/general/gr_float_to_int.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,7 @@ class gr_float_to_int;
typedef boost::shared_ptr<gr_float_to_int> gr_float_to_int_sptr;
GR_CORE_API gr_float_to_int_sptr
-gr_make_float_to_int ();
+gr_make_float_to_int (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of float to a stream of short
@@ -39,10 +39,18 @@ gr_make_float_to_int ();
class GR_CORE_API gr_float_to_int : public gr_sync_block
{
- friend GR_CORE_API gr_float_to_int_sptr gr_make_float_to_int ();
- gr_float_to_int ();
+ private:
+ friend GR_CORE_API
+ gr_float_to_int_sptr gr_make_float_to_int (size_t vlen, float scale);
+ gr_float_to_int (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.i b/gnuradio-core/src/lib/general/gr_float_to_int.i
index 4ab04cbf2..6e71f54a9 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_int.i
+++ b/gnuradio-core/src/lib/general/gr_float_to_int.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,9 +22,12 @@
GR_SWIG_BLOCK_MAGIC(gr,float_to_int)
-gr_float_to_int_sptr gr_make_float_to_int ();
+gr_float_to_int_sptr
+gr_make_float_to_int (size_t vlen=1, float scale=1);
class gr_float_to_int : public gr_sync_block
{
- gr_float_to_int ();
+public:
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc
index 084f76f9c..188bfdae3 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_short.cc
+++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,19 +26,35 @@
#include <gr_float_to_short.h>
#include <gr_io_signature.h>
-#include <gri_float_to_short.h>
+#include <volk/volk.h>
gr_float_to_short_sptr
-gr_make_float_to_short ()
+gr_make_float_to_short (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_float_to_short ());
+ return gnuradio::get_initial_sptr(new gr_float_to_short (vlen, scale));
}
-gr_float_to_short::gr_float_to_short ()
+gr_float_to_short::gr_float_to_short (size_t vlen, float scale)
: gr_sync_block ("gr_float_to_short",
- gr_make_io_signature (1, 1, sizeof (float)),
- gr_make_io_signature (1, 1, sizeof (short)))
+ gr_make_io_signature (1, 1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (short)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(short);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_float_to_short::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_float_to_short::set_scale(float scale)
+{
+ d_scale = scale;
}
int
@@ -49,8 +65,13 @@ gr_float_to_short::work (int noutput_items,
const float *in = (const float *) input_items[0];
short *out = (short *) output_items[0];
- gri_float_to_short (in, out, noutput_items);
-
+ if(is_unaligned()) {
+ volk_32f_s32f_convert_16i_u(out, in, d_scale, d_vlen*noutput_items);
+ }
+ else {
+ volk_32f_s32f_convert_16i_a(out, in, d_scale, d_vlen*noutput_items);
+ }
+
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h
index 010d61141..93e441f41 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_short.h
+++ b/gnuradio-core/src/lib/general/gr_float_to_short.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,7 @@ class gr_float_to_short;
typedef boost::shared_ptr<gr_float_to_short> gr_float_to_short_sptr;
GR_CORE_API gr_float_to_short_sptr
-gr_make_float_to_short ();
+gr_make_float_to_short (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of float to a stream of short
@@ -39,10 +39,17 @@ gr_make_float_to_short ();
class GR_CORE_API gr_float_to_short : public gr_sync_block
{
- friend GR_CORE_API gr_float_to_short_sptr gr_make_float_to_short ();
- gr_float_to_short ();
+ friend GR_CORE_API
+ gr_float_to_short_sptr gr_make_float_to_short (size_t vlen, float scale);
+ gr_float_to_short (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.i b/gnuradio-core/src/lib/general/gr_float_to_short.i
index ad059c453..072da5213 100644
--- a/gnuradio-core/src/lib/general/gr_float_to_short.i
+++ b/gnuradio-core/src/lib/general/gr_float_to_short.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,9 +22,12 @@
GR_SWIG_BLOCK_MAGIC(gr,float_to_short)
-gr_float_to_short_sptr gr_make_float_to_short ();
+gr_float_to_short_sptr
+gr_make_float_to_short (size_t vlen=1, float scale=1);
class gr_float_to_short : public gr_sync_block
{
- gr_float_to_short ();
+public:
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.cc b/gnuradio-core/src/lib/general/gr_int_to_float.cc
index 29ca22add..7ec15b1a8 100644
--- a/gnuradio-core/src/lib/general/gr_int_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,19 +26,23 @@
#include <gr_int_to_float.h>
#include <gr_io_signature.h>
-#include <gri_int_to_float.h>
+#include <volk/volk.h>
gr_int_to_float_sptr
-gr_make_int_to_float ()
+gr_make_int_to_float (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_int_to_float ());
+ return gnuradio::get_initial_sptr(new gr_int_to_float (vlen, scale));
}
-gr_int_to_float::gr_int_to_float ()
+gr_int_to_float::gr_int_to_float (size_t vlen, float scale)
: gr_sync_block ("gr_int_to_float",
- gr_make_io_signature (1, 1, sizeof (int32_t)),
- gr_make_io_signature (1, 1, sizeof (float)))
+ gr_make_io_signature (1, 1, sizeof (int32_t)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
}
int
@@ -48,9 +52,14 @@ gr_int_to_float::work (int noutput_items,
{
const int32_t *in = (const int32_t *) input_items[0];
float *out = (float *) output_items[0];
-
- gri_int_to_float(in, out, noutput_items);
+ if(is_unaligned()) {
+ volk_32i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items);
+ }
+ else {
+ volk_32i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items);
+ }
+
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h
index 9af381ba9..af6488a50 100644
--- a/gnuradio-core/src/lib/general/gr_int_to_float.h
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,7 @@ class gr_int_to_float;
typedef boost::shared_ptr<gr_int_to_float> gr_int_to_float_sptr;
GR_CORE_API gr_int_to_float_sptr
-gr_make_int_to_float ();
+gr_make_int_to_float (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of int to a stream of float
@@ -39,10 +39,18 @@ gr_make_int_to_float ();
class GR_CORE_API gr_int_to_float : public gr_sync_block
{
- friend GR_CORE_API gr_int_to_float_sptr gr_make_int_to_float ();
- gr_int_to_float ();
+ private:
+ friend GR_CORE_API gr_int_to_float_sptr
+ gr_make_int_to_float (size_t vlen, float scale);
+ gr_int_to_float (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.i b/gnuradio-core/src/lib/general/gr_int_to_float.i
index 8cb9e35b5..c1f25e37b 100644
--- a/gnuradio-core/src/lib/general/gr_int_to_float.i
+++ b/gnuradio-core/src/lib/general/gr_int_to_float.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,9 +22,11 @@
GR_SWIG_BLOCK_MAGIC(gr,int_to_float)
-gr_int_to_float_sptr gr_make_int_to_float ();
+gr_int_to_float_sptr
+gr_make_int_to_float (size_t vlen=1, float scale=1);
class gr_int_to_float : public gr_sync_block
{
- gr_int_to_float ();
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_cc.cc
new file mode 100644
index 000000000..0d20e6257
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_cc.cc
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_cc.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_cc_sptr
+gr_make_multiply_cc (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_cc (vlen));
+}
+
+gr_multiply_cc::gr_multiply_cc (size_t vlen)
+ : gr_sync_block ("gr_multiply_cc",
+ gr_make_io_signature (1, -1, sizeof (gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_multiply_cc::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(gr_complex));
+ if(is_unaligned()) {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32fc_x2_multiply_32fc_u(out, out, (gr_complex*)input_items[i], noi);
+ }
+ else {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32fc_x2_multiply_32fc_a(out, out, (gr_complex*)input_items[i], noi);
+ }
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.h b/gnuradio-core/src/lib/general/gr_multiply_cc.h
new file mode 100644
index 000000000..f80ec8b25
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_cc.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_CC_H
+#define INCLUDED_GR_MULTIPLY_CC_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_cc;
+typedef boost::shared_ptr<gr_multiply_cc> gr_multiply_cc_sptr;
+
+GR_CORE_API gr_multiply_cc_sptr
+gr_make_multiply_cc (size_t vlen=1);
+
+/*!
+ * \brief Multiply streams of complex values
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_cc : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_cc_sptr
+ gr_make_multiply_cc (size_t vlen);
+ gr_multiply_cc (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CC_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.i b/gnuradio-core/src/lib/general/gr_multiply_cc.i
new file mode 100644
index 000000000..61768c390
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_cc.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_cc)
+
+gr_multiply_cc_sptr
+gr_make_multiply_cc (size_t vlen=1);
+
+class gr_multiply_cc : public gr_sync_block
+{
+public:
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
new file mode 100644
index 000000000..103d87b8b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.cc
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_conjugate_cc.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_conjugate_cc (vlen));
+}
+
+gr_multiply_conjugate_cc::gr_multiply_conjugate_cc (size_t vlen)
+ : gr_sync_block ("gr_multiply_conjugate_cc",
+ gr_make_io_signature (2, 2, sizeof (gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_multiply_conjugate_cc::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *in0 = (gr_complex *) input_items[0];
+ gr_complex *in1 = (gr_complex *) input_items[1];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ if(is_unaligned()) {
+ volk_32fc_x2_multiply_conjugate_32fc_u(out, in0, in1, noi);
+ }
+ else {
+ volk_32fc_x2_multiply_conjugate_32fc_a(out, in0, in1, noi);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h
new file mode 100644
index 000000000..eb032f31b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H
+#define INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_conjugate_cc;
+typedef boost::shared_ptr<gr_multiply_conjugate_cc>
+gr_multiply_conjugate_cc_sptr;
+
+GR_CORE_API gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen=1);
+
+/*!
+ * \brief Multiplies a stream by the conjugate of the second stream
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_conjugate_cc : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_conjugate_cc_sptr
+ gr_make_multiply_conjugate_cc (size_t vlen);
+ gr_multiply_conjugate_cc (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CONJUGATE_CC_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i
new file mode 100644
index 000000000..023410505
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_conjugate_cc)
+
+gr_multiply_conjugate_cc_sptr
+gr_make_multiply_conjugate_cc (size_t vlen=1);
+
+class gr_multiply_conjugate_cc : public gr_sync_block
+{
+public:
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
new file mode 100644
index 000000000..59521f54a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.cc
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_const_cc.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_const_cc_sptr
+gr_make_multiply_const_cc (gr_complex k, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_const_cc (k, vlen));
+}
+
+gr_multiply_const_cc::gr_multiply_const_cc (gr_complex k, size_t vlen)
+ : gr_sync_block ("gr_multiply_const_cc",
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*vlen)),
+ d_k(k), d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(alignment_multiple);
+}
+
+gr_complex
+gr_multiply_const_cc::k() const
+{
+ return d_k;
+}
+
+void
+gr_multiply_const_cc::set_k(gr_complex k)
+{
+ d_k = k;
+}
+
+int
+gr_multiply_const_cc::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ if(is_unaligned()) {
+ volk_32fc_s32fc_multiply_32fc_u(out, in, d_k, noi);
+ }
+ else {
+ volk_32fc_s32fc_multiply_32fc_a(out, in, d_k, noi);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h
new file mode 100644
index 000000000..1791d9160
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_CONST_CC_H
+#define INCLUDED_GR_MULTIPLY_CONST_CC_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_const_cc;
+typedef boost::shared_ptr<gr_multiply_const_cc> gr_multiply_const_cc_sptr;
+
+GR_CORE_API gr_multiply_const_cc_sptr
+gr_make_multiply_const_cc (gr_complex k, size_t vlen=1);
+
+/*!
+ * \brief Multiply stream of complex values with a constant \p k
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_const_cc : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_const_cc_sptr
+ gr_make_multiply_const_cc (gr_complex k, size_t vlen);
+ gr_multiply_const_cc (gr_complex k, size_t vlen);
+
+ gr_complex d_k;
+ size_t d_vlen;
+
+ public:
+ gr_complex k() const;
+ void set_k(gr_complex k);
+
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CONST_CC_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.i b/gnuradio-core/src/lib/general/gr_multiply_const_cc.i
new file mode 100644
index 000000000..be8d32b31
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.i
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_const_cc)
+
+gr_multiply_const_cc_sptr
+gr_make_multiply_const_cc (gr_complex k, size_t vlen=1);
+
+class gr_multiply_const_cc : public gr_sync_block
+{
+public:
+ gr_complex k() const;
+ void set_k(gr_complex k);
+};
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
new file mode 100644
index 000000000..8354cb27b
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.cc
@@ -0,0 +1,80 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_const_ff.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_const_ff (k, vlen));
+}
+
+gr_multiply_const_ff::gr_multiply_const_ff (float k, size_t vlen)
+ : gr_sync_block ("gr_multiply_const_ff",
+ gr_make_io_signature (1, 1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_k(k), d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_multiply_const_ff::k() const
+{
+ return d_k;
+}
+
+void
+gr_multiply_const_ff::set_k(float k)
+{
+ d_k = k;
+}
+
+int
+gr_multiply_const_ff::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const float *in = (const float *) input_items[0];
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ if(is_unaligned()) {
+ volk_32f_s32f_multiply_32f_u(out, in, d_k, noi);
+ }
+ else {
+ volk_32f_s32f_multiply_32f_a(out, in, d_k, noi);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h
new file mode 100644
index 000000000..ef42a92f4
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_CONST_FF_H
+#define INCLUDED_GR_MULTIPLY_CONST_FF_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_const_ff;
+typedef boost::shared_ptr<gr_multiply_const_ff> gr_multiply_const_ff_sptr;
+
+GR_CORE_API gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen=1);
+
+/*!
+ * \brief Multiply stream of float values with a constant \p k
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_const_ff : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_const_ff_sptr
+ gr_make_multiply_const_ff (float k, size_t vlen);
+ gr_multiply_const_ff (float k, size_t vlen);
+
+ float d_k;
+ size_t d_vlen;
+
+ public:
+ float k() const;
+ void set_k(float k);
+
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_CONST_FF_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.i b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i
new file mode 100644
index 000000000..0fd3b1225
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.i
@@ -0,0 +1,33 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_const_ff)
+
+gr_multiply_const_ff_sptr
+gr_make_multiply_const_ff (float k, size_t vlen=1);
+
+class gr_multiply_const_ff : public gr_sync_block
+{
+public:
+ float k() const;
+ void set_k(float k);
+};
diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.cc b/gnuradio-core/src/lib/general/gr_multiply_ff.cc
new file mode 100644
index 000000000..a7d34ce51
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_ff.cc
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_multiply_ff.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_multiply_ff_sptr
+gr_make_multiply_ff (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_multiply_ff (vlen));
+}
+
+gr_multiply_ff::gr_multiply_ff (size_t vlen)
+ : gr_sync_block ("gr_multiply_ff",
+ gr_make_io_signature (1, -1, sizeof (float)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_multiply_ff::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ float *out = (float *) output_items[0];
+ int noi = d_vlen*noutput_items;
+
+ memcpy(out, input_items[0], noi*sizeof(float));
+ if(is_unaligned()) {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_multiply_32f_u(out, out, (const float*)input_items[i], noi);
+ }
+ else {
+ for(size_t i = 1; i < input_items.size(); i++)
+ volk_32f_x2_multiply_32f_a(out, out, (const float*)input_items[i], noi);
+ }
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.h b/gnuradio-core/src/lib/general/gr_multiply_ff.h
new file mode 100644
index 000000000..ae36cb1e0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_ff.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_MULTIPLY_FF_H
+#define INCLUDED_GR_MULTIPLY_FF_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_multiply_ff;
+typedef boost::shared_ptr<gr_multiply_ff> gr_multiply_ff_sptr;
+
+GR_CORE_API gr_multiply_ff_sptr
+gr_make_multiply_ff (size_t vlen=1);
+
+/*!
+ * \brief Multiply streams of complex values
+ * \ingroup math_blk
+ */
+
+class GR_CORE_API gr_multiply_ff : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_multiply_ff_sptr
+ gr_make_multiply_ff (size_t vlen);
+ gr_multiply_ff (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_MULTIPLY_FF_H */
diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.i b/gnuradio-core/src/lib/general/gr_multiply_ff.i
new file mode 100644
index 000000000..0f06301f2
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_multiply_ff.i
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,multiply_ff)
+
+gr_multiply_ff_sptr
+gr_make_multiply_ff (size_t vlen=1);
+
+class gr_multiply_ff : public gr_sync_block
+{
+public:
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.cc b/gnuradio-core/src/lib/general/gr_short_to_char.cc
new file mode 100644
index 000000000..a3c096e6d
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_short_to_char.cc
@@ -0,0 +1,67 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_short_to_char.h>
+#include <gr_io_signature.h>
+#include <volk/volk.h>
+
+gr_short_to_char_sptr
+gr_make_short_to_char (size_t vlen)
+{
+ return gnuradio::get_initial_sptr(new gr_short_to_char (vlen));
+}
+
+gr_short_to_char::gr_short_to_char (size_t vlen)
+ : gr_sync_block ("gr_short_to_char",
+ gr_make_io_signature (1, 1, sizeof (short)*vlen),
+ gr_make_io_signature (1, 1, sizeof (char)*vlen)),
+ d_vlen(vlen)
+{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(char);
+ set_alignment(alignment_multiple);
+}
+
+int
+gr_short_to_char::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const int16_t *in = (const int16_t *) input_items[0];
+ int8_t *out = (int8_t *) output_items[0];
+
+ if(is_unaligned()) {
+ volk_16i_convert_8i_u(out, in, d_vlen*noutput_items);
+ }
+ else {
+ volk_16i_convert_8i_a(out, in, d_vlen*noutput_items);
+ }
+
+ return noutput_items;
+}
+
+
+
diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h
new file mode 100644
index 000000000..9682d86ec
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_short_to_char.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_SHORT_TO_CHAR_H
+#define INCLUDED_GR_SHORT_TO_CHAR_H
+
+#include <gr_core_api.h>
+#include <gr_sync_block.h>
+
+class gr_short_to_char;
+typedef boost::shared_ptr<gr_short_to_char> gr_short_to_char_sptr;
+
+GR_CORE_API gr_short_to_char_sptr
+gr_make_short_to_char (size_t vlen=1);
+
+/*!
+ * \brief Convert stream of short to a stream of float
+ * \ingroup converter_blk
+ */
+
+class GR_CORE_API gr_short_to_char : public gr_sync_block
+{
+ private:
+ friend GR_CORE_API gr_short_to_char_sptr
+ gr_make_short_to_char (size_t vlen);
+ gr_short_to_char (size_t vlen);
+
+ size_t d_vlen;
+
+ public:
+ virtual int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif /* INCLUDED_GR_SHORT_TO_CHAR_H */
diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.i b/gnuradio-core/src/lib/general/gr_short_to_char.i
new file mode 100644
index 000000000..330a4fdda
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_short_to_char.i
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,short_to_char)
+
+gr_short_to_char_sptr
+gr_make_short_to_char (size_t vlen=1);
+
+class gr_short_to_char : public gr_sync_block
+{
+
+};
diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc
index 7b80953ac..94d376a27 100644
--- a/gnuradio-core/src/lib/general/gr_short_to_float.cc
+++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2010 Free Software Foundation, Inc.
+ * Copyright 2004,2010,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,19 +26,35 @@
#include <gr_short_to_float.h>
#include <gr_io_signature.h>
-#include <gri_short_to_float.h>
+#include <volk/volk.h>
gr_short_to_float_sptr
-gr_make_short_to_float ()
+gr_make_short_to_float (size_t vlen, float scale)
{
- return gnuradio::get_initial_sptr(new gr_short_to_float ());
+ return gnuradio::get_initial_sptr(new gr_short_to_float (vlen, scale));
}
-gr_short_to_float::gr_short_to_float ()
+gr_short_to_float::gr_short_to_float (size_t vlen, float scale)
: gr_sync_block ("gr_short_to_float",
- gr_make_io_signature (1, 1, sizeof (short)),
- gr_make_io_signature (1, 1, sizeof (float)))
+ gr_make_io_signature (1, 1, sizeof (short)*vlen),
+ gr_make_io_signature (1, 1, sizeof (float)*vlen)),
+ d_vlen(vlen), d_scale(scale)
{
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(float);
+ set_alignment(alignment_multiple);
+}
+
+float
+gr_short_to_float::scale() const
+{
+ return d_scale;
+}
+
+void
+gr_short_to_float::set_scale(float scale)
+{
+ d_scale = scale;
}
int
@@ -49,8 +65,12 @@ gr_short_to_float::work (int noutput_items,
const short *in = (const short *) input_items[0];
float *out = (float *) output_items[0];
- gri_short_to_float (in, out, noutput_items);
-
+ if(is_unaligned()) {
+ volk_16i_s32f_convert_32f_u(out, in, d_scale, d_vlen*noutput_items);
+ }
+ else {
+ volk_16i_s32f_convert_32f_a(out, in, d_scale, d_vlen*noutput_items);
+ }
return noutput_items;
}
diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h
index b40c966ea..efdc81ecd 100644
--- a/gnuradio-core/src/lib/general/gr_short_to_float.h
+++ b/gnuradio-core/src/lib/general/gr_short_to_float.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -30,7 +30,7 @@ class gr_short_to_float;
typedef boost::shared_ptr<gr_short_to_float> gr_short_to_float_sptr;
GR_CORE_API gr_short_to_float_sptr
-gr_make_short_to_float ();
+gr_make_short_to_float (size_t vlen=1, float scale=1);
/*!
* \brief Convert stream of short to a stream of float
@@ -39,10 +39,18 @@ gr_make_short_to_float ();
class GR_CORE_API gr_short_to_float : public gr_sync_block
{
- friend GR_CORE_API gr_short_to_float_sptr gr_make_short_to_float ();
- gr_short_to_float ();
-
+ private:
+ friend GR_CORE_API gr_short_to_float_sptr
+ gr_make_short_to_float (size_t vlen, float scale);
+ gr_short_to_float (size_t vlen, float scale);
+
+ size_t d_vlen;
+ float d_scale;
+
public:
+ float scale() const;
+ void set_scale(float scale);
+
virtual int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.i b/gnuradio-core/src/lib/general/gr_short_to_float.i
index 56759df29..229618890 100644
--- a/gnuradio-core/src/lib/general/gr_short_to_float.i
+++ b/gnuradio-core/src/lib/general/gr_short_to_float.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004 Free Software Foundation, Inc.
+ * Copyright 2004,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,9 +22,12 @@
GR_SWIG_BLOCK_MAGIC(gr,short_to_float)
-gr_short_to_float_sptr gr_make_short_to_float ();
+gr_short_to_float_sptr
+gr_make_short_to_float (size_t vlen=1, float scale=1);
class gr_short_to_float : public gr_sync_block
{
- gr_short_to_float ();
+public:
+ float scale() const;
+ void set_scale(float scale);
};
diff --git a/gnuradio-core/src/lib/general/gri_fft.cc b/gnuradio-core/src/lib/general/gri_fft.cc
index 0df1af25d..63e307776 100644
--- a/gnuradio-core/src/lib/general/gri_fft.cc
+++ b/gnuradio-core/src/lib/general/gri_fft.cc
@@ -78,6 +78,22 @@ gri_fftw_import_wisdom ()
}
static void
+gri_fftw_config_threading (int nthreads)
+{
+ static int fftw_threads_inited = 0;
+
+#ifdef FFTW3F_THREADS
+ if (fftw_threads_inited == 0)
+ {
+ fftw_threads_inited = 1;
+ fftwf_init_threads();
+ }
+
+ fftwf_plan_with_nthreads(nthreads);
+#endif
+}
+
+static void
gri_fftw_export_wisdom ()
{
const char *filename = wisdom_filename ();
@@ -94,7 +110,7 @@ gri_fftw_export_wisdom ()
// ----------------------------------------------------------------
-gri_fft_complex::gri_fft_complex (int fft_size, bool forward)
+gri_fft_complex::gri_fft_complex (int fft_size, bool forward, int nthreads)
{
// Hold global mutex during plan construction and destruction.
gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
@@ -115,7 +131,10 @@ gri_fft_complex::gri_fft_complex (int fft_size, bool forward)
throw std::runtime_error ("fftwf_malloc");
}
+ d_nthreads = nthreads;
+ gri_fftw_config_threading (nthreads);
gri_fftw_import_wisdom (); // load prior wisdom from disk
+
d_plan = fftwf_plan_dft_1d (fft_size,
reinterpret_cast<fftwf_complex *>(d_inbuf),
reinterpret_cast<fftwf_complex *>(d_outbuf),
@@ -139,6 +158,18 @@ gri_fft_complex::~gri_fft_complex ()
fftwf_free (d_outbuf);
}
+void
+gri_fft_complex::set_nthreads(int n)
+{
+ if (n <= 0)
+ throw std::out_of_range ("gri_fftw: invalid number of threads");
+ d_nthreads = n;
+
+#ifdef FFTW3F_THREADS
+ fftwf_plan_with_nthreads(d_nthreads);
+#endif
+}
+
void
gri_fft_complex::execute ()
{
@@ -147,7 +178,7 @@ gri_fft_complex::execute ()
// ----------------------------------------------------------------
-gri_fft_real_fwd::gri_fft_real_fwd (int fft_size)
+gri_fft_real_fwd::gri_fft_real_fwd (int fft_size, int nthreads)
{
// Hold global mutex during plan construction and destruction.
gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
@@ -168,7 +199,10 @@ gri_fft_real_fwd::gri_fft_real_fwd (int fft_size)
throw std::runtime_error ("fftwf_malloc");
}
+ d_nthreads = nthreads;
+ gri_fftw_config_threading (nthreads);
gri_fftw_import_wisdom (); // load prior wisdom from disk
+
d_plan = fftwf_plan_dft_r2c_1d (fft_size,
d_inbuf,
reinterpret_cast<fftwf_complex *>(d_outbuf),
@@ -191,6 +225,18 @@ gri_fft_real_fwd::~gri_fft_real_fwd ()
fftwf_free (d_outbuf);
}
+void
+gri_fft_real_fwd::set_nthreads(int n)
+{
+ if (n <= 0)
+ throw std::out_of_range ("gri_fftw: invalid number of threads");
+ d_nthreads = n;
+
+#ifdef FFTW3F_THREADS
+ fftwf_plan_with_nthreads(d_nthreads);
+#endif
+}
+
void
gri_fft_real_fwd::execute ()
{
@@ -199,7 +245,7 @@ gri_fft_real_fwd::execute ()
// ----------------------------------------------------------------
-gri_fft_real_rev::gri_fft_real_rev (int fft_size)
+gri_fft_real_rev::gri_fft_real_rev (int fft_size, int nthreads)
{
// Hold global mutex during plan construction and destruction.
gri_fft_planner::scoped_lock lock(gri_fft_planner::mutex());
@@ -220,11 +266,13 @@ gri_fft_real_rev::gri_fft_real_rev (int fft_size)
throw std::runtime_error ("fftwf_malloc");
}
+ d_nthreads = nthreads;
+ gri_fftw_config_threading (nthreads);
+ gri_fftw_import_wisdom (); // load prior wisdom from disk
+
// FIXME If there's ever a chance that the planning functions
// will be called in multiple threads, we've got to ensure single
// threaded access. They are not thread-safe.
-
- gri_fftw_import_wisdom (); // load prior wisdom from disk
d_plan = fftwf_plan_dft_c2r_1d (fft_size,
reinterpret_cast<fftwf_complex *>(d_inbuf),
d_outbuf,
@@ -244,6 +292,18 @@ gri_fft_real_rev::~gri_fft_real_rev ()
fftwf_free (d_outbuf);
}
+void
+gri_fft_real_rev::set_nthreads(int n)
+{
+ if (n <= 0)
+ throw std::out_of_range ("gri_fftw: invalid number of threads");
+ d_nthreads = n;
+
+#ifdef FFTW3F_THREADS
+ fftwf_plan_with_nthreads(d_nthreads);
+#endif
+}
+
void
gri_fft_real_rev::execute ()
{
diff --git a/gnuradio-core/src/lib/general/gri_fft.h b/gnuradio-core/src/lib/general/gri_fft.h
index 91a82fb55..ed80badf1 100644
--- a/gnuradio-core/src/lib/general/gri_fft.h
+++ b/gnuradio-core/src/lib/general/gri_fft.h
@@ -49,12 +49,13 @@ public:
*/
class GR_CORE_API gri_fft_complex {
int d_fft_size;
+ int d_nthreads;
gr_complex *d_inbuf;
gr_complex *d_outbuf;
void *d_plan;
public:
- gri_fft_complex (int fft_size, bool forward = true);
+ gri_fft_complex (int fft_size, bool forward = true, int nthreads=1);
virtual ~gri_fft_complex ();
/*
@@ -69,6 +70,16 @@ public:
int outbuf_length () const { return d_fft_size; }
/*!
+ * Set the number of threads to use for caclulation.
+ */
+ void set_nthreads(int n);
+
+ /*!
+ * Get the number of threads being used by FFTW
+ */
+ int nthreads() const { return d_nthreads; }
+
+ /*!
* compute FFT. The input comes from inbuf, the output is placed in outbuf.
*/
void execute ();
@@ -80,12 +91,13 @@ public:
*/
class GR_CORE_API gri_fft_real_fwd {
int d_fft_size;
+ int d_nthreads;
float *d_inbuf;
gr_complex *d_outbuf;
void *d_plan;
public:
- gri_fft_real_fwd (int fft_size);
+ gri_fft_real_fwd (int fft_size, int nthreads=1);
virtual ~gri_fft_real_fwd ();
/*
@@ -100,6 +112,16 @@ public:
int outbuf_length () const { return d_fft_size / 2 + 1; }
/*!
+ * Set the number of threads to use for caclulation.
+ */
+ void set_nthreads(int n);
+
+ /*!
+ * Get the number of threads being used by FFTW
+ */
+ int nthreads() const { return d_nthreads; }
+
+ /*!
* compute FFT. The input comes from inbuf, the output is placed in outbuf.
*/
void execute ();
@@ -111,12 +133,13 @@ public:
*/
class GR_CORE_API gri_fft_real_rev {
int d_fft_size;
+ int d_nthreads;
gr_complex *d_inbuf;
float *d_outbuf;
void *d_plan;
public:
- gri_fft_real_rev (int fft_size);
+ gri_fft_real_rev (int fft_size, int nthreads=1);
virtual ~gri_fft_real_rev ();
/*
@@ -131,6 +154,16 @@ public:
int outbuf_length () const { return d_fft_size; }
/*!
+ * Set the number of threads to use for caclulation.
+ */
+ void set_nthreads(int n);
+
+ /*!
+ * Get the number of threads being used by FFTW
+ */
+ int nthreads() const { return d_nthreads; }
+
+ /*!
* compute FFT. The input comes from inbuf, the output is placed in outbuf.
*/
void execute ();
diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.cc b/gnuradio-core/src/lib/general/gri_float_to_int.cc
index 5271e60e2..0b0b10dfe 100644
--- a/gnuradio-core/src/lib/general/gri_float_to_int.cc
+++ b/gnuradio-core/src/lib/general/gri_float_to_int.cc
@@ -34,10 +34,10 @@ static const int64_t MIN_INT = -2147483647; // -(2^31)-1
void
-gri_float_to_int (const float *in, int *out, int nsamples)
+gri_float_to_int (const float *in, int *out, float scale, int nsamples)
{
for (int i = 0; i < nsamples; i++){
- int64_t r = llrintf(in[i]);
+ int64_t r = llrintf(scale * in[i]);
if (r < MIN_INT)
r = MIN_INT;
else if (r > MAX_INT)
diff --git a/gnuradio-core/src/lib/general/gri_float_to_int.h b/gnuradio-core/src/lib/general/gri_float_to_int.h
index a2f6ea877..d8b98efc1 100644
--- a/gnuradio-core/src/lib/general/gri_float_to_int.h
+++ b/gnuradio-core/src/lib/general/gri_float_to_int.h
@@ -28,6 +28,6 @@
/*!
* convert array of floats to int with rounding and saturation.
*/
-GR_CORE_API void gri_float_to_int (const float *in, int *out, int nsamples);
+GR_CORE_API void gri_float_to_int (const float *in, int *out, float scale, int nsamples);
#endif /* INCLUDED_GRI_FLOAT_TO_INT_H */