Eliminate the last non-static pointer from the LPC-mode encoder structures.
The API permits the caller to freely copy the codec state on their own, but this can't work if there are any any position dependant pointers in the codec state.
This commit is contained in:
parent
f451b33b16
commit
16b25e908a
5 changed files with 14 additions and 17 deletions
|
@ -62,7 +62,7 @@ TIC(ENCODE_FRAME)
|
|||
/* Voice Activity Detection */
|
||||
/****************************/
|
||||
TIC(VAD)
|
||||
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 );
|
||||
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
||||
TOC(VAD)
|
||||
|
||||
/**************************************************/
|
||||
|
@ -91,12 +91,12 @@ TOC(VAD)
|
|||
/***************************************/
|
||||
/* Ensure smooth bandwidth transitions */
|
||||
/***************************************/
|
||||
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
|
||||
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length );
|
||||
|
||||
/*******************************************/
|
||||
/* Copy new frame to front of input buffer */
|
||||
/*******************************************/
|
||||
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
|
||||
SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length * sizeof( opus_int16 ) );
|
||||
|
||||
/*****************************************/
|
||||
/* Find pitch lags, initial LPC analysis */
|
||||
|
|
|
@ -62,7 +62,7 @@ TIC(ENCODE_FRAME)
|
|||
/* Voice Activity Detection */
|
||||
/****************************/
|
||||
TIC(VAD)
|
||||
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 );
|
||||
ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 );
|
||||
TOC(VAD)
|
||||
|
||||
/**************************************************/
|
||||
|
@ -91,12 +91,12 @@ TOC(VAD)
|
|||
/***************************************/
|
||||
/* Ensure smooth bandwidth transitions */
|
||||
/***************************************/
|
||||
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
|
||||
silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length );
|
||||
|
||||
/*******************************************/
|
||||
/* Copy new frame to front of input buffer */
|
||||
/*******************************************/
|
||||
SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length );
|
||||
SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length );
|
||||
|
||||
/* Add tiny signal to avoid high CPU load from denormalized floating point numbers */
|
||||
for( i = 0; i < 8; i++ ) {
|
||||
|
|
|
@ -220,7 +220,7 @@ opus_int silk_Encode(
|
|||
buf[ n ] = samplesIn[ 2 * n ];
|
||||
}
|
||||
ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
|
||||
psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
|
||||
|
||||
nSamplesToBuffer = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx;
|
||||
|
@ -229,7 +229,7 @@ opus_int silk_Encode(
|
|||
buf[ n ] = samplesIn[ 2 * n + 1 ];
|
||||
}
|
||||
ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state,
|
||||
&psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
|
||||
&psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
|
||||
psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer;
|
||||
} else if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 1 ) {
|
||||
/* Combine left and right channels before resampling */
|
||||
|
@ -237,12 +237,12 @@ opus_int silk_Encode(
|
|||
buf[ n ] = (opus_int16)SKP_RSHIFT_ROUND( samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ], 1 );
|
||||
}
|
||||
ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
|
||||
psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
|
||||
} else {
|
||||
SKP_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 );
|
||||
ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], samplesIn, nSamplesFromInput );
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], samplesIn, nSamplesFromInput );
|
||||
psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
|
||||
}
|
||||
samplesIn += nSamplesFromInput * encControl->nChannelsAPI;
|
||||
|
@ -323,7 +323,7 @@ opus_int silk_Encode(
|
|||
|
||||
/* Convert Left/Right to Mid/Side */
|
||||
if( encControl->nChannelsInternal == 2 ) {
|
||||
silk_stereo_LR_to_MS( &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf,
|
||||
silk_stereo_LR_to_MS( &psEnc->sStereo, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ 2 ], &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ 2 ],
|
||||
psEnc->sStereo.predIx[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], &psEnc->sStereo.mid_only_flags[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ],
|
||||
MStargetRates_bps, TargetRate_bps, psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8,
|
||||
psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
|
||||
|
@ -333,8 +333,8 @@ opus_int silk_Encode(
|
|||
}
|
||||
} else {
|
||||
/* Buffering */
|
||||
SKP_memcpy( &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ -2 ], psEnc->sStereo.sMid, 2 * sizeof( opus_int16 ) );
|
||||
SKP_memcpy( psEnc->sStereo.sMid, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.frame_length - 2 ], 2 * sizeof( opus_int16 ) );
|
||||
SKP_memcpy( psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->sStereo.sMid, 2 * sizeof( opus_int16 ) );
|
||||
SKP_memcpy( psEnc->sStereo.sMid, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.frame_length ], 2 * sizeof( opus_int16 ) );
|
||||
}
|
||||
|
||||
/* Encode */
|
||||
|
|
|
@ -46,8 +46,6 @@ opus_int silk_init_encoder(
|
|||
/* Clear the entire encoder state */
|
||||
SKP_memset( psEnc, 0, sizeof( silk_encoder_state_Fxx ) );
|
||||
|
||||
psEnc->sCmn.inputBuf = &psEnc->sCmn.inputBuf__[ 2 ];
|
||||
|
||||
psEnc->sCmn.variable_HP_smth1_Q15 = SKP_LSHIFT( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ), 8 );
|
||||
psEnc->sCmn.variable_HP_smth2_Q15 = psEnc->sCmn.variable_HP_smth1_Q15;
|
||||
|
||||
|
|
|
@ -191,8 +191,7 @@ typedef struct {
|
|||
opus_int8 pulses[ MAX_FRAME_LENGTH ];
|
||||
|
||||
/* Input/output buffering */
|
||||
opus_int16 inputBuf__[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */
|
||||
opus_int16 *inputBuf; /* Points to second element of above buffer */
|
||||
opus_int16 inputBuf[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */
|
||||
opus_int inputBufIx;
|
||||
opus_int nFramesPerPacket;
|
||||
opus_int nFramesEncoded; /* Number of frames analyzed in current packet */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue