commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 42/57: fec: wip: fixing formatting.


From: git
Subject: [Commit-gnuradio] [gnuradio] 42/57: fec: wip: fixing formatting.
Date: Wed, 21 May 2014 03:10:30 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 03b3b0eb63232507a4837be38d0398a655284f69
Author: Tom Rondeau <address@hidden>
Date:   Fri May 16 10:19:07 2014 -0400

    fec: wip: fixing formatting.
---
 gr-fec/grc/fec_async_decoder.xml                   | 124 +++++------
 gr-fec/grc/fec_async_encoder.xml                   |  60 ++---
 .../grc/variable_repetition_decoder_def_list.xml   |   1 +
 gr-fec/include/gnuradio/fec/async_decoder.h        | 138 ++++++------
 gr-fec/include/gnuradio/fec/async_encoder.h        | 130 +++++------
 gr-fec/lib/async_decoder_impl.cc                   | 222 +++++++++----------
 gr-fec/lib/async_decoder_impl.h                    | 110 +++++-----
 gr-fec/lib/async_encoder_impl.cc                   | 243 +++++++++++----------
 gr-fec/lib/async_encoder_impl.h                    | 109 ++++-----
 9 files changed, 574 insertions(+), 563 deletions(-)

diff --git a/gr-fec/grc/fec_async_decoder.xml b/gr-fec/grc/fec_async_decoder.xml
index 4cc7be7..1f9ff99 100644
--- a/gr-fec/grc/fec_async_decoder.xml
+++ b/gr-fec/grc/fec_async_decoder.xml
@@ -1,62 +1,62 @@
-<?xml version="1.0"?>
-<block>
-  <name>FEC Async Decoder</name>
-  <key>fec_async_decoder</key>
-  <import>from gnuradio import fec</import>
-  <make>fec.async_decoder($decoder, $itype.size, $otype.size)</make>
-
-  <param>
-    <name>Constituent Decoder</name>
-    <key>decoder</key>
-    <value>decoder_variable</value>
-    <type>raw</type>
-  </param>
-
-  <param>
-    <name>Input Type</name>
-    <key>itype</key>
-    <type>enum</type>
-    <option>
-      <name>Byte</name>
-      <key>byte</key>
-      <opt>size:gr.sizeof_char</opt>
-    </option>
-    <option>
-      <name>Float</name>
-      <key>float</key>
-      <opt>size:gr.sizeof_float</opt>
-    </option>
-  </param>
-
-  <param>
-    <name>Output Type</name>
-    <key>otype</key>
-    <type>enum</type>
-    <option>
-      <name>Byte</name>
-      <key>byte</key>
-      <opt>size:gr.sizeof_char</opt>
-    </option>
-    <option>
-      <name>Float</name>
-      <key>float</key>
-      <opt>size:gr.sizeof_float</opt>
-    </option>
-  </param>
-
-  <sink>
-    <name>pdus</name>
-    <type>message</type>
-    <optional>1</optional>
-  </sink>
-
-  <source>
-    <name>pdus</name>
-    <type>message</type>
-    <optional>1</optional>
-  </source>
-
-  <doc>
-  </doc>
-
-</block>
+<?xml version="1.0"?>
+<block>
+  <name>FEC Async Decoder</name>
+  <key>fec_async_decoder</key>
+  <import>from gnuradio import fec</import>
+  <make>fec.async_decoder($decoder, $itype.size, $otype.size)</make>
+
+  <param>
+    <name>Constituent Decoder</name>
+    <key>decoder</key>
+    <value>decoder_variable</value>
+    <type>raw</type>
+  </param>
+
+  <param>
+    <name>Input Type</name>
+    <key>itype</key>
+    <type>enum</type>
+    <option>
+      <name>Byte</name>
+      <key>byte</key>
+      <opt>size:gr.sizeof_char</opt>
+    </option>
+    <option>
+      <name>Float</name>
+      <key>float</key>
+      <opt>size:gr.sizeof_float</opt>
+    </option>
+  </param>
+
+  <param>
+    <name>Output Type</name>
+    <key>otype</key>
+    <type>enum</type>
+    <option>
+      <name>Byte</name>
+      <key>byte</key>
+      <opt>size:gr.sizeof_char</opt>
+    </option>
+    <option>
+      <name>Float</name>
+      <key>float</key>
+      <opt>size:gr.sizeof_float</opt>
+    </option>
+  </param>
+
+  <sink>
+    <name>in</name>
+    <type>message</type>
+    <optional>1</optional>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>message</type>
+    <optional>1</optional>
+  </source>
+
+  <doc>
+  </doc>
+
+</block>
diff --git a/gr-fec/grc/fec_async_encoder.xml b/gr-fec/grc/fec_async_encoder.xml
index 5b58c64..d552210 100644
--- a/gr-fec/grc/fec_async_encoder.xml
+++ b/gr-fec/grc/fec_async_encoder.xml
@@ -1,30 +1,30 @@
-<?xml version="1.0"?>
-<block>
-  <name>FEC Async Encoder</name>
-  <key>fec_async_encoder</key>
-  <import>from gnuradio import fec</import>
-  <make>fec.async_encoder($encoder)</make>
-
-  <param>
-    <name>Constituent Encoder</name>
-    <key>encoder</key>
-    <value>encoder_variable</value>
-    <type>raw</type>
-  </param>
-
-  <sink>
-    <name>pdus</name>
-    <type>message</type>
-    <optional>1</optional>
-  </sink>
-
-  <source>
-    <name>pdus</name>
-    <type>message</type>
-    <optional>1</optional>
-  </source>
-
-  <doc>
-  </doc>
-
-</block>
+<?xml version="1.0"?>
+<block>
+  <name>FEC Async Encoder</name>
+  <key>fec_async_encoder</key>
+  <import>from gnuradio import fec</import>
+  <make>fec.async_encoder($encoder)</make>
+
+  <param>
+    <name>Constituent Encoder</name>
+    <key>encoder</key>
+    <value>encoder_variable</value>
+    <type>raw</type>
+  </param>
+
+  <sink>
+    <name>in</name>
+    <type>message</type>
+    <optional>1</optional>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>message</type>
+    <optional>1</optional>
+  </source>
+
+  <doc>
+  </doc>
+
+</block>
diff --git a/gr-fec/grc/variable_repetition_decoder_def_list.xml 
b/gr-fec/grc/variable_repetition_decoder_def_list.xml
index c3ab1dc..eba43f9 100644
--- a/gr-fec/grc/variable_repetition_decoder_def_list.xml
+++ b/gr-fec/grc/variable_repetition_decoder_def_list.xml
@@ -11,6 +11,7 @@
     <var_make>
 #if int($ndim())==0 #
 self.$(id) = $(id) = fec.repetition_decoder.make($framebits, $rep, $prob)
+#else if int($ndim())==1 #
 self.$(id) = $(id) = map( (lambda a: fec.repetition_decoder.make($framebits, 
$rep, $prob)), range(0,$dim1) ) #slurp
 #else
 self.$(id) = $(id) = map( (lambda b: map( ( lambda a: 
fec.repetition_decoder.make($framebits, $rep, $prob)), range(0,$dim2) ) ), 
range(0,$dim1)) #slurp
diff --git a/gr-fec/include/gnuradio/fec/async_decoder.h 
b/gr-fec/include/gnuradio/fec/async_decoder.h
index 2053d64..b68bd71 100644
--- a/gr-fec/include/gnuradio/fec/async_decoder.h
+++ b/gr-fec/include/gnuradio/fec/async_decoder.h
@@ -1,69 +1,69 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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_FEC_ASYNC_DECODER_H
-#define INCLUDED_FEC_ASYNC_DECODER_H
-
-#include <gnuradio/fec/api.h>
-#include <gnuradio/fec/generic_decoder.h>
-#include <gnuradio/block.h>
-#include <boost/shared_ptr.hpp>
-
-namespace gr {
-  namespace fec {
-
-    /*!
-     * \brief Creates the decoder block for use in GNU Radio
-     * flowgraphs from a given FECAPI object derived from the
-     * generic_decoder class.
-     * \ingroup error_coding_blk
-     *
-     * \details
-     *
-     * Decodes frames received as a PDU over a message port.
-     */
-    class FEC_API async_decoder : virtual public block
-    {
-    public:
-      typedef boost::shared_ptr<async_decoder> sptr;
-
-      /*!
-       * Build the PDU-based FEC decoder block from an FECAPI decoder object.
-       *
-       * \param my_decoder An FECAPI decoder object child of the 
generic_decoder class.
-       * \param input_item_size size of a block of data for the decoder.
-       * \param output_item_size size of a block of data the decoder will 
produce.
-       */
-      static sptr make(generic_decoder::sptr my_decoder,
-                       size_t input_item_size,
-                       size_t output_item_size);
-
-      virtual int general_work(int noutput_items,
-                               gr_vector_int& ninput_items,
-                               gr_vector_const_void_star &input_items,
-                               gr_vector_void_star &output_items) = 0;
-    };
-
-  } /* namespace fec */
-} /* namespace gr */
-
-#endif /* INCLUDED_FEC_ASYNC_DECODER_H */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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_FEC_ASYNC_DECODER_H
+#define INCLUDED_FEC_ASYNC_DECODER_H
+
+#include <gnuradio/fec/api.h>
+#include <gnuradio/fec/generic_decoder.h>
+#include <gnuradio/block.h>
+#include <boost/shared_ptr.hpp>
+
+namespace gr {
+  namespace fec {
+
+    /*!
+     * \brief Creates the decoder block for use in GNU Radio
+     * flowgraphs from a given FECAPI object derived from the
+     * generic_decoder class.
+     * \ingroup error_coding_blk
+     *
+     * \details
+     *
+     * Decodes frames received as a PDU over a message port.
+     */
+    class FEC_API async_decoder : virtual public block
+    {
+    public:
+      typedef boost::shared_ptr<async_decoder> sptr;
+
+      /*!
+       * Build the PDU-based FEC decoder block from an FECAPI decoder object.
+       *
+       * \param my_decoder An FECAPI decoder object child of the 
generic_decoder class.
+       * \param input_item_size size of a block of data for the decoder.
+       * \param output_item_size size of a block of data the decoder will 
produce.
+       */
+      static sptr make(generic_decoder::sptr my_decoder,
+                       size_t input_item_size,
+                       size_t output_item_size);
+
+      virtual int general_work(int noutput_items,
+                               gr_vector_int& ninput_items,
+                               gr_vector_const_void_star &input_items,
+                               gr_vector_void_star &output_items) = 0;
+    };
+
+  } /* namespace fec */
+} /* namespace gr */
+
+#endif /* INCLUDED_FEC_ASYNC_DECODER_H */
diff --git a/gr-fec/include/gnuradio/fec/async_encoder.h 
b/gr-fec/include/gnuradio/fec/async_encoder.h
index fef1883..a59f47d 100644
--- a/gr-fec/include/gnuradio/fec/async_encoder.h
+++ b/gr-fec/include/gnuradio/fec/async_encoder.h
@@ -1,65 +1,65 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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_FEC_ASYNC_ENCODER_H
-#define INCLUDED_FEC_ASYNC_ENCODER_H
-
-#include <gnuradio/fec/api.h>
-#include <gnuradio/fec/generic_encoder.h>
-#include <gnuradio/block.h>
-#include <boost/shared_ptr.hpp>
-
-namespace gr {
-  namespace fec {
-
-    /*!
-     * \brief Creates the encoder block for use in GNU Radio
-     * flowgraphs from a given FECAPI object derived from the
-     * generic_encoder class.
-     * \ingroup error_coding_blk
-     *
-     * \details
-     *
-     * Encodes frames received as a PDU over a message port.
-     */
-    class FEC_API async_encoder : virtual public block
-    {
-    public:
-      typedef boost::shared_ptr<async_encoder> sptr;
-
-      /*!
-       * Build the PDU-based FEC encoder block from an FECAPI encoder object.
-       *
-       * \param my_encoder An FECAPI encoder object child of the 
generic_encoder class.
-       */
-      static sptr make(generic_encoder::sptr my_encoder);
-
-      virtual int general_work(int noutput_items,
-                               gr_vector_int& ninput_items,
-                               gr_vector_const_void_star &input_items,
-                               gr_vector_void_star &output_items) = 0;
-    };
-
-  } /* namespace fec */
-} /* namespace gr */
-
-#endif /* INCLUDED_FEC_ASYNC_ENCODER_H */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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_FEC_ASYNC_ENCODER_H
+#define INCLUDED_FEC_ASYNC_ENCODER_H
+
+#include <gnuradio/fec/api.h>
+#include <gnuradio/fec/generic_encoder.h>
+#include <gnuradio/block.h>
+#include <boost/shared_ptr.hpp>
+
+namespace gr {
+  namespace fec {
+
+    /*!
+     * \brief Creates the encoder block for use in GNU Radio
+     * flowgraphs from a given FECAPI object derived from the
+     * generic_encoder class.
+     * \ingroup error_coding_blk
+     *
+     * \details
+     *
+     * Encodes frames received as a PDU over a message port.
+     */
+    class FEC_API async_encoder : virtual public block
+    {
+    public:
+      typedef boost::shared_ptr<async_encoder> sptr;
+
+      /*!
+       * Build the PDU-based FEC encoder block from an FECAPI encoder object.
+       *
+       * \param my_encoder An FECAPI encoder object child of the 
generic_encoder class.
+       */
+      static sptr make(generic_encoder::sptr my_encoder);
+
+      virtual int general_work(int noutput_items,
+                               gr_vector_int& ninput_items,
+                               gr_vector_const_void_star &input_items,
+                               gr_vector_void_star &output_items) = 0;
+    };
+
+  } /* namespace fec */
+} /* namespace gr */
+
+#endif /* INCLUDED_FEC_ASYNC_ENCODER_H */
diff --git a/gr-fec/lib/async_decoder_impl.cc b/gr-fec/lib/async_decoder_impl.cc
index b235f95..d3cfd2c 100644
--- a/gr-fec/lib/async_decoder_impl.cc
+++ b/gr-fec/lib/async_decoder_impl.cc
@@ -1,111 +1,111 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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 "async_decoder_impl.h"
-#include <gnuradio/io_signature.h>
-#include <stdio.h>
-
-
-namespace gr {
-  namespace fec {
-
-    async_decoder::sptr
-    async_decoder::make(generic_decoder::sptr my_decoder,
-                        size_t input_item_size, size_t output_item_size)
-    {
-      return gnuradio::get_initial_sptr
-        (new async_decoder_impl(my_decoder, input_item_size, 
output_item_size));
-    }
-
-    async_decoder_impl::async_decoder_impl(generic_decoder::sptr my_decoder,
-                                           size_t input_item_size,
-                                           size_t output_item_size)
-      : block("async_decoder",
-              io_signature::make(0,0,0),
-              io_signature::make(0,0,0)),
-        d_input_item_size(input_item_size), 
d_output_item_size(output_item_size)
-    {
-      d_decoder = my_decoder;
-      message_port_register_in(pmt::mp("pdus"));
-      message_port_register_out(pmt::mp("pdus"));
-      set_msg_handler(pmt::mp("pdus"), 
boost::bind(&async_decoder_impl::decode, this ,_1));
-    }
-
-    async_decoder_impl::~async_decoder_impl()
-    {
-    }
-
-    void
-    async_decoder_impl::decode(pmt::pmt_t msg)
-    {
-      // extract input pdu
-      pmt::pmt_t meta(pmt::car(msg));
-      pmt::pmt_t bits(pmt::cdr(msg));
-
-      int nbits = pmt::length(bits);
-      int blksize_in = d_decoder->get_input_size();
-      int blksize_out = d_decoder->get_output_size();
-      int nblocks = nbits/blksize_in;
-
-      // nbits sanity check
-      if(nbits % blksize_in != 0){
-        throw std::runtime_error((boost::format("nbits_in %% blksize_in != 0 
in fec_decoder_asyn! %d bits in, %d blksize") \
-                                  % nbits % blksize_in).str());
-      }
-
-      printf("decoder :: blksize_in = %d, blksize_out = %d\n", blksize_in, 
blksize_out);
-
-      pmt::pmt_t outvec(pmt::make_u8vector(blksize_out * nblocks, 0xFF));
-      printf("decoder :: outvec len = %d (%d blks)\n", blksize_out * nblocks, 
nblocks);
-
-      // get pmt buffer pointers
-      size_t o0(0);
-      const float* f32in = pmt::f32vector_elements(bits, o0);
-      uint8_t* u8out = pmt::u8vector_writable_elements(outvec, o0);
-
-      // loop over n fec blocks
-      for(int i = 0; i < nblocks; i++) {
-        size_t offset_in = i * blksize_in;
-        size_t offset_out = i * blksize_out;
-
-        // DECODE!
-        d_decoder->generic_work((void*)&f32in[offset_in], 
(void*)&u8out[offset_out]);
-      }
-
-      message_port_pub(pmt::mp("pdus"),  pmt::cons(meta, outvec));
-    }
-
-    int
-    async_decoder_impl::general_work(int noutput_items,
-                                     gr_vector_int& ninput_items,
-                                     gr_vector_const_void_star &input_items,
-                                     gr_vector_void_star &output_items)
-    {
-      return noutput_items;
-    }
-
-  } /* namespace fec */
-} /* namespace gr */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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 "async_decoder_impl.h"
+#include <gnuradio/io_signature.h>
+#include <stdio.h>
+
+
+namespace gr {
+  namespace fec {
+
+    async_decoder::sptr
+    async_decoder::make(generic_decoder::sptr my_decoder,
+                        size_t input_item_size, size_t output_item_size)
+    {
+      return gnuradio::get_initial_sptr
+        (new async_decoder_impl(my_decoder, input_item_size, 
output_item_size));
+    }
+
+    async_decoder_impl::async_decoder_impl(generic_decoder::sptr my_decoder,
+                                           size_t input_item_size,
+                                           size_t output_item_size)
+      : block("async_decoder",
+              io_signature::make(0,0,0),
+              io_signature::make(0,0,0)),
+        d_input_item_size(input_item_size), 
d_output_item_size(output_item_size)
+    {
+      d_decoder = my_decoder;
+      message_port_register_in(pmt::mp("in"));
+      message_port_register_out(pmt::mp("out"));
+      set_msg_handler(pmt::mp("pdus"), 
boost::bind(&async_decoder_impl::decode, this ,_1));
+    }
+
+    async_decoder_impl::~async_decoder_impl()
+    {
+    }
+
+    void
+    async_decoder_impl::decode(pmt::pmt_t msg)
+    {
+      // extract input pdu
+      pmt::pmt_t meta(pmt::car(msg));
+      pmt::pmt_t bits(pmt::cdr(msg));
+
+      int nbits = pmt::length(bits);
+      int blksize_in = d_decoder->get_input_size();
+      int blksize_out = d_decoder->get_output_size();
+      int nblocks = nbits/blksize_in;
+
+      // nbits sanity check
+      if(nbits % blksize_in != 0){
+        throw std::runtime_error((boost::format("nbits_in %% blksize_in != 0 
in fec_decoder_asyn! %d bits in, %d blksize") \
+                                  % nbits % blksize_in).str());
+      }
+
+      printf("decoder :: blksize_in = %d, blksize_out = %d\n", blksize_in, 
blksize_out);
+
+      pmt::pmt_t outvec(pmt::make_u8vector(blksize_out * nblocks, 0xFF));
+      printf("decoder :: outvec len = %d (%d blks)\n", blksize_out * nblocks, 
nblocks);
+
+      // get pmt buffer pointers
+      size_t o0(0);
+      const float* f32in = pmt::f32vector_elements(bits, o0);
+      uint8_t* u8out = pmt::u8vector_writable_elements(outvec, o0);
+
+      // loop over n fec blocks
+      for(int i = 0; i < nblocks; i++) {
+        size_t offset_in = i * blksize_in;
+        size_t offset_out = i * blksize_out;
+
+        // DECODE!
+        d_decoder->generic_work((void*)&f32in[offset_in], 
(void*)&u8out[offset_out]);
+      }
+
+      message_port_pub(pmt::mp("pdus"),  pmt::cons(meta, outvec));
+    }
+
+    int
+    async_decoder_impl::general_work(int noutput_items,
+                                     gr_vector_int& ninput_items,
+                                     gr_vector_const_void_star &input_items,
+                                     gr_vector_void_star &output_items)
+    {
+      return noutput_items;
+    }
+
+  } /* namespace fec */
+} /* namespace gr */
diff --git a/gr-fec/lib/async_decoder_impl.h b/gr-fec/lib/async_decoder_impl.h
index 9d1744c..5f4c5c4 100644
--- a/gr-fec/lib/async_decoder_impl.h
+++ b/gr-fec/lib/async_decoder_impl.h
@@ -1,55 +1,55 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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_FEC_ASYNC_DECODER_IMPL_H
-#define INCLUDED_FEC_ASYNC_DECODER_IMPL_H
-
-#include <gnuradio/fec/async_decoder.h>
-
-namespace gr {
-  namespace fec {
-
-    class FEC_API async_decoder_impl : public async_decoder
-    {
-    private:
-      generic_decoder::sptr d_decoder;
-      size_t d_input_item_size;
-      size_t d_output_item_size;
-
-      void decode(pmt::pmt_t msg);
-
-    public:
-      async_decoder_impl(generic_decoder::sptr my_decoder,
-                         size_t input_item_size,
-                         size_t output_item_size);
-      ~async_decoder_impl();
-
-      int general_work(int noutput_items,
-                       gr_vector_int& ninput_items,
-                       gr_vector_const_void_star &input_items,
-                       gr_vector_void_star &output_items);
-    };
-
-  } /* namespace fec */
-} /* namespace gr */
-
-#endif /* INCLUDED_FEC_ASYNC_DECODER_IMPL_H */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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_FEC_ASYNC_DECODER_IMPL_H
+#define INCLUDED_FEC_ASYNC_DECODER_IMPL_H
+
+#include <gnuradio/fec/async_decoder.h>
+
+namespace gr {
+  namespace fec {
+
+    class FEC_API async_decoder_impl : public async_decoder
+    {
+    private:
+      generic_decoder::sptr d_decoder;
+      size_t d_input_item_size;
+      size_t d_output_item_size;
+
+      void decode(pmt::pmt_t msg);
+
+    public:
+      async_decoder_impl(generic_decoder::sptr my_decoder,
+                         size_t input_item_size,
+                         size_t output_item_size);
+      ~async_decoder_impl();
+
+      int general_work(int noutput_items,
+                       gr_vector_int& ninput_items,
+                       gr_vector_const_void_star &input_items,
+                       gr_vector_void_star &output_items);
+    };
+
+  } /* namespace fec */
+} /* namespace gr */
+
+#endif /* INCLUDED_FEC_ASYNC_DECODER_IMPL_H */
diff --git a/gr-fec/lib/async_encoder_impl.cc b/gr-fec/lib/async_encoder_impl.cc
index b12ece1..6f9b54b 100644
--- a/gr-fec/lib/async_encoder_impl.cc
+++ b/gr-fec/lib/async_encoder_impl.cc
@@ -1,118 +1,125 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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 "async_encoder_impl.h"
-#include <gnuradio/io_signature.h>
-#include <stdio.h>
-
-namespace gr {
-  namespace fec {
-
-    async_encoder::sptr
-    async_encoder::make(generic_encoder::sptr my_encoder)
-    {
-      return gnuradio::get_initial_sptr
-        (new async_encoder_impl(my_encoder));
-    }
-
-    async_encoder_impl::async_encoder_impl(generic_encoder::sptr my_encoder)
-      : block("async_encoder",
-              io_signature::make(0,0,0),
-              io_signature::make(0,0,0)),
-        d_input_item_size(sizeof(char)), d_output_item_size(sizeof(char))
-    {
-      d_encoder = my_encoder;
-      message_port_register_in(pmt::mp("pdus"));
-      message_port_register_out(pmt::mp("pdus"));
-      set_msg_handler(pmt::mp("pdus"), 
boost::bind(&async_encoder_impl::encode, this ,_1) );
-    }
-
-    async_encoder_impl::~async_encoder_impl()
-    {
-    }
-
-    void
-    async_encoder_impl::encode(pmt::pmt_t msg)
-    {
-      // extract input pdu
-      pmt::pmt_t meta(pmt::car(msg));
-      pmt::pmt_t bits(pmt::cdr(msg));
-
-      int nbits = pmt::length(bits);
-      int blksize_in = d_encoder->get_input_size();
-      int blksize_out = (int)d_encoder->rate();
-      int nblocks = nbits/blksize_in;
-
-      printf("async_encoder: blksize_in = %d, blksize_out = %d nblocks=%d\n",
-             blksize_in, blksize_out, nblocks);
-
-      pmt::pmt_t outvec(pmt::make_u8vector(blksize_out * nblocks, 0xFF));
-
-      printf("encoder: outvec len = %d\n", blksize_out * nblocks);
-
-      // get pmt buffer pointers
-      size_t o0(0);
-      const uint8_t* u8in = pmt::u8vector_elements(bits,o0);
-      uint8_t* u8tmp = pmt::u8vector_writable_elements(bits,o0);
-      uint8_t* u8out = pmt::u8vector_writable_elements(outvec,o0);
-
-      // alloc playspace
-      std::vector<uint8_t> blks_out(blksize_out);
-
-      // loop over n fec blocks
-      for(int i = 0; i < nblocks; i++) {
-        size_t offset_in = i * blksize_in;
-        size_t offset_out = i * blksize_out;
-
-        for(int jj = 0; jj < blksize_in; jj++) {
-          u8tmp[offset_in + jj] = 0x01 & u8in[offset_in + jj];
-          //printf("in[%zd]=%u ", offset_in+jj, u8tmp[offset_in + jj]);
-          //fflush(stdout);
-        }
-
-        // ENCODE!
-        d_encoder->generic_work((void*)&u8tmp[offset_in], (void*)&blks_out[0]);
-
-        // convert float -> u8
-        for(int j = 0; j < blksize_out; j++) {
-          u8out[offset_out + j] = (blks_out[j] > 0);
-        }
-      }
-
-      message_port_pub(pmt::mp("pdus"), pmt::cons(meta, outvec));
-    }
-
-    int
-    async_encoder_impl::general_work(int noutput_items,
-                                     gr_vector_int& ninput_items,
-                                     gr_vector_const_void_star &input_items,
-                                     gr_vector_void_star &output_items)
-    {
-      return noutput_items;
-    }
-
-  } /* namespace fec */
-} /* namespace gr */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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 "async_encoder_impl.h"
+#include <gnuradio/io_signature.h>
+#include <volk/volk.h>
+#include <stdio.h>
+
+namespace gr {
+  namespace fec {
+
+    async_encoder::sptr
+    async_encoder::make(generic_encoder::sptr my_encoder)
+    {
+      return gnuradio::get_initial_sptr
+        (new async_encoder_impl(my_encoder));
+    }
+
+    async_encoder_impl::async_encoder_impl(generic_encoder::sptr my_encoder)
+      : block("async_encoder",
+              io_signature::make(0,0,0),
+              io_signature::make(0,0,0)),
+        d_input_item_size(sizeof(char)), d_output_item_size(sizeof(char))
+    {
+      d_in_port = pmt::mp("in");
+      d_out_port = pmt::mp("out");
+
+      d_encoder = my_encoder;
+      message_port_register_in(d_in_port);
+      message_port_register_out(d_out_port);
+      set_msg_handler(d_in_port, boost::bind(&async_encoder_impl::encode, this 
,_1) );
+    }
+
+    async_encoder_impl::~async_encoder_impl()
+    {
+    }
+
+    void
+    async_encoder_impl::encode(pmt::pmt_t msg)
+    {
+      // extract input pdu
+      pmt::pmt_t meta(pmt::car(msg));
+      pmt::pmt_t bytes(pmt::cdr(msg));
+
+      int nbytes = pmt::length(bytes);
+      int nbits = 8*nbytes;
+      size_t o0(0);
+      const uint8_t* bytes_in = pmt::u8vector_elements(bytes, o0);
+      uint8_t* bits_in = (uint8_t*)volk_malloc(nbits*sizeof(uint8_t),
+                                               volk_get_alignment());
+
+      // Stolen from unpack_k_bits
+      int n = 0;
+      for(int i = 0; i < nbytes; i++) {
+        uint8_t t = bytes_in[i];
+        for(int j = 7; j >= 0; j--)
+          bits_in[n++] = (t >> j) & 0x01;
+      }
+
+      d_encoder->set_frame_size(nbits);
+
+      int nbits_out = d_encoder->get_output_size();
+      int nbytes_out = nbits_out/8;
+
+      // get pmt buffer pointers
+      uint8_t* bits_out = (uint8_t*)volk_malloc(nbits_out*sizeof(uint8_t),
+                                                volk_get_alignment());
+      uint8_t* bytes_out = (uint8_t*)volk_malloc(nbytes_out*sizeof(uint8_t),
+                                                 volk_get_alignment());
+
+      // ENCODE!
+      d_encoder->generic_work((void*)bits_in, (void*)bits_out);
+
+      // Stolen from pack_k_bits
+      for(int i = 0; i < nbytes_out; i++) {
+        bytes_out[i] = 0x00;
+        for(int j = 0; j < 8; j++) {
+          bytes_out[i] |= (0x01 & bits_out[i*8+j])<<(8-j-1);
+        }
+      }
+
+      //pmt::pmt_t outvec = pmt::init_u8vector(nouts, u8out);
+      pmt::pmt_t outvec = pmt::init_u8vector(nbytes_out, bytes_out);
+      pmt::pmt_t msg_pair = pmt::cons(meta, outvec);
+      message_port_pub(d_out_port, msg_pair);
+
+      volk_free(bits_in);
+      volk_free(bits_out);
+      volk_free(bytes_out);
+    }
+
+    int
+    async_encoder_impl::general_work(int noutput_items,
+                                     gr_vector_int& ninput_items,
+                                     gr_vector_const_void_star &input_items,
+                                     gr_vector_void_star &output_items)
+    {
+      return noutput_items;
+    }
+
+  } /* namespace fec */
+} /* namespace gr */
diff --git a/gr-fec/lib/async_encoder_impl.h b/gr-fec/lib/async_encoder_impl.h
index 99b628c..38ae685 100644
--- a/gr-fec/lib/async_encoder_impl.h
+++ b/gr-fec/lib/async_encoder_impl.h
@@ -1,53 +1,56 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 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_FEC_ASYNC_ENCODER_IMPL_H
-#define INCLUDED_FEC_ASYNC_ENCODER_IMPL_H
-
-#include <gnuradio/fec/async_encoder.h>
-
-namespace gr {
-  namespace fec {
-
-    class FEC_API async_encoder_impl : public async_encoder
-    {
-    private:
-      generic_encoder::sptr d_encoder;
-      size_t d_input_item_size;
-      size_t d_output_item_size;
-
-      void encode(pmt::pmt_t msg);
-
-    public:
-      async_encoder_impl(generic_encoder::sptr my_encoder);
-      ~async_encoder_impl();
-
-      int general_work(int noutput_items,
-                       gr_vector_int& ninput_items,
-                       gr_vector_const_void_star &input_items,
-                       gr_vector_void_star &output_items);
-    };
-
-  } /* namespace fec */
-} /* namespace gr */
-
-#endif /* INCLUDED_FEC_ASYNC_ENCODER_IMPL_H */
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 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_FEC_ASYNC_ENCODER_IMPL_H
+#define INCLUDED_FEC_ASYNC_ENCODER_IMPL_H
+
+#include <gnuradio/fec/async_encoder.h>
+
+namespace gr {
+  namespace fec {
+
+    class FEC_API async_encoder_impl : public async_encoder
+    {
+    private:
+      generic_encoder::sptr d_encoder;
+      size_t d_input_item_size;
+      size_t d_output_item_size;
+
+      pmt::pmt_t d_in_port;
+      pmt::pmt_t d_out_port;
+
+      void encode(pmt::pmt_t msg);
+
+    public:
+      async_encoder_impl(generic_encoder::sptr my_encoder);
+      ~async_encoder_impl();
+
+      int general_work(int noutput_items,
+                       gr_vector_int& ninput_items,
+                       gr_vector_const_void_star &input_items,
+                       gr_vector_void_star &output_items);
+    };
+
+  } /* namespace fec */
+} /* namespace gr */
+
+#endif /* INCLUDED_FEC_ASYNC_ENCODER_IMPL_H */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]