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
1a9c6cc4
Commit
1a9c6cc4
authored
Feb 01, 2019
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/nlmeans: use a dynamic size for the weight LUT
parent
65e61feb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
vf_nlmeans.c
libavfilter/vf_nlmeans.c
+6
-10
No files found.
libavfilter/vf_nlmeans.c
View file @
1a9c6cc4
...
@@ -43,13 +43,6 @@ struct weighted_avg {
...
@@ -43,13 +43,6 @@ struct weighted_avg {
float
sum
;
float
sum
;
};
};
/*
* Note: WEIGHT_LUT_SIZE must be larger than max_meaningful_diff
* (log(255)*max(h)^2, which is approximately 500000 with the current
* maximum sigma of 30).
*/
#define WEIGHT_LUT_SIZE 500000
typedef
struct
NLMeansContext
{
typedef
struct
NLMeansContext
{
const
AVClass
*
class
;
const
AVClass
*
class
;
int
nb_planes
;
int
nb_planes
;
...
@@ -66,7 +59,7 @@ typedef struct NLMeansContext {
...
@@ -66,7 +59,7 @@ typedef struct NLMeansContext {
ptrdiff_t
ii_lz_32
;
// linesize in 32-bit units of the integral image
ptrdiff_t
ii_lz_32
;
// linesize in 32-bit units of the integral image
struct
weighted_avg
*
wa
;
// weighted average of every pixel
struct
weighted_avg
*
wa
;
// weighted average of every pixel
ptrdiff_t
wa_linesize
;
// linesize for wa in struct size unit
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
*
weight_lut
;
// lookup table mapping (scaled) patch differences to their associated weights
uint32_t
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
;
NLMeansDSPContext
dsp
;
}
NLMeansContext
;
}
NLMeansContext
;
...
@@ -529,8 +522,10 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -529,8 +522,10 @@ static av_cold int init(AVFilterContext *ctx)
s
->
pdiff_scale
=
1
.
/
(
h
*
h
);
s
->
pdiff_scale
=
1
.
/
(
h
*
h
);
s
->
max_meaningful_diff
=
log
(
255
.)
/
s
->
pdiff_scale
;
s
->
max_meaningful_diff
=
log
(
255
.)
/
s
->
pdiff_scale
;
av_assert0
((
s
->
max_meaningful_diff
-
1
)
<
FF_ARRAY_ELEMS
(
s
->
weight_lut
));
s
->
weight_lut
=
av_calloc
(
s
->
max_meaningful_diff
,
sizeof
(
*
s
->
weight_lut
));
for
(
i
=
0
;
i
<
WEIGHT_LUT_SIZE
;
i
++
)
if
(
!
s
->
weight_lut
)
return
AVERROR
(
ENOMEM
);
for
(
i
=
0
;
i
<
s
->
max_meaningful_diff
;
i
++
)
s
->
weight_lut
[
i
]
=
exp
(
-
i
*
s
->
pdiff_scale
);
s
->
weight_lut
[
i
]
=
exp
(
-
i
*
s
->
pdiff_scale
);
CHECK_ODD_FIELD
(
research_size
,
"Luma research window"
);
CHECK_ODD_FIELD
(
research_size
,
"Luma research window"
);
...
@@ -559,6 +554,7 @@ static av_cold int init(AVFilterContext *ctx)
...
@@ -559,6 +554,7 @@ static av_cold int init(AVFilterContext *ctx)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
static
av_cold
void
uninit
(
AVFilterContext
*
ctx
)
{
{
NLMeansContext
*
s
=
ctx
->
priv
;
NLMeansContext
*
s
=
ctx
->
priv
;
av_freep
(
&
s
->
weight_lut
);
av_freep
(
&
s
->
ii_orig
);
av_freep
(
&
s
->
ii_orig
);
av_freep
(
&
s
->
wa
);
av_freep
(
&
s
->
wa
);
}
}
...
...
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