diff options
author | Tom Rondeau | 2012-01-28 12:49:00 -0500 |
---|---|---|
committer | Tom Rondeau | 2012-01-28 12:49:00 -0500 |
commit | 8f09eb204213492091fa8310b165c8ddb89b2801 (patch) | |
tree | dceb3e031282a430306f16d3c509ec4a860419e3 /gnuradio-core/src/lib | |
parent | 2a2663d625847217a237acba0229738a81003eef (diff) | |
download | gnuradio-8f09eb204213492091fa8310b165c8ddb89b2801.tar.gz gnuradio-8f09eb204213492091fa8310b165c8ddb89b2801.tar.bz2 gnuradio-8f09eb204213492091fa8310b165c8ddb89b2801.zip |
volk: cleaned up float_to_X to be Volk-only and added vlen and scale to constructor to set the vector length and a free scaling with the data.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_char.cc | 42 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_char.h | 16 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_char.i | 10 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_int.cc | 46 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_int.h | 16 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_int.i | 10 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_short.cc | 41 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_short.h | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_float_to_short.i | 10 |
9 files changed, 130 insertions, 76 deletions
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 2d7e21f2e..165172ac6 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 * @@ -30,19 +30,32 @@ #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); + 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 @@ -50,22 +63,15 @@ gr_float_to_char::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { -#if 1 - float d_scale = 1.0; const float *in = (const float *) input_items[0]; int8_t *out = (int8_t *) output_items[0]; if(is_unaligned()) { - volk_32f_s32f_convert_8i_u(out, in, d_scale, noutput_items); + 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, noutput_items); + volk_32f_s32f_convert_8i_a(out, in, d_scale, d_vlen*noutput_items); } -#else - const float *in = (const float *) input_items[0]; - char *out = (char *) output_items[0]; - gri_float_to_char (in, out, noutput_items); -#endif 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..05939f1b1 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,13 @@ 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); + gr_float_to_char (size_t vlen, 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 2ca723c7c..c4d9991af 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 * @@ -30,42 +30,48 @@ #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); + 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) { -#if 1 - float d_scale = 1.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, noutput_items); + 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, noutput_items); + 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); -#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..a0b52a3c1 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,13 @@ 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); + gr_float_to_int (size_t vlen, 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 6c4d031ac..e6ac5c184 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 * @@ -30,19 +30,32 @@ #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); + 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 @@ -53,18 +66,12 @@ gr_float_to_short::work (int noutput_items, const float *in = (const float *) input_items[0]; short *out = (short *) output_items[0]; -#if 1 - float d_scale = 1.0; - //volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); if(is_unaligned()) { - volk_32f_s32f_convert_16i_u(out, in, d_scale, noutput_items); + 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, noutput_items); + volk_32f_s32f_convert_16i_a(out, in, d_scale, d_vlen*noutput_items); } -#else - gri_float_to_short (in, out, noutput_items); -#endif 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..8da733054 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,13 @@ 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); + gr_float_to_short (size_t vlen, float scale); }; |