Hi, On Fri, Dec 2, 2011 at 6:36 PM, Derek Buitenhuis <[email protected]> wrote: > When decoding lossy WavPack samples, they are supposed > to be clipped, in order to be decoded correctly. > > Signed-off-by: Derek Buitenhuis <[email protected]> > --- > libavcodec/wavpack.c | 12 +++++++++++- > 1 files changed, 11 insertions(+), 1 deletions(-) > > diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c > index e4b7ebe..a781f27 100644 > --- a/libavcodec/wavpack.c > +++ b/libavcodec/wavpack.c > @@ -394,6 +394,7 @@ error: > static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t > *crc, int S) > { > int bit; > + int max; > > if(s->extra_bits){ > S <<= s->extra_bits; > @@ -403,8 +404,17 @@ static inline int > wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, in > *crc = *crc * 9 + (S&0xffff) * 3 + ((unsigned)S>>16); > } > } > + > bit = (S & s->and) | s->or; > - return (((S + bit) << s->shift) - bit) << s->post_shift; > + bit = (((S + bit) << s->shift) - bit); > + > + /* If it is lossy, bit needs to be clipped */ > + if(s->hybrid) { > + max = 1 << ((((s->frame_flags & 0x03) + 1) << 3) - 1); > + bit = av_clip(bit, -max, max - 1); > + } > + > + return bit << s->post_shift;
As per IRC, please calculate the min/max_range values outside the loop. Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
