diff options
author | wm4 <wm4@nowhere> | 2015-09-11 23:04:02 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-09-11 23:04:02 +0200 |
commit | 4e0e24c3c27362939d9f88d3e22267afef5f6d4f (patch) | |
tree | 5d8ad6f4a3ed84071b79e07df48e9bfc818db07f /audio/filter/af_lavfi.c | |
parent | f095e86b61022613371334d80552b918946b9387 (diff) | |
download | mpv-4e0e24c3c27362939d9f88d3e22267afef5f6d4f.tar.bz2 mpv-4e0e24c3c27362939d9f88d3e22267afef5f6d4f.tar.xz |
af_lavfi: implement af-metadata property
Works like vf-metadata. Unfortunately requires some code duplication
(even though it's not much).
Fixes #2311.
Diffstat (limited to 'audio/filter/af_lavfi.c')
-rw-r--r-- | audio/filter/af_lavfi.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/audio/filter/af_lavfi.c b/audio/filter/af_lavfi.c index 249a560fb6..a40904aa78 100644 --- a/audio/filter/af_lavfi.c +++ b/audio/filter/af_lavfi.c @@ -34,11 +34,14 @@ #include <libavfilter/buffersink.h> #include <libavfilter/buffersrc.h> +#include "config.h" + #include "audio/format.h" #include "audio/fmt-conversion.h" #include "af.h" #include "common/av_common.h" +#include "common/tags.h" #include "options/m_option.h" @@ -63,6 +66,8 @@ struct priv { bool eof; + struct mp_tags *metadata; + // options char *cfg_graph; char **cfg_avopts; @@ -213,6 +218,12 @@ static int control(struct af_instance *af, int cmd, void *arg) return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE; } + case AF_CONTROL_GET_METADATA: + if (p->metadata) { + *(struct mp_tags *)arg = *p->metadata; + return CONTROL_OK; + } + return CONTROL_NA; case AF_CONTROL_RESET: reset(af); return AF_OK; @@ -220,6 +231,17 @@ static int control(struct af_instance *af, int cmd, void *arg) return AF_UNKNOWN; } +static void get_metadata_from_av_frame(struct af_instance *af, AVFrame *frame) +{ +#if HAVE_AVFRAME_METADATA + struct priv *p = af->priv; + if (!p->metadata) + p->metadata = talloc_zero(p, struct mp_tags); + + mp_tags_copy_from_av_dictionary(p->metadata, av_frame_get_metadata(frame)); +#endif +} + static int filter_frame(struct af_instance *af, struct mp_audio *data) { struct priv *p = af->priv; @@ -307,6 +329,7 @@ static int filter_out(struct af_instance *af) af->delay = in_time - out_time; } + get_metadata_from_av_frame(af, frame); af_add_output_frame(af, out); av_frame_free(&frame); return 0; |