From 05a71cd57299bd27959deaca92af6b2c9a901739 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Wed, 20 Feb 2013 17:22:04 +0000 Subject: [PATCH] fixes by Michael Gorbovitski (mickg100) for OPUS performance improvement -> Thank you! --- src/client.cpp | 22 +++++++++++++++++----- src/global.h | 3 +++ src/server.cpp | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index d94939f6..4c0aa80a 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -83,6 +83,14 @@ CClient::CClient ( const quint16 iPortNumber ) : opus_custom_encoder_ctl ( OpusEncoderMono, OPUS_SET_VBR ( 0 ) ); + // we expect packet loss, tell the encoder about it + opus_custom_encoder_ctl ( OpusEncoderMono, + OPUS_SET_PACKET_LOSS_PERC ( OPUS_EXPECTED_PACKET_LOSS_PERC ) ); + + // we want as low delay as possible + opus_custom_encoder_ctl ( OpusEncoderMono, + OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity opus_custom_encoder_ctl ( OpusEncoderMono, @@ -114,6 +122,14 @@ CClient::CClient ( const quint16 iPortNumber ) : opus_custom_encoder_ctl ( OpusEncoderStereo, OPUS_SET_VBR ( 0 ) ); + // we expect packet loss, tell the encoder about it + opus_custom_encoder_ctl ( OpusEncoderStereo, + OPUS_SET_PACKET_LOSS_PERC ( OPUS_EXPECTED_PACKET_LOSS_PERC ) ); + + // we want as low delay as possible + opus_custom_encoder_ctl ( OpusEncoderStereo, + OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity opus_custom_encoder_ctl ( OpusEncoderStereo, @@ -354,13 +370,9 @@ void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ) // #### COMPATIBILITY OLD VERSION, TO BE REMOVED #### void CClient::OnOpusSupported() { -// TODO do NOT switch to OPUS since the PLC seems to be much worse in OPUS -// compared to the good old CELT version -// -> find out why this is the case and as soon as the issue is solved, -// enable OPUS again... if ( eAudioCompressionType != CT_OPUS ) { -// SetAudoCompressiontype ( CT_OPUS ); + SetAudoCompressiontype ( CT_OPUS ); } } diff --git a/src/global.h b/src/global.h index 264e4933..54401ee2 100755 --- a/src/global.h +++ b/src/global.h @@ -115,6 +115,9 @@ LED bar: lbr // low complexity CELT encoder (if defined) #define USE_LOW_COMPLEXITY_CELT_ENC +// percentage of expected packet loss percentage in the OPUS encoder +#define OPUS_EXPECTED_PACKET_LOSS_PERC 10 + // define the minimum allowed number of coded bytes for CELT (the encoder // gets in trouble if the value is too low) #define CELT_MINIMUM_NUM_BYTES 10 diff --git a/src/server.cpp b/src/server.cpp index 0c1acd15..1cd30e17 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -223,6 +223,14 @@ CServer::CServer ( const int iNewNumChan, opus_custom_encoder_ctl ( OpusEncoderMono[i], OPUS_SET_VBR ( 0 ) ); + // we expect packet loss, tell the encoder about it + opus_custom_encoder_ctl ( OpusEncoderMono[i], + OPUS_SET_PACKET_LOSS_PERC ( OPUS_EXPECTED_PACKET_LOSS_PERC ) ); + + // we want as low delay as possible + opus_custom_encoder_ctl ( OpusEncoderMono[i], + OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity opus_custom_encoder_ctl ( OpusEncoderMono[i], @@ -254,6 +262,14 @@ CServer::CServer ( const int iNewNumChan, opus_custom_encoder_ctl ( OpusEncoderStereo[i], OPUS_SET_VBR ( 0 ) ); + // we expect packet loss, tell the encoder about it + opus_custom_encoder_ctl ( OpusEncoderStereo[i], + OPUS_SET_PACKET_LOSS_PERC ( OPUS_EXPECTED_PACKET_LOSS_PERC ) ); + + // we want as low delay as possible + opus_custom_encoder_ctl ( OpusEncoderStereo[i], + OPUS_SET_APPLICATION ( OPUS_APPLICATION_RESTRICTED_LOWDELAY ) ); + #ifdef USE_LOW_COMPLEXITY_CELT_ENC // set encoder low complexity opus_custom_encoder_ctl ( OpusEncoderStereo[i],