diff options
author | Christophe Gisquet <christophe.gisquet@gmail.com> | 2015-02-07 09:20:09 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-07 15:14:32 +0100 |
commit | 46e2afa4dcb5ed6b4a6aa7aacbce2df74ed09c03 (patch) | |
tree | 98ea0abd13cb7540f21e166f4918eba4f3277b9b /libavcodec | |
parent | 1de742145f58b362736e01d6cd0c66c58d6f7533 (diff) | |
download | ffmpeg-46e2afa4dcb5ed6b4a6aa7aacbce2df74ed09c03.tar.gz |
wmalossless: reset lms_update
It may contain garbage at the end, and zeroing allows using DSP
with longer loops.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/wmalosslessdec.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index e6e34767bb..557b6b9805 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -147,8 +147,8 @@ typedef struct WmallDecodeCtx { int coefsend; int bitsend; DECLARE_ALIGNED(16, int16_t, coefs)[MAX_ORDER + WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]; - DECLARE_ALIGNED(16, int16_t, lms_prevvalues)[MAX_ORDER * 2]; - DECLARE_ALIGNED(16, int16_t, lms_updates)[MAX_ORDER * 2]; + DECLARE_ALIGNED(16, int16_t, lms_prevvalues)[MAX_ORDER * 2 + WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]; + DECLARE_ALIGNED(16, int16_t, lms_updates)[MAX_ORDER * 2 + WMALL_COEFF_PAD_SIZE/sizeof(int16_t)]; int recent; } cdlms[WMALL_MAX_CHANNELS][9]; @@ -711,17 +711,16 @@ 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) recent--; else { - memcpy(&s->cdlms[ich][ilms].lms_prevvalues[s->cdlms[ich][ilms].order], - s->cdlms[ich][ilms].lms_prevvalues, - 2 * s->cdlms[ich][ilms].order); - memcpy(&s->cdlms[ich][ilms].lms_updates[s->cdlms[ich][ilms].order], - s->cdlms[ich][ilms].lms_updates, - 2 * s->cdlms[ich][ilms].order); - recent = s->cdlms[ich][ilms].order - 1; + memcpy(s->cdlms[ich][ilms].lms_prevvalues + order, + s->cdlms[ich][ilms].lms_prevvalues, 2 * order); + memcpy(s->cdlms[ich][ilms].lms_updates + order, + s->cdlms[ich][ilms].lms_updates, 2 * order); + recent = order - 1; } s->cdlms[ich][ilms].lms_prevvalues[recent] = av_clip(input, -range, range - 1); @@ -732,9 +731,11 @@ static void lms_update(WmallDecodeCtx *s, int ich, int ilms, int input) else s->cdlms[ich][ilms].lms_updates[recent] = s->update_speed[ich]; - s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 4)] >>= 2; - s->cdlms[ich][ilms].lms_updates[recent + (s->cdlms[ich][ilms].order >> 3)] >>= 1; + 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) - 2*(recent+order)); } static void use_high_update_speed(WmallDecodeCtx *s, int ich) @@ -790,7 +791,8 @@ static void revert_cdlms(WmallDecodeCtx *s, int ch, + s->cdlms[ch][ilms].recent, s->cdlms[ch][ilms].lms_updates + s->cdlms[ch][ilms].recent, - s->cdlms[ch][ilms].order, + FFALIGN(s->cdlms[ch][ilms].order, + WMALL_COEFF_PAD_SIZE), WMASIGN(residue)); input = residue + (pred >> s->cdlms[ch][ilms].scaling); lms_update(s, ch, ilms, input); |