Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
云duo
FFmpeg
提交
fdcb7a85
F
FFmpeg
项目概览
云duo
/
FFmpeg
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FFmpeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fdcb7a85
编写于
12月 22, 2016
作者:
P
Paul B Mahol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avfilter/vf_deband: add planes coupling mode
Signed-off-by:
N
Paul B Mahol
<
onemda@gmail.com
>
上级
47cd8eff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
166 addition
and
3 deletion
+166
-3
doc/filters.texi
doc/filters.texi
+6
-1
libavfilter/vf_deband.c
libavfilter/vf_deband.c
+160
-2
未找到文件。
doc/filters.texi
浏览文件 @
fdcb7a85
...
...
@@ -6203,11 +6203,16 @@ absolute value will be picked. For example direction 0, -PI or -2*PI radians
will pick only pixels on same row and -PI/2 will pick only pixels on same
column.
@item blur
@item blur
, b
If enabled, current pixel is compared with average value of all four
surrounding pixels. The default is enabled. If disabled current pixel is
compared with all four surrounding pixels. The pixel is considered banded
if only all four differences with surrounding pixels are less than threshold.
@item coupling, c
If enabled, current pixel is changed if and only if all pixel components are banded,
e.g. banding detection threshold is triggered for all color components.
The default is disabled.
@end table
@anchor{decimate}
...
...
libavfilter/vf_deband.c
浏览文件 @
fdcb7a85
...
...
@@ -30,6 +30,7 @@
typedef
struct
DebandContext
{
const
AVClass
*
class
;
int
coupling
;
float
threshold
[
4
];
int
range
;
int
blur
;
...
...
@@ -38,6 +39,7 @@ typedef struct DebandContext {
int
nb_components
;
int
planewidth
[
4
];
int
planeheight
[
4
];
int
shift
[
2
];
int
thr
[
4
];
int
*
x_pos
;
...
...
@@ -59,6 +61,9 @@ static const AVOption deband_options[] = {
{
"direction"
,
"set direction"
,
OFFSET
(
direction
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
2
*
M_PI
},
-
2
*
M_PI
,
2
*
M_PI
,
FLAGS
},
{
"d"
,
"set direction"
,
OFFSET
(
direction
),
AV_OPT_TYPE_FLOAT
,
{.
dbl
=
2
*
M_PI
},
-
2
*
M_PI
,
2
*
M_PI
,
FLAGS
},
{
"blur"
,
"set blur"
,
OFFSET
(
blur
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"b"
,
"set blur"
,
OFFSET
(
blur
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
1
},
0
,
1
,
FLAGS
},
{
"coupling"
,
"set plane coupling"
,
OFFSET
(
coupling
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
FLAGS
},
{
"c"
,
"set plane coupling"
,
OFFSET
(
coupling
),
AV_OPT_TYPE_BOOL
,
{.
i64
=
0
},
0
,
1
,
FLAGS
},
{
NULL
}
};
...
...
@@ -66,6 +71,8 @@ AVFILTER_DEFINE_CLASS(deband);
static
int
query_formats
(
AVFilterContext
*
ctx
)
{
DebandContext
*
s
=
ctx
->
priv
;
static
const
enum
AVPixelFormat
pix_fmts
[]
=
{
AV_PIX_FMT_GRAY8
,
AV_PIX_FMT_GRAY16
,
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUV422P
,
AV_PIX_FMT_YUV420P
,
...
...
@@ -86,7 +93,21 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P16
,
AV_PIX_FMT_YUVA422P16
,
AV_PIX_FMT_YUVA444P16
,
AV_PIX_FMT_NONE
};
AVFilterFormats
*
fmts_list
=
ff_make_format_list
(
pix_fmts
);
static
const
enum
AVPixelFormat
cpix_fmts
[]
=
{
AV_PIX_FMT_YUV444P
,
AV_PIX_FMT_YUVJ444P
,
AV_PIX_FMT_YUVA444P
,
AV_PIX_FMT_YUV444P9
,
AV_PIX_FMT_YUVA444P9
,
AV_PIX_FMT_YUVA444P10
,
AV_PIX_FMT_YUV444P12
,
AV_PIX_FMT_YUV444P14
,
AV_PIX_FMT_YUV444P16
,
AV_PIX_FMT_YUVA444P16
,
AV_PIX_FMT_GBRP
,
AV_PIX_FMT_GBRAP
,
AV_PIX_FMT_GBRP9
,
AV_PIX_FMT_GBRP10
,
AV_PIX_FMT_GBRP12
,
AV_PIX_FMT_GBRP14
,
AV_PIX_FMT_GBRP16
,
AV_PIX_FMT_GBRAP16
,
AV_PIX_FMT_NONE
};
AVFilterFormats
*
fmts_list
=
ff_make_format_list
(
s
->
coupling
?
cpix_fmts
:
pix_fmts
);
if
(
!
fmts_list
)
return
AVERROR
(
ENOMEM
);
...
...
@@ -158,6 +179,138 @@ static int deband_8_c(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
return
0
;
}
static
int
deband_8_coupling_c
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
DebandContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
const
int
start
=
(
s
->
planeheight
[
0
]
*
jobnr
)
/
nb_jobs
;
const
int
end
=
(
s
->
planeheight
[
0
]
*
(
jobnr
+
1
))
/
nb_jobs
;
int
x
,
y
,
p
;
for
(
y
=
start
;
y
<
end
;
y
++
)
{
const
int
pos
=
y
*
s
->
planewidth
[
0
];
for
(
x
=
0
;
x
<
s
->
planewidth
[
p
];
x
++
)
{
const
int
x_pos
=
s
->
x_pos
[
pos
+
x
];
const
int
y_pos
=
s
->
y_pos
[
pos
+
x
];
int
avg
[
4
],
cmp
[
4
]
=
{
0
},
src
[
4
];
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
uint8_t
*
src_ptr
=
(
const
uint8_t
*
)
in
->
data
[
p
];
const
int
src_linesize
=
in
->
linesize
[
p
];
const
int
thr
=
s
->
thr
[
p
];
const
int
w
=
s
->
planewidth
[
p
]
-
1
;
const
int
h
=
s
->
planeheight
[
p
]
-
1
;
const
int
ref0
=
src_ptr
[
av_clip
(
y
+
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
x_pos
,
0
,
w
)];
const
int
ref1
=
src_ptr
[
av_clip
(
y
+
-
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
x_pos
,
0
,
w
)];
const
int
ref2
=
src_ptr
[
av_clip
(
y
+
-
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
-
x_pos
,
0
,
w
)];
const
int
ref3
=
src_ptr
[
av_clip
(
y
+
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
-
x_pos
,
0
,
w
)];
const
int
src0
=
src_ptr
[
y
*
src_linesize
+
x
];
src
[
p
]
=
src0
;
avg
[
p
]
=
get_avg
(
ref0
,
ref1
,
ref2
,
ref3
);
if
(
s
->
blur
)
{
cmp
[
p
]
=
FFABS
(
src0
-
avg
[
p
])
<
thr
;
}
else
{
cmp
[
p
]
=
(
FFABS
(
src0
-
ref0
)
<
thr
)
&&
(
FFABS
(
src0
-
ref1
)
<
thr
)
&&
(
FFABS
(
src0
-
ref2
)
<
thr
)
&&
(
FFABS
(
src0
-
ref3
)
<
thr
);
}
}
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
if
(
!
cmp
[
p
])
break
;
if
(
p
==
s
->
nb_components
)
{
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
int
dst_linesize
=
out
->
linesize
[
p
];
out
->
data
[
p
][
y
*
dst_linesize
+
x
]
=
avg
[
p
];
}
}
else
{
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
int
dst_linesize
=
out
->
linesize
[
p
];
out
->
data
[
p
][
y
*
dst_linesize
+
x
]
=
src
[
p
];
}
}
}
}
return
0
;
}
static
int
deband_16_coupling_c
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
DebandContext
*
s
=
ctx
->
priv
;
ThreadData
*
td
=
arg
;
AVFrame
*
in
=
td
->
in
;
AVFrame
*
out
=
td
->
out
;
const
int
start
=
(
s
->
planeheight
[
0
]
*
jobnr
)
/
nb_jobs
;
const
int
end
=
(
s
->
planeheight
[
0
]
*
(
jobnr
+
1
))
/
nb_jobs
;
int
x
,
y
,
p
,
z
;
for
(
y
=
start
;
y
<
end
;
y
++
)
{
const
int
pos
=
y
*
s
->
planewidth
[
0
];
for
(
x
=
0
;
x
<
s
->
planewidth
[
p
];
x
++
)
{
const
int
x_pos
=
s
->
x_pos
[
pos
+
x
];
const
int
y_pos
=
s
->
y_pos
[
pos
+
x
];
int
avg
[
4
],
cmp
[
4
]
=
{
0
},
src
[
4
];
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
uint16_t
*
src_ptr
=
(
const
uint16_t
*
)
in
->
data
[
p
];
const
int
src_linesize
=
in
->
linesize
[
p
]
/
2
;
const
int
thr
=
s
->
thr
[
p
];
const
int
w
=
s
->
planewidth
[
p
]
-
1
;
const
int
h
=
s
->
planeheight
[
p
]
-
1
;
const
int
ref0
=
src_ptr
[
av_clip
(
y
+
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
x_pos
,
0
,
w
)];
const
int
ref1
=
src_ptr
[
av_clip
(
y
+
-
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
x_pos
,
0
,
w
)];
const
int
ref2
=
src_ptr
[
av_clip
(
y
+
-
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
-
x_pos
,
0
,
w
)];
const
int
ref3
=
src_ptr
[
av_clip
(
y
+
y_pos
,
0
,
h
)
*
src_linesize
+
av_clip
(
x
+
-
x_pos
,
0
,
w
)];
const
int
src0
=
src_ptr
[
y
*
src_linesize
+
x
];
src
[
p
]
=
src0
;
avg
[
p
]
=
get_avg
(
ref0
,
ref1
,
ref2
,
ref3
);
if
(
s
->
blur
)
{
cmp
[
p
]
=
FFABS
(
src0
-
avg
[
p
])
<
thr
;
}
else
{
cmp
[
p
]
=
(
FFABS
(
src0
-
ref0
)
<
thr
)
&&
(
FFABS
(
src0
-
ref1
)
<
thr
)
&&
(
FFABS
(
src0
-
ref2
)
<
thr
)
&&
(
FFABS
(
src0
-
ref3
)
<
thr
);
}
}
for
(
z
=
0
;
z
<
s
->
nb_components
;
z
++
)
if
(
!
cmp
[
z
])
break
;
if
(
z
==
s
->
nb_components
)
{
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
int
dst_linesize
=
out
->
linesize
[
p
]
/
2
;
uint16_t
*
dst
=
(
uint16_t
*
)
out
->
data
[
p
]
+
y
*
dst_linesize
+
x
;
dst
[
0
]
=
avg
[
p
];
}
}
else
{
for
(
p
=
0
;
p
<
s
->
nb_components
;
p
++
)
{
const
int
dst_linesize
=
out
->
linesize
[
p
]
/
2
;
uint16_t
*
dst
=
(
uint16_t
*
)
out
->
data
[
p
]
+
y
*
dst_linesize
+
x
;
dst
[
0
]
=
src
[
p
];
}
}
}
}
return
0
;
}
static
int
deband_16_c
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
DebandContext
*
s
=
ctx
->
priv
;
...
...
@@ -222,8 +375,13 @@ static int config_input(AVFilterLink *inlink)
s
->
planeheight
[
0
]
=
s
->
planeheight
[
3
]
=
inlink
->
h
;
s
->
planewidth
[
1
]
=
s
->
planewidth
[
2
]
=
AV_CEIL_RSHIFT
(
inlink
->
w
,
desc
->
log2_chroma_w
);
s
->
planewidth
[
0
]
=
s
->
planewidth
[
3
]
=
inlink
->
w
;
s
->
shift
[
0
]
=
desc
->
log2_chroma_w
;
s
->
shift
[
1
]
=
desc
->
log2_chroma_h
;
s
->
deband
=
desc
->
comp
[
0
].
depth
>
8
?
deband_16_c
:
deband_8_c
;
if
(
s
->
coupling
)
s
->
deband
=
desc
->
comp
[
0
].
depth
>
8
?
deband_16_coupling_c
:
deband_8_coupling_c
;
else
s
->
deband
=
desc
->
comp
[
0
].
depth
>
8
?
deband_16_c
:
deband_8_c
;
s
->
thr
[
0
]
=
((
1
<<
desc
->
comp
[
0
].
depth
)
-
1
)
*
s
->
threshold
[
0
];
s
->
thr
[
1
]
=
((
1
<<
desc
->
comp
[
1
].
depth
)
-
1
)
*
s
->
threshold
[
1
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录