summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-11-29 21:30:10 +0100
committerwm4 <wm4@nowhere>2017-11-29 21:30:51 +0100
commitd725630b5f5817287d44cb31c3c7b9d815c187db (patch)
tree6c54b58b8bb3a4bfc25e0eafb253266a3a10f766 /audio/filter
parent9c909fbb4d4abeabe9ac6731cb0c3f966dacf0ff (diff)
downloadmpv-d725630b5f5817287d44cb31c3c7b9d815c187db.tar.bz2
mpv-d725630b5f5817287d44cb31c3c7b9d815c187db.tar.xz
audio: add audio softvol processing to AO
This does what af_volume used to do. Since we couldn't relicense it, just rewrite it. Since we don't have a new filter mechanism yet, and the libavfilter is too inconvenient, do applying the volume gain in ao.c directly. This is done before handling the audio data to the driver. Since push.c runs a separate thread, and pull.c is called asynchronously from the audio driver's thread, the volume value needs to be synchronized. There's no existing central mutex, so do some shit with atomics. Since there's no atomic_float type predefined (which is at least needed when using the legacy wrapper), do some nonsense about reinterpret casting the float value to an int for the purpose of atomic access. Not sure if using memcpy() is undefined behavior, but for now I don't care. The advantage of not using a filter is lower complexity (no filter auto insertion), and lower latency (gain processing is done after our internal audio buffer of at least 200ms). Disavdantages include inability to use native volume control _before_ other filters with custom filter chains, and the need to add new processing for each new sample type. Since this doesn't reuse any of the old GPL code, nor does indirectly rely on it, volume and replaygain handling now works in LGPL mode. How to process the gain is inspired by libavfilter's af_volume (LGPL). In particular, we use exactly the same rounding, and we quantize processing for integer sample types by 256 steps. Some of libavfilter's copyright may or may not apply, but I think not, and it's the same license anyway.
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af.c1
-rw-r--r--audio/filter/af.h2
2 files changed, 0 insertions, 3 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c
index dd78bb0cb5..5838c2e70b 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -167,7 +167,6 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
.log = mp_log_new(af, s->log, name),
.opts = s->opts,
.global = s->global,
- .replaygain_data = s->replaygain_data,
.out_pool = mp_audio_pool_create(af),
};
struct m_config *config =
diff --git a/audio/filter/af.h b/audio/filter/af.h
index 58f67727a2..f27edee71a 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -61,7 +61,6 @@ struct af_instance {
struct mp_log *log;
struct MPOpts *opts;
struct mpv_global *global;
- struct replaygain_data *replaygain_data;
int (*control)(struct af_instance *af, int cmd, void *arg);
void (*uninit)(struct af_instance *af);
/* Feed a frame. The frame is NULL if EOF was reached, and the filter
@@ -105,7 +104,6 @@ struct af_stream {
struct mp_log *log;
struct MPOpts *opts;
struct mpv_global *global;
- struct replaygain_data *replaygain_data;
};
// Return values