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
7ed833d7
Commit
7ed833d7
authored
Feb 25, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_gradfun: switch to an AVOptions-based system.
parent
c334c113
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
21 deletions
+38
-21
filters.texi
doc/filters.texi
+16
-12
gradfun.h
libavfilter/gradfun.h
+2
-0
vf_gradfun.c
libavfilter/vf_gradfun.c
+20
-9
No files found.
doc/filters.texi
View file @
7ed833d7
...
@@ -1174,23 +1174,27 @@ This filter is designed for playback only. Do not use it prior to
...
@@ -1174,23 +1174,27 @@ This filter is designed for playback only. Do not use it prior to
lossy compression, because compression tends to lose the dither and
lossy compression, because compression tends to lose the dither and
bring back the bands.
bring back the bands.
The filter takes two optional parameters, separated by ':':
This filter accepts the following options:
@var{strength}:@var{radius}
@table @option
@var{strength} is the maximum amount by which the filter will change
@item strength
any one pixel. Also the threshold for detecting nearly flat
The maximum amount by which the filter will change any one pixel. Also the
regions. Acceptable values range from .51 to 64, default value is
threshold for detecting nearly flat regions. Acceptable values range from .51 to
1.2, out-of-range values will be clipped to the valid range.
64, default value is 1.2, out-of-range values will be clipped to the valid
range.
@var{radius} is the neighborhood to fit the gradient to. A larger
@item radius
radius makes for smoother gradients, but also prevents the filter from
The neighborhood to fit the gradient to. A larger radius makes for smoother
modifying the pixels near detailed regions. Acceptable values are
gradients, but also prevents the filter from modifying the pixels near detailed
8-32, default value is 16, out-of-range values will be clipped to the
regions. Acceptable values are 8-32, default value is 16, out-of-range values
valid range.
will be clipped to the valid range.
@end table
@example
@example
# default parameters
# default parameters
gradfun=
1.2:
16
gradfun=
strength=1.2:radius=
16
# omitting radius
# omitting radius
gradfun=1.2
gradfun=1.2
...
...
libavfilter/gradfun.h
View file @
7ed833d7
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
/// Holds instance-specific information for gradfun.
/// Holds instance-specific information for gradfun.
typedef
struct
GradFunContext
{
typedef
struct
GradFunContext
{
const
AVClass
*
class
;
float
strength
;
int
thresh
;
///< threshold for gradient algorithm
int
thresh
;
///< threshold for gradient algorithm
int
radius
;
///< blur radius
int
radius
;
///< blur radius
int
chroma_w
;
///< width of the chroma planes
int
chroma_w
;
///< width of the chroma planes
...
...
libavfilter/vf_gradfun.c
View file @
7ed833d7
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "libavutil/common.h"
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "libavutil/cpu.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "avfilter.h"
#include "formats.h"
#include "formats.h"
...
@@ -122,15 +123,9 @@ static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, i
...
@@ -122,15 +123,9 @@ static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, i
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
{
GradFunContext
*
gf
=
ctx
->
priv
;
GradFunContext
*
gf
=
ctx
->
priv
;
float
thresh
=
1
.
2
;
int
radius
=
16
;
if
(
args
)
gf
->
thresh
=
(
1
<<
15
)
/
gf
->
strength
;
sscanf
(
args
,
"%f:%d"
,
&
thresh
,
&
radius
);
gf
->
radius
&=
~
1
;
thresh
=
av_clipf
(
thresh
,
0
.
51
,
64
);
gf
->
thresh
=
(
1
<<
15
)
/
thresh
;
gf
->
radius
=
av_clip
((
radius
+
1
)
&
~
1
,
4
,
32
);
gf
->
blur_line
=
ff_gradfun_blur_line_c
;
gf
->
blur_line
=
ff_gradfun_blur_line_c
;
gf
->
filter_line
=
ff_gradfun_filter_line_c
;
gf
->
filter_line
=
ff_gradfun_filter_line_c
;
...
@@ -138,7 +133,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
...
@@ -138,7 +133,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
if
(
ARCH_X86
)
if
(
ARCH_X86
)
ff_gradfun_init_x86
(
gf
);
ff_gradfun_init_x86
(
gf
);
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"threshold:%.2f radius:%d
\n
"
,
thres
h
,
gf
->
radius
);
av_log
(
ctx
,
AV_LOG_VERBOSE
,
"threshold:%.2f radius:%d
\n
"
,
gf
->
strengt
h
,
gf
->
radius
);
return
0
;
return
0
;
}
}
...
@@ -227,6 +222,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
...
@@ -227,6 +222,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return
ff_filter_frame
(
outlink
,
out
);
return
ff_filter_frame
(
outlink
,
out
);
}
}
#define OFFSET(x) offsetof(GradFunContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static
const
AVOption
options
[]
=
{
{
"strength"
,
"The maximum amount by which the filter will change any one pixel."
,
OFFSET
(
strength
),
AV_OPT_TYPE_FLOAT
,
{
.
dbl
=
1
.
2
},
0
.
51
,
64
,
FLAGS
},
{
"radius"
,
"The neighborhood to fit the gradient to."
,
OFFSET
(
radius
),
AV_OPT_TYPE_INT
,
{
.
i64
=
16
},
4
,
32
,
FLAGS
},
{
NULL
},
};
static
const
AVClass
gradfun_class
=
{
.
class_name
=
"gradfun"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
const
AVFilterPad
avfilter_vf_gradfun_inputs
[]
=
{
static
const
AVFilterPad
avfilter_vf_gradfun_inputs
[]
=
{
{
{
.
name
=
"default"
,
.
name
=
"default"
,
...
@@ -249,6 +259,7 @@ AVFilter avfilter_vf_gradfun = {
...
@@ -249,6 +259,7 @@ AVFilter avfilter_vf_gradfun = {
.
name
=
"gradfun"
,
.
name
=
"gradfun"
,
.
description
=
NULL_IF_CONFIG_SMALL
(
"Debands video quickly using gradients."
),
.
description
=
NULL_IF_CONFIG_SMALL
(
"Debands video quickly using gradients."
),
.
priv_size
=
sizeof
(
GradFunContext
),
.
priv_size
=
sizeof
(
GradFunContext
),
.
priv_class
=
&
gradfun_class
,
.
init
=
init
,
.
init
=
init
,
.
uninit
=
uninit
,
.
uninit
=
uninit
,
.
query_formats
=
query_formats
,
.
query_formats
=
query_formats
,
...
...
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