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
b54c0a55
Commit
b54c0a55
authored
Oct 25, 2011
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_overlay: use opt.h API for setting options
Extend syntax, allow to easily add more options later.
parent
5b1a06b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
7 deletions
+49
-7
avfilter.h
libavfilter/avfilter.h
+1
-1
vf_overlay.c
libavfilter/vf_overlay.c
+48
-6
No files found.
libavfilter/avfilter.h
View file @
b54c0a55
...
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 2
#define LIBAVFILTER_VERSION_MINOR 45
#define LIBAVFILTER_VERSION_MICRO
1
#define LIBAVFILTER_VERSION_MICRO
2
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_overlay.c
View file @
b54c0a55
...
...
@@ -28,6 +28,7 @@
#include "avfilter.h"
#include "libavutil/eval.h"
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/imgutils.h"
#include "libavutil/mathematics.h"
...
...
@@ -53,6 +54,7 @@ enum var_name {
#define OVERLAY 1
typedef
struct
{
const
AVClass
*
class
;
int
x
,
y
;
///< position of overlayed picture
AVFilterBufferRef
*
overpicref
;
...
...
@@ -60,26 +62,66 @@ typedef struct {
int
max_plane_step
[
4
];
///< steps per pixel for each plane
int
hsub
,
vsub
;
///< chroma subsampling values
char
x_expr
[
256
],
y_expr
[
256
]
;
char
*
x_expr
,
*
y_expr
;
}
OverlayContext
;
#define OFFSET(x) offsetof(OverlayContext, x)
static
const
AVOption
overlay_options
[]
=
{
{
"x"
,
"set the x expression"
,
OFFSET
(
x_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
"0"
},
CHAR_MIN
,
CHAR_MAX
},
{
"y"
,
"set the y expression"
,
OFFSET
(
y_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
"0"
},
CHAR_MIN
,
CHAR_MAX
},
{
NULL
},
};
static
const
char
*
overlay_get_name
(
void
*
ctx
)
{
return
"overlay"
;
}
static
const
AVClass
overlay_class
=
{
"OverlayContext"
,
overlay_get_name
,
overlay_options
};
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
,
void
*
opaque
)
{
OverlayContext
*
over
=
ctx
->
priv
;
char
*
args1
=
av_strdup
(
args
);
char
*
expr
,
*
bufptr
=
NULL
;
int
ret
=
0
;
av_strlcpy
(
over
->
x_expr
,
"0"
,
sizeof
(
over
->
x_expr
))
;
av_
strlcpy
(
over
->
y_expr
,
"0"
,
sizeof
(
over
->
y_expr
)
);
over
->
class
=
&
overlay_class
;
av_
opt_set_defaults
(
over
);
if
(
args
)
sscanf
(
args
,
"%255[^:]:%255[^:]"
,
over
->
x_expr
,
over
->
y_expr
);
if
(
expr
=
av_strtok
(
args1
,
":"
,
&
bufptr
))
{
if
(
!
(
over
->
x_expr
=
av_strdup
(
expr
)))
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
}
if
(
expr
=
av_strtok
(
NULL
,
":"
,
&
bufptr
))
{
if
(
!
(
over
->
y_expr
=
av_strdup
(
expr
)))
{
ret
=
AVERROR
(
ENOMEM
);
goto
end
;
}
}
return
0
;
if
(
bufptr
&&
(
ret
=
av_set_options_string
(
over
,
bufptr
,
"="
,
":"
))
<
0
)
goto
end
;
end:
av_free
(
args1
);
return
ret
;
}
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
OverlayContext
*
over
=
ctx
->
priv
;
av_freep
(
&
over
->
x_expr
);
av_freep
(
&
over
->
y_expr
);
if
(
over
->
overpicref
)
avfilter_unref_buffer
(
over
->
overpicref
);
}
...
...
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