summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-09-03 23:55:36 +0200
committerwm4 <wm4@nowhere>2015-09-03 23:55:36 +0200
commit091bfa3abf2f28b37fa12cca6b4c248c31d27965 (patch)
treef5406c1b373ed91a914712e3c0d25076449df123
parente1fbd3b790b5fe1ae6efc1dd0477c2da88a5b8dc (diff)
downloadmpv-091bfa3abf2f28b37fa12cca6b4c248c31d27965.tar.bz2
mpv-091bfa3abf2f28b37fa12cca6b4c248c31d27965.tar.xz
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 functio