mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-08 04:00:44 +00:00
Check for format change before coalescing PRS1 chunks, move data warnings out of parsing.
This commit is contained in:
parent
6e12cfea61
commit
76053b0469
@ -3101,11 +3101,13 @@ QList<PRS1DataChunk *> PRS1Import::CoalesceWaveformChunks(QList<PRS1DataChunk *>
|
|||||||
{
|
{
|
||||||
QList<PRS1DataChunk *> coalesced;
|
QList<PRS1DataChunk *> coalesced;
|
||||||
PRS1DataChunk *chunk = nullptr, *lastchunk = nullptr;
|
PRS1DataChunk *chunk = nullptr, *lastchunk = nullptr;
|
||||||
|
int num;
|
||||||
|
|
||||||
for (int i=0; i < allchunks.size(); ++i) {
|
for (int i=0; i < allchunks.size(); ++i) {
|
||||||
chunk = allchunks.at(i);
|
chunk = allchunks.at(i);
|
||||||
|
|
||||||
if (lastchunk != nullptr) {
|
if (lastchunk != nullptr) {
|
||||||
|
// Waveform files shouldn't contain multiple sessions
|
||||||
if (lastchunk->sessionid != chunk->sessionid) {
|
if (lastchunk->sessionid != chunk->sessionid) {
|
||||||
qWarning() << "lastchunk->sessionid != chunk->sessionid in PRS1Loader::CoalesceWaveformChunks()";
|
qWarning() << "lastchunk->sessionid != chunk->sessionid in PRS1Loader::CoalesceWaveformChunks()";
|
||||||
// Free any remaining chunks
|
// Free any remaining chunks
|
||||||
@ -3116,9 +3118,28 @@ QList<PRS1DataChunk *> PRS1Import::CoalesceWaveformChunks(QList<PRS1DataChunk *>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check whether the data format is the same between the two chunks
|
||||||
|
bool same_format = (lastchunk->waveformInfo.size() == chunk->waveformInfo.size());
|
||||||
|
if (same_format) {
|
||||||
|
num = chunk->waveformInfo.size();
|
||||||
|
for (int n=0; n < num; n++) {
|
||||||
|
const PRS1Waveform &a = lastchunk->waveformInfo.at(n);
|
||||||
|
const PRS1Waveform &b = chunk->waveformInfo.at(n);
|
||||||
|
if (a.interleave != b.interleave) {
|
||||||
|
// We've never seen this before
|
||||||
|
qWarning() << chunk->m_path << "format change?" << a.interleave << b.interleave;
|
||||||
|
same_format = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// We've never seen this before
|
||||||
|
qWarning() << chunk->m_path << "channels change?" << lastchunk->waveformInfo.size() << chunk->waveformInfo.size();
|
||||||
|
}
|
||||||
|
|
||||||
qint64 diff = (chunk->timestamp - lastchunk->timestamp) - lastchunk->duration;
|
qint64 diff = (chunk->timestamp - lastchunk->timestamp) - lastchunk->duration;
|
||||||
if (diff == 0) {
|
if (same_format && diff == 0) {
|
||||||
// In sync, so append waveform data to previous chunk
|
// Same format and in sync, so append waveform data to previous chunk
|
||||||
lastchunk->m_data.append(chunk->m_data);
|
lastchunk->m_data.append(chunk->m_data);
|
||||||
lastchunk->duration += chunk->duration;
|
lastchunk->duration += chunk->duration;
|
||||||
delete chunk;
|
delete chunk;
|
||||||
@ -3127,6 +3148,18 @@ QList<PRS1DataChunk *> PRS1Import::CoalesceWaveformChunks(QList<PRS1DataChunk *>
|
|||||||
// else start a new chunk to resync
|
// else start a new chunk to resync
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report any formats we haven't seen before
|
||||||
|
num = chunk->waveformInfo.size();
|
||||||
|
if (num > 2) {
|
||||||
|
qDebug() << chunk->m_path << num << "channels";
|
||||||
|
}
|
||||||
|
for (int n=0; n < num; n++) {
|
||||||
|
int interleave = chunk->waveformInfo.at(n).interleave;
|
||||||
|
if (interleave != 5) {
|
||||||
|
qDebug() << chunk->m_path << "interleave?" << interleave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
coalesced.append(chunk);
|
coalesced.append(chunk);
|
||||||
lastchunk = chunk;
|
lastchunk = chunk;
|
||||||
}
|
}
|
||||||
@ -3350,6 +3383,7 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
quint16 wvfm_signals=0;
|
quint16 wvfm_signals=0;
|
||||||
|
|
||||||
unsigned char * header;
|
unsigned char * header;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
//int lastheadersize = 0;
|
//int lastheadersize = 0;
|
||||||
int lastblocksize = 0;
|
int lastblocksize = 0;
|
||||||
@ -3367,6 +3401,7 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
QList<PRS1Waveform> waveformInfo;
|
QList<PRS1Waveform> waveformInfo;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
qint64 filepos = f.pos();
|
||||||
headerBA = f.read(16);
|
headerBA = f.read(16);
|
||||||
if (headerBA.size() != 16) {
|
if (headerBA.size() != 16) {
|
||||||
qDebug() << path << "file too short?";
|
qDebug() << path << "file too short?";
|
||||||
@ -3445,9 +3480,6 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
|
|
||||||
duration = header[0x0f] | header[0x10] << 8;
|
duration = header[0x0f] | header[0x10] << 8;
|
||||||
wvfm_signals = header[0x12] | header[0x13] << 8;
|
wvfm_signals = header[0x12] | header[0x13] << 8;
|
||||||
if (wvfm_signals > 2) {
|
|
||||||
qDebug() << path << wvfm_signals << "channels";
|
|
||||||
}
|
|
||||||
|
|
||||||
int ws_size = (fileVersion == 3) ? 4 : 3;
|
int ws_size = (fileVersion == 3) ? 4 : 3;
|
||||||
int sbsize = wvfm_signals * ws_size + 1;
|
int sbsize = wvfm_signals * ws_size + 1;
|
||||||
@ -3465,10 +3497,6 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
int pos = 0x14 + (wvfm_signals - 1) * ws_size;
|
int pos = 0x14 + (wvfm_signals - 1) * ws_size;
|
||||||
for (int i = 0; i < wvfm_signals; ++i) {
|
for (int i = 0; i < wvfm_signals; ++i) {
|
||||||
quint16 interleave = header[pos] | header[pos + 1] << 8; // samples per block (Usually 05 00)
|
quint16 interleave = header[pos] | header[pos + 1] << 8; // samples per block (Usually 05 00)
|
||||||
if (interleave != 5) {
|
|
||||||
qDebug() << path << "interleave?" << interleave;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileVersion == 2) {
|
if (fileVersion == 2) {
|
||||||
quint8 sample_format = header[pos + 2]; // TODO: sample_format seems to be unused anywhere else in the loader.
|
quint8 sample_format = header[pos + 2]; // TODO: sample_format seems to be unused anywhere else in the loader.
|
||||||
waveformInfo.push_back(PRS1Waveform(interleave, sample_format));
|
waveformInfo.push_back(PRS1Waveform(interleave, sample_format));
|
||||||
@ -3515,6 +3543,7 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cnt++;
|
||||||
continue;
|
continue;
|
||||||
// Corrupt header.. skip it.
|
// Corrupt header.. skip it.
|
||||||
}
|
}
|
||||||
@ -3522,6 +3551,10 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
|
|
||||||
chunk = new PRS1DataChunk();
|
chunk = new PRS1DataChunk();
|
||||||
|
|
||||||
|
chunk->m_path = path;
|
||||||
|
chunk->m_filepos = filepos;
|
||||||
|
chunk->m_index = cnt;
|
||||||
|
|
||||||
chunk->sessionid = sessionid;
|
chunk->sessionid = sessionid;
|
||||||
|
|
||||||
if (!firstsession) {
|
if (!firstsession) {
|
||||||
@ -3587,6 +3620,7 @@ QList<PRS1DataChunk *> PRS1Loader::ParseFile(const QString & path)
|
|||||||
CHUNKS.append(chunk);
|
CHUNKS.append(chunk);
|
||||||
|
|
||||||
lastchunk = chunk;
|
lastchunk = chunk;
|
||||||
|
cnt++;
|
||||||
} while (!f.atEnd());
|
} while (!f.atEnd());
|
||||||
|
|
||||||
return CHUNKS;
|
return CHUNKS;
|
||||||
|
@ -78,6 +78,10 @@ public:
|
|||||||
QByteArray m_data;
|
QByteArray m_data;
|
||||||
QByteArray m_headerblock;
|
QByteArray m_headerblock;
|
||||||
|
|
||||||
|
QString m_path;
|
||||||
|
qint64 m_filepos; // file offset
|
||||||
|
int m_index; // nth chunk in file
|
||||||
|
|
||||||
SessionID sessionid;
|
SessionID sessionid;
|
||||||
|
|
||||||
quint8 fileVersion;
|
quint8 fileVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user