aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-05-14 10:09:35 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-05-14 10:09:35 +0200
commit1a10e4cf82ff9082a84f81f3feadfceb528e08eb (patch)
tree0855564b702780680b2292debf1c428e9591aff3 /src
parentcc4cac79ada4adf808bd09417942a995530c3a69 (diff)
downloadetisnoop-1a10e4cf82ff9082a84f81f3feadfceb528e08eb.tar.gz
etisnoop-1a10e4cf82ff9082a84f81f3feadfceb528e08eb.tar.bz2
etisnoop-1a10e4cf82ff9082a84f81f3feadfceb528e08eb.zip
Add some more changes to subchannel extraction
Diffstat (limited to 'src')
-rw-r--r--src/dabplussnoop.cpp13
-rw-r--r--src/dabplussnoop.hpp30
-rw-r--r--src/etianalyse.cpp18
-rw-r--r--src/etisnoop.cpp6
4 files changed, 25 insertions, 42 deletions
diff --git a/src/dabplussnoop.cpp b/src/dabplussnoop.cpp
index 8fe40c1..3e55072 100644
--- a/src/dabplussnoop.cpp
+++ b/src/dabplussnoop.cpp
@@ -133,8 +133,8 @@ bool DabPlusSnoop::decode()
return false;
}
else if (rs_errors > 0) {
- printf("RS Decoder for stream %d: %d corrected errors\n",
- m_index, rs_errors);
+ printf("RS Decoder for subchannel %d: %d corrected errors\n",
+ subchid, rs_errors);
}
// -- Parse he_aac_super_frame
@@ -300,7 +300,7 @@ bool DabPlusSnoop::analyse_au(vector<vector<uint8_t> >& aus)
stringstream ss_filename;
if (m_write_to_wav_file) {
- ss_filename << "stream-" << m_index;
+ ss_filename << "stream-" << subchid;
}
if (!m_faad_decoder.is_initialised()) {
@@ -315,7 +315,6 @@ bool DabPlusSnoop::analyse_au(vector<vector<uint8_t> >& aus)
StreamSnoop::StreamSnoop(StreamSnoop&& other)
{
dps = move(other.dps);
- m_index = other.m_index;
m_raw_data_stream_fd = other.m_raw_data_stream_fd;
other.m_raw_data_stream_fd = nullptr;
m_dump_to_file = other.m_dump_to_file;
@@ -331,14 +330,14 @@ StreamSnoop::~StreamSnoop()
void StreamSnoop::push(uint8_t* streamdata, size_t streamsize)
{
- if (m_index == -1) {
- throw std::runtime_error("StreamSnoop not properly initialised");
+ if (subchid == -1) {
+ throw logic_error("StreamSnoop not properly initialised");
}
// First dump to subchannel file (superframe+parity word)
if (m_dump_to_file and m_raw_data_stream_fd == nullptr) {
stringstream dump_filename;
- dump_filename << "stream-" << m_index << ".dab";
+ dump_filename << "stream-" << subchid << ".dab";
m_raw_data_stream_fd = fopen(dump_filename.str().c_str(), "w");
diff --git a/src/dabplussnoop.hpp b/src/dabplussnoop.hpp
index b62d94d..cc91f46 100644
--- a/src/dabplussnoop.hpp
+++ b/src/dabplussnoop.hpp
@@ -81,8 +81,7 @@ he_aac_super_frame(subchannel_index)
#pragma once
// DabPlusSnoop is responsible for decoding DAB+ audio
-class DabPlusSnoop
-{
+class DabPlusSnoop {
public:
void set_subchannel_index(unsigned subchannel_index) {
m_subchannel_index = subchannel_index;
@@ -92,18 +91,15 @@ class DabPlusSnoop
m_write_to_wav_file = enable;
}
- void set_index(int index) {
- m_index = index;
- }
-
void push(uint8_t* streamdata, size_t streamsize);
audio_statistics_t get_audio_statistics(void) const;
+ int subchid = -1;
+
private:
/* Data needed for FAAD */
FaadDecoder m_faad_decoder;
- int m_index = -1;
bool m_write_to_wav_file = false;
bool m_ps_flag = false;
@@ -125,14 +121,13 @@ class DabPlusSnoop
// StreamSnoop is responsible for saving msc data into files,
// and calling DabPlusSnoop's decode routine if it's a DAB+ subchannel
-class StreamSnoop
-{
+class StreamSnoop {
public:
- StreamSnoop(bool dump_to_file) :
+ StreamSnoop(int subchid, bool dump_to_file) :
dps(),
- m_index(-1),
m_raw_data_stream_fd(nullptr),
m_dump_to_file(dump_to_file) {
+ dps.subchid = subchid;
dps.enable_wav_file_output(dump_to_file);
}
~StreamSnoop();
@@ -146,24 +141,15 @@ class StreamSnoop
dps.set_subchannel_index(subchannel_index);
}
- void set_index(int index) {
- m_index = index;
- dps.set_index(index);
- }
-
- int get_index() const {
- return m_index;
- }
-
void push(uint8_t* streamdata, size_t streamsize);
audio_statistics_t get_audio_statistics(void) const;
- uint32_t subchid;
+ int subchid = -1;
+ int stream_index = -1;
private:
DabPlusSnoop dps;
- int m_index;
FILE* m_raw_data_stream_fd;
bool m_dump_to_file;
};
diff --git a/src/etianalyse.cpp b/src/etianalyse.cpp
index d477c0e..fa3f297 100644
--- a/src/etianalyse.cpp
+++ b/src/etianalyse.cpp
@@ -392,14 +392,12 @@ void ETI_Analyser::eti_analyse()
if (config.statistics and config.streams_to_decode.count(scid) == 0) {
config.streams_to_decode.emplace(std::piecewise_construct,
std::make_tuple(scid),
- std::make_tuple(false)); // do not dump to file
- config.streams_to_decode.at(scid).subchid = scid;
+ std::make_tuple(scid, false)); // do not dump to file
}
if (config.streams_to_decode.count(scid) > 0) {
config.streams_to_decode.at(scid).set_subchannel_index(stl[i]/3);
- config.streams_to_decode.at(scid).set_index(i);
- config.streams_to_decode.at(scid).subchid = scid;
+ config.streams_to_decode.at(scid).stream_index = i;
}
}
@@ -500,21 +498,21 @@ void ETI_Analyser::eti_analyse()
printvalue("Id", 3, "", to_string(i));
printvalue("Length", 3, "", to_string(stl[i]*8));
- int subch_ix = -1;
+ int subchid = -1;
for (const auto& el : config.streams_to_decode) {
- if (el.second.get_index() == i) {
- subch_ix = el.first;
+ if (el.second.stream_index == i) {
+ subchid = el.first;
break;
}
}
- printvalue("Selected for decoding", 3, "", (subch_ix == -1 ? "false" : "true"));
+ printvalue("Selected for decoding", 3, "", (subchid == -1 ? "false" : "true"));
if (get_verbosity() > 1) {
printbuf("Data", 3, streamdata, stl[i]*8);
}
- if (subch_ix != -1) {
- config.streams_to_decode.at(subch_ix).push(streamdata, stl[i]*8);
+ if (subchid != -1) {
+ config.streams_to_decode.at(subchid).push(streamdata, stl[i]*8);
}
}
diff --git a/src/etisnoop.cpp b/src/etisnoop.cpp
index 13239e5..ce2f27a 100644
--- a/src/etisnoop.cpp
+++ b/src/etisnoop.cpp
@@ -138,10 +138,10 @@ int main(int argc, char *argv[])
switch (ch) {
case 'd':
{
- int subchix = atoi(optarg);
+ int subchid = atoi(optarg);
config.streams_to_decode.emplace(std::piecewise_construct,
- std::make_tuple(subchix),
- std::make_tuple(true)); // dump to file
+ std::make_tuple(subchid),
+ std::make_tuple(subchid, true)); // dump to file
}
break;
case 'e':