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
19804024
Commit
19804024
authored
Jul 17, 2017
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/vf_overlay: move to framesync2.
parent
0ae8df41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
33 deletions
+39
-33
Makefile
libavfilter/Makefile
+1
-1
vf_overlay.c
libavfilter/vf_overlay.c
+38
-32
No files found.
libavfilter/Makefile
View file @
19804024
...
@@ -245,7 +245,7 @@ OBJS-$(CONFIG_OCR_FILTER) += vf_ocr.o
...
@@ -245,7 +245,7 @@ OBJS-$(CONFIG_OCR_FILTER) += vf_ocr.o
OBJS-$(CONFIG_OCV_FILTER)
+=
vf_libopencv.o
OBJS-$(CONFIG_OCV_FILTER)
+=
vf_libopencv.o
OBJS-$(CONFIG_OPENCL)
+=
deshake_opencl.o
unsharp_opencl.o
OBJS-$(CONFIG_OPENCL)
+=
deshake_opencl.o
unsharp_opencl.o
OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)
+=
vf_datascope.o
OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)
+=
vf_datascope.o
OBJS-$(CONFIG_OVERLAY_FILTER)
+=
vf_overlay.o
dualinput.o
framesync
.o
OBJS-$(CONFIG_OVERLAY_FILTER)
+=
vf_overlay.o
framesync2
.o
OBJS-$(CONFIG_OWDENOISE_FILTER)
+=
vf_owdenoise.o
OBJS-$(CONFIG_OWDENOISE_FILTER)
+=
vf_owdenoise.o
OBJS-$(CONFIG_PAD_FILTER)
+=
vf_pad.o
OBJS-$(CONFIG_PAD_FILTER)
+=
vf_pad.o
OBJS-$(CONFIG_PALETTEGEN_FILTER)
+=
vf_palettegen.o
OBJS-$(CONFIG_PALETTEGEN_FILTER)
+=
vf_palettegen.o
...
...
libavfilter/vf_overlay.c
View file @
19804024
...
@@ -36,8 +36,8 @@
...
@@ -36,8 +36,8 @@
#include "libavutil/opt.h"
#include "libavutil/opt.h"
#include "libavutil/timestamp.h"
#include "libavutil/timestamp.h"
#include "internal.h"
#include "internal.h"
#include "dualinput.h"
#include "drawutils.h"
#include "drawutils.h"
#include "framesync2.h"
#include "video.h"
#include "video.h"
static
const
char
*
const
var_names
[]
=
{
static
const
char
*
const
var_names
[]
=
{
...
@@ -121,7 +121,7 @@ typedef struct OverlayContext {
...
@@ -121,7 +121,7 @@ typedef struct OverlayContext {
int
format
;
///< OverlayFormat
int
format
;
///< OverlayFormat
int
eval_mode
;
///< EvalMode
int
eval_mode
;
///< EvalMode
FF
DualInputContext
dinput
;
FF
FrameSync
fs
;
int
main_pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
main_pix_step
[
4
];
///< steps per pixel for each plane of the main output
int
overlay_pix_step
[
4
];
///< steps per pixel for each plane of the overlay
int
overlay_pix_step
[
4
];
///< steps per pixel for each plane of the overlay
...
@@ -132,6 +132,8 @@ typedef struct OverlayContext {
...
@@ -132,6 +132,8 @@ typedef struct OverlayContext {
char
*
x_expr
,
*
y_expr
;
char
*
x_expr
,
*
y_expr
;
int
eof_action
;
///< action to take on EOF from source
int
eof_action
;
///< action to take on EOF from source
int
opt_shortest
;
int
opt_repeatlast
;
AVExpr
*
x_pexpr
,
*
y_pexpr
;
AVExpr
*
x_pexpr
,
*
y_pexpr
;
...
@@ -142,7 +144,7 @@ static av_cold void uninit(AVFilterContext *ctx)
...
@@ -142,7 +144,7 @@ static av_cold void uninit(AVFilterContext *ctx)
{
{
OverlayContext
*
s
=
ctx
->
priv
;
OverlayContext
*
s
=
ctx
->
priv
;
ff_
dualinput_uninit
(
&
s
->
dinput
);
ff_
framesync2_uninit
(
&
s
->
fs
);
av_expr_free
(
s
->
x_pexpr
);
s
->
x_pexpr
=
NULL
;
av_expr_free
(
s
->
x_pexpr
);
s
->
x_pexpr
=
NULL
;
av_expr_free
(
s
->
y_pexpr
);
s
->
y_pexpr
=
NULL
;
av_expr_free
(
s
->
y_pexpr
);
s
->
y_pexpr
=
NULL
;
}
}
...
@@ -390,14 +392,20 @@ static int config_output(AVFilterLink *outlink)
...
@@ -390,14 +392,20 @@ static int config_output(AVFilterLink *outlink)
OverlayContext
*
s
=
ctx
->
priv
;
OverlayContext
*
s
=
ctx
->
priv
;
int
ret
;
int
ret
;
if
((
ret
=
ff_
dualinput_init
(
ctx
,
&
s
->
dinput
))
<
0
)
if
((
ret
=
ff_
framesync2_init_dualinput
(
&
s
->
fs
,
ctx
))
<
0
)
return
ret
;
return
ret
;
if
(
s
->
opt_shortest
)
s
->
fs
.
in
[
0
].
after
=
s
->
fs
.
in
[
1
].
after
=
EXT_STOP
;
if
(
!
s
->
opt_repeatlast
)
{
s
->
fs
.
in
[
1
].
after
=
EXT_NULL
;
s
->
fs
.
in
[
1
].
sync
=
0
;
}
outlink
->
w
=
ctx
->
inputs
[
MAIN
]
->
w
;
outlink
->
w
=
ctx
->
inputs
[
MAIN
]
->
w
;
outlink
->
h
=
ctx
->
inputs
[
MAIN
]
->
h
;
outlink
->
h
=
ctx
->
inputs
[
MAIN
]
->
h
;
outlink
->
time_base
=
ctx
->
inputs
[
MAIN
]
->
time_base
;
outlink
->
time_base
=
ctx
->
inputs
[
MAIN
]
->
time_base
;
return
0
;
return
ff_framesync2_configure
(
&
s
->
fs
)
;
}
}
// divide by 255 and round to nearest
// divide by 255 and round to nearest
...
@@ -770,11 +778,19 @@ static int config_input_main(AVFilterLink *inlink)
...
@@ -770,11 +778,19 @@ static int config_input_main(AVFilterLink *inlink)
return
0
;
return
0
;
}
}
static
AVFrame
*
do_blend
(
AVFilterContext
*
ctx
,
AVFrame
*
mainpic
,
static
int
do_blend
(
FFFrameSync
*
fs
)
const
AVFrame
*
second
)
{
{
AVFilterContext
*
ctx
=
fs
->
parent
;
AVFrame
*
mainpic
,
*
second
;
OverlayContext
*
s
=
ctx
->
priv
;
OverlayContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
int
ret
;
ret
=
ff_framesync2_dualinput_get_writable
(
fs
,
&
mainpic
,
&
second
);
if
(
ret
<
0
)
return
ret
;
if
(
!
second
)
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
mainpic
);
if
(
s
->
eval_mode
==
EVAL_MODE_FRAME
)
{
if
(
s
->
eval_mode
==
EVAL_MODE_FRAME
)
{
int64_t
pos
=
mainpic
->
pkt_pos
;
int64_t
pos
=
mainpic
->
pkt_pos
;
...
@@ -799,39 +815,32 @@ static AVFrame *do_blend(AVFilterContext *ctx, AVFrame *mainpic,
...
@@ -799,39 +815,32 @@ static AVFrame *do_blend(AVFilterContext *ctx, AVFrame *mainpic,
if
(
s
->
x
<
mainpic
->
width
&&
s
->
x
+
second
->
width
>=
0
||
if
(
s
->
x
<
mainpic
->
width
&&
s
->
x
+
second
->
width
>=
0
||
s
->
y
<
mainpic
->
height
&&
s
->
y
+
second
->
height
>=
0
)
s
->
y
<
mainpic
->
height
&&
s
->
y
+
second
->
height
>=
0
)
s
->
blend_image
(
ctx
,
mainpic
,
second
,
s
->
x
,
s
->
y
);
s
->
blend_image
(
ctx
,
mainpic
,
second
,
s
->
x
,
s
->
y
);
return
mainpic
;
return
ff_filter_frame
(
ctx
->
outputs
[
0
],
mainpic
);
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
inpicref
)
{
OverlayContext
*
s
=
inlink
->
dst
->
priv
;
av_log
(
inlink
->
dst
,
AV_LOG_DEBUG
,
"Incoming frame (time:%s) from link #%d
\n
"
,
av_ts2timestr
(
inpicref
->
pts
,
&
inlink
->
time_base
),
FF_INLINK_IDX
(
inlink
));
return
ff_dualinput_filter_frame
(
&
s
->
dinput
,
inlink
,
inpicref
);
}
static
int
request_frame
(
AVFilterLink
*
outlink
)
{
OverlayContext
*
s
=
outlink
->
src
->
priv
;
return
ff_dualinput_request_frame
(
&
s
->
dinput
,
outlink
);
}
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
{
OverlayContext
*
s
=
ctx
->
priv
;
OverlayContext
*
s
=
ctx
->
priv
;
if
(
!
s
->
dinput
.
repeatlast
||
s
->
eof_action
==
EOF_ACTION_PASS
)
{
if
(
!
s
->
opt_
repeatlast
||
s
->
eof_action
==
EOF_ACTION_PASS
)
{
s
->
dinput
.
repeatlast
=
0
;
s
->
opt_
repeatlast
=
0
;
s
->
eof_action
=
EOF_ACTION_PASS
;
s
->
eof_action
=
EOF_ACTION_PASS
;
}
}
if
(
s
->
dinput
.
shortest
||
s
->
eof_action
==
EOF_ACTION_ENDALL
)
{
if
(
s
->
opt_
shortest
||
s
->
eof_action
==
EOF_ACTION_ENDALL
)
{
s
->
dinput
.
shortest
=
1
;
s
->
opt_
shortest
=
1
;
s
->
eof_action
=
EOF_ACTION_ENDALL
;
s
->
eof_action
=
EOF_ACTION_ENDALL
;
}
}
s
->
dinput
.
process
=
do_blend
;
s
->
fs
.
on_event
=
do_blend
;
return
0
;
return
0
;
}
}
static
int
activate
(
AVFilterContext
*
ctx
)
{
OverlayContext
*
s
=
ctx
->
priv
;
return
ff_framesync2_activate
(
&
s
->
fs
);
}
#define OFFSET(x) offsetof(OverlayContext, x)
#define OFFSET(x) offsetof(OverlayContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
...
@@ -847,7 +856,7 @@ static const AVOption overlay_options[] = {
...
@@ -847,7 +856,7 @@ static const AVOption overlay_options[] = {
{
"eval"
,
"specify when to evaluate expressions"
,
OFFSET
(
eval_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
EVAL_MODE_FRAME
},
0
,
EVAL_MODE_NB
-
1
,
FLAGS
,
"eval"
},
{
"eval"
,
"specify when to evaluate expressions"
,
OFFSET
(
eval_mode
),
AV_OPT_TYPE_INT
,
{.
i64
=
EVAL_MODE_FRAME
},
0
,
EVAL_MODE_NB
-
1
,
FLAGS
,
"eval"
},
{
"init"
,
"eval expressions once during initialization"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EVAL_MODE_INIT
},
.
flags
=
FLAGS
,
.
unit
=
"eval"
},
{
"init"
,
"eval expressions once during initialization"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EVAL_MODE_INIT
},
.
flags
=
FLAGS
,
.
unit
=
"eval"
},
{
"frame"
,
"eval expressions per-frame"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EVAL_MODE_FRAME
},
.
flags
=
FLAGS
,
.
unit
=
"eval"
},
{
"frame"
,
"eval expressions per-frame"
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
EVAL_MODE_FRAME
},
.
flags
=
FLAGS
,
.
unit
=
"eval"
},
{
"shortest"
,
"force termination when the shortest input terminates"
,
OFFSET
(
dinput
.
shortest
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"shortest"
,
"force termination when the shortest input terminates"
,
OFFSET
(
opt_
shortest
),
AV_OPT_TYPE_BOOL
,
{
.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"format"
,
"set output format"
,
OFFSET
(
format
),
AV_OPT_TYPE_INT
,
{.
i64
=
OVERLAY_FORMAT_YUV420
},
0
,
OVERLAY_FORMAT_NB
-
1
,
FLAGS
,
"format"
},
{
"format"
,
"set output format"
,
OFFSET
(
format
),
AV_OPT_TYPE_INT
,
{.
i64
=
OVERLAY_FORMAT_YUV420
},
0
,
OVERLAY_FORMAT_NB
-
1
,
FLAGS
,
"format"
},
{
"yuv420"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_YUV420
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"yuv420"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_YUV420
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"yuv422"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_YUV422
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"yuv422"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_YUV422
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
...
@@ -855,7 +864,7 @@ static const AVOption overlay_options[] = {
...
@@ -855,7 +864,7 @@ static const AVOption overlay_options[] = {
{
"rgb"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_RGB
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"rgb"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_RGB
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"gbrp"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_GBRP
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"gbrp"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_GBRP
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"auto"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_AUTO
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"auto"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
OVERLAY_FORMAT_AUTO
},
.
flags
=
FLAGS
,
.
unit
=
"format"
},
{
"repeatlast"
,
"repeat overlay of the last overlay frame"
,
OFFSET
(
dinput
.
repeatlast
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"repeatlast"
,
"repeat overlay of the last overlay frame"
,
OFFSET
(
opt_
repeatlast
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
NULL
}
{
NULL
}
};
};
...
@@ -866,14 +875,11 @@ static const AVFilterPad avfilter_vf_overlay_inputs[] = {
...
@@ -866,14 +875,11 @@ static const AVFilterPad avfilter_vf_overlay_inputs[] = {
.
name
=
"main"
,
.
name
=
"main"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_input_main
,
.
config_props
=
config_input_main
,
.
filter_frame
=
filter_frame
,
.
needs_writable
=
1
,
},
},
{
{
.
name
=
"overlay"
,
.
name
=
"overlay"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_input_overlay
,
.
config_props
=
config_input_overlay
,
.
filter_frame
=
filter_frame
,
},
},
{
NULL
}
{
NULL
}
};
};
...
@@ -883,7 +889,6 @@ static const AVFilterPad avfilter_vf_overlay_outputs[] = {
...
@@ -883,7 +889,6 @@ static const AVFilterPad avfilter_vf_overlay_outputs[] = {
.
name
=
"default"
,
.
name
=
"default"
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_output
,
.
config_props
=
config_output
,
.
request_frame
=
request_frame
,
},
},
{
NULL
}
{
NULL
}
};
};
...
@@ -896,6 +901,7 @@ AVFilter ff_vf_overlay = {
...
@@ -896,6 +901,7 @@ AVFilter ff_vf_overlay = {
.
priv_size
=
sizeof
(
OverlayContext
),
.
priv_size
=
sizeof
(
OverlayContext
),
.
priv_class
=
&
overlay_class
,
.
priv_class
=
&
overlay_class
,
.
query_formats
=
query_formats
,
.
query_formats
=
query_formats
,
.
activate
=
activate
,
.
process_command
=
process_command
,
.
process_command
=
process_command
,
.
inputs
=
avfilter_vf_overlay_inputs
,
.
inputs
=
avfilter_vf_overlay_inputs
,
.
outputs
=
avfilter_vf_overlay_outputs
,
.
outputs
=
avfilter_vf_overlay_outputs
,
...
...
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