From a3a8d5e0c1c78cdccc6a25a27b78476cfde32814 Mon Sep 17 00:00:00 2001 From: Mashiat Sarker Shakkhar Date: Tue, 22 Nov 2011 00:54:01 +0600 Subject: [PATCH 1/3] Initialize pred in lms_predict() --- libavcodec/wmalosslessdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 3ae698538b..5b11d7d4a4 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -789,7 +789,7 @@ static void reset_codec(WmallDecodeCtx *s) static int lms_predict(WmallDecodeCtx *s, int ich, int ilms) { - int32_t pred, icoef; + int32_t pred = 0, icoef; int recent = s->cdlms[ich][ilms].recent; for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++) From 6cf31ef263d36f6b89d9b64f15ca81cef4f24901 Mon Sep 17 00:00:00 2001 From: Mashiat Sarker Shakkhar Date: Tue, 22 Nov 2011 01:01:30 +0600 Subject: [PATCH 2/3] Fix some loop conditions to prevent overreads --- libavcodec/wmalosslessdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 5b11d7d4a4..051ad1a9e8 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -857,7 +857,7 @@ static void use_high_update_speed(WmallDecodeCtx *s, int ich) { int ilms, recent, icoef; s->update_speed[ich] = 16; - for (ilms = s->cdlms_ttl[ich]; ilms >= 0; ilms--) { + for (ilms = s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) { recent = s->cdlms[ich][ilms].recent; if (s->bV3RTM) { for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++) @@ -873,7 +873,7 @@ static void use_normal_update_speed(WmallDecodeCtx *s, int ich) { int ilms, recent, icoef; s->update_speed[ich] = 8; - for (ilms = s->cdlms_ttl[ich]; ilms >= 0; ilms--) { + for (ilms = s->cdlms_ttl[ich] - 1; ilms >= 0; ilms--) { recent = s->cdlms[ich][ilms].recent; if (s->bV3RTM) { for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++) @@ -901,7 +901,7 @@ static void revert_cdlms(WmallDecodeCtx *s, int tile_size) s->transient[ich] = 1; use_high_update_speed(s, ich); } - for (ilms = num_lms; ilms >= 0; ilms--) { + 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); From ea0323b0fad2a0f2884329105a52f694f3a327cd Mon Sep 17 00:00:00 2001 From: Mashiat Sarker Shakkhar Date: Tue, 22 Nov 2011 01:03:15 +0600 Subject: [PATCH 3/3] call revert_cdlms() --- libavcodec/wmalosslessdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 051ad1a9e8..bfc3903835 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1044,6 +1044,7 @@ static int decode_subframe(WmallDecodeCtx *s) if(s->is_channel_coded[i]) decode_channel_residues(s, i, subframe_len); } + revert_cdlms(s, subframe_len); /** handled one subframe */