[FFmpeg-devel] [PATCH 3/6] wmalossless pro: move lms_update

Christophe Gisquet christophe.gisquet at gmail.com
Mon Apr 18 15:07:28 CEST 2016


Cosmetics before macroing it and another function.
---
 libavcodec/wmalosslessdec.c | 94 ++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 47 deletions(-)

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 3885dc1..77017ff 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -710,53 +710,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 (s->bits_per_sample > 16) {
-    if (recent)
-        recent--;
-    else {
-        memcpy(s->cdlms[ich][ilms].lms_prevvalues + order,
-               s->cdlms[ich][ilms].lms_prevvalues, sizeof(*s->cdlms[ich][ilms].lms_prevvalues) * order);
-        memcpy(s->cdlms[ich][ilms].lms_updates + order,
-               s->cdlms[ich][ilms].lms_updates, sizeof(*s->cdlms[ich][ilms].lms_updates) * order);
-        recent = order - 1;
-    }
-
-    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
-    s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich];
-
-    s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2;
-    s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1;
-    s->cdlms[ich][ilms].recent = recent;
-    memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0,
-           sizeof(s->cdlms[ich][ilms].lms_updates) - 4*(recent+order));
-    } else {
-        int16_t *prevvalues = s->cdlms[ich][ilms].lms_prevvalues;
-        int16_t *updates    = s->cdlms[ich][ilms].lms_updates;
-        if (recent)
-            recent--;
-        else {
-            memcpy(prevvalues + order, prevvalues, 2 * order);
-            memcpy(updates + order, updates, 2 * order);
-            recent = order - 1;
-        }
-    
-        prevvalues[recent] = av_clip(input, -range, range - 1);
-        updates[recent] = WMASIGN(input) * s->update_speed[ich];
-    
-        updates[recent + (order >> 4)] >>= 2;
-        updates[recent + (order >> 3)] >>= 1;
-        s->cdlms[ich][ilms].recent = recent;
-        memset(updates + recent + order, 0,
-               sizeof(s->cdlms[ich][ilms].lms_updates) - 2*(recent+order));
-    }
-}
-
 static void use_high_update_speed(WmallDecodeCtx *s, int ich)
 {
     int ilms, recent, icoef;
@@ -806,6 +759,53 @@ static void use_normal_update_speed(WmallDecodeCtx *s, int ich)
     s->update_speed[ich] = 8;
 }
 
+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 (s->bits_per_sample > 16) {
+    if (recent)
+        recent--;
+    else {
+        memcpy(s->cdlms[ich][ilms].lms_prevvalues + order,
+               s->cdlms[ich][ilms].lms_prevvalues, sizeof(*s->cdlms[ich][ilms].lms_prevvalues) * order);
+        memcpy(s->cdlms[ich][ilms].lms_updates + order,
+               s->cdlms[ich][ilms].lms_updates, sizeof(*s->cdlms[ich][ilms].lms_updates) * order);
+        recent = order - 1;
+    }
+
+    s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
+    s->cdlms[ich][ilms].lms_updates[recent] = WMASIGN(input) * s->update_speed[ich];
+
+    s->cdlms[ich][ilms].lms_updates[recent + (order >> 4)] >>= 2;
+    s->cdlms[ich][ilms].lms_updates[recent + (order >> 3)] >>= 1;
+    s->cdlms[ich][ilms].recent = recent;
+    memset(s->cdlms[ich][ilms].lms_updates + recent + order, 0,
+           sizeof(s->cdlms[ich][ilms].lms_updates) - 4*(recent+order));
+    } else {
+        int16_t *prevvalues = s->cdlms[ich][ilms].lms_prevvalues;
+        int16_t *updates    = s->cdlms[ich][ilms].lms_updates;
+        if (recent)
+            recent--;
+        else {
+            memcpy(prevvalues + order, prevvalues, 2 * order);
+            memcpy(updates + order, updates, 2 * order);
+            recent = order - 1;
+        }
+    
+        prevvalues[recent] = av_clip(input, -range, range - 1);
+        updates[recent] = WMASIGN(input) * s->update_speed[ich];
+    
+        updates[recent + (order >> 4)] >>= 2;
+        updates[recent + (order >> 3)] >>= 1;
+        s->cdlms[ich][ilms].recent = recent;
+        memset(updates + recent + order, 0,
+               sizeof(s->cdlms[ich][ilms].lms_updates) - 2*(recent+order));
+    }
+}
+
 static void revert_cdlms(WmallDecodeCtx *s, int ch,
                          int coef_begin, int coef_end)
 {
-- 
2.8.1



More information about the ffmpeg-devel mailing list