History

Don't attempt FEC decoding in decode(). More logging.

Also use the fixed size audio buffer for decoding -- audio always works in packets of the same size, so we should always get the same amount out of decoding.

Dale Glass committed 6 years ago

Commit 7616c9c1 parent e3967473 files · +12 −5Browse files

Showing the changes to plugins/opusCodec/src/OpusDecoder.cpp (1 of 3 files). Show all

Unified · Split

plugins/opusCodec/src/OpusDecoder.cpp+10−4
@@ -1,5 +1,6 @@
11 #include <PerfStat.h>
22 #include <QtCore/QLoggingCategory>
3+#include <AudioConstants.h>
34
45
56
@@ -45,7 +46,7 @@ AthenaOpusDecoder::AthenaOpusDecoder(int sampleRate, int numChannels) · 39 unmodified lines
4546 }
4647
4748
48− qCDebug(decoder) << "Opus decoder initialized";
49+ qCDebug(decoder) << "Opus decoder initialized, sampleRate = " << sampleRate << "; numChannels = " << numChannels;
4950 }
5051
5152 AthenaOpusDecoder::~AthenaOpusDecoder()
@@ -61,10 +62,14 @@ void AthenaOpusDecoder::decode(const QByteArray &encodedBuffer, QByteArray &deco · 9 unmodified lines
6162
6263 PerformanceTimer perfTimer("AthenaOpusDecoder::decode");
6364
64− decodedBuffer.resize( 65536 ); // Brute force, yeah!
65+
66+ int buffer_size = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * static_cast<int>(sizeof(int16_t)) * _opus_num_channels;
67+
68+ decodedBuffer.resize( buffer_size );
6569 int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
6670
67− int frames = opus_decode( _decoder, reinterpret_cast<const unsigned char*>(encodedBuffer.data()), encodedBuffer.length(), reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 1 );
71+ qCDebug(decoder) << "Opus decode: encodedBytes = " << encodedBuffer.length() << "; decodedBufferBytes = " << decodedBuffer.size() << "; frameCount = " << frame_size;
72+ int frames = opus_decode( _decoder, reinterpret_cast<const unsigned char*>(encodedBuffer.data()), encodedBuffer.length(), reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 0 );
6873
6974 if ( frames >= 0 ) {
7075 qCDebug(decoder) << "Decoded " << frames << " Opus frames";
@@ -81,7 +86,8 @@ void AthenaOpusDecoder::lostFrame(QByteArray &decodedBuffer) · 10 unmodified lines
8186
8287 PerformanceTimer perfTimer("AthenaOpusDecoder::lostFrame");
8388
84− decodedBuffer.resize( 65536 ); // Brute force, yeah!
89+ int buffer_size = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * static_cast<int>(sizeof(int16_t)) * _opus_num_channels;
90+ decodedBuffer.resize( buffer_size );
8591 int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
8692
8793 int frames = opus_decode( _decoder, nullptr, 0, reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 1 );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t