aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-31 21:20:54 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-31 21:20:54 +0200
commit36d70772c7ba15bf1d769f7ec54ba129377f4617 (patch)
treebce00b35aaaa0c68ae879230b98519075abd2358
parentb977fd4673c92fc264450d66f2f23fbd5ee04aef (diff)
downloadetisnoop-36d70772c7ba15bf1d769f7ec54ba129377f4617.tar.gz
etisnoop-36d70772c7ba15bf1d769f7ec54ba129377f4617.tar.bz2
etisnoop-36d70772c7ba15bf1d769f7ec54ba129377f4617.zip
Add faadalyse
-rw-r--r--.gitignore1
-rw-r--r--Makefile.faadalyse42
-rw-r--r--README.md20
-rw-r--r--src/dabplussnoop.cpp15
-rw-r--r--src/faadalyse.cpp94
5 files changed, 163 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 9541182..9442588 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
etisnoop
+faadalyse
faad2-2.7
tags
autom4te.cache
diff --git a/Makefile.faadalyse b/Makefile.faadalyse
new file mode 100644
index 0000000..449074a
--- /dev/null
+++ b/Makefile.faadalyse
@@ -0,0 +1,42 @@
+CC=gcc
+CXX=g++
+CFLAGS = -Wall -g
+CXXFLAGS = -Wall -g --std=c++11 -DDPS_DEBUG=1
+SOURCES = src/dabplussnoop.cpp \
+ src/faadalyse.cpp \
+ src/faad_decoder.cpp \
+ src/rsdecoder.cpp
+
+CSOURCES = src/firecode.c \
+ src/lib_crc.c \
+ src/wavfile.c \
+ src/fec/decode_rs_char.c \
+ src/fec/encode_rs_char.c \
+ src/fec/init_rs_char.c
+
+HEADERS = src/dabplussnoop.hpp \
+ src/faad_decoder.hpp \
+ src/firecode.h \
+ src/lib_crc.h \
+ src/rsdecoder.hpp \
+ src/wavfile.h \
+ src/fec/char.h \
+ src/fec/decode_rs.h \
+ src/fec/encode_rs.h \
+ src/fec/fec.h \
+ src/fec/init_rs.h \
+ src/fec/rs-common.h
+
+
+all: faadalyse
+
+faadalyse: libfaad $(SOURCES) $(CSOURCES) $(HEADERS)
+ $(CXX) $(CXXFLAGS) $(SOURCES) -Ifaad2-2.7/include -c
+ $(CC) $(CFLAGS) $(CSOURCES) -c
+ $(CXX) *.o faad2-2.7/libfaad/.libs/libfaad.a -o faadalyse
+
+libfaad:
+ make -C ./faad2-2.7
+
+clean:
+ rm -f faadalyse *.o
diff --git a/README.md b/README.md
index 943e23a..98bf18e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
ETISnoop analyser
=================
-The ETSnoop analyser decodes and prints out a RAW ETI file in a
+The ETISnoop analyser decodes and prints out a RAW ETI file in a
form that makes analysis easier.
It can show information about the signalling, details about the FIGs,
@@ -28,3 +28,21 @@ This is a contribution by CSP.it, is now developed by opendigitalradio,
and is published under the terms of the GNU GPL v3 or later.
See LICENCE for more information.
+
+Faadalyse
+=========
+
+faadalyse can extract the audio from .dabp files created with ODR-AudioEnc,
+and is designed to do more in-depth analysis of the AAC encoding using a modified
+libfaad.
+
+To install:
+
+download and extract faad2-2.7 to a folder of the same name, and configure and compile it.
+You can patch that faad library to display additional information you need.
+Do not run make install.
+
+Then run
+
+ make -f Makefile.faadalyse
+ ./faadalyse
diff --git a/src/dabplussnoop.cpp b/src/dabplussnoop.cpp
index 5b204fc..d7bc21a 100644
--- a/src/dabplussnoop.cpp
+++ b/src/dabplussnoop.cpp
@@ -43,7 +43,9 @@ extern "C" {
#define DPS_INDENT "\t\t"
#define DPS_PREFIX "DAB+ decode:"
-#define DPS_DEBUG 0
+#ifndef DPS_DEBUG
+# define DPS_DEBUG 0
+#endif
using namespace std;
@@ -54,13 +56,10 @@ void DabPlusSnoop::push(uint8_t* streamdata, size_t streamsize)
m_data.resize(original_size + streamsize);
memcpy(&m_data[original_size], streamdata, streamsize);
- if (seek_valid_firecode()) {
- // m_data now points to a valid header
-
- if (decode()) {
- // We have been able to decode the AUs, now flush vector
- m_data.clear();
- }
+ const size_t sf_len = m_subchannel_index * 120;
+ while (seek_valid_firecode() and decode()) {
+ // We have been able to decode the AUs, now flush vector
+ m_data.erase(m_data.begin(), m_data.begin() + sf_len);;
}
}
diff --git a/src/faadalyse.cpp b/src/faadalyse.cpp
new file mode 100644
index 0000000..9c7fbf9
--- /dev/null
+++ b/src/faadalyse.cpp
@@ -0,0 +1,94 @@
+/*
+ Copyright (C) 2017 Matthias P. Braendli (http://www.opendigitalradio.org)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ faadalyse.cpp
+ Use FAAD to analyse some AAC file internals
+
+ Authors:
+ Matthias P. Braendli <matthias@mpb.li>
+*/
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+#include <cstdio>
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <getopt.h>
+
+extern "C" {
+#include "lib_crc.h"
+}
+#include "dabplussnoop.hpp"
+
+using namespace std;
+
+static void usage(void)
+{
+ cerr << "\nUsage:\n"
+ "faadalyse <file.dabp> <bitrate>\n"
+ " The bitrate of the file must be given separately\n";
+}
+
+int main(int argc, char **argv)
+{
+ cerr << "Faadalyse -- A .dabp file analyser\n www.opendigitalradio.org\n" <<
+ " compiled at " << __DATE__ << " " << __TIME__ << "\n";
+
+ if (argc != 3) {
+ usage();
+ return 1;
+ }
+ const string fname = argv[1];
+ const int bitrate = stoi(argv[2]);
+ if (bitrate % 8 != 0) {
+ cerr << "Bitrate not a multiple of 8\n";
+ return 1;
+ }
+ const int subchannel_index = bitrate / 8;
+
+ cerr << "Analysing " << fname << " " << bitrate << "kbps\n";
+
+ DabPlusSnoop snoop;
+ snoop.set_subchannel_index(subchannel_index);
+
+ FILE* fd = fopen(fname.c_str(), "r");
+ if (!fd) {
+ cerr << "Failed to open file\n";
+ return 1;
+ }
+
+ while (!feof(fd) and !ferror(fd)) {
+ vector<uint8_t> buf(1024);
+ size_t read_bytes = fread(buf.data(), 1, 1024, fd);
+
+ if (read_bytes) {
+ snoop.push(buf.data(), read_bytes);
+ }
+ }
+
+ snoop.close();
+
+ cerr << "Write file stream-0.wav\n";
+
+ return 0;
+}
+