Re: FLAC frame boundaries and protocol

Dave Harris <[email protected]> Tue, 19 Mar 2019 16:08:02 +0000 (UTC)
Newsgroups gmane.comp.audio.compression.flac.devel
Message-ID <[email protected]>
Thanks, guys. Your answers helped and I think I have some ideas now on what to do.
On Wednesday, March 6, 2019 Miroslav Lichvar <[email protected]> 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

_______________________________________________
flac-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/flac-dev