RTP Player: Fix of resampling for visual waveform

When capture was longer (e.g. 800s), audio was decoded correctly, but
visual waveform was shown incorrectly. Reason was exceeding range of
guint32 during calculation. Calculation is now made in guint64 and then
put back to guint32.
This commit is contained in:
Jirka Novak 2021-08-20 22:39:01 +02:00 committed by Wireshark GitLab Utility
parent 2c556a0e90
commit dd161ade12
1 changed files with 2 additions and 2 deletions

View File

@ -412,7 +412,7 @@ void RtpAudioStream::decodeAudio(QAudioDeviceInfo out_device)
// Buffer is in SAMPLEs
spx_uint32_t in_len = (spx_uint32_t) (write_bytes / SAMPLE_BYTES);
// Output is audio_out_rate_/sample_rate bigger than input
spx_uint32_t out_len = (spx_uint32_t) (in_len * audio_out_rate_ / sample_rate);
spx_uint32_t out_len = (spx_uint32_t) ((guint64)in_len * audio_out_rate_ / sample_rate);
resample_buff = resizeBufferIfNeeded(resample_buff, &resample_buff_bytes, out_len * SAMPLE_BYTES);
speex_resampler_process_int(audio_resampler_, 0, decode_buff, &in_len, resample_buff, &out_len);
@ -453,7 +453,7 @@ void RtpAudioStream::decodeVisual()
// Loop over every frame record
// readFrameSamples() maintains size of buffer for us
while (audio_file_->readFrameSamples(&read_buff_bytes, &read_buff, &read_len, &frame_num, &type)) {
out_len = (spx_uint32_t)((read_len * visual_sample_rate_ ) / audio_out_rate_);
out_len = (spx_uint32_t)(((guint64)read_len * visual_sample_rate_ ) / audio_out_rate_);
if (type == RTP_FRAME_AUDIO) {
// We resample only audio samples