mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Added back in corrupt PRS1 waveform handling
This commit is contained in:
parent
61502b2da9
commit
a800aff28f
@ -1397,7 +1397,10 @@ void PRS1Import::run()
|
|||||||
delete sg->session;
|
delete sg->session;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sg->ParseEvents();
|
if (!sg->ParseEvents()) {
|
||||||
|
// delete sg->session;
|
||||||
|
// continue;
|
||||||
|
}
|
||||||
sg->ParseWaveforms();
|
sg->ParseWaveforms();
|
||||||
|
|
||||||
sg->session->SetChanged(true);
|
sg->session->SetChanged(true);
|
||||||
@ -1459,6 +1462,12 @@ bool PRS1FileGroup::ParseFile(QString path)
|
|||||||
quint16 wvfm_signals;
|
quint16 wvfm_signals;
|
||||||
|
|
||||||
unsigned char * header;
|
unsigned char * header;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
int lastheadersize = 0;
|
||||||
|
int lastblocksize = 0;
|
||||||
|
|
||||||
|
int cruft = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
QByteArray headerBA = f.read(16);
|
QByteArray headerBA = f.read(16);
|
||||||
@ -1480,6 +1489,29 @@ bool PRS1FileGroup::ParseFile(QString path)
|
|||||||
chunk->ext = header[6];
|
chunk->ext = header[6];
|
||||||
chunk->timestamp = (header[14] << 24) | (header[13] << 16) | (header[12] << 8) | header[11];
|
chunk->timestamp = (header[14] << 24) | (header[13] << 16) | (header[12] << 8) | header[11];
|
||||||
|
|
||||||
|
if (lastchunk != nullptr) {
|
||||||
|
if ((lastchunk->fileVersion != chunk->fileVersion)
|
||||||
|
&& (lastchunk->ext != chunk->ext)
|
||||||
|
&& (lastchunk->family != chunk->family)
|
||||||
|
&& (lastchunk->familyVersion != chunk->familyVersion)
|
||||||
|
&& (lastchunk->htype != chunk->htype)) {
|
||||||
|
QByteArray junk = f.read(lastblocksize - 16);
|
||||||
|
|
||||||
|
|
||||||
|
if (lastchunk->ext == 5) {
|
||||||
|
// The data is random crap
|
||||||
|
// lastchunk->m_data.append(junk.mid(lastheadersize-16));
|
||||||
|
}
|
||||||
|
delete chunk;
|
||||||
|
++cruft;
|
||||||
|
if (cruft > 3)
|
||||||
|
break;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
// Corrupt header.. skip it.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
@ -1523,21 +1555,26 @@ bool PRS1FileGroup::ParseFile(QString path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int headersize = headerBA.size() - 1;
|
int headersize = headerBA.size();
|
||||||
|
|
||||||
|
lastblocksize = blocksize;
|
||||||
|
lastheadersize = headersize;
|
||||||
|
blocksize -= headersize;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check header checksum
|
// Check header checksum
|
||||||
quint8 csum = 0;
|
quint8 csum = 0;
|
||||||
for (int i=0; i < headersize; ++i) csum += header[i];
|
for (int i=0; i < headersize-1; ++i) csum += header[i];
|
||||||
if (csum != header[headersize]) {
|
if (csum != header[headersize-1]) {
|
||||||
// header checksum error.
|
// header checksum error.
|
||||||
delete chunk;
|
delete chunk;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read data block
|
// Read data block
|
||||||
chunk->m_data = f.read(blocksize - (headersize+1));
|
chunk->m_data = f.read(blocksize);
|
||||||
|
|
||||||
if (chunk->m_data.size() < (blocksize - (headersize+1))) {
|
if (chunk->m_data.size() < blocksize) {
|
||||||
delete chunk;
|
delete chunk;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1564,6 +1601,7 @@ bool PRS1FileGroup::ParseFile(QString path)
|
|||||||
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;
|
||||||
|
cnt++;
|
||||||
chunk = lastchunk;
|
chunk = lastchunk;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1596,6 +1634,7 @@ bool PRS1FileGroup::ParseFile(QString path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastchunk = chunk;
|
lastchunk = chunk;
|
||||||
|
cnt++;
|
||||||
} while (!f.atEnd());
|
} while (!f.atEnd());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user