FS-11903: Fix errors reported by PVS-Studio Static Code Analyzer for mod_opus

This commit is contained in:
Andrey Volk 2019-07-12 19:57:22 +04:00
parent e0211e2ce1
commit 7afec393c7
1 changed files with 45 additions and 52 deletions

View File

@ -257,7 +257,6 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt
if ((arg = strchr(data, '='))) {
*arg++ = '\0';
if (codec_settings) {
if (!strcasecmp(data, "useinbandfec")) {
codec_settings->useinbandfec = switch_true(arg);
}
@ -313,7 +312,6 @@ static switch_status_t switch_opus_fmtp_parse(const char *fmtp, switch_codec_fmt
}
}
}
}
free(fmtp_dup);
}
return SWITCH_STATUS_SUCCESS;
@ -572,7 +570,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
if (encoding) {
/* come up with a way to specify these */
int bitrate_bps = OPUS_AUTO;
int use_vbr = opus_codec_settings.cbr ? !opus_codec_settings.cbr : opus_prefs.use_vbr ;
int use_vbr = opus_codec_settings.cbr ? 0 : opus_prefs.use_vbr ;
int complexity = opus_prefs.complexity;
int plpct = opus_prefs.plpct;
int err;
@ -623,8 +621,7 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
audiobandwidth = switch_opus_encoder_set_audio_bandwidth(context->encoder_object,opus_codec_settings.maxplaybackrate);
if (!switch_opus_show_audio_bandwidth(audiobandwidth,audiobandwidth_str)) {
memset(audiobandwidth_str,0,sizeof(audiobandwidth_str));
strncpy(audiobandwidth_str, "OPUS_AUTO",sizeof(audiobandwidth_str)-1);
snprintf(audiobandwidth_str, sizeof(audiobandwidth_str), "%s", "OPUS_AUTO");
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opus encoder: set audio bandwidth to [%s] based on maxplaybackrate value found in SDP or local config [%dHz]\n",audiobandwidth_str,opus_codec_settings.maxplaybackrate);
}
@ -1090,9 +1087,7 @@ static switch_status_t opus_load_config(switch_bool_t reload)
}
}
if (xml) {
switch_xml_free(xml);
}
return status;
}
@ -1131,7 +1126,7 @@ static switch_status_t switch_opus_keep_fec_enabled(switch_codec_t *codec)
b32 = ((opus_int32)((0.01) * ((opus_int64)1 << (16)) + 0.5));
LBRR_threshold_bitrate = (a32 >> 16) * (opus_int32)((opus_int16)b32) + (((a32 & 0x0000FFFF) * (opus_int32)((opus_int16)b32)) >> 16);
if ((!real_target_bitrate || !LBRR_threshold_bitrate)) {
if (!real_target_bitrate || !LBRR_threshold_bitrate) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opus encoder: error while controlling FEC params\n");
return SWITCH_STATUS_FALSE;
@ -1191,10 +1186,8 @@ static switch_status_t switch_opus_control(switch_codec_t *codec,
if (rtype) {
*rtype = reply_type;
if (reply) {
*ret_data = (void *)reply;
}
}
}
break;