[flac-dev] FLAC frame boundaries and protocol

Dave Harris dmwharris at verizon.net
Tue Mar 19 16:08:02 UTC 2019


Thanks, guys. Your answers helped and I think I have some ideas now on what to do.
On Wednesday, March 6, 2019 Miroslav Lichvar <mlichvar at redhat.com> wrote:
On Tue, Mar 05, 2019 at 10:26:54PM -0800, Brian Willoughby wrote:
> Frames start with a 14-bit sync code, which is 13 “one" bits and 1 “zero" bit. Subframes start with a 1-bit padding of “zero." Keep in mind that FLAC is a bit stream, not a byte stream, so that 14-bit frame sync can happen anywhere in a pair of bytes. You can’t simply scan memory bytes for a frame sync, at least not unless you allow for 8 variations, apply bit masks, and allow for non-word-address-aligned matches.

The specification says frames are aligned to bytes:

    Following the frame header are encoded subframes, one for each
    channel, and finally, the frame is zero-padded to a byte boundary.

The problem with finding frame boundaries is that the sync code and
the 8-bit CRC are too short, so the whole frame needs to be parsed
and the 16-bit CRC checked to be reasonably sure it really is a FLAC
frame.

-- 
Miroslav Lichvar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/flac-dev/attachments/20190319/ca72df05/attachment.html>


More information about the flac-dev mailing list