opus_int silk_Get_Decoder_Size( /* O Returns error code */
opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */
)
{
opus_int ret = SILK_NO_ERROR;
*decSizeBytes = sizeof( silk_decoder );
return ret;
}
/* Reset decoder state */
opus_int silk_ResetDecoder( /* O Returns error code */ void *decState /* I/O State */
)
{
opus_int n, ret = SILK_NO_ERROR;
silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_state;
for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
ret = silk_reset_decoder( &channel_state[ n ] );
}
silk_memset(&((silk_decoder *)decState)->sStereo, 0, sizeof(((silk_decoder *)decState)->sStereo)); /* Not strictly needed, but it's cleaner that way */
((silk_decoder *)decState)->prev_decode_only_middle = 0;
for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
ret = silk_init_decoder( &channel_state[ n ] );
}
silk_memset(&((silk_decoder *)decState)->sStereo, 0, sizeof(((silk_decoder *)decState)->sStereo)); /* Not strictly needed, but it's cleaner that way */
((silk_decoder *)decState)->prev_decode_only_middle = 0;
return ret;
}
/* Decode a frame */
opus_int silk_Decode( /* O Returns error code */ void* decState, /* I/O State */
silk_DecControlStruct* decControl, /* I/O Control Structure */
opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */
opus_int newPacketFlag, /* I Indicates first decoder call for this packet */
ec_dec *psRangeDec, /* I/O Compressor data structure */
opus_res *samplesOut, /* O Decoded output speech vector */
opus_int32 *nSamplesOut, /* O Number of samples decoded */ #ifdef ENABLE_DEEP_PLC
LPCNetPLCState *lpcnet, #endif int arch /* I Run-time architecture */
)
{
opus_int i, n, decode_only_middle = 0, ret = SILK_NO_ERROR;
opus_int32 nSamplesOutDec, LBRR_symbol;
opus_int16 *samplesOut1_tmp[ 2 ];
VARDECL( opus_int16, samplesOut1_tmp_storage1 );
VARDECL( opus_int16, samplesOut2_tmp );
opus_int32 MS_pred_Q13[ 2 ] = { 0 };
opus_int16 *resample_out_ptr;
silk_decoder *psDec = ( silk_decoder * )decState;
silk_decoder_state *channel_state = psDec->channel_state;
opus_int has_side;
opus_int stereo_to_mono; #ifdef ENABLE_OSCE_BWE
VARDECL( opus_int16, resamp_buffer ); #endif
SAVE_STACK;
/**********************************/ /* Test if first frame in payload */ /**********************************/ if( newPacketFlag ) { for( n = 0; n < decControl->nChannelsInternal; n++ ) {
channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in packet */
}
}
/* If Mono -> Stereo transition in bitstream: init state of second channel */ if( decControl->nChannelsInternal > psDec->nChannelsInternal ) {
ret += silk_init_decoder( &channel_state[ 1 ] );
}
/* Check if the temp buffer fits into the output PCM buffer. If it fits, wecandelayallocatingthetempbufferuntilaftertheSILKpeakstack
usage. We need to use a < and not a <= because of the two extra samples. */
ALLOC( samplesOut1_tmp_storage1, decControl->nChannelsInternal*(channel_state[ 0 ].frame_length + 2 ),
opus_int16 );
samplesOut1_tmp[ 0 ] = samplesOut1_tmp_storage1;
samplesOut1_tmp[ 1 ] = samplesOut1_tmp_storage1 + channel_state[ 0 ].frame_length + 2;
for( n = 0; n < silk_min( decControl->nChannelsAPI, decControl->nChannelsInternal ); n++ ) {
#ifdef ENABLE_OSCE_BWE /* Resample or extend decoded signal to API_sampleRate */ if (decControl->osce_extended_mode == OSCE_MODE_SILK_BBWE) {
silk_assert(decControl->API_sampleRate == 48000);
if (decControl->prev_osce_extended_mode != OSCE_MODE_SILK_BBWE) { /* Reset the BWE state */
osce_bwe_reset( &channel_state[ n ].osce_bwe );
}
osce_bwe(&psDec->osce_model, &channel_state[ n ].osce_bwe,
resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec, arch);
if (decControl->prev_osce_extended_mode == OSCE_MODE_SILK_ONLY ||
decControl->prev_osce_extended_mode == OSCE_MODE_HYBRID) { /* cross-fade with upsampled signal */
silk_resampler( &channel_state[ n ].resampler_state, resamp_buffer, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec );
osce_bwe_cross_fade_10ms(resample_out_ptr, resamp_buffer, 480);
}
} else {
ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec ); if (decControl->prev_osce_extended_mode == OSCE_MODE_SILK_BBWE && decControl->internalSampleRate == 16000) { /* fade out if internal sample rate did not change */
osce_bwe(&psDec->osce_model, &channel_state[ n ].osce_bwe,
resamp_buffer, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec, arch); /* cross-fade with upsampled signal */
osce_bwe_cross_fade_10ms(resample_out_ptr, resamp_buffer, 480);
}
} #else /* Resample decoded signal to API_sampleRate */
ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec ); #endif /* Interleave if stereo output and stereo stream */ if( decControl->nChannelsAPI == 2 ) { for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ n + 2 * i ] = INT16TORES(resample_out_ptr[ i ]);
}
} else { for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ i ] = INT16TORES(resample_out_ptr[ i ]);
}
}
}
/* Create two channel output from mono stream */ if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 1 ) { if ( stereo_to_mono ){ /* Resample right channel for newly collapsed stereo just in case
we weren't doing collapsing when switching to mono */
ret += silk_resampler( &channel_state[ 1 ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ 0 ][ 1 ], nSamplesOutDec );
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ 1 + 2 * i ] = INT16TORES(resample_out_ptr[ i ]);
}
} else { for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ 1 + 2 * i ] = samplesOut[ 0 + 2 * i ];
}
}
}
if( lostFlag == FLAG_PACKET_LOST ) { /* On packet loss, remove the gain clamping to prevent having the energy "bounce back"
if we lose packets when the energy is going down */ for ( i = 0; i < psDec->nChannelsInternal; i++ )
psDec->channel_state[ i ].LastGainIndex = 10;
} else {
psDec->prev_decode_only_middle = decode_only_middle;
}
RESTORE_STACK; return ret;
}
#if0 /* Getting table of contents for a packet */
opus_int silk_get_TOC( const opus_uint8 *payload, /* I Payload data */ const opus_int nBytesIn, /* I Number of input bytes */ const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */
silk_TOC_struct *Silk_TOC /* O Type of content */
)
{
opus_int i, flags, ret = SILK_NO_ERROR;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.