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 30 matching lines...) Expand all Loading... |
41 opus_int condCoding /* I
The type of conditional coding used so far for this frame
*/ | 41 opus_int condCoding /* I
The type of conditional coding used so far for this frame
*/ |
42 ); | 42 ); |
43 | 43 |
44 void silk_encode_do_VAD_FIX( | 44 void silk_encode_do_VAD_FIX( |
45 silk_encoder_state_FIX *psEnc /* I
/O Pointer to Silk FIX encoder state
*/ | 45 silk_encoder_state_FIX *psEnc /* I
/O Pointer to Silk FIX encoder state
*/ |
46 ) | 46 ) |
47 { | 47 { |
48 /****************************/ | 48 /****************************/ |
49 /* Voice Activity Detection */ | 49 /* Voice Activity Detection */ |
50 /****************************/ | 50 /****************************/ |
51 silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); | 51 silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.arch
); |
52 | 52 |
53 /**************************************************/ | 53 /**************************************************/ |
54 /* Convert speech activity into VAD and DTX flags */ | 54 /* Convert speech activity into VAD and DTX flags */ |
55 /**************************************************/ | 55 /**************************************************/ |
56 if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THR
ES, 8 ) ) { | 56 if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THR
ES, 8 ) ) { |
57 psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; | 57 psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; |
58 psEnc->sCmn.noSpeechCounter++; | 58 psEnc->sCmn.noSpeechCounter++; |
59 if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) { | 59 if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) { |
60 psEnc->sCmn.inDTX = 0; | 60 psEnc->sCmn.inDTX = 0; |
61 } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH
_FRAMES_BEFORE_DTX ) { | 61 } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH
_FRAMES_BEFORE_DTX ) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; | 189 psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; |
190 psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; | 190 psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; |
191 } | 191 } |
192 | 192 |
193 /*****************************************/ | 193 /*****************************************/ |
194 /* Noise shaping quantization */ | 194 /* Noise shaping quantization */ |
195 /*****************************************/ | 195 /*****************************************/ |
196 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warpin
g_Q16 > 0 ) { | 196 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warpin
g_Q16 > 0 ) { |
197 silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->s
Cmn.indices, xfw_Q3, psEnc->sCmn.pulses, | 197 silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->s
Cmn.indices, xfw_Q3, psEnc->sCmn.pulses, |
198 sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEn
cCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, | 198 sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEn
cCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, |
199 sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gain
s_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); | 199 sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gain
s_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, |
| 200 psEnc->sCmn.arch ); |
200 } else { | 201 } else { |
201 silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indi
ces, xfw_Q3, psEnc->sCmn.pulses, | 202 silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indi
ces, xfw_Q3, psEnc->sCmn.pulses, |
202 sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sE
ncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, | 203 sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sE
ncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, |
203 sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gai
ns_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); | 204 sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gai
ns_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14, |
| 205 psEnc->sCmn.arch); |
204 } | 206 } |
205 | 207 |
206 /****************************************/ | 208 /****************************************/ |
207 /* Encode Parameters */ | 209 /* Encode Parameters */ |
208 /****************************************/ | 210 /****************************************/ |
209 silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFram
esEncoded, 0, condCoding ); | 211 silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFram
esEncoded, 0, condCoding ); |
210 | 212 |
211 /****************************************/ | 213 /****************************************/ |
212 /* Encode Excitation Signal */ | 214 /* Encode Excitation Signal */ |
213 /****************************************/ | 215 /****************************************/ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 gainMult_Q8 = silk_ADD_RSHIFT32( gainMult_lower, gainMult_up
per - gainMult_lower, 2 ); | 282 gainMult_Q8 = silk_ADD_RSHIFT32( gainMult_lower, gainMult_up
per - gainMult_lower, 2 ); |
281 } else | 283 } else |
282 if( gainMult_Q8 < silk_SUB_RSHIFT32( gainMult_upper, gainMult_up
per - gainMult_lower, 2 ) ) { | 284 if( gainMult_Q8 < silk_SUB_RSHIFT32( gainMult_upper, gainMult_up
per - gainMult_lower, 2 ) ) { |
283 gainMult_Q8 = silk_SUB_RSHIFT32( gainMult_upper, gainMult_up
per - gainMult_lower, 2 ); | 285 gainMult_Q8 = silk_SUB_RSHIFT32( gainMult_upper, gainMult_up
per - gainMult_lower, 2 ); |
284 } | 286 } |
285 } | 287 } |
286 | 288 |
287 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { | 289 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { |
288 sEncCtrl.Gains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCt
rl.GainsUnq_Q16[ i ], gainMult_Q8 ), 8 ); | 290 sEncCtrl.Gains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCt
rl.GainsUnq_Q16[ i ], gainMult_Q8 ), 8 ); |
289 } | 291 } |
290 | 292 |
291 /* Quantize gains */ | 293 /* Quantize gains */ |
292 psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; | 294 psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; |
293 silk_gains_quant( psEnc->sCmn.indices.GainsIndices, sEncCtrl.Gains_Q
16, | 295 silk_gains_quant( psEnc->sCmn.indices.GainsIndices, sEncCtrl.Gains_Q
16, |
294 &psEnc->sShape.LastGainIndex, condCoding == CODE_CONDITIONALLY
, psEnc->sCmn.nb_subfr ); | 296 &psEnc->sShape.LastGainIndex, condCoding == CODE_CONDITIONALLY
, psEnc->sCmn.nb_subfr ); |
295 | 297 |
296 /* Unique identifier of gains vector */ | 298 /* Unique identifier of gains vector */ |
297 gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sC
mn.nb_subfr ); | 299 gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sC
mn.nb_subfr ); |
298 } | 300 } |
299 } | 301 } |
300 | 302 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, | 366 silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, |
365 &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY
, psEnc->sCmn.nb_subfr ); | 367 &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY
, psEnc->sCmn.nb_subfr ); |
366 | 368 |
367 /*****************************************/ | 369 /*****************************************/ |
368 /* Noise shaping quantization */ | 370 /* Noise shaping quantization */ |
369 /*****************************************/ | 371 /*****************************************/ |
370 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 >
0 ) { | 372 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 >
0 ) { |
371 silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, | 373 silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, |
372 psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl
->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, | 374 psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl
->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, |
373 psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Til
t_Q14, psEncCtrl->LF_shp_Q14, | 375 psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Til
t_Q14, psEncCtrl->LF_shp_Q14, |
374 psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10,
psEncCtrl->LTP_scale_Q14 ); | 376 psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10,
psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); |
375 } else { | 377 } else { |
376 silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, | 378 silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, |
377 psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl
->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, | 379 psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl
->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, |
378 psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Til
t_Q14, psEncCtrl->LF_shp_Q14, | 380 psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Til
t_Q14, psEncCtrl->LF_shp_Q14, |
379 psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10,
psEncCtrl->LTP_scale_Q14 ); | 381 psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10,
psEncCtrl->LTP_scale_Q14, psEnc->sCmn.arch ); |
380 } | 382 } |
381 | 383 |
382 /* Restore original gains */ | 384 /* Restore original gains */ |
383 silk_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr *
sizeof( opus_int32 ) ); | 385 silk_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr *
sizeof( opus_int32 ) ); |
384 } | 386 } |
385 } | 387 } |
OLD | NEW |