pierreroudier / opusreader

Reading OPUS binary files in R
GNU General Public License v3.0
4 stars 5 forks source link

- Fix error reading larger OPUS files #16

Closed philipp-baumann closed 3 years ago

philipp-baumann commented 3 years ago

Hi Pierre, I could not read larger OPUS files. This fixes the error. Cheers

pierreroudier commented 3 years ago

I wonder if we could/should use a smarter approach using file.size, as described here:

[...]
fsize <- file.info(fn)["size"]
rw <- readBin(fn, "raw", n = fsize)
out <- opus_read_raw(rw, type = type, atm_comp_minus4offset = atm_comp_minus4offset)
[...]

According to the readBin docs, you can give the n parameter a generous allocation, but you have to be mindful as this space will be reserved (in other words we can be "wasting" RAM).

philipp-baumann commented 3 years ago

The latest commit fixes the invalid byte strings that can occur for time and PLF elements.

philipp-baumann commented 3 years ago

The latest fix is not really linked and should have been assigned to a different pull request.