Lines Matching refs:psEnc
76 silk_encoder *psEnc; in silk_InitEncoder() local
79 psEnc = (silk_encoder *)encState; in silk_InitEncoder()
82 silk_memset( psEnc, 0, sizeof( silk_encoder ) ); in silk_InitEncoder()
84 if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ], arch ) ) { in silk_InitEncoder()
89 psEnc->nChannelsAPI = 1; in silk_InitEncoder()
90 psEnc->nChannelsInternal = 1; in silk_InitEncoder()
110 silk_encoder *psEnc = (silk_encoder *)encState; in silk_QueryEncoder() local
112 state_Fxx = psEnc->state_Fxx; in silk_QueryEncoder()
114 encStatus->nChannelsAPI = psEnc->nChannelsAPI; in silk_QueryEncoder()
115 encStatus->nChannelsInternal = psEnc->nChannelsInternal; in silk_QueryEncoder()
155 silk_encoder *psEnc = ( silk_encoder * )encState; in silk_Encode() local
162 psEnc->state_Fxx[0].sCmn.first_frame_after_reset = 1; in silk_Encode()
163 psEnc->state_Fxx[1].sCmn.first_frame_after_reset = 1; in silk_Encode()
165 psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded = psEnc->state_Fxx[ 1 ].sCmn.nFramesEncoded = 0; in silk_Encode()
176 if( encControl->nChannelsInternal > psEnc->nChannelsInternal ) { in silk_Encode()
178 ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ], psEnc->state_Fxx[ 0 ].sCmn.arch ); in silk_Encode()
179 silk_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pred_prev_Q13 ) ); in silk_Encode()
180 silk_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) ); in silk_Encode()
181 psEnc->sStereo.mid_side_amp_Q0[ 0 ] = 0; in silk_Encode()
182 psEnc->sStereo.mid_side_amp_Q0[ 1 ] = 1; in silk_Encode()
183 psEnc->sStereo.mid_side_amp_Q0[ 2 ] = 0; in silk_Encode()
184 psEnc->sStereo.mid_side_amp_Q0[ 3 ] = 1; in silk_Encode()
185 psEnc->sStereo.width_prev_Q14 = 0; in silk_Encode()
186 psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 ); in silk_Encode()
187 if( psEnc->nChannelsAPI == 2 ) { in silk_Encode()
188 …silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_st… in silk_Encode()
189 …silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.In_HP_State, &psEnc->state_Fxx[ 0 ].sCmn.In_HP_State,… in silk_Encode()
193 …transition = (encControl->payloadSize_ms != psEnc->state_Fxx[ 0 ].sCmn.PacketSize_ms) || (psEnc->n… in silk_Encode()
195 psEnc->nChannelsAPI = encControl->nChannelsAPI; in silk_Encode()
196 psEnc->nChannelsInternal = encControl->nChannelsInternal; in silk_Encode()
210 ret = silk_init_encoder( &psEnc->state_Fxx[ n ], psEnc->state_Fxx[ n ].sCmn.arch ); in silk_Encode()
218 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; in silk_Encode()
219 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1; in silk_Encode()
239 opus_int force_fs_kHz = (n==1) ? psEnc->state_Fxx[0].sCmn.fs_kHz : 0; in silk_Encode()
240 …if( ( ret = silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allow… in silk_Encode()
245 if( psEnc->state_Fxx[n].sCmn.first_frame_after_reset || transition ) { in silk_Encode()
246 for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) { in silk_Encode()
247 psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] = 0; in silk_Encode()
250 psEnc->state_Fxx[ n ].sCmn.inDTX = psEnc->state_Fxx[ n ].sCmn.useDTX; in silk_Encode()
252 …silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->sta… in silk_Encode()
256 10 * nBlocksOf10ms * psEnc->state_Fxx[ 0 ].sCmn.fs_kHz; in silk_Encode()
259 psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, in silk_Encode()
260 psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 ); in silk_Encode()
263 …nSamplesToBuffer = psEnc->state_Fxx[ 0 ].sCmn.frame_length - psEnc->state_Fxx[ 0 ].sCmn.inputBufI… in silk_Encode()
265 …nSamplesFromInput = silk_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc-… in silk_Encode()
268 opus_int id = psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded; in silk_Encode()
273 if( psEnc->nPrevChannelsInternal == 1 && id==0 ) { in silk_Encode()
274 …silk_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_st… in silk_Encode()
277 ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, in silk_Encode()
278 …&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFr… in silk_Encode()
279 psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; in silk_Encode()
281 …nSamplesToBuffer = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufI… in silk_Encode()
282 …nSamplesToBuffer = silk_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 1 ].sCmn.fs… in silk_Encode()
286 ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, in silk_Encode()
287 …&psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFr… in silk_Encode()
289 psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer; in silk_Encode()
296 ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, in silk_Encode()
297 …&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFr… in silk_Encode()
299 … if( psEnc->nPrevChannelsInternal == 2 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 ) { in silk_Encode()
300 ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, in silk_Encode()
301 …&psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFr… in silk_Encode()
302 for( n = 0; n < psEnc->state_Fxx[ 0 ].sCmn.frame_length; n++ ) { in silk_Encode()
303 psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] = in silk_Encode()
304 … silk_RSHIFT(psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx+n+2 ] in silk_Encode()
305 … + psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx+n+2 ], 1); in silk_Encode()
308 psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; in silk_Encode()
312 ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, in silk_Encode()
313 …&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFr… in silk_Encode()
314 psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; in silk_Encode()
321 psEnc->allowBandwidthSwitch = 0; in silk_Encode()
324 if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) { in silk_Encode()
326 … silk_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length ); in silk_Encode()
327 …silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc-… in silk_Encode()
330 if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 && !prefillFlag ) { in silk_Encode()
333 …iCDF[ 0 ] = 256 - silk_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encContr… in silk_Encode()
340 for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { in silk_Encode()
341 LBRR_symbol |= silk_LSHIFT( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ], i ); in silk_Encode()
343 psEnc->state_Fxx[ n ].sCmn.LBRR_flag = LBRR_symbol > 0 ? 1 : 0; in silk_Encode()
344 if( LBRR_symbol && psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket > 1 ) { in silk_Encode()
345 …ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFr… in silk_Encode()
350 for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) { in silk_Encode()
352 if( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] ) { in silk_Encode()
356 silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.predIx[ i ] ); in silk_Encode()
358 if( psEnc->state_Fxx[ 1 ].sCmn.LBRR_flags[ i ] == 0 ) { in silk_Encode()
359 … silk_stereo_encode_mid_only( psRangeEnc, psEnc->sStereo.mid_only_flags[ i ] ); in silk_Encode()
363 if( i > 0 && psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i - 1 ] ) { in silk_Encode()
368 … silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1, condCoding ); in silk_Encode()
369 …silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->stat… in silk_Encode()
370 … psEnc->state_Fxx[ n ].sCmn.pulses_LBRR[ i ], psEnc->state_Fxx[ n ].sCmn.frame_length ); in silk_Encode()
377 …silk_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_fla… in silk_Encode()
381 silk_HP_variable_cutoff( psEnc->state_Fxx ); in silk_Encode()
390 …nBits = silk_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].… in silk_Encode()
398 …TargetRate_bps -= silk_DIV32_16( silk_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_M… in silk_Encode()
404 …silk_stereo_LR_to_MS( &psEnc->sStereo, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ 2 ], &psEnc->state_Fx… in silk_Encode()
405 …psEnc->sStereo.predIx[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], &psEnc->sStereo.mid_only_flags… in silk_Encode()
406 …MStargetRates_bps, TargetRate_bps, psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8, encControl->toMo… in silk_Encode()
407 psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length ); in silk_Encode()
408 … if( psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] == 0 ) { in silk_Encode()
410 if( psEnc->prev_decode_only_middle == 1 ) { in silk_Encode()
411 …silk_memset( &psEnc->state_Fxx[ 1 ].sShape, 0, sizeof( psEnc->state_Fxx[ 1 ].sShape … in silk_Encode()
412 …silk_memset( &psEnc->state_Fxx[ 1 ].sPrefilt, 0, sizeof( psEnc->state_Fxx[ 1 ].sPrefil… in silk_Encode()
413 …silk_memset( &psEnc->state_Fxx[ 1 ].sCmn.sNSQ, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.sN… in silk_Encode()
414 …silk_memset( psEnc->state_Fxx[ 1 ].sCmn.prev_NLSFq_Q15, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.pr… in silk_Encode()
415 …silk_memset( &psEnc->state_Fxx[ 1 ].sCmn.sLP.In_LP_State, 0, sizeof( psEnc->state_Fxx[ 1 ].sCmn.sL… in silk_Encode()
416 psEnc->state_Fxx[ 1 ].sCmn.prevLag = 100; in silk_Encode()
417 psEnc->state_Fxx[ 1 ].sCmn.sNSQ.lagPrev = 100; in silk_Encode()
418 psEnc->state_Fxx[ 1 ].sShape.LastGainIndex = 10; in silk_Encode()
419 psEnc->state_Fxx[ 1 ].sCmn.prevSignalType = TYPE_NO_VOICE_ACTIVITY; in silk_Encode()
420 psEnc->state_Fxx[ 1 ].sCmn.sNSQ.prev_gain_Q16 = 65536; in silk_Encode()
421 psEnc->state_Fxx[ 1 ].sCmn.first_frame_after_reset = 1; in silk_Encode()
423 silk_encode_do_VAD_Fxx( &psEnc->state_Fxx[ 1 ] ); in silk_Encode()
425 … psEnc->state_Fxx[ 1 ].sCmn.VAD_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] = 0; in silk_Encode()
428 …silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.predIx[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEnco… in silk_Encode()
429 … if( psEnc->state_Fxx[ 1 ].sCmn.VAD_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] == 0 ) { in silk_Encode()
430 …silk_stereo_encode_mid_only( psRangeEnc, psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn… in silk_Encode()
435 … silk_memcpy( psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->sStereo.sMid, 2 * sizeof( opus_int16 ) ); in silk_Encode()
436 …silk_memcpy( psEnc->sStereo.sMid, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn… in silk_Encode()
438 silk_encode_do_VAD_Fxx( &psEnc->state_Fxx[ 0 ] ); in silk_Encode()
471 silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps ); in silk_Encode()
474 if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded - n <= 0 ) { in silk_Encode()
476 } else if( n > 0 && psEnc->prev_decode_only_middle ) { in silk_Encode()
483 …if( ( ret = silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc, condCoding, maxB… in silk_Encode()
487 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; in silk_Encode()
488 psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0; in silk_Encode()
489 psEnc->state_Fxx[ n ].sCmn.nFramesEncoded++; in silk_Encode()
491 …psEnc->prev_decode_only_middle = psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFrames… in silk_Encode()
494 …if( *nBytesOut > 0 && psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == psEnc->state_Fxx[ 0 ].sCmn.nFra… in silk_Encode()
497 for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { in silk_Encode()
499 flags |= psEnc->state_Fxx[ n ].sCmn.VAD_flags[ i ]; in silk_Encode()
502 flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag; in silk_Encode()
505 …ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) … in silk_Encode()
509 …if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ … in silk_Encode()
513 psEnc->nBitsExceeded += *nBytesOut * 8; in silk_Encode()
514 …psEnc->nBitsExceeded -= silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms )… in silk_Encode()
515 psEnc->nBitsExceeded = silk_LIMIT( psEnc->nBitsExceeded, 0, 10000 ); in silk_Encode()
519 … - SPEECH_ACTIVITY_DTX_THRES ) / MAX_BANDWIDTH_SWITCH_DELAY_MS, 16 + 8 ), psEnc->timeSinceSwitchAl… in silk_Encode()
520 if( psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8 < speech_act_thr_for_switch_Q8 ) { in silk_Encode()
521 psEnc->allowBandwidthSwitch = 1; in silk_Encode()
522 psEnc->timeSinceSwitchAllowed_ms = 0; in silk_Encode()
524 psEnc->allowBandwidthSwitch = 0; in silk_Encode()
525 psEnc->timeSinceSwitchAllowed_ms += encControl->payloadSize_ms; in silk_Encode()
538 psEnc->nPrevChannelsInternal = encControl->nChannelsInternal; in silk_Encode()
540 encControl->allowBandwidthSwitch = psEnc->allowBandwidthSwitch; in silk_Encode()
541 …encControl->inWBmodeWithoutVariableLP = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 && psEnc->state_Fx… in silk_Encode()
542 encControl->internalSampleRate = silk_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 ); in silk_Encode()
543 encControl->stereoWidth_Q14 = encControl->toMono ? 0 : psEnc->sStereo.smth_width_Q14; in silk_Encode()
548 psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; in silk_Encode()
549 psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0; in silk_Encode()