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
e3212bfd
Commit
e3212bfd
authored
Aug 12, 2014
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfitler/vf_perspective: support slice threading
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
1e519b9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
18 deletions
+53
-18
vf_perspective.c
libavfilter/vf_perspective.c
+53
-18
No files found.
libavfilter/vf_perspective.c
View file @
e3212bfd
...
...
@@ -47,10 +47,8 @@ typedef struct PerspectiveContext {
int
hsub
,
vsub
;
int
nb_planes
;
void
(
*
perspective
)(
struct
PerspectiveContext
*
s
,
uint8_t
*
dst
,
int
dst_linesize
,
uint8_t
*
src
,
int
src_linesize
,
int
w
,
int
h
,
int
hsub
,
int
vsub
);
int
(
*
perspective
)(
AVFilterContext
*
ctx
,
void
*
arg
,
int
job
,
int
nb_jobs
);
}
PerspectiveContext
;
#define OFFSET(x) offsetof(PerspectiveContext, x)
...
...
@@ -193,15 +191,34 @@ static int config_input(AVFilterLink *inlink)
return
0
;
}
static
void
resample_cubic
(
PerspectiveContext
*
s
,
uint8_t
*
dst
,
int
dst_linesize
,
uint8_t
*
src
,
int
src_linesize
,
int
w
,
int
h
,
int
hsub
,
int
vsub
)
typedef
struct
ThreadData
{
uint8_t
*
dst
;
int
dst_linesize
;
uint8_t
*
src
;
int
src_linesize
;
int
w
,
h
;
int
hsub
,
vsub
;
}
ThreadData
;
static
int
resample_cubic
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
job
,
int
nb_jobs
)
{
PerspectiveContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
uint8_t
*
dst
=
td
->
dst
;
int
dst_linesize
=
td
->
dst_linesize
;
uint8_t
*
src
=
td
->
src
;
int
src_linesize
=
td
->
src_linesize
;
int
w
=
td
->
w
;
int
h
=
td
->
h
;
int
hsub
=
td
->
hsub
;
int
vsub
=
td
->
vsub
;
int
start
=
(
h
*
job
)
/
nb_jobs
;
int
end
=
(
h
*
(
job
+
1
))
/
nb_jobs
;
const
int
linesize
=
s
->
linesize
[
0
];
int
x
,
y
;
for
(
y
=
0
;
y
<
h
;
y
++
)
{
for
(
y
=
start
;
y
<
end
;
y
++
)
{
int
sy
=
y
<<
vsub
;
for
(
x
=
0
;
x
<
w
;
x
++
)
{
int
u
,
v
,
subU
,
subV
,
sum
,
sx
;
...
...
@@ -259,17 +276,28 @@ static void resample_cubic(PerspectiveContext *s,
dst
[
x
+
y
*
dst_linesize
]
=
sum
;
}
}
return
0
;
}
static
void
resample_linear
(
PerspectiveContext
*
s
,
uint8_t
*
dst
,
int
dst_linesize
,
uint8_t
*
src
,
int
src_linesize
,
int
w
,
int
h
,
int
hsub
,
int
vsub
)
static
int
resample_linear
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
job
,
int
nb_jobs
)
{
PerspectiveContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
uint8_t
*
dst
=
td
->
dst
;
int
dst_linesize
=
td
->
dst_linesize
;
uint8_t
*
src
=
td
->
src
;
int
src_linesize
=
td
->
src_linesize
;
int
w
=
td
->
w
;
int
h
=
td
->
h
;
int
hsub
=
td
->
hsub
;
int
vsub
=
td
->
vsub
;
int
start
=
(
h
*
job
)
/
nb_jobs
;
int
end
=
(
h
*
(
job
+
1
))
/
nb_jobs
;
const
int
linesize
=
s
->
linesize
[
0
];
int
x
,
y
;
for
(
y
=
0
;
y
<
h
;
y
++
){
for
(
y
=
start
;
y
<
end
;
y
++
){
int
sy
=
y
<<
vsub
;
for
(
x
=
0
;
x
<
w
;
x
++
){
int
u
,
v
,
subU
,
subV
,
sum
,
sx
,
index
,
subUI
,
subVI
;
...
...
@@ -323,6 +351,7 @@ static void resample_linear(PerspectiveContext *s,
dst
[
x
+
y
*
dst_linesize
]
=
sum
;
}
}
return
0
;
}
static
av_cold
int
init
(
AVFilterContext
*
ctx
)
...
...
@@ -355,9 +384,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
for
(
plane
=
0
;
plane
<
s
->
nb_planes
;
plane
++
)
{
int
hsub
=
plane
==
1
||
plane
==
2
?
s
->
hsub
:
0
;
int
vsub
=
plane
==
1
||
plane
==
2
?
s
->
vsub
:
0
;
s
->
perspective
(
s
,
out
->
data
[
plane
],
out
->
linesize
[
plane
],
frame
->
data
[
plane
],
frame
->
linesize
[
plane
],
s
->
linesize
[
plane
],
s
->
height
[
plane
],
hsub
,
vsub
);
ThreadData
td
=
{.
dst
=
out
->
data
[
plane
],
.
dst_linesize
=
out
->
linesize
[
plane
],
.
src
=
frame
->
data
[
plane
],
.
src_linesize
=
frame
->
linesize
[
plane
],
.
w
=
s
->
linesize
[
plane
],
.
h
=
s
->
height
[
plane
],
.
hsub
=
hsub
,
.
vsub
=
vsub
};
ctx
->
internal
->
execute
(
ctx
,
s
->
perspective
,
&
td
,
NULL
,
FFMIN
(
td
.
h
,
ctx
->
graph
->
nb_threads
));
}
av_frame_free
(
&
frame
);
...
...
@@ -399,5 +434,5 @@ AVFilter ff_vf_perspective = {
.
inputs
=
perspective_inputs
,
.
outputs
=
perspective_outputs
,
.
priv_class
=
&
perspective_class
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
,
.
flags
=
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
|
AVFILTER_FLAG_SLICE_THREADS
,
};
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