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
aa7e1748
Commit
aa7e1748
authored
9 years ago
by
Koen Vos
Committed by
Jean-Marc Valin
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
NLSF VQ now uses absolute error, and prediction
parent
2955f68b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
silk/NLSF_VQ.c
+25
-17
25 additions, 17 deletions
silk/NLSF_VQ.c
silk/NLSF_decode.c
+1
-1
1 addition, 1 deletion
silk/NLSF_decode.c
silk/NLSF_encode.c
+1
-1
1 addition, 1 deletion
silk/NLSF_encode.c
silk/main.h
+1
-0
1 addition, 0 deletions
silk/main.h
with
28 additions
and
19 deletions
silk/NLSF_VQ.c
+
25
−
17
View file @
aa7e1748
...
...
@@ -33,36 +33,44 @@ POSSIBILITY OF SUCH DAMAGE.
/* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
void
silk_NLSF_VQ
(
opus_int32
err_Q2
6
[],
/* O Quantization errors [K] */
opus_int32
err_Q2
4
[],
/* O Quantization errors [K] */
const
opus_int16
in_Q15
[],
/* I Input vectors to be quantized [LPC_order] */
const
opus_uint8
pCB_Q8
[],
/* I Codebook vectors [K*LPC_order] */
const
opus_int16
pWght_Q9
[],
/* I Codebook weights [K*LPC_order] */
const
opus_int
K
,
/* I Number of codebook vectors */
const
opus_int
LPC_order
/* I Number of LPCs */
)
{
opus_int
i
,
m
;
opus_int32
diff_Q15
,
sum_error_Q30
,
sum_error_Q26
;
opus_int
i
,
m
;
opus_int32
diff_Q15
,
diffw_Q24
,
sum_error_Q24
,
pred_Q24
;
const
opus_int16
*
w_Q9_ptr
;
const
opus_uint8
*
cb_Q8_ptr
;
silk_assert
(
LPC_order
<=
16
);
silk_assert
(
(
LPC_order
&
1
)
==
0
);
/* Loop over codebook */
cb_Q8_ptr
=
pCB_Q8
;
w_Q9_ptr
=
pWght_Q9
;
for
(
i
=
0
;
i
<
K
;
i
++
)
{
sum_error_Q26
=
0
;
for
(
m
=
0
;
m
<
LPC_order
;
m
+=
2
)
{
/* Compute weighted squared quantization error for index m */
diff_Q15
=
silk_SUB_LSHIFT32
(
in_Q15
[
m
],
(
opus_int32
)
*
pCB_Q8
++
,
7
);
/* range: [ -32767 : 32767 ]*/
sum_error_Q30
=
silk_SMULBB
(
diff_Q15
,
diff_Q15
);
sum_error_Q24
=
0
;
pred_Q24
=
0
;
for
(
m
=
LPC_order
-
2
;
m
>=
0
;
m
-=
2
)
{
/* Compute weighted absolute predictive quantization error for index m + 1 */
diff_Q15
=
silk_SUB_LSHIFT32
(
in_Q15
[
m
+
1
],
(
opus_int32
)
cb_Q8_ptr
[
m
+
1
],
7
);
/* range: [ -32767 : 32767 ]*/
diffw_Q24
=
silk_SMULBB
(
diff_Q15
,
w_Q9_ptr
[
m
+
1
]
);
sum_error_Q24
=
silk_ADD32
(
sum_error_Q24
,
silk_abs
(
silk_SUB_RSHIFT32
(
diffw_Q24
,
pred_Q24
,
1
)
)
);
pred_Q24
=
diffw_Q24
;
/* Compute weighted squared quantization error for index m + 1 */
diff_Q15
=
silk_SUB_LSHIFT32
(
in_Q15
[
m
+
1
],
(
opus_int32
)
*
pCB_Q8
++
,
7
);
/* range: [ -32767 : 32767 ]*/
sum_error_Q30
=
silk_SMLABB
(
sum_error_Q30
,
diff_Q15
,
diff_Q15
);
/* Compute weighted absolute predictive quantization error for index m */
diff_Q15
=
silk_SUB_LSHIFT32
(
in_Q15
[
m
],
(
opus_int32
)
cb_Q8_ptr
[
m
],
7
);
/* range: [ -32767 : 32767 ]*/
diffw_Q24
=
silk_SMULBB
(
diff_Q15
,
w_Q9_ptr
[
m
]
);
sum_error_Q24
=
silk_ADD32
(
sum_error_Q24
,
silk_abs
(
silk_SUB_RSHIFT32
(
diffw_Q24
,
pred_Q24
,
1
)
)
);
pred_Q24
=
diffw_Q24
;
sum_error_Q26
=
silk_ADD_RSHIFT32
(
sum_error_Q26
,
sum_error_Q30
,
4
);
silk_assert
(
sum_error_Q26
>=
0
);
silk_assert
(
sum_error_Q30
>=
0
);
silk_assert
(
sum_error_Q24
>=
0
);
}
err_Q26
[
i
]
=
sum_error_Q26
;
err_Q24
[
i
]
=
sum_error_Q24
;
cb_Q8_ptr
+=
LPC_order
;
w_Q9_ptr
+=
LPC_order
;
}
}
This diff is collapsed.
Click to expand it.
silk/NLSF_decode.c
+
1
−
1
View file @
aa7e1748
...
...
@@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include
"main.h"
/* Predictive dequantizer for NLSF residuals */
static
OPUS_INLINE
void
silk_NLSF_residual_dequant
(
/* O Returns RD value in Q30 */
static
OPUS_INLINE
void
silk_NLSF_residual_dequant
(
/* O Returns RD value in Q30 */
opus_int16
x_Q10
[],
/* O Output [ order ] */
const
opus_int8
indices
[],
/* I Quantization indices [ order ] */
const
opus_uint8
pred_coef_Q8
[],
/* I Backward predictor coefs [ order ] */
...
...
This diff is collapsed.
Click to expand it.
silk/NLSF_encode.c
+
1
−
1
View file @
aa7e1748
...
...
@@ -70,7 +70,7 @@ opus_int32 silk_NLSF_encode( /* O Returns
/* First stage: VQ */
ALLOC
(
err_Q26
,
psNLSF_CB
->
nVectors
,
opus_int32
);
silk_NLSF_VQ
(
err_Q26
,
pNLSF_Q15
,
psNLSF_CB
->
CB1_NLSF_Q8
,
psNLSF_CB
->
nVectors
,
psNLSF_CB
->
order
);
silk_NLSF_VQ
(
err_Q26
,
pNLSF_Q15
,
psNLSF_CB
->
CB1_NLSF_Q8
,
psNLSF_CB
->
CB1_Wght_Q9
,
psNLSF_CB
->
nVectors
,
psNLSF_CB
->
order
);
/* Sort the quantization errors */
ALLOC
(
tempIndices1
,
nSurvivors
,
opus_int
);
...
...
This diff is collapsed.
Click to expand it.
silk/main.h
+
1
−
0
View file @
aa7e1748
...
...
@@ -346,6 +346,7 @@ void silk_NLSF_VQ(
opus_int32
err_Q26
[],
/* O Quantization errors [K] */
const
opus_int16
in_Q15
[],
/* I Input vectors to be quantized [LPC_order] */
const
opus_uint8
pCB_Q8
[],
/* I Codebook vectors [K*LPC_order] */
const
opus_int16
pWght_Q9
[],
/* I Codebook weights [K*LPC_order] */
const
opus_int
K
,
/* I Number of codebook vectors */
const
opus_int
LPC_order
/* I Number of LPCs */
);
...
...
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