[FFmpeg-devel] [PATCH][RFC] Lagarith Decoder.

Nathan Caldwell saintdev
Fri Aug 14 22:25:44 CEST 2009


On Wed, Aug 12, 2009 at 8:34 AM, Reimar
D?ffinger<Reimar.Doeffinger at gmx.de> wrote:
> On Mon, Aug 10, 2009 at 11:42:19PM -0600, Nathan Caldwell wrote:
>> + ? ?/* Scale probabilities so cumulative probability is an even power of 2. */
>> + ? ?cumulative_target = clp2(cumul_prob);
>> +
>> + ? ?scale_factor = cumulative_target / (double) cumul_prob;
>> +
>> + ? ?for (i = 1; i < 257; i++) {
>> + ? ? ? ?rac->prob[i] = (unsigned int) (rac->prob[i] * scale_factor);
>
> I think a 32x32 -> 64 bit multiply + right shift is a more reliable way
> to calculate this. floating-point IMO is usually misplaced in
> anything that claims to be lossless (yes, you can do it and even have
> it work cross-platform, but it's a real effort).

I tried this earlier, but it doesn't retain enough precision. It was
right most of the time, but not all the time. I'm open to any other
suggestions.


-- 
-Nathan Caldwell



More information about the ffmpeg-devel mailing list