msel-source / pymef

Python wrapper for MEF library
Other
5 stars 3 forks source link

error when reading by sample and the start sample not in the first segment #24

Closed cimbi closed 3 years ago

cimbi commented 3 years ago

Problem Description

When reading channel data by sample and the start sample is not in the first segment the code returns array of NaNs

Pymef version and platform

pymef=1.2.1 ubuntu 20.04

dancrepeau commented 3 years ago

Is this still an issue? I can help debug if desired.

dancrepeau commented 3 years ago

Figured this one out: when the first block decoded is in the second segment or later, the offset into the output buffer isn't being calculated correctly. The following code works correctly. Previously the start_sample of the segment wasn't being taken into account. The bug is that the start_sample of the block is defined to be zero for the first block of each segment (according to the MEF 3 spec, so the start_sample of the segment is relative to the channel, but the start_segment of the block is relative to the segment).

        offset_into_output_buffer = (si4) (channel->segments[start_segment].metadata_fps->metadata.time_series_section_2->start_sample +
                                           channel->segments[start_segment].time_series_indices_fps->time_series_indices[start_idx].start_sample) - start_samp;
cimbi commented 3 years ago

commit 6f156395 fixes this issue?

dancrepeau commented 3 years ago

No, that commit is a separate thing that doesn't really affect pymef, but just fixes incorrect code that could in the future be part of pymef. This issue is fixed by the same commit as the other issue. (sorry fo the confusion... I probably should have done separate commits for both issues, and then a third for the unrelated issue).

cimbi commented 3 years ago

Fixed by e824bfe