Fix cppcheck and compiler warnings

This commit is contained in:
Mat Sutcliffe
2020-06-18 23:48:58 +01:00
parent 9309beefc4
commit 670b1a1986
61 changed files with 131 additions and 153 deletions

View File

@@ -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");

View File

@@ -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);

View File

@@ -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);

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
};