summaryrefslogtreecommitdiff
path: root/libavfilter/af_pan.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-12 10:32:41 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-12 10:35:45 +0200
commit3c821e7550866129ad19d4bba0f84dc4648ceb5a (patch)
treefb98654e1ff6b8656d592db66dcd052d6a6c7f43 /libavfilter/af_pan.c
parent9470b541e5c4c4131723df09b0f7fb248b7ee1b9 (diff)
af_pan: switch to an AVOptions-based shorthand system.
TODO: The first argument can be seperated into its own AVOption Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/af_pan.c')
-rw-r--r--libavfilter/af_pan.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 4fa81ab7fb..338cc6ea00 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -40,6 +40,8 @@
#define MAX_CHANNELS 63
typedef struct PanContext {
+ const AVClass *class;
+ char *args;
int64_t out_channel_layout;
double gain[MAX_CHANNELS][MAX_CHANNELS];
int64_t need_renorm;
@@ -99,12 +101,12 @@ static void skip_spaces(char **arg)
static av_cold int init(AVFilterContext *ctx, const char *args0)
{
PanContext *const pan = ctx->priv;
- char *arg, *arg0, *tokenizer, *args = av_strdup(args0);
+ char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args);
int out_ch_id, in_ch_id, len, named, ret;
int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels
double gain;
- if (!args0) {
+ if (!pan->args) {
av_log(ctx, AV_LOG_ERROR,
"pan filter needs a channel layout and a set "
"of channels definitions as parameter\n");
@@ -112,14 +114,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
}
if (!args)
return AVERROR(ENOMEM);
- arg = av_strtok(args, ":", &tokenizer);
+ arg = av_strtok(args, "|", &tokenizer);
ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
if (ret < 0)
goto fail;
pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
/* parse channel specifications */
- while ((arg = arg0 = av_strtok(NULL, ":", &tokenizer))) {
+ while ((arg = arg0 = av_strtok(NULL, "|", &tokenizer))) {
/* channel name */
if (parse_channel_name(&arg, &out_ch_id, &named)) {
av_log(ctx, AV_LOG_ERROR,
@@ -379,6 +381,16 @@ static av_cold void uninit(AVFilterContext *ctx)
swr_free(&pan->swr);
}
+#define OFFSET(x) offsetof(PanContext, x)
+
+static const AVOption pan_options[] = {
+ { "args", NULL, OFFSET(args), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(pan);
+
+
static const AVFilterPad pan_inputs[] = {
{
.name = "default",
@@ -401,6 +413,7 @@ AVFilter avfilter_af_pan = {
.name = "pan",
.description = NULL_IF_CONFIG_SMALL("Remix channels with coefficients (panning)."),
.priv_size = sizeof(PanContext),
+ .priv_class = &pan_class,
.init = init,
.uninit = uninit,
.query_formats = query_formats,