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
027a53dc
Commit
027a53dc
authored
Oct 01, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_drawbox: reduce code duplication
parent
a650e8c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
vf_drawbox.c
libavfilter/vf_drawbox.c
+10
-8
No files found.
libavfilter/vf_drawbox.c
View file @
027a53dc
...
...
@@ -208,6 +208,12 @@ fail:
return
ret
;
}
static
av_pure
av_always_inline
int
pixel_belongs_to_box
(
DrawBoxContext
*
s
,
int
x
,
int
y
)
{
return
(
y
-
s
->
y
<
s
->
thickness
)
||
(
s
->
y
+
s
->
h
-
1
-
y
<
s
->
thickness
)
||
(
x
-
s
->
x
<
s
->
thickness
)
||
(
s
->
x
+
s
->
w
-
1
-
x
<
s
->
thickness
);
}
static
int
filter_frame
(
AVFilterLink
*
inlink
,
AVFrame
*
frame
)
{
DrawBoxContext
*
s
=
inlink
->
dst
->
priv
;
...
...
@@ -225,13 +231,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if
(
s
->
invert_color
)
{
for
(
x
=
FFMAX
(
xb
,
0
);
x
<
xb
+
s
->
w
&&
x
<
frame
->
width
;
x
++
)
if
((
y
-
yb
<
s
->
thickness
)
||
(
yb
+
s
->
h
-
1
-
y
<
s
->
thickness
)
||
(
x
-
xb
<
s
->
thickness
)
||
(
xb
+
s
->
w
-
1
-
x
<
s
->
thickness
))
if
(
pixel_belongs_to_box
(
s
,
x
,
y
))
row
[
0
][
x
]
=
0xff
-
row
[
0
][
x
];
}
else
{
for
(
x
=
FFMAX
(
xb
,
0
);
x
<
xb
+
s
->
w
&&
x
<
frame
->
width
;
x
++
)
{
if
((
y
-
yb
<
s
->
thickness
)
||
(
yb
+
s
->
h
-
1
-
y
<
s
->
thickness
)
||
(
x
-
xb
<
s
->
thickness
)
||
(
xb
+
s
->
w
-
1
-
x
<
s
->
thickness
))
{
if
(
pixel_belongs_to_box
(
s
,
x
,
y
))
{
row
[
0
][
x
]
=
s
->
yuv_color
[
Y
];
row
[
1
][
x
>>
s
->
hsub
]
=
s
->
yuv_color
[
U
];
row
[
2
][
x
>>
s
->
hsub
]
=
s
->
yuv_color
[
V
];
...
...
@@ -250,15 +254,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if
(
s
->
invert_color
)
{
for
(
x
=
FFMAX
(
xb
,
0
);
x
<
xb
+
s
->
w
&&
x
<
frame
->
width
;
x
++
)
if
((
y
-
yb
<
s
->
thickness
)
||
(
yb
+
s
->
h
-
1
-
y
<
s
->
thickness
)
||
(
x
-
xb
<
s
->
thickness
)
||
(
xb
+
s
->
w
-
1
-
x
<
s
->
thickness
))
if
(
pixel_belongs_to_box
(
s
,
x
,
y
))
row
[
0
][
x
]
=
0xff
-
row
[
0
][
x
];
}
else
{
for
(
x
=
FFMAX
(
xb
,
0
);
x
<
xb
+
s
->
w
&&
x
<
frame
->
width
;
x
++
)
{
double
alpha
=
(
double
)
s
->
yuv_color
[
A
]
/
255
;
if
((
y
-
yb
<
s
->
thickness
)
||
(
yb
+
s
->
h
-
1
-
y
<
s
->
thickness
)
||
(
x
-
xb
<
s
->
thickness
)
||
(
xb
+
s
->
w
-
1
-
x
<
s
->
thickness
))
{
if
(
pixel_belongs_to_box
(
s
,
x
,
y
))
{
row
[
0
][
x
]
=
(
1
-
alpha
)
*
row
[
0
][
x
]
+
alpha
*
s
->
yuv_color
[
Y
];
row
[
1
][
x
>>
s
->
hsub
]
=
(
1
-
alpha
)
*
row
[
1
][
x
>>
s
->
hsub
]
+
alpha
*
s
->
yuv_color
[
U
];
row
[
2
][
x
>>
s
->
hsub
]
=
(
1
-
alpha
)
*
row
[
2
][
x
>>
s
->
hsub
]
+
alpha
*
s
->
yuv_color
[
V
];
...
...
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