Merge commit 'b42f49e42f8cde25a788b2d13d03e99ca2956647'
[ffmpeg.git] / libavfilter / af_ladspa.c
index 45f17ff..2057e6d 100644 (file)
@@ -450,9 +450,11 @@ static av_cold int init(AVFilterContext *ctx)
 
             count_ports(desc, &inputs, &outputs);
             av_log(ctx, AV_LOG_INFO, "%lu:%lu %-25s %s\n", inputs, outputs, desc->Label,
-                                     av_x_if_null(desc->Name, "?"));
-            av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n", av_x_if_null(desc->Maker, "?"));
-            av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n", av_x_if_null(desc->Copyright, "?"));
+                   (char *)av_x_if_null(desc->Name, "?"));
+            av_log(ctx, AV_LOG_VERBOSE, "Maker: %s\n",
+                   (char *)av_x_if_null(desc->Maker, "?"));
+            av_log(ctx, AV_LOG_VERBOSE, "Copyright: %s\n",
+                   (char *)av_x_if_null(desc->Copyright, "?"));
         }
         return AVERROR_EXIT;
     } else {
@@ -612,6 +614,8 @@ static int query_formats(AVFilterContext *ctx)
 
         ff_set_common_channel_layouts(ctx, layouts);
     } else {
+        AVFilterLink *outlink = ctx->outputs[0];
+
         if (s->nb_inputs >= 1) {
             AVFilterLink *inlink = ctx->inputs[0];
             int64_t inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
@@ -619,10 +623,12 @@ static int query_formats(AVFilterContext *ctx)
             layouts = NULL;
             ff_add_channel_layout(&layouts, inlayout);
             ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts);
+
+            if (!s->nb_outputs)
+                ff_channel_layouts_ref(layouts, &outlink->in_channel_layouts);
         }
 
         if (s->nb_outputs >= 1) {
-            AVFilterLink *outlink = ctx->outputs[0];
             int64_t outlayout = FF_COUNT2LAYOUT(s->nb_outputs);
 
             layouts = NULL;
@@ -662,6 +668,18 @@ static av_cold void uninit(AVFilterContext *ctx)
         av_freep(&ctx->input_pads[0].name);
 }
 
+static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
+                           char *res, int res_len, int flags)
+{
+    LADSPA_Data value;
+    unsigned long port;
+
+    if (sscanf(cmd, "c%ld", &port) + sscanf(args, "%f", &value) != 2)
+        return AVERROR(EINVAL);
+
+    return set_control(ctx, port, value);
+}
+
 static const AVFilterPad ladspa_outputs[] = {
     {
         .name          = "default",
@@ -672,7 +690,7 @@ static const AVFilterPad ladspa_outputs[] = {
     { NULL }
 };
 
-AVFilter avfilter_af_ladspa = {
+AVFilter ff_af_ladspa = {
     .name          = "ladspa",
     .description   = NULL_IF_CONFIG_SMALL("Apply LADSPA effect."),
     .priv_size     = sizeof(LADSPAContext),
@@ -680,6 +698,7 @@ AVFilter avfilter_af_ladspa = {
     .init          = init,
     .uninit        = uninit,
     .query_formats = query_formats,
+    .process_command = process_command,
     .inputs        = 0,
     .outputs       = ladspa_outputs,
     .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS,