Frame with block size shorter than 16 samples
pkkolos opened this issue · 2 comments
I have a FLAC file encoded with the reference implementation (libFLAC) which has a frame (probably the last) with block size 8. The file has minimum and maximum block size of 4096 (fixed block size stream). All other frames have block size 4096.
When I parse it with claxon, though, I get the error invalid block size, must be at least 16
.
If I understand correctly the specification (Note 3), this is allowed, as the last frame of a fixed block size stream can be shorter than the minimum block size defined in STREAMINFO block and thus shorter than 16 as well.
Thank you for taking the time to report this.
I was able to reproduce this with a file encoded by the reference encoder. Indeed the block size limit applies only to the global block size, but not to the block size of individual frames. When the length of the stream modulo the block size was less than 16, this error would be reported incorrectly. With the default block size of 4096, the probability of that happening was about 1 in 273, which is probably why I had not noticed this before.
I’ve pushed a fix to master. Are you able to decode the file now?
Yes that fixes the problem. I can decode the file just fine. Thanks.