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
b414cff6
Commit
b414cff6
authored
Oct 30, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_median: add radiusV option
parent
86a42e95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
12 deletions
+21
-12
filters.texi
doc/filters.texi
+6
-1
median.h
libavfilter/median.h
+1
-0
median_template.c
libavfilter/median_template.c
+8
-7
vf_median.c
libavfilter/vf_median.c
+6
-4
No files found.
doc/filters.texi
View file @
b414cff6
...
...
@@ -12919,11 +12919,16 @@ This filter accepts the following options:
@table @option
@item radius
Set horizontal
and vertical
radius size. Default value is @code{1}.
Set horizontal radius size. Default value is @code{1}.
Allowed range is integer from 1 to 127.
@item planes
Set which planes to process. Default is @code{15}, which is all available planes.
@item radiusV
Set vertical radius size. Default value is @code{0}.
Allowed range is integer from 0 to 127.
If it is 0, value will be picked from horizontal @code{radius} option.
@end table
@section mergeplanes
...
...
libavfilter/median.h
View file @
b414cff6
...
...
@@ -30,6 +30,7 @@ typedef struct MedianContext {
int
planes
;
int
radius
;
int
radiusV
;
int
planewidth
[
4
];
int
planeheight
[
4
];
...
...
libavfilter/median_template.c
View file @
b414cff6
...
...
@@ -57,6 +57,7 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
htype
*
ccoarse
=
s
->
coarse
[
jobnr
];
htype
*
cfine
=
s
->
fine
[
jobnr
];
const
int
radius
=
s
->
radius
;
const
int
radiusV
=
s
->
radiusV
;
const
int
t
=
s
->
t
;
const
pixel
*
src
=
(
const
pixel
*
)
ssrc
;
pixel
*
dst
=
(
pixel
*
)
ddst
;
...
...
@@ -69,16 +70,16 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
memset
(
cfine
,
0
,
s
->
fine_size
*
sizeof
(
*
cfine
));
memset
(
ccoarse
,
0
,
s
->
coarse_size
*
sizeof
(
*
ccoarse
));
srcp
=
src
+
FFMAX
(
0
,
slice_h_start
-
radius
)
*
src_linesize
;
srcp
=
src
+
FFMAX
(
0
,
slice_h_start
-
radius
V
)
*
src_linesize
;
if
(
jobnr
==
0
)
{
for
(
int
i
=
0
;
i
<
width
;
i
++
)
{
cfine
[
PICK_FINE_BIN
(
width
,
srcp
[
i
],
i
)]
+=
radius
+
1
;
ccoarse
[
PICK_COARSE_BIN
(
i
,
srcp
[
i
])]
+=
radius
+
1
;
cfine
[
PICK_FINE_BIN
(
width
,
srcp
[
i
],
i
)]
+=
radius
V
+
1
;
ccoarse
[
PICK_COARSE_BIN
(
i
,
srcp
[
i
])]
+=
radius
V
+
1
;
}
}
srcp
=
src
+
FFMAX
(
0
,
slice_h_start
-
radius
-
(
jobnr
!=
0
))
*
src_linesize
;
for
(
int
i
=
0
;
i
<
radius
+
(
jobnr
!=
0
)
*
(
1
+
radius
);
i
++
)
{
srcp
=
src
+
FFMAX
(
0
,
slice_h_start
-
radius
V
-
(
jobnr
!=
0
))
*
src_linesize
;
for
(
int
i
=
0
;
i
<
radius
V
+
(
jobnr
!=
0
)
*
(
1
+
radiusV
);
i
++
)
{
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
cfine
[
PICK_FINE_BIN
(
width
,
srcp
[
j
],
j
)]
++
;
ccoarse
[
PICK_COARSE_BIN
(
j
,
srcp
[
j
])]
++
;
...
...
@@ -93,13 +94,13 @@ static void fn(filter_plane)(AVFilterContext *ctx, const uint8_t *ssrc, int src_
htype
fine
[
BINS
][
BINS
]
=
{
{
0
}
};
htype
luc
[
BINS
]
=
{
0
};
p
=
srcp
+
src_linesize
*
FFMAX
(
0
,
i
-
radius
-
1
);
p
=
srcp
+
src_linesize
*
FFMAX
(
0
,
i
-
radius
V
-
1
);
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
cfine
[
PICK_FINE_BIN
(
width
,
p
[
j
],
j
)]
--
;
ccoarse
[
PICK_COARSE_BIN
(
j
,
p
[
j
])]
--
;
}
p
=
srcp
+
src_linesize
*
FFMIN
(
height
-
1
,
i
+
radius
);
p
=
srcp
+
src_linesize
*
FFMIN
(
height
-
1
,
i
+
radius
V
);
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
cfine
[
PICK_FINE_BIN
(
width
,
p
[
j
],
j
)]
++
;
ccoarse
[
PICK_COARSE_BIN
(
j
,
p
[
j
])]
++
;
...
...
libavfilter/vf_median.c
View file @
b414cff6
...
...
@@ -59,6 +59,7 @@
static
const
AVOption
median_options
[]
=
{
{
"radius"
,
"set median radius"
,
OFFSET
(
radius
),
AV_OPT_TYPE_INT
,
{.
i64
=
1
},
1
,
127
,
FLAGS
},
{
"planes"
,
"set planes to filter"
,
OFFSET
(
planes
),
AV_OPT_TYPE_INT
,
{.
i64
=
0xF
},
0
,
0xF
,
FLAGS
},
{
"radiusV"
,
"set median vertical radius"
,
OFFSET
(
radiusV
),
AV_OPT_TYPE_INT
,
{.
i64
=
0
},
0
,
127
,
FLAGS
},
{
NULL
}
};
...
...
@@ -119,8 +120,9 @@ static int config_input(AVFilterLink *inlink)
s
->
planeheight
[
1
]
=
s
->
planeheight
[
2
]
=
AV_CEIL_RSHIFT
(
inlink
->
h
,
desc
->
log2_chroma_h
);
s
->
planeheight
[
0
]
=
s
->
planeheight
[
3
]
=
inlink
->
h
;
s
->
radiusV
=
!
s
->
radiusV
?
s
->
radius
:
s
->
radiusV
;
s
->
nb_planes
=
av_pix_fmt_count_planes
(
inlink
->
format
);
s
->
t
=
2
*
s
->
radius
*
s
->
radius
+
2
*
s
->
radius
;
s
->
t
=
2
*
s
->
radius
*
s
->
radius
V
+
2
*
s
->
radius
;
for
(
int
i
=
0
;
i
<
s
->
nb_planes
;
i
++
)
{
if
(
!
(
s
->
planes
&
(
1
<<
i
)))
...
...
@@ -131,13 +133,13 @@ static int config_input(AVFilterLink *inlink)
return
AVERROR
(
EINVAL
);
}
if
(
s
->
planeheight
[
i
]
<
s
->
radius
*
2
+
1
)
{
av_log
(
inlink
->
dst
,
AV_LOG_ERROR
,
"The %d plane height %d must be not less than %d
\n
"
,
i
,
s
->
planeheight
[
i
],
s
->
radius
*
2
+
1
);
if
(
s
->
planeheight
[
i
]
<
s
->
radius
V
*
2
+
1
)
{
av_log
(
inlink
->
dst
,
AV_LOG_ERROR
,
"The %d plane height %d must be not less than %d
\n
"
,
i
,
s
->
planeheight
[
i
],
s
->
radius
V
*
2
+
1
);
return
AVERROR
(
EINVAL
);
}
}
s
->
nb_threads
=
FFMAX
(
1
,
FFMIN
(
s
->
planeheight
[
1
]
/
(
s
->
radius
+
1
),
ff_filter_get_nb_threads
(
inlink
->
dst
)));
s
->
nb_threads
=
FFMAX
(
1
,
FFMIN
(
s
->
planeheight
[
1
]
/
(
s
->
radius
V
+
1
),
ff_filter_get_nb_threads
(
inlink
->
dst
)));
s
->
bins
=
1
<<
((
s
->
depth
+
1
)
/
2
);
s
->
fine_size
=
s
->
bins
*
s
->
bins
*
inlink
->
w
;
s
->
coarse_size
=
s
->
bins
*
inlink
->
w
;
...
...
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