Fixes a bug in the handling of the first packet after DTX
We were using the last frame's DTX decision at the beginning
of the encoding
diff --git a/src_FLP/SKP_Silk_encode_frame_FLP.c b/src_FLP/SKP_Silk_encode_frame_FLP.c
index 8a6d3b4..c80bcbe 100644
--- a/src_FLP/SKP_Silk_encode_frame_FLP.c
+++ b/src_FLP/SKP_Silk_encode_frame_FLP.c
@@ -47,24 +47,6 @@
TIC(ENCODE_FRAME)
- if( psEnc->sCmn.nFramesAnalyzed == 0 && !psEnc->sCmn.prefillFlag && !( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
- /* Create space at start of payload for VAD and FEC flags */
- SKP_uint8 iCDF[ 2 ] = { 0, 0 };
- iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, psEnc->sCmn.nFramesPerPacket + 1 );
- ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
-
- /* Encode any LBRR data from previous packet */
- SKP_Silk_LBRR_embed( &psEnc->sCmn, psRangeEnc );
-
- /* Reduce coding SNR depending on how many bits used by LBRR */
- nBits = ec_tell( psRangeEnc );
- psEnc->inBandFEC_SNR_comp = ( 6.0f * nBits ) /
- ( psEnc->sCmn.nFramesPerPacket * psEnc->sCmn.frame_length );
-
- /* Reset LBRR flags */
- SKP_memset( psEnc->sCmn.LBRR_flags, 0, sizeof( psEnc->sCmn.LBRR_flags ) );
- }
-
psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3;
/**************************************************************/
@@ -102,6 +84,25 @@
psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
}
+ if( psEnc->sCmn.nFramesAnalyzed == 0 && !psEnc->sCmn.prefillFlag && !( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
+ /* Create space at start of payload for VAD and FEC flags */
+ SKP_uint8 iCDF[ 2 ] = { 0, 0 };
+ iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, psEnc->sCmn.nFramesPerPacket + 1 );
+ ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
+
+ /* Encode any LBRR data from previous packet */
+ SKP_Silk_LBRR_embed( &psEnc->sCmn, psRangeEnc );
+
+ /* Reduce coding SNR depending on how many bits used by LBRR */
+ nBits = ec_tell( psRangeEnc );
+ psEnc->inBandFEC_SNR_comp = ( 6.0f * nBits ) /
+ ( psEnc->sCmn.nFramesPerPacket * psEnc->sCmn.frame_length );
+
+ /* Reset LBRR flags */
+ SKP_memset( psEnc->sCmn.LBRR_flags, 0, sizeof( psEnc->sCmn.LBRR_flags ) );
+ }
+
+
/*******************************************/
/* High-pass filtering of the input signal */
/*******************************************/