changeset 4835:ae2f8c9bc25d libavcodec

Fix an underflow/overflow that was causing some crackles when playing certain THP files. patch by Marco Gerards, mgerards xs4all nl
author diego
date Tue, 10 Apr 2007 08:18:04 +0000
parents 300b60dee58c
children ae19d863073f
files adpcm.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/adpcm.c	Tue Apr 10 05:31:22 2007 +0000
+++ b/adpcm.c	Tue Apr 10 08:18:04 2007 +0000
@@ -1359,8 +1359,10 @@
                     if(n&1) sampledat=  *src++    <<28;
                     else    sampledat= (*src&0xF0)<<24;
 
-                    *samples = ((prev[ch][0]*factor1
+                    sampledat = ((prev[ch][0]*factor1
                                 + prev[ch][1]*factor2) >> 11) + (sampledat>>exp);
+                    CLAMP_TO_SHORT(sampledat);
+                    *samples = sampledat;
                     prev[ch][1] = prev[ch][0];
                     prev[ch][0] = *samples++;