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

lvqcl lvqcl.mail at gmail.com
Fri Jun 20 03:15:31 PDT 2014


Miroslav Lichvar wrote:

>>  From FLAC__fixed_compute_residual:
>>      residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
>>
>> so max(residual[i]) == 16 * max(data[j]), or:  max_bps(residual[]) == 4 + max_bps(data[]).
>>
>> Am I right that it's the reason why FLAC__MAX_EXTRA_RESIDUAL_BPS is equal to 4?
>
> Not really, it's just a guess. With LPC the maximum possible residual
> could be much larger than with the fixed predictor if the coefficients
> were chosen randomly, but the autocorrelation routine should keep them
> more reasonable. The snippet6.wav file needed 2, so I made it slightly
> larger to have some extra room.
>
> As overflow in the accumulator won't result in a data loss, I think
> this is good enough until someone can figure out a better approach.


I see.

FLAC calculates real bitdepth of input signal for every block. Is it
feasible to calculate real bitdepth of residual signal and use this
value instead of (bps + 4) ?


More information about the flac-dev mailing list