imc: fix undefined float to int conversion
authorMåns Rullgård <mans@mansr.com>
Thu, 19 Aug 2010 16:51:26 +0000 (16:51 +0000)
committerMåns Rullgård <mans@mansr.com>
Thu, 19 Aug 2010 16:51:26 +0000 (16:51 +0000)
Conversion of an out of range float to int is undefined.  Clipping to
the final range first avoids such problems.  This fixes decoding on
MIPS, which handles these conversions differently from many other CPUs.

Originally committed as revision 24838 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/imc.c

index b54937539d5b705747973a209785b5742aac34c5..730d8218da6120735b35e0d9e5eb6716812bff32 100644 (file)
@@ -362,7 +362,7 @@ static int bit_allocation (IMCContext* q, int stream_format_code, int freebits,
         iacc = 0;
 
         for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) {
-            cwlen = av_clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
+            cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
 
             q->bitsBandT[j] = cwlen;
             summer += q->bandWidthT[j] * cwlen;