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
526e2415
Commit
526e2415
authored
Dec 18, 2012
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/gradfun: support named options.
This breaks usage for out-of-range values.
parent
ca83e6ce
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
14 deletions
+33
-14
filters.texi
doc/filters.texi
+7
-5
gradfun.h
libavfilter/gradfun.h
+2
-0
version.h
libavfilter/version.h
+1
-1
vf_gradfun.c
libavfilter/vf_gradfun.c
+23
-8
No files found.
doc/filters.texi
View file @
526e2415
...
...
@@ -2665,19 +2665,21 @@ This filter is designed for playback only. Do not use it prior to
lossy compression, because compression tends to lose the dither and
bring back the bands.
The filter
takes two optional parameters, separated by ':':
@var{strength}:@var{radius}
The filter
accepts a list of options in the form of @var{key}=@var{value} pairs
separated by ":". A description of the accepted options follows.
@var{strength} is the maximum amount by which the filter will change
any one pixel. Also the threshold for detecting nearly flat
regions. Acceptable values range from .51 to 64, default value is
1.2
, out-of-range values will be clipped to the valid range
.
1.2.
@var{radius} is the neighborhood to fit the gradient to. A larger
radius makes for smoother gradients, but also prevents the filter from
modifying the pixels near detailed regions. Acceptable values are
8-32, default value is 16, out-of-range values will be clipped to the
valid range.
8-32, default value is 16.
Alternatively, the options can be specified as a flat string:
@var{strength}[:@var{radius}]
@example
# default parameters
...
...
libavfilter/gradfun.h
View file @
526e2415
...
...
@@ -26,6 +26,8 @@
/// Holds instance-specific information for gradfun.
typedef
struct
GradFunContext
{
const
AVClass
*
class
;
double
strength
;
///< user specified strength, used to define thresh
int
thresh
;
///< threshold for gradient algorithm
int
radius
;
///< blur radius
int
chroma_w
;
///< width of the chroma planes
...
...
libavfilter/version.h
View file @
526e2415
...
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 28
#define LIBAVFILTER_VERSION_MICRO 10
1
#define LIBAVFILTER_VERSION_MICRO 10
2
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_gradfun.c
View file @
526e2415
...
...
@@ -36,12 +36,24 @@
#include "libavutil/common.h"
#include "libavutil/cpu.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "gradfun.h"
#include "internal.h"
#include "video.h"
#define OFFSET(x) offsetof(GradFunContext, x)
#define F AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
gradfun_options
[]
=
{
{
"strength"
,
"set the maximum amount by which the filter will change any one pixel"
,
OFFSET
(
strength
),
AV_OPT_TYPE_DOUBLE
,
{.
dbl
=
1
.
2
},
0
.
51
,
64
,
F
},
{
"radius"
,
"set the neighborhood to fit the gradient to"
,
OFFSET
(
radius
),
AV_OPT_TYPE_INT
,
{.
i64
=
16
},
4
,
32
,
F
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
gradfun
);
DECLARE_ALIGNED
(
16
,
static
const
uint16_t
,
dither
)[
8
][
8
]
=
{
{
0x00
,
0x60
,
0x18
,
0x78
,
0x06
,
0x66
,
0x1E
,
0x7E
},
{
0x40
,
0x20
,
0x58
,
0x38
,
0x46
,
0x26
,
0x5E
,
0x3E
},
...
...
@@ -121,16 +133,18 @@ static void filter(GradFunContext *ctx, uint8_t *dst, const uint8_t *src, int wi
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
int
ret
;
GradFunContext
*
gf
=
ctx
->
priv
;
float
thresh
=
1
.
2
;
int
radius
=
16
;
static
const
char
*
shorthand
[]
=
{
"strength"
,
"radius"
,
NULL
};
gf
->
class
=
&
gradfun_class
;
av_opt_set_defaults
(
gf
);
if
(
args
)
sscanf
(
args
,
"%f:%d"
,
&
thresh
,
&
radius
)
;
if
(
(
ret
=
av_opt_set_from_string
(
gf
,
args
,
shorthand
,
"="
,
":"
))
<
0
)
return
ret
;
thresh
=
av_clipf
(
thresh
,
0
.
51
,
64
);
gf
->
thresh
=
(
1
<<
15
)
/
thresh
;
gf
->
radius
=
av_clip
((
radius
+
1
)
&
~
1
,
4
,
32
);
gf
->
thresh
=
(
1
<<
15
)
/
gf
->
strength
;
gf
->
radius
=
av_clip
((
gf
->
radius
+
1
)
&
~
1
,
4
,
32
);
gf
->
blur_line
=
ff_gradfun_blur_line_c
;
gf
->
filter_line
=
ff_gradfun_filter_line_c
;
...
...
@@ -138,7 +152,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
if
(
ARCH_X86
)
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
;
}
...
...
@@ -252,4 +266,5 @@ AVFilter avfilter_vf_gradfun = {
.
inputs
=
avfilter_vf_gradfun_inputs
,
.
outputs
=
avfilter_vf_gradfun_outputs
,
.
priv_class
=
&
gradfun_class
,
};
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