mirror of
https://github.com/xiph/opus.git
synced 2025-05-28 06:09:15 +00:00
Converting some silk_assert()s into hardening celt_assert()s
Only converted the ones that are really sure (not signal-dependent) and that shouldn't add much run-time complexity
This commit is contained in:
parent
69bcb28d3d
commit
7e3352ef51
29 changed files with 96 additions and 96 deletions
|
@ -82,7 +82,7 @@ opus_int silk_InitEncoder( /* O Returns error co
|
|||
silk_memset( psEnc, 0, sizeof( silk_encoder ) );
|
||||
for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) {
|
||||
if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ], arch ) ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ opus_int silk_InitEncoder( /* O Returns error co
|
|||
|
||||
/* Read control structure */
|
||||
if( ret += silk_QueryEncoder( encState, encStatus ) ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -166,7 +166,7 @@ opus_int silk_Encode( /* O Returns error co
|
|||
|
||||
/* Check values in encoder control structure */
|
||||
if( ( ret = check_control_input( encControl ) ) != 0 ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
RESTORE_STACK;
|
||||
return ret;
|
||||
}
|
||||
|
@ -201,14 +201,14 @@ opus_int silk_Encode( /* O Returns error co
|
|||
if( prefillFlag ) {
|
||||
/* Only accept input length of 10 ms */
|
||||
if( nBlocksOf10ms != 1 ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
RESTORE_STACK;
|
||||
return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
|
||||
}
|
||||
/* Reset Encoder */
|
||||
for( n = 0; n < encControl->nChannelsInternal; n++ ) {
|
||||
ret = silk_init_encoder( &psEnc->state_Fxx[ n ], psEnc->state_Fxx[ n ].sCmn.arch );
|
||||
silk_assert( !ret );
|
||||
celt_assert( !ret );
|
||||
}
|
||||
tmp_payloadSize_ms = encControl->payloadSize_ms;
|
||||
encControl->payloadSize_ms = 10;
|
||||
|
@ -221,13 +221,13 @@ opus_int silk_Encode( /* O Returns error co
|
|||
} else {
|
||||
/* Only accept input lengths that are a multiple of 10 ms */
|
||||
if( nBlocksOf10ms * encControl->API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0 ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
RESTORE_STACK;
|
||||
return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
|
||||
}
|
||||
/* Make sure no more than one packet can be produced */
|
||||
if( 1000 * (opus_int32)nSamplesIn > encControl->payloadSize_ms * encControl->API_sampleRate ) {
|
||||
silk_assert( 0 );
|
||||
celt_assert( 0 );
|
||||
RESTORE_STACK;
|
||||
return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ opus_int silk_Encode( /* O Returns error co
|
|||
}
|
||||
psEnc->state_Fxx[ n ].sCmn.inDTX = psEnc->state_Fxx[ n ].sCmn.useDTX;
|
||||
}
|
||||
silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
|
||||
celt_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
|
||||
|
||||
/* Input buffering/resampling and encoding */
|
||||
nSamplesToBufferMax =
|
||||
|
@ -306,7 +306,7 @@ opus_int silk_Encode( /* O Returns error co
|
|||
}
|
||||
psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
|
||||
} else {
|
||||
silk_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 );
|
||||
celt_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 );
|
||||
silk_memcpy(buf, samplesIn, nSamplesFromInput*sizeof(opus_int16));
|
||||
ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state,
|
||||
&psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx + 2 ], buf, nSamplesFromInput );
|
||||
|
@ -322,8 +322,8 @@ opus_int silk_Encode( /* O Returns error co
|
|||
/* Silk encoder */
|
||||
if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) {
|
||||
/* Enough data in input buffer, so encode */
|
||||
silk_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length );
|
||||
silk_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length );
|
||||
celt_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length );
|
||||
celt_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length );
|
||||
|
||||
/* Deal with LBRR data */
|
||||
if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 && !prefillFlag ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue