2004-11-26 23:10:28 +00:00
|
|
|
/*
|
|
|
|
* filters.h
|
|
|
|
*
|
2005-12-06 19:55:58 +00:00
|
|
|
* Description: TTAv1 filter functions
|
2004-11-26 23:10:28 +00:00
|
|
|
* Developed by: Alexander Djourik <sasha@iszf.irk.ru>
|
|
|
|
* Pavel Zhilin <pzh@iszf.irk.ru>
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999-2004 Alexander Djourik. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* aint with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Please see the file COPYING in this directory for full copyright
|
|
|
|
* information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILTERS_H
|
|
|
|
#define FILTERS_H
|
|
|
|
|
|
|
|
///////// Filter Settings //////////
|
|
|
|
static long flt_set[3] = {10, 9, 10};
|
|
|
|
|
|
|
|
static void
|
|
|
|
memshl (register long *pA, register long *pB) {
|
2005-12-06 19:55:58 +00:00
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA++ = *pB++;
|
|
|
|
*pA = *pB;
|
2004-11-26 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
hybrid_filter (fltst *fs, long *in) {
|
2005-12-06 19:55:58 +00:00
|
|
|
register long *pA = fs->dl;
|
|
|
|
register long *pB = fs->qm;
|
|
|
|
register long *pM = fs->dx;
|
|
|
|
register long sum = fs->round;
|
2004-11-26 23:10:28 +00:00
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
if (!fs->error) {
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++;
|
|
|
|
sum += *pA++ * *pB, pB++; pM += 8;
|
|
|
|
} else if (fs->error < 0) {
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB -= *pM++), pB++;
|
|
|
|
} else {
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
sum += *pA++ * (*pB += *pM++), pB++;
|
|
|
|
}
|
2004-11-26 23:10:28 +00:00
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
*(pM-0) = ((*(pA-1) >> 30) | 1) << 2;
|
|
|
|
*(pM-1) = ((*(pA-2) >> 30) | 1) << 1;
|
|
|
|
*(pM-2) = ((*(pA-3) >> 30) | 1) << 1;
|
|
|
|
*(pM-3) = ((*(pA-4) >> 30) | 1);
|
2004-11-26 23:10:28 +00:00
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
fs->error = *in;
|
|
|
|
*in += (sum >> fs->shift);
|
|
|
|
*pA = *in;
|
2004-11-26 23:10:28 +00:00
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
*(pA-1) = *(pA-0) - *(pA-1);
|
|
|
|
*(pA-2) = *(pA-1) - *(pA-2);
|
|
|
|
*(pA-3) = *(pA-2) - *(pA-3);
|
2004-11-26 23:10:28 +00:00
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
memshl (fs->dl, fs->dl + 1);
|
|
|
|
memshl (fs->dx, fs->dx + 1);
|
2004-11-26 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filter_init (fltst *fs, long shift) {
|
2005-12-06 19:55:58 +00:00
|
|
|
memset (fs, 0, sizeof(fltst));
|
|
|
|
fs->shift = shift;
|
|
|
|
fs->round = 1 << (shift - 1);
|
2004-11-26 23:10:28 +00:00
|
|
|
}
|
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
#endif /* FILTERS_H */
|
2004-11-26 23:10:28 +00:00
|
|
|
|