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
87577f55
Commit
87577f55
authored
Jan 28, 2015
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_telecine: use the name 's' for the pointer to the private context
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
0d37ca15
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
55 deletions
+55
-55
vf_telecine.c
libavfilter/vf_telecine.c
+55
-55
No files found.
libavfilter/vf_telecine.c
View file @
87577f55
...
...
@@ -69,29 +69,29 @@ AVFILTER_DEFINE_CLASS(telecine);
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
{
TelecineContext
*
tc
=
ctx
->
priv
;
TelecineContext
*
s
=
ctx
->
priv
;
const
char
*
p
;
int
max
=
0
;
if
(
!
strlen
(
tc
->
pattern
))
{
if
(
!
strlen
(
s
->
pattern
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"No pattern provided.
\n
"
);
return
AVERROR_INVALIDDATA
;
}
for
(
p
=
tc
->
pattern
;
*
p
;
p
++
)
{
for
(
p
=
s
->
pattern
;
*
p
;
p
++
)
{
if
(
!
av_isdigit
(
*
p
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Provided pattern includes non-numeric characters.
\n
"
);
return
AVERROR_INVALIDDATA
;
}
max
=
FFMAX
(
*
p
-
'0'
,
max
);
tc
->
pts
.
num
+=
2
;
tc
->
pts
.
den
+=
*
p
-
'0'
;
s
->
pts
.
num
+=
2
;
s
->
pts
.
den
+=
*
p
-
'0'
;
}
tc
->
out_cnt
=
(
max
+
1
)
/
2
;
s
->
out_cnt
=
(
max
+
1
)
/
2
;
av_log
(
ctx
,
AV_LOG_INFO
,
"Telecine pattern %s yields up to %d frames per frame, pts advance factor: %d/%d
\n
"
,
tc
->
pattern
,
tc
->
out_cnt
,
tc
->
pts
.
num
,
tc
->
pts
.
den
);
s
->
pattern
,
s
->
out_cnt
,
s
->
pts
.
num
,
s
->
pts
.
den
);
return
0
;
}
...
...
@@ -115,26 +115,26 @@ static int query_formats(AVFilterContext *ctx)
static
int
config_input
(
AVFilterLink
*
inlink
)
{
TelecineContext
*
tc
=
inlink
->
dst
->
priv
;
TelecineContext
*
s
=
inlink
->
dst
->
priv
;
const
AVPixFmtDescriptor
*
desc
=
av_pix_fmt_desc_get
(
inlink
->
format
);
int
i
,
ret
;
tc
->
temp
=
ff_get_video_buffer
(
inlink
,
inlink
->
w
,
inlink
->
h
);
if
(
!
tc
->
temp
)
s
->
temp
=
ff_get_video_buffer
(
inlink
,
inlink
->
w
,
inlink
->
h
);
if
(
!
s
->
temp
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
tc
->
out_cnt
;
i
++
)
{
tc
->
frame
[
i
]
=
ff_get_video_buffer
(
inlink
,
inlink
->
w
,
inlink
->
h
);
if
(
!
tc
->
frame
[
i
])
for
(
i
=
0
;
i
<
s
->
out_cnt
;
i
++
)
{
s
->
frame
[
i
]
=
ff_get_video_buffer
(
inlink
,
inlink
->
w
,
inlink
->
h
);
if
(
!
s
->
frame
[
i
])
return
AVERROR
(
ENOMEM
);
}
if
((
ret
=
av_image_fill_linesizes
(
tc
->
stride
,
inlink
->
format
,
inlink
->
w
))
<
0
)
if
((
ret
=
av_image_fill_linesizes
(
s
->
stride
,
inlink
->
format
,
inlink
->
w
))
<
0
)
return
ret
;
tc
->
planeheight
[
1
]
=
tc
->
planeheight
[
2
]
=
FF_CEIL_RSHIFT
(
inlink
->
h
,
desc
->
log2_chroma_h
);
tc
->
planeheight
[
0
]
=
tc
->
planeheight
[
3
]
=
inlink
->
h
;
s
->
planeheight
[
1
]
=
s
->
planeheight
[
2
]
=
FF_CEIL_RSHIFT
(
inlink
->
h
,
desc
->
log2_chroma_h
);
s
->
planeheight
[
0
]
=
s
->
planeheight
[
3
]
=
inlink
->
h
;
tc
->
nb_planes
=
av_pix_fmt_count_planes
(
inlink
->
format
);
s
->
nb_planes
=
av_pix_fmt_count_planes
(
inlink
->
format
);
return
0
;
}
...
...
@@ -142,7 +142,7 @@ static int config_input(AVFilterLink *inlink)
static
int
config_output
(
AVFilterLink
*
outlink
)
{
AVFilterContext
*
ctx
=
outlink
->
src
;
TelecineContext
*
tc
=
ctx
->
priv
;
TelecineContext
*
s
=
ctx
->
priv
;
const
AVFilterLink
*
inlink
=
ctx
->
inputs
[
0
];
AVRational
fps
=
inlink
->
frame_rate
;
...
...
@@ -151,17 +151,17 @@ static int config_output(AVFilterLink *outlink)
"current rate of %d/%d is invalid
\n
"
,
fps
.
num
,
fps
.
den
);
return
AVERROR
(
EINVAL
);
}
fps
=
av_mul_q
(
fps
,
av_inv_q
(
tc
->
pts
));
fps
=
av_mul_q
(
fps
,
av_inv_q
(
s
->
pts
));
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"FPS: %d/%d -> %d/%d
\n
"
,
inlink
->
frame_rate
.
num
,
inlink
->
frame_rate
.
den
,
fps
.
num
,
fps
.
den
);
outlink
->
flags
|=
FF_LINK_FLAG_REQUEST_LOOP
;
outlink
->
frame_rate
=
fps
;
outlink
->
time_base
=
av_mul_q
(
inlink
->
time_base
,
tc
->
pts
);
outlink
->
time_base
=
av_mul_q
(
inlink
->
time_base
,
s
->
pts
);
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"TB: %d/%d -> %d/%d
\n
"
,
inlink
->
time_base
.
num
,
inlink
->
time_base
.
den
,
outlink
->
time_base
.
num
,
outlink
->
time_base
.
den
);
tc
->
ts_unit
=
av_q2d
(
av_inv_q
(
av_mul_q
(
fps
,
outlink
->
time_base
)));
s
->
ts_unit
=
av_q2d
(
av_inv_q
(
av_mul_q
(
fps
,
outlink
->
time_base
)));
return
0
;
}
...
...
@@ -170,72 +170,72 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
TelecineContext
*
tc
=
ctx
->
priv
;
TelecineContext
*
s
=
ctx
->
priv
;
int
i
,
len
,
ret
=
0
,
nout
=
0
;
len
=
tc
->
pattern
[
tc
->
pattern_pos
]
-
'0'
;
len
=
s
->
pattern
[
s
->
pattern_pos
]
-
'0'
;
tc
->
pattern_pos
++
;
if
(
!
tc
->
pattern
[
tc
->
pattern_pos
])
tc
->
pattern_pos
=
0
;
s
->
pattern_pos
++
;
if
(
!
s
->
pattern
[
s
->
pattern_pos
])
s
->
pattern_pos
=
0
;
if
(
!
len
)
{
// do not output any field from this frame
av_frame_free
(
&
inpicref
);
return
0
;
}
if
(
tc
->
occupied
)
{
for
(
i
=
0
;
i
<
tc
->
nb_planes
;
i
++
)
{
if
(
s
->
occupied
)
{
for
(
i
=
0
;
i
<
s
->
nb_planes
;
i
++
)
{
// fill in the EARLIER field from the buffered pic
av_image_copy_plane
(
tc
->
frame
[
nout
]
->
data
[
i
]
+
tc
->
frame
[
nout
]
->
linesize
[
i
]
*
tc
->
first_field
,
tc
->
frame
[
nout
]
->
linesize
[
i
]
*
2
,
tc
->
temp
->
data
[
i
]
+
tc
->
temp
->
linesize
[
i
]
*
tc
->
first_field
,
tc
->
temp
->
linesize
[
i
]
*
2
,
tc
->
stride
[
i
],
(
tc
->
planeheight
[
i
]
-
tc
->
first_field
+
1
)
/
2
);
av_image_copy_plane
(
s
->
frame
[
nout
]
->
data
[
i
]
+
s
->
frame
[
nout
]
->
linesize
[
i
]
*
s
->
first_field
,
s
->
frame
[
nout
]
->
linesize
[
i
]
*
2
,
s
->
temp
->
data
[
i
]
+
s
->
temp
->
linesize
[
i
]
*
s
->
first_field
,
s
->
temp
->
linesize
[
i
]
*
2
,
s
->
stride
[
i
],
(
s
->
planeheight
[
i
]
-
s
->
first_field
+
1
)
/
2
);
// fill in the LATER field from the new pic
av_image_copy_plane
(
tc
->
frame
[
nout
]
->
data
[
i
]
+
tc
->
frame
[
nout
]
->
linesize
[
i
]
*
!
tc
->
first_field
,
tc
->
frame
[
nout
]
->
linesize
[
i
]
*
2
,
inpicref
->
data
[
i
]
+
inpicref
->
linesize
[
i
]
*
!
tc
->
first_field
,
av_image_copy_plane
(
s
->
frame
[
nout
]
->
data
[
i
]
+
s
->
frame
[
nout
]
->
linesize
[
i
]
*
!
s
->
first_field
,
s
->
frame
[
nout
]
->
linesize
[
i
]
*
2
,
inpicref
->
data
[
i
]
+
inpicref
->
linesize
[
i
]
*
!
s
->
first_field
,
inpicref
->
linesize
[
i
]
*
2
,
tc
->
stride
[
i
],
(
tc
->
planeheight
[
i
]
-
!
tc
->
first_field
+
1
)
/
2
);
s
->
stride
[
i
],
(
s
->
planeheight
[
i
]
-
!
s
->
first_field
+
1
)
/
2
);
}
nout
++
;
len
--
;
tc
->
occupied
=
0
;
s
->
occupied
=
0
;
}
while
(
len
>=
2
)
{
// output THIS image as-is
for
(
i
=
0
;
i
<
tc
->
nb_planes
;
i
++
)
av_image_copy_plane
(
tc
->
frame
[
nout
]
->
data
[
i
],
tc
->
frame
[
nout
]
->
linesize
[
i
],
for
(
i
=
0
;
i
<
s
->
nb_planes
;
i
++
)
av_image_copy_plane
(
s
->
frame
[
nout
]
->
data
[
i
],
s
->
frame
[
nout
]
->
linesize
[
i
],
inpicref
->
data
[
i
],
inpicref
->
linesize
[
i
],
tc
->
stride
[
i
],
tc
->
planeheight
[
i
]);
s
->
stride
[
i
],
s
->
planeheight
[
i
]);
nout
++
;
len
-=
2
;
}
if
(
len
>=
1
)
{
// copy THIS image to the buffer, we need it later
for
(
i
=
0
;
i
<
tc
->
nb_planes
;
i
++
)
av_image_copy_plane
(
tc
->
temp
->
data
[
i
],
tc
->
temp
->
linesize
[
i
],
for
(
i
=
0
;
i
<
s
->
nb_planes
;
i
++
)
av_image_copy_plane
(
s
->
temp
->
data
[
i
],
s
->
temp
->
linesize
[
i
],
inpicref
->
data
[
i
],
inpicref
->
linesize
[
i
],
tc
->
stride
[
i
],
tc
->
planeheight
[
i
]);
tc
->
occupied
=
1
;
s
->
stride
[
i
],
s
->
planeheight
[
i
]);
s
->
occupied
=
1
;
}
for
(
i
=
0
;
i
<
nout
;
i
++
)
{
AVFrame
*
frame
=
av_frame_clone
(
tc
->
frame
[
i
]);
AVFrame
*
frame
=
av_frame_clone
(
s
->
frame
[
i
]);
if
(
!
frame
)
{
av_frame_free
(
&
inpicref
);
return
AVERROR
(
ENOMEM
);
}
frame
->
pts
=
outlink
->
frame_count
*
tc
->
ts_unit
;
frame
->
pts
=
outlink
->
frame_count
*
s
->
ts_unit
;
ret
=
ff_filter_frame
(
outlink
,
frame
);
}
av_frame_free
(
&
inpicref
);
...
...
@@ -245,12 +245,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
TelecineContext
*
tc
=
ctx
->
priv
;
TelecineContext
*
s
=
ctx
->
priv
;
int
i
;
av_frame_free
(
&
tc
->
temp
);
for
(
i
=
0
;
i
<
tc
->
out_cnt
;
i
++
)
av_frame_free
(
&
tc
->
frame
[
i
]);
av_frame_free
(
&
s
->
temp
);
for
(
i
=
0
;
i
<
s
->
out_cnt
;
i
++
)
av_frame_free
(
&
s
->
frame
[
i
]);
}
static
const
AVFilterPad
telecine_inputs
[]
=
{
...
...
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