mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-08 04:00:44 +00:00
Split PRS1DataChunk::ReadHeader into ReadHeader/ReadWaveformHeader.
This commit is contained in:
parent
e07c4ce63c
commit
d3c6d6445b
@ -3562,6 +3562,44 @@ bool PRS1DataChunk::ReadHeader(QFile & f)
|
|||||||
this->m_headerblock = headerB2;
|
this->m_headerblock = headerB2;
|
||||||
|
|
||||||
} else { // Waveform Chunk
|
} else { // Waveform Chunk
|
||||||
|
bool hdr_ok = ReadWaveformHeader(f);
|
||||||
|
if (!hdr_ok) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The 8bit checksum comes at the end.
|
||||||
|
QByteArray checksum = f.read(1);
|
||||||
|
if (checksum.size() < 1) {
|
||||||
|
qWarning() << this->m_path << "read error header checksum";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this->storedChecksum = checksum.data()[0];
|
||||||
|
|
||||||
|
// Calculate 8bit additive header checksum.
|
||||||
|
header = (unsigned char *)this->m_header.data(); // important because its memory location could move
|
||||||
|
int header_size = this->m_header.size();
|
||||||
|
quint8 achk=0;
|
||||||
|
for (int i=0; i < header_size; i++) {
|
||||||
|
achk += header[i];
|
||||||
|
}
|
||||||
|
this->calcChecksum = achk;
|
||||||
|
|
||||||
|
// Append the stored checksum to the raw data *after* calculating the checksum on the preceding data.
|
||||||
|
this->m_header.append(checksum);
|
||||||
|
|
||||||
|
ok = true;
|
||||||
|
} while (false);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PRS1DataChunk::ReadWaveformHeader(QFile & f)
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
unsigned char * header;
|
||||||
|
do {
|
||||||
QByteArray extra = f.read(5);
|
QByteArray extra = f.read(5);
|
||||||
if (extra.size() != 5) {
|
if (extra.size() != 5) {
|
||||||
qWarning() << this->m_path << "read error in waveform header";
|
qWarning() << this->m_path << "read error in waveform header";
|
||||||
@ -3605,27 +3643,6 @@ bool PRS1DataChunk::ReadHeader(QFile & f)
|
|||||||
pos -= 4;
|
pos -= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// The 8bit checksum comes at the end.
|
|
||||||
QByteArray checksum = f.read(1);
|
|
||||||
if (checksum.size() < 1) {
|
|
||||||
qWarning() << this->m_path << "read error header checksum";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this->storedChecksum = checksum.data()[0];
|
|
||||||
|
|
||||||
// Calculate 8bit additive header checksum.
|
|
||||||
header = (unsigned char *)this->m_header.data(); // important because its memory location could move
|
|
||||||
int header_size = this->m_header.size();
|
|
||||||
quint8 achk=0;
|
|
||||||
for (int i=0; i < header_size; i++) {
|
|
||||||
achk += header[i];
|
|
||||||
}
|
|
||||||
this->calcChecksum = achk;
|
|
||||||
|
|
||||||
// Append the stored checksum to the raw data *after* calculating the checksum on the preceding data.
|
|
||||||
this->m_header.append(checksum);
|
|
||||||
|
|
||||||
ok = true;
|
ok = true;
|
||||||
} while (false);
|
} while (false);
|
||||||
|
@ -115,6 +115,10 @@ public:
|
|||||||
|
|
||||||
//! \brief Read the chunk's data from a PRS1 file and calculate its CRC, must be called after ReadHeader
|
//! \brief Read the chunk's data from a PRS1 file and calculate its CRC, must be called after ReadHeader
|
||||||
bool ReadData(class QFile & f);
|
bool ReadData(class QFile & f);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \brief Read and parse the waveform-specific header data from a PRS1 file
|
||||||
|
bool ReadWaveformHeader(class QFile & f);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PRS1Loader;
|
class PRS1Loader;
|
||||||
|
Loading…
Reference in New Issue
Block a user