mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 10:45:37 +08:00
Fix cppcheck and compiler warnings
This commit is contained in:
@@ -19,7 +19,7 @@ using namespace BlackMisc::Audio;
|
||||
|
||||
namespace BlackSound
|
||||
{
|
||||
QVector<float> convertBytesTo32BitFloatPCM(const QByteArray input)
|
||||
QVector<float> convertBytesTo32BitFloatPCM(const QByteArray &input)
|
||||
{
|
||||
int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample
|
||||
QVector<float> output;
|
||||
@@ -33,7 +33,7 @@ namespace BlackSound
|
||||
return output;
|
||||
}
|
||||
|
||||
QVector<qint16> convertBytesTo16BitPCM(const QByteArray input)
|
||||
QVector<qint16> convertBytesTo16BitPCM(const QByteArray &input)
|
||||
{
|
||||
const int inputSamples = input.size() / 2; // 16 bit input, so 2 bytes per sample
|
||||
QVector<qint16> output;
|
||||
@@ -45,7 +45,7 @@ namespace BlackSound
|
||||
return output;
|
||||
}
|
||||
|
||||
QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input)
|
||||
QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray &input)
|
||||
{
|
||||
Q_UNUSED(input)
|
||||
// qFatal("Not implemented");
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
namespace BlackSound
|
||||
{
|
||||
//! Conversion functions @{
|
||||
BLACKSOUND_EXPORT QVector<float> convertBytesTo32BitFloatPCM(const QByteArray input);
|
||||
BLACKSOUND_EXPORT QVector<qint16> convertBytesTo16BitPCM(const QByteArray input);
|
||||
BLACKSOUND_EXPORT QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray input);
|
||||
BLACKSOUND_EXPORT QVector<float> convertBytesTo32BitFloatPCM(const QByteArray &input);
|
||||
BLACKSOUND_EXPORT QVector<qint16> convertBytesTo16BitPCM(const QByteArray &input);
|
||||
BLACKSOUND_EXPORT QVector<qint16> convertFloatBytesTo16BitPCM(const QByteArray &input);
|
||||
BLACKSOUND_EXPORT QVector<float> convertFromMonoToStereo(const QVector<float> &mono);
|
||||
BLACKSOUND_EXPORT QVector<qint16> convertFromStereoToMono(const QVector<qint16> &stereo);
|
||||
BLACKSOUND_EXPORT QVector<float> convertFromShortToFloat(const QVector<qint16> &input);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BlackSound
|
||||
return bufferSize / bytesPerSample;
|
||||
}
|
||||
|
||||
QVector<qint16> COpusDecoder::decode(const QByteArray opusData, int dataLength, int *decodedLength)
|
||||
QVector<qint16> COpusDecoder::decode(const QByteArray &opusData, int dataLength, int *decodedLength)
|
||||
{
|
||||
QVector<qint16> decoded(MaxDataBytes, 0);
|
||||
int count = frameCount(MaxDataBytes);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace BlackSound
|
||||
int frameCount(int bufferSize);
|
||||
|
||||
//! Decode
|
||||
QVector<qint16> decode(const QByteArray opusData, int dataLength, int *decodedLength);
|
||||
QVector<qint16> decode(const QByteArray &opusData, int dataLength, int *decodedLength);
|
||||
|
||||
//! Reset
|
||||
void resetState();
|
||||
|
||||
@@ -12,9 +12,7 @@ namespace BlackSound
|
||||
{
|
||||
namespace Codecs
|
||||
{
|
||||
COpusEncoder::COpusEncoder(int sampleRate, int channels, int application) :
|
||||
m_sampleRate(sampleRate),
|
||||
m_channels(channels)
|
||||
COpusEncoder::COpusEncoder(int sampleRate, int channels, int application)
|
||||
{
|
||||
int error;
|
||||
opusEncoder = opus_encoder_create(sampleRate, channels, application, &error);
|
||||
@@ -30,7 +28,7 @@ namespace BlackSound
|
||||
opus_encoder_ctl(opusEncoder, OPUS_SET_BITRATE(bitRate));
|
||||
}
|
||||
|
||||
QByteArray COpusEncoder::encode(const QVector<qint16> pcmSamples, int samplesLength, int *encodedLength)
|
||||
QByteArray COpusEncoder::encode(const QVector<qint16> &pcmSamples, int samplesLength, int *encodedLength)
|
||||
{
|
||||
QByteArray encoded(maxDataBytes, 0);
|
||||
int length = opus_encode(opusEncoder, reinterpret_cast<const opus_int16 *>(pcmSamples.data()), samplesLength, reinterpret_cast<unsigned char *>(encoded.data()), maxDataBytes);
|
||||
|
||||
@@ -40,20 +40,11 @@ namespace BlackSound
|
||||
//! Bit rate
|
||||
void setBitRate(int bitRate);
|
||||
|
||||
//! \param frameCount Number of audio samples per frame
|
||||
//! \returns the size of an audio frame in bytes
|
||||
int frameByteCount(int frameCount);
|
||||
|
||||
//! Frame count
|
||||
int frameCount(const QVector<qint16> pcmSamples);
|
||||
|
||||
//! Encode
|
||||
QByteArray encode(const QVector<qint16> pcmSamples, int samplesLength, int *encodedLength);
|
||||
QByteArray encode(const QVector<qint16> &pcmSamples, int samplesLength, int *encodedLength);
|
||||
|
||||
private:
|
||||
OpusEncoder *opusEncoder = nullptr;
|
||||
int m_sampleRate;
|
||||
int m_channels;
|
||||
|
||||
static constexpr int maxDataBytes = 4000;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user