Skip to content

Commit

Permalink
mot handling and sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
JvanKatwijk committed May 12, 2021
1 parent 29dce65 commit 804f592
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 48 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Qt-DAB-3.71 [![Build Status](https://travis-ci.org/JvanKatwijk/qt-dab.svg?branch=master)](https://travis-ci.org/JvanKatwijk/qt-dab)
# Qt-DAB-3.72 [![Build Status](https://travis-ci.org/JvanKatwijk/qt-dab.svg?branch=master)](https://travis-ci.org/JvanKatwijk/qt-dab)

Qt-DAB-3.71 is software for Linux and Raspberry Pi for listening to terrestrial Digital Audio Broadcasting (DAB and DAB+). Qt-DAB is accompanied by its little sister dabMini and brother dab-2 for experimenting, all built on the same set of sources.
Qt-DAB-3.72 is software for Linux and Raspberry Pi for listening to terrestrial Digital Audio Broadcasting (DAB and DAB+). Qt-DAB is accompanied by its little sister dabMini, built on the same set of sources.

![overview](/qt-dab-screen.png?raw=true)

Expand Down Expand Up @@ -33,7 +33,7 @@ Table of Contents
Introduction
------------------------------------------------------------------

**Qt-DAB-3.71** is a rich implementation of a DAB decoder for use on Linux and Windows based PC's, including some ARM based boards, such as the Raspberry PI, both 2 and 3.
**Qt-DAB-3.72** is a rich implementation of a DAB decoder for use on Linux and Windows based PC's, including some ARM based boards, such as the Raspberry PI, both 2 and 3.

It provides an abundant amount of selectors and displays, most of
which can be switched off, but are of interest for those who want to see aspects of the DAB signal.
Expand Down Expand Up @@ -89,7 +89,7 @@ Features
- SDR DAB sticks (RTL2838U or similar),
- HACKRF One,
- Airspy, including Airspy mini,
- SDRplay ( RSP I, RSP II, RSP Duo and RSP Dx), with separate entries for v2 and v3 library
- SDRplay (RSP I, RSP II, RSP Duo and RSP Dx), with separate entries for v2 and v3 library
- limeSDR,
- Soapy (experimental, Linux only),
- ExtIO (expertimental, Windows only),
Expand Down Expand Up @@ -457,14 +457,14 @@ The software is experimental though and - at least here - the times
on the time table are two hours off.

-----------------------------------------------------------------------
Recording the SNR
* [Recording the SNR](#Recording-the-SNR)
-----------------------------------------------------------------------

Just as an experiment, a widget was added that shows the development of the
SNR over time. The main purpose of the widget is to look at the
performance of antennas.

Computation of the SNR is done with every second DAB frame. As is known,
Computation of the SNR is done with all DAB frames. As is known,
a sampled DAB frame starts with a null period of app 2600 samples, followed by
76 blocks (each about 2500 samples) with data. SNR is computed as the ratio between the amplitudes in the data blocks and the amplitudes of the
samples in the null period.
Expand All @@ -476,9 +476,7 @@ The configuration widget contains a spinbox that can be used to set the
If the value "1" is chosen, the result of each snr computation is shown,
if a value larger than "1" is chosen that number of computations will be
averaged and the result shown.
Each minute there are 312 computations.
The default value for the X-axis of the display in the widget is
therefore 312.
The default value for the X-axis of the display in the widget is 312.

As configuration option, the widget can be equipped with a **dump** button,
touching the button will show a menu for file selection. Once a file
Expand Down
9 changes: 5 additions & 4 deletions dab-maxi/qt-dab.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ TEMPLATE = app
QT += widgets xml
#CONFIG += console
CONFIG -= console
QMAKE_CXXFLAGS += -std=c++14
QMAKE_CFLAGS += -O4 -ffast-math
#QMAKE_CFLAGS += -ffast-math -flto
QMAKE_CXXFLAGS += -O4 -ffast-math
#QMAKE_CXXFLAGS += -std=c++14
#QMAKE_CFLAGS += -O4 -ffast-math
#QMAKE_CXXFLAGS += -O4 -ffast-math
QMAKE_CXXFLAGS += -ffast-math -flto
QMAKE_CFLAGS += -ffast-math -flto
QMAKE_LFLAGS += -ffast-math -flto
#QMAKE_CFLAGS += -g -fsanitize=address
#QMAKE_CXXFLAGS += -g -fsanitize=address
#QMAKE_LFLAGS += -g -fsanitize=address
Expand Down
6 changes: 3 additions & 3 deletions src/backend/data/epg-2/epg-decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ progDesc theElement;
return endPoint;

case 0x81: { // creation time
// int time = process_474 (v, index, length);
int time = process_474 (v, index, length);
// fprintf (stderr, "schedule created at %.2d:%.2d\n",
// time / 60, time % 60);
return endPoint;
Expand Down Expand Up @@ -579,8 +579,8 @@ QString result = "";
}

void epgDecoder::process_483 (uint8_t *v, int index, int elength) {
fprintf (stderr, "Version %d\n",
(v [index + 0] << 8) | v [index + 1]);
// fprintf (stderr, "Version %d\n",
// (v [index + 0] << 8) | v [index + 1]);
}

void epgDecoder::record (progDesc *theElement) {
Expand Down
14 changes: 7 additions & 7 deletions src/backend/data/mot/mot-dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int16_t i;
this -> dirSize = dirSize;
this -> numObjects = objects;
this -> dir_segmentSize = segmentSize;
fprintf (stderr, "dirSize %d, numObjects %d, segmentSize %d\n",
dirSize, objects, segmentSize);
dir_segments = new uint8_t [dirSize];
motComponents = new motComponentType [objects];
for (i = 0; i < objects; i ++)
Expand All @@ -55,7 +57,7 @@ int i;

for (i = 0; i < numObjects; i ++)
if (motComponents [i]. inUse)
delete motComponents [i]. motSlide;
delete [] motComponents [i]. motSlide;
delete [] motComponents;
}

Expand Down Expand Up @@ -106,10 +108,9 @@ int16_t i;
for (i = 0; i < this -> num_dirSegments; i ++)
if (!this -> marked [i])
return;
// yes we have all data to build up the directory
analyse_theDirectory();
}
//
// yes we have all data to build up the directory
analyse_theDirectory();
}
//
// This is the tough one, we collected the bits, and now
Expand All @@ -121,14 +122,13 @@ uint8_t *data = dir_segments;
uint16_t extensionLength = (dir_segments [currentBase] << 8) |
data [currentBase + 1];

int16_t i;

currentBase += 2 + extensionLength;
for (i = 0; i < numObjects; i ++) {
for (int i = 0; i < numObjects; i ++) {
uint16_t transportId = (data [currentBase] << 8) |
data [currentBase + 1];
if (transportId == 0) // just a dummy
break;

uint8_t *segment = &data [currentBase + 2];
motObject *handle = new motObject (myRadioInterface,
true,
Expand Down
35 changes: 15 additions & 20 deletions src/backend/data/mot/mot-handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,23 @@ int32_t i;
}

int32_t sizeinBits =
msc. size() - next - (crcFlag != 0 ? 16 : 0);
msc. size () - next - (crcFlag != 0 ? 16 : 0);

if (!transportIdFlag)
return;

std::vector<uint8_t> motVector;
motVector. resize (sizeinBits / 8);
for (i = 0; i < sizeinBits / 8; i ++)
motVector [i] = getBits_8 (data, next + 8 * i);
for (i = 0; i < sizeinBits / 8; i ++) {
uint8_t t = 0;
for (int j = 0; j < 8; j ++)
t = (t << 1) | data [next + 8 * i + j];
motVector [i] = t;
}

uint32_t segmentSize = ((motVector [0] & 0x1F) << 8) |
motVector [1];

switch (groupType) {
case 3:
if (segmentNumber == 0) {
Expand All @@ -133,23 +138,13 @@ int32_t i;

case 4: {
motObject *h = getHandle (transportId);
if ((h == nullptr) && (segmentNumber != 0))
break;
if ((h == nullptr) && (segmentNumber == 0)) {
h = new motObject (myRadioInterface,
false, // not within a directory
transportId,
&motVector [2],
segmentSize,
lastFlag);
setHandle (h, transportId);
break;
}

h -> addBodySegment (&motVector [2],
segmentNumber,
segmentSize,
lastFlag);
// if ((h == nullptr) && (segmentNumber != 0))
// break;
if (h != nullptr)
h -> addBodySegment (&motVector [2],
segmentNumber,
segmentSize,
lastFlag);
}
break;

Expand Down
13 changes: 8 additions & 5 deletions src/backend/data/mot/mot-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,22 @@ uint16_t rawContentType = 0;
this -> segmentSize = -1;

headerSize =
((segment [3] & 0x0F) << 9) |
// ((segment [3] & 0x0F) << 9) |
(segment [4] << 1) | ((segment [5] >> 7) & 0x01);
bodySize =
(segment [0] << 20) | (segment [1] << 12) |
(segment [2] << 4 ) | ((segment [3] & 0xF0) >> 4);

// Extract the content type
int b = (segment [5] >> 1) & 0x3F;
rawContentType |= ((segment [5] >> 1) & 0x3F) << 8;
rawContentType |= ((segment [5] & 0x01) << 8) | segment [6];
contentType = static_cast<MOTContentType>(rawContentType);

// fprintf (stderr, "headerSize %d, bodySize %d. contentType %d, transportId %d\n",
// headerSize, bodySize, b, transportId);
// we are actually only interested in the name, if any

while ((uint16_t)pointer < headerSize) {
uint8_t PLI = (segment [pointer] & 0300) >> 6;
uint8_t paramId = (segment [pointer] & 077);
Expand Down Expand Up @@ -83,7 +88,6 @@ uint16_t rawContentType = 0;
length = segment [pointer + 1] & 0177;
pointer += 2;
}

switch (paramId) {
case 12: {
int16_t i;
Expand All @@ -94,7 +98,7 @@ uint16_t rawContentType = 0;
break;

case 2: // creation time
case 3: //start validity
case 3: // start validity
case 4: // expiretime
case 5: // triggerTime
case 6: // version number
Expand Down Expand Up @@ -160,7 +164,6 @@ int32_t i;
if (motMap. find (i) == motMap. end())
return;
}

// The motObject is (seems to be) complete
handleComplete();
}
Expand All @@ -170,7 +173,7 @@ void motObject::handleComplete () {
QByteArray result;
for (const auto &it : motMap)
result. append (it. second);

fprintf (stderr, "Handling complete\n");
handle_motObject (result, name, (int)contentType, dirElement);
}

Expand Down

0 comments on commit 804f592

Please sign in to comment.