Mercurial > libavcodec.hg
comparison imc.c @ 12391:4be72e19ab0e libavcodec
imc: fix undefined float to int conversion
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.
author | mru |
---|---|
date | Thu, 19 Aug 2010 16:51:26 +0000 |
parents | 93ba40eb28b9 |
children |
comparison
equal
deleted
inserted
replaced
12390:21133d90ecf2 | 12391:4be72e19ab0e |
---|---|
360 | 360 |
361 summer = 0; | 361 summer = 0; |
362 iacc = 0; | 362 iacc = 0; |
363 | 363 |
364 for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) { | 364 for(j = (stream_format_code & 0x2)?4:0; j < BANDS; j++) { |
365 cwlen = av_clip((int)((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); | 365 cwlen = av_clipf(((q->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); |
366 | 366 |
367 q->bitsBandT[j] = cwlen; | 367 q->bitsBandT[j] = cwlen; |
368 summer += q->bandWidthT[j] * cwlen; | 368 summer += q->bandWidthT[j] * cwlen; |
369 | 369 |
370 if (cwlen > 0) | 370 if (cwlen > 0) |