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
4278f79e
Commit
4278f79e
authored
May 07, 2018
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/nlmeans: use unsigned for the integral patch value
This value can not be negative.
parent
de956198
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
vf_nlmeans.c
libavfilter/vf_nlmeans.c
+8
-8
No files found.
libavfilter/vf_nlmeans.c
View file @
4278f79e
...
...
@@ -64,7 +64,7 @@ typedef struct NLMeansContext {
ptrdiff_t
wa_linesize
;
// linesize for wa in struct size unit
float
weight_lut
[
WEIGHT_LUT_SIZE
];
// lookup table mapping (scaled) patch differences to their associated weights
float
pdiff_lut_scale
;
// scale factor for patch differences before looking into the LUT
int
max_meaningful_diff
;
// maximum difference considered (if the patch difference is too high we ignore the pixel)
uint32_t
max_meaningful_diff
;
// maximum difference considered (if the patch difference is too high we ignore the pixel)
NLMeansDSPContext
dsp
;
}
NLMeansContext
;
...
...
@@ -129,12 +129,12 @@ static int query_formats(AVFilterContext *ctx)
* contains the sum of the squared difference of every corresponding pixels of
* two input planes of the same size as M.
*/
static
inline
in
t
get_integral_patch_value
(
const
uint32_t
*
ii
,
int
ii_lz_32
,
int
x
,
int
y
,
int
p
)
static
inline
uint32_
t
get_integral_patch_value
(
const
uint32_t
*
ii
,
int
ii_lz_32
,
int
x
,
int
y
,
int
p
)
{
const
in
t
a
=
ii
[(
y
-
p
-
1
)
*
ii_lz_32
+
(
x
-
p
-
1
)];
const
in
t
b
=
ii
[(
y
-
p
-
1
)
*
ii_lz_32
+
(
x
+
p
)];
const
in
t
d
=
ii
[(
y
+
p
)
*
ii_lz_32
+
(
x
-
p
-
1
)];
const
in
t
e
=
ii
[(
y
+
p
)
*
ii_lz_32
+
(
x
+
p
)];
const
uint32_
t
a
=
ii
[(
y
-
p
-
1
)
*
ii_lz_32
+
(
x
-
p
-
1
)];
const
uint32_
t
b
=
ii
[(
y
-
p
-
1
)
*
ii_lz_32
+
(
x
+
p
)];
const
uint32_
t
d
=
ii
[(
y
+
p
)
*
ii_lz_32
+
(
x
-
p
-
1
)];
const
uint32_
t
e
=
ii
[(
y
+
p
)
*
ii_lz_32
+
(
x
+
p
)];
return
e
-
d
-
b
+
a
;
}
...
...
@@ -398,9 +398,9 @@ static int nlmeans_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
const
uint8_t
*
src
=
td
->
src
+
y
*
src_linesize
;
struct
weighted_avg
*
wa
=
s
->
wa
+
y
*
s
->
wa_linesize
;
for
(
x
=
td
->
startx
;
x
<
td
->
endx
;
x
++
)
{
const
in
t
patch_diff_sq
=
get_integral_patch_value
(
td
->
ii_start
,
s
->
ii_lz_32
,
x
,
y
,
td
->
p
);
const
uint32_
t
patch_diff_sq
=
get_integral_patch_value
(
td
->
ii_start
,
s
->
ii_lz_32
,
x
,
y
,
td
->
p
);
if
(
patch_diff_sq
<
s
->
max_meaningful_diff
)
{
const
int
weight_lut_idx
=
patch_diff_sq
*
s
->
pdiff_lut_scale
;
const
unsigned
weight_lut_idx
=
patch_diff_sq
*
s
->
pdiff_lut_scale
;
const
float
weight
=
s
->
weight_lut
[
weight_lut_idx
];
// exp(-patch_diff_sq * s->pdiff_scale)
wa
[
x
].
total_weight
+=
weight
;
wa
[
x
].
sum
+=
weight
*
src
[
x
];
...
...
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