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

View file

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

View file

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

View file

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