[flac-dev] How to get FLAC frame length

Dongfu He hedongfu at gmail.com
Sat Jan 30 23:48:54 PST 2016


I'm study FLAC decode problem, but can't figure out how to get FLAC frame
length. Please help.https://xiph.org/flac/format.html I docoded
METADATA_BLOCK_STREAMINFO, and get below data:

mMinBlock: 4096
mMaxBlock: 4096
mMinFrame: 1201
mMaxFrame: 12804
mSampleRate: 44100
mBitPerSample: 16
mTotalSample: 14170212

Then I start to analyse first Frame, below is the info from first Frame
header:

isFixBlock = true
blockSize = 12
sampleRate = 9
channel = 10
sampleSize = 4
number = 0
Blocking strategy is fixed-blocksize;
Block size: 1100, it means 256 * (2^(12-8)) samples = 4096 samples;
Sample rate: 1001 : 44.1kHz;
Channel: 2;
Sample size: 100 : 16 bits per sample;

So from above infomation, we'll know this frame has 4096 samples, and
sample size is 16 bits per sample. That means this frame length is at
least(ignore subframe header and frame footer,etc.) 4096 * 16 / 8 = 8192
bytes. But if I check the FLAC file manually, the offset gap of first and
second frame is only 2976 bytes, this means the frame length of first frame
is only 2976 bytes. Is there anything wrong for my calculation?

My purpose is get frame offset and frame length of every frame, is there
any good way? I know there is sync code 0xFF F8, but it's very low
efficiency. Thanks in advance!

-- 
Best Regards,
Dongfu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20160131/d0cc9ff6/attachment.htm 


More information about the flac-dev mailing list