Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
9c9d5bf2
Commit
9c9d5bf2
authored
Sep 30, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/f_metadata: add ends_with() function for comparing ends of strings
parent
6ca3d34f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
filters.texi
doc/filters.texi
+4
-0
f_metadata.c
libavfilter/f_metadata.c
+13
-0
No files found.
doc/filters.texi
View file @
9c9d5bf2
...
...
@@ -21856,6 +21856,10 @@ Values are interpreted as floats, returns true if metadata value is greater than
@item expr
Values are interpreted as floats, returns true if expression from option @code{expr}
evaluates to true.
@item ends_with
Values are interpreted as strings, returns true if metadata value ends with
the @code{value} option string.
@end table
@item expr
...
...
libavfilter/f_metadata.c
View file @
9c9d5bf2
...
...
@@ -54,6 +54,7 @@ enum MetadataFunction {
METADATAF_EQUAL
,
METADATAF_GREATER
,
METADATAF_EXPR
,
METADATAF_ENDS_WITH
,
METADATAF_NB
};
...
...
@@ -107,6 +108,7 @@ static const AVOption filt_name##_options[] = { \
{ "equal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EQUAL }, 0, 3, FLAGS, "function" }, \
{ "greater", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_GREATER }, 0, 3, FLAGS, "function" }, \
{ "expr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_EXPR }, 0, 3, FLAGS, "function" }, \
{ "ends_with", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = METADATAF_ENDS_WITH }, 0, 0, FLAGS, "function" }, \
{ "expr", "set expression for expr function", OFFSET(expr_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, FLAGS }, \
{ "file", "set file where to print metadata information", OFFSET(file_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, \
{ NULL } \
...
...
@@ -122,6 +124,14 @@ static int starts_with(MetadataContext *s, const char *value1, const char *value
return
!
strncmp
(
value1
,
value2
,
strlen
(
value2
));
}
static
int
ends_with
(
MetadataContext
*
s
,
const
char
*
value1
,
const
char
*
value2
)
{
const
int
len1
=
strlen
(
value1
);
const
int
len2
=
strlen
(
value2
);
return
!
strncmp
(
value1
+
FFMAX
(
len1
-
len2
,
0
),
value2
,
len2
);
}
static
int
equal
(
MetadataContext
*
s
,
const
char
*
value1
,
const
char
*
value2
)
{
float
f1
,
f2
;
...
...
@@ -212,6 +222,9 @@ static av_cold int init(AVFilterContext *ctx)
case
METADATAF_STARTS_WITH
:
s
->
compare
=
starts_with
;
break
;
case
METADATAF_ENDS_WITH
:
s
->
compare
=
ends_with
;
break
;
case
METADATAF_LESS
:
s
->
compare
=
less
;
break
;
...
...
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