diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-05 00:11:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-05 00:11:57 +0100 |
commit | 707138593af5c4783035d0b9cc2d7c8cb2137dfa (patch) | |
tree | 7ead2e3c73fd33764dede26546b0238bb40d484b /libavcodec/wavpack.c | |
parent | 2f8b6e909dd733d9b722a5266ca516a9a5ba67e9 (diff) | |
parent | dc6d0430503ecd7ed0d81276f977b26b4c4bd916 (diff) | |
download | ffmpeg-707138593af5c4783035d0b9cc2d7c8cb2137dfa.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
adpcmenc: cosmetics: pretty-printing
ac3dec: cosmetics: pretty-printing
yuv4mpeg: cosmetics: pretty-printing
shorten: remove dead initialization
roqvideodec: set AVFrame reference before reget_buffer.
bmp: fix some 1bit samples.
latmdec: add fate test for audio config change
oma: PCM support
oma: better format detection with small probe buffer
oma: clearify ambiguous if condition
wavpack: Properly clip samples during lossy decode
Code clean-up for crc.c, lfg.c, log.c, random_see.d, rational.c and tree.c.
Cleaned pixdesc.c file in libavutil
zmbv.c: coding style clean-up.
xan.c: coding style clean-up.
mpegvideo.c: code cleanup - first 500 lines.
Conflicts:
Changelog
libavcodec/adpcmenc.c
libavcodec/bmp.c
libavcodec/zmbv.c
libavutil/log.c
libavutil/pixdesc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/wavpack.c')
-rw-r--r-- | libavcodec/wavpack.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 1ccaec665d..1a8c25943f 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -110,7 +110,7 @@ typedef struct WavpackFrameContext { int extra_bits; int and, or, shift; int post_shift; - int hybrid, hybrid_bitrate; + int hybrid, hybrid_bitrate, hybrid_maxclip; int float_flag; int float_shift; int float_max_exp; @@ -403,8 +403,14 @@ 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(s->hybrid) + bit = av_clip(bit, -s->hybrid_maxclip, s->hybrid_maxclip - 1); + + return bit << s->post_shift; } static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) @@ -792,6 +798,7 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, s->joint = s->frame_flags & WV_JOINT_STEREO; s->hybrid = s->frame_flags & WV_HYBRID_MODE; s->hybrid_bitrate = s->frame_flags & WV_HYBRID_BITRATE; + s->hybrid_maxclip = 1 << ((((s->frame_flags & 0x03) + 1) << 3) - 1); s->post_shift = 8 * (bpp-1-(s->frame_flags&0x03)) + ((s->frame_flags >> 13) & 0x1f); s->CRC = AV_RL32(buf); buf += 4; if(wc->mkv_mode) |