[FFmpeg-devel] [PATCH] avcodec/wmalossless: use av_clip_intp2

zhaoxiu.zeng zhaoxiu.zeng at gmail.com
Sat Mar 7 16:44:10 CET 2015


>From 47c997fa0623ab94a7a93b2d2e4cc4fa64c85d5f Mon Sep 17 00:00:00 2001
From: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
Date: Sat, 7 Mar 2015 23:26:42 +0800
Subject: [PATCH 1/1] avcodec/wmalossless: use av_clip_intp2

Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng at gmail.com>
---
 libavcodec/wmalosslessdec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index fcadbc0..afe82a9 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -622,7 +622,6 @@ static void mclms_update(WmallDecodeCtx *s, int icoef, int *pred)
     int i, j, ich, pred_error;
     int order        = s->mclms_order;
     int num_channels = s->num_channels;
-    int range        = 1 << (s->bits_per_sample - 1);
 
     for (ich = 0; ich < num_channels; ich++) {
         pred_error = s->channel_residues[ich][icoef] - pred[ich];
@@ -643,8 +642,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] = av_clip(s->channel_residues[ich][icoef],
-            -range, range - 1);
+        s->mclms_prevvalues[s->mclms_recent] = av_clip_intp2(s->channel_residues[ich][icoef],
+            s->bits_per_sample - 1);
         s->mclms_updates[s->mclms_recent] = WMASIGN(s->channel_residues[ich][icoef]);
     }
 
@@ -693,7 +692,6 @@ static void revert_mclms(WmallDecodeCtx *s, int tile_size)
 static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int input)
 {
     int recent = s->cdlms[ich][ilms].recent;
-    int range  = 1 << s->bits_per_sample - 1;
     int order  = s->cdlms[ich][ilms].order;
 
     if (recent)
@@ -706,7 +704,7 @@ static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int input)
         recent = order - 1;
     }
 
-    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
+    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip_intp2(input, s->bits_per_sample - 1);
     s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich];
 
     s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2;
-- 
2.1.0



More information about the ffmpeg-devel mailing list