Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoen Vos <koenvos@users.noreply.github.com>2016-06-01 08:14:32 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-06-29 22:21:31 +0300
commited41deea7a74142fc80e40974e7019fe34401c97 (patch)
tree7e33265607ec04b1f6bf2d1660304dd2257002fe
parentcb952ef9eed9d99caebb998c7fcd52f11bdd6c6c (diff)
more conservative scaling of LTP corrs; remove assert that checks for negative residual energy; discard CB entries leading to such negative energies
-rw-r--r--silk/VQ_WMat_EC.c15
-rw-r--r--silk/fixed/find_LTP_FIX.c17
-rw-r--r--silk/fixed/find_pred_coefs_FIX.c2
-rw-r--r--silk/float/find_LTP_FLP.c10
-rw-r--r--silk/main.h2
-rw-r--r--silk/quant_LTP_gains.c22
-rw-r--r--silk/tuning_parameters.h3
7 files changed, 30 insertions, 41 deletions
diff --git a/silk/VQ_WMat_EC.c b/silk/VQ_WMat_EC.c
index 67e63418..966d7c36 100644
--- a/silk/VQ_WMat_EC.c
+++ b/silk/VQ_WMat_EC.c
@@ -34,13 +34,13 @@ POSSIBILITY OF SUCH DAMAGE.
/* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */
void silk_VQ_WMat_EC_c(
opus_int8 *ind, /* O index of best codebook vector */
- opus_int32 *res_nrg_Q15, /* O best residual energy */
- opus_int32 *rate_dist_Q8, /* O best total bitrate */
+ opus_int32 *res_nrg_Q15, /* O best residual energy */
+ opus_int32 *rate_dist_Q8, /* O best total bitrate */
const opus_int32 *XX_Q17, /* I correlation matrix */
- const opus_int32 *xX_Q17, /* I correlation vector */
+ const opus_int32 *xX_Q17, /* I correlation vector */
const opus_int8 *cb_Q7, /* I codebook */
const opus_uint8 *cl_Q5, /* I code length for each codebook vector */
- const opus_int subfr_len, /* I number of samples per subframe */
+ const opus_int subfr_len, /* I number of samples per subframe */
const opus_int L /* I number of vectors in codebook */
)
{
@@ -65,7 +65,7 @@ void silk_VQ_WMat_EC_c(
for( k = 0; k < L; k++ ) {
/* Weighted rate */
/* Quantization error: 1 - 2* xX * cb + cb' * XX * cb */
- sum1_Q15 = SILK_FIX_CONST( 1.0001, 15 );
+ sum1_Q15 = SILK_FIX_CONST( 1.001, 15 );
/* first row of XX_Q17 */
sum2_Q24 = silk_MLA( neg_xX_Q24[ 0 ], XX_Q17[ 1 ], cb_row_Q7[ 1 ] );
@@ -102,11 +102,8 @@ void silk_VQ_WMat_EC_c(
sum2_Q24 = silk_MLA( sum2_Q24, XX_Q17[ 24 ], cb_row_Q7[ 4 ] );
sum1_Q15 = silk_SMLAWB( sum1_Q15, sum2_Q24, cb_row_Q7[ 4 ] );
- /* If ever the following assert triggers, increase LTP_CORR_INV_MAX */
- silk_assert( sum1_Q15 >= 0 );
-
/* find best */
- if( sum1_Q15 <= sum1_best_Q15 ) {
+ if( sum1_Q15 <= sum1_best_Q15 && sum1_Q15 >= 0 ) {
sum1_best_Q15 = sum1_Q15;
/* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */
bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 ) - (15 << 7) );
diff --git a/silk/fixed/find_LTP_FIX.c b/silk/fixed/find_LTP_FIX.c
index aea6fc01..c773966c 100644
--- a/silk/fixed/find_LTP_FIX.c
+++ b/silk/fixed/find_LTP_FIX.c
@@ -33,9 +33,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "tuning_parameters.h"
void silk_find_LTP_FIX(
- opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */
- opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */
- const opus_int16 r_ptr[], /* I Residual signal after LPC */
+ opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */
+ opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */
+ const opus_int16 r_ptr[], /* I Residual signal after LPC */
const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
const opus_int subfr_length, /* I Subframe length */
const opus_int nb_subfr, /* I Number of subframes */
@@ -53,28 +53,27 @@ void silk_find_LTP_FIX(
for( k = 0; k < nb_subfr; k++ ) {
lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );
- silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length ); /* xx in Q( -xx_shifts ) */
+ silk_sum_sqr_shift( &xx, &xx_shifts, r_ptr, subfr_length + LTP_ORDER ); /* xx in Q( -xx_shifts ) */
silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, XXLTP_Q17_ptr, &nrg, &XX_shifts, arch ); /* XXLTP_Q17_ptr and nrg in Q( -XX_shifts ) */
extra_shifts = xx_shifts - XX_shifts;
if( extra_shifts > 0 ) {
/* Shift XX */
xX_shifts = xx_shifts;
for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
- XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */
+ XXLTP_Q17_ptr[ i ] = silk_RSHIFT32( XXLTP_Q17_ptr[ i ], extra_shifts ); /* Q( -xX_shifts ) */
}
nrg = silk_RSHIFT32( nrg, extra_shifts ); /* Q( -xX_shifts ) */
- } else if( extra_shifts < 0 ) {
+ } else if( extra_shifts < 0 ) {
/* Shift xx */
xX_shifts = XX_shifts;
- xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */
+ xx = silk_RSHIFT32( xx, -extra_shifts ); /* Q( -xX_shifts ) */
} else {
xX_shifts = xx_shifts;
}
silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xXLTP_Q17_ptr, xX_shifts, arch ); /* xXLTP_Q17_ptr in Q( -xX_shifts ) */
/* At this point all correlations are in Q(-xX_shifts) */
- temp = silk_SMLAWB( 1, nrg, SILK_FIX_CONST( LTP_CORR_INV_MAX, 16 ) );
- temp = silk_max( temp, xx );
+ temp = silk_ADD32( xx, 1 );
TIC(div)
#if 0
for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) {
diff --git a/silk/fixed/find_pred_coefs_FIX.c b/silk/fixed/find_pred_coefs_FIX.c
index 2b286a6a..0bfa58ca 100644
--- a/silk/fixed/find_pred_coefs_FIX.c
+++ b/silk/fixed/find_pred_coefs_FIX.c
@@ -86,7 +86,7 @@ void silk_find_pred_coefs_FIX(
ALLOC( XXLTP_Q17, psEnc->sCmn.nb_subfr * LTP_ORDER * LTP_ORDER, opus_int32 );
/* LTP analysis */
- silk_find_LTP_FIX( XXLTP_Q17, xXLTP_Q17, res_pitch,
+ silk_find_LTP_FIX( XXLTP_Q17, xXLTP_Q17, res_pitch,
psEncCtrl->pitchL, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.arch );
/* Quantize LTP gain parameters */
diff --git a/silk/float/find_LTP_FLP.c b/silk/float/find_LTP_FLP.c
index 2e1a0fe5..c9295236 100644
--- a/silk/float/find_LTP_FLP.c
+++ b/silk/float/find_LTP_FLP.c
@@ -33,10 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "tuning_parameters.h"
void silk_find_LTP_FLP(
- silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
- silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */
+ silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
+ silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */
const silk_float r_ptr[], /* I LPC residual */
- const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
+ const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
const opus_int subfr_length, /* I Subframe length */
const opus_int nb_subfr /* I number of subframes */
)
@@ -52,8 +52,8 @@ void silk_find_LTP_FLP(
lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );
silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, XX_ptr );
silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, xX_ptr );
- xx = ( silk_float )silk_energy_FLP( r_ptr, subfr_length );
- temp = 1.0f / silk_max( xx, LTP_CORR_INV_MAX * 0.5f * ( XX_ptr[ 0 ] + XX_ptr[ 24 ] ) + 1.0f );
+ xx = ( silk_float )silk_energy_FLP( r_ptr, subfr_length + LTP_ORDER );
+ temp = 1.0f / ( xx + 1.0f );
silk_scale_vector_FLP( XX_ptr, temp, LTP_ORDER * LTP_ORDER );
silk_scale_vector_FLP( xX_ptr, temp, LTP_ORDER );
diff --git a/silk/main.h b/silk/main.h
index 14229b04..94315b47 100644
--- a/silk/main.h
+++ b/silk/main.h
@@ -210,7 +210,7 @@ void silk_quant_LTP_gains(
opus_int8 *periodicity_index, /* O Periodicity Index */
opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */
const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */
- const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation vector in Q18 */
+ const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER ], /* I Correlation vector in Q18 */
const opus_int subfr_len, /* I Number of samples per subframe */
const opus_int nb_subfr, /* I Number of subframes */
int arch /* I Run-time architecture */
diff --git a/silk/quant_LTP_gains.c b/silk/quant_LTP_gains.c
index 23f85695..6fd28d20 100644
--- a/silk/quant_LTP_gains.c
+++ b/silk/quant_LTP_gains.c
@@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "main.h"
void silk_quant_LTP_gains(
- opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */
+ opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */
opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */
opus_int8 *periodicity_index, /* O Periodicity Index */
- opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */
+ opus_int *pred_gain_dB_Q7, /* O LTP prediction gain */
const opus_int32 XX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation matrix in Q18 */
- const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ], /* I Correlation vector in Q18 */
- const opus_int subfr_len, /* I Number of samples per subframe */
+ const opus_int32 xX_Q17[ MAX_NB_SUBFR*LTP_ORDER ], /* I Correlation vector in Q18 */
+ const opus_int subfr_len, /* I Number of samples per subframe */
const opus_int nb_subfr, /* I Number of subframes */
int arch /* I Run-time architecture */
)
@@ -47,7 +47,6 @@ void silk_quant_LTP_gains(
opus_int8 temp_idx[ MAX_NB_SUBFR ];
const opus_uint8 *cl_ptr_Q5;
const opus_int8 *cbk_ptr_Q7;
- const opus_int16 *b_Q14_ptr;
const opus_int32 *XX_Q17_ptr, *xX_Q17_ptr;
opus_int32 res_nrg_Q15_subfr, res_nrg_Q15, rate_dist_Q7_subfr, rate_dist_Q7, min_rate_dist_Q7;
@@ -61,31 +60,29 @@ void silk_quant_LTP_gains(
cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ k ];
cbk_size = silk_LTP_vq_sizes[ k ];
- /* Set up pointer to first subframe */
+ /* Set up pointers to first subframe */
XX_Q17_ptr = XX_Q17;
xX_Q17_ptr = xX_Q17;
- b_Q14_ptr = B_Q14;
res_nrg_Q15 = 0;
rate_dist_Q7 = 0;
for( j = 0; j < nb_subfr; j++ ) {
silk_VQ_WMat_EC(
&temp_idx[ j ], /* O index of best codebook vector */
- &res_nrg_Q15_subfr, /* O residual energy */
+ &res_nrg_Q15_subfr, /* O residual energy */
&rate_dist_Q7_subfr, /* O best weighted quantization error + mu * rate */
XX_Q17_ptr, /* I correlation matrix */
- xX_Q17_ptr, /* I correlation vector */
+ xX_Q17_ptr, /* I correlation vector */
cbk_ptr_Q7, /* I codebook */
cl_ptr_Q5, /* I code length for each codebook vector */
- subfr_len, /* I number of samples per subframe */
+ subfr_len, /* I number of samples per subframe */
cbk_size, /* I number of vectors in codebook */
arch /* I Run-time architecture */
);
- res_nrg_Q15 = silk_ADD_POS_SAT32( res_nrg_Q15, res_nrg_Q15_subfr );
+ res_nrg_Q15 = silk_ADD_POS_SAT32( res_nrg_Q15, res_nrg_Q15_subfr );
rate_dist_Q7 = silk_ADD_POS_SAT32( rate_dist_Q7, rate_dist_Q7_subfr );
- b_Q14_ptr += LTP_ORDER;
XX_Q17_ptr += LTP_ORDER * LTP_ORDER;
xX_Q17_ptr += LTP_ORDER;
}
@@ -112,4 +109,3 @@ void silk_quant_LTP_gains(
*pred_gain_dB_Q7 = (opus_int)silk_SMULBB( -3, silk_lin2log( res_nrg_Q15 ) - ( 15 << 7 ) );
}
-
diff --git a/silk/tuning_parameters.h b/silk/tuning_parameters.h
index bf1d23b2..f15eb16b 100644
--- a/silk/tuning_parameters.h
+++ b/silk/tuning_parameters.h
@@ -53,9 +53,6 @@ extern "C"
/* LPC analysis defines: regularization and bandwidth expansion */
#define FIND_LPC_COND_FAC 1e-5f
-/* LTP analysis defines */
-#define LTP_CORR_INV_MAX 0.015f
-
/***********************/
/* High pass filtering */
/***********************/