]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/g723_1dec.c
avcodec/takdec: Fix overflow with large sample rates
[ffmpeg] / libavcodec / g723_1dec.c
index d8bc3f97acfddcda0fdc06bae0969d29572ffc23..a7bf528470e5c3de1b18b4d932510f206a037d5c 100644 (file)
@@ -678,6 +678,8 @@ static int estimate_sid_gain(G723_1_ChannelContext *p)
             else                 t = INT32_MAX;
         } else
             t = p->sid_gain << shift;
+    } else if(shift < -31) {
+        t = (p->sid_gain < 0) ? -1 : 0;
     }else
         t = p->sid_gain >> -shift;
     x = av_clipl_int32(t * (int64_t)cng_filt[0] >> 16);
@@ -1010,7 +1012,7 @@ static int g723_1_decode_frame(AVCodecContext *avctx, void *data,
             formant_postfilter(p, lpc, p->audio, out);
         } else { // if output is not postfiltered it should be scaled by 2
             for (i = 0; i < FRAME_LEN; i++)
-                out[i] = av_clip_int16(p->audio[LPC_ORDER + i] << 1);
+                out[i] = av_clip_int16(2 * p->audio[LPC_ORDER + i]);
         }
     }