avcodec/mpegvideo_enc: fix undefined shifts in ff_dct_quantize_c()
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 1 Jul 2015 11:39:43 +0000 (13:39 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 1 Jul 2015 11:40:36 +0000 (13:40 +0200)
Fixes: signal_sigsegv_35eac16_2762_cov_2704249783_missing_frames.avi

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpegvideo_enc.c

index e729d36..7f84bcc 100644 (file)
@@ -4559,12 +4559,12 @@ int ff_dct_quantize_c(MpegEncContext *s,
         start_i = 1;
         last_non_zero = 0;
         qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale];
-        bias= s->intra_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT);
+        bias= s->intra_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT));
     } else {
         start_i = 0;
         last_non_zero = -1;
         qmat = s->q_inter_matrix[qscale];
-        bias= s->inter_quant_bias<<(QMAT_SHIFT - QUANT_BIAS_SHIFT);
+        bias= s->inter_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT));
     }
     threshold1= (1<<QMAT_SHIFT) - bias - 1;
     threshold2= (threshold1<<1);