kopia lustrzana https://gitlab.com/eliggett/wfview
Skip unneeded float conversion for Opus
rodzic
bbbb36ebae
commit
71f88cdfed
|
@ -16,6 +16,10 @@ bool audioConverter::init(QAudioFormat inFormat, QAudioFormat outFormat, quint8
|
|||
qInfo(logAudioConverter) << "Starting audioConverter() Input:" << inFormat.channelCount() << "Channels of" << inFormat.codec() << inFormat.sampleRate() << inFormat.sampleType() << inFormat.sampleSize() <<
|
||||
"Output:" << outFormat.channelCount() << "Channels of" << outFormat.codec() << outFormat.sampleRate() << outFormat.sampleType() << outFormat.sampleSize();
|
||||
|
||||
if (inFormat.byteOrder() != outFormat.byteOrder()) {
|
||||
qInfo(logAudioConverter) << "Byteorder mismatch in:" << inFormat.byteOrder() << "out:" << outFormat.byteOrder();
|
||||
}
|
||||
|
||||
|
||||
if (inFormat.codec() == "audio/opus")
|
||||
{
|
||||
|
@ -31,7 +35,7 @@ bool audioConverter::init(QAudioFormat inFormat, QAudioFormat outFormat, quint8
|
|||
int opus_err = 0;
|
||||
opusEncoder = opus_encoder_create(outFormat.sampleRate(), outFormat.channelCount(), OPUS_APPLICATION_AUDIO, &opus_err);
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_LSB_DEPTH(16));
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_INBAND_FEC(1));
|
||||
//opus_encoder_ctl(opusEncoder, OPUS_SET_INBAND_FEC(1));
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_DTX(1));
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_PACKET_LOSS_PERC(5));
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_COMPLEXITY(opusComplexity)); // Reduce complexity to maybe lower CPU?
|
||||
|
@ -222,10 +226,13 @@ bool audioConverter::convert(audioPacket audio)
|
|||
}
|
||||
else {
|
||||
outPacket.resize(nbBytes);
|
||||
samplesF = Eigen::Map<Eigen::VectorXf>(reinterpret_cast<float*>(outPacket.data()), outPacket.size() / int(sizeof(float)));
|
||||
audio.data.clear();
|
||||
audio.data = outPacket; // Copy output packet back to input buffer.
|
||||
//samplesF = Eigen::Map<Eigen::VectorXf>(reinterpret_cast<float*>(outPacket.data()), outPacket.size() / int(sizeof(float)));
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
/*
|
||||
|
@ -292,7 +299,7 @@ bool audioConverter::convert(audioPacket audio)
|
|||
audio.data = outPacket; // Copy output packet back to input buffer.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
emit converted(audio);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ bool audioHandler::init(audioSetup setupIn)
|
|||
setup.format.setChannelCount(1);
|
||||
setup.format.setSampleSize(8);
|
||||
setup.format.setSampleType(QAudioFormat::UnSignedInt);
|
||||
setup.format.setByteOrder(QAudioFormat::LittleEndian);
|
||||
setup.format.setCodec("audio/pcm");
|
||||
qInfo(logAudio()) << (setup.isinput ? "Input" : "Output") << "audio handler starting:" << setup.name;
|
||||
|
||||
|
@ -267,10 +268,11 @@ void audioHandler::setVolume(unsigned char volume)
|
|||
void audioHandler::incomingAudio(audioPacket packet)
|
||||
{
|
||||
//QTime startProcessing = QTime::currentTime();
|
||||
|
||||
if (audioDevice != Q_NULLPTR) {
|
||||
packet.volume = volume;
|
||||
|
||||
emit sendToConverter(packet);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue