From d6a4257565bd47c4a93ffcc06c67eba9c3426730 Mon Sep 17 00:00:00 2001 From: Mathias Coinchon Date: Mon, 7 Mar 2016 22:26:13 +0100 Subject: Fix subchannel extraction Frame aligned suchannel export, flush erroneous frames --- dabplussnoop.cpp | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'dabplussnoop.cpp') diff --git a/dabplussnoop.cpp b/dabplussnoop.cpp index eb79e15..5ee556e 100644 --- a/dabplussnoop.cpp +++ b/dabplussnoop.cpp @@ -19,6 +19,7 @@ Authors: Matthias P. Braendli + Mathias Coinchon */ #include @@ -45,20 +46,6 @@ using namespace std; void DabPlusSnoop::push(uint8_t* streamdata, size_t streamsize) { - // First dump to file - if (m_raw_data_stream_fd == NULL) { - stringstream dump_filename; - dump_filename << "stream-" << m_index << ".msc"; - - m_raw_data_stream_fd = fopen(dump_filename.str().c_str(), "w"); - - if (m_raw_data_stream_fd == NULL) { - perror("File open failed"); - } - } - - fwrite(streamdata, 1, streamsize, m_raw_data_stream_fd); - // Try to decode audio size_t original_size = m_data.size(); m_data.resize(original_size + streamsize); @@ -66,9 +53,25 @@ void DabPlusSnoop::push(uint8_t* streamdata, size_t streamsize) if (seek_valid_firecode()) { // m_data now points to a valid header + if (decode()) { - // We have been able to decode the AUs - m_data.erase(m_data.begin(), m_data.begin() + m_subchannel_index * 120); + + // First dump to subchannel file (superframe+parity word) + if (m_raw_data_stream_fd == NULL) { + stringstream dump_filename; + dump_filename << "stream-" << m_index << ".msc"; + + m_raw_data_stream_fd = fopen(dump_filename.str().c_str(), "w"); + + if (m_raw_data_stream_fd == NULL) { + perror("File open failed"); + } + } + + fwrite(&m_data[0], m_subchannel_index, 120, m_raw_data_stream_fd); + + // We have been able to decode the AUs, now flush vector + m_data.clear(); } } } @@ -104,7 +107,7 @@ bool DabPlusSnoop::seek_valid_firecode() #if DPS_DEBUG printf(DPS_PREFIX " Found valid FireCode at %zu\n", i); #endif - + //erase elements before the header m_data.erase(m_data.begin(), m_data.begin() + i); return true; } @@ -288,6 +291,8 @@ bool DabPlusSnoop::extract_au(vector au_start) return analyse_au(aus); } else { + //discard faulty superframe (to be improved to correct/conceal) + m_data.clear(); return false; } } -- cgit v1.2.3