commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 15/43: fec: ldpc encoder now working in asy


From: git
Subject: [Commit-gnuradio] [gnuradio] 15/43: fec: ldpc encoder now working in async encoder interface
Date: Thu, 2 Apr 2015 19:15:50 +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 ef9b37cb05411a8cbfcaa05495b22329c3b913b9
Author: Tim O'Shea <address@hidden>
Date:   Wed Apr 1 13:46:18 2015 -0700

    fec: ldpc encoder now working in async encoder interface
---
 gr-fec/lib/async_encoder_impl.cc | 20 +++++++++++++++++---
 gr-fec/lib/ldpc_encoder.cc       |  4 ++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gr-fec/lib/async_encoder_impl.cc b/gr-fec/lib/async_encoder_impl.cc
index d6ce67d..106ad25 100644
--- a/gr-fec/lib/async_encoder_impl.cc
+++ b/gr-fec/lib/async_encoder_impl.cc
@@ -110,9 +110,21 @@ namespace gr {
       int nbits_in = pmt::length(bits);
       const uint8_t* bits_in = pmt::u8vector_elements(bits, o0);
 
-      d_encoder->set_frame_size(nbits_in);
+      bool variable_framesize = d_encoder->set_frame_size(nbits_in);
+      size_t nbits_out = 0;
+      size_t nblocks = 1;
+      if( variable_framesize ){
+        nbits_out = d_encoder->get_output_size();
+        } else {
+        nblocks = nbits_in / d_encoder->get_input_size();
+        if( nblocks * d_encoder->get_input_size() != nbits_in ){
+            printf("nblocks: %d, in_block_size: %d, got_input_size: %d\n",
+                nblocks, d_encoder->get_input_size(), nbits_in);
+            throw std::runtime_error("input does not divide into code block 
size!");
+            }
+        nbits_out = nblocks * d_encoder->get_output_size();
+        }
 
-      int nbits_out = d_encoder->get_output_size();
 
       // buffers for output bits to go to
       pmt::pmt_t outvec = pmt::make_u8vector(nbits_out, 0x00);
@@ -123,7 +135,9 @@ namespace gr {
         d_encoder->generic_work((void*)d_bits_in, (void*)bits_out);
       }
       else {
-        d_encoder->generic_work((void*)bits_in, (void*)bits_out);
+        for(size_t i=0; i<nblocks; i++){
+            d_encoder->generic_work((void*) 
&bits_in[i*d_encoder->get_input_size()], 
(void*)&bits_out[i*d_encoder->get_output_size()]);
+            }
       }
 
       pmt::pmt_t msg_pair = pmt::cons(meta, outvec);
diff --git a/gr-fec/lib/ldpc_encoder.cc b/gr-fec/lib/ldpc_encoder.cc
index e25eade..a181c28 100755
--- a/gr-fec/lib/ldpc_encoder.cc
+++ b/gr-fec/lib/ldpc_encoder.cc
@@ -58,11 +58,11 @@ int ldpc_encoder::get_input_size() {
 
 void ldpc_encoder::generic_work(void *inBuffer, void *outBuffer) {
     const unsigned char *in = (const unsigned char *) inBuffer;
-    float *out = (float *) outBuffer;
+    unsigned char *out = (unsigned char *) outBuffer;
     std::vector<char> inbuf(inputSize);
     memcpy(&inbuf[0], in, inputSize);
     std::vector<char> coded(d_code.encode(inbuf));
-    for(size_t i=0; i<coded.size();i++){ out[i] = coded[i]; }
+    memcpy(&out[0], &coded[0], coded.size());
 }
 
 



reply via email to

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