Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
800a659c
Commit
800a659c
authored
6 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Using log approximations
parent
677182fc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dnn/common.h
+22
-2
22 additions, 2 deletions
dnn/common.h
dnn/dump_data.c
+1
-1
1 addition, 1 deletion
dnn/dump_data.c
with
23 additions
and
3 deletions
dnn/common.h
+
22
−
2
View file @
800a659c
...
@@ -12,6 +12,26 @@
...
@@ -12,6 +12,26 @@
float
lpc_from_cepstrum
(
float
*
lpc
,
const
float
*
cepstrum
);
float
lpc_from_cepstrum
(
float
*
lpc
,
const
float
*
cepstrum
);
#define LOG256 5.5451774445f
static
RNN_INLINE
float
log2_approx
(
float
x
)
{
int
integer
;
float
frac
;
union
{
float
f
;
int
i
;
}
in
;
in
.
f
=
x
;
integer
=
(
in
.
i
>>
23
)
-
127
;
in
.
i
-=
integer
<<
23
;
frac
=
in
.
f
-
1
.
5
f
;
frac
=
-
0
.
41445418
f
+
frac
*
(
0
.
95909232
f
+
frac
*
(
-
0
.
33951290
f
+
frac
*
0
.
16541097
f
));
return
1
+
integer
+
frac
;
}
#define log_approx(x) (0.69315f*log2_approx(x))
static
RNN_INLINE
float
ulaw2lin
(
float
u
)
static
RNN_INLINE
float
ulaw2lin
(
float
u
)
{
{
float
s
;
float
s
;
...
@@ -19,7 +39,7 @@ static RNN_INLINE float ulaw2lin(float u)
...
@@ -19,7 +39,7 @@ static RNN_INLINE float ulaw2lin(float u)
u
=
u
-
128
;
u
=
u
-
128
;
s
=
u
>=
0
?
1
:
-
1
;
s
=
u
>=
0
?
1
:
-
1
;
u
=
fabs
(
u
);
u
=
fabs
(
u
);
return
s
*
scale_1
*
(
exp
(
u
/
128
.
*
log
(
256
)
)
-
1
);
return
s
*
scale_1
*
(
exp
(
u
/
128
.
*
LOG
256
)
-
1
);
}
}
static
RNN_INLINE
int
lin2ulaw
(
float
x
)
static
RNN_INLINE
int
lin2ulaw
(
float
x
)
...
@@ -28,7 +48,7 @@ static RNN_INLINE int lin2ulaw(float x)
...
@@ -28,7 +48,7 @@ static RNN_INLINE int lin2ulaw(float x)
float
scale
=
255
.
f
/
32768
.
f
;
float
scale
=
255
.
f
/
32768
.
f
;
int
s
=
x
>=
0
?
1
:
-
1
;
int
s
=
x
>=
0
?
1
:
-
1
;
x
=
fabs
(
x
);
x
=
fabs
(
x
);
u
=
(
s
*
(
128
*
log
(
1
+
scale
*
x
)
/
log
(
256
))
)
;
u
=
(
s
*
(
128
*
log
_approx
(
1
+
scale
*
x
)
/
LOG
256
));
u
=
128
+
u
;
u
=
128
+
u
;
if
(
u
<
0
)
u
=
0
;
if
(
u
<
0
)
u
=
0
;
if
(
u
>
255
)
u
=
255
;
if
(
u
>
255
)
u
=
255
;
...
...
This diff is collapsed.
Click to expand it.
dnn/dump_data.c
+
1
−
1
View file @
800a659c
...
@@ -219,7 +219,7 @@ void write_audio(DenoiseState *st, const short *pcm, float noise_std, FILE *file
...
@@ -219,7 +219,7 @@ void write_audio(DenoiseState *st, const short *pcm, float noise_std, FILE *file
/* Excitation out. */
/* Excitation out. */
data
[
4
*
i
+
3
]
=
e
;
data
[
4
*
i
+
3
]
=
e
;
/* Simulate error on excitation. */
/* Simulate error on excitation. */
noise
=
(
int
)
floor
(.
5
+
noise_std
*
.
707
*
(
log
((
float
)
rand
()
/
RAND_MAX
)
-
log
((
float
)
rand
()
/
RAND_MAX
)));
noise
=
(
int
)
floor
(.
5
+
noise_std
*
.
707
*
(
log
_approx
((
float
)
rand
()
/
RAND_MAX
)
-
log
_approx
((
float
)
rand
()
/
RAND_MAX
)));
e
+=
noise
;
e
+=
noise
;
e
=
IMIN
(
255
,
IMAX
(
0
,
e
));
e
=
IMIN
(
255
,
IMAX
(
0
,
e
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment