summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@ghedini.me>2014-03-12 10:41:52 +0100
committerwm4 <wm4@nowhere>2014-03-13 14:36:20 +0100
commit04e14ec8f69c66681808609046111bc225119e8e (patch)
treed9cf84254ed05077141d7ae54c90bf3ff971533b
parent7918034e151a49fa84622cb3a2753377b3b5597b (diff)
downloadmpv-04e14ec8f69c66681808609046111bc225119e8e.tar.bz2
mpv-04e14ec8f69c66681808609046111bc225119e8e.tar.xz
af: add metadata field to af_stream and af_instance
This allows to propagate metadata information to audio filters. Closes #632
-rw-r--r--audio/decode/dec_audio.c2
-rw-r--r--audio/decode/dec_audio.h2
-rw-r--r--audio/filter/af.c1
-rw-r--r--audio/filter/af.h2
-rw-r--r--player/audio.c1
5 files changed, 8 insertions, 0 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index ad9ccb504e..b753043869 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -213,6 +213,8 @@ int audio_init_filters(struct dec_audio *d_audio, int in_samplerate,
mp_audio_set_channels(&afs->output, out_channels);
mp_audio_set_format(&afs->output, *out_format);
+ afs->metadata = d_audio->metadata;
+
char *s_from = mp_audio_config_to_str(&afs->input);
char *s_to = mp_audio_config_to_str(&afs->output);
MP_VERBOSE(d_audio, "Building audio filter chain for %s -> %s...\n", s_from, s_to);
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index c17a3baca3..8e9a1bcd12 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -21,6 +21,7 @@
#include "audio/chmap.h"
#include "audio/audio.h"
+#include "demux/demux.h"
#include "demux/stheader.h"
struct mp_audio_buffer;
@@ -35,6 +36,7 @@ struct dec_audio {
struct mp_audio_buffer *decode_buffer;
struct af_stream *afilter;
char *decoder_desc;
+ struct mp_tags *metadata;
// set by decoder
struct mp_audio decoded; // format of decoded audio (no data, temporarily
// different from decode_buffer during format
diff --git a/audio/filter/af.c b/audio/filter/af.c
index fe21cc61ed..5a4838ca25 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -204,6 +204,7 @@ static struct af_instance *af_create(struct af_stream *s, char *name,
.mul = 1,
.data = talloc_zero(af, struct mp_audio),
.log = mp_log_new(af, s->log, name),
+ .metadata = s->metadata,
};
struct m_config *config = m_config_from_obj_desc(af, s->log, &desc);
if (m_config_apply_defaults(config, name, s->opts->af_defs) < 0)
diff --git a/audio/filter/af.h b/audio/filter/af.h
index 6b0f0e9c01..9e424308b8 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -59,6 +59,7 @@ struct af_info {
struct af_instance {
const struct af_info *info;
struct mp_log *log;
+ struct mp_tags *metadata;
int (*control)(struct af_instance *af, int cmd, void *arg);
void (*uninit)(struct af_instance *af);
/* flags is a bit mask of AF_FILTER_FLAG_* values
@@ -90,6 +91,7 @@ struct af_stream {
struct mp_log *log;
struct MPOpts *opts;
+ struct mp_tags *metadata;
};
// Return values
diff --git a/player/audio.c b/player/audio.c
index 28a110eba8..e7c2b8baf4 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -125,6 +125,7 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->d_audio->global = mpctx->global;
mpctx->d_audio->opts = opts;
mpctx->d_audio->header = sh;
+ mpctx->d_audio->metadata = mpctx->demuxer->metadata;
if (!audio_init_best_codec(mpctx->d_audio, opts->audio_decoders))
goto init_error;
}