aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-09-03 23:55:36 +0200
committerGravatar wm4 <wm4@nowhere>2015-09-03 23:55:36 +0200
commit091bfa3abf2f28b37fa12cca6b4c248c31d27965 (patch)
treef5406c1b373ed91a914712e3c0d25076449df123
parente1fbd3b790b5fe1ae6efc1dd0477c2da88a5b8dc (diff)
audio/filter: remove some useless filters
All of these filters are considered not useful anymore by us. Some have replacements in libavfilter (useable through af_lavfi). af_center, af_extrastereo, af_karaoke, af_sinesuppress, af_sub, af_surround, af_sweep: pretty simple and useless filters which probably nobody ever wants. af_ladspa: has a replacement in libavfilter. af_hrtf: the algorithm doesn't work properly on most sources, and the implementation was buggy and complicated. (The filter was inherited from MPlayer; but even in mpv times we had to apply fixes that fixed major issues with added noise.) There is a ladspa filter if you still want to use it. af_export: I'm not even sure what this is supposed to do. Possibly it was meant for GUIs rendering audio visualizations, but it couldn't really work well. For example, the size of the audio depended on the samplerate (fixed number of samples only), and it couldn't retrieve the complete audio, only fragments. If this is really needed for GUIs, mpv should add native visualization, or a proper API for it.
-rw-r--r--DOCS/man/af.rst158
-rwxr-xr-xTOOLS/old-configure4
-rw-r--r--TOOLS/old-makefile12
-rw-r--r--audio/audio.c7
-rw-r--r--audio/audio.h1
-rw-r--r--audio/filter/af.c23
-rw-r--r--audio/filter/af_center.c104
-rw-r--r--audio/filter/af_export.c237
-rw-r--r--audio/filter/af_extrastereo.c132
-rw-r--r--audio/filter/af_hrtf.c670
-rw-r--r--audio/filter/af_hrtf.h510
-rw-r--r--audio/filter/af_karaoke.c86
-rw-r--r--audio/filter/af_ladspa.c851
-rw-r--r--audio/filter/af_sinesuppress.c117
-rw-r--r--audio/filter/af_sub.c148
-rw-r--r--audio/filter/af_surround.c246
-rw-r--r--audio/filter/af_sweep.c92
-rw-r--r--audio/filter/dsp.h31
-rw-r--r--audio/filter/filter.c359
-rw-r--r--audio/filter/filter.h74
-rw-r--r--audio/filter/window.c212
-rw-r--r--audio/filter/window.h42
-rw-r--r--wscript4
-rw-r--r--wscript_build.py12
24 files changed, 0 insertions, 4132 deletions
diff --git a/DOCS/man/af.rst b/DOCS/man/af.rst
index 15bc3050e6..e632820811 100644
--- a/DOCS/man/af.rst
+++ b/DOCS/man/af.rst
@@ -96,25 +96,6 @@ Available filters are:
If the input channel number is less than ``<minch>``, the filter will
detach itself (default: 3).
-``sweep[=speed]``
- Produces a sine sweep.
-
- ``<0.0-1.0>``
- Sine function delta, use very low values to hear the sweep.
-
-``sinesuppress[=freq:decay]``
- Remove a sine at the specified frequency. Useful to get rid of the 50/60 Hz
- noise on low quality audio equipment. It only works on mono input.
-
- ``<freq>``
- The frequency of the sine which should be removed (in Hz) (default:
- 50)
- ``<decay>``
- Controls the adaptivity (a larger value will make the filter adapt to
- amplitude and phase changes quicker, a smaller value will make the
- adaptation slower) (default: 0.0001). Reasonable values are around
- 0.001.
-
``bs2b[=option1:option2:...]``
Bauer stereophonic to binaural transformation using libbs2b. Improves the
headphone listening experience by making the sound similar to that from
@@ -137,18 +118,6 @@ Available filters are:
If ``fcut`` or ``feed`` options are specified together with a profile, they
will be applied on top of the selected profile.
-``hrtf[=flag]``
- Head-related transfer function: Converts multichannel audio to 2-channel
- output for headphones, preserving the spatiality of the sound.
-
- ==== ===================================
- Flag Meaning
- ==== ===================================
- m matrix decoding of the rear channel
- s 2-channel matrix decoding
- 0 no matrix decoding (default)
- ==== ===================================
-
``equalizer=g1:g2:g3:...:g10``
10 octave band graphic equalizer, implemented using 10 IIR band-pass
filters. This means that it works regardless of what type of audio is
@@ -354,64 +323,6 @@ Available filters are:
``mpv '--af=format=channels=5.1' '--audio-channels=5.1'`` would always force
remixing audio to 5.1 and output it like this.
-``sub[=fc:ch]``
- Adds a subwoofer channel to the audio stream. The audio data used for
- creating the subwoofer channel is an average of the sound in channel 0 and
- channel 1. The resulting sound is then low-pass filtered by a 4th order
- Butterworth filter with a default cutoff frequency of 60Hz and added to a
- separate channel in the audio stream.
-
- .. warning::
-
- Disable this filter when you are playing media with an LFE channel
- (e.g. 5.1 surround sound), otherwise this filter will disrupt the sound
- to the subwoofer.
-
- ``<fc>``
- cutoff frequency in Hz for the low-pass filter (20 Hz to 300 Hz)
- (default: 60 Hz) For the best result try setting the cutoff frequency
- as low as possible. This will improve the stereo or surround sound
- experience.
- ``<ch>``
- Determines the channel number in which to insert the sub-channel
- audio. Channel number can be between 0 and 7 (default: 5). Observe
- that the number of channels will automatically be increased to <ch> if
- necessary.
-
- .. admonition:: Example
-
- ``mpv --af=sub=100:4 --audio-channels=5 media.avi``
- Would add a subwoofer channel with a cutoff frequency of 100 Hz to
- output channel 4.
-
-``center``
- Creates a center channel from the front channels. May currently be low
- quality as it does not implement a high-pass filter for proper extraction
- yet, but averages and halves the channels instead.
-
- ``<ch>``
- Determines the channel number in which to insert the center channel.
- Channel number can be between 0 and 7 (default: 5). Observe that the
- number of channels will automatically be increased to ``<ch>`` if
- necessary.
-
-``surround[=delay]``
- Decoder for matrix encoded surround sound like Dolby Surround. Some files
- with 2-channel audio actually contain matrix encoded surround sound.
-
- ``<delay>``
- delay time in ms for the rear speakers (0 to 1000) (default: 20) This
- delay should be set as follows: If d1 is the distance from the
- listening position to the front speakers and d2 is the distance from
- the listening position to the rear speakers, then the delay should be
- set to 15ms if d1 <= d2 and to 15 + 5*(d1-d2) if d1 > d2.
-
- .. admonition:: Example
-
- ``mpv --af=surround=15 --audio-channels=4 media.avi``
- Would add surround sound decoding with 15 ms delay for the sound to
- the rear speakers.
-
``delay[=[ch1,ch2,...]]``
Delays the sound to the loudspeakers such that the sound from the
different channels arrives at the listening position simultaneously. It is
@@ -440,36 +351,6 @@ Available filters are:
Would delay front left and right by 10.5 ms, the two rear channels
and the subwoofer by 0 ms and the center channel by 7 ms.
-``export=mmapped_file:nsamples]``
- Exports the incoming signal to other processes using memory mapping
- (``mmap()``). Memory mapped areas contain a header::
-
- int nch /* number of channels */
- int size /* buffer size */
- unsigned long long counter /* Used to keep sync, updated every time
- new data is exported. */
-
- The rest is payload (non-interleaved) 16-bit data.
-
- ``<mmapped_file>``
- File to map data to (required)
- ``<nsamples>``
- number of samples per channel (default: 512).
-
- .. admonition:: Example
-
- ``mpv --af=export=/tmp/mpv-af_export:1024 media.avi``
- Would export 1024 samples per channel to ``/tmp/mpv-af_export``.
-
-``extrastereo[=mul]``
- (Linearly) increases the difference between left and right channels which
- adds some sort of "live" effect to playback.
-
- ``<mul>``
- Sets the difference coefficient (default: 2.5). 0.0 means mono sound
- (average of both channels), with 1.0 sound will be unchanged, with
- -1.0 left and right channels will be swapped.
-
``drc[=method:target]``
Applies dynamic range compression. This maximizes the volume by compressing
the audio signal's dynamic range. (Formerly called ``volnorm``.)
@@ -493,45 +374,6 @@ Available filters are:
This filter can cause distortion with audio signals that have a very
large dynamic range.
-``ladspa=file:label:[<control0>,<control1>,...]``
- Load a LADSPA (Linux Audio Developer's Simple Plugin API) plugin. This
- filter is reentrant, so multiple LADSPA plugins can be used at once.
-
- ``<file>``
- Specifies the LADSPA plugin library file.
-
- .. note::
-
- See also the note about the ``LADSPA_PATH`` variable in the
- `ENVIRONMENT VARIABLES`_ section.
- ``<label>``
- Specifies the filter within the library. Some libraries contain only
- one filter, but others contain many of them. Entering 'help' here
- will list all available filters within the specified library, which
- eliminates the use of 'listplugins' from the LADSPA SDK.
- ``[<control0>,<control1>,...]``
- Controls are zero or more ``,`` separated floating point values that
- determine the behavior of the loaded plugin (for example delay,
- threshold or gain).
- In verbose mode (add ``-v`` to the mpv command line), all
- available controls and their valid ranges are printed. This eliminates
- the use of 'analyseplugin' from the LADSPA SDK.
- Note that ``,`` is already used by the option parser to separate
- filters, so you must quote the list of values with ``[...]`` or
- similar.
-
- .. admonition:: Example
-
- ``mpv --af=ladspa='/usr/lib/ladspa/delay.so':delay_5s:[0.5,0.2] media.avi``
- Does something.
-
-``karaoke``
- Simple voice removal filter exploiting the fact that voice is usually
- recorded with mono gear and later 'center' mixed onto the final audio
- stream. Beware that this filter will turn your signal into mono. Works
- well for 2 channel tracks; do not bother trying it on anything but 2
- channel stereo.
-
``scaletempo[=option1:option2:...]``
Scales audio tempo without altering pitch, optionally synced to playback
speed (default).
diff --git a/TOOLS/old-configure b/TOOLS/old-configure
index 60575a8ec1..e967a657eb 100755
--- a/TOOLS/old-configure
+++ b/TOOLS/old-configure
@@ -191,7 +191,6 @@ options_state_machine() {
opt_yes_no _libcdio "libcdio support"
opt_yes_no _librubberband "librubberband support"
opt_yes_no _ffmpeg "skip FFmpeg/Libav autodetection"
- opt_yes_no _ladspa "LADSPA plugin support"
opt_yes_no _libbs2b "libbs2b audio filter support"
opt_yes_no _libavresample "libavresample (preferred over libswresample)"
opt_yes_no _libswresample "libswresample"
@@ -749,9 +748,6 @@ check_pkg_config "uchardet" $_uchardet UCHARDET 'uchardet'
check_pkg_config "zlib" auto ZLIB 'zlib'
test $(defretval) = no && die "Unable to find development files for zlib."
-test "$_dl" = no && _ladspa=no
-check_statement_libs "LADSPA plugin support" $_ladspa LADSPA ladspa.h 'LADSPA_Descriptor ld = {0}'
-
check_pkg_config "libbs2b audio filter support" $_libbs2b LIBBS2B 'libbs2b'
check_pkg_config "LCMS2 support" $_lcms2 LCMS2 'lcms2 >= 2.6'
diff --git a/TOOLS/old-makefile b/TOOLS/old-makefile
index 4f5737595f..f3e4d7ea86 100644
--- a/TOOLS/old-makefile
+++ b/TOOLS/old-makefile
@@ -35,7 +35,6 @@ SOURCES-$(DVDREAD) += stream/stream_dvd.c \
SOURCES-$(DVDNAV) += stream/stream_dvdnav.c \
stream/stream_dvd_common.c
-SOURCES-$(LADSPA) += audio/filter/af_ladspa.c
SOURCES-$(RUBBERBAND) += audio/filter/af_rubberband.c
SOURCES-$(LIBASS) += sub/ass_mp.c sub/sd_ass.c \
demux/demux_libass.c
@@ -123,28 +122,17 @@ SOURCES = audio/audio.c \
audio/decode/ad_spdif.c \
audio/decode/dec_audio.c \
audio/filter/af.c \
- audio/filter/af_center.c \
audio/filter/af_channels.c \
audio/filter/af_delay.c \
audio/filter/af_equalizer.c \
- audio/filter/af_export.c \
- audio/filter/af_extrastereo.c \
audio/filter/af_format.c \
- audio/filter/af_hrtf.c \
- audio/filter/af_karaoke.c \
audio/filter/af_lavcac3enc.c \
audio/filter/af_lavrresample.c \
audio/filter/af_pan.c \
audio/filter/af_scaletempo.c \
- audio/filter/af_sinesuppress.c \
- audio/filter/af_sub.c \
- audio/filter/af_surround.c \
- audio/filter/af_sweep.c \
audio/filter/af_drc.c \
audio/filter/af_volume.c \
- audio/filter/filter.c \
audio/filter/tools.c \
- audio/filter/window.c \
audio/out/ao.c \
audio/out/ao_null.c \
audio/out/ao_pcm.c \
diff --git a/audio/audio.c b/audio/audio.c
index f84d6054bc..4b12992879 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -58,13 +58,6 @@ void mp_audio_set_num_channels(struct mp_audio *mpa, int num_channels)
update_redundant_info(mpa);
}
-// Use old MPlayer/ALSA channel layout.
-void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels)
-{
- mp_chmap_from_channels_alsa(&mpa->channels, num_channels);
- update_redundant_info(mpa);
-}
-
void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap)
{
mpa->channels = *chmap;
diff --git a/audio/audio.h b/audio/audio.h
index a0ecb2d7bf..bf5358274a 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -46,7 +46,6 @@ struct mp_audio {
void mp_audio_set_format(struct mp_audio *mpa, int format);
void mp_audio_set_num_channels(struct mp_audio *mpa, int num_channels);
-void mp_audio_set_channels_old(struct mp_audio *mpa, int num_channels);
void mp_audio_set_channels(struct mp_audio *mpa, const struct mp_chmap *chmap);
void mp_audio_copy_config(struct mp_audio *dst, const struct mp_audio *src);
bool mp_audio_config_equals(const struct mp_audio *a, const struct mp_audio *b);
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 6a5b1f42a5..b877ba7661 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -34,23 +34,12 @@
extern const struct af_info af_info_delay;
extern const struct af_info af_info_channels;
extern const struct af_info af_info_format;
-extern const struct af_info af_info_force;
extern const struct af_info af_info_volume;
extern const struct af_info af_info_equalizer;
extern const struct af_info af_info_pan;
-extern const struct af_info af_info_surround;
-extern const struct af_info af_info_sub;
-extern const struct af_info af_info_export;
extern const struct af_info af_info_drc;
-extern const struct af_info af_info_extrastereo;
extern const struct af_info af_info_lavcac3enc;
extern const struct af_info af_info_lavrresample;
-extern const struct af_info af_info_sweep;
-extern const struct af_info af_info_hrtf;
-extern const struct af_info af_info_ladspa;
-extern const struct af_info af_info_center;
-extern const struct af_info af_info_sinesuppress;
-extern const struct af_info af_info_karaoke;
extern const struct af_info af_info_scaletempo;
extern const struct af_info af_info_bs2b;
extern const struct af_info af_info_lavfi;
@@ -63,24 +52,12 @@ static const struct af_info *const filter_list[] = {
&af_info_volume,
&af_info_equalizer,
&af_info_pan,
- &af_info_surround,
- &af_info_sub,
- &af_info_export,
&af_info_drc,
- &af_info_extrastereo,
&af_info_lavcac3enc,
&af_info_lavrresample,
- &af_info_sweep,
- &af_info_hrtf,
-#if HAVE_LADSPA
- &af_info_ladspa,
-#endif
#if HAVE_RUBBERBAND
&af_info_rubberband,
#endif
- &af_info_center,
- &af_info_sinesuppress,
- &af_info_karaoke,
&af_info_scaletempo,
#if HAVE_LIBBS2B
&af_info_bs2b,
diff --git a/audio/filter/af_center.c b/audio/filter/af_center.c
deleted file mode 100644
index 69e54e81c6..0000000000
--- a/audio/filter/af_center.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * This filter adds a center channel to the audio stream by
- * averaging the left and right channel.
- * There are two runtime controls one for setting which channel
- * to insert the center-audio into called AF_CONTROL_SUB_CH.
- *
- * FIXME: implement a high-pass filter for better results.
- *
- * copyright (c) 2005 Alex Beregszaszi
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "common/common.h"
-#include "af.h"
-
-// Data for specific instances of this filter
-typedef struct af_center_s
-{
- int ch; // Channel number which to insert the filtered data
-}af_center_t;
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- af_center_t* s = af->priv;
-
- switch(cmd){
- case AF_CONTROL_REINIT:{
- // Sanity check
- if(!arg) return AF_ERROR;
-
- af->data->rate = ((struct mp_audio*)arg)->rate;
- mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
-
- return af_test_output(af,(struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-static int filter_frame(struct af_instance* af, struct mp_audio* data)
-{
- if (!data)
- return 0;
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return -1;
- }
- struct mp_audio* c = data; // Current working data
- af_center_t* s = af->priv; // Setup for this instance
- float* a = c->planes[0]; // Audio data
- int nch = c->nch; // Number of channels
- int len = c->samples*c->nch; // Number of samples in current audio block
- int ch = s->ch; // Channel in which to insert the center audio
- register int i;
-
- // Run filter
- for(i=0;i<len;i+=nch){
- // Average left and right
- a[i+ch] = (a[i]/2) + (a[i+1]/2);
- }
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-// Allocate memory and set function pointers
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = filter_frame;
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_center_t
-const struct af_info af_info_center = {
- .info = "Audio filter for adding a center channel",
- .name = "center",
- .flags = AF_FLAGS_NOT_REENTRANT,
- .open = af_open,
- .priv_size = sizeof(af_center_t),
- .options = (const struct m_option[]) {
- OPT_INTRANGE("channel", ch, 0, 0, AF_NCH - 1, OPTDEF_INT(1)),
- {0}
- },
-};
diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c
deleted file mode 100644
index 6020d9d98e..0000000000
--- a/audio/filter/af_export.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * This audio filter exports the incoming signal to other processes
- * using memory mapping. The memory mapped area contains a header:
- * int nch,
- * int size,
- * unsigned long long counter (updated every time the contents of
- * the area changes),
- * the rest is payload (non-interleaved).
- *
- * Authors: Anders; Gustavo Sverzut Barbieri <gustavo.barbieri@ic.unicamp.br>
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "osdep/io.h"
-
-#include "talloc.h"
-#include "af.h"
-#include "options/path.h"
-
-#define DEF_SZ 512 // default buffer size (in samples)
-#define SHARED_FILE "mpv-af_export" /* default file name
- (relative to ~/.mpv/ */
-
-#define SIZE_HEADER (2 * sizeof(int) + sizeof(unsigned long long))
-
-// Data for specific instances of this filter
-typedef struct af_export_s
-{
- unsigned long long count; // Used for sync
- void* buf[AF_NCH]; // Buffers for storing the data before it is exported
- int sz; // Size of buffer in samples
- int wi; // Write index
- int fd; // File descriptor to shared memory area
- char* filename; // File to export data
- uint8_t *mmap_area; // MMap shared area
-} af_export_t;
-
-
-/* Initialization and runtime control
- af audio filter instance
- cmd control command
- arg argument
-*/
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- af_export_t* s = af->priv;
- switch (cmd){
- case AF_CONTROL_REINIT:{
- int i=0;
- int mapsize;
-
- // Free previous buffers
- free(s->buf[0]);
-
- // unmap previous area
- if(s->mmap_area)
- munmap(s->mmap_area, SIZE_HEADER + (af->data->bps*s->sz*af->data->nch));
- // close previous file descriptor
- if(s->fd)
- close(s->fd);
-
- // Accept only int16_t as input format (which sucks)
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_set_format(af->data, AF_FORMAT_S16);
-
- // Allocate new buffers (as one continuous block)
- s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
- if(NULL == s->buf[0]) {
- MP_FATAL(af, "Out of memory\n");
- return AF_ERROR;
- }
- for(i = 1; i < af->data->nch; i++)
- s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
-
- if (!s->filename) {
- MP_FATAL(af, "No filename set.\n");
- return AF_ERROR;
- }
-
- // Init memory mapping
- s->fd = open(s->filename, O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0640);
- MP_INFO(af, "Exporting to file: %s\n", s->filename);
- if(s->fd < 0) {
- MP_FATAL(af, "Could not open/create file: %s\n",
- s->filename);
- return AF_ERROR;
- }
-
- // header + buffer
- mapsize = (SIZE_HEADER + (af->data->bps * s->sz * af->data->nch));
-
- // grow file to needed size
- for(i = 0; i < mapsize; i++){
- char null = 0;
- write(s->fd, (void*) &null, 1);
- }
-
- // mmap size
- s->mmap_area = mmap(0, mapsize, PROT_READ|PROT_WRITE,MAP_SHARED, s->fd, 0);
- if(s->mmap_area == NULL)
- MP_FATAL(af, "Could not mmap file %s\n", s->filename);
- MP_INFO(af, "Memory mapped to file: %s (%p)\n",
- s->filename, s->mmap_area);
-
- // Initialize header
- *((int*)s->mmap_area) = af->data->nch;
- *((int*)s->mmap_area + 1) = s->sz * af->data->bps * af->data->nch;
- msync(s->mmap_area, mapsize, MS_ASYNC);
-
- // Use test_output to return FALSE if necessary
- return af_test_output(af, (struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-/* Free allocated memory and clean up other stuff too.
- af audio filter instance
-*/
-static void uninit( struct af_instance* af )
-{
- af_export_t* s = af->priv;
-
- free(s->buf[0]);
-
- // Free mmaped area
- if(s->mmap_area)
- munmap(s->mmap_area, sizeof(af_export_t));
-
- if(s->fd > -1)
- close(s->fd);
-}
-
-/* Filter data through filter
- af audio filter instance
- data audio data
-*/
-static int filter(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- struct mp_audio* c = data; // Current working data
- af_export_t* s = af->priv; // Setup for this instance
- int16_t* a = c->planes[0]; // Incoming sound
- int nch = c->nch; // Number of channels
- int len = c->samples*c->nch; // Number of sample in data chunk
- int sz = s->sz; // buffer size (in samples)
- int flag = 0; // Set to 1 if buffer is filled
-
- int ch, i;
-
- // Fill all buffers
- for(ch = 0; ch < nch; ch++){
- int wi = s->wi; // Reset write index
- int16_t* b = s->buf[ch]; // Current buffer
-
- // Copy data to export buffers
- for(i = ch; i < len; i += nch){
- b[wi++] = a[i];
- if(wi >= sz){ // Don't write outside the end of the buffer
- flag = 1;
- break;
- }
- }
- s->wi = wi % s->sz;
- }
-
- // Export buffer to mmaped area
- if(flag){
- // update buffer in mapped area
- memcpy(s->mmap_area + SIZE_HEADER, s->buf[0], sz * c->bps * nch);
- s->count++; // increment counter (to sync)
- memcpy(s->mmap_area + SIZE_HEADER - sizeof(s->count),
- &(s->count), sizeof(s->count));
- }
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-/* Allocate memory and set function pointers
- af audio filter instance
- returns AF_OK or AF_ERROR
-*/
-static int af_open( struct af_instance* af )
-{
- af->control = control;
- af->uninit = uninit;
- af->filter_frame = filter;
- af_export_t *priv = af->priv;
-
- if (!priv->filename || !priv->filename[0]) {
- MP_FATAL(af, "no export filename given");
- return AF_ERROR;
- }
-
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_export_t
-const struct af_info af_info_export = {
- .info = "Sound export filter",
- .name = "export",
- .open = af_open,
- .priv_size = sizeof(af_export_t),
- .options = (const struct m_option[]) {
- OPT_STRING("filename", filename, 0),
- OPT_INTRANGE("buffersamples", sz, 0, 1, 2048, OPTDEF_INT(DEF_SZ)),
- {0}
- },
-};
diff --git a/audio/filter/af_extrastereo.c b/audio/filter/af_extrastereo.c
deleted file mode 100644
index 49222ebfdc..0000000000
--- a/audio/filter/af_extrastereo.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2004 Alex Beregszaszi & Pierre Lombard
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <inttypes.h>
-#include <math.h>
-#include <limits.h>
-
-#include "common/common.h"
-#include "af.h"
-
-// Data for specific instances of this filter
-typedef struct af_extrastereo_s
-{
- float mul;
-}af_extrastereo_t;
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- switch(cmd){
- case AF_CONTROL_REINIT:{
- // Sanity check
- if(!arg) return AF_ERROR;
-
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_force_interleaved_format(af->data);
- mp_audio_set_num_channels(af->data, 2);
- if (af->data->format != AF_FORMAT_FLOAT)
- mp_audio_set_format(af->data, AF_FORMAT_S16);
-
- return af_test_output(af,(struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-// Filter data through filter
-static void play_s16(af_extrastereo_t *s, struct mp_audio* data)
-{
- register int i = 0;
- int16_t *a = (int16_t*)data->planes[0]; // Audio data
- int len = data->samples*data->nch; // Number of samples
- int avg, l, r;
-
- for (i = 0; i < len; i+=2)
- {
- avg = (a[i] + a[i + 1]) / 2;
-
- l = avg + (int)(s->mul * (a[i] - avg));
- r = avg + (int)(s->mul * (a[i + 1] - avg));
-
- a[i] = MPCLAMP(l, SHRT_MIN, SHRT_MAX);
- a[i + 1] = MPCLAMP(r, SHRT_MIN, SHRT_MAX);
- }
-}
-
-static void play_float(af_extrastereo_t *s, struct mp_audio* data)
-{
- register int i = 0;
- float *a = (float*)data->planes[0]; // Audio data
- int len = data->samples * data->nch; // Number of samples
- float avg, l, r;
-
- for (i = 0; i < len; i+=2)
- {
- avg = (a[i] + a[i + 1]) / 2;
-
- l = avg + (s->mul * (a[i] - avg));
- r = avg + (s->mul * (a[i + 1] - avg));
-
- a[i] = af_softclip(l);
- a[i + 1] = af_softclip(r);
- }
-}
-
-static int filter_frame(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return -1;
- }
- if (data->format == AF_FORMAT_FLOAT) {
- play_float(af->priv, data);
- } else {
- play_s16(af->priv, data);
- }
- af_add_output_frame(af, data);
- return 0;
-}
-
-// Allocate memory and set function pointers
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = filter_frame;
-
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_extrastereo_t
-const struct af_info af_info_extrastereo = {
- .info = "Increase difference between audio channels",
- .name = "extrastereo",
- .flags = AF_FLAGS_NOT_REENTRANT,
- .open = af_open,
- .priv_size = sizeof(af_extrastereo_t),
- .options = (const struct m_option[]) {
- OPT_FLOAT("mul", mul, 0, OPTDEF_FLOAT(2.5)),
- {0}
- },
-};
diff --git a/audio/filter/af_hrtf.c b/audio/filter/af_hrtf.c
deleted file mode 100644
index 3c8a89c665..0000000000
--- a/audio/filter/af_hrtf.c
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * Experimental audio filter that mixes 5.1 and 5.1 with matrix
- * encoded rear channels into headphone signal using FIR filtering
- * with HRTF.
- *
- * Author: ylai
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-//#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include <math.h>
-#include <libavutil/common.h>
-
-#include "af.h"
-#include "dsp.h"
-
-/* HRTF filter coefficients and adjustable parameters */
-#include "af_hrtf.h"
-
-typedef struct af_hrtf_s {
- /* Lengths */
- int dlbuflen, hrflen, basslen;
- /* L, C, R, Ls, Rs channels */
- float *lf, *rf, *lr, *rr, *cf, *cr;
- const float *cf_ir, *af_ir, *of_ir, *ar_ir, *or_ir, *cr_ir;
- int cf_o, af_o, of_o, ar_o, or_o, cr_o;
- /* Bass */
- float *ba_l, *ba_r;
- float *ba_ir;
- /* Whether to matrix decode the rear center channel */
- int matrix_mode;
- /* How to decode the input:
- 0 = 5/5+1 channels
- 1 = 2 channels
- 2 = matrix encoded 2 channels */
- int decode_mode;
- /* Full wave rectified (FWR) amplitudes and gain used to steer the
- active matrix decoding of front channels (variable names
- lpr/lmr means Lt + Rt, Lt - Rt) */
- float l_fwr, r_fwr, lpr_fwr, lmr_fwr;
- float adapt_l_gain, adapt_r_gain, adapt_lpr_gain, adapt_lmr_gain;
- /* Matrix input decoding require special FWR buffer, since the
- decoding is done in place. */
- float *fwrbuf_l, *fwrbuf_r, *fwrbuf_lr, *fwrbuf_rr;
- /* Rear channel delay buffer for matrix decoding */
- float *rear_dlbuf;
- /* Full wave rectified amplitude and gain used to steer the active
- matrix decoding of center rear channel */
- float lr_fwr, rr_fwr, lrprr_fwr, lrmrr_fwr;
- float adapt_lr_gain, adapt_rr_gain;
- float adapt_lrprr_gain, adapt_lrmrr_gain;
- /* Cyclic position on the ring buffer */
- int cyc_pos;
- int print_flag;
- int mode;
-} af_hrtf_t;
-
-/* Convolution on a ring buffer
- * nx: length of the ring buffer
- * nk: length of the convolution kernel
- * sx: ring buffer
- * sk: convolution kernel
- * offset: offset on the ring buffer, can be
- */
-static float conv(const int nx, const int nk, const float *sx, const float *sk,
- const int offset)
-{
- /* k = reminder of offset / nx */
- int k = offset >= 0 ? offset % nx : nx + (offset % nx);
-
- if(nk + k <= nx)
- return af_filter_fir(nk, sx + k, sk);
- else
- return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
- af_filter_fir(nx - k, sx + k, sk);
-}
-
-/* Detect when the impulse response starts (significantly) */
-static int pulse_detect(const float *sx)
-{
- /* nmax must be the reference impulse response length (128) minus
- s->hrflen */
- const int nmax = 128 - HRTFFILTLEN;
- const float thresh = IRTHRESH;
- int i;
-
- for(i = 0; i < nmax; i++)
- if(fabs(sx[i]) > thresh)
- return i;
- return 0;
-}
-
-/* Fuzzy matrix coefficient transfer function to "lock" the matrix on
- a effectively passive mode if the gain is approximately 1 */
-static inline float passive_lock(float x)
-{
- const float x1 = x - 1;
- const float ax1s = fabs(x - 1) * (1.0 / MATAGCLOCK);
-
- return x1 - x1 / (1 + ax1s * ax1s) + 1;
-}
-
-/* Unified active matrix decoder for 2 channel matrix encoded surround
- sources */
-static inline void matrix_decode(short *in, const int k, const int il,
- const int ir, const int decode_rear,
- const int dlbuflen,
- float l_fwr, float r_fwr,
- float lpr_fwr, float lmr_fwr,
- float *adapt_l_gain, float *adapt_r_gain,
- float *adapt_lpr_gain, float *adapt_lmr_gain,
- float *lf, float *rf, float *lr,
- float *rr, float *cf)
-{
- const int kr = (k + MATREARDELAY) % dlbuflen;
- float l_gain = (l_fwr + r_fwr) /
- (1 + l_fwr + l_fwr);
- float r_gain = (l_fwr + r_fwr) /
- (1 + r_fwr + r_fwr);
- /* The 2nd axis has strong gain fluctuations, and therefore require
- limits. The factor corresponds to the 1 / amplification of (Lt
- - Rt) when (Lt, Rt) is strongly correlated. (e.g. during
- dialogues). It should be bigger than -12 dB to prevent
- distortion. */
- float lmr_lim_fwr = lmr_fwr > M9_03DB * lpr_fwr ?
- lmr_fwr : M9_03DB * lpr_fwr;
- float lpr_gain = (lpr_fwr + lmr_lim_fwr) /
- (1 + lpr_fwr + lpr_fwr);
- float lmr_gain = (lpr_fwr + lmr_lim_fwr) /
- (1 + lmr_lim_fwr + lmr_lim_fwr);
- float lmr_unlim_gain = (lpr_fwr + lmr_fwr) /
- (1 + lmr_fwr + lmr_fwr);
- float lpr, lmr;
- float l_agc, r_agc, lpr_agc, lmr_agc;
- float f, d_gain, c_gain, c_agc_cfk;
-
-#if 0
- static int counter = 0;
- static FILE *fp_out;
-
- if(counter == 0)
- fp_out = fopen("af_hrtf.log", "w");
- if(counter % 240 == 0)
- fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000),
- l_gain, r_gain, lpr_gain, lmr_gain);
-#endif
-
- /*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/
- /* AGC adaption */
- d_gain = (fabs(l_gain - *adapt_l_gain) +
- fabs(r_gain - *adapt_r_gain)) * 0.5;
- f = d_gain * (1.0 / MATAGCTRIG);
- f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
- *adapt_l_gain = (1 - f) * *adapt_l_gain + f * l_gain;
- *adapt_r_gain = (1 - f) * *adapt_r_gain + f * r_gain;
- /* Matrix */
- l_agc = in[il] * passive_lock(*adapt_l_gain);
- r_agc = in[ir] * passive_lock(*adapt_r_gain);
- cf[k] = (l_agc + r_agc) * M_SQRT1_2;
- if(decode_rear) {
- lr[kr] = rr[kr] = (l_agc - r_agc) * M_SQRT1_2;
- /* Stereo rear channel is steered with the same AGC steering as
- the decoding matrix. Note this requires a fast updating AGC
- at the order of 20 ms (which is the case here). */
- lr[kr] *= (l_fwr + l_fwr) /
- (1 + l_fwr + r_fwr);
- rr[kr] *= (r_fwr + r_fwr) /
- (1 + l_fwr + r_fwr);
- }
-
- /*** AXIS NO. 2: (Lt + Rt, Lt - Rt) -> (L, R) ***/
- lpr = (in[il] + in[ir]) * M_SQRT1_2;
- lmr = (in[il] - in[ir]) * M_SQRT1_2;
- /* AGC adaption */
- d_gain = fabs(lmr_unlim_gain - *adapt_lmr_gain);
- f = d_gain * (1.0 / MATAGCTRIG);
- f = MATAGCDECAY - MATAGCDECAY / (1 + f * f);
- *adapt_lpr_gain = (1 - f) * *adapt_lpr_gain + f * lpr_gain;
- *adapt_lmr_gain = (1 - f) * *adapt_lmr_gain + f * lmr_gain;
- /* Matrix */
- lpr_agc = lpr * passive_lock(*adapt_lpr_gain);
- lmr_agc = lmr * passive_lock(*adapt_lmr_gain);
- lf[k] = (lpr_agc + lmr_agc) * M_SQRT1_2;
- rf[k] = (lpr_agc - lmr_agc) * M_SQRT1_2;
-
- /*** CENTER FRONT CANCELLATION ***/
- /* A heuristic approach exploits that Lt + Rt gain contains the
- information about Lt, Rt correlation. This effectively reshapes
- the front and rear "cones" to concentrate Lt + Rt to C and
- introduce Lt - Rt in L, R. */
- /* 0.67677 is the empirical lower bound for lpr_gain. */
- c_gain = 8 * (*adapt_lpr_gain - 0.67677);
- c_gain = c_gain > 0 ? c_gain : 0;
- /* c_gain should not be too high, not even reaching full
- cancellation (~ 0.50 - 0.55 at current AGC implementation), or
- the center will s0und too narrow. */
- c_gain = MATCOMPGAIN / (1 + c_gain * c_gain);
- c_agc_cfk = c_gain * cf[k];
- lf[k] -= c_agc_cfk;
- rf[k] -= c_agc_cfk;
- cf[k] += c_agc_cfk + c_agc_cfk;
-#if 0
- if(counter % 240 == 0)
- fprintf(fp_out, "%g %g %g %g %g\n",
- *adapt_l_gain, *adapt_r_gain,
- *adapt_lpr_gain, *adapt_lmr_gain,
- c_gain);
- counter++;
-#endif
-}
-
-static inline void update_ch(af_hrtf_t *s, short *in, const int k)
-{
- const int fwr_pos = (k + FWRDURATION) % s->dlbuflen;
- /* Update the full wave rectified total amplitude */
- /* Input matrix decoder */
- if(s->decode_mode == HRTF_MIX_MATRIX2CH) {
- s->l_fwr += abs(in[0]) - fabs(s->fwrbuf_l[fwr_pos]);
- s->r_fwr += abs(in[1]) - fabs(s->fwrbuf_r[fwr_pos]);
- s->lpr_fwr += abs(in[0] + in[1]) -
- fabs(s->fwrbuf_l[fwr_pos] + s->fwrbuf_r[fwr_pos]);
- s->lmr_fwr += abs(in[0] - in[1]) -
- fabs(s->fwrbuf_l[fwr_pos] - s->fwrbuf_r[fwr_pos]);
- }
- /* Rear matrix decoder */
- if(s->matrix_mode) {
- s->lr_fwr += abs(in[2]) - fabs(s->fwrbuf_lr[fwr_pos]);
- s->rr_fwr += abs(in[3]) - fabs(s->fwrbuf_rr[fwr_pos]);
- s->lrprr_fwr += abs(in[2] + in[3]) -
- fabs(s->fwrbuf_lr[fwr_pos] + s->fwrbuf_rr[fwr_pos]);
- s->lrmrr_fwr += abs(in[2] - in[3]) -
- fabs(s->fwrbuf_lr[fwr_pos] - s->fwrbuf_rr[fwr_pos]);
- }
-
- switch (s->decode_mode) {
- case HRTF_MIX_51:
- /* 5/5+1 channel sources */
- s->lf[k] = in[0];
- s->cf[k] = in[4];
- s->rf[k] = in[1];
- s->fwrbuf_lr[k] = s->lr[k] = in[2];
- s->fwrbuf_rr[k] = s->rr[k] = in[3];
- break;
- case HRTF_MIX_MATRIX2CH:
- /* Matrix encoded 2 channel sources */
- s->fwrbuf_l[k] = in[0];
- s->fwrbuf_r[k] = in[1];
- matrix_decode(in, k, 0, 1, 1, s->dlbuflen,
- s->l_fwr, s->r_fwr,
- s->lpr_fwr, s->lmr_fwr,
- &(s->adapt_l_gain), &(s->adapt_r_gain),
- &(s->adapt_lpr_gain), &(s->adapt_lmr_gain),
- s->lf, s->rf, s->lr, s->rr, s->cf);
- break;
- case HRTF_MIX_STEREO:
- /* Stereo sources */
- s->lf[k] = in[0];
- s->rf[k] = in[1];
- s->cf[k] = s->lr[k] = s->rr[k] = 0;
- break;
- }
-
- /* We need to update the bass compensation delay line, too. */
- // TODO: should this use lf/cf/rf etc. instead?
- s->ba_l[k] = in[0];
- s->ba_r[k] = in[1];
- if (s->decode_mode == HRTF_MIX_51) {
- s->ba_l[k] += in[4] + in[2];
- s->ba_r[k] += in[4] + in[3];
- }
-}
-
-static void clear_coeff(af_hrtf_t *s, float *c)
-{
- memset(c, 0, s->dlbuflen * sizeof(float));
-}
-
-static void reset(af_hrtf_t *s)
-{
- clear_coeff(s, s->lf);
- clear_coeff(s, s->rf);
- clear_coeff(s, s->lr);
- clear_coeff(s, s->rr);
- clear_coeff(s, s->cf);
- clear_coeff(s, s->cr);
- clear_coeff(s, s->ba_l);
- clear_coeff(s, s->ba_r);
- clear_coeff(s, s->fwrbuf_l);
- clear_coeff(s, s->fwrbuf_r);
- clear_coeff(s, s->fwrbuf_lr);
- clear_coeff(s, s->fwrbuf_rr);
-}
-
-/* Initialization and runtime control */
-static int control(struct af_instance *af, int cmd, void* arg)
-{
- af_hrtf_t *s = af->priv;
- int test_output_res;
-
- switch(cmd) {
- case AF_CONTROL_REINIT:
- reset(s);
- af->data->rate = 48000;
- mp_audio_set_channels_old(af->data, ((struct mp_audio*)arg)->nch);
- if(af->data->nch == 2) {
- /* 2 channel input */
- if(s->decode_mode != HRTF_MIX_MATRIX2CH) {
- /* Default behavior is stereo mixing. */
- s->decode_mode = HRTF_MIX_STEREO;
- }
- } else if (af->data->nch < 5) {
- mp_audio_set_channels_old(af->data, 5);
- }
- mp_audio_set_format(af->data, AF_FORMAT_S16);
- test_output_res = af_test_output(af, (struct mp_audio*)arg);
- // after testing input set the real output format
- mp_audio_set_num_channels(af->data, 2);
- s->print_flag = 1;
- return test_output_res;
- case AF_CONTROL_RESET:
- reset(s);
- return AF_OK;
- }
-
- return AF_UNKNOWN;
-}
-
-/* Deallocate memory */
-static void uninit(struct af_instance *af)
-{
- af_hrtf_t *s = af->priv;
-
- free(s->lf);
- free(s->rf);
- free(s->lr);
- free(s->rr);
- free(s->cf);
- free(s->cr);
- free(s->ba_l);
- free(s->ba_r);
- free(s->ba_ir);
- free(s->fwrbuf_l);
- free(s->fwrbuf_r);
- free(s->fwrbuf_lr);
- free(s->fwrbuf_rr);
-}
-
-/* Filter data through filter
-
-Two "tricks" are used to compensate the "color" of the KEMAR data:
-
-1. The KEMAR data is refiltered to ensure that the front L, R channels
-on the same side of the ear are equalized (especially in the high
-frequencies).
-
-2. A bass compensation is introduced to ensure that 0-200 Hz are not
-damped (without any real 3D acoustical image, however).
-*/
-static int filter(struct af_instance *af, struct mp_audio *data)
-{
- af_hrtf_t *s = af->priv;
-
- if (!data)
- return 0;
- struct mp_audio *outframe =
- mp_audio_pool_get(af->out_pool, &af->fmt_out, data->samples);
- if (!outframe) {
- talloc_free(data);
- return -1;
- }
- mp_audio_copy_attributes(outframe, data);
-
- short *in = data->planes[0]; // Input audio data
- short *out = outframe->planes[0]; // Output audio data
- short *end = in + data->samples * data->nch; // Loop end
- float common, left, right, diff, left_b, right_b;
- const int dblen = s->dlbuflen, hlen = s->hrflen, blen = s->basslen;
-
- if(s->print_flag) {
- s->print_flag = 0;
- switch (s->decode_mode) {
- case HRTF_MIX_51:
- MP_INFO(af, "Using HRTF to mix %s discrete surround into "
- "L, R channels\n", s->matrix_mode ? "5+1" : "5");
- break;
- case HRTF_MIX_STEREO:
- MP_INFO(af, "Using HRTF to mix stereo into "
- "L, R channels\n");
- break;
- case HRTF_MIX_MATRIX2CH:
- MP_INFO(af, "Using active matrix to decode 2 channel "
- "input, HRTF to mix %s matrix surround into "
- "L, R channels\n", "3/2");
- break;
- default:
- MP_WARN(af, "bogus decode_mode: %d\n", s->decode_mode);
- break;
- }
-
- if(s->matrix_mode)
- MP_INFO(af, "Using active matrix to decode rear center "
- "channel\n");
- }
-
- /* MPlayer's 5 channel layout (notation for the variable):
- *
- * 0: L (LF), 1: R (RF), 2: Ls (LR), 3: Rs (RR), 4: C (CF), matrix
- * encoded: Cs (CR)
- *
- * or: L = left, C = center, R = right, F = front, R = rear
- *
- * Filter notation:
- *
- * CF
- * OF AF
- * Ear->
- * OR AR
- * CR
- *
- * or: C = center, A = same side, O = opposite, F = front, R = rear
- */
-
- while(in < end) {
- const int k = s->cyc_pos;
-
- update_ch(s, in, k);
-
- /* Simulate a 7.5 ms -20 dB echo of the center channel in the
- front channels (like reflection from a room wall) - a kind of
- psycho-acoustically "cheating" to focus the center front
- channel, which is normally hard to be perceived as front */
- s->lf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
- s->rf[k] += CFECHOAMPL * s->cf[(k + CFECHODELAY) % s->dlbuflen];
-
- switch (s->decode_mode) {
- case HRTF_MIX_51:
- case HRTF_MIX_MATRIX2CH:
- /* Mixer filter matrix */
- common = conv(dblen, hlen, s->cf, s->cf_ir, k + s->cf_o);
- if(s->matrix_mode) {
- /* In matrix decoding mode, the rear channel gain must be
- renormalized, as there is an additional channel. */
- matrix_decode(in, k, 2, 3, 0, s->dlbuflen,
- s->lr_fwr, s->rr_fwr,
- s->lrprr_fwr, s->lrmrr_fwr,
- &(s->adapt_lr_gain), &(s->adapt_rr_gain),
- &(s->adapt_lrprr_gain), &(s->adapt_lrmrr_gain),
- s->lr, s->rr, NULL, NULL, s->cr);
- common +=
- conv(dblen, hlen, s->cr, s->cr_ir, k + s->cr_o) *
- M1_76DB;
- left =
- ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
- (conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
- conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o)) *
- M1_76DB + common);
- right =
- ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
- (conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
- conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o)) *
- M1_76DB + common);
- } else {
- left =
- ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o) +
- conv(dblen, hlen, s->lr, s->ar_ir, k + s->ar_o) +
- conv(dblen, hlen, s->rr, s->or_ir, k + s->or_o) +
- common);
- right =
- ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o) +
- conv(dblen, hlen, s->rr, s->ar_ir, k + s->ar_o) +
- conv(dblen, hlen, s->lr, s->or_ir, k + s->or_o) +
- common);
- }
- break;
- case HRTF_MIX_STEREO:
- left =
- ( conv(dblen, hlen, s->lf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->rf, s->of_ir, k + s->of_o));
- right =
- ( conv(dblen, hlen, s->rf, s->af_ir, k + s->af_o) +
- conv(dblen, hlen, s->lf, s->of_ir, k + s->of_o));
- break;
- default:
- /* make gcc happy */
- left = 0.0;
- right = 0.0;
- break;
- }
-
- /* Bass compensation for the lower frequency cut of the HRTF. A
- cross talk of the left and right channel is introduced to
- match the directional characteristics of higher frequencies.
- The bass will not have any real 3D perception, but that is
- OK (note at 180 Hz, the wavelength is about 2 m, and any
- spatial perception is impossible). */
- left_b = conv(dblen, blen, s->ba_l, s->ba_ir, k);
- right_b = conv(dblen, blen, s->ba_r, s->ba_ir, k);
- left += (1 - BASSCROSS) * left_b + BASSCROSS * right_b;
- right += (1 - BASSCROSS) * right_b + BASSCROSS * left_b;
- /* Also mix the LFE channel (if available) */
- if(data->nch >= 6) {
- left += in[5] * M3_01DB;
- right += in[5] * M3_01DB;
- }
-
- /* Amplitude renormalization. */
- left *= AMPLNORM;
- right *= AMPLNORM;
-
- switch (s->decode_mode) {
- case HRTF_MIX_51:
- case HRTF_MIX_STEREO:
- /* "Cheating": linear stereo expansion to amplify the 3D
- perception. Note: Too much will destroy the acoustic space
- and may even result in headaches. */
- diff = STEXPAND2 * (left - right);
- out[0] = av_clip_int16(left + diff);
- out[1] = av_clip_int16(right - diff);
- break;
- case HRTF_MIX_MATRIX2CH:
- /* Do attempt any stereo expansion with matrix encoded
- sources. The L, R channels are already stereo expanded
- by the steering, any further stereo expansion will sound
- very unnatural. */
- out[0] = av_clip_int16(left);
- out[1] = av_clip_int16(right);
- break;
- }
-
- /* Next sample... */
- in = &in[data->nch];
- out = &out[af->data->nch];
- (s->cyc_pos)--;
- if(s->cyc_pos < 0)
- s->cyc_pos += dblen;
- }
-
- talloc_free(data);
- af_add_output_frame(af, outframe);
- return 0;
-}
-
-static int allocate(af_hrtf_t *s)
-{
- if ((s->lf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->rf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->lr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->rr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->cf = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->cr = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->ba_l = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->ba_r = malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->fwrbuf_l =
- malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->fwrbuf_r =
- malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->fwrbuf_lr =
- malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- if ((s->fwrbuf_rr =
- malloc(s->dlbuflen * sizeof(float))) == NULL) return -1;
- return 0;
-}
-
-/* Allocate memory and set function pointers */
-static int af_open(struct af_instance* af)
-{
- int i;
- af_hrtf_t *s;
- float fc;
-
- af->control = control;
- af->uninit = uninit;
- af->filter_frame = filter;
-
- s = af->priv;
-
- s->dlbuflen = DELAYBUFLEN;
- s->hrflen = HRTFFILTLEN;
- s->basslen = BASSFILTLEN;
-
- s->cyc_pos = s->dlbuflen - 1;
- /* With a full (two axis) steering matrix decoder, s->matrix_mode
- should not be enabled lightly (it will also steer the Ls, Rs
- channels). */
- s->matrix_mode = 0;
- s->decode_mode = HRTF_MIX_51;
-
- switch (s->mode) {
- case 0: /* Use matrix rear decoding. */
- s->matrix_mode = 1;
- break;
- case 1: /* Input needs matrix decoding. */
- s->decode_mode = HRTF_MIX_MATRIX2CH;
- break;
- case 2:
- s->matrix_mode = 0;
- break;
- }
-
- s->print_flag = 1;
-
- if (allocate(s) != 0) {
- MP_ERR(af, "Memory allocation error.\n");
- return AF_ERROR;
- }
-
- for(i = 0; i < s->dlbuflen; i++)
- s->lf[i] = s->rf[i] = s->lr[i] = s->rr[i] = s->cf[i] =
- s->cr[i] = 0;
-
- s->lr_fwr =
- s->rr_fwr = 0;
-
- s->cf_ir = cf_filt + (s->cf_o = pulse_detect(cf_filt));
- s->af_ir = af_filt + (s->af_o = pulse_detect(af_filt));
- s->of_ir = of_filt + (s->of_o = pulse_detect(of_filt));
- s->ar_ir = ar_filt + (s->ar_o = pulse_detect(ar_filt));
- s->or_ir = or_filt + (s->or_o = pulse_detect(or_filt));
- s->cr_ir = cr_filt + (s->cr_o = pulse_detect(cr_filt));
-
- if((s->ba_ir = malloc(s->basslen * sizeof(float))) == NULL) {
- MP_ERR(af, "Memory allocation error.\n");
- return AF_ERROR;
- }
- fc = 2.0 * BASSFILTFREQ / (float)af->data->rate;
- if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
- -1) {
- MP_ERR(af, "Unable to design low-pass "
- "filter.\n");
- return AF_ERROR;
- }
- for(i = 0; i < s->basslen; i++)
- s->ba_ir[i] *= BASSGAIN;
-
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_hrtf_t
-const struct af_info af_info_hrtf = {
- .info = "HRTF Headphone",
- .name = "hrtf",
- .open = af_open,
- .priv_size = sizeof(af_hrtf_t),
- .options = (const struct m_option[]) {
- OPT_CHOICE("mode", mode, 0, ({"m", 0}, {"s", 1}, {"0", 2})),
- {0}
- },
-};
diff --git a/audio/filter/af_hrtf.h b/audio/filter/af_hrtf.h
deleted file mode 100644
index 9ba9858aaf..0000000000
--- a/audio/filter/af_hrtf.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MPLAYER_AF_HRTF_H
-#define MPLAYER_AF_HRTF_H
-
-#define HRTF_MIX_51 0
-#define HRTF_MIX_STEREO 1
-#define HRTF_MIX_MATRIX2CH 2
-
-/* Amplitude scaling factors */
-#define M17_0DB 0.1414213562
-#define M9_03DB 0.3535533906
-#define M6_99DB 0.4472135955
-#define M4_77DB 0.5773502692
-#define M3_01DB 0.7071067812
-#define M1_76DB 0.8164965809
-
-#define DELAYBUFLEN 1024 /* Length of the delay buffer */
-#define HRTFFILTLEN 64 /* HRTF filter length */
-#define IRTHRESH 0.001 /* Impulse response pruning thresh. */
-
-#define AMPLNORM M6_99DB /* Overall amplitude renormalization */
-
-#define BASSFILTFREQ 180 /* Bass compensation filter cut (Hz) */
-#define BASSFILTLEN 193 /* Bass compensation filter length */
-#define BASSGAIN M_SQRT2 /* Bass compensation gain */
-#define BASSCROSS 0.35 /* Bass cross talk */
-
-#define FWRDURATION 240 /* FWR average duration (samples) */
-#define MATREARDELAY 720 /* Matrix mode rear delay (samples) */
-
-#define MATAGCTRIG 8.0 /* (Fuzzy) AGC trigger */
-#define MATAGCDECAY 1.0 /* AGC baseline decay rate (1/samp.) */
-#define MATAGCLOCK 0.2 /* AGC range (around 1) where the
- matrix behaves passively */
-#define MATCOMPGAIN 0.37 /* Cross talk compensation gain,
- 0.50 - 0.55 is full cancellation. */
-
-#define CFECHODELAY 360 /* Center front echo delay (samples) */
-#define CFECHOAMPL M17_0DB /* Center front echo amplitude */
-
-#define STEXPAND2 0.07 /* Stereo expansion / 2 */
-
-/* Head related impulse response (HRIR) derived from KEMAR measurement
- data by Bill Gardner <billg@media.mit.edu> and Keith Martin
- <kdm@media.mit.edu>
-
- URL: http://sound.media.mit.edu/KEMAR.html
-
- Distributed under GPL with authors' permission
-*/
-
-/* EQUALIZED KEMAR HRIR
-
-How to generate these data:
-
-1. You need the MIT Media Lab's KEMAR data, read it into an software
- capable of signal/time series analysis (like Mathematica, Matlab,
- ...)
-
-2. Construct an equalizing FIR inverse filter by calculating the
- transfer function of the front, same side impulse response, then
- take 1 over the absolute magnitude.
-
-3. Cut the poles in the inverse filter's transfer function
- specification by limiting the amplification to 2.5 (note, this
- number assumes that you have correct signal processing
- normalization of the Fourier transform).
-
-4. Design the FIR inverse filter by calculating the inverse Fourier
- transform, then chopping the coefficients down to a reasonable
- number (N = 15 is used here), apply the Kaiser-Bessel window (alpha
- = 2 is used here). Note the objective is remove the color bias
- only (as if you are using an equalizer), _not_ to do a full inverse
- filtering. (Note: beta = pi*alpha in other notation.)
-
- For N = 15, alpha = 2, you should get the following impulse
- response:
-
- 0.001001558668605168, 0.00698457265741865, 0.040453643039829436,
- 0.012230541722147855, -0.11939760844854072, 0.16468099899755967,
- -0.30297563073747436, 1.3140211791355982, -0.30297563073747436,
- 0.16468099899755967, -0.11939760844854072, 0.012230541722147855,
- 0.040453643039829436, 0.00698457265741865, 0.001001558668605168
-
-5. Linearly convolve all KEMAR HRIR with this inverse filter.
-
-6. Resample from 44.1 kHz sampling frequency to 48 kHz.
-*/
-
-/* Center front (-5 degree) - not 0 degree in order to create a clear
- front image from a finite distance */
-static const float cf_filt[128] = {
- -0.00008638082319075036, 0.0003198059946385229,
- -0.0005010631339162132, 0.0011424741331126876,
- -0.001584220794688753, 0.001742715363246275,
- -0.0011080796626780694, 0.0001651829990860167,
- 0.005235028337314985, 0.0035223828473357776,
- 0.010057681388431303, -0.033469432129545514,
- 0.013391253316233523, 0.004858462839827063,
- 0.08172161220103627, 0.26158596134500023,
- -0.12420314583323326, -0.14298458356097565,
- 0.14421897280453896, -0.1635792507629016,
- -0.02187136722480014, 0.2426863044711817,
- 0.07229814207917194, 0.0942742651913879,
- 0.29856830878076834, 0.2944146162057754,
- -0.12122157003421209, -0.19640092165631157,
- 0.11623836502034968, -0.05794027397995521,
- -0.34313138341973776, -0.19487516249168105,
- 0.010118993953802401, -0.09460218797710966,
- -0.16761521117359582, 0.004154461610153861,
- 0.052768641758969316, -0.00041823982226147407,
- 0.021634960445143514, 0.07562793486871108,
- 0.08895407129506479, 0.039857755093416214,
- 0.044257936180422945, 0.061557584906101664,
- 0.015547268541895703, -0.023908191934932484,
- 0.009498030443468223, 0.03816269003221337,
- -0.009820500607303615, -0.042003975527908084,
- -0.03335447117311547, -0.029294510859746596,
- -0.05212623136198511, -0.073427547153205,
- -0.061190797824958836, -0.04620925059966413,
- -0.04204619420702159, -0.02331915902615157,
- 0.00211481411477094, 0.00852563995740107,
- 0.008766809731743399, 0.008666632180812078,
- 0.018279202191625352, 0.02924332751289675,
- 0.022293148257836494, 0.012362146008584188,
- 0.008572582458807008, 0.006491370763597344,
- -0.0019366944997535774, -0.006318669309634434,
- -0.006457921690218669, -0.015050265524669974,
- -0.02110660282616213, -0.017027809096377904,
- -0.01651052305334348, -0.022770064150046673,
- -0.01999875754219472, -0.012294792027337775,
- -0.011506057031057188, -0.011448970577312903,
- -0.004823572302580925, 0.0022451134042777883,
- 0.004145473526859826, 0.005629030064546135,
- 0.008588029213398785, 0.010092048834844231,
- 0.007182013245552008, 0.0014600979508720656,
- -0.0038314646272511756, -0.003443901997881347,
- -0.0029483418254804047, -0.007609357112679647,
- -0.006518368948030822, -0.004495803701497202,
- -0.007109113004849672, -0.008346237278084265,
- -0.005560847336252453, -0.002993453167553188,
- -0.005122897816824269, -0.004389782626604215,
- -0.0010912633695218108, -0.0019712029474458835,
- -0.005870162265802235, -0.005626159534954128,
- -0.00027254977910844407, 0.0013794425431633785,
- -0.0005919083190430062, -0.0007861203545416682,
- -0.0007049560240893946, -0.0032720188494468868,
- -0.004460645567968504, -0.0032018528193571696,
- -0.0030579229375062105, -0.003593998902656612,
- -0.0038032977997776445, -0.004613776010454773,
- -0.0059796549143736845, -0.00420126194319768,
- -0.0012374419948287222, 0.0008572699213050608,
- 0.0021490971020081094, 0.00047295283198381995,
- -0.0009670277915884887, -0.001354440866080231,
- -0.002962902746547851, -0.00533935813338141,
- -0.005469203016468759, -0.004355784273189485
-};
-/* Front, same side (30 degree) */
-static const float af_filt[128] = {
- -0.004140580614755493, 0.005790934614385445,
- 0.003318916682081112, 0.014257145544366063,
- 0.007328442487127339, -0.06550381777876194,
- 0.03502225818161845, -0.013090579770708259,
- 0.2517776798694195, 0.420770489950659,
- -0.3418854608834852, -0.24371032493696737,
- 0.04901356150030018, -0.1778083521632833,
- 0.26448004245714163, 0.23245199964546834,
- 0.033053145803936305, 0.46811222821062415,
- 0.5359265986255611, -0.011912195468533787,
- -0.39763432601411647, -0.034482864386898314,
- 0.029445398240649626, -0.3850940407863262,
- -0.3272328478175581, -0.14701421403616477,
- -0.08522137400169517, -0.14936851633336035,
- -0.09432605283433723, 0.0991200405937827,
- 0.011075012089917331, -0.0051036489980274685,
- 0.0933903289749412, 0.1344189369609565,
- 0.10507466913017807, 0.04240159324684365,
- 0.06559270110638656, 0.026984119875617524,
- -0.03359846103238096, -0.018000197099174275,
- 0.042031818548178244, 0.03849039666888434,
- -0.02450829674011345, -0.03407882403088576,
- -0.029230189282961977, -0.046964865291761734,
- -0.09458258700116245, -0.1527349330901158,
- -0.15411577687826097, -0.08761679790956928,
- -0.033623549089171874, -0.007204768531481949,
- 0.008273425020444852, 0.021368717994908505,
- 0.04366608267875025, 0.05660907333076205,
- 0.06775726495503939, 0.05621881735271431,
- 0.03576231950669927, 0.02500825834889175,
- 0.015423811076054601, 0.007903258334503761,
- -0.0053873014137761945, -0.006987955469434698,
- -0.012027972007598602, -0.025228281243816594,
- -0.026225091797257318, -0.023809293997344882,
- -0.03250172017712295, -0.03195696301067249,
- -0.01784813952189948, -0.01663267233760342,
- -0.016184530450468065, -0.011659883749357463,
- -0.0035378511240219163, -0.0005485800790443406,
- 0.0018432660108168625, 0.011634844139907534,
- 0.018333603402051105, 0.020447379185133056,
- 0.00850783664147828, 0.0004694148911037838,
- -0.0017047130409786676, -0.0022409152834483997,
- -0.000860472174892845, -0.004111075059198666,
- -0.003527843382056666, -0.009640160874903018,
- -0.01750044574231376, -0.015613389403672443,
- -0.010790028120953001, -0.0095313499955768,
- -0.007469721416726809, -0.0019186578145117315,
- -0.00014977322572890802, -0.0029803838028179728,
- -0.006520567233727221, 0.000035015132033882596,
- 0.009245098100543752, 0.009896930052308656,
- 0.008316744929565786, 0.004575207140193997,
- -0.0000647420103997081, -0.004502916832871627,
- -0.004225962213251224, -0.002886014126381486,
- -0.006416834142585976, -0.007156609995423569,
- -0.008840274447579472, -0.01441763751386817,
- -0.015435817484659574, -0.00924487254924743,
- -0.0021571721940235205, 0.0028540722992305453,
- 0.00273577475088536, -0.000788412365513805,
- -0.0032650029728365907, -0.003880217646231338,
- -0.0035302087299613778, -0.0038531436176586246,
- -0.0011921632190514074, -0.0020722967099011938,
- -0.004985351145629344, -0.0042375588844648735,
- -0.003030360463006021, -0.0014161075428041471,
- -0.0005083025643192044, 0.00035096963769606926
-};
-/* Front, opposite (-30 degree) */
-static const float of_filt[128] = {
- -0.000013472538374193126, -0.00008048061877079751,
- 0.000043927265781258155, -0.000017931700794858892,
- -0.000034774602476112886, -0.00009576223008735474,
- 0.0001557797638630691, -0.00018742885883751094,
- 0.00026512448626705716, -0.0001451040203319678,
- -0.00008263233117758043, 0.0006486245853639179,
- -0.0010631408451846698, 0.0026571994100746143,
- 0.0014179177997092787, 0.0062326502956616256,
- -0.008194149324545333, -0.006568029415878379,
- 0.009538759710818582, 0.012309193558632693,
- 0.12336638055838955, 0.046164307101829005,
- -0.10228706407884815, 0.04047687260345798,
- -0.00296595313977046, -0.07057949208414134,
- 0.08172114840714612, 0.08736490764127891,
- 0.05105250431333021, 0.11627179512747428,
- 0.20717888490340705, 0.09375052213570291,
- -0.09784374168330194, -0.010493571845901443,
- 0.053131894303891716, -0.10157443971694806,
- -0.16264032634244974, -0.05402369511361273,
- -0.0274403608654217, -0.09860277022495063,
- -0.06841875821090282, -0.004434574400066223,
- -0.0005222661652743502, -0.006231881259827263,
- 0.014410397820340159, 0.04885649512730243,
- 0.04361962569042684, 0.03399214029009391,
- 0.04961073933475931, 0.04067325604132289,
- 0.007850647519227257, 0.004564440466905299,
- 0.02257107958021618, 0.008183791928884486,
- -0.014913479343180557, -0.018685938460856224,
- -0.01745737397226911, -0.02327177054233603,
- -0.03723048632685227, -0.044739390162299685,
- -0.042651220125613766, -0.03730017561004743,
- -0.029039465434276192, -0.01885087458914294,
- -0.01207127752277769, -0.006779800724164512,
- -0.001930416967444157, 0.000029454577995528385,
- 0.0013822760965755472, 0.0014799128583230202,
- 0.0002068200609199832, 0.0022254295286201083,
- 0.005143858159434566, 0.0018580542060917013,
- -0.0019426046325146259, -0.0014464042108543495,
- -0.0034430083560735582, -0.009692758426099499,
- -0.011840035292593485, -0.010716508855893968,
- -0.012939889036853034, -0.0121846427935653,
- -0.006198503315630782, -0.0023186723099380305,
- -0.002679872498314837, -0.003086020446226295,
- -0.0015709623347698936, -0.0008147490468332398,
- -0.0012384575726770983, -0.0005212877089109362,
- 0.0017707578744906142, 0.001324932723905786,
- -0.0017023653780617696, -0.0045108927752919425,
- -0.005422155613096912, -0.0039489323837623835,
- -0.005295995750506547, -0.00629706566356189,
- -0.004685732198036754, -0.0048076735568143,
- -0.005978864279217503, -0.005928999306332966,
- -0.004187703549017582, -0.003213999896976475,
- -0.0028068699816073414, -0.0010889703907593833,
- 0.0003276714243495386, -0.0013015007040186994,
- -0.003208050402434782, -0.0025115319088208545,
- -0.0013787553006401076, -0.0018279087370218635,
- -0.0025904836507747754, -0.002071221947222004,
- -0.0026424212922485594, -0.0039837031817577,
- -0.0041635566057380965, -0.004355223489150822,
- -0.004350395332709937, -0.0036693292471930263,
- -0.003386384394185026, -0.003972568655001128,
- -0.004332336840023821, -0.002648767912111827,
- -0.001384410080218114, -0.0011353792711849466,
- -0.0013726264946164232, -0.0020075119315034313
-};
-/* Rear, same side (135 degree) */
-static const float ar_filt[128] = {
- 0.004573315040810066, 0.0013592578059426913,
- 0.01553271930902704, -0.0002356117224941317,
- -0.05746098219774702, 0.03430688963370445,
- 0.00808371687447385, 0.21893535841158596,
- 0.2984357591724814, -0.3302799746504719,
- -0.3194029149806245, 0.21633225051331056,
- 0.24371260938097083, -0.08843705549751085,
- 0.03939684701343366, 0.45386926431114494,
- 0.07599118140753386, -0.18114706160474578,
- 0.285640624686038, 0.4049515236666218,
- -0.05347890222071792, -0.31464359045319074,
- -0.1033502246468194, -0.04553593949283157,
- -0.1880747731157464, -0.13629090230626037,
- -0.10435789106123239, -0.19818232801888755,
- -0.16701805476330397, -0.022793111199284,
- 0.058049696762683685, 0.007048321372693906,
- -0.002966419183225961, 0.10140569697797763,
- 0.11648999956673124, 0.05218347182779882,
- 0.028427001212735392, 0.04151900310166159,
- -0.0006960604221423734, -0.05898623212226975,
- -0.03801934531173312, -0.029306970535287986,
- -0.04549125782835908, -0.0599222718506552,
- -0.058299618975430116, -0.03765579129720727,
- -0.03559302657499581, -0.020647901025903054,
- -0.005720957338744348, -0.0041915732688915545,
- -0.0011470880098346143, 0.008737404798553,
- 0.023444168098121512, 0.024204226042172663,
- 0.01894897166475026, 0.020807655257479588,
- 0.021570431128040954, 0.006800556178576289,
- -0.009000089216921362, -0.010969824547067934,
- -0.0033653428332822374, -0.012676936164668659,
- -0.026739938673413587, -0.023427869194287573,
- -0.023302007105117244, -0.023647155590533712,
- -0.021289317515613106, -0.009120487305069884,
- 0.0009251551667728967, 0.00004285344125653763,
- -0.00009042365479456271, 0.00022573242339446494,
- 0.00720168491586098, 0.007111875505402431,
- 0.003186514817683482, 0.00810087718334745,
- 0.012619557025922575, 0.007854726400013397,
- -0.0024013592881066267, -0.001452457473161119,
- -0.0025535188366093945, -0.012428911627809337,
- -0.013729251536694145, -0.0070099675146427344,
- -0.007165284278706593, -0.01639289295622301,
- -0.015831795079778305, -0.007305768485523729,
- -0.003608863157004021, -0.0032640528878698084,
- 0.0030901263998481944, 0.00749497566124848,
- 0.002515185532327241, 0.00004840875738621367,
- 0.0017596043486043966, 0.0046229941553338144,
- 0.0034259167322926096, 0.003707347634186093,
- 0.0035584806528586328, -0.0019078936035275198,
- -0.006057343815214898, -0.0069262470468817,
- -0.004345020728618624, -0.004177623355574794,
- -0.005373506556122508, -0.006624933928893836,
- -0.008679541408588839, -0.010718719681595322,
- -0.011392246979594496, -0.007893917064389902,
- -0.0027572935365832536, -0.00006064707149834412,
- -0.0012512537319656323, -0.0024501501002409786,
- -0.0022106788572895998, -0.00234124933370301,
- -0.0008953445167066823, 0.0005393670625637734,
- -0.00033175600142209297, -0.004023994309351289,
- -0.008655472335784443, -0.009899957354849682,
- -0.008664952919996412, -0.00553483124503576,
- -0.003735336089277662, -0.002754824348643885,
- -0.0026884314856593368, -0.004084181815125924
-};
-/* Rear, opposite (-135 degree) */
-static const float or_filt[128] = {
- 0.0001220944028243897, -0.000021785381808441314,
- 5.823057988603169e-6, -0.00001217768176447613,
- -0.00006123604397345513, 5.574117262531134e-6,
- -0.00004935331914366778, 1.1771577934768211e-6,
- -0.000059236211621095756, 9.503536190497286e-6,
- -0.0001494445696103564, 0.00012248858284145305,
- -0.0000963975321456313, 6.017905197665205e-6,
- 0.00003353395360402643, -0.0001931511015359506,
- 0.0005113536523931485, -0.0005676652619386114,
- 0.0012057159755477467, 0.0009370492250339692,
- 0.004596472288877981, -0.0018831773384237068,
- -0.008208535225621212, 0.0038178646400751056,
- 0.008726517739105965, 0.06664363898418262,
- 0.06788684221502142, -0.04492315162807267,
- -0.04019906311255255, 0.026203059677375153,
- 0.013678129114847544, -0.014334962223993527,
- 0.010141709596167392, 0.11559131576945537,
- 0.1586402064538425, 0.059975334707967023,
- 0.004671725963777715, 0.031498678282775874,
- 0.014338626006524587, -0.014749719448472231,
- -0.02055508237941379, -0.05407690143992048,
- -0.07767559836886143, -0.05029091786216801,
- -0.030808335706574427, -0.03401958135442541,
- -0.030520368430288967, -0.014168302104259355,
- 0.011907621259989802, 0.014286081013069,
- 0.006377467879613449, 0.018546823568277478,
- 0.028297012771618273, 0.025222339408338186,
- 0.021931611353415138, 0.019708894333646355,
- 0.01729258494072014, 0.017468204169564034,
- 0.009729094845051928, -0.002976992018531901,
- -0.00956986166277019, -0.016125733548332074,
- -0.02934094241442545, -0.04133767871051455,
- -0.043536981145416466, -0.0385966307108608,
- -0.02784453599342459, -0.018995135307247116,
- -0.012849534096536747, -0.004437491064613308,
- 0.00028385411598204655, 0.003776874988516643,
- 0.008069432041547833, 0.008764754183751848,
- 0.008020908861878062, 0.006830351461360802,
- 0.002218330884267235, -0.0020478725582339444,
- -0.003997428121462543, -0.007066287373515421,
- -0.00940847412544698, -0.010938998446237963,
- -0.011775483016151306, -0.011391103919484287,
- -0.010586061195163017, -0.009842793078929053,
- -0.007753202010139829, -0.00569213732353025,
- -0.006506783349722073, -0.005346134281903736,
- -0.003913089814898934, -0.0036091443854759727,
- -0.0020328564301266287, 0.00017932870773467683,
- 0.0032779786679056357, 0.003969695813293966,
- 0.0020339334412434987, -0.00011345940675415259,
- -0.0018344103399567666, -0.003556764701666365,
- -0.004263523639408391, -0.002940568582022133,
- -0.0034341188272627556, -0.006023399920020824,
- -0.0077456903203677865, -0.007912219312377842,
- -0.00625202770436523, -0.00530785086116117,
- -0.005569722659634311, -0.004664448462594344,
- -0.0037747773914077747, -0.004175649656985592,
- -0.004659601521384289, -0.005008602967819641,
- -0.004730625079902729, -0.0034039554356604146,
- -0.0017110333873406587, -0.0006091938771510242,
- -0.0016051679050678297, -0.003312864664007262,
- -0.004505512715977288, -0.004152222189861692,
- -0.003218596419678823, -0.0027277806209877343,
- -0.001715005444317267, -0.0012589960071233749,
- -0.001852908777923165, -0.002540339553144362
-};
-/* Center rear (180 degree) */
-static const float cr_filt[128] = {
- -0.00005989110716536726, -0.00022790291829128702,
- 0.0002659166098971966, -0.0003774772716776257,
- 0.0004540309551867803, -0.000420238187386368,
- 0.00025518536450885686, 0.00028285526288953955,
- -0.001016391007574093, 0.0028634984299063795,
- 0.0021574799687976045, 0.01035121276682072,
- -0.010481720917298163, -0.013197198495899292,
- 0.0031928225328717195, 0.02903137843618603,
- 0.1632429772511569, 0.1047487989875262,
- -0.10464685060623742, -0.09260196288035998,
- -0.007514241993554443, 0.013596249226741712,
- -0.019876166508450258, 0.1255626123599804,
- 0.3648170359521724, 0.19458249753223478,
- -0.04434070930031298, 0.046582528121935265,
- 0.09484427347230277, -0.03137795311969644,
- -0.10297437925363695, -0.09351091015917065,
- -0.1129521092162064, -0.14925322995658827,
- -0.1231466295584665, -0.06356719756705227,
- -0.05442277895126282, -0.07568433015661316,
- -0.023314932828602003, 0.04260950721318558,
- 0.02249026315598923, 0.02048195669571197,
- 0.05651342117268278, 0.05885038917623213,
- 0.03797102097397795, 0.011767394419953451,
- 0.00560502503429481, 0.005051125343961189,
- -0.012925933188033823, -0.023918884651306566,
- -0.013251659441678816, -0.010694772488866284,
- -0.03080486448617846, -0.03661278237783158,
- -0.0379227303416262, -0.042189005718490775,
- -0.026595666344596286, -0.009759025956801257,
- -0.002064986663513004, -0.002420117028098389,
- -0.006629991977552491, 0.004619970897631026,
- 0.019450642967537877, 0.0173521119057514,
- 0.017641425439988062, 0.02270029598048491,
- 0.018976431925275348, 0.009299852902290885,
- -0.001695039371619912, -0.00675162574265618,
- -0.009380968871003034, -0.011208396125485165,
- -0.01308640049201482, -0.0165636375633249,
- -0.022004099870933345, -0.025173458684139286,
- -0.016918759559175375, -0.00865150653575917,
- -0.006999929082792643, -0.005454830010518988,
- -0.0021129521131095317, 0.00018717090054046307,
- -0.0002864344788569993, 0.0017615225381095569,
- 0.006985907557802283, 0.010577308310476465,
- 0.006466104789306027, -0.0014988738575948326,
- -0.0039669755229277195, -0.0065156971200080235,
- -0.009343206924192169, -0.0076430644693577495,
- -0.004395214976600924, -0.003052735340422483,
- -0.007019103043066595, -0.00974109267696527,
- -0.007968015032797376, -0.007801513845528344,
- -0.007535748903681969, -0.003543341967287925,
- 0.0015083125553729722, 0.0023345972556147025,
- -0.0010043623069557037, -0.0025295765105203746,
- -0.0023701840891643634, -0.0005908186035024362,
- 0.0029826252289082847, 0.004829048542117764,
- 0.004488360022902081, 0.00002643748103005408,
- -0.0042100779212597295, -0.006170600558114495,
- -0.007267149164680168, -0.006825522903494639,
- -0.006899834372739123, -0.0073493916110062675,
- -0.009554351265163382, -0.011790297433830197,
- -0.010645796603734424, -0.0064661575394022106,
- -0.002026743466524137, -0.0004337034584909932,
- -0.0011172647031654614, -0.0017947816283674731,
- -0.00255615052036616, -0.0017721562881944813,
- -0.0002379619297227554, 0.0007130120121089036
-};
-
-#endif /* MPLAYER_AF_HRTF_H */
diff --git a/audio/filter/af_karaoke.c b/audio/filter/af_karaoke.c
deleted file mode 100644
index 0c8dc626d7..0000000000
--- a/audio/filter/af_karaoke.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * simple voice removal filter
- *
- * copyright (c) 2006 Reynaldo H. Verdejo Pinochet
- * Based on code by Alex Beregszaszi for his 'center' filter.
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "af.h"
-
-// Data for specific instances of this filter
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- switch(cmd){
- case AF_CONTROL_REINIT:
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
- return af_test_output(af,(struct mp_audio*)arg);
- }
- return AF_UNKNOWN;
-}
-
-static int filter_frame(struct af_instance *af, struct mp_audio *c)
-{
- if (!c)
- return 0;
- if (af_make_writeable(af, c) < 0) {
- talloc_free(c);
- return 0;
- }
-
- float* a = c->planes[0]; // Audio data
- int nch = c->nch; // Number of channels
- int len = c->samples*nch; // Number of samples in current audio block
- register int i;
-
- /*
- FIXME1 add a low band pass filter to avoid suppressing
- centered bass/drums
- FIXME2 better calculated* attenuation factor
- */
-
- for(i=0;i<len;i+=nch)
- {
- a[i] = (a[i] - a[i+1]) * 0.7;
- a[i+1]=a[i];
- }
-
- af_add_output_frame(af, c);
- return 0;
-}
-
-// Allocate memory and set function pointers
-static int af_open(struct af_instance* af){
- af->control = control;
- af->filter_frame = filter_frame;
- return AF_OK;
-}
-
-// Description of this filter
-const struct af_info af_info_karaoke = {
- .info = "Simple karaoke/voice-removal audio filter",
- .name = "karaoke",
- .flags = AF_FLAGS_NOT_REENTRANT,
- .open = af_open,
-};
diff --git a/audio/filter/af_ladspa.c b/audio/filter/af_ladspa.c
deleted file mode 100644
index edde6a68b1..0000000000
--- a/audio/filter/af_ladspa.c
+++ /dev/null
@@ -1,851 +0,0 @@
-/*
- * LADSPA plugin loader
- *
- * Written by Ivo van Poorten <ivop@euronet.nl>
- * Copyright (C) 2004, 2005
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* ------------------------------------------------------------------------- */
-
-/* Global Includes */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <inttypes.h>
-#include <math.h>
-#include <limits.h>
-
-#include <dlfcn.h>
-#include <ladspa.h>
-
-/* ------------------------------------------------------------------------- */
-
-/* Local Includes */
-
-#include "af.h"
-
-#define _(x) (x)
-
-/* ------------------------------------------------------------------------- */
-
-/* Filter specific data */
-
-typedef struct af_ladspa_s
-{
- int status; /**< Status of the filter.
- * Either AF_OK or AF_ERROR
- * Because MPlayer re-inits audio filters that
- * _clearly_ returned AF_ERROR anyway, I use this
- * in play() to skip the processing and return
- * the data unchanged.
- */
-
- int activated; /**< 0 or 1. Activate LADSPA filters only once, even
- * if the buffers get resized, to avoid a stuttering
- * filter.
- */
-
- char *file;
- char *label;
- char *controls;
-
- char *myname; /**< It's easy to have a concatenation of file and label */
-
- void *libhandle;
- const LADSPA_Descriptor *plugin_descriptor;
-
- int nports;
-
- int ninputs;
- int *inputs;
-
- int noutputs;
- int *outputs;
-
- int ninputcontrols;
- int *inputcontrolsmap; /**< Map input port number [0-] to actual port */
- float *inputcontrols;
-
- int noutputcontrols;
- int *outputcontrolsmap;
- float *outputcontrols;
-
- int nch; /**< number of channels */
- int bufsize;
- float **inbufs;
- float **outbufs;
- LADSPA_Handle *chhandles;
-
-} af_ladspa_t;
-
-/* ------------------------------------------------------------------------- */
-
-static int af_open(struct af_instance *af);
-static int af_ladspa_malloc_failed(char*);
-
-/* ------------------------------------------------------------------------- */
-
-#define OPT_BASE_STRUCT af_ladspa_t
-const struct af_info af_info_ladspa = {
- .info = "LADSPA plugin loader",
- .name = "ladspa",
- .open = af_open,
- .priv_size = sizeof(af_ladspa_t),
- .options = (const struct m_option[]) {
- OPT_STRING("file", file, 0),
- OPT_STRING("label", label, 0),
- OPT_STRING("controls", controls, 0),
- {0}
- },
-};
-
-/* ------------------------------------------------------------------------- */
-
-/* By lack of a better word (in my vocabulary) this is called 'parse'.
- * Feel free to suggest an alternative.
- */
-
-/** \brief Check for inputs, outputs and controls of a given filter.
- *
- * This function counts and checks all input, output and control ports
- * of the filter that was loaded. If it turns out to be a valid
- * filter for MPlayer use, it prints out a list of all controls and
- * the corresponding range of its value at message level MSGL_V.
- *
- * \param setup Current setup of the filter. Must have its
- * plugin_descriptor set!
- *
- * \return Returns AF_OK if it has a valid input/output/controls
- * configuration. Else, it returns AF_ERROR.
- */
-
-static int af_ladspa_parse_plugin(struct af_instance *af) {
- af_ladspa_t *setup = af->priv;
- int p, i;
- const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
- LADSPA_PortDescriptor d;
- LADSPA_PortRangeHint hint;
-
- if (!setup->libhandle)
- return AF_ERROR; /* only call parse after a successful load */
- if (!setup->plugin_descriptor)
- return AF_ERROR; /* same as above */
-
- /* let's do it */
-
- setup->nports = pdes->PortCount;
-
- /* allocate memory for all inputs/outputs/controls */
-
- setup->inputs = calloc(setup->nports, sizeof(int));
- if (!setup->inputs) return af_ladspa_malloc_failed(setup->myname);
-
- setup->outputs = calloc(setup->nports, sizeof(int));
- if (!setup->outputs) return af_ladspa_malloc_failed(setup->myname);
-
- setup->inputcontrolsmap = calloc(setup->nports, sizeof(int));
- if (!setup->inputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
-
- setup->inputcontrols = calloc(setup->nports, sizeof(float));
- if (!setup->inputcontrols) return af_ladspa_malloc_failed(setup->myname);
-
- setup->outputcontrolsmap = calloc(setup->nports, sizeof(int));
- if (!setup->outputcontrolsmap) return af_ladspa_malloc_failed(setup->myname);
-
- setup->outputcontrols = calloc(setup->nports, sizeof(float));
- if (!setup->outputcontrols) return af_ladspa_malloc_failed(setup->myname);
-
- /* set counts to zero */
-
- setup->ninputs = 0;
- setup->noutputs = 0;
- setup->ninputcontrols = 0;
- setup->noutputcontrols = 0;
-
- /* check all ports, see what type it is and set variables according to
- * what we have found
- */
-
- for (p=0; p<setup->nports; p++) {
- d = pdes->PortDescriptors[p];
-
- if (LADSPA_IS_PORT_AUDIO(d)) {
- if (LADSPA_IS_PORT_INPUT(d)) {
- setup->inputs[setup->ninputs] = p;
- setup->ninputs++;
- } else if (LADSPA_IS_PORT_OUTPUT(d)) {
- setup->outputs[setup->noutputs] = p;
- setup->noutputs++;
- }
- }
-
- if (LADSPA_IS_PORT_CONTROL(d)) {
- if (LADSPA_IS_PORT_INPUT(d)) {
- setup->inputcontrolsmap[setup->ninputcontrols] = p;
- setup->ninputcontrols++;
- /* set control to zero. set values after reading the rest
- * of the suboptions and check LADSPA_?_HINT's later.
- */
- setup->inputcontrols[p] = 0.0f;
- } else if (LADSPA_IS_PORT_OUTPUT(d)) {
- /* read and handle these too, otherwise filters that have them
- * will sig11
- */
- setup->outputcontrolsmap[setup->noutputcontrols]=p;
- setup->noutputcontrols++;
- setup->outputcontrols[p] = 0.0f;
- }
- }
-
- }
-
- if (setup->ninputs == 0) {
- MP_WARN(af, "%s: %s\n", setup->myname,
- _("WARNING! This LADSPA plugin has no audio inputs.\n The incoming audio signal will be lost."));
- } else if (setup->ninputs == 1) {
- MP_VERBOSE(af, "%s: this is a mono effect\n", setup->myname);
- } else if (setup->ninputs == 2) {
- MP_VERBOSE(af, "%s: this is a stereo effect\n", setup->myname);
- } else {
- MP_VERBOSE(af, "%s: this is a %i-channel effect, "
- "support is experimental\n", setup->myname, setup->ninputs);
- }
-
- if (setup->noutputs == 0) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("This LADSPA plugin has no audio outputs."));
- return AF_ERROR;
- }
-
- if (setup->noutputs != setup->ninputs ) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("The number of audio inputs and audio outputs of the LADSPA plugin differ."));
- return AF_ERROR;
- }
-
- MP_VERBOSE(af, "%s: this plugin has %d input control(s)\n",
- setup->myname, setup->ninputcontrols);
-
- /* Print list of controls and its range of values it accepts */
-
- for (i=0; i<setup->ninputcontrols; i++) {
- p = setup->inputcontrolsmap[i];
- hint = pdes->PortRangeHints[p];
- MP_VERBOSE(af, " --- %d %s [", i, pdes->PortNames[p]);
-
- if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) {
- MP_VERBOSE(af, "%0.2f , ", hint.LowerBound);
- } else {
- MP_VERBOSE(af, "... , ");
- }
-
- if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) {
- MP_VERBOSE(af, "%0.2f]\n", hint.UpperBound);
- } else {
- MP_VERBOSE(af, "...]\n");
- }
-
- }
-
- return AF_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/* This function might "slightly" look like dlopenLADSPA in the LADSPA SDK :-)
- * But, I changed a few things, because imho it was broken. It did not support
- * relative paths, only absolute paths that start with a /
- * I think ../../some/dir/foobar.so is just as valid. And if one wants to call
- * his library '...somename...so' he's crazy, but it should be allowed.
- * So, search the path first, try plain *filename later.
- * Also, try adding .so first! I like the recursion the SDK did, but it's
- * better the other way around. -af ladspa=cmt:amp_stereo:0.5 is easier to type
- * than -af ladspa=cmt.so:amp_stereo:0.5 :-))
- */
-
-/** \brief dlopen() wrapper
- *
- * This is a wrapper around dlopen(). It tries various variations of the
- * filename (with or without the addition of the .so extension) in various
- * directories specified by the LADSPA_PATH environment variable. If all fails
- * it tries the filename directly as an absolute path to the library.
- *
- * \param filename filename of the library to load.
- * \param flag see dlopen(3) for a description of the flags.
- *
- * \return returns a pointer to the loaded library on success, or
- * NULL if it fails to load.
- */
-
-static void* mydlopen(const char *filename, int flag) {
- char *buf;
- const char *end, *start, *ladspapath;
- int endsinso;
- size_t filenamelen;
- void *result = NULL;
-
-#if defined(__MINGW32__) || defined(__CYGWIN__)
- /* For Windows there's only absolute path support.
- * If you have a Windows machine, feel free to fix this.
- * (path separator, shared objects extension, et cetera). */
- MP_VERBOSE(af, "\ton windows, only absolute pathnames "
- "are supported\n");
- MP_VERBOSE(af, "\ttrying %s\n", filename);
- return dlopen(filename, flag);
-#endif
-
- filenamelen = strlen(filename);
-
- endsinso = 0;
- if (filenamelen > 3)
- endsinso = (strcmp(filename+filenamelen-3, ".so") == 0);
- if (!endsinso) {
- buf=malloc(filenamelen+4);
- strcpy(buf, filename);
- strcat(buf, ".so");
- result=mydlopen(buf, flag);
- free(buf);
- }
-
- if (result)
- return result;
-
- ladspapath=getenv("LADSPA_PATH");
-
- if (ladspapath) {
- start=ladspapath;
- while (*start != '\0') {
- int needslash;
- end=start;
- while ( (*end != ':') && (*end != '\0') )
- end++;
-
- buf=malloc(filenamelen + 2 + (end-start) );
- if (end > start)
- strncpy(buf, start, end-start);
- needslash=0;
- if (end > start)
- if (*(end-1) != '/') {
- needslash = 1;
- buf[end-start] = '/';
- }
- strcpy(buf+needslash+(end-start), filename);
-
- result=dlopen(buf, flag);
-
- free(buf);
- if (result)
- return result;
-
- start = end;
- if (*start == ':')
- start++;
- } /* end while there's still more in the path */
- } /* end if there's a ladspapath */
-
- /* last resort, just open it again, so the dlerror() message is correct */
- return dlopen(filename,flag);
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Load a LADSPA Plugin
- *
- * This function loads the LADSPA plugin specified by the file and label
- * that are present in the setup variable. First, it loads the library.
- * If it fails, it returns AF_ERROR. If not, it continues to look for the
- * specified label. If it finds it, it sets the plugin_descriptor inside
- * setup and returns AF_OK. If it doesn't, it returns AF_ERROR. Special case
- * is a label called 'help'. In that case, it prints a list of all available
- * labels (filters) in the library specified by file.
- *
- * \param setup Current setup of the filter. Contains filename and label.
- *
- * \return Either AF_ERROR or AF_OK, depending on the success of the operation.
- */
-
-static int af_ladspa_load_plugin(struct af_instance *af) {
- af_ladspa_t *setup = af->priv;
- const LADSPA_Descriptor *ladspa_descriptor;
- LADSPA_Descriptor_Function descriptor_function;
- int i;
-
- /* load library */
- MP_VERBOSE(af, "%s: loading ladspa plugin library %s\n",
- setup->myname, setup->file);
-
- setup->libhandle = mydlopen(setup->file, RTLD_NOW);
-
- if (!setup->libhandle) {
- MP_ERR(af, "%s: %s %s\n\t%s\n", setup->myname,
- _("failed to load"), setup->file, dlerror() );
- return AF_ERROR;
- }
-
- MP_VERBOSE(af, "%s: library found.\n", setup->myname);
-
- /* find descriptor function */
- dlerror();
- descriptor_function = (LADSPA_Descriptor_Function) dlsym (setup->libhandle,
- "ladspa_descriptor");
-
- if (!descriptor_function) {
- MP_ERR(af, "%s: %s\n\t%s\n", setup->myname,
- _("Couldn't find ladspa_descriptor() function in the specified library file."), dlerror());
- return AF_ERROR;
- }
-
- /* if label == help, list all labels in library and exit */
-
- if (strcmp(setup->label, "help") == 0) {
- MP_INFO(af, "%s: %s %s:\n", setup->myname,
- _("available labels in"), setup->file);
- for (i=0; ; i++) {
- ladspa_descriptor = descriptor_function(i);
- if (ladspa_descriptor == NULL) {
- return AF_ERROR;
- }
- MP_INFO(af, " %-16s - %s (%lu)\n",
- ladspa_descriptor->Label,
- ladspa_descriptor->Name,
- ladspa_descriptor->UniqueID);
- }
- }
-
- MP_VERBOSE(af, "%s: looking for label\n", setup->myname);
-
- /* find label in library */
- for (i=0; ; i++) {
- ladspa_descriptor = descriptor_function(i);
- if (ladspa_descriptor == NULL) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("Couldn't find label in plugin library."));
- return AF_ERROR;
- }
- if (strcmp(ladspa_descriptor->Label, setup->label) == 0) {
- setup->plugin_descriptor = ladspa_descriptor;
- MP_VERBOSE(af, "%s: %s found\n", setup->myname,
- setup->label);
- return AF_OK;
- }
- }
-
- return AF_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Print a malloc() failed error message.
- *
- * Generic function which can be called if a call to malloc(), calloc(),
- * strdup(), et cetera, failed. It prints a message to the console and
- * returns AF_ERROR.
- *
- * \return AF_ERROR
- */
-
-static int af_ladspa_malloc_failed(char *myname) {
- return AF_ERROR;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Controls the filter.
- *
- * Control the behaviour of the filter.
- *
- * Commands:
- * CONTROL_REINIT Sets the af structure with proper values for number
- * of channels, rate, format, et cetera.
- * \param af Audio filter instance
- * \param cmd The command to execute
- * \param arg Arguments to the command
- *
- * \return Either AF_ERROR or AF_OK, depending on the succes of the
- * operation.
- */
-
-static int control(struct af_instance *af, int cmd, void *arg) {
- af_ladspa_t *setup = (af_ladspa_t*) af->priv;
-
- switch(cmd) {
- case AF_CONTROL_REINIT:
- MP_VERBOSE(af, "%s: (re)init\n", setup->myname);
-
- if (!arg) return AF_ERROR;
-
- /* accept FLOAT, let af_format do conversion */
-
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
-
- return af_test_output(af, (struct mp_audio*)arg);
- }
-
- return AF_UNKNOWN;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Uninitialise the LADSPA Plugin Loader filter.
- *
- * This function deactivates the plugin(s), cleans up, frees all allocated
- * memory and exits.
- *
- * \return No return value.
- */
-
-static void uninit(struct af_instance *af) {
- if (af->priv) {
- af_ladspa_t *setup = (af_ladspa_t*) af->priv;
- const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
-
- if (setup->myname) {
- MP_VERBOSE(af, "%s: cleaning up\n", setup->myname);
- free(setup->myname);
- }
-
- if (setup->chhandles) {
- for (int i = 0; i < setup->nch; i+=setup->ninputs) {
- if (pdes->deactivate) pdes->deactivate(setup->chhandles[i]);
- if (pdes->cleanup) pdes->cleanup(setup->chhandles[i]);
- }
- free(setup->chhandles);
- }
-
- free(setup->inputcontrolsmap);
- free(setup->inputcontrols);
- free(setup->outputcontrolsmap);
- free(setup->outputcontrols);
- free(setup->inputs);
- free(setup->outputs);
-
- if (setup->inbufs) {
- for(int i = 0; i < setup->nch; i++)
- free(setup->inbufs[i]);
- free(setup->inbufs);
- }
-
- if (setup->outbufs) {
- for (int i = 0; i < setup->nch; i++)
- free(setup->outbufs[i]);
- free(setup->outbufs);
- }
-
- if (setup->libhandle)
- dlclose(setup->libhandle);
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Process chunk of audio data through the selected LADSPA Plugin.
- *
- * \param af Pointer to audio filter instance
- * \param data Pointer to chunk of audio data
- *
- * \return Either AF_ERROR or AF_OK
- */
-
-static int filter_frame(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- af_ladspa_t *setup = af->priv;
- const LADSPA_Descriptor *pdes = setup->plugin_descriptor;
- float *audio = (float*)data->planes[0];
- int nsamples = data->samples*data->nch;
- int nch = data->nch;
- int rate = data->rate;
- int i, p;
-
- if (setup->status !=AF_OK) {
- talloc_free(data);
- return -1;
- }
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return -1;
- }
-
- /* See if it's the first call. If so, setup inbufs/outbufs, instantiate
- * plugin, connect ports and activate plugin
- */
-
- if ( (setup->bufsize != nsamples/nch) || (setup->nch != nch) ) {
-
- /* if setup->nch==0, it's the first call, if not, something has
- * changed and all previous mallocs have to be freed
- */
-
- if (setup->nch != 0) {
- MP_TRACE(af, "%s: bufsize change; free old buffer\n",
- setup->myname);
-
- if(setup->inbufs) {
- for(i=0; i<setup->nch; i++)
- free(setup->inbufs[i]);
- free(setup->inbufs);
- }
- if(setup->outbufs) {
- for(i=0; i<setup->nch; i++)
- free(setup->outbufs[i]);
- free(setup->outbufs);
- }
- } /* everything is freed */
-
- setup->bufsize = nsamples/nch;
- setup->nch = nch;
-
- setup->inbufs = calloc(nch, sizeof(float*));
- setup->outbufs = calloc(nch, sizeof(float*));
-
- MP_TRACE(af, "%s: bufsize = %d\n",
- setup->myname, setup->bufsize);
-
- for(i=0; i<nch; i++) {
- setup->inbufs[i] = calloc(setup->bufsize, sizeof(float));
- setup->outbufs[i] = calloc(setup->bufsize, sizeof(float));
- }
-
- /* only on the first call, there are no handles. */
-
- if (!setup->chhandles) {
- setup->chhandles = calloc(nch, sizeof(LADSPA_Handle));
-
- /* create handles
- * for stereo effects, create one handle for two channels
- */
-
- for(i=0; i<nch; i++) {
-
- if (i % setup->ninputs) { /* stereo effect */
- /* copy the handle from previous channel */
- setup->chhandles[i] = setup->chhandles[i-1];
- continue;
- }
-
- setup->chhandles[i] = pdes->instantiate(pdes, rate);
- }
- }
-
- /* connect input/output ports for each channel/filter instance
- *
- * always (re)connect ports
- */
-
- for(i=0; i<nch; i++) {
- pdes->connect_port(setup->chhandles[i],
- setup->inputs[i % setup->ninputs],
- setup->inbufs[i]);
- pdes->connect_port(setup->chhandles[i],
- setup->outputs[i % setup->ninputs],
- setup->outbufs[i]);
-
- /* connect (input) controls */
-
- for (p=0; p<setup->nports; p++) {
- LADSPA_PortDescriptor d = pdes->PortDescriptors[p];
- if (LADSPA_IS_PORT_CONTROL(d)) {
- if (LADSPA_IS_PORT_INPUT(d)) {
- pdes->connect_port(setup->chhandles[i], p,
- &(setup->inputcontrols[p]) );
- } else {
- pdes->connect_port(setup->chhandles[i], p,
- &(setup->outputcontrols[p]) );
- }
- }
- }
-
- /* Activate filter (if it isn't already :) ) */
-
- if (pdes->activate && !setup->activated && i % setup->ninputs == 0)
- pdes->activate(setup->chhandles[i]);
-
- } /* All channels/filters done! except for... */
- setup->activated = 1;
-
- /* Stereo effect with one channel left. Use same buffer for left
- * and right. connect it to the second port.
- */
-
- for (p = i; p % setup->ninputs; p++) {
- pdes->connect_port(setup->chhandles[i-1],
- setup->inputs[p % setup->ninputs],
- setup->inbufs[i-1]);
- pdes->connect_port(setup->chhandles[i-1],
- setup->outputs[p % setup->ninputs],
- setup->outbufs[i-1]);
- } /* done! */
-
- } /* setup for first call/change of bufsize is done.
- * normal playing routine follows...
- */
-
- /* Right now, I use a separate input and output buffer.
- * I could change this to in-place processing (inbuf==outbuf), but some
- * ladspa filters are broken and are not able to handle that. This seems
- * fast enough, so unless somebody complains, it stays this way :)
- */
-
- /* Fill inbufs */
-
- for (p=0; p<setup->bufsize; p++) {
- for (i=0; i<nch; i++) {
- setup->inbufs[i][p] = audio[p*nch + i];
- }
- }
-
- /* Run filter(s) */
-
- for (i=0; i<nch; i+=setup->ninputs) {
- pdes->run(setup->chhandles[i], setup->bufsize);
- }
-
- /* Extract outbufs */
-
- for (p=0; p<setup->bufsize; p++) {
- for (i=0; i<nch; i++) {
- audio[p*nch + i] = setup->outbufs[i][p];
- }
- }
-
- /* done */
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/** \brief Open LADSPA Plugin Loader Filter
- *
- * \param af Audio Filter instance
- *
- * \return Either AF_ERROR or AF_OK
- */
-
-static int af_open(struct af_instance *af) {
-
- af->control=control;
- af->uninit=uninit;
- af->filter_frame = filter_frame;
-
- af_ladspa_t *setup = af->priv;
-
- setup->status = AF_ERROR; /* will be set to AF_OK if
- * all went OK and filter()
- * should proceed.
- */
-
- setup->myname = strdup(af_info_ladspa.name);
- if (!setup->myname)
- return af_ladspa_malloc_failed((char*)af_info_ladspa.name);
-
- if (!setup->file || !setup->file[0]) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("No library file specified."));
- uninit(af);
- return AF_ERROR;
- }
- if (!setup->label || !setup->label[0]) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("No filter label specified."));
- uninit(af);
- return AF_ERROR;
- }
-
- free(setup->myname);
- setup->myname = calloc(strlen(af_info_ladspa.name)+strlen(setup->file)+
- strlen(setup->label)+6, 1);
- snprintf(setup->myname, strlen(af_info_ladspa.name)+
- strlen(setup->file)+strlen(setup->label)+6, "%s: (%s:%s)",
- af_info_ladspa.name, setup->file, setup->label);
-
- /* load plugin :) */
-
- if ( af_ladspa_load_plugin(af) != AF_OK )
- return AF_ERROR;
-
- /* see what inputs, outputs and controls this plugin has */
- if ( af_ladspa_parse_plugin(af) != AF_OK )
- return AF_ERROR;
-
- /* ninputcontrols is set by now, read control values from arg */
-
- float val;
- char *line = setup->controls;
- for (int i = 0; i < setup->ninputcontrols; i++) {
- if (!line || (i != 0 && *line != ',')) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("Not enough controls specified on the command line."));
- return AF_ERROR;
- }
- if (i != 0)
- line++;
- if (sscanf(line, "%f", &val) != 1) {
- MP_ERR(af, "%s: %s\n", setup->myname,
- _("Not enough controls specified on the command line."));
- return AF_ERROR;
- }
- setup->inputcontrols[setup->inputcontrolsmap[i]] = val;
- line = strchr(line, ',');
- }
-
- MP_VERBOSE(af, "%s: input controls: ", setup->myname);
- for (int i = 0; i < setup->ninputcontrols; i++) {
- MP_VERBOSE(af, "%0.4f ",
- setup->inputcontrols[setup->inputcontrolsmap[i]]);
- }
- MP_VERBOSE(af, "\n");
-
- /* check boundaries of inputcontrols */
-
- MP_VERBOSE(af, "%s: checking boundaries of input controls\n",
- setup->myname);
- for (int i = 0; i < setup->ninputcontrols; i++) {
- int p = setup->inputcontrolsmap[i];
- LADSPA_PortRangeHint hint =
- setup->plugin_descriptor->PortRangeHints[p];
- val = setup->inputcontrols[p];
-
- if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) &&
- val < hint.LowerBound) {
- MP_ERR(af, "%s: Input control #%d is below lower boundary of %0.4f.\n",
- setup->myname, i, hint.LowerBound);
- return AF_ERROR;
- }
- if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) &&
- val > hint.UpperBound) {
- MP_ERR(af, "%s: Input control #%d is above upper boundary of %0.4f.\n",
- setup->myname, i, hint.UpperBound);
- return AF_ERROR;
- }
- }
- MP_VERBOSE(af, "%s: all controls have sane values\n",
- setup->myname);
-
- /* All is well! */
- setup->status = AF_OK;
-
- return AF_OK;
-}
-
-/* ------------------------------------------------------------------------- */
diff --git a/audio/filter/af_sinesuppress.c b/audio/filter/af_sinesuppress.c
deleted file mode 100644
index 2418262f5d..0000000000
--- a/audio/filter/af_sinesuppress.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Niedermayer
- * Copyright (C) 2004 Alex Beregszaszi
- * based upon af_extrastereo.c by Pierre Lombard
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <inttypes.h>
-#include <math.h>
-#include <limits.h>
-
-#include "af.h"
-
-// Data for specific instances of this filter
-typedef struct af_sinesuppress_s
-{
- double freq;
- double decay;
- double real;
- double imag;
- double ref;
- double pos;
-}af_sinesuppress_t;
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- switch(cmd){
- case AF_CONTROL_REINIT:{
- // Sanity check
- if(!arg) return AF_ERROR;
-
- mp_audio_copy_config(af->data, (struct mp_audio*)arg);
- mp_audio_set_num_channels(af->data, 1);
- mp_audio_set_format(af->data, AF_FORMAT_S16);
-
- return af_test_output(af,(struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-static int play_s16(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return -1;
- }
-
- af_sinesuppress_t *s = af->priv;
- register int i = 0;
- int16_t *a = (int16_t*)data->planes[0]; // Audio data
- int len = data->samples*data->nch; // Number of samples
-
- for (i = 0; i < len; i++)
- {
- double co= cos(s->pos);
- double si= sin(s->pos);
-
- s->real += co * a[i];
- s->imag += si * a[i];
- s->ref += co * co;
-
- a[i] -= (s->real * co + s->imag * si) / s->ref;
-
- s->real -= s->real * s->decay;
- s->imag -= s->imag * s->decay;
- s->ref -= s->ref * s->decay;
-
- s->pos += 2 * M_PI * s->freq / data->rate;
- }
-
- MP_VERBOSE(af, "f:%8.2f: amp:%8.2f\n", s->freq, sqrt(s->real*s->real + s->imag*s->imag) / s->ref);
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-// Allocate memory and set function pointers
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = play_s16;
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_sinesuppress_t
-const struct af_info af_info_sinesuppress = {
- .info = "Sine Suppress",
- .name = "sinesuppress",
- .open = af_open,
- .priv_size = sizeof(af_sinesuppress_t),
- .options = (const struct m_option[]) {
- OPT_DOUBLE("freq", freq, 0, OPTDEF_DOUBLE(50.0)),
- OPT_DOUBLE("decay", decay, 0, OPTDEF_DOUBLE(0.0001)),
- {0}
- },
-};
diff --git a/audio/filter/af_sub.c b/audio/filter/af_sub.c
deleted file mode 100644
index 82aa77f4a4..0000000000
--- a/audio/filter/af_sub.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2002 Anders Johansson ajh@watri.uwa.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* This filter adds a sub-woofer channels to the audio stream by
- averaging the left and right channel and low-pass filter them. The
- low-pass filter is implemented as a 4th order IIR Butterworth
- filter, with a variable cutoff frequency between 10 and 300 Hz. The
- filter gives 24dB/octave attenuation. There are two runtime
- controls one for setting which channel to insert the sub-audio into
- called AF_CONTROL_SUB_CH and one for setting the cutoff frequency
- called AF_CONTROL_SUB_FC.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "common/common.h"
-#include "af.h"
-#include "dsp.h"
-
-// Q value for low-pass filter
-#define Q 1.0
-
-// Analog domain biquad section
-typedef struct{
- float a[3]; // Numerator coefficients
- float b[3]; // Denominator coefficients
-} biquad_t;
-
-// S-parameters for designing 4th order Butterworth filter
-static const biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}},
- {{1.0,0.0,0.0},{1.0,1.847759,1.0}}};
-
-// Data for specific instances of this filter
-typedef struct af_sub_s
-{
- float w[2][4]; // Filter taps for low-pass filter
- float q[2][2]; // Circular queues
- float fc; // Cutoff frequency [Hz] for low-pass filter
- float k; // Filter gain;
- int ch; // Channel number which to insert the filtered data
-
-}af_sub_t;
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- af_sub_t* s = af->priv;
-
- switch(cmd){
- case AF_CONTROL_REINIT:{
- // Sanity check
- if(!arg) return AF_ERROR;
-
- af->data->rate = ((struct mp_audio*)arg)->rate;
- mp_audio_set_channels_old(af->data, MPMAX(s->ch+1,((struct mp_audio*)arg)->nch));
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
-
- // Design low-pass filter
- s->k = 1.0;
- if((-1 == af_filter_szxform(sp[0].a, sp[0].b, Q, s->fc,
- (float)af->data->rate, &s->k, s->w[0])) ||
- (-1 == af_filter_szxform(sp[1].a, sp[1].b, Q, s->fc,
- (float)af->data->rate, &s->k, s->w[1])))
- return AF_ERROR;
- return af_test_output(af,(struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-#ifndef IIR
-#define IIR(in,w,q,out) { \
- float h0 = (q)[0]; \
- float h1 = (q)[1]; \
- float hn = (in) - h0 * (w)[0] - h1 * (w)[1]; \
- out = hn + h0 * (w)[2] + h1 * (w)[3]; \
- (q)[1] = h0; \
- (q)[0] = hn; \
-}
-#endif
-
-static int filter_frame(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return -1;
- }
-
- struct mp_audio* c = data; // Current working data
- af_sub_t* s = af->priv; // Setup for this instance
- float* a = c->planes[0]; // Audio data
- int len = c->samples*c->nch; // Number of samples in current audio block
- int nch = c->nch; // Number of channels
- int ch = s->ch; // Channel in which to insert the sub audio
- register int i;
-
- // Run filter
- for(i=0;i<len;i+=nch){
- // Average left and right
- register float x = 0.5 * (a[i] + a[i+1]);
- IIR(x * s->k, s->w[0], s->q[0], x);
- IIR(x , s->w[1], s->q[1], a[i+ch]);
- }
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-// Allocate memory and set function pointers
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = filter_frame;
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_sub_t
-const struct af_info af_info_sub = {
- .info = "Audio filter for adding a sub-base channel",
- .name = "sub",
- .flags = AF_FLAGS_NOT_REENTRANT,
- .open = af_open,
- .priv_size = sizeof(af_sub_t),
- .options = (const struct m_option[]) {
- OPT_FLOATRANGE("fc", fc, 0, 20, 300, OPTDEF_FLOAT(60.0)),
- OPT_INTRANGE("ch", ch, 0, 0, AF_NCH - 1, OPTDEF_INT(5)),
- {0}
- },
-};
diff --git a/audio/filter/af_surround.c b/audio/filter/af_surround.c
deleted file mode 100644
index fdbd396337..0000000000
--- a/audio/filter/af_surround.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Filter to do simple decoding of matrixed surround sound.
- * This will provide a (basic) surround-sound effect from
- * audio encoded for Dolby Surround, Pro Logic etc.
- *
- * Original author: Steve Davies <steve@daviesfam.org>
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* The principle: Make rear channels by extracting anti-phase data
- from the front channels, delay by 20ms and feed to rear in anti-phase
-*/
-
-
-/* SPLITREAR: Define to decode two distinct rear channels - this
- doesn't work so well in practice because separation in a passive
- matrix is not high. C (dialogue) to Ls and Rs 14dB or so - so
- dialogue leaks to the rear. Still - give it a try and send
- feedback. Comment this define for old behavior of a single
- surround sent to rear in anti-phase */
-#define SPLITREAR 1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "af.h"
-#include "dsp.h"
-
-#define L 32 // Length of fir filter
-#define LD 65536 // Length of delay buffer
-
-// 32 Tap fir filter loop unrolled
-#define FIR(x,w,y) \
- y = ( w[0] *x[0] +w[1] *x[1] +w[2] *x[2] +w[3] *x[3] \
- + w[4] *x[4] +w[5] *x[5] +w[6] *x[6] +w[7] *x[7] \
- + w[8] *x[8] +w[9] *x[9] +w[10]*x[10]+w[11]*x[11] \
- + w[12]*x[12]+w[13]*x[13]+w[14]*x[14]+w[15]*x[15] \
- + w[16]*x[16]+w[17]*x[17]+w[18]*x[18]+w[19]*x[19] \
- + w[20]*x[20]+w[21]*x[21]+w[22]*x[22]+w[23]*x[23] \
- + w[24]*x[24]+w[25]*x[25]+w[26]*x[26]+w[27]*x[27] \
- + w[28]*x[28]+w[29]*x[29]+w[30]*x[30]+w[31]*x[31])
-
-// Add to circular queue macro + update index
-#ifdef SPLITREAR
-#define ADDQUE(qi,rq,lq,r,l)\
- lq[qi]=lq[qi+L]=(l);\
- rq[qi]=rq[qi+L]=(r);\
- qi=(qi-1)&(L-1);
-#else
-#define ADDQUE(qi,lq,l)\
- lq[qi]=lq[qi+L]=(l);\
- qi=(qi-1)&(L-1);
-#endif
-
-// Macro for updating queue index in delay queues
-#define UPDATEQI(qi) qi=(qi+1)&(LD-1)
-
-// instance data
-typedef struct af_surround_s
-{
- float lq[2*L]; // Circular queue for filtering left rear channel
- float rq[2*L]; // Circular queue for filtering right rear channel
- float w[L]; // FIR filter coefficients for surround sound 7kHz low-pass
- float* dr; // Delay queue right rear channel
- float* dl; // Delay queue left rear channel
- float d; // Delay time
- int i; // Position in circular buffer
- int wi; // Write index for delay queue
- int ri; // Read index for delay queue
-}af_surround_t;
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- af_surround_t *s = af->priv;
- switch(cmd){
- case AF_CONTROL_REINIT:{
- struct mp_audio *in = arg;
- float fc;
- if (!mp_chmap_is_stereo(&in->channels)) {
- MP_ERR(af, "Only stereo input is supported.\n");
- return AF_DETACH;
- }
-
- mp_audio_set_format(in, AF_FORMAT_FLOAT);
- mp_audio_copy_config(af->data, in);
- mp_audio_set_channels_old(af->data, in->nch * 2);
-
- // Surround filer coefficients
- fc = 2.0 * 7000.0/(float)af->data->rate;
- if (-1 == af_filter_design_fir(L, s->w, &fc, LP|HAMMING, 0)){
- MP_ERR(af, "Unable to design low-pass filter.\n");
- return AF_ERROR;
- }
-
- // Free previous delay queues
- free(s->dl);
- free(s->dr);
- // Allocate new delay queues
- s->dl = calloc(LD,af->data->bps);
- s->dr = calloc(LD,af->data->bps);
- if((NULL == s->dl) || (NULL == s->dr))
- MP_FATAL(af, "Out of memory\n");
-
- // Initialize delay queue index
- if(AF_OK != af_from_ms(1, &s->d, &s->wi, af->data->rate, 0.0, 1000.0))
- return AF_ERROR;
-// printf("%i\n",s->wi);
- s->ri = 0;
-
- return AF_OK;
- }
- }
- return AF_UNKNOWN;
-}
-
-// The beginnings of an active matrix...
-static const float steering_matrix[][12] = {
-// LL RL LR RR LS RS
-// LLs RLs LRs RRs LC RC
- {.707, .0, .0, .707, .5, -.5,
- .5878, -.3928, .3928, -.5878, .5, .5},
-};
-
-// Experimental moving average dominance
-//static int amp_L = 0, amp_R = 0, amp_C = 0, amp_S = 0;
-
-static int filter_frame(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- struct mp_audio *outframe =
- mp_audio_pool_get(af->out_pool, &af->fmt_out, data->samples);
- if (!outframe) {
- talloc_free(data);
- return -1;
- }
- mp_audio_copy_attributes(outframe, data);
-
- af_surround_t* s = (af_surround_t*)af->priv;
- const float* m = steering_matrix[0];
- float* in = data->planes[0]; // Input audio data
- float* out = outframe->planes[0]; // Output audio data
- float* end = in + data->samples * data->nch;
- int i = s->i; // Filter queue index
- int ri = s->ri; // Read index for delay queue
- int wi = s->wi; // Write index for delay queue
-
- while(in < end){
- /* Dominance:
- abs(in[0]) abs(in[1]);
- abs(in[0]+in[1]) abs(in[0]-in[1]);
- 10 * log( abs(in[0]) / (abs(in[1])|1) );
- 10 * log( abs(in[0]+in[1]) / (abs(in[0]-in[1])|1) ); */
-
- /* About volume balancing...
- Surround encoding does the following:
- Lt=L+.707*C+.707*S, Rt=R+.707*C-.707*S
- So S should be extracted as:
- (Lt-Rt)
- But we are splitting the S to two output channels, so we
- must take 3dB off as we split it:
- Ls=Rs=.707*(Lt-Rt)
- Trouble is, Lt could be +1, Rt -1, so possibility that S will
- overflow. So to avoid that, we cut L/R by 3dB (*.707), and S by
- 6dB (/2). This keeps the overall balance, but guarantees no
- overflow. */
-
- // Output front left and right
- out[0] = m[0]*in[0] + m[1]*in[1];
- out[1] = m[2]*in[0] + m[3]*in[1];
-
- // Low-pass output @ 7kHz
- FIR((&s->lq[i]), s->w, s->dl[wi]);
-
- // Delay output by d ms
- out[2] = s->dl[ri];
-
-#ifdef SPLITREAR
- // Low-pass output @ 7kHz
- FIR((&s->rq[i]), s->w, s->dr[wi]);
-
- // Delay output by d ms
- out[3] = s->dr[ri];
-#else
- out[3] = -out[2];
-#endif
-
- // Update delay queues indexes
- UPDATEQI(ri);
- UPDATEQI(wi);
-
- // Calculate and save surround in circular queue
-#ifdef SPLITREAR
- ADDQUE(i, s->rq, s->lq, m[6]*in[0]+m[7]*in[1], m[8]*in[0]+m[9]*in[1]);
-#else
- ADDQUE(i, s->lq, m[4]*in[0]+m[5]*in[1]);
-#endif
-
- // Next sample...
- in = &in[data->nch];
- out = &out[af->data->nch];
- }
-
- // Save indexes
- s->i = i; s->ri = ri; s->wi = wi;
-
- talloc_free(data);
- af_add_output_frame(af, outframe);
- return 0;
-}
-
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = filter_frame;
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_surround_t
-const struct af_info af_info_surround =
-{
- .info = "Surround decoder filter",
- .name = "surround",
- .flags = AF_FLAGS_NOT_REENTRANT,
- .open = af_open,
- .priv_size = sizeof(af_surround_t),
- .options = (const struct m_option[]) {
- OPT_FLOATRANGE("d", d, 0, 0, 1000, OPTDEF_FLOAT(20.0)),
- {0}
- },
-};
diff --git a/audio/filter/af_sweep.c b/audio/filter/af_sweep.c
deleted file mode 100644
index 5f338638ed..0000000000
--- a/audio/filter/af_sweep.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <math.h>
-
-#include "config.h"
-#include "af.h"
-
-typedef struct af_sweep_s{
- double x;
- double delta;
-}af_sweept;
-
-
-// Initialization and runtime control
-static int control(struct af_instance* af, int cmd, void* arg)
-{
- struct mp_audio *data= (struct mp_audio*)arg;
-
- switch(cmd){
- case AF_CONTROL_REINIT:
- mp_audio_copy_config(af->data, data);
- mp_audio_set_format(af->data, AF_FORMAT_S16);
-
- return af_test_output(af, data);
- }
- return AF_UNKNOWN;
-}
-
-static int filter_frame(struct af_instance *af, struct mp_audio *data)
-{
- if (!data)
- return 0;
- if (af_make_writeable(af, data) < 0) {
- talloc_free(data);
- return 0;
- }
-
- af_sweept *s = af->priv;
- int i, j;
- int16_t *in = (int16_t*)data->planes[0];
- int chans = data->nch;
- int in_len = data->samples;
-
- for(i=0; i<in_len; i++){
- for(j=0; j<chans; j++)
- in[i*chans+j]= 32000*sin(s->x*s->x);
- s->x += s->delta;
- if(2*s->x*s->delta >= 3.141592) s->x=0;
- }
-
- af_add_output_frame(af, data);
- return 0;
-}
-
-static int af_open(struct af_instance* af){
- af->control=control;
- af->filter_frame = filter_frame;
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT af_sweept
-const struct af_info af_info_sweep = {
- .info = "sine sweep",
- .name = "sweep",
- .open = af_open,
- .priv_size = sizeof(af_sweept),
- .options = (const struct m_option[]) {
- OPT_DOUBLE("delta", delta, 0),
- {0}
- },
-};
diff --git a/audio/filter/dsp.h b/audio/filter/dsp.h
deleted file mode 100644
index 85fbb29564..0000000000
--- a/audio/filter/dsp.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2002 Anders Johansson ajh@atri.curtin.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MPLAYER_DSP_H
-#define MPLAYER_DSP_H
-
-/* Implementation of routines used for DSP */
-
-/* Size of floating point type used in routines */
-#define FLOAT_TYPE float
-
-#include "window.h"
-#include "filter.h"
-
-#endif /* MPLAYER_DSP_H */
diff --git a/audio/filter/filter.c b/audio/filter/filter.c
deleted file mode 100644
index 9a2107c715..0000000000
--- a/audio/filter/filter.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * design and implementation of different types of digital filters
- *
- * Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <string.h>
-#include <math.h>
-#include "dsp.h"
-
-/******************************************************************************
-* FIR filter implementations
-******************************************************************************/
-
-/* C implementation of FIR filter y=w*x
-
- n number of filter taps, where mod(n,4)==0
- w filter taps
- x input signal must be a circular buffer which is indexed backwards
-*/
-inline FLOAT_TYPE af_filter_fir(register unsigned int n, const FLOAT_TYPE* w,
- const FLOAT_TYPE* x)
-{
- register FLOAT_TYPE y; // Output
- y = 0.0;
- do{
- n--;
- y+=w[n]*x[n];
- }while(n != 0);
- return y;
-}
-
-/******************************************************************************
-* FIR filter design
-******************************************************************************/
-
-/* Design FIR filter using the Window method
-
- n filter length must be odd for HP and BS filters
- w buffer for the filter taps (must be n long)
- fc cutoff frequencies (1 for LP and HP, 2 for BP and BS)
- 0 < fc < 1 where 1 <=> Fs/2
- flags window and filter type as defined in filter.h
- variables are ored together: i.e. LP|HAMMING will give a
- low pass filter designed using a hamming window
- opt beta constant used only when designing using kaiser windows
-
- returns 0 if OK, -1 if fail
-*/
-int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
- unsigned int flags, FLOAT_TYPE opt)
-{
- unsigned int o = n & 1; // Indicator for odd filter length
- unsigned int end = ((n + 1) >> 1) - o; // Loop end
- unsigned int i; // Loop index
-
- FLOAT_TYPE k1 = 2 * M_PI; // 2*pi*fc1
- FLOAT_TYPE k2 = 0.5 * (FLOAT_TYPE)(1 - o);// Constant used if the filter has even length
- FLOAT_TYPE k3; // 2*pi*fc2 Constant used in BP and BS design
- FLOAT_TYPE g = 0.0; // Gain
- FLOAT_TYPE t1,t2,t3; // Temporary variables
- FLOAT_TYPE fc1,fc2; // Cutoff frequencies
-
- // Sanity check
- if(!w || (n == 0)) return -1;
-
- // Get window coefficients
- switch(flags & WINDOW_MASK){
- case(BOXCAR):
- af_window_boxcar(n,w); break;
- case(TRIANG):
- af_window_triang(n,w); break;
- case(HAMMING):
- af_window_hamming(n,w); break;
- case(HANNING):
- af_window_hanning(n,w); break;
- case(BLACKMAN):
- af_window_blackman(n,w); break;
- case(FLATTOP):
- af_window_flattop(n,w); break;
- case(KAISER):
- af_window_kaiser(n,w,opt); break;
- default:
- return -1;
- }
-
- if(flags & (LP | HP)){
- fc1=*fc;
- // Cutoff frequency must be < 0.5 where 0.5 <=> Fs/2
- fc1 = ((fc1 <= 1.0) && (fc1 > 0.0)) ? fc1/2 : 0.25;
- k1 *= fc1;
-
- if(flags & LP){ // Low pass filter
-
- // If the filter length is odd, there is one point which is exactly
- // in the middle. The value at this point is 2*fCutoff*sin(x)/x,
- // where x is zero. To make sure nothing strange happens, we set this
- // value separately.
- if (o){
- w[end] = fc1 * w[end] * 2.0;
- g=w[end];
- }
-
- // Create filter
- for (i=0 ; i<end ; i++){
- t1 = (FLOAT_TYPE)(i+1) - k2;
- w[end-i-1] = w[n-end+i] = w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
- g += 2*w[end-i-1]; // Total gain in filter
- }
- }
- else{ // High pass filter
- if (!o) // High pass filters must have odd length
- return -1;
- w[end] = 1.0 - (fc1 * w[end] * 2.0);
- g= w[end];
-
- // Create filter
- for (i=0 ; i<end ; i++){
- t1 = (FLOAT_TYPE)(i+1);
- w[end-i-1] = w[n-end+i] = -1 * w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
- g += ((i&1) ? (2*w[end-i-1]) : (-2*w[end-i-1])); // Total gain in filter
- }
- }
- }
-
- if(flags & (BP | BS)){
- fc1=fc[0];
- fc2=fc[1];
- // Cutoff frequencies must be < 1.0 where 1.0 <=> Fs/2
- fc1 = ((fc1 <= 1.0) && (fc1 > 0.0)) ? fc1/2 : 0.25;
- fc2 = ((fc2 <= 1.0) && (fc2 > 0.0)) ? fc2/2 : 0.25;
- k3 = k1 * fc2; // 2*pi*fc2
- k1 *= fc1; // 2*pi*fc1
-
- if(flags & BP){ // Band pass
- // Calculate center tap
- if (o){
- g=w[end]*(fc1+fc2);
- w[end] = (fc2 - fc1) * w[end] * 2.0;
- }
-
- // Create filter
- for (i=0 ; i<end ; i++){
- t1 = (FLOAT_TYPE)(i+1) - k2;
- t2 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
- t3 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
- g += w[end-i-1] * (t3 + t2); // Total gain in filter
- w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
- }
- }
- else{ // Band stop
- if (!o) // Band stop filters must have odd length
- return -1;
- w[end] = 1.0 - (fc2 - fc1) * w[end] * 2.0;
- g= w[end];
-
- // Create filter
- for (i=0 ; i<end ; i++){
- t1 = (FLOAT_TYPE)(i+1);
- t2 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
- t3 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
- w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3);
- g += 2*w[end-i-1]; // Total gain in filter
- }
- }
- }
-
- // Normalize gain
- g=1/g;
- for (i=0; i<n; i++)
- w[i] *= g;
-
- return 0;
-}
-
-/******************************************************************************
-* IIR filter design
-******************************************************************************/
-
-/* Helper functions for the bilinear transform */
-
-/* Pre-warp the coefficients of a numerator or denominator.
- Note that a0 is assumed to be 1, so there is no wrapping
- of it.
-*/
-static void af_filter_prewarp(FLOAT_TYPE* a, FLOAT_TYPE fc, FLOAT_TYPE fs)
-{
- FLOAT_TYPE wp;
- wp = 2.0 * fs * tan(M_PI * fc / fs);
- a[2] = a[2]/(wp * wp);
- a[1] = a[1]/wp;
-}
-
-/* Transform the numerator and denominator coefficients of s-domain
- biquad section into corresponding z-domain coefficients.
-
- The transfer function for z-domain is:
-
- 1 + alpha1 * z^(-1) + alpha2 * z^(-2)
- H(z) = -------------------------------------
- 1 + beta1 * z^(-1) + beta2 * z^(-2)
-
- Store the 4 IIR coefficients in array pointed by coef in following
- order:
- beta1, beta2 (denominator)
- alpha1, alpha2 (numerator)
-
- Arguments:
- a - s-domain numerator coefficients
- b - s-domain denominator coefficients
- k - filter gain factor. Initially set to 1 and modified by each
- biquad section in such a way, as to make it the
- coefficient by which to multiply the overall filter gain
- in order to achieve a desired overall filter gain,
- specified in initial value of k.
- fs - sampling rate (Hz)
- coef - array of z-domain coefficients to be filled in.
-
- Return: On return, set coef z-domain coefficients and k to the gain
- required to maintain overall gain = 1.0;
-*/
-static void af_filter_bilinear(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE* k,
- FLOAT_TYPE fs, FLOAT_TYPE *coef)
-{
- FLOAT_TYPE ad, bd;
-
- /* alpha (Numerator in s-domain) */
- ad = 4. * a[2] * fs * fs + 2. * a[1] * fs + a[0];
- /* beta (Denominator in s-domain) */
- bd = 4. * b[2] * fs * fs + 2. * b[1] * fs + b[0];
-
- /* Update gain constant for this section */
- *k *= ad/bd;
-
- /* Denominator */
- *coef++ = (2. * b[0] - 8. * b[2] * fs * fs)/bd; /* beta1 */
- *coef++ = (4. * b[2] * fs * fs - 2. * b[1] * fs + b[0])/bd; /* beta2 */
-
- /* Numerator */
- *coef++ = (2. * a[0] - 8. * a[2] * fs * fs)/ad; /* alpha1 */
- *coef = (4. * a[2] * fs * fs - 2. * a[1] * fs + a[0])/ad; /* alpha2 */
-}
-
-
-
-/* IIR filter design using bilinear transform and prewarp. Transforms
- 2nd order s domain analog filter into a digital IIR biquad link. To
- create a filter fill in a, b, Q and fs and make space for coef and k.
-
-
- Example Butterworth design:
-
- Below are Butterworth polynomials, arranged as a series of 2nd
- order sections:
-
- Note: n is filter order.
-
- n Polynomials
- -------------------------------------------------------------------
- 2 s^2 + 1.4142s + 1
- 4 (s^2 + 0.765367s + 1) * (s^2 + 1.847759s + 1)
- 6 (s^2 + 0.5176387s + 1) * (s^2 + 1.414214 + 1) * (s^2 + 1.931852s + 1)
-
- For n=4 we have following equation for the filter transfer function:
- 1 1
- T(s) = --------------------------- * ----------------------------
- s^2 + (1/Q) * 0.765367s + 1 s^2 + (1/Q) * 1.847759s + 1
-
- The filter consists of two 2nd order sections since highest s power
- is 2. Now we can take the coefficients, or the numbers by which s
- is multiplied and plug them into a standard formula to be used by
- bilinear transform.
-
- Our standard form for each 2nd order section is:
-
- a2 * s^2 + a1 * s + a0
- H(s) = ----------------------
- b2 * s^2 + b1 * s + b0
-
- Note that Butterworth numerator is 1 for all filter sections, which
- means s^2 = 0 and s^1 = 0
-
- Let's convert standard Butterworth polynomials into this form:
-
- 0 + 0 + 1 0 + 0 + 1
- --------------------------- * --------------------------
- 1 + ((1/Q) * 0.765367) + 1 1 + ((1/Q) * 1.847759) + 1
-
- Section 1:
- a2 = 0; a1 = 0; a0 = 1;
- b2 = 1; b1 = 0.765367; b0 = 1;
-
- Section 2:
- a2 = 0; a1 = 0; a0 = 1;
- b2 = 1; b1 = 1.847759; b0 = 1;
-
- Q is filter quality factor or resonance, in the range of 1 to
- 1000. The overall filter Q is a product of all 2nd order stages.
- For example, the 6th order filter (3 stages, or biquads) with
- individual Q of 2 will have filter Q = 2 * 2 * 2 = 8.
-
-
- Arguments:
- a - s-domain numerator coefficients, a[1] is always assumed to be 1.0
- b - s-domain denominator coefficients
- Q - Q value for the filter
- k - filter gain factor. Initially set to 1 and modified by each
- biquad section in such a way, as to make it the
- coefficient by which to multiply the overall filter gain
- in order to achieve a desired overall filter gain,
- specified in initial value of k.
- fs - sampling rate (Hz)
- coef - array of z-domain coefficients to be filled in.
-
- Note: Upon return from each call, the k argument will be set to a
- value, by which to multiply our actual signal in order for the gain
- to be one. On second call to szxform() we provide k that was
- changed by the previous section. During actual audio filtering
- k can be used for gain compensation.
-
- return -1 if fail 0 if success.
-*/
-int af_filter_szxform(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE Q, FLOAT_TYPE fc,
- FLOAT_TYPE fs, FLOAT_TYPE *k, FLOAT_TYPE *coef)
-{
- FLOAT_TYPE at[3];
- FLOAT_TYPE bt[3];
-
- if(!a || !b || !k || !coef || (Q>1000.0 || Q< 1.0))
- return -1;
-
- memcpy(at,a,3*sizeof(FLOAT_TYPE));
- memcpy(bt,b,3*sizeof(FLOAT_TYPE));
-
- bt[1]/=Q;
-
- /* Calculate a and b and overwrite the original values */
- af_filter_prewarp(at, fc, fs);
- af_filter_prewarp(bt, fc, fs);
- /* Execute bilinear transform */
- af_filter_bilinear(at, bt, k, fs, coef);
-
- return 0;
-}
diff --git a/audio/filter/filter.h b/audio/filter/filter.h
deleted file mode 100644
index 8a1864a940..0000000000
--- a/audio/filter/filter.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#if !defined MPLAYER_DSP_H
-# error Never use filter.h directly; include dsp.h instead.
-#endif
-
-#ifndef MPLAYER_FILTER_H
-#define MPLAYER_FILTER_H
-
-
-// Design and implementation of different types of digital filters
-
-
-// Flags used for filter design
-
-// Filter characteristics
-#define LP 0x00010000 // Low pass
-#define HP 0x00020000 // High pass
-#define BP 0x00040000 // Band pass
-#define BS 0x00080000 // Band stop
-#define TYPE_MASK 0x000F0000
-
-// Window types
-#define BOXCAR 0x00000001
-#define TRIANG 0x00000002
-#define HAMMING 0x00000004
-#define HANNING 0x00000008
-#define BLACKMAN 0x00000010
-#define FLATTOP 0x00000011
-#define KAISER 0x00000012
-#define WINDOW_MASK 0x0000001F
-
-// Parallel filter design
-#define FWD 0x00000001 // Forward indexing of polyphase filter
-#define REW 0x00000002 // Reverse indexing of polyphase filter
-#define ODD 0x00000010 // Make filter HP
-
-// Exported functions
-FLOAT_TYPE af_filter_fir(unsigned int n, const FLOAT_TYPE* w, const FLOAT_TYPE* x);
-
-int af_filter_design_fir(unsigned int n, FLOAT_TYPE* w, const FLOAT_TYPE* fc,
- unsigned int flags, FLOAT_TYPE opt);
-
-int af_filter_szxform(const FLOAT_TYPE* a, const FLOAT_TYPE* b, FLOAT_TYPE Q,
- FLOAT_TYPE fc, FLOAT_TYPE fs, FLOAT_TYPE *k,
- FLOAT_TYPE *coef);
-
-/* Add new data to circular queue designed to be used with a FIR
- filter. xq is the circular queue, in pointing at the new sample, xi
- current index for xq and n the length of the filter. xq must be n*2
- long.
-*/
-#define af_filter_updateq(n,xi,xq,in)\
- xq[xi]=(xq)[(xi)+(n)]=*(in);\
- xi=(++(xi))&((n)-1);
-
-#endif /* MPLAYER_FILTER_H */
diff --git a/audio/filter/window.c b/audio/filter/window.c
deleted file mode 100644
index 3cc8fe4b1b..0000000000
--- a/audio/filter/window.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* Calculates a number of window functions. The following window
- functions are currently implemented: Boxcar, Triang, Hanning,
- Hamming, Blackman, Flattop and Kaiser. In the function call n is
- the number of filter taps and w the buffer in which the filter
- coefficients will be stored.
-*/
-
-#include <math.h>
-#include "dsp.h"
-
-/*
-// Boxcar
-//
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_boxcar(int n, FLOAT_TYPE* w)
-{
- int i;
- // Calculate window coefficients
- for (i=0 ; i<n ; i++)
- w[i] = 1.0;
-}
-
-
-/*
-// Triang a.k.a Bartlett
-//
-// | (N-1)|
-// 2 * |k - -----|
-// | 2 |
-// w = 1.0 - ---------------
-// N+1
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_triang(int n, FLOAT_TYPE* w)
-{
- FLOAT_TYPE k1 = (FLOAT_TYPE)(n & 1);
- FLOAT_TYPE k2 = 1/((FLOAT_TYPE)n + k1);
- int end = (n + 1) >> 1;
- int i;
-
- // Calculate window coefficients
- for (i=0 ; i<end ; i++)
- w[i] = w[n-i-1] = (2.0*((FLOAT_TYPE)(i+1))-(1.0-k1))*k2;
-}
-
-
-/*
-// Hanning
-// 2*pi*k
-// w = 0.5 - 0.5*cos(------), where 0 < k <= N
-// N+1
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_hanning(int n, FLOAT_TYPE* w)
-{
- int i;
- FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n+1)); // 2*pi/(N+1)
-
- // Calculate window coefficients
- for (i=0; i<n; i++)
- *w++ = 0.5*(1.0 - cos(k*(FLOAT_TYPE)(i+1)));
-}
-
-/*
-// Hamming
-// 2*pi*k
-// w(k) = 0.54 - 0.46*cos(------), where 0 <= k < N
-// N-1
-//
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_hamming(int n,FLOAT_TYPE* w)
-{
- int i;
- FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
-
- // Calculate window coefficients
- for (i=0; i<n; i++)
- *w++ = 0.54 - 0.46*cos(k*(FLOAT_TYPE)i);
-}
-
-/*
-// Blackman
-// 2*pi*k 4*pi*k
-// w(k) = 0.42 - 0.5*cos(------) + 0.08*cos(------), where 0 <= k < N
-// N-1 N-1
-//
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_blackman(int n,FLOAT_TYPE* w)
-{
- int i;
- FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
- FLOAT_TYPE k2 = 2*k1; // 4*pi/(N-1)
-
- // Calculate window coefficients
- for (i=0; i<n; i++)
- *w++ = 0.42 - 0.50*cos(k1*(FLOAT_TYPE)i) + 0.08*cos(k2*(FLOAT_TYPE)i);
-}
-
-/*
-// Flattop
-// 2*pi*k 4*pi*k
-// w(k) = 0.2810638602 - 0.5208971735*cos(------) + 0.1980389663*cos(------), where 0 <= k < N
-// N-1 N-1
-//
-// n window length
-// w buffer for the window parameters
-*/
-void af_window_flattop(int n,FLOAT_TYPE* w)
-{
- int i;
- FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
- FLOAT_TYPE k2 = 2*k1; // 4*pi/(N-1)
-
- // Calculate window coefficients
- for (i=0; i<n; i++)
- *w++ = 0.2810638602 - 0.5208971735*cos(k1*(FLOAT_TYPE)i)
- + 0.1980389663*cos(k2*(FLOAT_TYPE)i);
-}
-
-/* Computes the 0th order modified Bessel function of the first kind.
-// (Needed to compute Kaiser window)
-//
-// y = sum( (x/(2*n))^2 )
-// n
-*/
-#define BIZ_EPSILON 1E-21 // Max error acceptable
-
-static FLOAT_TYPE besselizero(FLOAT_TYPE x)
-{
- FLOAT_TYPE temp;
- FLOAT_TYPE sum = 1.0;
- FLOAT_TYPE u = 1.0;
- FLOAT_TYPE halfx = x/2.0;
- int n = 1;
-
- do {
- temp = halfx/(FLOAT_TYPE)n;
- u *=temp * temp;
- sum += u;
- n++;
- } while (u >= BIZ_EPSILON * sum);
- return sum;
-}
-
-/*
-// Kaiser
-//
-// n window length
-// w buffer for the window parameters
-// b beta parameter of Kaiser window, Beta >= 1
-//
-// Beta trades the rejection of the low pass filter against the
-// transition width from passband to stop band. Larger Beta means a
-// slower transition and greater stop band rejection. See Rabiner and
-// Gold (Theory and Application of DSP) under Kaiser windows for more
-// about Beta. The following table from Rabiner and Gold gives some
-// feel for the effect of Beta:
-//
-// All ripples in dB, width of transition band = D*N where N = window
-// length
-//
-// BETA D PB RIP SB RIP
-// 2.120 1.50 +-0.27 -30
-// 3.384 2.23 0.0864 -40
-// 4.538 2.93 0.0274 -50
-// 5.658 3.62 0.00868 -60
-// 6.764 4.32 0.00275 -70
-// 7.865 5.0 0.000868 -80
-// 8.960 5.7 0.000275 -90
-// 10.056 6.4 0.000087 -100
-*/
-void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b)
-{
- FLOAT_TYPE tmp;
- FLOAT_TYPE k1 = 1.0/besselizero(b);
- int k2 = 1 - (n & 1);
- int end = (n + 1) >> 1;
- int i;
-
- // Calculate window coefficients
- for (i=0 ; i<end ; i++){
- tmp = (FLOAT_TYPE)(2*i + k2) / ((FLOAT_TYPE)n - 1.0);
- w[end-(1&(!k2))+i] = w[end-1-i] = k1 * besselizero(b*sqrt(1.0 - tmp*tmp));
- }
-}
diff --git a/audio/filter/window.h b/audio/filter/window.h
deleted file mode 100644
index 0187423053..0000000000
--- a/audio/filter/window.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2001 Anders Johansson ajh@atri.curtin.edu.au
- *
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* Calculates a number of window functions. The following window
- functions are currently implemented: Boxcar, Triang, Hanning,
- Hamming, Blackman, Flattop and Kaiser. In the function call n is
- the number of filter taps and w the buffer in which the filter
- coefficients will be stored.
-*/
-
-#if !defined MPLAYER_DSP_H
-# error Never use window.h directly; include dsp.h instead.
-#endif
-
-#ifndef MPLAYER_WINDOW_H
-#define MPLAYER_WINDOW_H
-
-void af_window_boxcar(int n, FLOAT_TYPE* w);
-void af_window_triang(int n, FLOAT_TYPE* w);
-void af_window_hanning(int n, FLOAT_TYPE* w);
-void af_window_hamming(int n, FLOAT_TYPE* w);
-void af_window_blackman(int n, FLOAT_TYPE* w);
-void af_window_flattop(int n, FLOAT_TYPE* w);
-void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b);
-
-#endif /* MPLAYER_WINDOW_H */
diff --git a/wscript b/wscript
index 13b13a2ac5..2fecdebb59 100644
--- a/wscript
+++ b/wscript
@@ -348,10 +348,6 @@ iconv support use --disable-iconv.",
'deps': [ 'iconv' ],
'func': check_pkg_config('uchardet'),
}, {
- 'name': '--ladspa',
- 'desc': 'LADSPA plugin support',
- 'func': check_statement('ladspa.h', 'LADSPA_Descriptor ld = {0}'),
- }, {
'name': '--rubberband',
'desc': 'librubberband support',
'func': check_pkg_config('rubberband', '>= 1.8.0'),
diff --git a/wscript_build.py b/wscript_build.py
index f306740e37..a7ddc26e31 100644
--- a/wscript_build.py
+++ b/wscript_build.py
@@ -101,31 +101,19 @@ def build(ctx):
( "audio/decode/dec_audio.c" ),
( "audio/filter/af.c" ),
( "audio/filter/af_bs2b.c", "libbs2b" ),
- ( "audio/filter/af_center.c" ),
( "audio/filter/af_channels.c" ),
( "audio/filter/af_delay.c" ),
( "audio/filter/af_drc.c" ),
( "audio/filter/af_equalizer.c" ),
- ( "audio/filter/af_export.c" ),
- ( "audio/filter/af_extrastereo.c" ),
( "audio/filter/af_format.c" ),
- ( "audio/filter/af_hrtf.c" ),
- ( "audio/filter/af_karaoke.c" ),
- ( "audio/filter/af_ladspa.c", "ladspa" ),
( "audio/filter/af_lavcac3enc.c" ),
( "audio/filter/af_lavfi.c", "libavfilter" ),
( "audio/filter/af_lavrresample.c" ),
( "audio/filter/af_pan.c" ),
( "audio/filter/af_rubberband.c", "rubberband" ),
( "audio/filter/af_scaletempo.c" ),
- ( "audio/filter/af_sinesuppress.c" ),
- ( "audio/filter/af_sub.c" ),
- ( "audio/filter/af_surround.c" ),
- ( "audio/filter/af_sweep.c" ),
( "audio/filter/af_volume.c" ),
- ( "audio/filter/filter.c" ),
( "audio/filter/tools.c" ),
- ( "audio/filter/window.c" ),
( "audio/out/ao.c" ),
( "audio/out/ao_alsa.c", "alsa" ),
( "audio/out/ao_coreaudio.c", "coreaudio" ),