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
0ae8df41
Commit
0ae8df41
authored
Jul 17, 2017
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/framesync2: add dualinput helper functions.
parent
6bde475c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
21 deletions
+103
-21
framesync2.c
libavfilter/framesync2.c
+78
-21
framesync2.h
libavfilter/framesync2.h
+25
-0
No files found.
libavfilter/framesync2.c
View file @
0ae8df41
...
...
@@ -46,6 +46,8 @@ enum {
STATE_EOF
,
};
static
int
consume_from_fifos
(
FFFrameSync
*
fs
);
int
ff_framesync2_init
(
FFFrameSync
*
fs
,
AVFilterContext
*
parent
,
unsigned
nb_in
)
{
/* For filters with several outputs, we will not be able to assume which
...
...
@@ -127,30 +129,20 @@ int ff_framesync2_configure(FFFrameSync *fs)
return
0
;
}
static
void
framesync_advance
(
FFFrameSync
*
fs
)
static
int
framesync_advance
(
FFFrameSync
*
fs
)
{
int
latest
;
unsigned
i
;
int64_t
pts
;
int
ret
;
if
(
fs
->
eof
)
return
;
while
(
!
fs
->
frame_ready
)
{
latest
=
-
1
;
for
(
i
=
0
;
i
<
fs
->
nb_in
;
i
++
)
{
if
(
!
fs
->
in
[
i
].
have_next
)
{
if
(
latest
<
0
||
fs
->
in
[
i
].
pts
<
fs
->
in
[
latest
].
pts
)
latest
=
i
;
}
}
if
(
latest
>=
0
)
{
fs
->
in_request
=
latest
;
break
;
}
while
(
!
(
fs
->
frame_ready
||
fs
->
eof
))
{
ret
=
consume_from_fifos
(
fs
);
if
(
ret
<=
0
)
return
ret
;
pts
=
fs
->
in
[
0
].
pts_next
;
for
(
i
=
1
;
i
<
fs
->
nb_in
;
i
++
)
if
(
fs
->
in
[
i
].
pts_next
<
pts
)
pts
=
INT64_MAX
;
for
(
i
=
0
;
i
<
fs
->
nb_in
;
i
++
)
if
(
fs
->
in
[
i
].
have_next
&&
fs
->
in
[
i
].
pts_next
<
pts
)
pts
=
fs
->
in
[
i
].
pts_next
;
if
(
pts
==
INT64_MAX
)
{
framesync_eof
(
fs
);
...
...
@@ -181,6 +173,7 @@ static void framesync_advance(FFFrameSync *fs)
fs
->
frame_ready
=
0
;
fs
->
pts
=
pts
;
}
return
0
;
}
static
int64_t
framesync_pts_extrapolate
(
FFFrameSync
*
fs
,
unsigned
in
,
...
...
@@ -264,7 +257,7 @@ void ff_framesync2_uninit(FFFrameSync *fs)
av_freep
(
&
fs
->
in
);
}
int
ff_framesync2_activate
(
FFFrameSync
*
fs
)
static
int
consume_from_fifos
(
FFFrameSync
*
fs
)
{
AVFilterContext
*
ctx
=
fs
->
parent
;
AVFrame
*
frame
=
NULL
;
...
...
@@ -300,8 +293,16 @@ int ff_framesync2_activate(FFFrameSync *fs)
ff_inlink_request_frame
(
ctx
->
inputs
[
i
]);
return
0
;
}
return
1
;
}
framesync_advance
(
fs
);
int
ff_framesync2_activate
(
FFFrameSync
*
fs
)
{
int
ret
;
ret
=
framesync_advance
(
fs
);
if
(
ret
<
0
)
return
ret
;
if
(
fs
->
eof
||
!
fs
->
frame_ready
)
return
0
;
ret
=
fs
->
on_event
(
fs
);
...
...
@@ -311,3 +312,59 @@ int ff_framesync2_activate(FFFrameSync *fs)
return
0
;
}
int
ff_framesync2_init_dualinput
(
FFFrameSync
*
fs
,
AVFilterContext
*
parent
)
{
int
ret
;
ret
=
ff_framesync2_init
(
fs
,
parent
,
2
);
if
(
ret
<
0
)
return
ret
;
fs
->
in
[
0
].
time_base
=
parent
->
inputs
[
0
]
->
time_base
;
fs
->
in
[
1
].
time_base
=
parent
->
inputs
[
1
]
->
time_base
;
fs
->
in
[
0
].
sync
=
2
;
fs
->
in
[
0
].
before
=
EXT_STOP
;
fs
->
in
[
0
].
after
=
EXT_INFINITY
;
fs
->
in
[
1
].
sync
=
1
;
fs
->
in
[
1
].
before
=
EXT_NULL
;
fs
->
in
[
1
].
after
=
EXT_INFINITY
;
return
0
;
}
int
ff_framesync2_dualinput_get
(
FFFrameSync
*
fs
,
AVFrame
**
f0
,
AVFrame
**
f1
)
{
AVFilterContext
*
ctx
=
fs
->
parent
;
AVFrame
*
mainpic
=
NULL
,
*
secondpic
=
NULL
;
int
ret
=
0
;
if
((
ret
=
ff_framesync2_get_frame
(
fs
,
0
,
&
mainpic
,
1
))
<
0
||
(
ret
=
ff_framesync2_get_frame
(
fs
,
1
,
&
secondpic
,
0
))
<
0
)
{
av_frame_free
(
&
mainpic
);
return
ret
;
}
if
(
ret
<
0
)
return
ret
;
av_assert0
(
mainpic
);
mainpic
->
pts
=
av_rescale_q
(
fs
->
pts
,
fs
->
time_base
,
ctx
->
outputs
[
0
]
->
time_base
);
if
(
ctx
->
is_disabled
)
secondpic
=
NULL
;
*
f0
=
mainpic
;
*
f1
=
secondpic
;
return
0
;
}
int
ff_framesync2_dualinput_get_writable
(
FFFrameSync
*
fs
,
AVFrame
**
f0
,
AVFrame
**
f1
)
{
int
ret
;
ret
=
ff_framesync2_dualinput_get
(
fs
,
f0
,
f1
);
if
(
ret
<
0
)
return
ret
;
ret
=
ff_inlink_make_frame_writable
(
fs
->
parent
->
inputs
[
0
],
f0
);
if
(
ret
<
0
)
{
av_frame_free
(
f0
);
av_frame_free
(
f1
);
return
ret
;
}
return
0
;
}
libavfilter/framesync2.h
View file @
0ae8df41
...
...
@@ -245,4 +245,29 @@ int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
*/
int
ff_framesync2_activate
(
FFFrameSync
*
fs
);
/**
* Initialize a frame sync structure for dualinput.
*
* Compared to generic framesync, dualinput assumes the first input is the
* main one and the filtering is performed on it. The first input will be
* the only one with sync set and generic timeline support will just pass it
* unchanged when disabled.
*
* Equivalent to ff_framesync2_init(fs, parent, 2) then setting the time
* base, sync and ext modes on the inputs.
*/
int
ff_framesync2_init_dualinput
(
FFFrameSync
*
fs
,
AVFilterContext
*
parent
);
/**
* @param f0 used to return the main frame
* @param f1 used to return the second frame, or NULL if disabled
* @return >=0 for success or AVERROR code
*/
int
ff_framesync2_dualinput_get
(
FFFrameSync
*
fs
,
AVFrame
**
f0
,
AVFrame
**
f1
);
/**
* Same as ff_framesync2_dualinput_get(), but make sure that f0 is writable.
*/
int
ff_framesync2_dualinput_get_writable
(
FFFrameSync
*
fs
,
AVFrame
**
f0
,
AVFrame
**
f1
);
#endif
/* AVFILTER_FRAMESYNC2_H */
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