[Ffmpeg-devel] THP ADPCM overflow fix [PATCH]
Marco Gerards
mgerards
Mon Apr 9 20:12:21 CEST 2007
Hi,
There are some cracks when playing some THP files (the samples on the
website work just fine). This is because of an underflow/overflow.
Here is a patch to fix this.
--
Marco
Index: libavcodec/adpcm.c
===================================================================
--- libavcodec/adpcm.c (revision 8698)
+++ libavcodec/adpcm.c (working copy)
@@ -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++;
More information about the ffmpeg-devel
mailing list