From 4ee1e821f2ea6d7cd3c30d6cff2e631bc7f89dfd Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 3 Feb 2017 14:47:37 +0100 Subject: Make EDI fragment interleaver less bursty --- src/DabMultiplexer.cpp | 5 +++++ src/dabOutput/edi/Interleaver.cpp | 14 +++++++++++--- src/dabOutput/edi/Interleaver.h | 5 +++++ 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 97336d1..a86a1c7 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -716,6 +716,11 @@ void DabMultiplexer::mux_frame(std::vector >& outputs // Apply PFT layer to AF Packet (Reed Solomon FEC and Fragmentation) vector edi_fragments = edi_pft.Assemble(edi_afpacket); + if (edi_conf.verbose) { + fprintf(stderr, "EDI number of PFT fragment before interleaver %zu\n", + edi_fragments.size()); + } + if (edi_conf.interleaver_enabled()) { edi_fragments = edi_interleaver.Interleave(edi_fragments); } diff --git a/src/dabOutput/edi/Interleaver.cpp b/src/dabOutput/edi/Interleaver.cpp index 810e76f..e31326b 100644 --- a/src/dabOutput/edi/Interleaver.cpp +++ b/src/dabOutput/edi/Interleaver.cpp @@ -64,8 +64,6 @@ Interleaver::fragment_vec Interleaver::Interleave(fragment_vec &fragments) fragments.clear(); - std::vector interleaved_frags; - while ( not m_buffer.empty() and (m_buffer.front().size() >= m_fragment_count * m_latency)) { @@ -89,7 +87,7 @@ Interleaver::fragment_vec Interleaver::Interleave(fragment_vec &fragments) for (size_t i = 0; i < m_fragment_count; i++) { const size_t ix = m_interleave_offset + m_fragment_count * m_stride; - interleaved_frags.push_back(first_buffer.at(ix)); + m_interleaved_fragments.push_back(first_buffer.at(ix)); m_stride += 1; if (m_stride >= m_latency) { @@ -105,6 +103,16 @@ Interleaver::fragment_vec Interleaver::Interleave(fragment_vec &fragments) } } + std::vector interleaved_frags; + + const size_t n = std::min(m_fragment_count, m_interleaved_fragments.size()); + std::move(m_interleaved_fragments.begin(), + m_interleaved_fragments.begin() + n, + std::back_inserter(interleaved_frags)); + m_interleaved_fragments.erase( + m_interleaved_fragments.begin(), + m_interleaved_fragments.begin() + n); + return interleaved_frags; } diff --git a/src/dabOutput/edi/Interleaver.h b/src/dabOutput/edi/Interleaver.h index f94219e..f1cff30 100644 --- a/src/dabOutput/edi/Interleaver.h +++ b/src/dabOutput/edi/Interleaver.h @@ -64,6 +64,11 @@ class Interleaver { /* Buffer that accumulates enough fragments to interleave */ std::deque m_buffer; + + /* Buffer that contains fragments that have been interleaved, + * to avoid that the interleaver output is too bursty + */ + std::deque m_interleaved_fragments; }; } -- cgit v1.2.3