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

Michael Niedermayer michaelni at gmx.at
Sat Dec 17 02:31:34 CET 2011


On Fri, Dec 16, 2011 at 01:32:05PM -0500, Derek Buitenhuis wrote:
> 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);

this does not work with 32bit

for example consider 0x40000000 and post_shift of 2 (or 1)
it will be 0 or worse before it gets cliped correctly to 0x7FFFFFFF


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111217/90bacde5/attachment.asc>


More information about the ffmpeg-devel mailing list