changeset 420:44c513ae3527 trunk

[svn] Remove equalization code. We do this same processing in the core in 0.2.
author nenolod
date Fri, 13 Jan 2006 14:50:54 -0800
parents 2291caab50ca
children 147325df7461
files Plugins/Input/wma/Makefile.am Plugins/Input/wma/iir.c Plugins/Input/wma/iir.h Plugins/Input/wma/wma.c
diffstat 4 files changed, 2 insertions(+), 275 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/wma/Makefile.am	Thu Jan 12 18:27:22 2006 -0800
+++ b/Plugins/Input/wma/Makefile.am	Fri Jan 13 14:50:54 2006 -0800
@@ -10,6 +10,6 @@
 
 libwma_la_LDFLAGS = $(PLUGIN_LDFLAGS) ./libffwma/libffwma.la
 
-libwma_la_SOURCES = wma.c iir.c
+libwma_la_SOURCES = wma.c
 
 INCLUDES = $(GTK_CFLAGS) -I$(top_builddir)/intl -I$(top_srcdir) -I./libffwma -std=c99
--- a/Plugins/Input/wma/iir.c	Thu Jan 12 18:27:22 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- *   PCM time-domain equalizer
- *
- *   Copyright (C) 2002  Felipe Rivera <liebremx at users sourceforge net>
- *
- *   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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *   $Id: iir.c,v 1.5 2003/09/10 21:53:08 liebremx Exp $
- */
-
-/* IIR filter coefficients */
-#include "iir.h"
-#include <math.h>
-#include <strings.h>
-
-/* History for two filters */
-static sXYData data_history[EQ_MAX_BANDS][EQ_CHANNELS] __attribute__((aligned));
-static sXYData data_history2[EQ_MAX_BANDS][EQ_CHANNELS] __attribute__((aligned));
-
-/* Coefficients */
-static sIIRCoefficients *iir_cf;
-
-/* Config EQ */
-static int band_num = 10;       /* Set num band: 10 - default in XMMS */ 
-static int extra_filtering = 1; /* Set extra filtering: 0 - OFF, 1 - ON */
-
-/* BETA, ALPHA, GAMMA */
-static sIIRCoefficients iir_cforiginal10[] __attribute__((aligned)) = {
-    { (9.9421504945e-01), (2.8924752745e-03), (1.9941421835e+00) },    /*    60.0 Hz */
-    { (9.8335039428e-01), (8.3248028618e-03), (1.9827686547e+00) },    /*   170.0 Hz */
-    { (9.6958094144e-01), (1.5209529281e-02), (1.9676601546e+00) },    /*   310.0 Hz */
-    { (9.4163923306e-01), (2.9180383468e-02), (1.9345490229e+00) },    /*   600.0 Hz */
-    { (9.0450844499e-01), (4.7745777504e-02), (1.8852109613e+00) },    /*  1000.0 Hz */
-    { (7.3940088234e-01), (1.3029955883e-01), (1.5829158753e+00) },    /*  3000.0 Hz */
-    { (5.4697667908e-01), (2.2651166046e-01), (1.0153238114e+00) },    /*  6000.0 Hz */
-    { (3.1023210589e-01), (3.4488394706e-01), (-1.8142472036e-01) },    /* 12000.0 Hz */
-    { (2.6718639778e-01), (3.6640680111e-01), (-5.2117742267e-01) },    /* 14000.0 Hz */
-    { (2.4201241845e-01), (3.7899379077e-01), (-8.0847117831e-01) },    /* 16000.0 Hz */
-};
-
-/* Init the filter */
-void init_iir()
-{
-	iir_cf = iir_cforiginal10;
-
-	/* Zero the history arrays */
-	bzero(data_history, sizeof(sXYData) * EQ_MAX_BANDS * EQ_CHANNELS);
-	bzero(data_history2, sizeof(sXYData) * EQ_MAX_BANDS * EQ_CHANNELS);
-}
-
-__inline__ int iir(gpointer * d, gint length)
-{
-	gint16 *data = (gint16 *) * d;
-	/* Indexes for the history arrays
-	 * These have to be kept between calls to this function
-	 * hence they are static */
-	static gint i = 0, j = 2, k = 1;	
-
-	gint index, band, channel;
-	gint tempgint, halflength;
-	float out[EQ_CHANNELS], pcm[EQ_CHANNELS];
-
-	/**
-	 * IIR filter equation is
-	 * y[n] = 2 * (alpha*(x[n]-x[n-2]) + gamma*y[n-1] - beta*y[n-2])
-	 *
-	 * NOTE: The 2 factor was introduced in the coefficients to save
-	 * 			a multiplication
-	 *
-	 * This algorithm cascades two filters to get nice filtering
-	 * at the expense of extra CPU cycles
-	 */
-	/* 16bit, 2 bytes per sample, so divide by two the length of
-	 * the buffer (length is in bytes)
-	 */
-	halflength = (length >> 1);
-	for (index = 0; index < halflength; index+=2)
-	{
-		/* For each channel */
-		for (channel = 0; channel < EQ_CHANNELS; channel++)
-		{
-			/* No need to scale when processing the PCM with the filter */
-			pcm[channel] = data[index+channel];
-			/* Preamp gain */
-			pcm[channel] *= preamp[channel];
-
-	
-			out[channel] = 0;
-			/* For each band */
-			for (band = 0; band < band_num; band++)
-			{
-				/* Store Xi(n) */
-				data_history[band][channel].x[i] = pcm[channel];
-				/* Calculate and store Yi(n) */
-				data_history[band][channel].y[i] = 
-               		   (
-               	/* 		= alpha * [x(n)-x(n-2)] */
-						iir_cf[band].alpha * ( data_history[band][channel].x[i]
-               			-  data_history[band][channel].x[k])
-               	/* 		+ gamma * y(n-1) */
-               			+ iir_cf[band].gamma * data_history[band][channel].y[j]
-               	/* 		- beta * y(n-2) */
-               			- iir_cf[band].beta * data_history[band][channel].y[k]
-						);
-				/* 
-				 * The multiplication by 2.0 was 'moved' into the coefficients to save
-				 * CPU cycles here */
-				 /* Apply the gain  */
-				out[channel] +=  data_history[band][channel].y[i]*gain[band][channel]; // * 2.0;
-			} /* For each band */
-
-                        if (extra_filtering)
-                        {
-				/* Filter the sample again */
-				for (band = 0; band < band_num; band++)
-				{
-					/* Store Xi(n) */
-					data_history2[band][channel].x[i] = out[channel];
-					/* Calculate and store Yi(n) */
-					data_history2[band][channel].y[i] = 
-            	   		   (
-	               	/* y(n) = alpha * [x(n)-x(n-2)] */
-							iir_cf[band].alpha * (data_history2[band][channel].x[i]
-            	   			-  data_history2[band][channel].x[k])
-               		/* 	    + gamma * y(n-1) */
-	               			+ iir_cf[band].gamma * data_history2[band][channel].y[j]
-    	           	/* 		- beta * y(n-2) */
-        	       			- iir_cf[band].beta * data_history2[band][channel].y[k]
-							);
-					/* Apply the gain */
-					out[channel] +=  data_history2[band][channel].y[i]*gain[band][channel];
-				} /* For each band */
-                        }
-
-			/* Volume stuff
-			   Scale down original PCM sample and add it to the filters 
-			   output. This substitutes the multiplication by 0.25
-			 */
-
-			out[channel] += (data[index+channel]>>2);
-
-			/* Round and convert to integer */
-			tempgint = (int)lroundf(out[channel]);
-
-			/* Limit the output */
-			if (tempgint < -32768)
-				data[index+channel] = -32768;
-			else if (tempgint > 32767)
-				data[index+channel] = 32767;
-			else 
-				data[index+channel] = tempgint;
-		} /* For each channel */
-
-		i++; j++; k++;
-		
-		/* Wrap around the indexes */
-		if (i == 3) i = 0;
-		else if (j == 3) j = 0;
-		else k = 0;
-
-		
-	}/* For each pair of samples */
-
-	return length;
-}
--- a/Plugins/Input/wma/iir.h	Thu Jan 12 18:27:22 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- *   PCM time-domain equalizer
- *
- *   Copyright (C) 2002  Felipe Rivera <liebremx at users.sourceforge.net>
- *
- *   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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *   $Id: iir.h,v 1.1 2003/05/21 13:59:59 liebremx Exp $
- */
-#ifndef IIR_H
-#define IIR_H
-
-#include <stdio.h>
-#include <string.h>
-
-#include <audacious/plugin.h>
-#include <libaudacious/util.h>
-
-#define EQ_MAX_BANDS 10
-/* Number of channels (Stereo) */
-#define EQ_CHANNELS 2
-
-
-// Fixed Point Fractional bits
-#define FP_FRBITS 28	
-
-// Conversions
-#define EQ_REAL(x) ((gint)((x) * (1 << FP_FRBITS)))
-
-/* Floating point */
-typedef struct 
-{
-	float beta;
-	float alpha; 
-	float gamma;
-}sIIRCoefficients;
-
-/* Coefficient history for the IIR filter */
-typedef struct
-{
-	float x[3]; /* x[n], x[n-1], x[n-2] */
-	float y[3]; /* y[n], y[n-1], y[n-2] */
-}sXYData;
-
-/* Gain for each band
- * values should be between -0.2 and 1.0 */
-float gain[EQ_MAX_BANDS][EQ_CHANNELS] __attribute__((aligned));
-/* Volume gain
- * values should be between 0.0 and 1.0
- * Use the preamp from XMMS for now
- * */
-float preamp[EQ_CHANNELS] __attribute__((aligned));
-
-__inline__ int iir(gpointer * d, gint length);
-void init_iir();
-
-#endif /* #define IIR_H */
--- a/Plugins/Input/wma/wma.c	Thu Jan 12 18:27:22 2006 -0800
+++ b/Plugins/Input/wma/wma.c	Fri Jan 13 14:50:54 2006 -0800
@@ -37,7 +37,6 @@
 
 #include "avcodec.h"
 #include "avformat.h"
-#include "iir.h"
 
 #define ABOUT_TXT "Adapted for use in audacious by Tony Vroon (chainsaw@gentoo.org) from\n \
 the BEEP-WMA plugin which is Copyright (C) 2004,2005 Mokrushin I.V. aka McMCC (mcmcc@mail.ru).\n \
@@ -99,7 +98,7 @@
     wma_stop,           // Stop
     wma_do_pause,       // Pause
     wma_seek,           // Seek
-    wma_set_eq,         // Set the equalizer, most plugins won't be able to do this
+    NULL, 		// We don't use this in audacious.
     wma_get_time,       // Get the time, usually returns the output plugins output time
     NULL,           	// Get volume
     NULL,           	// Set volume
@@ -181,7 +180,6 @@
     avcodec_init();
     avcodec_register_all();
     av_register_all();
-    init_iir();
 }
 
 static int wma_is_our_file(char *filename)
@@ -215,27 +213,6 @@
     return -1;
 }
 
-static void wma_set_eq(int q_on, float q_preamp, float *q_bands)
-{
-    int chn;
-    int index;
-    float value;
-
-    wma_eq_on = q_on;
-    if(wma_eq_on)
-    {
-	q_preamp = q_preamp/1.6;
-        for(chn = 0; chn < c->channels; chn++)
-            preamp[chn] = 1.0 + 0.0932471 * q_preamp + 0.00279033 * q_preamp * q_preamp;
-        for(index = 0; index < 10; index++)
-        {
-            value = q_bands[index]/1.2;
-            for(chn = 0; chn < c->channels; chn++)
-                gain[index][chn] = 0.03 * value + 0.000999999 * value * value;
-        }
-    }
-}
-
 static gchar *extname(const char *filename)
 {
     gchar *ext = strrchr(filename, '.');
@@ -322,10 +299,6 @@
     fifo_write(&f, wma_outbuf, out_size, &f.wptr);
     while(!fifo_read(&f, wma_s_outbuf, wma_st_buff, &f.rptr) && wma_decode)
     {
-        if(wma_eq_on)
-            sst_buff = iir((gpointer)&wma_s_outbuf, wma_st_buff);
-        else
-	    sst_buff = wma_st_buff;
 	if(wma_pause) memset(wma_s_outbuf, 0, sst_buff);	
     	while(wma_ip.output->buffer_free() < wma_st_buff) xmms_usleep(20000);
 	produce_audio(wma_ip.output->written_time(), FMT_S16_NE,