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