2009-01-05 12:41:40 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2009-01-05 12:41:40 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2009-01-05 12:41:40 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2009-01-05 12:41:40 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2015-04-13 07:36:54 +00:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2009-01-05 12:41:40 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_AF_H
|
|
|
|
#define MPLAYER_AF_H
|
2004-06-26 10:05:13 +00:00
|
|
|
|
2002-11-12 12:33:56 +00:00
|
|
|
#include <stdio.h>
|
2013-03-23 12:02:59 +00:00
|
|
|
#include <stdbool.h>
|
2013-11-18 13:16:08 +00:00
|
|
|
#include <sys/types.h>
|
2002-11-12 12:33:56 +00:00
|
|
|
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/options.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "audio/format.h"
|
2013-04-05 13:25:09 +00:00
|
|
|
#include "audio/chmap.h"
|
2013-04-05 17:47:51 +00:00
|
|
|
#include "audio/audio.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
2015-09-11 21:03:04 +00:00
|
|
|
#include "common/common.h"
|
2009-03-28 20:01:43 +00:00
|
|
|
|
2012-11-01 11:23:48 +00:00
|
|
|
struct af_instance;
|
2013-12-21 17:23:59 +00:00
|
|
|
struct mpv_global;
|
2002-10-01 06:45:08 +00:00
|
|
|
|
2006-11-25 19:57:31 +00:00
|
|
|
// Number of channels
|
2013-04-05 13:25:09 +00:00
|
|
|
#define AF_NCH MP_NUM_CHANNELS
|
2006-11-25 19:57:31 +00:00
|
|
|
|
2013-12-04 23:01:46 +00:00
|
|
|
// Flags for af->filter()
|
|
|
|
#define AF_FILTER_FLAG_EOF 1
|
|
|
|
|
2002-10-01 06:45:08 +00:00
|
|
|
/* Audio filter information not specific for current instance, but for
|
2009-07-06 23:26:13 +00:00
|
|
|
a specific filter */
|
2012-11-01 11:20:35 +00:00
|
|
|
struct af_info {
|
2012-11-01 12:37:20 +00:00
|
|
|
const char *info;
|
|
|
|
const char *name;
|
|
|
|
int (*open)(struct af_instance *vf);
|
2013-07-22 12:43:58 +00:00
|
|
|
int priv_size;
|
|
|
|
const void *priv_defaults;
|
|
|
|
const struct m_option *options;
|
2012-11-01 11:20:35 +00:00
|
|
|
};
|
2002-10-01 06:45:08 +00:00
|
|
|
|
|
|
|
// Linked list of audio filters
|
2012-11-01 11:23:48 +00:00
|
|
|
struct af_instance {
|
2013-07-22 12:43:58 +00:00
|
|
|
const struct af_info *info;
|
2013-12-21 17:23:59 +00:00
|
|
|
struct mp_log *log;
|
2016-01-20 16:14:04 +00:00
|
|
|
struct MPOpts *opts;
|
2014-03-25 10:49:25 +00:00
|
|
|
struct replaygain_data *replaygain_data;
|
2012-11-01 12:37:20 +00:00
|
|
|
int (*control)(struct af_instance *af, int cmd, void *arg);
|
|
|
|
void (*uninit)(struct af_instance *af);
|
2015-01-13 19:15:43 +00:00
|
|
|
/* 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);
|
2013-07-22 12:43:58 +00:00
|
|
|
void *priv;
|
2013-11-10 22:20:06 +00:00
|
|
|
struct mp_audio *data; // configuration and buffer for outgoing data stream
|
2015-01-13 19:15:43 +00:00
|
|
|
|
2012-11-01 12:37:20 +00:00
|
|
|
struct af_instance *next;
|
|
|
|
struct af_instance *prev;
|
2013-11-10 22:39:29 +00:00
|
|
|
double delay; /* Delay caused by the filter, in seconds of audio consumed
|
|
|
|
* without corresponding output */
|
2013-03-23 12:02:59 +00:00
|
|
|
bool auto_inserted; // inserted by af.c, such as conversion filters
|
2014-10-02 00:50:12 +00:00
|
|
|
char *label;
|
2015-01-13 19:15:43 +00:00
|
|
|
|
|
|
|
struct mp_audio fmt_in, fmt_out;
|
|
|
|
|
|
|
|
struct mp_audio **out_queued;
|
|
|
|
int num_out_queued;
|
|
|
|
|
|
|
|
struct mp_audio_pool *out_pool;
|
2012-11-01 11:23:48 +00:00
|
|
|
};
|
2002-10-01 06:45:08 +00:00
|
|
|
|
2002-10-01 12:53:30 +00:00
|
|
|
// Current audio stream
|
2012-11-01 12:33:38 +00:00
|
|
|
struct af_stream {
|
2014-10-01 23:47:27 +00:00
|
|
|
int initialized; // 0: no, 1: yes, -1: attempted to, but failed
|
|
|
|
|
2012-11-01 12:37:20 +00:00
|
|
|
// The first and last filter in the list
|
|
|
|
struct af_instance *first;
|
|
|
|
struct af_instance *last;
|
2013-03-29 21:52:15 +00:00
|
|
|
// The user sets the input format (what the decoder outputs), and sets some
|
|
|
|
// or all fields in output to the output format the AO accepts.
|
2012-11-01 12:37:20 +00:00
|
|
|
struct mp_audio input;
|
|
|
|
struct mp_audio output;
|
2013-03-29 21:52:15 +00:00
|
|
|
struct mp_audio filter_output;
|
2013-07-22 12:43:58 +00:00
|
|
|
|
2013-12-21 17:23:59 +00:00
|
|
|
struct mp_log *log;
|
2012-11-01 12:37:20 +00:00
|
|
|
struct MPOpts *opts;
|
2014-03-25 10:49:25 +00:00
|
|
|
struct replaygain_data *replaygain_data;
|
2012-11-01 12:33:38 +00:00
|
|
|
};
|
2002-10-01 12:53:30 +00:00
|
|
|
|
2013-11-18 13:11:13 +00:00
|
|
|
// Return values
|
2015-09-11 21:03:04 +00:00
|
|
|
#define AF_DETACH (CONTROL_OK + 1)
|
|
|
|
#define AF_OK CONTROL_OK
|
|
|
|
#define AF_TRUE CONTROL_TRUE
|
|
|
|
#define AF_FALSE CONTROL_FALSE
|
|
|
|
#define AF_UNKNOWN CONTROL_UNKNOWN
|
|
|
|
#define AF_ERROR CONTROL_ERROR
|
2002-10-01 06:45:08 +00:00
|
|
|
|
2013-11-18 13:16:08 +00:00
|
|
|
// Parameters for af_control_*
|
|
|
|
enum af_control {
|
|
|
|
AF_CONTROL_REINIT = 1,
|
2013-11-18 13:18:37 +00:00
|
|
|
AF_CONTROL_RESET,
|
2013-11-18 13:16:08 +00:00
|
|
|
AF_CONTROL_SET_VOLUME,
|
|
|
|
AF_CONTROL_SET_PAN_LEVEL,
|
|
|
|
AF_CONTROL_SET_PAN_NOUT,
|
|
|
|
AF_CONTROL_SET_PAN_BALANCE,
|
|
|
|
AF_CONTROL_GET_PAN_BALANCE,
|
|
|
|
AF_CONTROL_SET_PLAYBACK_SPEED,
|
2014-11-10 19:16:25 +00:00
|
|
|
AF_CONTROL_SET_PLAYBACK_SPEED_RESAMPLE,
|
2015-09-11 21:04:02 +00:00
|
|
|
AF_CONTROL_GET_METADATA,
|
2016-01-22 19:36:54 +00:00
|
|
|
AF_CONTROL_COMMAND,
|
2013-11-18 13:16:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Argument for AF_CONTROL_SET_PAN_LEVEL
|
|
|
|
typedef struct af_control_ext_s {
|
|
|
|
void* arg; // Argument
|
|
|
|
int ch; // Chanel number
|
|
|
|
} af_control_ext_t;
|
|
|
|
|
2013-12-21 17:23:59 +00:00
|
|
|
struct af_stream *af_new(struct mpv_global *global);
|
2013-03-29 21:52:15 +00:00
|
|
|
void af_destroy(struct af_stream *s);
|
2012-11-01 12:37:20 +00:00
|
|
|
int af_init(struct af_stream *s);
|
|
|
|
void af_uninit(struct af_stream *s);
|
2015-04-07 19:23:23 +00:00
|
|
|
struct af_instance *af_add(struct af_stream *s, char *name, char *label,
|
|
|
|
char **args);
|
2014-10-02 00:50:12 +00:00
|
|
|
int af_remove_by_label(struct af_stream *s, char *label);
|
|
|
|
struct af_instance *af_find_by_label(struct af_stream *s, char *label);
|
2012-11-01 12:37:20 +00:00
|
|
|
struct af_instance *af_control_any_rev(struct af_stream *s, int cmd, void *arg);
|
2013-11-18 13:18:37 +00:00
|
|
|
void af_control_all(struct af_stream *s, int cmd, void *arg);
|
2015-09-11 21:04:02 +00:00
|
|
|
int af_control_by_label(struct af_stream *s, int cmd, void *arg, bstr label);
|
2015-01-13 19:15:43 +00:00
|
|
|
void af_seek_reset(struct af_stream *s);
|
2016-01-22 19:36:54 +00:00
|
|
|
int af_send_command(struct af_stream *s, char *label, char *cmd, char *arg);
|
2015-01-13 19:15:43 +00:00
|
|
|
|
|
|
|
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);
|
2016-08-18 18:38:09 +00:00
|
|
|
void af_unread_output_frame(struct af_stream *s, struct mp_audio *frame);
|
2015-01-13 19:15:43 +00:00
|
|
|
int af_make_writeable(struct af_instance *af, struct mp_audio *frame);
|
2004-06-25 19:02:53 +00:00
|
|
|
|
2012-11-01 12:37:20 +00:00
|
|
|
double af_calc_delay(struct af_stream *s);
|
2002-10-01 06:45:08 +00:00
|
|
|
|
2013-11-18 13:11:13 +00:00
|
|
|
int af_test_output(struct af_instance *af, struct mp_audio *out);
|
2005-10-01 12:55:34 +00:00
|
|
|
|
2012-11-01 12:37:20 +00:00
|
|
|
int af_from_ms(int n, float *in, int *out, int rate, float mi, float ma);
|
2005-01-31 11:43:08 +00:00
|
|
|
float af_softclip(float a);
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_AF_H */
|