Merge branch 'master' of https://github.com/olive-editor/olive
This commit is contained in:
@@ -366,6 +366,8 @@ QString NodeInput::ValueToString(const DataType& data_type, const QVariant &valu
|
||||
|| data_type == kBuffer) {
|
||||
// These data types need no XML representation
|
||||
return QString();
|
||||
} else if (data_type == kInt) {
|
||||
return QString::number(value.value<int64_t>());
|
||||
} else {
|
||||
if (value.canConvert<QString>()) {
|
||||
return value.toString();
|
||||
@@ -397,6 +399,8 @@ QVariant NodeInput::StringToValue(const DataType& data_type, const QString &stri
|
||||
QStringList vals = string.split(':');
|
||||
|
||||
return QVariant::fromValue(Color(vals.at(0).toFloat(), vals.at(1).toFloat(), vals.at(2).toFloat(), vals.at(3).toFloat()));
|
||||
} else if (data_type == kInt) {
|
||||
return QVariant::fromValue(string.toLongLong());
|
||||
} else if (data_type == kRational) {
|
||||
return QVariant::fromValue(rational::fromString(string));
|
||||
} else {
|
||||
|
||||
@@ -275,23 +275,33 @@ void AudioMonitor::UpdateValuesFromFile(QVector<double>& v)
|
||||
// Determines how many milliseconds have passed since last update
|
||||
qint64 current_time = QDateTime::currentMSecsSinceEpoch();
|
||||
qint64 time_passed = current_time - last_time_;
|
||||
int abs_speed = qAbs(playback_speed_);
|
||||
|
||||
// Multiply by speed if the speed is not 1
|
||||
if (abs_speed != 1) {
|
||||
time_passed *= abs_speed;
|
||||
}
|
||||
|
||||
// Convert ms to float seconds and determine how many bytes that is
|
||||
qint64 bytes_to_read = params_.time_to_bytes(static_cast<double>(time_passed) * 0.001);
|
||||
|
||||
if (playback_speed_ < 0) {
|
||||
// If reversing, jump back by the amount of bytes we're going to read
|
||||
bytes_to_read = qMin(bytes_to_read, file_.pos());
|
||||
|
||||
file_.seek(file_.pos() - bytes_to_read);
|
||||
}
|
||||
|
||||
// Read bytes in from file
|
||||
QByteArray b = file_.read(bytes_to_read);
|
||||
|
||||
if (playback_speed_ < 0) {
|
||||
// If reversing, head back to where we were before the read so that the next read starts
|
||||
// from where we left off
|
||||
file_.seek(file_.pos() - bytes_to_read);
|
||||
}
|
||||
|
||||
int abs_speed = qAbs(playback_speed_);
|
||||
// If speed is not 1, transform it here
|
||||
if (abs_speed != 1) {
|
||||
int sample_sz = params_.samples_to_bytes(1);
|
||||
int in_nb_samples = params_.bytes_to_samples(b.size());
|
||||
@@ -299,8 +309,8 @@ void AudioMonitor::UpdateValuesFromFile(QVector<double>& v)
|
||||
QByteArray speed_adjusted(out_nb_samples * sample_sz, Qt::Uninitialized);
|
||||
|
||||
for (int i=0;i<out_nb_samples;i++) {
|
||||
memcpy(speed_adjusted.data() + params_.samples_to_bytes(i),
|
||||
b.constData() + params_.samples_to_bytes(i * abs_speed),
|
||||
memcpy(speed_adjusted.data() + i * sample_sz,
|
||||
b.constData() + i * abs_speed * sample_sz,
|
||||
sample_sz);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,10 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
|
||||
// Default to showing play button
|
||||
playpause_stack_->setCurrentWidget(play_btn_);
|
||||
playpause_stack_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
|
||||
// Hack to conform the play/pause button size to the other buttons (QStackedWidget has a
|
||||
// different size policy by default)
|
||||
playpause_stack_->setSizePolicy(prev_frame_btn_->sizePolicy());
|
||||
|
||||
// Next Frame Button
|
||||
next_frame_btn_ = new QPushButton();
|
||||
|
||||
Reference in New Issue
Block a user