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
395e8a53
Commit
395e8a53
authored
Jan 10, 2019
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_anlmdn: use lut table to calculate weights
parent
dcae5ba3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
af_anlmdn.c
libavfilter/af_anlmdn.c
+21
-4
No files found.
libavfilter/af_anlmdn.c
View file @
395e8a53
...
@@ -29,6 +29,10 @@
...
@@ -29,6 +29,10 @@
#include "af_anlmdndsp.h"
#include "af_anlmdndsp.h"
#define MAX_DIFF 11.f
#define WEIGHT_LUT_NBITS 20
#define WEIGHT_LUT_SIZE (1<<WEIGHT_LUT_NBITS)
#define SQR(x) ((x) * (x))
#define SQR(x) ((x) * (x))
typedef
struct
AudioNLMeansContext
{
typedef
struct
AudioNLMeansContext
{
...
@@ -38,6 +42,9 @@ typedef struct AudioNLMeansContext {
...
@@ -38,6 +42,9 @@ typedef struct AudioNLMeansContext {
int64_t
pd
;
int64_t
pd
;
int64_t
rd
;
int64_t
rd
;
float
pdiff_lut_scale
;
float
weight_lut
[
WEIGHT_LUT_SIZE
];
int
K
;
int
K
;
int
S
;
int
S
;
int
N
;
int
N
;
...
@@ -150,6 +157,13 @@ static int config_output(AVFilterLink *outlink)
...
@@ -150,6 +157,13 @@ static int config_output(AVFilterLink *outlink)
if
(
!
s
->
fifo
)
if
(
!
s
->
fifo
)
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
s
->
pdiff_lut_scale
=
1
.
f
/
MAX_DIFF
*
WEIGHT_LUT_SIZE
;
for
(
int
i
=
0
;
i
<
WEIGHT_LUT_SIZE
;
i
++
)
{
float
w
=
-
i
/
s
->
pdiff_lut_scale
;
s
->
weight_lut
[
i
]
=
expf
(
w
);
}
ff_anlmdn_init
(
&
s
->
dsp
);
ff_anlmdn_init
(
&
s
->
dsp
);
return
0
;
return
0
;
...
@@ -183,13 +197,16 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
...
@@ -183,13 +197,16 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs)
for
(
int
j
=
0
;
j
<
2
*
S
;
j
++
)
{
for
(
int
j
=
0
;
j
<
2
*
S
;
j
++
)
{
const
float
distance
=
cache
[
j
];
const
float
distance
=
cache
[
j
];
unsigned
weight_lut_idx
;
float
w
;
float
w
;
av_assert
0
(
distance
>=
0
.
f
);
av_assert
2
(
distance
>=
0
.
f
);
w
=
-
distance
*
sw
;
w
=
distance
*
sw
;
if
(
w
<
-
11
.
f
)
if
(
w
>=
MAX_DIFF
)
continue
;
continue
;
w
=
expf
(
w
);
weight_lut_idx
=
w
*
s
->
pdiff_lut_scale
;
av_assert2
(
weight_lut_idx
<
WEIGHT_LUT_SIZE
);
w
=
s
->
weight_lut
[
weight_lut_idx
];
P
+=
w
*
f
[
i
-
S
+
j
+
(
j
>=
S
)];
P
+=
w
*
f
[
i
-
S
+
j
+
(
j
>=
S
)];
Q
+=
w
;
Q
+=
w
;
}
}
...
...
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