Browse Source

engine: client: voice: codec quality levels changed

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
8e48a98d48
  1. 31
      engine/client/voice.c

31
engine/client/voice.c

@ -161,28 +161,35 @@ qboolean Voice_Init( const char *pszCodecName, int quality )
switch( quality ) switch( quality )
{ {
case 1: // 4800 bits per second, <4 kHz bandwidth case 1: // 6 kbps, <6 kHz bandwidth
opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 4800 )); opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 6000 ));
opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_NARROWBAND )); opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_MEDIUMBAND ));
break; break;
case 2: // 12000 bits per second, <6 kHz bandwidth case 2: // 12 kbps, <12 kHz bandwidth
opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 12000 )); opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 12000 ));
opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_MEDIUMBAND )); opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_SUPERWIDEBAND ));
break; break;
case 4: // automatic bitrate, full band (20 kHz) case 4: // 64 kbps, full band (20 kHz)
opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( OPUS_AUTO )); opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 64000 ));
opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_FULLBAND )); opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_FULLBAND ));
break; break;
case 5: // maximum bitrate, full band (20 kHz) case 5: // 96 kbps, full band (20 kHz)
opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( OPUS_BITRATE_MAX )); opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 96000 ));
opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_FULLBAND )); opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_FULLBAND ));
break; break;
default: // 36000 bits per second, <12 kHz bandwidth default: // 36 kbps, <12 kHz bandwidth
opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 36000 )); opus_encoder_ctl( voice.encoder, OPUS_SET_BITRATE( 36000 ));
opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_SUPERWIDEBAND )); opus_encoder_ctl( voice.encoder, OPUS_SET_BANDWIDTH( OPUS_BANDWIDTH_SUPERWIDEBAND ));
break; break;
} }
if (quality == 5) {
opus_encoder_ctl( voice.encoder, OPUS_SET_APPLICATION( OPUS_APPLICATION_AUDIO ));
}
else {
opus_encoder_ctl( voice.encoder, OPUS_SET_APPLICATION( OPUS_APPLICATION_VOIP ));
}
voice.initialized = (err == OPUS_OK); voice.initialized = (err == OPUS_OK);
return voice.initialized; return voice.initialized;
} }
@ -354,10 +361,12 @@ static void Voice_StartChannel( uint samples, byte *data, int entnum )
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames ) void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
{ {
int samples;
if( !voice.initialized ) if( !voice.initialized )
return; return;
int samples = opus_decode( voice.decoder, data, size, (short *)voice.decompress_buffer, voice.frame_size / voice.width * frames, false ); samples = opus_decode( voice.decoder, data, size, (short *)voice.decompress_buffer, voice.frame_size / voice.width * frames, false );
if( samples > 0 ) if( samples > 0 )
Voice_StartChannel( samples, voice.decompress_buffer, ent ); Voice_StartChannel( samples, voice.decompress_buffer, ent );

Loading…
Cancel
Save