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
8a994b74
Commit
8a994b74
authored
May 11, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_fade: support slice threading
parent
cb79881b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
24 deletions
+56
-24
vf_fade.c
libavfilter/vf_fade.c
+56
-24
No files found.
libavfilter/vf_fade.c
View file @
8a994b74
...
@@ -92,39 +92,70 @@ static int config_props(AVFilterLink *inlink)
...
@@ -92,39 +92,70 @@ static int config_props(AVFilterLink *inlink)
return
0
;
return
0
;
}
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
static
int
filter_slice_luma
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
{
FadeContext
*
s
=
inlink
->
dst
->
priv
;
FadeContext
*
s
=
ctx
->
priv
;
uint8_t
*
p
;
AVFrame
*
frame
=
arg
;
int
slice_h
=
frame
->
height
/
nb_jobs
;
int
slice_start
=
jobnr
*
slice_h
;
int
slice_end
=
(
jobnr
==
nb_jobs
-
1
)
?
frame
->
height
:
(
jobnr
+
1
)
*
slice_h
;
int
i
,
j
;
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
uint8_t
*
p
=
frame
->
data
[
0
]
+
i
*
frame
->
linesize
[
0
];
for
(
j
=
0
;
j
<
frame
->
width
*
s
->
bpp
;
j
++
)
{
/* s->factor is using 16 lower-order bits for decimal
* places. 32768 = 1 << 15, it is an integer representation
* of 0.5 and is for rounding. */
*
p
=
(
*
p
*
s
->
factor
+
32768
)
>>
16
;
p
++
;
}
}
return
0
;
}
static
int
filter_slice_chroma
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
FadeContext
*
s
=
ctx
->
priv
;
AVFrame
*
frame
=
arg
;
int
slice_h
=
FFALIGN
(
frame
->
height
/
nb_jobs
,
1
<<
s
->
vsub
);
int
slice_start
=
jobnr
*
slice_h
;
int
slice_end
=
(
jobnr
==
nb_jobs
-
1
)
?
frame
->
height
:
(
jobnr
+
1
)
*
slice_h
;
int
i
,
j
,
plane
;
int
i
,
j
,
plane
;
if
(
s
->
factor
<
UINT16_MAX
)
{
for
(
plane
=
1
;
plane
<
3
;
plane
++
)
{
/* luma or rgb plane */
for
(
i
=
slice_start
;
i
<
slice_end
;
i
++
)
{
for
(
i
=
0
;
i
<
frame
->
height
;
i
++
)
{
uint8_t
*
p
=
frame
->
data
[
plane
]
+
(
i
>>
s
->
vsub
)
*
frame
->
linesize
[
plane
];
p
=
frame
->
data
[
0
]
+
i
*
frame
->
linesize
[
0
];
for
(
j
=
0
;
j
<
frame
->
width
>>
s
->
hsub
;
j
++
)
{
for
(
j
=
0
;
j
<
inlink
->
w
*
s
->
bpp
;
j
++
)
{
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
/* s->factor is using 16 lower-order bits for decimal
* representation of 128.5. The .5 is for rounding
* places. 32768 = 1 << 15, it is an integer representation
* purposes. */
* of 0.5 and is for rounding. */
*
p
=
((
*
p
-
128
)
*
s
->
factor
+
8421367
)
>>
16
;
*
p
=
(
*
p
*
s
->
factor
+
32768
)
>>
16
;
p
++
;
p
++
;
}
}
}
}
}
return
0
;
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
{
AVFilterContext
*
ctx
=
inlink
->
dst
;
FadeContext
*
s
=
ctx
->
priv
;
if
(
s
->
factor
<
UINT16_MAX
)
{
/* luma or rgb plane */
ctx
->
internal
->
execute
(
ctx
,
filter_slice_luma
,
frame
,
NULL
,
FFMIN
(
frame
->
height
,
ctx
->
graph
->
nb_threads
));
if
(
frame
->
data
[
1
]
&&
frame
->
data
[
2
])
{
if
(
frame
->
data
[
1
]
&&
frame
->
data
[
2
])
{
/* chroma planes */
/* chroma planes */
for
(
plane
=
1
;
plane
<
3
;
plane
++
)
{
ctx
->
internal
->
execute
(
ctx
,
filter_slice_chroma
,
frame
,
NULL
,
for
(
i
=
0
;
i
<
frame
->
height
;
i
++
)
{
FFMIN
(
frame
->
height
,
ctx
->
graph
->
nb_threads
));
p
=
frame
->
data
[
plane
]
+
(
i
>>
s
->
vsub
)
*
frame
->
linesize
[
plane
];
for
(
j
=
0
;
j
<
inlink
->
w
>>
s
->
hsub
;
j
++
)
{
/* 8421367 = ((128 << 1) + 1) << 15. It is an integer
* representation of 128.5. The .5 is for rounding
* purposes. */
*
p
=
((
*
p
-
128
)
*
s
->
factor
+
8421367
)
>>
16
;
p
++
;
}
}
}
}
}
}
}
...
@@ -187,4 +218,5 @@ AVFilter avfilter_vf_fade = {
...
@@ -187,4 +218,5 @@ AVFilter avfilter_vf_fade = {
.
inputs
=
avfilter_vf_fade_inputs
,
.
inputs
=
avfilter_vf_fade_inputs
,
.
outputs
=
avfilter_vf_fade_outputs
,
.
outputs
=
avfilter_vf_fade_outputs
,
.
flags
=
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