diff options
author | Johnathan Corgan | 2012-07-19 07:02:45 -0700 |
---|---|---|
committer | Johnathan Corgan | 2012-07-19 07:02:45 -0700 |
commit | 66f49de1986dd531bee011299d4b1f7c62872d39 (patch) | |
tree | bf4dbc1730beb129c250fbf7e938c379c16d958e /gr-blocks/lib | |
parent | bbd91d7a08bfc0c229267e5dc848d1f57d629373 (diff) | |
download | gnuradio-66f49de1986dd531bee011299d4b1f7c62872d39.tar.gz gnuradio-66f49de1986dd531bee011299d4b1f7c62872d39.tar.bz2 gnuradio-66f49de1986dd531bee011299d4b1f7c62872d39.zip |
blocks: added gr::blocks::repeat
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gr-blocks/lib/repeat_impl.cc | 69 | ||||
-rw-r--r-- | gr-blocks/lib/repeat_impl.h | 47 |
3 files changed, 117 insertions, 0 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index e4aca48f0..9b0043d4b 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -154,6 +154,7 @@ list(APPEND gr_blocks_sources multiply_const_cc_impl.cc multiply_const_ff_impl.cc nlog10_ff_impl.cc + repeat_impl.cc short_to_char_impl.cc short_to_float_impl.cc uchar_array_to_float.cc diff --git a/gr-blocks/lib/repeat_impl.cc b/gr-blocks/lib/repeat_impl.cc new file mode 100644 index 000000000..939a33b87 --- /dev/null +++ b/gr-blocks/lib/repeat_impl.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 "repeat_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + repeat::sptr repeat::make(size_t itemsize, int interp) + { + return gnuradio::get_initial_sptr(new repeat_impl(itemsize, interp)); + } + + repeat_impl::repeat_impl(size_t itemsize, int interp) + : gr_sync_interpolator("repeat", + gr_make_io_signature (1, 1, itemsize), + gr_make_io_signature (1, 1, itemsize), + interp), + d_itemsize(itemsize), + d_interp(interp) + { + } + + int + repeat_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char *) input_items[0]; + char *out = (char *)output_items[0]; + + for (int i = 0; i < noutput_items/d_interp; i++) { + for (int j = 0; j < d_interp; j++) { + memcpy(out, in, d_itemsize); + out += d_itemsize; + } + + in += d_itemsize; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/repeat_impl.h b/gr-blocks/lib/repeat_impl.h new file mode 100644 index 000000000..6451d0d98 --- /dev/null +++ b/gr-blocks/lib/repeat_impl.h @@ -0,0 +1,47 @@ +/* -*- 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_REPEAT_IMPL_H +#define INCLUDED_REPEAT_IMPL_H + +#include <blocks/repeat.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API repeat_impl : public repeat + { + size_t d_itemsize; + int d_interp; + + public: + repeat_impl(size_t itemsize, int d_interp); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_REPEAT_IMPL_H */ |