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
86277390
Commit
86277390
authored
Sep 29, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_rotate: support slice threading
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
54197c7a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
61 deletions
+94
-61
vf_rotate.c
libavfilter/vf_rotate.c
+94
-61
No files found.
libavfilter/vf_rotate.c
View file @
86277390
...
...
@@ -77,6 +77,16 @@ typedef struct {
FFDrawColor
color
;
}
RotContext
;
typedef
struct
ThreadData
{
AVFrame
*
in
,
*
out
;
int
inw
,
inh
;
int
outw
,
outh
;
int
plane
;
int
xi
,
yi
;
int
xprime
,
yprime
;
int
c
,
s
;
}
ThreadData
;
#define OFFSET(x) offsetof(RotContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
...
...
@@ -299,53 +309,24 @@ static uint8_t *interpolate_bilinear(uint8_t *dst_color,
#define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
static
int
filter_
frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
static
int
filter_
slice
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
job
,
int
nb_jobs
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVF
ilterLink
*
outlink
=
ctx
->
outputs
[
0
]
;
AVFrame
*
out
;
ThreadData
*
td
=
arg
;
AVF
rame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
RotContext
*
rot
=
ctx
->
priv
;
int
angle_int
,
s
,
c
,
plane
;
double
res
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
rot
->
var_values
[
VAR_N
]
=
inlink
->
frame_count
;
rot
->
var_values
[
VAR_T
]
=
TS2T
(
in
->
pts
,
inlink
->
time_base
);
rot
->
angle
=
res
=
av_expr_eval
(
rot
->
angle_expr
,
rot
->
var_values
,
rot
);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"n:%f time:%f angle:%f/PI
\n
"
,
rot
->
var_values
[
VAR_N
],
rot
->
var_values
[
VAR_T
],
rot
->
angle
/
M_PI
);
angle_int
=
res
*
FIXP
;
s
=
int_sin
(
angle_int
);
c
=
int_sin
(
angle_int
+
INT_PI
/
2
);
/* fill background */
if
(
rot
->
fillcolor_enable
)
ff_fill_rectangle
(
&
rot
->
draw
,
&
rot
->
color
,
out
->
data
,
out
->
linesize
,
0
,
0
,
outlink
->
w
,
outlink
->
h
);
for
(
plane
=
0
;
plane
<
rot
->
nb_planes
;
plane
++
)
{
int
hsub
=
plane
==
1
||
plane
==
2
?
rot
->
hsub
:
0
;
int
vsub
=
plane
==
1
||
plane
==
2
?
rot
->
vsub
:
0
;
int
inw
=
FF_CEIL_RSHIFT
(
inlink
->
w
,
hsub
);
int
inh
=
FF_CEIL_RSHIFT
(
inlink
->
h
,
vsub
);
int
outw
=
FF_CEIL_RSHIFT
(
outlink
->
w
,
hsub
);
int
outh
=
FF_CEIL_RSHIFT
(
outlink
->
h
,
vsub
);
const
int
xi
=
-
outw
/
2
*
c
;
const
int
yi
=
outw
/
2
*
s
;
int
xprime
=
-
outh
/
2
*
s
;
int
yprime
=
-
outh
/
2
*
c
;
const
int
outw
=
td
->
outw
,
outh
=
td
->
outh
;
const
int
inw
=
td
->
inw
,
inh
=
td
->
inh
;
const
int
plane
=
td
->
plane
;
const
int
xi
=
td
->
xi
,
yi
=
td
->
yi
;
const
int
c
=
td
->
c
,
s
=
td
->
s
;
const
int
start
=
(
outh
*
job
)
/
nb_jobs
;
const
int
end
=
(
outh
*
(
job
+
1
))
/
nb_jobs
;
int
xprime
=
td
->
xprime
+
start
*
s
;
int
yprime
=
td
->
yprime
+
start
*
c
;
int
i
,
j
,
x
,
y
;
for
(
j
=
0
;
j
<
outh
;
j
++
)
{
for
(
j
=
start
;
j
<
end
;
j
++
)
{
x
=
xprime
+
xi
+
FIXP
*
inw
/
2
;
y
=
yprime
+
yi
+
FIXP
*
inh
/
2
;
...
...
@@ -394,6 +375,58 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
xprime
+=
s
;
yprime
+=
c
;
}
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
in
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
AVFilterLink
*
outlink
=
ctx
->
outputs
[
0
];
AVFrame
*
out
;
RotContext
*
rot
=
ctx
->
priv
;
int
angle_int
,
s
,
c
,
plane
;
double
res
;
out
=
ff_get_video_buffer
(
outlink
,
outlink
->
w
,
outlink
->
h
);
if
(
!
out
)
{
av_frame_free
(
&
in
);
return
AVERROR
(
ENOMEM
);
}
av_frame_copy_props
(
out
,
in
);
rot
->
var_values
[
VAR_N
]
=
inlink
->
frame_count
;
rot
->
var_values
[
VAR_T
]
=
TS2T
(
in
->
pts
,
inlink
->
time_base
);
rot
->
angle
=
res
=
av_expr_eval
(
rot
->
angle_expr
,
rot
->
var_values
,
rot
);
av_log
(
ctx
,
AV_LOG_DEBUG
,
"n:%f time:%f angle:%f/PI
\n
"
,
rot
->
var_values
[
VAR_N
],
rot
->
var_values
[
VAR_T
],
rot
->
angle
/
M_PI
);
angle_int
=
res
*
FIXP
;
s
=
int_sin
(
angle_int
);
c
=
int_sin
(
angle_int
+
INT_PI
/
2
);
/* fill background */
if
(
rot
->
fillcolor_enable
)
ff_fill_rectangle
(
&
rot
->
draw
,
&
rot
->
color
,
out
->
data
,
out
->
linesize
,
0
,
0
,
outlink
->
w
,
outlink
->
h
);
for
(
plane
=
0
;
plane
<
rot
->
nb_planes
;
plane
++
)
{
int
hsub
=
plane
==
1
||
plane
==
2
?
rot
->
hsub
:
0
;
int
vsub
=
plane
==
1
||
plane
==
2
?
rot
->
vsub
:
0
;
const
int
outw
=
FF_CEIL_RSHIFT
(
outlink
->
w
,
hsub
);
const
int
outh
=
FF_CEIL_RSHIFT
(
outlink
->
h
,
vsub
);
ThreadData
td
=
{
.
in
=
in
,
.
out
=
out
,
.
inw
=
FF_CEIL_RSHIFT
(
inlink
->
w
,
hsub
),
.
inh
=
FF_CEIL_RSHIFT
(
inlink
->
h
,
vsub
),
.
outh
=
outh
,
.
outw
=
outw
,
.
xi
=
-
outw
/
2
*
c
,
.
yi
=
outw
/
2
*
s
,
.
xprime
=
-
outh
/
2
*
s
,
.
yprime
=
-
outh
/
2
*
c
,
.
plane
=
plane
,
.
c
=
c
,
.
s
=
s
};
ctx
->
internal
->
execute
(
ctx
,
filter_slice
,
&
td
,
NULL
,
FFMIN
(
outh
,
ctx
->
graph
->
nb_threads
));
}
av_frame_free
(
&
in
);
...
...
@@ -452,5 +485,5 @@ AVFilter avfilter_vf_rotate = {
.
inputs
=
rotate_inputs
,
.
outputs
=
rotate_outputs
,
.
priv_class
=
&
rotate_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