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
98b8be09
Verified
Commit
98b8be09
authored
1 year ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Vectorize DRED quantization
parent
fa5e960c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silk/dred_encoder.c
+19
-11
19 additions, 11 deletions
silk/dred_encoder.c
with
19 additions
and
11 deletions
silk/dred_encoder.c
+
19
−
11
View file @
98b8be09
...
...
@@ -31,7 +31,7 @@
#include
<string.h>
#if
1
#if
0
#include <stdio.h>
#include <math.h>
#endif
...
...
@@ -43,7 +43,6 @@
#include
"dred_decoder.h"
#include
"float_cast.h"
#include
"os_support.h"
#include
"vec.h"
#include
"celt/laplace.h"
...
...
@@ -220,18 +219,27 @@ void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int ex
static
void
dred_encode_latents
(
ec_enc
*
enc
,
const
float
*
x
,
const
opus_uint16
*
scale
,
const
opus_uint16
*
dzone
,
const
opus_uint16
*
r
,
const
opus_uint16
*
p0
,
int
dim
)
{
int
i
;
int
q
[
IMAX
(
DRED_LATENT_DIM
,
DRED_STATE_DIM
)];
float
xq
[
IMAX
(
DRED_LATENT_DIM
,
DRED_STATE_DIM
)];
float
delta
[
IMAX
(
DRED_LATENT_DIM
,
DRED_STATE_DIM
)];
float
deadzone
[
IMAX
(
DRED_LATENT_DIM
,
DRED_STATE_DIM
)];
float
eps
=
.
1
f
;
/* This is split into multiple loops (with temporary arrays) so that the compiler
can vectorize all of it, and so we can call the vector tanh(). */
for
(
i
=
0
;
i
<
dim
;
i
++
)
{
delta
[
i
]
=
dzone
[
i
]
*
(
1
.
f
/
1024
.
f
);
xq
[
i
]
=
x
[
i
]
*
scale
[
i
]
*
(
1
.
f
/
256
.
f
);
deadzone
[
i
]
=
xq
[
i
]
/
(
delta
[
i
]
+
eps
);
}
compute_activation
(
deadzone
,
deadzone
,
dim
,
ACTIVATION_TANH
);
for
(
i
=
0
;
i
<
dim
;
i
++
)
{
xq
[
i
]
=
xq
[
i
]
-
delta
[
i
]
*
deadzone
[
i
];
q
[
i
]
=
(
int
)
floor
(.
5
f
+
xq
[
i
]);
}
for
(
i
=
0
;
i
<
dim
;
i
++
)
{
float
delta
;
float
xq
;
int
q
;
delta
=
dzone
[
i
]
*
(
1
.
f
/
1024
.
f
);
xq
=
x
[
i
]
*
scale
[
i
]
*
(
1
.
f
/
256
.
f
);
xq
=
xq
-
delta
*
tanh_approx
(
xq
/
(
delta
+
eps
));
q
=
(
int
)
floor
(.
5
f
+
xq
);
/* Make the impossible actually impossible. */
if
(
r
[
i
]
==
0
||
p0
[
i
]
>=
32767
)
q
=
0
;
ec_laplace_encode_p0
(
enc
,
q
,
p0
[
i
],
r
[
i
]);
if
(
r
[
i
]
==
0
||
p0
[
i
]
>=
32767
)
q
[
i
]
=
0
;
ec_laplace_encode_p0
(
enc
,
q
[
i
]
,
p0
[
i
],
r
[
i
]);
}
}
...
...
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