# HG changeset patch # User Matti Hamalainen # Date 1234184216 -7200 # Node ID 229fa2d043b9ae192dbb161290b55d580f00b2ac # Parent 06db79680afe012b9ab859b94a4e1e6a316fa929 Moved filter routines to xs_support.[ch]. diff -r 06db79680afe -r 229fa2d043b9 src/xmms-sid.c --- a/src/xmms-sid.c Mon Feb 09 13:23:32 2009 +0200 +++ b/src/xmms-sid.c Mon Feb 09 14:56:56 2009 +0200 @@ -34,7 +34,6 @@ #include "xs_length.h" #include "xs_stil.h" #include "xs_title.h" -#include "xs_filter.h" #include "xs_fileinfo.h" #include "xs_interface.h" #include "xs_glade.h" diff -r 06db79680afe -r 229fa2d043b9 src/xs_filter.c --- a/src/xs_filter.c Mon Feb 09 13:23:32 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/* - XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) - - Audio rate-conversion filter - - Programmed and designed by Matti 'ccr' Hamalainen - (C) Copyright 1999-2007 Tecnic Software productions (TNSP) - - 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 along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#include "xs_filter.h" - -/* Let's do some preprocessor magic :) */ -#define XS_FVAR(T, P, K) g ## K ## int ## P *sp_ ## T ## P , *dp_ ## T ## P - -#define XS_FILTER1(T, P, K, Q) \ - dataSize /= sizeof(g ## K ## int ## P); \ - sp_ ## T ## P = (g ## K ## int ## P *) srcBuf; \ - dp_ ## T ## P = (g ## K ## int ## P *) destBuf; \ - while (dataSize-- > 0) { \ - for (tmp = 0, i = 0; i < oversampleFactor; i++) \ - tmp += (gint32) ((gint ## P) (*(sp_ ## T ## P ++) Q)); \ - xs_filter_mbn = (tmp + xs_filter_mbn) / (oversampleFactor + 1); \ - *(dp_ ## T ## P ++) = ((g ## K ## int ## P) xs_filter_mbn) Q ; \ - } - - -static gint32 xs_filter_mbn = 0; - - -gint xs_filter_rateconv(void *destBuf, void *srcBuf, const AFormat audioFormat, - const gint oversampleFactor, const gint bufSize) -{ - static gint32 tmp; - XS_FVAR(s, 8,); - XS_FVAR(u, 8, u); - XS_FVAR(s, 16,); - XS_FVAR(u, 16, u); - gint i; - gint dataSize = bufSize; - - if (dataSize <= 0) - return dataSize; - - switch (audioFormat) { - case FMT_U8: - XS_FILTER1(u, 8, u, ^0x80) - break; - - case FMT_S8: - XS_FILTER1(s, 8,,) - break; - - - case FMT_U16_BE: - case FMT_U16_LE: - case FMT_U16_NE: - XS_FILTER1(u, 16, u, ^0x8000) - break; - - case FMT_S16_BE: - case FMT_S16_LE: - case FMT_S16_NE: - XS_FILTER1(s, 16,,) - break; - - default: - return -1; - } - - return 0; -} diff -r 06db79680afe -r 229fa2d043b9 src/xs_filter.h --- a/src/xs_filter.h Mon Feb 09 13:23:32 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#ifndef XS_FILTER_H -#define XS_FILTER_H - -#include "xmms-sid.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* -typedef struct { -} t_xs_filter; - -void xs_filter_init(t_xs_filter *); -*/ -gint xs_filter_rateconv(void *, void *, const AFormat, const gint, const gint); - -#ifdef __cplusplus -} -#endif -#endif /* XS_FILTER_H */ diff -r 06db79680afe -r 229fa2d043b9 src/xs_support.c --- a/src/xs_support.c Mon Feb 09 13:23:32 2009 +0200 +++ b/src/xs_support.c Mon Feb 09 14:56:56 2009 +0200 @@ -243,3 +243,64 @@ (*pos)++; } + +/* Let's do some preprocessor magic :) */ +#define XS_FVAR(T, P, K) g ## K ## int ## P *sp_ ## T ## P , *dp_ ## T ## P + +#define XS_FILTER1(T, P, K, Q) \ + dataSize /= sizeof(g ## K ## int ## P); \ + sp_ ## T ## P = (g ## K ## int ## P *) srcBuf; \ + dp_ ## T ## P = (g ## K ## int ## P *) destBuf; \ + while (dataSize-- > 0) { \ + for (tmp = 0, i = 0; i < oversampleFactor; i++) \ + tmp += (gint32) ((gint ## P) (*(sp_ ## T ## P ++) Q)); \ + xs_filter_mbn = (tmp + xs_filter_mbn) / (oversampleFactor + 1); \ + *(dp_ ## T ## P ++) = ((g ## K ## int ## P) xs_filter_mbn) Q ; \ + } + + +static gint32 xs_filter_mbn = 0; + + +gint xs_filter_rateconv(void *destBuf, void *srcBuf, const AFormat audioFormat, + const gint oversampleFactor, const gint bufSize) +{ + static gint32 tmp; + XS_FVAR(s, 8,); + XS_FVAR(u, 8, u); + XS_FVAR(s, 16,); + XS_FVAR(u, 16, u); + gint i; + gint dataSize = bufSize; + + if (dataSize <= 0) + return dataSize; + + switch (audioFormat) { + case FMT_U8: + XS_FILTER1(u, 8, u, ^0x80) + break; + + case FMT_S8: + XS_FILTER1(s, 8,,) + break; + + + case FMT_U16_BE: + case FMT_U16_LE: + case FMT_U16_NE: + XS_FILTER1(u, 16, u, ^0x8000) + break; + + case FMT_S16_BE: + case FMT_S16_LE: + case FMT_S16_NE: + XS_FILTER1(s, 16,,) + break; + + default: + return -1; + } + + return 0; +} diff -r 06db79680afe -r 229fa2d043b9 src/xs_support.h --- a/src/xs_support.h Mon Feb 09 13:23:32 2009 +0200 +++ b/src/xs_support.h Mon Feb 09 14:56:56 2009 +0200 @@ -102,6 +102,15 @@ void xs_findeol(const gchar *, size_t *); void xs_findnum(const gchar *, size_t *); +/* +typedef struct { +} t_xs_filter; + +void xs_filter_init(t_xs_filter *); +*/ +gint xs_filter_rateconv(void *, void *, const AFormat, const gint, const gint); + + #ifdef __cplusplus } #endif