FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavfilter
dualinput.c
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with FFmpeg; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#include "
dualinput.h
"
20
#include "
libavutil/timestamp.h
"
21
22
static
int
process_frame
(
FFFrameSync
*fs)
23
{
24
AVFilterContext
*ctx = fs->
parent
;
25
FFDualInputContext
*
s
= fs->
opaque
;
26
AVFrame
*mainpic =
NULL
, *secondpic =
NULL
;
27
int
ret
= 0;
28
29
if
((ret =
ff_framesync_get_frame
(&s->
fs
, 0, &mainpic, 1)) < 0 ||
30
(ret =
ff_framesync_get_frame
(&s->
fs
, 1, &secondpic, 0)) < 0) {
31
av_frame_free
(&mainpic);
32
return
ret
;
33
}
34
av_assert0
(mainpic);
35
mainpic->
pts
=
av_rescale_q
(mainpic->
pts
, s->
fs
.
time_base
, ctx->
outputs
[0]->
time_base
);
36
if
(secondpic && !ctx->
is_disabled
)
37
mainpic = s->
process
(ctx, mainpic, secondpic);
38
ret =
ff_filter_frame
(ctx->
outputs
[0], mainpic);
39
av_assert1
(ret !=
AVERROR
(EAGAIN));
40
return
ret
;
41
}
42
43
int
ff_dualinput_init
(
AVFilterContext
*ctx,
FFDualInputContext
*
s
)
44
{
45
FFFrameSyncIn
*
in
= s->
fs
.
in
;
46
47
ff_framesync_init
(&s->
fs
, ctx, 2);
48
s->
fs
.
opaque
=
s
;
49
s->
fs
.
on_event
=
process_frame
;
50
in[0].
time_base
= ctx->
inputs
[0]->
time_base
;
51
in[1].
time_base
= ctx->
inputs
[1]->
time_base
;
52
in[0].
sync
= 2;
53
in[0].
before
=
EXT_STOP
;
54
in[0].
after
=
EXT_INFINITY
;
55
in[1].
sync
= 1;
56
in[1].
before
=
EXT_NULL
;
57
in[1].
after
=
EXT_INFINITY
;
58
59
if
(s->
shortest
)
60
in[0].
after
= in[1].
after
=
EXT_STOP
;
61
if
(!s->
repeatlast
) {
62
in[1].
after
=
EXT_NULL
;
63
in[1].
sync
= 0;
64
}
65
66
return
ff_framesync_configure
(&s->
fs
);
67
}
68
69
int
ff_dualinput_filter_frame
(
FFDualInputContext
*
s
,
70
AVFilterLink
*inlink,
AVFrame
*
in
)
71
{
72
return
ff_framesync_filter_frame
(&s->
fs
, inlink, in);
73
}
74
75
int
ff_dualinput_request_frame
(
FFDualInputContext
*
s
,
AVFilterLink
*outlink)
76
{
77
return
ff_framesync_request_frame
(&s->
fs
, outlink);
78
}
79
80
void
ff_dualinput_uninit
(
FFDualInputContext
*
s
)
81
{
82
ff_framesync_uninit
(&s->
fs
);
83
}
Generated on Sun Mar 8 2015 02:35:05 for FFmpeg by
1.8.2