[flac-dev] [PATCH] stream_encoder : Improve selection of residual accumulator width

Miroslav Lichvar mlichvar at redhat.com
Thu Jun 19 08:04:23 PDT 2014


On Thu, Jun 19, 2014 at 06:25:57PM +0400, lvqcl wrote:
> Now I wonder why evaluate_lpc_subframe_() function in stream_encoder.c contains
> almost the same code, but without any comments that it's not enough pessimistic:

> evaluate_lpc_subframe_():
> 
> if(subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
> 	if(subframe_bps <= 16 && qlp_coeff_precision <= 16)
> 		encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit(...);
> 	else
> 		encoder->private_->local_lpc_compute_residual_from_qlp_coefficients(...);
> else
> 	encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit(...);

Yes, it's the same check. Assuming residual can be at most
FLAC__MAX_EXTRA_RESIDUAL_BPS bits wider than subframe_bps, I think it
should be:

if(subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order) + FLAC__MAX_EXTRA_RESIDUAL_BPS - 1 <= 32)
	if(subframe_bps + FLAC__MAX_EXTRA_RESIDUAL_BPS <= 16 && qlp_coeff_precision <= 16)

> vs. read_subframe_lpc_():
> 
> if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
> 	if(bps <= 16 && subframe->qlp_coeff_precision <= 16)
> 		decoder->private_->local_lpc_restore_signal_16bit(...);
> 	else
> 		decoder->private_->local_lpc_restore_signal(...);
> else
> 	decoder->private_->local_lpc_restore_signal_64bit(...);

-- 
Miroslav Lichvar


More information about the flac-dev mailing list