commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 18/43: fec: ldpc works, add iterations meta


From: git
Subject: [Commit-gnuradio] [gnuradio] 18/43: fec: ldpc works, add iterations meta tag, etc
Date: Thu, 2 Apr 2015 19:15:51 +0000 (UTC)

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

jcorgan pushed a commit to branch master
in repository gnuradio.

commit cc1124dcee3043649062bbf1e08a8d313e12a08e
Author: Tim O'Shea <address@hidden>
Date:   Wed Apr 1 17:01:20 2015 -0700

    fec: ldpc works, add iterations meta tag, etc
---
 gr-fec/include/gnuradio/fec/generic_decoder.h | 9 +++++++++
 gr-fec/include/gnuradio/fec/ldpc_decoder.h    | 4 +++-
 gr-fec/lib/async_decoder_impl.cc              | 5 ++++-
 gr-fec/lib/ldpc_decoder.cc                    | 3 +++
 gr-fec/lib/ldpc_encoder.cc                    | 2 ++
 5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/gr-fec/include/gnuradio/fec/generic_decoder.h 
b/gr-fec/include/gnuradio/fec/generic_decoder.h
index 0e14d49..bfce85a 100644
--- a/gr-fec/include/gnuradio/fec/generic_decoder.h
+++ b/gr-fec/include/gnuradio/fec/generic_decoder.h
@@ -210,6 +210,15 @@ namespace gr {
        * behavior. It should also provide bounds checks.
        */
       virtual bool set_frame_size(unsigned int frame_size) = 0;
+      
+
+      /*!
+       * Get repetitions to decode.
+       *
+       * The child class should implement this function and return the
+       * number of iterations required to decode.
+       */
+      virtual float get_iterations(){ return -1; }
     };
 
     /*! see generic_decoder::get_output_size() */
diff --git a/gr-fec/include/gnuradio/fec/ldpc_decoder.h 
b/gr-fec/include/gnuradio/fec/ldpc_decoder.h
index 705bbab..02cf12d 100644
--- a/gr-fec/include/gnuradio/fec/ldpc_decoder.h
+++ b/gr-fec/include/gnuradio/fec/ldpc_decoder.h
@@ -50,7 +50,7 @@ class FEC_API ldpc_decoder : public generic_decoder {
        float get_shift();
        const char* get_conversion();
     void generic_work(void *inBuffer, void *outbuffer);
-
+    float d_iterations;
     int inputSize, outputSize;
 
       alist d_list;
@@ -69,6 +69,8 @@ class FEC_API ldpc_decoder : public generic_decoder {
     int get_input_size();
        int get_input_item_size();
        int get_output_item_size();
+    float get_iterations(){ return d_iterations; }
+
 };
 
 }
diff --git a/gr-fec/lib/async_decoder_impl.cc b/gr-fec/lib/async_decoder_impl.cc
index 3044a2c..2cdea6a 100644
--- a/gr-fec/lib/async_decoder_impl.cc
+++ b/gr-fec/lib/async_decoder_impl.cc
@@ -145,6 +145,8 @@ namespace gr {
         volk_32f_s32f_multiply_32f(d_tmp_f32, f32in, 48.0f, nbits_in);
       }
       else {
+
+        // grow d_tmp_f32 if needed
         if(nbits_in > d_max_bits_in){
             d_max_bits_in = nbits_in;
             volk_free(d_tmp_f32);
@@ -168,10 +170,11 @@ namespace gr {
       }
       else {
         for(size_t i=0; i<nblocks; i++){
-          d_decoder->generic_work((void*)d_tmp_f32, (void*)u8out);
+          
d_decoder->generic_work((void*)&d_tmp_f32[i*d_decoder->get_input_size()], 
(void*)&u8out[i*d_decoder->get_output_size()]);
           }
       }
 
+      meta = pmt::dict_add(meta, pmt::mp("iterations"), 
pmt::mp(d_decoder->get_iterations()) );
       message_port_pub(d_out_port, pmt::cons(meta, outvec));
     }
 
diff --git a/gr-fec/lib/ldpc_decoder.cc b/gr-fec/lib/ldpc_decoder.cc
index 3f545ed..066024c 100644
--- a/gr-fec/lib/ldpc_decoder.cc
+++ b/gr-fec/lib/ldpc_decoder.cc
@@ -45,6 +45,8 @@ ldpc_decoder::make(std::string alist_file, float sigma, int 
max_iterations)
 ldpc_decoder::ldpc_decoder (std::string alist_file, float sigma, int 
max_iterations)
     : generic_decoder("ldpc_decoder")
 {
+        if(!boost::filesystem::exists( alist_file ))
+            throw std::runtime_error("Bad AList file name!");
         d_list.read(alist_file.c_str());
         d_code.set_alist(d_list);
         d_spa.set_alist_sigma(d_list, sigma);
@@ -73,6 +75,7 @@ void ldpc_decoder::generic_work(void *inBuffer, void 
*outBuffer) {
     std::vector<char> estimate( d_spa.decode(rx, &n_iterations) );   
     std::vector<char> data( d_code.get_systematic_bits(estimate) );
     memcpy(out, &data[0], outputSize);
+    d_iterations = n_iterations;
 }
 
 int ldpc_decoder::get_input_item_size() {
diff --git a/gr-fec/lib/ldpc_encoder.cc b/gr-fec/lib/ldpc_encoder.cc
index a181c28..813715a 100755
--- a/gr-fec/lib/ldpc_encoder.cc
+++ b/gr-fec/lib/ldpc_encoder.cc
@@ -41,6 +41,8 @@ ldpc_encoder::make(std::string alist_file)
 
 ldpc_encoder::ldpc_encoder (std::string alist_file)
 {
+    if(!boost::filesystem::exists( alist_file ))
+        throw std::runtime_error("Bad AList file name!");
     d_list.read(alist_file.c_str());
     d_code.set_alist(d_list);
     inputSize = d_code.dimension();



reply via email to

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