OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
5 are met: | 5 are met: |
6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 ALLOC( WLTP, psEnc->sCmn.nb_subfr * LTP_ORDER * LTP_ORDER, opus_int32 ); | 87 ALLOC( WLTP, psEnc->sCmn.nb_subfr * LTP_ORDER * LTP_ORDER, opus_int32 ); |
88 | 88 |
89 /* LTP analysis */ | 89 /* LTP analysis */ |
90 silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGa
in_Q7, | 90 silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGa
in_Q7, |
91 res_pitch, psEncCtrl->pitchL, Wght_Q15, psEnc->sCmn.subfr_length, | 91 res_pitch, psEncCtrl->pitchL, Wght_Q15, psEnc->sCmn.subfr_length, |
92 psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift )
; | 92 psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift )
; |
93 | 93 |
94 /* Quantize LTP gain parameters */ | 94 /* Quantize LTP gain parameters */ |
95 silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPInd
ex, &psEnc->sCmn.indices.PERIndex, | 95 silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPInd
ex, &psEnc->sCmn.indices.PERIndex, |
96 WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEn
c->sCmn.nb_subfr); | 96 &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sC
mn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr); |
97 | 97 |
98 /* Control LTP scaling */ | 98 /* Control LTP scaling */ |
99 silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl, condCoding ); | 99 silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl, condCoding ); |
100 | 100 |
101 /* Create LTP residual */ | 101 /* Create LTP residual */ |
102 silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrde
r, psEncCtrl->LTPCoef_Q14, | 102 silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrde
r, psEncCtrl->LTPCoef_Q14, |
103 psEncCtrl->pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sC
mn.nb_subfr, psEnc->sCmn.predictLPCOrder ); | 103 psEncCtrl->pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sC
mn.nb_subfr, psEnc->sCmn.predictLPCOrder ); |
104 | 104 |
105 } else { | 105 } else { |
106 /************/ | 106 /************/ |
107 /* UNVOICED */ | 107 /* UNVOICED */ |
108 /************/ | 108 /************/ |
109 /* Create signal with prepended subframes, scaled by inverse gains */ | 109 /* Create signal with prepended subframes, scaled by inverse gains */ |
110 x_ptr = x - psEnc->sCmn.predictLPCOrder; | 110 x_ptr = x - psEnc->sCmn.predictLPCOrder; |
111 x_pre_ptr = LPC_in_pre; | 111 x_pre_ptr = LPC_in_pre; |
112 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { | 112 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { |
113 silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ], | 113 silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ], |
114 psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); | 114 psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); |
115 x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; | 115 x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; |
116 x_ptr += psEnc->sCmn.subfr_length; | 116 x_ptr += psEnc->sCmn.subfr_length; |
117 } | 117 } |
118 | 118 |
119 silk_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER
* sizeof( opus_int16 ) ); | 119 silk_memset( psEncCtrl->LTPCoef_Q14, 0, psEnc->sCmn.nb_subfr * LTP_ORDER
* sizeof( opus_int16 ) ); |
120 psEncCtrl->LTPredCodGain_Q7 = 0; | 120 psEncCtrl->LTPredCodGain_Q7 = 0; |
| 121 psEnc->sCmn.sum_log_gain_Q7 = 0; |
121 } | 122 } |
122 | 123 |
123 /* Limit on total predictive coding gain */ | 124 /* Limit on total predictive coding gain */ |
124 if( psEnc->sCmn.first_frame_after_reset ) { | 125 if( psEnc->sCmn.first_frame_after_reset ) { |
125 minInvGain_Q30 = SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_
RESET, 30 ); | 126 minInvGain_Q30 = SILK_FIX_CONST( 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_
RESET, 30 ); |
126 } else { | 127 } else { |
127 minInvGain_Q30 = silk_log2lin( silk_SMLAWB( 16 << 7, (opus_int32)psEncCt
rl->LTPredCodGain_Q7, SILK_FIX_CONST( 1.0 / 3, 16 ) ) ); /* Q16 */ | 128 minInvGain_Q30 = silk_log2lin( silk_SMLAWB( 16 << 7, (opus_int32)psEncCt
rl->LTPredCodGain_Q7, SILK_FIX_CONST( 1.0 / 3, 16 ) ) ); /* Q16 */ |
128 minInvGain_Q30 = silk_DIV32_varQ( minInvGain_Q30, | 129 minInvGain_Q30 = silk_DIV32_varQ( minInvGain_Q30, |
129 silk_SMULWW( SILK_FIX_CONST( MAX_PREDICTION_POWER_GAIN, 0 ), | 130 silk_SMULWW( SILK_FIX_CONST( MAX_PREDICTION_POWER_GAIN, 0 ), |
130 silk_SMLAWB( SILK_FIX_CONST( 0.25, 18 ), SILK_FIX_CONST( 0.75, 1
8 ), psEncCtrl->coding_quality_Q14 ) ), 14 ); | 131 silk_SMLAWB( SILK_FIX_CONST( 0.25, 18 ), SILK_FIX_CONST( 0.75, 1
8 ), psEncCtrl->coding_quality_Q14 ) ), 14 ); |
131 } | 132 } |
132 | 133 |
133 /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered
input for unvoiced */ | 134 /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered
input for unvoiced */ |
134 silk_find_LPC_FIX( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain_Q30 ); | 135 silk_find_LPC_FIX( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain_Q30 ); |
135 | 136 |
136 /* Quantize LSFs */ | 137 /* Quantize LSFs */ |
137 silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->
sCmn.prev_NLSFq_Q15 ); | 138 silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->
sCmn.prev_NLSFq_Q15 ); |
138 | 139 |
139 /* Calculate residual energy using quantized LPC coefficients */ | 140 /* Calculate residual energy using quantized LPC coefficients */ |
140 silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre,
psEncCtrl->PredCoef_Q12, local_gains, | 141 silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre,
psEncCtrl->PredCoef_Q12, local_gains, |
141 psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOr
der ); | 142 psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOr
der ); |
142 | 143 |
143 /* Copy to prediction struct for use in next frame for interpolation */ | 144 /* Copy to prediction struct for use in next frame for interpolation */ |
144 silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_
NLSFq_Q15 ) ); | 145 silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_
NLSFq_Q15 ) ); |
145 RESTORE_STACK; | 146 RESTORE_STACK; |
146 } | 147 } |
OLD | NEW |