[flac-dev] Exact FLAC subset constraints

Brian Willoughby
Tue, 07 Jan 2014 07:06:43 -0000

I think you've found a bug, Bart.

flac 1.2.1 did not have any FLAC__format_blocksize_is_subset()
function, so the source you're seeing in format.c must be new. If the
format documentation you linked to is correct, then either the
specifications are self-contradictory, or the code is not
implementing the subset checks as described. My interpretation is
that blocksize bits of 0110 and 0111 would not be included in the
subset. The whole point of the subset is to have a small and finite
list of values so that embedded decoders do not have to deal with
every possible block size.

This bears further investigation.

Brian


On Jan 6, 2014, at 05:47, ???? ?????? wrote:

I mean that the first statement [Subset streams must use one of
192/576/1152/2304/4608/256/512/1024/2048/4096 (and 8192/16384 if the
sample rate is >48kHz).] published on
https://www.xiph.org/flac/
documentation_tools_flac.html#flac_options_blocksize
page IS NOT EQUAL to second statement [The blocksize bits in the frame
header must be 0001-1110. The blocksize must be <=16384; if the sample
rate is <= 48000Hz, the blocksize must be <=4608.] published on
https://www.xiph.org/flac/format.html#subset page.

What statement (first or second) is right?

0001-1110 mean 0110 and 0111 too??? (0110 mean "get 8 bit
(blocksize-1) from end of header", 0111 mean "get 16 bit (blocksize-1)
from end of header")

Why you don't use STRICT block size checking in
FLAC__format_blocksize_is_subset() like this:

FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned
blocksize, unsigned sample_rate)
{
         if(blocksize == 192 || blocksize == 576 || blocksize == 1152
|| blocksize == 2304 || blocksize == 4608 || blocksize == 256 ||
blocksize == 512 || blocksize == 1024 || blocksize == 2048 ||
blocksize == 4096 || (sample_rate > 48000 && (blocksize == 8192 ||
blocksize == 16384)))
                 return true;
         else
                 return false;
}

instead of

FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned
blocksize, unsigned sample_rate)
{
         if(blocksize > 16384)
                 return false;
         else if(sample_rate <= 48000 && blocksize > 4608)
                 return false;
         else
                 return true;
}

FLAC__format_blocksize_is_subset from format.c IS NOT EQUAL to my
code. E.g. FLAC__format_blocksize_is_subset(1536, 44100) from format.c
returns true, but 1536 is not subset blocksize because 1536 is not one
of 192/576/1152/2304/4608/256/512/1024/2048/4096!

> I don't understand what it is you don't get about those blocksizes.
> For
> subset streams, the blocksize has to be one of 576/1152/2304/4608 or
> 256/512/1024/2048/4096 if the samplerate is lower then or equal to
> 48kHz, if higher, 8192 and 16384 are allowed too. If you use any other
> blocksize, the stream is not subset compliant.
>
> Considering the fixed or variable blocksize stuff, the subset does not
> restrict that, so using a variable blocksize is technically subset
> compliant. However, flake does warn when using variable blocksizes
> that
> the stream is not subset compliant. The thing is, it's not in the
> reference encoder, so probably most (hardware) decoders haven't been
> tested with it. If you want to be safe, you should probably restrict
> yourself to a fixed-blocksize stream.
>
> Finally, ffmpeg level 12 is not subset compliant.


>> I'm misleading about FLAC subset constraints... Please help me
>> understand exact FLAC subset limitation.
>>
>>  From https://www.xiph.org/flac/
>> documentation_tools_flac.html#flac_options_blocksize:
>>
>> Subset streams must use one of
>> 192/576/1152/2304/4608/256/512/1024/2048/4096 (and 8192/16384 if the
>> sample rate is >48kHz). The reference encoder uses the same block
>> size
>> for the entire stream.
>>
>>  From https://www.xiph.org/flac/format.html#subset:
>>
>> The blocksize must be <=16384; if the sample rate is <= 48000Hz,
the
>> blocksize must be <=4608.
>>
>> Finally, "one of
192/576/1152/2304/4608/256/512/1024/2048/4096" or
>> just (simply) "<=4608", "one of 8192/16384" or
just "<=16384"?
>>
>> Maximum (4608) value and any intermediate values are not one of
>> 192/576/1152/2304/4608/256/512/1024/2048/4096.
>>
>> The first statement is more restricted.
>>
>> Is the word "must" to be interpreted as described in RFC 2119
>> (http://www.ietf.org/rfc/rfc2119.txt)?
>>
>> The second question:
>>
>>  From https://www.xiph.org/flac/documentation_format_overview.html:
>>
>> The reference encoder uses a single block size for the whole stream
>> but the FLAC format does not require it.
>>
>> Should stream MUST have constant (fixed) block size (if blocksize
>> satisfies all restrictions from first question) to be subset?
>>
>> Is variable block size stream (if blocksize satisfies all
>> restrictions
>> from first question) be subset?
>>
>> The third question:
>>
>> Is FLAC files compressed by FFMPEG with "-compression_level
12"
>> switch
>> are subset?
_______________________________________________
flac-dev mailing list
flac-dev at xiph.org