[FFmpeg-cvslog] Fix lms_update()

Mashiat Sarker Shakkhar git at videolan.org
Wed Dec 7 04:57:33 CET 2011


ffmpeg | branch: master | Mashiat Sarker Shakkhar <shahriman_ams at yahoo.com> | Fri Dec  2 16:24:50 2011 +0600| [460bec6800f6229b664297a6c83a5ef4f0701221] | committer: Mashiat Sarker Shakkhar

Fix lms_update()

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=460bec6800f6229b664297a6c83a5ef4f0701221
---

 libavcodec/wmalosslessdec.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index cdaf2f3..90a2c97 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -891,21 +891,23 @@ static int lms_predict(WmallDecodeCtx *s, int ich, int ilms)
     return pred;
 }
 
-static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int16_t input, int16_t pred)
+static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int16_t residue, int16_t pred)
 {
     int16_t icoef;
     int recent = s->cdlms[ich][ilms].recent;
     int16_t range = (1 << s->bits_per_sample - 1) - 1;
     int bps = s->bits_per_sample > 16 ? 4 : 2; // bytes per sample
+    int16_t input = residue + pred;
 
-    if (input > pred) {
+    if (residue > 0) {
         for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
             s->cdlms[ich][ilms].coefs[icoef] +=
                 s->cdlms[ich][ilms].lms_updates[icoef + recent];
     } else {
         for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++)
             s->cdlms[ich][ilms].coefs[icoef] -=
-                s->cdlms[ich][ilms].lms_updates[icoef];     // XXX: [icoef + recent] ?
+                s->cdlms[ich][ilms].lms_updates[icoef + recent];    /* spec mistakenly
+                                                                    dropped the recent */
     }
     s->cdlms[ich][ilms].recent--;
     s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1);
@@ -990,8 +992,8 @@ static void revert_cdlms(WmallDecodeCtx *s, int tile_size)
             }
             for (ilms = num_lms - 1; ilms >= 0; ilms--) {
                 pred = lms_predict(s, ich, ilms);
-                channel_coeff += pred;
                 lms_update(s, ich, ilms, channel_coeff, pred);
+                channel_coeff += pred;
             }
             if (s->transient[ich]) {
                 --s->channel[ich].transient_counter;



More information about the ffmpeg-cvslog mailing list