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
6770fa4d
Commit
6770fa4d
authored
Sep 06, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/fieldorder: work with non writtable frames too
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
33dacda4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
14 deletions
+32
-14
vf_fieldorder.c
libavfilter/vf_fieldorder.c
+32
-14
No files found.
libavfilter/vf_fieldorder.c
View file @
6770fa4d
...
...
@@ -80,21 +80,35 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
AVFilterContext
*
ctx
=
inlink
->
dst
;
FieldOrderContext
*
s
=
ctx
->
priv
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
int
h
,
plane
,
line_step
,
line_size
,
line
;
uint8_t
*
data
;
int
h
,
plane
,
src_line_step
,
dst_line_step
,
line_size
,
line
;
uint8_t
*
dst
,
*
src
;
AVFrame
*
out
;
if
(
!
frame
->
interlaced_frame
||
frame
->
top_field_first
==
s
->
dst_tff
)
return
ff_filter_frame
(
outlink
,
frame
);
if
(
av_frame_is_writable
(
frame
))
{
out
=
frame
;
}
else
{
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
av_frame_free
(
&
frame
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
frame
);
}
av_dlog
(
ctx
,
"picture will move %s one line
\n
"
,
s
->
dst_tff
?
"up"
:
"down"
);
h
=
frame
->
height
;
for
(
plane
=
0
;
plane
<
4
&&
frame
->
data
[
plane
]
&&
frame
->
linesize
[
plane
];
plane
++
)
{
line_step
=
frame
->
linesize
[
plane
];
dst_line_step
=
out
->
linesize
[
plane
];
src_line_step
=
frame
->
linesize
[
plane
];
line_size
=
s
->
line_size
[
plane
];
data
=
frame
->
data
[
plane
];
dst
=
out
->
data
[
plane
];
src
=
frame
->
data
[
plane
];
if
(
s
->
dst_tff
)
{
/** Move every line up one line, working from
* the top to the bottom of the frame.
...
...
@@ -103,11 +117,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
* penultimate line from that field. */
for
(
line
=
0
;
line
<
h
;
line
++
)
{
if
(
1
+
line
<
frame
->
height
)
{
memcpy
(
d
ata
,
data
+
line_step
,
line_size
);
memcpy
(
d
st
,
src
+
src_
line_step
,
line_size
);
}
else
{
memcpy
(
d
ata
,
data
-
line_step
-
line_step
,
line_size
);
memcpy
(
d
st
,
src
-
2
*
src_
line_step
,
line_size
);
}
data
+=
line_step
;
dst
+=
dst_line_step
;
src
+=
src_line_step
;
}
}
else
{
/** Move every line down one line, working from
...
...
@@ -115,20 +130,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
* The original bottom line is lost.
* The new first line is created as a copy of the
* second line from that field. */
data
+=
(
h
-
1
)
*
line_step
;
dst
+=
(
h
-
1
)
*
dst_line_step
;
src
+=
(
h
-
1
)
*
src_line_step
;
for
(
line
=
h
-
1
;
line
>=
0
;
line
--
)
{
if
(
line
>
0
)
{
memcpy
(
d
ata
,
data
-
line_step
,
line_size
);
memcpy
(
d
st
,
src
-
src_
line_step
,
line_size
);
}
else
{
memcpy
(
d
ata
,
data
+
line_step
+
line_step
,
line_size
);
memcpy
(
d
st
,
src
+
2
*
src_
line_step
,
line_size
);
}
data
-=
line_step
;
dst
-=
dst_line_step
;
src
-=
src_line_step
;
}
}
}
frame
->
top_field_first
=
s
->
dst_tff
;
out
->
top_field_first
=
s
->
dst_tff
;
return
ff_filter_frame
(
outlink
,
frame
);
if
(
frame
!=
out
)
av_frame_free
(
&
frame
);
return
ff_filter_frame
(
outlink
,
out
);
}
#define OFFSET(x) offsetof(FieldOrderContext, x)
...
...
@@ -149,7 +168,6 @@ static const AVFilterPad avfilter_vf_fieldorder_inputs[] = {
.
type
=
AVMEDIA_TYPE_VIDEO
,
.
config_props
=
config_input
,
.
filter_frame
=
filter_frame
,
.
needs_writable
=
1
,
},
{
NULL
}
};
...
...
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