IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
FLAC Subframe size
filoe
post Sep 5 2012, 21:35
Post #1





Group: Members
Posts: 13
Joined: 7-April 12
Member No.: 98516



I am writing a Flac decoder. And there are 4 subframe types.
I am programming in C# and I have to read an amount of bytes of a stream. (the amount of bytes of all subframes or of the next subframe)
But how can I get the size of the ENCODED subframe?
Go to the top of the page
+Quote Post
tuffy
post Sep 6 2012, 13:18
Post #2





Group: Members
Posts: 111
Joined: 20-August 07
Member No.: 46367



There is no subframe size field. When the decoder has finished with one subframe, it simply expects the next subframe to follow (without any byte alignment) until all of them have been decoded.
Go to the top of the page
+Quote Post
filoe
post Sep 6 2012, 16:00
Post #3





Group: Members
Posts: 13
Joined: 7-April 12
Member No.: 98516



Hmmm so is there a max size?
Because I have to know how many bytes I have to read into a buffer. I can t load the whole file into memory because that would case a outofmem exception sad.gif
Go to the top of the page
+Quote Post
pdq
post Sep 6 2012, 16:29
Post #4





Group: Members
Posts: 3315
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



Worst case would be slightly larger than the uncompressed data.
Go to the top of the page
+Quote Post
tuffy
post Sep 6 2012, 16:32
Post #5





Group: Members
Posts: 111
Joined: 20-August 07
Member No.: 46367



There technically isn't any maximum size for a given FLAC frame; a perfectly valid LPC subframe might be much larger than VERBATIM by populating its tunable fields with junk, for example. The reference decoder handles this by only working on a bit-by-bit basis and not caring whether whatever's in the byte buffer is part of one frame or another. You'll just need to ensure callbacks for CRC-8 and CRC-16 calculation are only executed as each byte is consumed rather than as the buffer is filled (or use a 1 byte buffer).
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th April 2014 - 02:35