summaryrefslogtreecommitdiffstats
path: root/src/PuncturingEncoder.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-12 17:51:48 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-02-12 17:51:48 +0100
commit6eb9a403558d4dfde1de36e5c6744b58dc26ea79 (patch)
tree60f35619167d007ab7ef3a3af3573d3a9c8e8501 /src/PuncturingEncoder.cpp
parente659399f872832552a5fdae02e70f4579f0e266e (diff)
downloaddabmod-6eb9a403558d4dfde1de36e5c6744b58dc26ea79.tar.gz
dabmod-6eb9a403558d4dfde1de36e5c6744b58dc26ea79.tar.bz2
dabmod-6eb9a403558d4dfde1de36e5c6744b58dc26ea79.zip
Fix incorrect frame size bug due to missing puncturing padding
Diffstat (limited to 'src/PuncturingEncoder.cpp')
-rw-r--r--src/PuncturingEncoder.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/PuncturingEncoder.cpp b/src/PuncturingEncoder.cpp
index a212a93..9bd9004 100644
--- a/src/PuncturingEncoder.cpp
+++ b/src/PuncturingEncoder.cpp
@@ -35,12 +35,23 @@
PuncturingEncoder::PuncturingEncoder() :
ModCodec(),
+ d_num_cu(0),
d_in_block_size(0),
d_out_block_size(0),
d_tail_rule()
{
PDEBUG("PuncturingEncoder() @ %p\n", this);
+}
+PuncturingEncoder::PuncturingEncoder(
+ size_t num_cu) :
+ ModCodec(),
+ d_num_cu(num_cu),
+ d_in_block_size(0),
+ d_out_block_size(0),
+ d_tail_rule()
+{
+ PDEBUG("PuncturingEncoder(%zu) @ %p\n", num_cu, this);
}
void PuncturingEncoder::adjust_item_size()
@@ -104,12 +115,29 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
PDEBUG(" in block size: %zu\n", d_in_block_size);
PDEBUG(" out block size: %zu\n", d_out_block_size);
+ if (d_num_cu > 0) {
+ if (d_num_cu * 8 == d_out_block_size + 1) {
+ /* EN 300 401 Table 31 in 11.3.1 UEP coding specifies
+ * that we need one byte of padding
+ */
+ d_out_block_size = d_num_cu * 8;
+ }
+
+ if (d_num_cu * 8 != d_out_block_size) {
+ throw std::runtime_error(
+ "PuncturingEncoder encoder initialisation failed. "
+ " CU: " + std::to_string(d_num_cu) +
+ " block_size: " + std::to_string(d_out_block_size));
+ }
+ }
+
dataOut->setLength(d_out_block_size);
const unsigned char* in = reinterpret_cast<const unsigned char*>(dataIn->getData());
unsigned char* out = reinterpret_cast<unsigned char*>(dataOut->getData());
if (dataIn->getLength() != d_in_block_size) {
- throw std::runtime_error("PuncturingEncoder::process wrong input size");
+ throw std::runtime_error(
+ "PuncturingEncoder::process wrong input size");
}
if (d_tail_rule) {
@@ -167,7 +195,8 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
++out_count;
}
}
- for (size_t i = d_out_block_size; i < dataOut->getLength(); ++i) {
+
+ for (size_t i = out_count; i < dataOut->getLength(); ++i) {
out[out_count++] = 0;
}