diff mbox

[FFmpeg-devel] avfilter/graphparser: allow specifying filter@id as filter instance

Message ID 20170517061345.31800-1-mfcc64@gmail.com
State Accepted
Commit 162414cefee64eff114179a45abc45aca5133ed0
Headers show

Commit Message

Muhammad Faiz May 17, 2017, 6:13 a.m. UTC
See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
Parsed_filter_X is not intuitive as filter instance name and
also undocumented.

Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
---
 doc/filters.texi          | 13 ++++++++++---
 libavfilter/graphparser.c | 26 +++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 8 deletions(-)

Comments

Paul B Mahol May 18, 2017, 4:11 p.m. UTC | #1
On 5/17/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
> See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
> Parsed_filter_X is not intuitive as filter instance name and
> also undocumented.
>
> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
> ---
>  doc/filters.texi          | 13 ++++++++++---
>  libavfilter/graphparser.c | 26 +++++++++++++++++++++-----
>  2 files changed, 31 insertions(+), 8 deletions(-)
>

Could you add example in git log when you also linked that thread
article.

IMHO ParsedXXXX could remain and user can override it with custom one.
Muhammad Faiz May 18, 2017, 4:36 p.m. UTC | #2
On Thu, May 18, 2017 at 11:11 PM, Paul B Mahol <onemda@gmail.com> wrote:
> On 5/17/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
>> See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
>> Parsed_filter_X is not intuitive as filter instance name and
>> also undocumented.
>>
>> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
>> ---
>>  doc/filters.texi          | 13 ++++++++++---
>>  libavfilter/graphparser.c | 26 +++++++++++++++++++++-----
>>  2 files changed, 31 insertions(+), 8 deletions(-)
>>
>
> Could you add example in git log when you also linked that thread
> article.

Added
Example:
ffplay -f lavfi "nullsrc=s=640x360,
sendcmd='1 drawtext@top reinit text=Hello; 2 drawtext@bottom reinit text=World',
drawtext@top=x=16:y=16:fontsize=20:fontcolor=Red:text='',
drawtext@bottom=x=16:y=340:fontsize=16:fontcolor=Blue:text=''"

>
> IMHO ParsedXXXX could remain and user can override it with custom one.

Changed.

Thank's
Paul B Mahol May 18, 2017, 4:48 p.m. UTC | #3
On 5/18/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
> On Thu, May 18, 2017 at 11:11 PM, Paul B Mahol <onemda@gmail.com> wrote:
>> On 5/17/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
>>> See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
>>> Parsed_filter_X is not intuitive as filter instance name and
>>> also undocumented.
>>>
>>> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
>>> ---
>>>  doc/filters.texi          | 13 ++++++++++---
>>>  libavfilter/graphparser.c | 26 +++++++++++++++++++++-----
>>>  2 files changed, 31 insertions(+), 8 deletions(-)
>>>
>>
>> Could you add example in git log when you also linked that thread
>> article.
>
> Added
> Example:
> ffplay -f lavfi "nullsrc=s=640x360,
> sendcmd='1 drawtext@top reinit text=Hello; 2 drawtext@bottom reinit
> text=World',
> drawtext@top=x=16:y=16:fontsize=20:fontcolor=Red:text='',
> drawtext@bottom=x=16:y=340:fontsize=16:fontcolor=Blue:text=''"
>
>>
>> IMHO ParsedXXXX could remain and user can override it with custom one.
>
> Changed.
>
> Thank's

No more comments from me.
Muhammad Faiz May 19, 2017, 1:34 p.m. UTC | #4
On Thu, May 18, 2017 at 11:48 PM, Paul B Mahol <onemda@gmail.com> wrote:
> On 5/18/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
>> On Thu, May 18, 2017 at 11:11 PM, Paul B Mahol <onemda@gmail.com> wrote:
>>> On 5/17/17, Muhammad Faiz <mfcc64@gmail.com> wrote:
>>>> See http://lists.ffmpeg.org/pipermail/ffmpeg-user/2017-April/035975.html
>>>> Parsed_filter_X is not intuitive as filter instance name and
>>>> also undocumented.
>>>>
>>>> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
>>>> ---
>>>>  doc/filters.texi          | 13 ++++++++++---
>>>>  libavfilter/graphparser.c | 26 +++++++++++++++++++++-----
>>>>  2 files changed, 31 insertions(+), 8 deletions(-)
>>>>
>>>
>>> Could you add example in git log when you also linked that thread
>>> article.
>>
>> Added
>> Example:
>> ffplay -f lavfi "nullsrc=s=640x360,
>> sendcmd='1 drawtext@top reinit text=Hello; 2 drawtext@bottom reinit
>> text=World',
>> drawtext@top=x=16:y=16:fontsize=20:fontcolor=Red:text='',
>> drawtext@bottom=x=16:y=340:fontsize=16:fontcolor=Blue:text=''"
>>
>>>
>>> IMHO ParsedXXXX could remain and user can override it with custom one.
>>
>> Changed.
>>
>> Thank's
>
> No more comments from me.

Applied.

Thank's.
diff mbox

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index a7c6063..d2b5110 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -130,11 +130,11 @@  filterchains is represented by a list of ";"-separated filterchain
 descriptions.
 
 A filter is represented by a string of the form:
-[@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
+[@var{in_link_1}]...[@var{in_link_N}]@var{filter_name}@@@var{id}=@var{arguments}[@var{out_link_1}]...[@var{out_link_M}]
 
 @var{filter_name} is the name of the filter class of which the
 described filter is an instance of, and has to be the name of one of
-the filter classes registered in the program.
+the filter classes registered in the program optionally followed by "@@@var{id}".
 The name of the filter class is optionally followed by a string
 "=@var{arguments}".
 
@@ -212,10 +212,11 @@  to the filtergraph description.
 Here is a BNF description of the filtergraph syntax:
 @example
 @var{NAME}             ::= sequence of alphanumeric characters and '_'
+@var{FILTER_NAME}      ::= @var{NAME}["@@"@var{NAME}]
 @var{LINKLABEL}        ::= "[" @var{NAME} "]"
 @var{LINKLABELS}       ::= @var{LINKLABEL} [@var{LINKLABELS}]
 @var{FILTER_ARGUMENTS} ::= sequence of chars (possibly quoted)
-@var{FILTER}           ::= [@var{LINKLABELS}] @var{NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
+@var{FILTER}           ::= [@var{LINKLABELS}] @var{FILTER_NAME} ["=" @var{FILTER_ARGUMENTS}] [@var{LINKLABELS}]
 @var{FILTERCHAIN}      ::= @var{FILTER} [,@var{FILTERCHAIN}]
 @var{FILTERGRAPH}      ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
 @end example
@@ -17190,6 +17191,12 @@  asendcmd=c='4.0 atempo tempo 1.5',atempo
 @end example
 
 @item
+Target a specific filter instance:
+@example
+asendcmd=c='4.0 atempo@@my tempo 1.5',atempo@@my
+@end example
+
+@item
 Specify a list of drawtext and hue commands in a file.
 @example
 # show text in the interval 5-10
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 04b4272..1405926 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -88,20 +88,36 @@  static char *parse_link_name(const char **buf, void *log_ctx)
  * @param filt_ctx put here a filter context in case of successful creation and configuration, NULL otherwise.
  * @param ctx the filtergraph context
  * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
- * @param filt_name the name of the filter to create
+ * @param name the name of the filter to create, can be filter name or filter_name\@id as instance name
  * @param args the arguments provided to the filter during its initialization
  * @param log_ctx the log context to use
  * @return >= 0 in case of success, a negative AVERROR code otherwise
  */
 static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
-                         const char *filt_name, const char *args, void *log_ctx)
+                         const char *name, const char *args, void *log_ctx)
 {
     AVFilter *filt;
-    char inst_name[30];
+    char name2[30];
+    const char *inst_name = NULL, *filt_name = NULL;
     char *tmp_args = NULL;
-    int ret;
+    int ret, k;
+
+    av_strlcpy(name2, name, sizeof(name2));
+
+    for (k = 0; name2[k]; k++) {
+        if (name2[k] == '@' && name[k+1]) {
+            name2[k] = 0;
+            inst_name = name;
+            filt_name = name2;
+            break;
+        }
+    }
 
-    snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%d", filt_name, index);
+    if (!inst_name) {
+        snprintf(name2, sizeof(name2), "Parsed_%s_%d", name, index);
+        inst_name = name2;
+        filt_name = name;
+    }
 
     filt = avfilter_get_by_name(filt_name);