diff options
author | Tim O'Shea <tim.oshea753@gmail.com> | 2015-04-01 17:01:20 -0700 |
---|---|---|
committer | Tim O'Shea <tim.oshea753@gmail.com> | 2015-04-01 17:01:20 -0700 |
commit | cc1124dcee3043649062bbf1e08a8d313e12a08e (patch) | |
tree | 07fe084c7cd2097ef5dcb7fa48f53c224cd7fea4 | |
parent | 1bd6282cc2523b6f149abf66946ead0309632a4a (diff) |
fec: ldpc works, add iterations meta tag, etc
-rw-r--r-- | gr-fec/include/gnuradio/fec/generic_decoder.h | 9 | ||||
-rw-r--r-- | gr-fec/include/gnuradio/fec/ldpc_decoder.h | 4 | ||||
-rw-r--r-- | gr-fec/lib/async_decoder_impl.cc | 5 | ||||
-rw-r--r-- | gr-fec/lib/ldpc_decoder.cc | 3 | ||||
-rwxr-xr-x | 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 0e14d49e76..bfce85a8c1 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 705bbabc15..02cf12d585 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 3044a2cdf8..2cdea6a1a6 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 3f545eda34..066024c9e0 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 a181c28c3e..813715a06b 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(); |