avcodec/ac3: Fix undefined shift in ff_ac3_bit_alloc_calc_mask()
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 15 Mar 2015 10:21:50 +0000 (11:21 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 15 Mar 2015 10:21:50 +0000 (11:21 +0100)
Found-by: Clang -fsanitize=shift
Reported-by: Thierry Foucu <tfoucu@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/ac3.c

index 29e132f..c4fc77c 100644 (file)
@@ -200,9 +200,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
             if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
                 return -1;
             if (dba_values[seg] >= 4) {
-                delta = (dba_values[seg] - 3) << 7;
+                delta = (dba_values[seg] - 3) * 128;
             } else {
-                delta = (dba_values[seg] - 4) << 7;
+                delta = (dba_values[seg] - 4) * 128;
             }
             for (i = 0; i < dba_lengths[seg]; i++) {
                 mask[band++] += delta;