summaryrefslogtreecommitdiff
path: root/libavcodec/wmalosslessdec.c
diff options
context:
space:
mode:
authorzhaoxiu.zeng <zhaoxiu.zeng@gmail.com>2015-02-14 00:53:12 +0800
committerMichael Niedermayer <michaelni@gmx.at>2015-02-13 23:08:00 +0100
commit9e6198f0a457630dde5f433fcd1dd40e10e00333 (patch)
tree2684c1bda1802e9d5c30814c7118a98df9c0f727 /libavcodec/wmalosslessdec.c
parent80f13780051fd9afa924e1c0db2eb36701592c75 (diff)
avcodec/wmalosslessdec: simplify
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/wmalosslessdec.c')
-rw-r--r--libavcodec/wmalosslessdec.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 19165941f1..a03b118e86 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -553,10 +553,7 @@ static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)
s->ave_sum[ch] = residue + s->ave_sum[ch] -
(s->ave_sum[ch] >> s->movave_scaling);
- if (residue & 1)
- residue = -(residue >> 1) - 1;
- else
- residue = residue >> 1;
+ residue = (residue >> 1) ^ -(residue & 1);
s->channel_residues[ch][i] = residue;
}
@@ -646,12 +643,8 @@ static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
for (ich = num_channels - 1; ich >= 0; ich--) {
s->mclms_recent--;
- s->mclms_prevvalues[s->mclms_recent] = s->channel_residues[ich][icoef];
- if (s->channel_residues[ich][icoef] > range - 1)
- s->mclms_prevvalues[s->mclms_recent] = range - 1;
- else if (s->channel_residues[ich][icoef] < -range)
- s->mclms_prevvalues[s->mclms_recent] = -range;
-
+ s->mclms_prevvalues[s->mclms_recent] = av_clip(s->channel_residues[ich][icoef],
+ -range, range - 1);
s->mclms_updates[s->mclms_recent] = WMASIGN(s->channel_residues[ich][icoef]);
}
@@ -1073,8 +1066,7 @@ static int decode_frame(WmallDecodeCtx *s)
av_dlog(s->avctx, "Frame done\n");
- if (s->skip_frame)
- s->skip_frame = 0;
+ s->skip_frame = 0;
if (s->len_prefix) {
if (len != (get_bits_count(gb) - s->frame_offset) + 2) {