Commit 15e07348 authored by Paul B Mahol's avatar Paul B Mahol Committed by Michael Niedermayer

ttadec: refactor ttafilter_process()

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 1a7a707f
......@@ -98,67 +98,35 @@ static void ttafilter_init(TTAFilter *c, int32_t shift) {
// c->round = 1 << (shift - 1);
}
// FIXME: copy paste from original
static inline void memshl(register int32_t *a, register int32_t *b) {
*a++ = *b++;
*a++ = *b++;
*a++ = *b++;
*a++ = *b++;
*a++ = *b++;
*a++ = *b++;
*a++ = *b++;
*a = *b;
}
static inline void ttafilter_process(TTAFilter *c, int32_t *in)
{
register int32_t *dl = c->dl, *qm = c->qm, *dx = c->dx, sum = c->round;
if (!c->error) {
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
sum += *dl++ * *qm, qm++;
dx += 8;
} else if(c->error < 0) {
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
sum += *dl++ * (*qm -= *dx++), qm++;
} else {
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
sum += *dl++ * (*qm += *dx++), qm++;
if (c->error < 0) {
qm[0] -= dx[0]; qm[1] -= dx[1]; qm[2] -= dx[2]; qm[3] -= dx[3];
qm[4] -= dx[4]; qm[5] -= dx[5]; qm[6] -= dx[6]; qm[7] -= dx[7];
} else if (c->error > 0) {
qm[0] += dx[0]; qm[1] += dx[1]; qm[2] += dx[2]; qm[3] += dx[3];
qm[4] += dx[4]; qm[5] += dx[5]; qm[6] += dx[6]; qm[7] += dx[7];
}
*(dx-0) = ((*(dl-1) >> 30) | 1) << 2;
*(dx-1) = ((*(dl-2) >> 30) | 1) << 1;
*(dx-2) = ((*(dl-3) >> 30) | 1) << 1;
*(dx-3) = ((*(dl-4) >> 30) | 1);
sum += dl[0] * qm[0] + dl[1] * qm[1] + dl[2] * qm[2] + dl[3] * qm[3] +
dl[4] * qm[4] + dl[5] * qm[5] + dl[6] * qm[6] + dl[7] * qm[7];
dx[0] = dx[1]; dx[1] = dx[2]; dx[2] = dx[3]; dx[3] = dx[4];
dl[0] = dl[1]; dl[1] = dl[2]; dl[2] = dl[3]; dl[3] = dl[4];
dx[4] = ((dl[4] >> 30) | 1);
dx[5] = ((dl[5] >> 30) | 2) & ~1;
dx[6] = ((dl[6] >> 30) | 2) & ~1;
dx[7] = ((dl[7] >> 30) | 4) & ~3;
c->error = *in;
*in += (sum >> c->shift);
*dl = *in;
*(dl-1) = *dl - *(dl-1);
*(dl-2) = *(dl-1) - *(dl-2);
*(dl-3) = *(dl-2) - *(dl-3);
memshl(c->dl, c->dl + 1);
memshl(c->dx, c->dx + 1);
dl[4] = -dl[5]; dl[5] = -dl[6];
dl[6] = *in - dl[7]; dl[7] = *in;
dl[5] += dl[6]; dl[4] += dl[5];
}
static void rice_init(TTARice *c, uint32_t k0, uint32_t k1)
......
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