OSDN Git Service

libavcodec/mpegaudio_tablegen: clip value before casting
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 22 Oct 2013 10:48:47 +0000 (12:48 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 22 Oct 2013 10:48:47 +0000 (12:48 +0200)
Avoids FPE on alpha

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpegaudio_tablegen.h

index 789bc2a..5592b4a 100644 (file)
@@ -63,7 +63,7 @@ static void mpegaudio_tableinit(void)
             /* cbrtf() isn't available on all systems, so we use powf(). */
             double f = (double)value * pow(value, 1.0 / 3.0) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
             /* llrint() isn't always available, so round and cast manually. */
-            expval_table_fixed[exponent][value] = (long long int) floor(f + 0.5);
+            expval_table_fixed[exponent][value] = (long long int) FFMIN(floor(f + 0.5), 0xFFFFFFFF);
             expval_table_float[exponent][value] = f;
         }
         exp_table_fixed[exponent] = expval_table_fixed[exponent][1];