Commit 46e2afa4 authored by Christophe Gisquet's avatar Christophe Gisquet Committed by Michael Niedermayer

wmalossless: reset lms_update

It may contain garbage at the end, and zeroing allows using DSP
with longer loops.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 1de74214
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment