bug fix: use OPUS custom interface instead of the normal one

This commit is contained in:
Volker Fischer 2013-02-16 19:11:30 +00:00
parent dcbfba2fd9
commit 694ee2fae2
5 changed files with 129 additions and 130 deletions

View File

@ -134,6 +134,7 @@ HEADERS += src/audiomixerboard.h \
libs/celt/cc6_vq.h \
libs/opus/include/opus.h \
libs/opus/include/opus_multistream.h \
libs/opus/include/opus_custom.h \
libs/opus/src/opus_private.h \
libs/opus/celt/arch.h \
libs/opus/celt/bands.h \

View File

@ -67,23 +67,26 @@ CClient::CClient ( const quint16 iPortNumber ) :
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
#endif
OpusEncoderMono = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
1,
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
&iOpusError );
OpusMode = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
SYSTEM_FRAME_SIZE_SAMPLES,
&iOpusError );
OpusDecoderMono = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
1,
&iOpusError );
OpusEncoderMono = opus_custom_encoder_create ( OpusMode,
1,
&iOpusError );
OpusDecoderMono = opus_custom_decoder_create ( OpusMode,
1,
&iOpusError );
// we require a constant bit rate
opus_encoder_ctl ( OpusEncoderMono,
OPUS_SET_VBR ( 0 ) );
opus_custom_encoder_ctl ( OpusEncoderMono,
OPUS_SET_VBR ( 0 ) );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity
opus_encoder_ctl ( OpusEncoderMono,
OPUS_SET_COMPLEXITY ( 1 ) );
opus_custom_encoder_ctl ( OpusEncoderMono,
OPUS_SET_COMPLEXITY ( 1 ) );
#endif
// init audio encoder/decoder (stereo)
@ -99,23 +102,22 @@ CClient::CClient ( const quint16 iPortNumber ) :
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
#endif
OpusEncoderStereo = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
2,
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
&iOpusError );
OpusEncoderStereo = opus_custom_encoder_create ( OpusMode,
2,
&iOpusError );
OpusDecoderStereo = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
2,
&iOpusError );
OpusDecoderStereo = opus_custom_decoder_create ( OpusMode,
2,
&iOpusError );
// we require a constant bit rate
opus_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_VBR ( 0 ) );
opus_custom_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_VBR ( 0 ) );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity
opus_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_COMPLEXITY ( 1 ) );
opus_custom_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_COMPLEXITY ( 1 ) );
#endif
@ -731,13 +733,13 @@ void CClient::Init()
if ( bUseStereo )
{
opus_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_custom_encoder_ctl ( OpusEncoderStereo,
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
}
else
{
opus_encoder_ctl ( OpusEncoderMono,
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_custom_encoder_ctl ( OpusEncoderMono,
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
}
// inits for network and channel
@ -971,11 +973,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_encode ( OpusEncoderStereo,
&vecsNetwork[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
opus_custom_encode ( OpusEncoderStereo,
&vecsNetwork[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
}
}
else
@ -991,11 +993,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_encode ( OpusEncoderMono,
&vecsNetwork[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
opus_custom_encode ( OpusEncoderMono,
&vecsNetwork[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
}
}
@ -1035,12 +1037,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_decode ( OpusDecoderStereo,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderStereo,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
else
@ -1054,12 +1055,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_decode ( OpusDecoderMono,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderMono,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
}
@ -1077,12 +1077,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_decode ( OpusDecoderStereo,
NULL,
iCeltNumCodedBytes,
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderStereo,
NULL,
iCeltNumCodedBytes,
&vecsStereoSndCrd[i * 2 * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
else
@ -1096,12 +1095,11 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
}
else
{
opus_decode ( OpusDecoderMono,
NULL,
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderMono,
NULL,
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[i * SYSTEM_FRAME_SIZE_SAMPLES],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
}

View File

@ -31,7 +31,7 @@
#include <QDateTime>
#include <QMessageBox>
#include "cc6_celt.h"
#include "opus.h"
#include "opus_custom.h"
#include "global.h"
#include "socket.h"
#include "channel.h"
@ -275,10 +275,11 @@ void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType );
cc6_CELTMode* CeltModeStereo;
cc6_CELTEncoder* CeltEncoderStereo;
cc6_CELTDecoder* CeltDecoderStereo;
OpusEncoder* OpusEncoderMono;
OpusDecoder* OpusDecoderMono;
OpusEncoder* OpusEncoderStereo;
OpusDecoder* OpusDecoderStereo;
OpusCustomMode* OpusMode;
OpusCustomEncoder* OpusEncoderMono;
OpusCustomDecoder* OpusDecoderMono;
OpusCustomEncoder* OpusEncoderStereo;
OpusCustomDecoder* OpusDecoderStereo;
EAudComprType eAudioCompressionType;
int iCeltNumCodedBytes;
bool bCeltDoHighQuality;

View File

@ -207,23 +207,26 @@ CServer::CServer ( const int iNewNumChan,
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
#endif
OpusEncoderMono[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
1,
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
&iOpusError );
OpusMode[i] = opus_custom_mode_create ( SYSTEM_SAMPLE_RATE_HZ,
SYSTEM_FRAME_SIZE_SAMPLES,
&iOpusError );
OpusDecoderMono[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
1,
&iOpusError );
OpusEncoderMono[i] = opus_custom_encoder_create ( OpusMode[i],
1,
&iOpusError );
OpusDecoderMono[i] = opus_custom_decoder_create ( OpusMode[i],
1,
&iOpusError );
// we require a constant bit rate
opus_encoder_ctl ( OpusEncoderMono[i],
OPUS_SET_VBR ( 0 ) );
opus_custom_encoder_ctl ( OpusEncoderMono[i],
OPUS_SET_VBR ( 0 ) );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity
opus_encoder_ctl ( OpusEncoderMono[i],
OPUS_SET_COMPLEXITY ( 1 ) );
opus_custom_encoder_ctl ( OpusEncoderMono[i],
OPUS_SET_COMPLEXITY ( 1 ) );
#endif
// init audio endocder/decoder (stereo)
@ -239,23 +242,22 @@ CServer::CServer ( const int iNewNumChan,
cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) );
#endif
OpusEncoderStereo[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ,
2,
OPUS_APPLICATION_RESTRICTED_LOWDELAY,
&iOpusError );
OpusEncoderStereo[i] = opus_custom_encoder_create ( OpusMode[i],
2,
&iOpusError );
OpusDecoderStereo[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ,
2,
&iOpusError );
OpusDecoderStereo[i] = opus_custom_decoder_create ( OpusMode[i],
2,
&iOpusError );
// we require a constant bit rate
opus_encoder_ctl ( OpusEncoderStereo[i],
OPUS_SET_VBR ( 0 ) );
opus_custom_encoder_ctl ( OpusEncoderStereo[i],
OPUS_SET_VBR ( 0 ) );
#ifdef USE_LOW_COMPLEXITY_CELT_ENC
// set encoder low complexity
opus_encoder_ctl ( OpusEncoderStereo[i],
OPUS_SET_COMPLEXITY ( 1 ) );
opus_custom_encoder_ctl ( OpusEncoderStereo[i],
OPUS_SET_COMPLEXITY ( 1 ) );
#endif
}
@ -633,12 +635,11 @@ void CServer::OnTimer()
}
else
{
opus_decode ( OpusDecoderMono[iCurChanID],
&vecbyData[0],
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderMono[iCurChanID],
&vecbyData[0],
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
else
@ -654,12 +655,11 @@ void CServer::OnTimer()
}
else
{
opus_decode ( OpusDecoderStereo[iCurChanID],
&vecbyData[0],
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
&vecbyData[0],
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
}
@ -679,12 +679,11 @@ void CServer::OnTimer()
}
else
{
opus_decode ( OpusDecoderMono[iCurChanID],
NULL,
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderMono[iCurChanID],
NULL,
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
else
@ -700,12 +699,11 @@ void CServer::OnTimer()
}
else
{
opus_decode ( OpusDecoderStereo[iCurChanID],
NULL,
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES,
0 );
opus_custom_decode ( OpusDecoderStereo[iCurChanID],
NULL,
iCeltNumCodedBytes,
&vecvecsData[i][0],
SYSTEM_FRAME_SIZE_SAMPLES );
}
}
}
@ -784,14 +782,14 @@ const int iCeltBitRateBitsPerSec =
// TODO find a better place than this: the setting does not change all the time
// so for speed optimization it would be better to set it only if the network
// frame size is changed
opus_encoder_ctl ( OpusEncoderMono[iCurChanID],
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_custom_encoder_ctl ( OpusEncoderMono[iCurChanID],
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_encode ( OpusEncoderMono[iCurChanID],
&vecsSendData[0],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
opus_custom_encode ( OpusEncoderMono[iCurChanID],
&vecsSendData[0],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
}
}
else
@ -811,14 +809,14 @@ opus_encoder_ctl ( OpusEncoderMono[iCurChanID],
// TODO find a better place than this: the setting does not change all the time
// so for speed optimization it would be better to set it only if the network
// frame size is changed
opus_encoder_ctl ( OpusEncoderStereo[iCurChanID],
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_custom_encoder_ctl ( OpusEncoderStereo[iCurChanID],
OPUS_SET_BITRATE ( iCeltBitRateBitsPerSec ) );
opus_encode ( OpusEncoderStereo[iCurChanID],
&vecsSendData[0],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
opus_custom_encode ( OpusEncoderStereo[iCurChanID],
&vecsSendData[0],
SYSTEM_FRAME_SIZE_SAMPLES,
&vecCeltData[0],
iCeltNumCodedBytes );
}
}

View File

@ -30,7 +30,7 @@
#include <QDateTime>
#include <QHostAddress>
#include "cc6_celt.h"
#include "opus.h"
#include "opus_custom.h"
#include "global.h"
#include "socket.h"
#include "channel.h"
@ -214,10 +214,11 @@ protected:
cc6_CELTMode* CeltModeStereo[MAX_NUM_CHANNELS];
cc6_CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS];
cc6_CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS];
OpusEncoder* OpusEncoderMono[MAX_NUM_CHANNELS];
OpusDecoder* OpusDecoderMono[MAX_NUM_CHANNELS];
OpusEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS];
OpusDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS];
OpusCustomMode* OpusMode[MAX_NUM_CHANNELS];
OpusCustomEncoder* OpusEncoderMono[MAX_NUM_CHANNELS];
OpusCustomDecoder* OpusDecoderMono[MAX_NUM_CHANNELS];
OpusCustomEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS];
OpusCustomDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS];
CVector<QString> vstrChatColors;