summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_lavrresample.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-12 04:02:55 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-13 03:26:45 -0800
commit6d4b4c0de3152bc2deb2df09ec3e98e032124593 (patch)
treee257216a98e0a40610dc90e6e526152ea7f63833 /audio/filter/af_lavrresample.c
parent23edaf4412e378dabf061b6e852f7314b38b8020 (diff)
downloadmpv-6d4b4c0de3152bc2deb2df09ec3e98e032124593.tar.bz2
mpv-6d4b4c0de3152bc2deb2df09ec3e98e032124593.tar.xz
audio: add global options for resampler defaults
This is part of trying to get rid of --af-defaults, and the af resample filter. It requires a complicated mechanism to set the defaults on the resample filter for backwards compatibility.
Diffstat (limited to 'audio/filter/af_lavrresample.c')
-rw-r--r--audio/filter/af_lavrresample.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index 55eb6b0f20..96387060b1 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -32,6 +32,7 @@
#include "common/av_common.h"
#include "common/msg.h"
+#include "options/m_config.h"
#include "options/m_option.h"
#include "audio/filter/af.h"
#include "audio/fmt-conversion.h"
@@ -42,6 +43,7 @@ struct af_resample {
int allow_detach;
double playback_speed;
struct mp_resample_opts opts;
+ int global_normalize;
struct mp_aconverter *converter;
};
@@ -142,11 +144,34 @@ static int af_open(struct af_instance *af)
af->filter_frame = filter;
af->filter_out = filter_out;
+ if (s->opts.normalize < 0)
+ s->opts.normalize = s->global_normalize;
+
s->converter = mp_aconverter_create(af->global, af->log, &s->opts);
return AF_OK;
}
+static void set_defaults(struct mpv_global *global, void *p)
+{
+ struct af_resample *s = p;
+
+ struct mp_resample_opts *opts = &s->opts;
+
+ struct mp_resample_opts *src_opts =
+ mp_get_config_group(s, global, &resample_config);
+
+ s->global_normalize = src_opts->normalize;
+
+ assert(!opts->avopts); // we don't set a default value, so it must be NULL
+
+ *opts = *src_opts;
+
+ opts->avopts = NULL;
+ struct m_option dummy = {.type = &m_option_type_keyvalue_list};
+ m_option_copy(&dummy, &opts->avopts, &src_opts->avopts);
+}
+
#define OPT_BASE_STRUCT struct af_resample
const struct af_info af_info_lavrresample = {
@@ -170,4 +195,5 @@ const struct af_info af_info_lavrresample = {
OPT_KEYVALUELIST("o", opts.avopts, 0),
{0}
},
+ .set_defaults = set_defaults,
};