[FFmpeg-devel] [PATCH 1/2] wavpack: Clip samples after shifting

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Dec 16 19:32:05 CET 2011


It doesn't make much sense to clip pre-shift,
nor is it correct for proper decoding.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 libavcodec/wavpack.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 1a8c259..9f1ce34 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -405,12 +405,12 @@ static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, in
     }
 
     bit = (S & s->and) | s->or;
-    bit = (((S + bit) << s->shift) - bit);
+    bit = (((S + bit) << s->shift) - bit) << s->post_shift;
 
     if(s->hybrid)
         bit = av_clip(bit, -s->hybrid_maxclip, s->hybrid_maxclip - 1);
 
-    return bit << s->post_shift;
+    return bit;
 }
 
 static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S)
-- 
1.7.7.3



More information about the ffmpeg-devel mailing list