Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
38c86e7a
Commit
38c86e7a
authored
Oct 24, 2021
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/vf_nlmeans: avoid if () to help paralellization
parent
64d19411
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
vf_nlmeans.c
libavfilter/vf_nlmeans.c
+6
-7
No files found.
libavfilter/vf_nlmeans.c
View file @
38c86e7a
...
...
@@ -332,6 +332,7 @@ struct thread_data {
static
int
nlmeans_slice
(
AVFilterContext
*
ctx
,
void
*
arg
,
int
jobnr
,
int
nb_jobs
)
{
NLMeansContext
*
s
=
ctx
->
priv
;
const
uint32_t
max_meaningful_diff
=
s
->
max_meaningful_diff
;
const
struct
thread_data
*
td
=
arg
;
const
ptrdiff_t
src_linesize
=
td
->
src_linesize
;
const
int
process_h
=
td
->
endy
-
td
->
starty
;
...
...
@@ -383,13 +384,11 @@ static int nlmeans_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
const
uint32_t
b
=
ii
[
x
+
dist_b
];
const
uint32_t
d
=
ii
[
x
+
dist_d
];
const
uint32_t
e
=
ii
[
x
+
dist_e
];
const
uint32_t
patch_diff_sq
=
e
-
d
-
b
+
a
;
const
uint32_t
patch_diff_sq
=
FFMIN
(
e
-
d
-
b
+
a
,
max_meaningful_diff
);
const
float
weight
=
weight_lut
[
patch_diff_sq
];
// exp(-patch_diff_sq * s->pdiff_scale)
if
(
patch_diff_sq
<
s
->
max_meaningful_diff
)
{
const
float
weight
=
weight_lut
[
patch_diff_sq
];
// exp(-patch_diff_sq * s->pdiff_scale)
wa
[
x
].
total_weight
+=
weight
;
wa
[
x
].
sum
+=
weight
*
src
[
x
];
}
wa
[
x
].
total_weight
+=
weight
;
wa
[
x
].
sum
+=
weight
*
src
[
x
];
}
ii
+=
s
->
ii_lz_32
;
}
...
...
@@ -506,7 +505,7 @@ static av_cold int init(AVFilterContext *ctx)
s
->
pdiff_scale
=
1
.
/
(
h
*
h
);
s
->
max_meaningful_diff
=
log
(
255
.)
/
s
->
pdiff_scale
;
s
->
weight_lut
=
av_calloc
(
s
->
max_meaningful_diff
,
sizeof
(
*
s
->
weight_lut
));
s
->
weight_lut
=
av_calloc
(
s
->
max_meaningful_diff
+
1
,
sizeof
(
*
s
->
weight_lut
));
if
(
!
s
->
weight_lut
)
return
AVERROR
(
ENOMEM
);
for
(
int
i
=
0
;
i
<
s
->
max_meaningful_diff
;
i
++
)
...
...
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