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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 /* VOICED */ | 60 /* VOICED */ |
61 /**********/ | 61 /**********/ |
62 silk_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >=
psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); | 62 silk_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >=
psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); |
63 | 63 |
64 /* LTP analysis */ | 64 /* LTP analysis */ |
65 silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain,
res_pitch, | 65 silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain,
res_pitch, |
66 psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_su
bfr, psEnc->sCmn.ltp_mem_length ); | 66 psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_su
bfr, psEnc->sCmn.ltp_mem_length ); |
67 | 67 |
68 /* Quantize LTP gain parameters */ | 68 /* Quantize LTP gain parameters */ |
69 silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPInd
ex, &psEnc->sCmn.indices.PERIndex, | 69 silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPInd
ex, &psEnc->sCmn.indices.PERIndex, |
70 WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEn
c->sCmn.nb_subfr ); | 70 &psEnc->sCmn.sum_log_gain_Q7, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sC
mn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr ); |
71 | 71 |
72 /* Control LTP scaling */ | 72 /* Control LTP scaling */ |
73 silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl, condCoding ); | 73 silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl, condCoding ); |
74 | 74 |
75 /* Create LTP residual */ | 75 /* Create LTP residual */ |
76 silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrde
r, psEncCtrl->LTPCoef, | 76 silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrde
r, psEncCtrl->LTPCoef, |
77 psEncCtrl->pitchL, invGains, psEnc->sCmn.subfr_length, psEnc->sCmn.n
b_subfr, psEnc->sCmn.predictLPCOrder ); | 77 psEncCtrl->pitchL, invGains, psEnc->sCmn.subfr_length, psEnc->sCmn.n
b_subfr, psEnc->sCmn.predictLPCOrder ); |
78 } else { | 78 } else { |
79 /************/ | 79 /************/ |
80 /* UNVOICED */ | 80 /* UNVOICED */ |
81 /************/ | 81 /************/ |
82 /* Create signal with prepended subframes, scaled by inverse gains */ | 82 /* Create signal with prepended subframes, scaled by inverse gains */ |
83 x_ptr = x - psEnc->sCmn.predictLPCOrder; | 83 x_ptr = x - psEnc->sCmn.predictLPCOrder; |
84 x_pre_ptr = LPC_in_pre; | 84 x_pre_ptr = LPC_in_pre; |
85 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { | 85 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { |
86 silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ], | 86 silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ], |
87 psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); | 87 psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); |
88 x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; | 88 x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; |
89 x_ptr += psEnc->sCmn.subfr_length; | 89 x_ptr += psEnc->sCmn.subfr_length; |
90 } | 90 } |
91 silk_memset( psEncCtrl->LTPCoef, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * s
izeof( silk_float ) ); | 91 silk_memset( psEncCtrl->LTPCoef, 0, psEnc->sCmn.nb_subfr * LTP_ORDER * s
izeof( silk_float ) ); |
92 psEncCtrl->LTPredCodGain = 0.0f; | 92 psEncCtrl->LTPredCodGain = 0.0f; |
| 93 psEnc->sCmn.sum_log_gain_Q7 = 0; |
93 } | 94 } |
94 | 95 |
95 /* Limit on total predictive coding gain */ | 96 /* Limit on total predictive coding gain */ |
96 if( psEnc->sCmn.first_frame_after_reset ) { | 97 if( psEnc->sCmn.first_frame_after_reset ) { |
97 minInvGain = 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET; | 98 minInvGain = 1.0f / MAX_PREDICTION_POWER_GAIN_AFTER_RESET; |
98 } else { | 99 } else { |
99 minInvGain = (silk_float)pow( 2, psEncCtrl->LTPredCodGain / 3 ) / MAX_P
REDICTION_POWER_GAIN; | 100 minInvGain = (silk_float)pow( 2, psEncCtrl->LTPredCodGain / 3 ) / MAX_P
REDICTION_POWER_GAIN; |
100 minInvGain /= 0.25f + 0.75f * psEncCtrl->coding_quality; | 101 minInvGain /= 0.25f + 0.75f * psEncCtrl->coding_quality; |
101 } | 102 } |
102 | 103 |
103 /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered
input for unvoiced */ | 104 /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered
input for unvoiced */ |
104 silk_find_LPC_FLP( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain ); | 105 silk_find_LPC_FLP( &psEnc->sCmn, NLSF_Q15, LPC_in_pre, minInvGain ); |
105 | 106 |
106 /* Quantize LSFs */ | 107 /* Quantize LSFs */ |
107 silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->
sCmn.prev_NLSFq_Q15 ); | 108 silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->
sCmn.prev_NLSFq_Q15 ); |
108 | 109 |
109 /* Calculate residual energy using quantized LPC coefficients */ | 110 /* Calculate residual energy using quantized LPC coefficients */ |
110 silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef
, psEncCtrl->Gains, | 111 silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef
, psEncCtrl->Gains, |
111 psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOr
der ); | 112 psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOr
der ); |
112 | 113 |
113 /* Copy to prediction struct for use in next frame for interpolation */ | 114 /* Copy to prediction struct for use in next frame for interpolation */ |
114 silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_
NLSFq_Q15 ) ); | 115 silk_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_
NLSFq_Q15 ) ); |
115 } | 116 } |
116 | 117 |
OLD | NEW |