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
f30979e0
Commit
f30979e0
authored
Feb 20, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/boxblur: add support to named options
parent
6f77122b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
43 deletions
+89
-43
filters.texi
doc/filters.texi
+34
-16
version.h
libavfilter/version.h
+1
-1
vf_boxblur.c
libavfilter/vf_boxblur.c
+54
-26
No files found.
doc/filters.texi
View file @
f30979e0
...
...
@@ -1890,17 +1890,30 @@ blend=all_expr='if(eq(mod(X,2),mod(Y,2)),A,B)'
Apply boxblur algorithm to the input video.
This filter accepts the parameters:
@var{luma_radius}:@var{luma_power}:@var{chroma_radius}:@var{chroma_power}:@var{alpha_radius}:@var{alpha_power}
The filter accepts parameters as a list of @var{key}=@var{value}
pairs, separated by ":". If the key of the first options is omitted,
the arguments are interpreted according to the syntax
@option{luma_radius}:@option{luma_power}:@option{chroma_radius}:@option{chroma_power}:@option{alpha_radius}:@option{alpha_power}.
Chroma and alpha parameters are optional, if not specified they default
to the corresponding values set for @var{luma_radius} and
@var{luma_power}.
A description of the accepted options follows.
@var{luma_radius}, @var{chroma_radius}, and @var{alpha_radius} represent
the radius in pixels of the box used for blurring the corresponding
input plane. They are expressions, and can contain the following
constants:
@table @option
@item luma_radius, lr
@item chroma_radius, cr
@item alpha_radius, ar
Set an expression for the box radius in pixels used for blurring the
corresponding input plane.
The radius value must be a non-negative number, and must not be
greater than the value of the expression @code{min(w,h)/2} for the
luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
planes.
Default value for @option{luma_radius} is "2". If not specified,
@option{chroma_radius} and @option{alpha_radius} default to the
corresponding value set for @option{luma_radius}.
The expressions can contain the following constants:
@table @option
@item w, h
the input width and height in pixels
...
...
@@ -1913,13 +1926,18 @@ horizontal and vertical chroma subsample values. For example for the
pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
@end table
The radius must be a non-negative number, and must not be greater than
the value of the expression @code{min(w,h)/2} for the luma and alpha planes,
and of @code{min(cw,ch)/2} for the chroma planes.
@item luma_power, lp
@item chroma_power, cp
@item alpha_power, ap
Specify how many times the boxblur filter is applied to the
corresponding plane.
@var{luma_power}, @var{chroma_power}, and @var{alpha_power} represent
how many times the boxblur filter is applied to the corresponding
plane.
Default value for @option{luma_power} is 2. If not specified,
@option{chroma_power} and @option{alpha_power} default to the
corresponding value set for @option{luma_power}.
A value of 0 will disable the effect.
@end table
Some examples follow:
...
...
@@ -1935,7 +1953,7 @@ boxblur=2:1
@item
Set luma radius to 2, alpha and chroma radius to 0
@example
boxblur=2:1:
0:0:0:
0
boxblur=2:1:
cr=0:ar=
0
@end example
@item
...
...
libavfilter/version.h
View file @
f30979e0
...
...
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 39
#define LIBAVFILTER_VERSION_MICRO 10
0
#define LIBAVFILTER_VERSION_MICRO 10
1
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
...
...
libavfilter/vf_boxblur.c
View file @
f30979e0
...
...
@@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
...
...
@@ -57,15 +58,14 @@ enum var_name {
typedef
struct
{
int
radius
;
int
power
;
char
*
radius_expr
;
}
FilterParam
;
typedef
struct
{
const
AVClass
*
class
;
FilterParam
luma_param
;
FilterParam
chroma_param
;
FilterParam
alpha_param
;
char
luma_radius_expr
[
256
];
char
chroma_radius_expr
[
256
];
char
alpha_radius_expr
[
256
];
int
hsub
,
vsub
;
int
radius
[
4
];
...
...
@@ -73,6 +73,30 @@ typedef struct {
uint8_t
*
temp
[
2
];
///< temporary buffer used in blur_power()
}
BoxBlurContext
;
#define OFFSET(x) offsetof(BoxBlurContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static
const
AVOption
boxblur_options
[]
=
{
{
"luma_radius"
,
"set luma radius"
,
OFFSET
(
luma_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
"2"
},
.
flags
=
FLAGS
},
{
"lr"
,
"set luma radius"
,
OFFSET
(
luma_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
"2"
},
.
flags
=
FLAGS
},
{
"luma_power"
,
"set luma power"
,
OFFSET
(
luma_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
0
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"lp"
,
"set luma power"
,
OFFSET
(
luma_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
0
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"chroma_radius"
,
"set chroma radius"
,
OFFSET
(
chroma_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"cr"
,
"set chroma radius"
,
OFFSET
(
chroma_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"chroma_power"
,
"set chroma power"
,
OFFSET
(
chroma_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"cp"
,
"set chroma power"
,
OFFSET
(
chroma_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"alpha_radius"
,
"set alpha radius"
,
OFFSET
(
alpha_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"ar"
,
"set alpha radius"
,
OFFSET
(
alpha_param
.
radius_expr
),
AV_OPT_TYPE_STRING
,
{.
str
=
NULL
},
.
flags
=
FLAGS
},
{
"alpha_power"
,
"set alpha power"
,
OFFSET
(
alpha_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
"ap"
,
"set alpha power"
,
OFFSET
(
alpha_param
.
power
),
AV_OPT_TYPE_INT
,
{.
i64
=-
1
},
-
1
,
INT_MAX
,
.
flags
=
FLAGS
},
{
NULL
}
};
AVFILTER_DEFINE_CLASS
(
boxblur
);
#define Y 0
#define U 1
#define V 2
...
...
@@ -81,35 +105,36 @@ typedef struct {
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
BoxBlurContext
*
boxblur
=
ctx
->
priv
;
int
e
;
static
const
char
*
shorthand
[]
=
{
"luma_radius"
,
"luma_power"
,
"chroma_radius"
,
"chroma_power"
,
"alpha_radius"
,
"alpha_power"
,
NULL
};
int
ret
;
if
(
!
args
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Filter expects 2 or 4 or 6 arguments, none provided
\n
"
);
return
AVERROR
(
EINVAL
);
}
boxblur
->
class
=
&
boxblur_class
;
av_opt_set_defaults
(
boxblur
);
e
=
sscanf
(
args
,
"%255[^:]:%d:%255[^:]:%d:%255[^:]:%d"
,
boxblur
->
luma_radius_expr
,
&
boxblur
->
luma_param
.
power
,
boxblur
->
chroma_radius_expr
,
&
boxblur
->
chroma_param
.
power
,
boxblur
->
alpha_radius_expr
,
&
boxblur
->
alpha_param
.
power
);
if
((
ret
=
av_opt_set_from_string
(
boxblur
,
args
,
shorthand
,
"="
,
":"
))
<
0
)
return
ret
;
if
(
e
!=
2
&&
e
!=
4
&&
e
!=
6
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Filter expects 2 or 4 or 6 params, provided %d
\n
"
,
e
);
return
AVERROR
(
EINVAL
);
/* fill missing params */
if
(
!
boxblur
->
chroma_param
.
radius_expr
)
{
boxblur
->
chroma_param
.
radius_expr
=
av_strdup
(
boxblur
->
luma_param
.
radius_expr
);
if
(
!
boxblur
->
chroma_param
.
radius_expr
)
return
AVERROR
(
ENOMEM
);
}
if
(
e
<
4
)
{
if
(
boxblur
->
chroma_param
.
power
<
0
)
boxblur
->
chroma_param
.
power
=
boxblur
->
luma_param
.
power
;
av_strlcpy
(
boxblur
->
chroma_radius_expr
,
boxblur
->
luma_radius_expr
,
sizeof
(
boxblur
->
chroma_radius_expr
));
if
(
!
boxblur
->
alpha_param
.
radius_expr
)
{
boxblur
->
alpha_param
.
radius_expr
=
av_strdup
(
boxblur
->
luma_param
.
radius_expr
);
if
(
!
boxblur
->
alpha_param
.
radius_expr
)
return
AVERROR
(
ENOMEM
);
}
if
(
e
<
6
)
{
if
(
boxblur
->
alpha_param
.
power
<
0
)
boxblur
->
alpha_param
.
power
=
boxblur
->
luma_param
.
power
;
av_strlcpy
(
boxblur
->
alpha_radius_expr
,
boxblur
->
luma_radius_expr
,
sizeof
(
boxblur
->
alpha_radius_expr
));
}
return
0
;
}
...
...
@@ -120,6 +145,7 @@ static av_cold void uninit(AVFilterContext *ctx)
av_freep
(
&
boxblur
->
temp
[
0
]);
av_freep
(
&
boxblur
->
temp
[
1
]);
av_opt_free
(
boxblur
);
}
static
int
query_formats
(
AVFilterContext
*
ctx
)
...
...
@@ -163,7 +189,7 @@ static int config_input(AVFilterLink *inlink)
var_values
[
VAR_VSUB
]
=
1
<<
boxblur
->
vsub
;
#define EVAL_RADIUS_EXPR(comp) \
expr = boxblur->comp##_
radius_expr;
\
expr = boxblur->comp##_
param.radius_expr;
\
ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
NULL, NULL, NULL, NULL, NULL, 0, ctx); \
boxblur->comp##_param.radius = res; \
...
...
@@ -366,4 +392,6 @@ AVFilter avfilter_vf_boxblur = {
.
inputs
=
avfilter_vf_boxblur_inputs
,
.
outputs
=
avfilter_vf_boxblur_outputs
,
.
priv_class
=
&
boxblur_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