From f7479653be7649267fd9e2096adf47862cea1a95 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jean-marc.valin@octasic.com> Date: Thu, 17 Mar 2011 16:55:42 -0400 Subject: [PATCH] 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 --- src_FLP/SKP_Silk_encode_frame_FLP.c | 37 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src_FLP/SKP_Silk_encode_frame_FLP.c b/src_FLP/SKP_Silk_encode_frame_FLP.c index 8a6d3b4eb..c80bcbeb4 100644 --- a/src_FLP/SKP_Silk_encode_frame_FLP.c +++ b/src_FLP/SKP_Silk_encode_frame_FLP.c @@ -47,24 +47,6 @@ SKP_int SKP_Silk_encode_frame_FLP( 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 @@ TOC(VAD) 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 */ /*******************************************/ -- GitLab