Commit daf4290d authored by Simon Eugster's avatar Simon Eugster

QString::toStdString() replaced by QString::toLocal8Bit() as KDE4

disables STL support with QT_NO_STL.

Also, changed delete to delete[].
parent 5aa35dcb
......@@ -22,6 +22,10 @@ AudioCorrelation::AudioCorrelation(AudioEnvelope *mainTrackEnvelope) :
AudioCorrelation::~AudioCorrelation()
{
delete m_mainTrackEnvelope;
foreach (AudioEnvelope *envelope, m_children) {
delete envelope;
}
}
int AudioCorrelation::addChild(AudioEnvelope *envelope)
......
......@@ -27,10 +27,14 @@ class AudioCorrelationInfo;
class AudioCorrelation
{
public:
/// AudioCorrelation will take ownership of mainTrackEnvelope
AudioCorrelation(AudioEnvelope *mainTrackEnvelope);
~AudioCorrelation();
/// \return The child's index
/**
This object will take ownership of the passed envelope.
\return The child's index
*/
int addChild(AudioEnvelope *envelope);
const AudioCorrelationInfo *info(int childIndex) const;
......
......@@ -21,7 +21,7 @@ AudioCorrelationInfo::AudioCorrelationInfo(int mainSize, int subSize) :
AudioCorrelationInfo::~AudioCorrelationInfo()
{
delete m_correlationVector;
delete[] m_correlationVector;
}
int AudioCorrelationInfo::size() const
......
......@@ -29,7 +29,7 @@ AudioEnvelope::AudioEnvelope(Mlt::Producer *producer) :
AudioEnvelope::~AudioEnvelope()
{
if (m_envelope != NULL) {
delete m_envelope;
delete[] m_envelope;
}
delete m_info;
}
......
......@@ -11,6 +11,7 @@
#include "audioInfo.h"
#include "audioStreamInfo.h"
#include <QString>
#include <iostream>
#include <cstdlib>
......@@ -22,9 +23,9 @@ AudioInfo::AudioInfo(Mlt::Producer *producer)
// Get the number of streams and add the information of each of them if it is an audio stream.
int streams = atoi(producer->get("meta.media.nb_streams"));
for (int i = 0; i < streams; i++) {
std::string propertyName = QString("meta.media.%1.stream.type").arg(i).toStdString();
QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit();
if (strcmp("audio", producer->get(propertyName.c_str())) == 0) {
if (strcmp("audio", producer->get(propertyName.data())) == 0) {
m_list << new AudioStreamInfo(producer, i);
}
......
......@@ -10,6 +10,7 @@
#include "audioStreamInfo.h"
#include <QString>
#include <iostream>
#include <cstdlib>
......@@ -17,25 +18,25 @@ AudioStreamInfo::AudioStreamInfo(Mlt::Producer *producer, int audioStreamIndex)
m_audioStreamIndex(audioStreamIndex)
{
std::string key;
QByteArray key;
key = QString("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toStdString();
m_samplingFormat = QString(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toLocal8Bit();
m_samplingFormat = QString(producer->get(key.data()));
key = QString("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toStdString();
m_samplingRate = atoi(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toLocal8Bit();
m_samplingRate = atoi(producer->get(key.data()));
key = QString("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toStdString();
m_bitRate = atoi(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toLocal8Bit();
m_bitRate = atoi(producer->get(key.data()));
key = QString("meta.media.%1.codec.channels").arg(audioStreamIndex).toStdString();
m_channels = atoi(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.channels").arg(audioStreamIndex).toLocal8Bit();
m_channels = atoi(producer->get(key.data()));
key = QString("meta.media.%1.codec.name").arg(audioStreamIndex).toStdString();
m_codecName = QString(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.name").arg(audioStreamIndex).toLocal8Bit();
m_codecName = QString(producer->get(key.data()));
key = QString("meta.media.%1.codec.long_name").arg(audioStreamIndex).toStdString();
m_codecLongName = QString(producer->get(key.c_str()));
key = QString("meta.media.%1.codec.long_name").arg(audioStreamIndex).toLocal8Bit();
m_codecLongName = QString(producer->get(key.data()));
}
AudioStreamInfo::~AudioStreamInfo()
{
......@@ -57,7 +58,7 @@ const QString& AudioStreamInfo::codecName(bool longName) const
void AudioStreamInfo::dumpInfo() const
{
std::cout << "Info for audio stream " << m_audioStreamIndex << std::endl
<< "\tCodec: " << m_codecLongName.toStdString() << " (" << m_codecName.toStdString() << ")" << std::endl
<< "\tCodec: " << m_codecLongName.toLocal8Bit().data() << " (" << m_codecName.toLocal8Bit().data() << ")" << std::endl
<< "\tChannels: " << m_channels << std::endl
<< "\tSampling rate: " << m_samplingRate << std::endl
<< "\tBit rate: " << m_bitRate << std::endl
......
......@@ -117,15 +117,15 @@ int main(int argc, char *argv[])
// Build the audio envelopes for the correlation
AudioEnvelope envelopeMain(&prodMain);
envelopeMain.loadEnvelope();
envelopeMain.loadStdDev();
envelopeMain.dumpInfo();
AudioEnvelope *envelopeMain = new AudioEnvelope(&prodMain);
envelopeMain->loadEnvelope();
envelopeMain->loadStdDev();
envelopeMain->dumpInfo();
AudioEnvelope envelopeSub(&prodSub);
envelopeSub.loadEnvelope();
envelopeSub.loadStdDev();
envelopeSub.dumpInfo();
AudioEnvelope *envelopeSub = new AudioEnvelope(&prodSub);
envelopeSub->loadEnvelope();
envelopeSub->loadStdDev();
envelopeSub->dumpInfo();
......@@ -133,8 +133,8 @@ int main(int argc, char *argv[])
// Calculate the correlation and hereby the audio shift
AudioCorrelation corr(&envelopeMain);
int index = corr.addChild(&envelopeSub);
AudioCorrelation corr(envelopeMain);
int index = corr.addChild(envelopeSub);
int shift = corr.getShift(index);
std::cout << fileSub << " should be shifted by " << shift << " frames" << std::endl
......@@ -147,13 +147,13 @@ int main(int argc, char *argv[])
QString outImg;
outImg = QString("envelope-main-%1.png")
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
envelopeMain.drawEnvelope().save(outImg);
envelopeMain->drawEnvelope().save(outImg);
std::cout << "Saved volume envelope as "
<< QFileInfo(outImg).absoluteFilePath().toStdString()
<< std::endl;
outImg = QString("envelope-sub-%1.png")
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
envelopeSub.drawEnvelope().save(outImg);
envelopeSub->drawEnvelope().save(outImg);
std::cout << "Saved volume envelope as "
<< QFileInfo(outImg).absoluteFilePath().toStdString()
<< std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment