mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
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.
This commit is contained in:
parent
e396747377
commit
7616c9c06e
3 changed files with 12 additions and 5 deletions
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
set(TARGET_NAME opusCodec)
|
set(TARGET_NAME opusCodec)
|
||||||
setup_hifi_client_server_plugin()
|
setup_hifi_client_server_plugin()
|
||||||
link_hifi_libraries(shared plugins)
|
link_hifi_libraries(shared audio plugins)
|
||||||
|
|
||||||
if (BUILD_SERVER)
|
if (BUILD_SERVER)
|
||||||
install_beside_console()
|
install_beside_console()
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
|
#include <AudioConstants.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ AthenaOpusDecoder::AthenaOpusDecoder(int sampleRate, int numChannels)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qCDebug(decoder) << "Opus decoder initialized";
|
qCDebug(decoder) << "Opus decoder initialized, sampleRate = " << sampleRate << "; numChannels = " << numChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
AthenaOpusDecoder::~AthenaOpusDecoder()
|
AthenaOpusDecoder::~AthenaOpusDecoder()
|
||||||
|
@ -61,10 +62,14 @@ void AthenaOpusDecoder::decode(const QByteArray &encodedBuffer, QByteArray &deco
|
||||||
|
|
||||||
PerformanceTimer perfTimer("AthenaOpusDecoder::decode");
|
PerformanceTimer perfTimer("AthenaOpusDecoder::decode");
|
||||||
|
|
||||||
decodedBuffer.resize( 65536 ); // Brute force, yeah!
|
|
||||||
|
int buffer_size = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * static_cast<int>(sizeof(int16_t)) * _opus_num_channels;
|
||||||
|
|
||||||
|
decodedBuffer.resize( buffer_size );
|
||||||
int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
|
int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
|
||||||
|
|
||||||
int frames = opus_decode( _decoder, reinterpret_cast<const unsigned char*>(encodedBuffer.data()), encodedBuffer.length(), reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 1 );
|
qCDebug(decoder) << "Opus decode: encodedBytes = " << encodedBuffer.length() << "; decodedBufferBytes = " << decodedBuffer.size() << "; frameCount = " << frame_size;
|
||||||
|
int frames = opus_decode( _decoder, reinterpret_cast<const unsigned char*>(encodedBuffer.data()), encodedBuffer.length(), reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 0 );
|
||||||
|
|
||||||
if ( frames >= 0 ) {
|
if ( frames >= 0 ) {
|
||||||
qCDebug(decoder) << "Decoded " << frames << " Opus frames";
|
qCDebug(decoder) << "Decoded " << frames << " Opus frames";
|
||||||
|
@ -81,7 +86,8 @@ void AthenaOpusDecoder::lostFrame(QByteArray &decodedBuffer)
|
||||||
|
|
||||||
PerformanceTimer perfTimer("AthenaOpusDecoder::lostFrame");
|
PerformanceTimer perfTimer("AthenaOpusDecoder::lostFrame");
|
||||||
|
|
||||||
decodedBuffer.resize( 65536 ); // Brute force, yeah!
|
int buffer_size = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * static_cast<int>(sizeof(int16_t)) * _opus_num_channels;
|
||||||
|
decodedBuffer.resize( buffer_size );
|
||||||
int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
|
int frame_size = decodedBuffer.size() / _opus_num_channels / static_cast<int>(sizeof( opus_int16 ));
|
||||||
|
|
||||||
int frames = opus_decode( _decoder, nullptr, 0, reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 1 );
|
int frames = opus_decode( _decoder, nullptr, 0, reinterpret_cast<opus_int16*>(decodedBuffer.data()), frame_size, 1 );
|
||||||
|
|
|
@ -22,6 +22,7 @@ private:
|
||||||
OpusDecoder *_decoder = nullptr;
|
OpusDecoder *_decoder = nullptr;
|
||||||
int _opus_sample_rate = 0;
|
int _opus_sample_rate = 0;
|
||||||
int _opus_num_channels = 0;
|
int _opus_num_channels = 0;
|
||||||
|
int _decoded_size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue