Adjust the header size calculations.
This commit is contained in:
parent
414a8053d5
commit
2fe695d38e
@ -245,19 +245,26 @@ oceanic_atom2_parser_get_field (parser_t *abstract, parser_field_type_t type, un
|
|||||||
const unsigned char *data = abstract->data;
|
const unsigned char *data = abstract->data;
|
||||||
unsigned int size = abstract->size;
|
unsigned int size = abstract->size;
|
||||||
|
|
||||||
unsigned int length = 11 * PAGESIZE / 2;
|
// Get the total amount of bytes before and after the profile data.
|
||||||
unsigned int header = 4 * PAGESIZE;
|
unsigned int headersize = 9 * PAGESIZE / 2;
|
||||||
unsigned int footer = size - PAGESIZE;
|
unsigned int footersize = 2 * PAGESIZE / 2;
|
||||||
if (parser->model == DATAMASK || parser->model == COMPUMASK ||
|
if (parser->model == DATAMASK || parser->model == COMPUMASK ||
|
||||||
parser->model == GEO || parser->model == GEO20 ||
|
parser->model == GEO || parser->model == GEO20 ||
|
||||||
parser->model == VEO20 || parser->model == VEO30) {
|
parser->model == VEO20 || parser->model == VEO30) {
|
||||||
length -= PAGESIZE;
|
headersize -= PAGESIZE;
|
||||||
header -= PAGESIZE;
|
} else if (parser->model == VT4 || parser->model == VT41) {
|
||||||
|
headersize += PAGESIZE;
|
||||||
|
} else if (parser->model == ATOM1) {
|
||||||
|
headersize -= 2 * PAGESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < length)
|
if (size < headersize + footersize)
|
||||||
return PARSER_STATUS_ERROR;
|
return PARSER_STATUS_ERROR;
|
||||||
|
|
||||||
|
// Get the offset to the header and footer sample.
|
||||||
|
unsigned int header = headersize - PAGESIZE / 2;
|
||||||
|
unsigned int footer = size - footersize;
|
||||||
|
|
||||||
if (!parser->cached) {
|
if (!parser->cached) {
|
||||||
sample_statistics_t statistics = SAMPLE_STATISTICS_INITIALIZER;
|
sample_statistics_t statistics = SAMPLE_STATISTICS_INITIALIZER;
|
||||||
parser_status_t rc = oceanic_atom2_parser_samples_foreach (
|
parser_status_t rc = oceanic_atom2_parser_samples_foreach (
|
||||||
@ -317,19 +324,25 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
|
|||||||
const unsigned char *data = abstract->data;
|
const unsigned char *data = abstract->data;
|
||||||
unsigned int size = abstract->size;
|
unsigned int size = abstract->size;
|
||||||
|
|
||||||
unsigned int header = 4 * PAGESIZE;
|
// Get the total amount of bytes before and after the profile data.
|
||||||
|
unsigned int headersize = 9 * PAGESIZE / 2;
|
||||||
|
unsigned int footersize = 2 * PAGESIZE / 2;
|
||||||
if (parser->model == DATAMASK || parser->model == COMPUMASK ||
|
if (parser->model == DATAMASK || parser->model == COMPUMASK ||
|
||||||
parser->model == GEO || parser->model == GEO20 ||
|
parser->model == GEO || parser->model == GEO20 ||
|
||||||
parser->model == VEO20 || parser->model == VEO30)
|
parser->model == VEO20 || parser->model == VEO30) {
|
||||||
header -= PAGESIZE;
|
headersize -= PAGESIZE;
|
||||||
else if (parser->model == VT4 || parser->model == VT41)
|
} else if (parser->model == VT4 || parser->model == VT41) {
|
||||||
header += PAGESIZE;
|
headersize += PAGESIZE;
|
||||||
else if (parser->model == ATOM1)
|
} else if (parser->model == ATOM1) {
|
||||||
header -= 2 * PAGESIZE;
|
headersize -= 2 * PAGESIZE;
|
||||||
|
}
|
||||||
|
|
||||||
if (size < header + 3 * PAGESIZE / 2)
|
if (size < headersize + footersize)
|
||||||
return PARSER_STATUS_ERROR;
|
return PARSER_STATUS_ERROR;
|
||||||
|
|
||||||
|
// Get the offset to the header sample.
|
||||||
|
unsigned int header = headersize - PAGESIZE / 2;
|
||||||
|
|
||||||
unsigned int time = 0;
|
unsigned int time = 0;
|
||||||
unsigned interval = 0;
|
unsigned interval = 0;
|
||||||
switch (data[0x17] & 0x03) {
|
switch (data[0x17] & 0x03) {
|
||||||
@ -372,8 +385,8 @@ oceanic_atom2_parser_samples_foreach (parser_t *abstract, sample_callback_t call
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int complete = 1;
|
unsigned int complete = 1;
|
||||||
unsigned int offset = header + PAGESIZE / 2;
|
unsigned int offset = headersize;
|
||||||
while (offset + samplesize <= size - PAGESIZE) {
|
while (offset + samplesize <= size - footersize) {
|
||||||
parser_sample_value_t sample = {0};
|
parser_sample_value_t sample = {0};
|
||||||
|
|
||||||
// Ignore empty samples.
|
// Ignore empty samples.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user