[flac-dev] About a comment in stream_decoder.c

lvqcl lvqcl.mail at gmail.com
Mon Apr 20 10:00:20 PDT 2015


I don't understand the comment in src/libFLAC/stream_decoder.c:

		/*@@@@@@ technically not pessimistic enough, should be more like
		if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) )
		*/
		if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)


see http://git.xiph.org/?p=flac.git;a=commitdiff;h=8534bbe4e92300609fd6dc289d882130b69d48cd



First, I suspect that there's a typo and the intended code is

		... < (((FLAC__uint64)1) << 32) )

(without an unary minus).


Second, this condition (in algebraic form)

	order * (2^bps - 1) * (2^qlp_coeff_precision - 1) < 2^32

makes sense if qlp_coeff[] and data[] in FLAC__lpc_restore_signal() are
unsigned integers. But they are signed, and the condition should be

	order * 2^(bps-1) * 2^(qlp_coeff_precision-1) < 2^31

which is equivalent to the current

	bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32

So IMHO the comment is incorrect.


More information about the flac-dev mailing list