summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af.c53
-rw-r--r--audio/filter/af.h21
-rw-r--r--audio/filter/af_bs2b.c168
-rw-r--r--audio/filter/af_center.c104
-rw-r--r--audio/filter/af_drc.c1
-rw-r--r--audio/filter/af_equalizer.c1
-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_lavfi.c23
-rw-r--r--audio/filter/af_lavrresample.c73
-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/af_volume.c1
-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
24 files changed, 82 insertions, 4170 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 6a5b1f42a5..62ba6a9665 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,28 +52,13 @@ 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,
-#endif
#if HAVE_LIBAVFILTER
&af_info_lavfi,
#endif
@@ -185,24 +159,11 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
MP_ERR(s, "Couldn't find audio filter '%s'.\n", name);
return NULL;
}
- const struct af_info *info = desc.p;
- /* Make sure that the filter is not already in the list if it is
- non-reentrant */
- if (info->flags & AF_FLAGS_NOT_REENTRANT) {
- for (struct af_instance *cur = s->first; cur; cur = cur->next) {
- if (cur->info == info) {
- MP_ERR(s, "There can only be one "
- "instance of the filter '%s' in each stream\n", name);
- return NULL;
- }
- }
- }
-
MP_VERBOSE(s, "Adding filter %s \n", name);
struct af_instance *af = talloc_zero(NULL, struct af_instance);
*af = (struct af_instance) {
- .info = info,
+ .info = desc.p,
.data = talloc_zero(af, struct mp_audio),
.log = mp_log_new(af, s->log, name),
.replaygain_data = s->replaygain_data,
@@ -721,6 +682,18 @@ void af_control_all(struct af_stream *s, int cmd, void *arg)
af->control(af, cmd, arg);
}
+int af_control_by_label(struct af_stream *s, int cmd, void *arg, bstr label)
+{
+ char *label_str = bstrdup0(NULL, label);
+ struct af_instance *cur = af_find_by_label(s, label_str);
+ talloc_free(label_str);
+ if (cur) {
+ return cur->control ? cur->control(cur, cmd, arg) : CONTROL_NA;
+ } else {
+ return CONTROL_UNKNOWN;
+ }
+}
+
// Used by filters to add a filtered frame to the output queue.
// Ownership of frame is transferred from caller to the filter chain.
void af_add_output_frame(struct af_instance *af, struct mp_audio *frame)
diff --git a/audio/filter/af.h b/audio/filter/af.h
index 88cbbc0119..ba64379661 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -27,6 +27,7 @@
#include "audio/chmap.h"
#include "audio/audio.h"
#include "common/msg.h"
+#include "common/common.h"
struct af_instance;
struct mpv_global;
@@ -34,10 +35,6 @@ struct mpv_global;
// Number of channels
#define AF_NCH MP_NUM_CHANNELS
-// Flags used for defining the behavior of an audio filter
-#define AF_FLAGS_REENTRANT 0x00000000
-#define AF_FLAGS_NOT_REENTRANT 0x00000001
-
// Flags for af->filter()
#define AF_FILTER_FLAG_EOF 1
@@ -46,7 +43,6 @@ struct mpv_global;
struct af_info {
const char *info;
const char *name;
- const int flags;
int (*open)(struct af_instance *vf);
int priv_size;
const void *priv_defaults;
@@ -104,13 +100,12 @@ struct af_stream {
};
// Return values
-#define AF_DETACH 2
-#define AF_OK 1
-#define AF_TRUE 1
-#define AF_FALSE 0
-#define AF_UNKNOWN -1
-#define AF_ERROR -2
-#define AF_FATAL -3
+#define AF_DETACH (CONTROL_OK + 1)
+#define AF_OK CONTROL_OK
+#define AF_TRUE CONTROL_TRUE
+#define AF_FALSE CONTROL_FALSE
+#define AF_UNKNOWN CONTROL_UNKNOWN
+#define AF_ERROR CONTROL_ERROR
// Parameters for af_control_*
enum af_control {
@@ -127,6 +122,7 @@ enum af_control {
AF_CONTROL_GET_PAN_BALANCE,
AF_CONTROL_SET_PLAYBACK_SPEED,
AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE,
+ AF_CONTROL_GET_METADATA,
};
// Argument for AF_CONTROL_SET_PAN_LEVEL
@@ -145,6 +141,7 @@ int af_remove_by_label(struct af_stream *s, char *label);
struct af_instance *af_find_by_label(struct af_stream *s, char *label);
struct af_instance *af_control_any_rev(struct af_stream *s, int cmd, void *arg);
void af_control_all(struct af_stream *s, int cmd, void *arg);
+int af_control_by_label(struct af_stream *s, int cmd, void *arg, bstr label);
void af_seek_reset(struct af_stream *s);
void af_add_output_frame(struct af_instance *af, struct mp_audio *frame);
diff --git a/audio/filter/af_bs2b.c b/audio/filter/af_bs2b.c
deleted file mode 100644
index beb4dc9b96..0000000000
--- a/audio/filter/af_bs2b.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * The Bauer stereophonic-to-binaural DSP using bs2b library:
- * http://bs2b.sourceforge.net/
- *
- * Copyright (c) 2009 Andrew Savchenko
- *
- * 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 <bs2b.h>
-#include <inttypes.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "af.h"
-#include "options/m_option.h"
-
-/// Internal specific data of the filter
-struct af_bs2b {
- int fcut; ///< cut frequency in Hz
- int feed; ///< feed level for low frequencies in 0.1*dB
- int profile ; ///< profile (available crossfeed presets)
- t_bs2bdp filter; ///< instance of a library filter
-};
-
-#define DEF_FILTER(fmt, name) \
-static int filter_##name(struct af_instance *af, struct mp_audio *data) \
-{ \
- if (!data) \
- return 0; \
- if (af_make_writeable(af, data) < 0) { \
- talloc_free(data); \
- return -1; \
- } \
- bs2b_cross_feed_##name(((struct af_bs2b*)(af->priv))->filter, \
- (data->planes[0]), data->samples); \
- af_add_output_frame(af, data); \
- return 0; \
-}
-
-#define GET_FILTER(fmt, name) \
- case AF_FORMAT_##fmt: return filter_##name;
-
-#define FILTERS \
- FILTER(FLOAT, f) \
- FILTER(S32, s32) \
- FILTER(S24, s24) \
- FILTER(S16, s16) \
- FILTER(U8, u8)
-
-#define FILTER DEF_FILTER
-FILTERS
-#undef FILTER
-
-typedef int (*filter)(struct af_instance *af, struct mp_audio *d);
-static filter get_filter(int fmt)
-{
- switch (fmt) {
-#define FILTER GET_FILTER
-FILTERS
-#undef FILTER
- default: return NULL;
- }
-}
-
-/// Initialization and runtime control
-static int control(struct af_instance *af, int cmd, void *arg)
-{
- struct af_bs2b *s = af->priv;
-
- switch (cmd) {
- case AF_CONTROL_REINIT: {
- int format;
- // Sanity check
- if (!arg) return AF_ERROR;
-
- format = ((struct mp_audio*)arg)->format;
- af->data->rate = ((struct mp_audio*)arg)->rate;
- mp_audio_set_num_channels(af->data, 2); // bs2b is useful only for 2ch audio
- mp_audio_set_format(af->data, format);
-
- /* check for formats supported by libbs2b
- and assign corresponding handlers */
- af->filter_frame = get_filter(format);
- if (!af->filter_frame) {
- af->filter_frame = filter_f;
- mp_audio_set_format(af->data, AF_FORMAT_FLOAT);
- }
-
- // bs2b have srate limits, try to resample if needed
- if (af->data->rate > BS2B_MAXSRATE || af->data->rate < BS2B_MINSRATE) {
- af->data->rate = BS2B_DEFAULT_SRATE;
- MP_WARN(af, "Requested sample rate %d Hz is out of bounds [%d..%d] Hz.\n"
- "Trying to resample to %d Hz.\n",
- af->data->rate, BS2B_MINSRATE, BS2B_MAXSRATE, BS2B_DEFAULT_SRATE);
- }
- bs2b_set_srate(s->filter, (long)af->data->rate);
- MP_VERBOSE(af, "using format %s\n",
- af_fmt_to_str(af->data->format));
-
- return af_test_output(af,(struct mp_audio*)arg);
- }
- }
- return AF_UNKNOWN;
-}
-
-/// Deallocate memory and close library
-static void uninit(struct af_instance *af)
-{
- struct af_bs2b *s = af->priv;
- if (s->filter)
- bs2b_close(s->filter);
-}
-
-/// Allocate memory, set function pointers and init library
-static int af_open(struct af_instance *af)
-{
- struct af_bs2b *s = af->priv;
- af->control = control;
- af->uninit = uninit;
-
- // NULL means failed initialization
- if (!(s->filter = bs2b_open())) {
- return AF_ERROR;
- }
-
- if (s->profile)
- bs2b_set_level(s->filter, s->profile);
- // set fcut and feed only if specified, otherwise defaults will be used
- if (s->fcut)
- bs2b_set_level_fcut(s->filter, s->fcut);
- if (s->feed)
- bs2b_set_level_feed(s->filter, s->feed);
- return AF_OK;
-}
-
-#define OPT_BASE_STRUCT struct af_bs2b
-
-/// Description of this filter
-const struct af_info af_info_bs2b = {
- .info = "Bauer stereophonic-to-binaural audio filter",
- .name = "bs2b",
- .open = af_open,
- .priv_size = sizeof(struct af_bs2b),
- .options = (const struct m_option[]) {
- OPT_INTRANGE("fcut", fcut, 0, BS2B_MINFCUT, BS2B_MAXFCUT),
- OPT_INTRANGE("feed", feed, 0, BS2B_MINFEED, BS2B_MAXFEED),
- OPT_CHOICE("profile", profile, 0,
- ({"unset", 0},
- {"default", BS2B_DEFAULT_CLEVEL},
- {"cmoy", BS2B_CMOY_CLEVEL},
- {"jmeier", BS2B_JMEIER_CLEVEL})),
- {0}
- },
-};
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_drc.c b/audio/filter/af_drc.c
index 472758c4c7..7b375febf4 100644
--- a/audio/filter/af_drc.c
+++ b/audio/filter/af_drc.c
@@ -324,7 +324,6 @@ static int af_open(struct af_instance* af){
const struct af_info af_info_drc = {
.info = "Dynamic range compression filter",
.name = "drc",
- .flags = AF_FLAGS_NOT_REENTRANT,
.open = af_open,
.priv_size = sizeof(af_drc_t),
.options = (const struct m_option[]) {
diff --git a/audio/filter/af_equalizer.c b/audio/filter/af_equalizer.c
index 781239c02a..cb4ecb2675 100644
--- a/audio/filter/af_equalizer.c
+++ b/audio/filter/af_equalizer.c
@@ -203,7 +203,6 @@ static int af_open(struct af_instance* af){
const struct af_info af_info_equalizer = {
.info = "Equalizer audio filter",
.name = "equalizer",
- .flags = AF_FLAGS_NOT_REENTRANT,
.open = af_open,
.priv_size = sizeof(af_equalizer_t),
.options = (const struct m_option[]) {
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>
-