]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/aacsbr_fixed.c
Merge commit 'e7d7cf86dcaba8eaaed62c80172ff0aff2588c2a'
[ffmpeg] / libavcodec / aacsbr_fixed.c
index 8eb8c5867f19666a343b963382451489f90b33d6..2473de4ec5501c70256dde15b1cbbda59d597111 100644 (file)
@@ -169,6 +169,10 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
                 else
                   temp1.mant = 0x20000000;
                 temp1.exp = (temp1.exp >> 1) + 1;
+                if (temp1.exp > 66) { // temp1 > 1E20
+                    av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
+                    temp1 = FLOAT_1;
+                }
 
                 temp2.exp = (pan_offset - sbr->data[1].env_facs[e][k].mant) * alpha;
                 if (temp2.exp & 1)
@@ -186,9 +190,10 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
                 SoftFloat temp1, temp2, fac;
 
                 temp1.exp = NOISE_FLOOR_OFFSET - \
-                    sbr->data[0].noise_facs[e][k].mant + 2;
+                    sbr->data[0].noise_facs_q[e][k] + 2;
                 temp1.mant = 0x20000000;
-                temp2.exp = 12 - sbr->data[1].noise_facs[e][k].mant + 1;
+                av_assert0(temp1.exp <= 66);
+                temp2.exp = 12 - sbr->data[1].noise_facs_q[e][k] + 1;
                 temp2.mant = 0x20000000;
                 fac   = av_div_sf(temp1, av_add_sf(FLOAT_1, temp2));
                 sbr->data[0].noise_facs[e][k] = fac;
@@ -208,13 +213,16 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
                     else
                         temp1.mant = 0x20000000;
                     temp1.exp = (temp1.exp >> 1) + 1;
-
+                    if (temp1.exp > 66) { // temp1 > 1E20
+                        av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n");
+                        temp1 = FLOAT_1;
+                    }
                     sbr->data[ch].env_facs[e][k] = temp1;
                 }
             for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
                 for (k = 0; k < sbr->n_q; k++){
                     sbr->data[ch].noise_facs[e][k].exp = NOISE_FLOOR_OFFSET - \
-                        sbr->data[ch].noise_facs[e][k].mant + 1;
+                        sbr->data[ch].noise_facs_q[e][k] + 1;
                     sbr->data[ch].noise_facs[e][k].mant = 0x20000000;
                 }
         }