summaryrefslogtreecommitdiffstats
path: root/audio/filter/af.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-13 20:15:43 +0100
committerwm4 <wm4@nowhere>2015-01-13 20:15:43 +0100
commit5e25a3d2168555efea9cbd7eb2846d44ede1948d (patch)
treed5c9fa8180c4f35b062cd2291ebb589d7d58be03 /audio/filter/af.h
parent97becbc31bfd6acb76f584eaf65c1546d6fbcc8b (diff)
downloadmpv-5e25a3d2168555efea9cbd7eb2846d44ede1948d.tar.bz2
mpv-5e25a3d2168555efea9cbd7eb2846d44ede1948d.tar.xz
audio: use refcounted frames in the filter chain
The goal is switching the whole audio chain to using refcounted frames. This brings the architecture closer to FFmpeg, enables better integration with libavfilter, will reduce useless copying somewhat, and will probably allow better timestamp tracking. For now, every filter goes through a semi-awful wrapper in af_do_filter(), though. This will be fixed step by step, and the wrapper should eventually be removed. Another thing that will have to be done is improving the timestamp handling and avoiding extra copies for the AO. Some of the new code is rather similar to the video filter code (the core filter code basically just has types replaced). Such code duplication is normally very unwanted, but in this case there's probably no other choice. On the other hand, this code is pretty simple (even if somewhat tricky). Maybe there will be unified filter code in the future, but this is still far away.
Diffstat (limited to 'audio/filter/af.h')
-rw-r--r--audio/filter/af.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/audio/filter/af.h b/audio/filter/af.h
index 96758a0cc9..e9299c132f 100644
--- a/audio/filter/af.h
+++ b/audio/filter/af.h
@@ -62,18 +62,34 @@ struct af_instance {
struct replaygain_data *replaygain_data;
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
+ /* old filter function (use filter_frame instead)
+ * flags is a bit mask of AF_FILTER_FLAG_* values
* returns 0 on success, negative value on error
*/
int (*filter)(struct af_instance *af, struct mp_audio *data, int flags);
+ /* Feed a frame. The frame is NULL if EOF was reached, and the filter
+ * should drain all remaining buffered data.
+ * Use af_add_output_frame() to output data. The optional filter_out
+ * callback can be set to produce output frames gradually.
+ */
+ int (*filter_frame)(struct af_instance *af, struct mp_audio *frame);
+ int (*filter_out)(struct af_instance *af);
void *priv;
struct mp_audio *data; // configuration and buffer for outgoing data stream
+
struct af_instance *next;
struct af_instance *prev;
double delay; /* Delay caused by the filter, in seconds of audio consumed
* without corresponding output */
bool auto_inserted; // inserted by af.c, such as conversion filters
char *label;
+
+ struct mp_audio fmt_in, fmt_out;
+
+ struct mp_audio **out_queued;
+ int num_out_queued;
+
+ struct mp_audio_pool *out_pool;
};
// Current audio stream
@@ -133,11 +149,15 @@ void af_uninit(struct af_stream *s);
struct af_instance *af_add(struct af_stream *s, char *name, char **args);
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 mp_audio_buffer;
-int af_filter(struct af_stream *s, struct mp_audio *data,
- struct mp_audio_buffer *output);
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);
+void af_seek_reset(struct af_stream *s);
+
+void af_add_output_frame(struct af_instance *af, struct mp_audio *frame);
+int af_filter_frame(struct af_stream *s, struct mp_audio *frame);
+int af_output_frame(struct af_stream *s, bool eof);
+struct mp_audio *af_read_output_frame(struct af_stream *s);
+int af_make_writeable(struct af_instance *af, struct mp_audio *frame);
double af_calc_delay(struct af_stream *s);