Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
38853169
Commit
38853169
authored
Apr 20, 2013
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi: add 'enable' command injection to filters supporting timeline.
parent
fdd93eab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
13 deletions
+49
-13
filters.texi
doc/filters.texi
+3
-0
avfilter.c
libavfilter/avfilter.c
+46
-13
No files found.
doc/filters.texi
View file @
38853169
...
@@ -287,6 +287,9 @@ sequential number of the input frame, starting from 0
...
@@ -287,6 +287,9 @@ sequential number of the input frame, starting from 0
the position in the file of the input frame, NAN if unknown
the position in the file of the input frame, NAN if unknown
@end table
@end table
Additionally, these filters support an @option{enable} command that can be used
to re-define the expression.
Like any other filtering option, the @option{enable} option follows the same
Like any other filtering option, the @option{enable} option follows the same
rules.
rules.
...
...
libavfilter/avfilter.c
View file @
38853169
...
@@ -366,6 +366,49 @@ int ff_poll_frame(AVFilterLink *link)
...
@@ -366,6 +366,49 @@ int ff_poll_frame(AVFilterLink *link)
return
min
;
return
min
;
}
}
static
const
char
*
const
var_names
[]
=
{
"t"
,
"n"
,
"pos"
,
NULL
};
enum
{
VAR_T
,
VAR_N
,
VAR_POS
,
VAR_VARS_NB
};
static
int
set_enable_expr
(
AVFilterContext
*
ctx
,
const
char
*
expr
)
{
int
ret
;
char
*
expr_dup
;
AVExpr
*
old
=
ctx
->
enable
;
if
(
!
(
ctx
->
filter
->
flags
&
AVFILTER_FLAG_SUPPORT_TIMELINE
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Timeline ('enable' option) not supported "
"with filter '%s'
\n
"
,
ctx
->
filter
->
name
);
return
AVERROR_PATCHWELCOME
;
}
expr_dup
=
av_strdup
(
expr
);
if
(
!
expr_dup
)
return
AVERROR
(
ENOMEM
);
if
(
!
ctx
->
var_values
)
{
ctx
->
var_values
=
av_calloc
(
VAR_VARS_NB
,
sizeof
(
*
ctx
->
var_values
));
if
(
!
ctx
->
var_values
)
{
av_free
(
expr_dup
);
return
AVERROR
(
ENOMEM
);
}
}
ret
=
av_expr_parse
((
AVExpr
**
)
&
ctx
->
enable
,
expr_dup
,
var_names
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
ctx
->
priv
);
if
(
ret
<
0
)
{
av_log
(
ctx
->
priv
,
AV_LOG_ERROR
,
"Error when evaluating the expression '%s' for enable
\n
"
,
expr_dup
);
av_free
(
expr_dup
);
return
ret
;
}
av_expr_free
(
old
);
av_free
(
ctx
->
enable_str
);
ctx
->
enable_str
=
expr_dup
;
return
0
;
}
void
ff_update_link_current_pts
(
AVFilterLink
*
link
,
int64_t
pts
)
void
ff_update_link_current_pts
(
AVFilterLink
*
link
,
int64_t
pts
)
{
{
if
(
pts
==
AV_NOPTS_VALUE
)
if
(
pts
==
AV_NOPTS_VALUE
)
...
@@ -381,6 +424,8 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
...
@@ -381,6 +424,8 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha
if
(
!
strcmp
(
cmd
,
"ping"
)){
if
(
!
strcmp
(
cmd
,
"ping"
)){
av_strlcatf
(
res
,
res_len
,
"pong from:%s %s
\n
"
,
filter
->
filter
->
name
,
filter
->
name
);
av_strlcatf
(
res
,
res_len
,
"pong from:%s %s
\n
"
,
filter
->
filter
->
name
,
filter
->
name
);
return
0
;
return
0
;
}
else
if
(
!
strcmp
(
cmd
,
"enable"
))
{
return
set_enable_expr
(
filter
,
arg
);
}
else
if
(
filter
->
filter
->
process_command
)
{
}
else
if
(
filter
->
filter
->
process_command
)
{
return
filter
->
filter
->
process_command
(
filter
,
cmd
,
arg
,
res
,
res_len
,
flags
);
return
filter
->
filter
->
process_command
(
filter
,
cmd
,
arg
,
res
,
res_len
,
flags
);
}
}
...
@@ -634,9 +679,6 @@ void avfilter_free(AVFilterContext *filter)
...
@@ -634,9 +679,6 @@ void avfilter_free(AVFilterContext *filter)
av_free
(
filter
);
av_free
(
filter
);
}
}
static
const
char
*
const
var_names
[]
=
{
"t"
,
"n"
,
"pos"
,
NULL
};
enum
{
VAR_T
,
VAR_N
,
VAR_POS
,
VAR_VARS_NB
};
static
int
process_options
(
AVFilterContext
*
ctx
,
AVDictionary
**
options
,
static
int
process_options
(
AVFilterContext
*
ctx
,
AVDictionary
**
options
,
const
char
*
args
)
const
char
*
args
)
{
{
...
@@ -707,16 +749,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
...
@@ -707,16 +749,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
}
}
if
(
ctx
->
enable_str
)
{
if
(
ctx
->
enable_str
)
{
if
(
!
(
ctx
->
filter
->
flags
&
AVFILTER_FLAG_SUPPORT_TIMELINE
))
{
ret
=
set_enable_expr
(
ctx
,
ctx
->
enable_str
);
av_log
(
ctx
,
AV_LOG_ERROR
,
"Timeline ('enable' option) not supported "
"with filter '%s'
\n
"
,
ctx
->
filter
->
name
);
return
AVERROR_PATCHWELCOME
;
}
ctx
->
var_values
=
av_calloc
(
VAR_VARS_NB
,
sizeof
(
*
ctx
->
var_values
));
if
(
!
ctx
->
var_values
)
return
AVERROR
(
ENOMEM
);
ret
=
av_expr_parse
((
AVExpr
**
)
&
ctx
->
enable
,
ctx
->
enable_str
,
var_names
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
ctx
->
priv
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment