Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
b83e9efc
Commit
b83e9efc
authored
Feb 25, 2013
by
Anton Khirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vf_unsharp: switch to an AVOptions-based system.
parent
0c2466de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
filters.texi
doc/filters.texi
+5
-6
vf_unsharp.c
libavfilter/vf_unsharp.c
+27
-18
No files found.
doc/filters.texi
View file @
b83e9efc
...
...
@@ -2157,11 +2157,6 @@ l.r l.L
Sharpen or blur the input video.
It accepts the following parameters:
@var{luma_msize_x}:@var{luma_msize_y}:@var{luma_amount}:@var{chroma_msize_x}:@var{chroma_msize_y}:@var{chroma_amount}
Negative values for the amount will blur the input video, while positive
values will sharpen. All parameters are optional and default to the
equivalent of the string '5:5:1.0:5:5:0.0'.
@table @option
...
...
@@ -2191,9 +2186,13 @@ and 5.0, default value is 0.0.
@end table
Negative values for the amount will blur the input video, while positive
values will sharpen. All parameters are optional and default to the
equivalent of the string '5:5:1.0:5:5:0.0'.
@example
# Strong luma sharpen effect parameters
unsharp=
7:7:
2.5
unsharp=
luma_msize_x=7:luma_msize_y=7:luma_amount=
2.5
# Strong blur of both luma and chroma parameters
unsharp=7:7:-2:7:7:-2
...
...
libavfilter/vf_unsharp.c
View file @
b83e9efc
...
...
@@ -42,6 +42,7 @@
#include "video.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#define MIN_SIZE 3
...
...
@@ -62,6 +63,9 @@ typedef struct FilterParam {
}
FilterParam
;
typedef
struct
{
const
AVClass
*
class
;
int
lmsize_x
,
lmsize_y
,
cmsize_x
,
cmsize_y
;
float
lamount
,
camount
;
FilterParam
luma
;
///< luma parameters (width, height, amount)
FilterParam
chroma
;
///< chroma parameters (width, height, amount)
int
hsub
,
vsub
;
...
...
@@ -120,7 +124,7 @@ static void apply_unsharp( uint8_t *dst, int dst_stride,
}
}
static
void
set_filter_param
(
FilterParam
*
fp
,
int
msize_x
,
int
msize_y
,
double
amount
)
static
void
set_filter_param
(
FilterParam
*
fp
,
int
msize_x
,
int
msize_y
,
float
amount
)
{
fp
->
msize_x
=
msize_x
;
fp
->
msize_y
=
msize_y
;
...
...
@@ -135,24 +139,9 @@ static void set_filter_param(FilterParam *fp, int msize_x, int msize_y, double a
static
av_cold
int
init
(
AVFilterContext
*
ctx
,
const
char
*
args
)
{
UnsharpContext
*
unsharp
=
ctx
->
priv
;
int
lmsize_x
=
5
,
cmsize_x
=
5
;
int
lmsize_y
=
5
,
cmsize_y
=
5
;
double
lamount
=
1
.
0
f
,
camount
=
0
.
0
f
;
if
(
args
)
sscanf
(
args
,
"%d:%d:%lf:%d:%d:%lf"
,
&
lmsize_x
,
&
lmsize_y
,
&
lamount
,
&
cmsize_x
,
&
cmsize_y
,
&
camount
);
if
((
lamount
&&
(
lmsize_x
<
2
||
lmsize_y
<
2
))
||
(
camount
&&
(
cmsize_x
<
2
||
cmsize_y
<
2
)))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Invalid value <2 for lmsize_x:%d or lmsize_y:%d or cmsize_x:%d or cmsize_y:%d
\n
"
,
lmsize_x
,
lmsize_y
,
cmsize_x
,
cmsize_y
);
return
AVERROR
(
EINVAL
);
}
set_filter_param
(
&
unsharp
->
luma
,
lmsize_x
,
lmsize_y
,
lamount
);
set_filter_param
(
&
unsharp
->
chroma
,
cmsize_x
,
cmsize_y
,
camount
);
set_filter_param
(
&
unsharp
->
luma
,
unsharp
->
lmsize_x
,
unsharp
->
lmsize_y
,
unsharp
->
lamount
);
set_filter_param
(
&
unsharp
->
chroma
,
unsharp
->
cmsize_x
,
unsharp
->
cmsize_y
,
unsharp
->
camount
);
return
0
;
}
...
...
@@ -237,6 +226,25 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
return
ff_filter_frame
(
outlink
,
out
);
}
#define OFFSET(x) offsetof(UnsharpContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
static
const
AVOption
options
[]
=
{
{
"luma_msize_x"
,
"luma matrix horizontal size"
,
OFFSET
(
lmsize_x
),
AV_OPT_TYPE_INT
,
{
.
i64
=
5
},
MIN_SIZE
,
MAX_SIZE
,
FLAGS
},
{
"luma_msize_y"
,
"luma matrix vertical size"
,
OFFSET
(
lmsize_y
),
AV_OPT_TYPE_INT
,
{
.
i64
=
5
},
MIN_SIZE
,
MAX_SIZE
,
FLAGS
},
{
"luma_amount"
,
"luma effect strength"
,
OFFSET
(
lamount
),
AV_OPT_TYPE_FLOAT
,
{
.
dbl
=
1
},
-
2
,
5
,
FLAGS
},
{
"chroma_msize_x"
,
"chroma matrix horizontal size"
,
OFFSET
(
cmsize_x
),
AV_OPT_TYPE_INT
,
{
.
i64
=
5
},
MIN_SIZE
,
MAX_SIZE
,
FLAGS
},
{
"chroma_msize_y"
,
"chroma matrix vertical size"
,
OFFSET
(
cmsize_y
),
AV_OPT_TYPE_INT
,
{
.
i64
=
5
},
MIN_SIZE
,
MAX_SIZE
,
FLAGS
},
{
"chroma_amount"
,
"chroma effect strength"
,
OFFSET
(
camount
),
AV_OPT_TYPE_FLOAT
,
{
.
dbl
=
0
},
-
2
,
5
,
FLAGS
},
{
NULL
},
};
static
const
AVClass
unsharp_class
=
{
.
class_name
=
"unsharp"
,
.
item_name
=
av_default_item_name
,
.
option
=
options
,
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
const
AVFilterPad
avfilter_vf_unsharp_inputs
[]
=
{
{
.
name
=
"default"
,
...
...
@@ -260,6 +268,7 @@ AVFilter avfilter_vf_unsharp = {
.
description
=
NULL_IF_CONFIG_SMALL
(
"Sharpen or blur the input video."
),
.
priv_size
=
sizeof
(
UnsharpContext
),
.
priv_class
=
&
unsharp_class
,
.
init
=
init
,
.
uninit
=
uninit
,
...
...
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