sequence encapsulation

This commit is contained in:
itsmattkc
2019-05-09 00:19:36 +10:00
parent 5f0debb7ec
commit 2905dce3d9
37 changed files with 380 additions and 293 deletions
+1 -1
View File
@@ -92,7 +92,7 @@ ClipPropertiesDialog::ClipPropertiesDialog(QWidget *parent, QVector<Clip *> clip
}
// it's assumed all the clips come from the same sequence
duration_field_->SetFrameRate(first_clip->track()->sequence()->frame_rate);
duration_field_->SetFrameRate(first_clip->track()->sequence()->frame_rate());
if (all_clips_have_same_duration) {
duration_field_->SetDefault(first_clip->length());
+6 -6
View File
@@ -72,7 +72,7 @@ ExportDialog::ExportDialog(QWidget *parent, Sequence* sequence) :
QDialog(parent),
sequence_(sequence)
{
setWindowTitle(tr("Export \"%1\"").arg(sequence->name));
setWindowTitle(tr("Export \"%1\"").arg(sequence->name()));
setup_ui();
rangeCombobox->setCurrentIndex(0);
@@ -110,10 +110,10 @@ ExportDialog::ExportDialog(QWidget *parent, Sequence* sequence) :
formatCombobox->setCurrentIndex(FORMAT_MPEG4);
// default to sequence's native dimensions
widthSpinbox->setValue(sequence->width);
heightSpinbox->setValue(sequence->height);
samplingRateSpinbox->setValue(sequence->audio_frequency);
framerateSpinbox->setValue(sequence->frame_rate);
widthSpinbox->setValue(sequence->width());
heightSpinbox->setValue(sequence->height());
samplingRateSpinbox->setValue(sequence->audio_frequency());
framerateSpinbox->setValue(sequence->frame_rate());
// set some advanced defaults
vcodec_params.threads = 0;
@@ -656,7 +656,7 @@ void ExportDialog::comp_type_changed(int) {
case COMPRESSION_TYPE_CBR:
case COMPRESSION_TYPE_TARGETBR:
videoBitrateLabel->setText(tr("Bitrate (Mbps):"));
videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence_->height) - 4.5)));
videobitrateSpinbox->setValue(qMax(0.5, (double) qRound((0.01528 * sequence_->height()) - 4.5)));
break;
case COMPRESSION_TYPE_CFR:
videoBitrateLabel->setText(tr("Quality (CRF):"));
+19 -19
View File
@@ -59,20 +59,20 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing, Sequence*
}
if (existing_sequence != nullptr) {
setWindowTitle(tr("Editing \"%1\"").arg(existing_sequence->name));
setWindowTitle(tr("Editing \"%1\"").arg(existing_sequence->name()));
width_numeric->setValue(existing_sequence->width);
height_numeric->setValue(existing_sequence->height);
int comp_rate = qRound(existing_sequence->frame_rate*100);
width_numeric->setValue(existing_sequence->width());
height_numeric->setValue(existing_sequence->height());
int comp_rate = qRound(existing_sequence->frame_rate()*100);
for (int i=0;i<frame_rate_combobox->count();i++) {
if (qRound(frame_rate_combobox->itemData(i).toDouble()*100) == comp_rate) {
frame_rate_combobox->setCurrentIndex(i);
break;
}
}
sequence_name_edit->setText(existing_sequence->name);
sequence_name_edit->setText(existing_sequence->name());
for (int i=0;i<audio_frequency_combobox->count();i++) {
if (audio_frequency_combobox->itemData(i) == existing_sequence->audio_frequency) {
if (audio_frequency_combobox->itemData(i) == existing_sequence->audio_frequency()) {
audio_frequency_combobox->setCurrentIndex(i);
break;
}
@@ -100,12 +100,12 @@ void NewSequenceDialog::accept() {
SequencePtr s = std::make_shared<Sequence>();
s->name = sequence_name_edit->text();
s->width = width_numeric->value();
s->height = height_numeric->value();
s->frame_rate = frame_rate_combobox->currentData().toDouble();
s->audio_frequency = audio_frequency_combobox->currentData().toInt();
s->audio_layout = AV_CH_LAYOUT_STEREO;
s->set_name(sequence_name_edit->text());
s->set_width(width_numeric->value());
s->set_height(height_numeric->value());
s->set_frame_rate(frame_rate_combobox->currentData().toDouble());
s->set_audio_frequency(audio_frequency_combobox->currentData().toInt());
s->set_audio_layout(AV_CH_LAYOUT_STEREO);
ComboAction* ca = new ComboAction();
olive::project_model.CreateSequence(ca, s, true, nullptr);
@@ -117,7 +117,7 @@ void NewSequenceDialog::accept() {
ComboAction* ca = new ComboAction();
double multiplier = frame_rate_combobox->currentData().toDouble() / existing_sequence->frame_rate;
double multiplier = frame_rate_combobox->currentData().toDouble() / existing_sequence->frame_rate();
EditSequenceCommand* esc = new EditSequenceCommand(existing_item, existing_item->to_sequence());
esc->name = sequence_name_edit->text();
@@ -139,12 +139,12 @@ void NewSequenceDialog::accept() {
// This dialog was given an existing Sequence without a Media wrapper - therefore just directly apply the settings
existing_sequence->name = sequence_name_edit->text();
existing_sequence->width = width_numeric->value();
existing_sequence->height = height_numeric->value();
existing_sequence->frame_rate = frame_rate_combobox->currentData().toDouble();
existing_sequence->audio_frequency = audio_frequency_combobox->currentData().toInt();
existing_sequence->audio_layout = AV_CH_LAYOUT_STEREO;
existing_sequence->set_name(sequence_name_edit->text());
existing_sequence->set_width(width_numeric->value());
existing_sequence->set_height(height_numeric->value());
existing_sequence->set_frame_rate(frame_rate_combobox->currentData().toDouble());
existing_sequence->set_audio_frequency(audio_frequency_combobox->currentData().toInt());
existing_sequence->set_audio_layout(AV_CH_LAYOUT_STEREO);
}
+11 -11
View File
@@ -89,12 +89,12 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :
setup_kbd_shortcuts(olive::MainWindow->menuBar());
// set up default sequence
default_sequence.name = tr("Default Sequence");
default_sequence.width = olive::config.default_sequence_width;
default_sequence.height = olive::config.default_sequence_height;
default_sequence.frame_rate = olive::config.default_sequence_framerate;
default_sequence.audio_frequency = olive::config.default_sequence_audio_frequency;
default_sequence.audio_layout = olive::config.default_sequence_audio_channel_layout;
default_sequence.set_name(tr("Default Sequence"));
default_sequence.set_width(olive::config.default_sequence_width);
default_sequence.set_height(olive::config.default_sequence_height);
default_sequence.set_frame_rate(olive::config.default_sequence_framerate);
default_sequence.set_audio_frequency(olive::config.default_sequence_audio_frequency);
default_sequence.set_audio_layout(olive::config.default_sequence_audio_channel_layout);
}
void PreferencesDialog::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent) {
@@ -460,11 +460,11 @@ void PreferencesDialog::accept() {
// Set default sequence options
olive::config.default_sequence_width = default_sequence.width;
olive::config.default_sequence_height = default_sequence.height;
olive::config.default_sequence_framerate = default_sequence.frame_rate;
olive::config.default_sequence_audio_frequency = default_sequence.audio_frequency;
olive::config.default_sequence_audio_channel_layout = default_sequence.audio_layout;
olive::config.default_sequence_width = default_sequence.width();
olive::config.default_sequence_height = default_sequence.height();
olive::config.default_sequence_framerate = default_sequence.frame_rate();
olive::config.default_sequence_audio_frequency = default_sequence.audio_frequency();
olive::config.default_sequence_audio_channel_layout = default_sequence.audio_layout();
// Set all bool options
for (int i=0;i<bool_ui.size();i++) {
+1 -1
View File
@@ -61,7 +61,7 @@ SpeedDialog::SpeedDialog(QWidget *parent, QVector<Clip*> clips) : QDialog(parent
grid->addWidget(new QLabel(tr("Duration:"), this), 2, 0);
duration = new LabelSlider(this);
duration->SetDisplayType(LabelSlider::FrameNumber);
duration->SetFrameRate(clips_.first()->track()->sequence()->frame_rate);
duration->SetFrameRate(clips_.first()->track()->sequence()->frame_rate());
grid->addWidget(duration, 2, 1);
main_layout->addLayout(grid);
+2 -2
View File
@@ -297,11 +297,11 @@ double EffectField::GetValidKeyframeHandlePosition(int key, bool post) {
}
double EffectField::FrameToSeconds(long frame) {
return (double(frame) / GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate);
return (double(frame) / GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate());
}
long EffectField::SecondsToFrame(double seconds) {
return qRound(seconds * GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate);
return qRound(seconds * GetParentRow()->GetParentEffect()->parent_clip->track()->sequence()->frame_rate());
}
void EffectField::GetKeyframeData(double timecode, int &before, int &after, double &progress) {
+1 -1
View File
@@ -116,7 +116,7 @@ void TimecodeEffect::redraw(double timecode) {
if (tc_select->GetValueAt(timecode).toBool()) {
display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(sequence->playhead,
olive::config.timecode_view,
sequence->frame_rate);
sequence->frame_rate());
} else {
double media_rate = parent_clip->media_frame_rate();
display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(qRound(timecode * media_rate),
+1 -1
View File
@@ -90,7 +90,7 @@ void ToneEffect::process_audio(double timecode_start,
double timecode = timecode_start+(interval*i);
float tone_sample = qSin((2*M_PI*sinX*freq_val->GetDoubleAt(timecode))
/parent_clip->track()->sequence()->audio_frequency)
/parent_clip->track()->sequence()->audio_frequency())
*log_volume(amount_val->GetDoubleAt(timecode)*0.01);
for (int j=0;j<channel_count;j++) {
+6 -6
View File
@@ -163,11 +163,11 @@ OldEffectNodePtr TransformEffect::Create(Clip *c)
void TransformEffect::refresh() {
if (parent_clip != nullptr && parent_clip->track()->sequence() != nullptr) {
position->SetDefault({parent_clip->track()->sequence()->width*0.5,
parent_clip->track()->sequence()->height*0.5});
position->SetDefault({parent_clip->track()->sequence()->width()*0.5,
parent_clip->track()->sequence()->height()*0.5});
double x_percent_multipler = 200.0 / parent_clip->track()->sequence()->width;
double y_percent_multipler = 200.0 / parent_clip->track()->sequence()->height;
double x_percent_multipler = 200.0 / parent_clip->track()->sequence()->width();
double y_percent_multipler = 200.0 / parent_clip->track()->sequence()->height();
top_left_gizmo->x_field_multi1 = -x_percent_multipler;
top_left_gizmo->y_field_multi1 = -y_percent_multipler;
@@ -203,8 +203,8 @@ void TransformEffect::toggle_uniform_scale(bool enabled) {
void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int) {
// position
coords.matrix.translate(position->GetVector2DAt(timecode)
- QVector2D(parent_clip->track()->sequence()->width*0.5f,
parent_clip->track()->sequence()->height*0.5f));
- QVector2D(parent_clip->track()->sequence()->width()*0.5f,
parent_clip->track()->sequence()->height()*0.5f));
// anchor point
QVector2D anchor_val = anchor_point->GetVector2DAt(timecode);
+1 -1
View File
@@ -51,7 +51,7 @@ Transition::Transition(Clip *c) :
if (parent_clip != nullptr) {
length_field->SetFrameRate(parent_clip->track()->sequence() == nullptr ?
parent_clip->cached_frame_rate() : parent_clip->track()->sequence()->frame_rate);
parent_clip->cached_frame_rate() : parent_clip->track()->sequence()->frame_rate());
}
connect(length_field, SIGNAL(Changed()), this, SLOT(UpdateMaximumLength()));
+3 -3
View File
@@ -340,9 +340,9 @@ void OliveGlobal::PasteInternal(Sequence *s, bool insert)
ClipPtr cc = c->copy(s->GetTrackList(c->track()->type()).at(c->track()->Index()));
// convert frame rates
cc->set_timeline_in(rescale_frame_number(cc->timeline_in(), c->cached_frame_rate(), s->frame_rate));
cc->set_timeline_out(rescale_frame_number(cc->timeline_out(), c->cached_frame_rate(), s->frame_rate));
cc->set_clip_in(rescale_frame_number(cc->clip_in(), c->cached_frame_rate(), s->frame_rate));
cc->set_timeline_in(rescale_frame_number(cc->timeline_in(), c->cached_frame_rate(), s->frame_rate()));
cc->set_timeline_out(rescale_frame_number(cc->timeline_out(), c->cached_frame_rate(), s->frame_rate()));
cc->set_clip_in(rescale_frame_number(cc->clip_in(), c->cached_frame_rate(), s->frame_rate()));
cc->set_timeline_in(cc->timeline_in() + s->playhead);
cc->set_timeline_out(cc->timeline_out() + s->playhead);
+2 -2
View File
@@ -5,7 +5,7 @@
#include "global/config.h"
double get_timecode(Clip* c, long playhead) {
return double(playhead_to_clip_frame(c, playhead))/c->track()->sequence()->frame_rate;
return double(playhead_to_clip_frame(c, playhead))/c->track()->sequence()->frame_rate();
}
long rescale_frame_number(long framenumber, double source_frame_rate, double target_frame_rate) {
@@ -24,7 +24,7 @@ double playhead_to_clip_seconds(Clip* c, long playhead) {
clip_frame = c->media_length() - clip_frame - 1;
}
double secs = (double(clip_frame)/c->track()->sequence()->frame_rate)*c->speed().value;
double secs = (double(clip_frame)/c->track()->sequence()->frame_rate())*c->speed().value;
if (c->media() != nullptr && c->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
secs *= c->media()->to_footage()->speed;
}
+6
View File
@@ -8,6 +8,12 @@ NodeGraph::NodeGraph() :
}
void NodeGraph::AddNode(NodePtr node)
{
nodes_.append(node);
emit NodeGraphChanged();
}
Node *NodeGraph::OutputNode()
{
return output_node_.get();
+6 -1
View File
@@ -2,11 +2,13 @@
#define NODEGRAPH_H
#include <QVector>
#include <QObject>
#include "nodes/node.h"
class NodeGraph
class NodeGraph : public QObject
{
Q_OBJECT
public:
NodeGraph();
@@ -48,6 +50,9 @@ public:
*/
Node* OutputNode();
signals:
void NodeGraphChanged();
private:
NodePtr output_node_;
+3 -3
View File
@@ -811,10 +811,10 @@ void OldEffectNode::gizmo_world_to_screen(const QMatrix4x4& matrix, const QMatri
projection,
QRect(0,
0,
parent_clip->track()->sequence()->width,
parent_clip->track()->sequence()->height));
parent_clip->track()->sequence()->width(),
parent_clip->track()->sequence()->height()));
g->screen_pos[j] = QPoint(screen_pos.x(), parent_clip->track()->sequence()->height-screen_pos.y());
g->screen_pos[j] = QPoint(screen_pos.x(), parent_clip->track()->sequence()->height() - screen_pos.y());
}
}
+1 -1
View File
@@ -391,7 +391,7 @@ void Project::delete_selected_media() {
// we found a reference, so we know we'll need to ask if the user wants to delete it
QMessageBox confirm(this);
confirm.setWindowTitle(tr("Delete media in use?"));
confirm.setText(tr("The media '%1' is currently used in '%2'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?").arg(media->name, s->name));
confirm.setText(tr("The media '%1' is currently used in '%2'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?").arg(media->name, s->name()));
QAbstractButton* yes_button = confirm.addButton(QMessageBox::Yes);
QAbstractButton* skip_button = nullptr;
if (items.size() > 1) skip_button = confirm.addButton(tr("Skip"), QMessageBox::NoRole);
+11 -13
View File
@@ -326,12 +326,12 @@ void Timeline::nest() {
// create "nest" sequence with the same attributes as the current sequence
SequencePtr s = std::make_shared<Sequence>();
s->name = olive::project_model.GetNextSequenceName(tr("Nested Sequence"));
s->width = sequence_->width;
s->height = sequence_->height;
s->frame_rate = sequence_->frame_rate;
s->audio_frequency = sequence_->audio_frequency;
s->audio_layout = sequence_->audio_layout;
s->set_name(olive::project_model.GetNextSequenceName(tr("Nested Sequence")));
s->set_width(sequence_->width());
s->set_height(sequence_->height());
s->set_frame_rate(sequence_->frame_rate());
s->set_audio_frequency(sequence_->audio_frequency());
s->set_audio_layout(sequence_->audio_layout());
QVector<ClipPtr> new_clips;
@@ -919,13 +919,11 @@ void Timeline::set_sb_max() {
}
void Timeline::UpdateTitle() {
QString title = tr("Timeline: ");
if (sequence_ == nullptr) {
setWindowTitle(title + tr("(none)"));
} else {
setWindowTitle(title + sequence_->name);
update_ui(false);
}
setWindowTitle(
tr("Timeline: %1").arg(
(sequence_ == nullptr) ? tr("(none)") : sequence_->name()
)
);
}
void Timeline::setup_ui() {
+19 -25
View File
@@ -146,7 +146,7 @@ void Viewer::reset_all_audio() {
if (playback_speed < 0) {
audio_ibuffer_frame = last_frame - audio_ibuffer_frame;
}
audio_ibuffer_timecode = double(audio_ibuffer_frame) / seq->frame_rate;
audio_ibuffer_timecode = double(audio_ibuffer_frame) / seq->frame_rate();
}
clear_audio_ibuffer();
}
@@ -359,7 +359,7 @@ void Viewer::pause() {
c->set_media(m, 0); // latest media
c->set_timeline_in(recording_start);
c->set_timeline_out(recording_start + f->get_length_in_frames(seq->frame_rate));
c->set_timeline_out(recording_start + f->get_length_in_frames(seq->frame_rate()));
c->set_clip_in(0);
c->set_color(128, 192, 128);
c->set_name(m->get_name());
@@ -381,7 +381,7 @@ void Viewer::update_playhead_timecode(long p) {
}
void Viewer::update_end_timecode() {
end_timecode->setText((seq == nullptr) ? frame_to_timecode(0, olive::config.timecode_view, 30) : frame_to_timecode(seq->GetEndFrame(), olive::config.timecode_view, seq->frame_rate));
end_timecode->setText((seq == nullptr) ? frame_to_timecode(0, olive::config.timecode_view, 30) : frame_to_timecode(seq->GetEndFrame(), olive::config.timecode_view, seq->frame_rate()));
}
void Viewer::update_header_zoom() {
@@ -546,13 +546,7 @@ void Viewer::show_videoaudio_buttons(bool s)
}
void Viewer::update_window_title() {
QString name;
if (seq == nullptr) {
name = tr("(none)");
} else {
name = seq->name;
}
setWindowTitle(QString("%1: %2").arg(panel_name, name));
setWindowTitle(panel_name.arg((seq == nullptr) ? tr("(none)") : seq->name()));
}
void Viewer::set_zoom_value(double d) {
@@ -734,7 +728,7 @@ void Viewer::set_media(Media* m) {
new_sequence = std::make_shared<Sequence>();
created_sequence = true;
new_sequence->wrapper_sequence = true;
new_sequence->name = footage->name;
new_sequence->set_name(footage->name);
new_sequence->using_workarea = footage->using_inout;
if (footage->using_inout) {
@@ -742,14 +736,14 @@ void Viewer::set_media(Media* m) {
new_sequence->workarea_out = footage->out;
}
new_sequence->frame_rate = olive::config.default_sequence_framerate;
new_sequence->set_frame_rate(olive::config.default_sequence_framerate);
if (footage->video_tracks.size() > 0) {
const FootageStream& video_stream = footage->video_tracks.at(0);
new_sequence->width = video_stream.video_width;
new_sequence->height = video_stream.video_height;
new_sequence->set_width(video_stream.video_width);
new_sequence->set_height(video_stream.video_height);
if (video_stream.video_frame_rate > 0 && !video_stream.infinite_length) {
new_sequence->frame_rate = video_stream.video_frame_rate * footage->speed;
new_sequence->set_frame_rate(video_stream.video_frame_rate * footage->speed);
}
Track* first_track = new_sequence->GetTrackList(olive::kTypeVideo).first();
@@ -757,7 +751,7 @@ void Viewer::set_media(Media* m) {
ClipPtr c = std::make_shared<Clip>(first_track);
c->set_media(media, video_stream.file_index);
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate));
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate()));
if (c->timeline_out() <= 0) {
// FIXME: Move this magic number to Config
c->set_timeline_out(150);
@@ -767,19 +761,19 @@ void Viewer::set_media(Media* m) {
c->refresh();
first_track->AddClip(c);
} else {
new_sequence->width = olive::config.default_sequence_width;
new_sequence->height = olive::config.default_sequence_height;
new_sequence->set_width(olive::config.default_sequence_width);
new_sequence->set_height(olive::config.default_sequence_height);
}
if (footage->audio_tracks.size() > 0) {
const FootageStream& audio_stream = footage->audio_tracks.at(0);
new_sequence->audio_frequency = audio_stream.audio_frequency;
new_sequence->set_audio_frequency(audio_stream.audio_frequency);
Track* track = new_sequence->GetTrackList(olive::kTypeAudio).first();
ClipPtr c = std::make_shared<Clip>(track);
c->set_media(media, audio_stream.file_index);
c->set_timeline_in(0);
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate));
c->set_timeline_out(footage->get_length_in_frames(new_sequence->frame_rate()));
c->set_clip_in(0);
c->refresh();
track->AddClip(c);
@@ -791,10 +785,10 @@ void Viewer::set_media(Media* m) {
viewer_widget_->frame_update();
}
} else {
new_sequence->audio_frequency = olive::config.default_sequence_audio_frequency;
new_sequence->set_audio_frequency(olive::config.default_sequence_audio_frequency);
}
new_sequence->audio_layout = AV_CH_LAYOUT_STEREO;
new_sequence->set_audio_layout(AV_CH_LAYOUT_STEREO);
}
break;
case MEDIA_TYPE_SEQUENCE:
@@ -813,7 +807,7 @@ void Viewer::update_playhead() {
void Viewer::timer_update() {
previous_playhead = seq->playhead;
seq->playhead = qMax(0, qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate * playback_speed)));
seq->playhead = qMax(0, qRound(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * seq->frame_rate() * playback_speed)));
if (olive::config.seek_also_selects) {
seq->SelectAtPlayhead();
@@ -918,9 +912,9 @@ void Viewer::set_sequence(SequencePtr s) {
audio_only_button->setEnabled(!null_sequence);
if (!null_sequence) {
current_timecode_slider->SetFrameRate(seq->frame_rate);
current_timecode_slider->SetFrameRate(seq->frame_rate());
playback_updater.setInterval(qFloor(1000 / seq->frame_rate));
playback_updater.setInterval(qFloor(1000 / seq->frame_rate()));
update_playhead_timecode(seq->playhead);
update_end_timecode();
+6 -6
View File
@@ -404,22 +404,22 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
for (int j=0;j<stream.attributes().size();j++) {
const QXmlStreamAttribute& attr = stream.attributes().at(j);
if (attr.name() == "name") {
s->name = attr.value().toString();
s->set_name(attr.value().toString());
} else if (attr.name() == "folder") {
int folder = attr.value().toInt();
if (folder > 0) parent = find_loaded_folder_by_id(folder);
} else if (attr.name() == "id") {
s->save_id = attr.value().toInt();
} else if (attr.name() == "width") {
s->width = attr.value().toInt();
s->set_width(attr.value().toInt());
} else if (attr.name() == "height") {
s->height = attr.value().toInt();
s->set_height(attr.value().toInt());
} else if (attr.name() == "framerate") {
s->frame_rate = attr.value().toDouble();
s->set_frame_rate(attr.value().toDouble());
} else if (attr.name() == "afreq") {
s->audio_frequency = attr.value().toInt();
s->set_audio_frequency(attr.value().toInt());
} else if (attr.name() == "alayout") {
s->audio_layout = attr.value().toInt();
s->set_audio_layout(attr.value().toInt());
} else if (attr.name() == "open") {
open_seq = s;
} else if (attr.name() == "workarea") {
+11 -11
View File
@@ -189,12 +189,12 @@ void Media::update_tooltip(const QString& error) {
"\nFrame Rate: %4"
"\nAudio Frequency: %5"
"\nAudio Layout: %6").arg(
s->name,
QString::number(s->width),
QString::number(s->height),
QString::number(s->frame_rate),
QString::number(s->audio_frequency),
Footage::get_channel_layout_name(av_get_channel_layout_nb_channels(s->audio_layout), s->audio_layout)
s->name(),
QString::number(s->width()),
QString::number(s->height()),
QString::number(s->frame_rate()),
QString::number(s->audio_frequency()),
Footage::get_channel_layout_name(av_get_channel_layout_nb_channels(s->audio_layout()), s->audio_layout())
);
}
break;
@@ -213,7 +213,7 @@ int Media::get_type() {
const QString &Media::get_name() {
switch (type) {
case MEDIA_TYPE_FOOTAGE: return to_footage()->name;
case MEDIA_TYPE_SEQUENCE: return to_sequence()->name;
case MEDIA_TYPE_SEQUENCE: return to_sequence()->name();
default: return folder_name;
}
}
@@ -221,7 +221,7 @@ const QString &Media::get_name() {
void Media::set_name(const QString &n) {
switch (type) {
case MEDIA_TYPE_FOOTAGE: to_footage()->name = n; break;
case MEDIA_TYPE_SEQUENCE: to_sequence()->name = n; break;
case MEDIA_TYPE_SEQUENCE: to_sequence()->set_name(n); break;
case MEDIA_TYPE_FOLDER: folder_name = n; break;
}
}
@@ -239,7 +239,7 @@ double Media::get_frame_rate(int stream) {
if (stream < 0) return f->video_tracks.at(0).video_frame_rate * f->speed;
return f->get_stream_from_file_index(true, stream)->video_frame_rate * f->speed;
}
case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate;
case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate();
}
return 0;
}
@@ -252,7 +252,7 @@ int Media::get_sampling_rate(int stream) {
if (stream < 0) return f->audio_tracks.at(0).audio_frequency * f->speed;
return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency * f->speed;
}
case MEDIA_TYPE_SEQUENCE: return to_sequence()->audio_frequency;
case MEDIA_TYPE_SEQUENCE: return to_sequence()->audio_frequency();
}
return 0;
}
@@ -288,7 +288,7 @@ int Media::columnCount() const {
QString Media::GetStringDuration() {
if (get_type() == MEDIA_TYPE_SEQUENCE) {
Sequence* s = to_sequence().get();
return frame_to_timecode(s->GetEndFrame(), olive::config.timecode_view, s->frame_rate);
return frame_to_timecode(s->GetEndFrame(), olive::config.timecode_view, s->frame_rate());
}
if (get_type() == MEDIA_TYPE_FOOTAGE) {
Footage* f = to_footage();
+16 -16
View File
@@ -18,14 +18,14 @@ SequencePtr olive::project::CreateSequenceFromMedia(QVector<olive::timeline::Med
{
SequencePtr s = std::make_shared<Sequence>();
s->name = olive::project_model.GetNextSequenceName();
s->set_name(olive::project_model.GetNextSequenceName());
// Retrieve default Sequence settings from Config
s->width = olive::config.default_sequence_width;
s->height = olive::config.default_sequence_height;
s->frame_rate = olive::config.default_sequence_framerate;
s->audio_frequency = olive::config.default_sequence_audio_frequency;
s->audio_layout = olive::config.default_sequence_audio_channel_layout;
s->set_width(olive::config.default_sequence_width);
s->set_height(olive::config.default_sequence_height);
s->set_frame_rate(olive::config.default_sequence_framerate);
s->set_audio_frequency(olive::config.default_sequence_audio_frequency);
s->set_audio_layout(olive::config.default_sequence_audio_channel_layout);
bool got_video_values = false;
bool got_audio_values = false;
@@ -39,12 +39,12 @@ SequencePtr olive::project::CreateSequenceFromMedia(QVector<olive::timeline::Med
if (!got_video_values) {
for (int j=0;j<m->video_tracks.size();j++) {
const FootageStream& ms = m->video_tracks.at(j);
s->width = ms.video_width;
s->height = ms.video_height;
s->set_width(ms.video_width);
s->set_height(ms.video_height);
if (!qFuzzyCompare(ms.video_frame_rate, 0.0)) {
s->frame_rate = ms.video_frame_rate * m->speed;
s->set_frame_rate(ms.video_frame_rate * m->speed);
if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2;
if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->set_frame_rate(s->frame_rate() * 2);
// only break with a decent frame rate, otherwise there may be a better candidate
got_video_values = true;
@@ -54,7 +54,7 @@ SequencePtr olive::project::CreateSequenceFromMedia(QVector<olive::timeline::Med
}
if (!got_audio_values && m->audio_tracks.size() > 0) {
const FootageStream& ms = m->audio_tracks.at(0);
s->audio_frequency = ms.audio_frequency;
s->set_audio_frequency(ms.audio_frequency);
got_audio_values = true;
}
}
@@ -65,11 +65,11 @@ SequencePtr olive::project::CreateSequenceFromMedia(QVector<olive::timeline::Med
// Clone all attributes of the original sequence (seq) into the new one (s)
Sequence* seq = media->to_sequence().get();
s->width = seq->width;
s->height = seq->height;
s->frame_rate = seq->frame_rate;
s->audio_frequency = seq->audio_frequency;
s->audio_layout = seq->audio_layout;
s->set_width(seq->width());
s->set_height(seq->height());
s->set_frame_rate(seq->frame_rate());
s->set_audio_frequency(seq->audio_frequency());
s->set_audio_layout(seq->audio_layout());
got_video_values = true;
got_audio_values = true;
+16 -16
View File
@@ -69,8 +69,8 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
}
if (clip->opening_transition != nullptr) {
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
double transition_start = (clip->clip_in(true) / clip->track()->sequence()->frame_rate);
double transition_end = (clip->clip_in(true) + clip->opening_transition->get_length()) / clip->track()->sequence()->frame_rate;
double transition_start = (clip->clip_in(true) / clip->track()->sequence()->frame_rate());
double transition_end = (clip->clip_in(true) + clip->opening_transition->get_length()) / clip->track()->sequence()->frame_rate();
if (timecode_end < transition_end) {
double adjustment = transition_end - transition_start;
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
@@ -82,8 +82,8 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
if (clip->closing_transition != nullptr) {
if (clip->media() != nullptr && clip->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
long length_with_transitions = clip->timeline_out(true) - clip->timeline_in(true);
double transition_start = (clip->clip_in(true) + length_with_transitions - clip->closing_transition->get_length()) / clip->track()->sequence()->frame_rate;
double transition_end = (clip->clip_in(true) + length_with_transitions) / clip->track()->sequence()->frame_rate;
double transition_start = (clip->clip_in(true) + length_with_transitions - clip->closing_transition->get_length()) / clip->track()->sequence()->frame_rate();
double transition_end = (clip->clip_in(true) + length_with_transitions) / clip->track()->sequence()->frame_rate();
if (timecode_start > transition_start) {
double adjustment = transition_end - transition_start;
double adjusted_range_start = (timecode_start - transition_start) / adjustment;
@@ -97,7 +97,7 @@ void apply_audio_effects(Clip* clip, double timecode_start, AVFrame* frame, int
Clip* next_nest = nests.last();
nests.removeLast();
apply_audio_effects(next_nest,
timecode_start + (double(clip->timeline_in(true)-clip->clip_in(true))/clip->track()->sequence()->frame_rate),
timecode_start + (double(clip->timeline_in(true)-clip->clip_in(true))/clip->track()->sequence()->frame_rate()),
frame,
nb_samples,
nb_channels,
@@ -127,16 +127,16 @@ void Cacher::CacheAudioWorker() {
bool reverse_audio = IsReversed();
long frame_skip = 0;
double last_fr = clip->track()->sequence()->frame_rate;
double last_fr = clip->track()->sequence()->frame_rate();
if (!nests_.isEmpty()) {
for (int i=nests_.size()-1;i>=0;i--) {
timeline_in = rescale_frame_number(timeline_in, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
timeline_out = rescale_frame_number(timeline_out, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
target_frame = rescale_frame_number(target_frame, last_fr, nests_.at(i)->track()->sequence()->frame_rate) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
timeline_in = rescale_frame_number(timeline_in, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
timeline_out = rescale_frame_number(timeline_out, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
target_frame = rescale_frame_number(target_frame, last_fr, nests_.at(i)->track()->sequence()->frame_rate()) + nests_.at(i)->timeline_in(true) - nests_.at(i)->clip_in(true);
timeline_out = qMin(timeline_out, nests_.at(i)->timeline_out(true));
frame_skip = rescale_frame_number(frame_skip, last_fr, nests_.at(i)->track()->sequence()->frame_rate);
frame_skip = rescale_frame_number(frame_skip, last_fr, nests_.at(i)->track()->sequence()->frame_rate());
long validator = nests_.at(i)->timeline_in(true) - timeline_in;
if (validator > 0) {
@@ -144,7 +144,7 @@ void Cacher::CacheAudioWorker() {
//timeline_in = nests_.at(i)->timeline_in(true);
}
last_fr = nests_.at(i)->track()->sequence()->frame_rate;
last_fr = nests_.at(i)->track()->sequence()->frame_rate();
}
}
@@ -405,7 +405,7 @@ void Cacher::CacheAudioWorker() {
apply_audio_effects(clip,
samples_to_seconds(audio_buffer_write, 2, current_audio_freq())
+ audio_ibuffer_timecode
+ (double(clip->clip_in(true))/clip->track()->sequence()->frame_rate)
+ (double(clip->clip_in(true))/clip->track()->sequence()->frame_rate())
- (double(timeline_in)/last_fr),
frame,
nb_samples,
@@ -418,7 +418,7 @@ void Cacher::CacheAudioWorker() {
if (frame->nb_samples == 0) {
break;
} else {
qint64 buffer_timeline_out = get_buffer_offset_from_frame(clip->track()->sequence()->frame_rate, timeline_out);
qint64 buffer_timeline_out = get_buffer_offset_from_frame(clip->track()->sequence()->frame_rate(), timeline_out);
audio_write_lock.lock();
@@ -882,7 +882,7 @@ void Cacher::OpenWorker() {
if (clip->type() == olive::kTypeAudio) {
frame_ = av_frame_alloc();
frame_->format = kDestSampleFmt;
frame_->channel_layout = clip->track()->sequence()->audio_layout;
frame_->channel_layout = clip->track()->sequence()->audio_layout();
frame_->channels = av_get_channel_layout_nb_channels(frame_->channel_layout);
frame_->sample_rate = current_audio_freq();
frame_->nb_samples = 2048;
@@ -1040,8 +1040,8 @@ void Cacher::OpenWorker() {
reverse_frame->format = kDestSampleFmt;
reverse_frame->nb_samples = current_audio_freq()*10;
reverse_frame->channel_layout = clip->track()->sequence()->audio_layout;
reverse_frame->channels = av_get_channel_layout_nb_channels(clip->track()->sequence()->audio_layout);
reverse_frame->channel_layout = clip->track()->sequence()->audio_layout();
reverse_frame->channels = av_get_channel_layout_nb_channels(clip->track()->sequence()->audio_layout());
av_frame_get_buffer(reverse_frame, 0);
queue_.append(reverse_frame);
+6 -6
View File
@@ -192,16 +192,16 @@ bool ExportThread::SetupVideo() {
video_frame = av_frame_alloc();
av_frame_make_writable(video_frame);
video_frame->format = AV_PIX_FMT_RGBA;
video_frame->width = params_.sequence->width;
video_frame->height = params_.sequence->height;
video_frame->width = params_.sequence->width();
video_frame->height = params_.sequence->height();
av_frame_get_buffer(video_frame, 0);
av_init_packet(&video_pkt);
// Set up conversion context
sws_ctx = sws_getContext(
params_.sequence->width,
params_.sequence->height,
params_.sequence->width(),
params_.sequence->height(),
AV_PIX_FMT_RGBA,
params_.video_width,
params_.video_height,
@@ -288,7 +288,7 @@ bool ExportThread::SetupAudio() {
acodec_ctx->channel_layout,
acodec_ctx->sample_fmt,
acodec_ctx->sample_rate,
params_.sequence->audio_layout,
params_.sequence->audio_layout(),
AV_SAMPLE_FMT_S16,
acodec_ctx->sample_rate,
0,
@@ -449,7 +449,7 @@ void ExportThread::Export()
}
// Get the current sequence playhead in seconds (used for timestamp calculations later on)
double timecode_secs = double(params_.sequence->playhead - params_.start_frame) / params_.sequence->frame_rate;
double timecode_secs = double(params_.sequence->playhead - params_.start_frame) / params_.sequence->frame_rate();
// If we're exporting video, construct an AVFrame in the destination codec's pixel format to convert the raw RGBA
// OpenGL buffer to
+8 -8
View File
@@ -236,7 +236,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
for (int i=0;i<params.nests.size();i++) {
s = params.nests.at(i)->media()->to_sequence().get();
playhead += params.nests.at(i)->clip_in(true) - params.nests.at(i)->timeline_in(true);
playhead = rescale_frame_number(playhead, params.nests.at(i)->track()->sequence()->frame_rate, s->frame_rate);
playhead = rescale_frame_number(playhead, params.nests.at(i)->track()->sequence()->frame_rate(), s->frame_rate());
}
if (params.type == olive::kTypeVideo && !params.nests.last()->fbo.isEmpty()) {
@@ -348,8 +348,8 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
params.ctx->functions()->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
int half_width = s->width/2;
int half_height = s->height/2;
int half_width = s->width()/2;
int half_height = s->height()/2;
projection.ortho(-half_width, half_width, -half_height, half_height, -1, 1);
}
@@ -540,10 +540,10 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
// Check whether the parent clip is auto-scaled
if (c->autoscaled()
&& (video_width != s->width
&& video_height != s->height)) {
float width_multiplier = float(s->width) / float(video_width);
float height_multiplier = float(s->height) / float(video_height);
&& (video_width != s->width()
&& video_height != s->height())) {
float width_multiplier = float(s->width()) / float(video_width);
float height_multiplier = float(s->height()) / float(video_height);
float scale_multiplier = qMin(width_multiplier, height_multiplier);
coords.matrix.scale(scale_multiplier, scale_multiplier);
@@ -563,7 +563,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams &params) {
if (textureID > 0) {
// set viewport to sequence size
params.ctx->functions()->glViewport(0, 0, s->width, s->height);
params.ctx->functions()->glViewport(0, 0, s->width(), s->height());
+8 -8
View File
@@ -76,29 +76,29 @@ void RenderThread::run() {
ctx->makeCurrent(&surface);
// if the sequence size has changed, we'll need to reinitialize the textures
if (seq->width != tex_width || seq->height != tex_height) {
if (seq->width() != tex_width || seq->height() != tex_height) {
delete_buffers();
// cache sequence values for future checks
tex_width = seq->width;
tex_height = seq->height;
tex_width = seq->width();
tex_height = seq->height();
}
// create any buffers that don't yet exist
if (!composite_buffer.IsCreated()) {
composite_buffer.Create(ctx, seq->width, seq->height);
composite_buffer.Create(ctx, seq->width(), seq->height());
}
if (!front_buffer_1.IsCreated()) {
front_buffer_1.Create(ctx, seq->width, seq->height);
front_buffer_1.Create(ctx, seq->width(), seq->height());
}
if (!front_buffer_2.IsCreated()) {
front_buffer_2.Create(ctx, seq->width, seq->height);
front_buffer_2.Create(ctx, seq->width(), seq->height());
}
if (!back_buffer_1.IsCreated()) {
back_buffer_1.Create(ctx, seq->width, seq->height);
back_buffer_1.Create(ctx, seq->width(), seq->height());
}
if (!back_buffer_2.IsCreated()) {
back_buffer_2.Create(ctx, seq->width, seq->height);
back_buffer_2.Create(ctx, seq->width(), seq->height());
}
// If there's no pipeline shader, create it now
+10 -10
View File
@@ -74,7 +74,7 @@ ClipPtr Clip::copy(Track* s) {
copy->effects.append(effects.at(i)->copy(copy.get()));
}
copy->set_cached_frame_rate((this->track_ == nullptr) ? cached_frame_rate() : this->track_->sequence()->frame_rate);
copy->set_cached_frame_rate((this->track_ == nullptr) ? cached_frame_rate() : this->track_->sequence()->frame_rate());
copy->refresh();
@@ -432,13 +432,13 @@ double Clip::media_frame_rate() {
double rate = media_->get_frame_rate(media_stream_index());
if (!qIsNaN(rate)) return rate;
}
if (track() != nullptr) return track()->sequence()->frame_rate;
if (track() != nullptr) return track()->sequence()->frame_rate();
return qSNaN();
}
long Clip::media_length() {
if (this->track() != nullptr) {
double fr = this->track()->sequence()->frame_rate;
double fr = this->track()->sequence()->frame_rate();
fr /= speed_.value;
@@ -459,7 +459,7 @@ long Clip::media_length() {
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media_->to_sequence().get();
return rescale_frame_number(s->GetEndFrame(), s->frame_rate, fr);
return rescale_frame_number(s->GetEndFrame(), s->frame_rate(), fr);
}
}
}
@@ -468,38 +468,38 @@ long Clip::media_length() {
}
int Clip::media_width() {
if (media_ == nullptr && track() != nullptr) return track()->sequence()->width;
if (media_ == nullptr && track() != nullptr) return track()->sequence()->width();
switch (media_->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
const FootageStream* ms = media_stream();
if (ms != nullptr) return ms->video_width;
if (track() != nullptr) return track()->sequence()->width;
if (track() != nullptr) return track()->sequence()->width();
break;
}
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media_->to_sequence().get();
return s->width;
return s->width();
}
}
return 0;
}
int Clip::media_height() {
if (media_ == nullptr && track() != nullptr) return track()->sequence()->height;
if (media_ == nullptr && track() != nullptr) return track()->sequence()->height();
switch (media_->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
const FootageStream* ms = media_stream();
if (ms != nullptr) return ms->video_height;
if (track() != nullptr) return track()->sequence()->height;
if (track() != nullptr) return track()->sequence()->height();
}
break;
case MEDIA_TYPE_SEQUENCE:
{
Sequence* s = media_->to_sequence().get();
return s->height;
return s->height();
}
}
return 0;
+79 -13
View File
@@ -39,12 +39,12 @@ Sequence::Sequence() :
SequencePtr Sequence::copy() {
SequencePtr s = std::make_shared<Sequence>();
s->name = QCoreApplication::translate("Sequence", "%1 (copy)").arg(name);
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
s->audio_frequency = audio_frequency;
s->audio_layout = audio_layout;
s->name_ = tr("%1 (copy)").arg(name_);
s->width_ = width_;
s->height_ = height_;
s->frame_rate_ = frame_rate_;
s->audio_frequency_ = audio_frequency_;
s->audio_layout_ = audio_layout_;
/* FIXME
// deep copy all of the sequence's clips
@@ -69,12 +69,12 @@ void Sequence::Save(QXmlStreamWriter &stream)
stream.writeStartElement("sequence");
stream.writeAttribute("id", QString::number(save_id));
stream.writeAttribute("name", name);
stream.writeAttribute("width", QString::number(width));
stream.writeAttribute("height", QString::number(height));
stream.writeAttribute("framerate", QString::number(frame_rate, 'f', 10));
stream.writeAttribute("afreq", QString::number(audio_frequency));
stream.writeAttribute("alayout", QString::number(audio_layout));
stream.writeAttribute("name", name_);
stream.writeAttribute("width", QString::number(width_));
stream.writeAttribute("height", QString::number(height_));
stream.writeAttribute("framerate", QString::number(frame_rate_, 'f', 10));
stream.writeAttribute("afreq", QString::number(audio_frequency_));
stream.writeAttribute("alayout", QString::number(audio_layout_));
if (this == Timeline::GetTopSequence().get()) {
stream.writeAttribute("open", "1");
}
@@ -98,6 +98,72 @@ void Sequence::Save(QXmlStreamWriter &stream)
stream.writeEndElement();
}
const QString &Sequence::name()
{
return name_;
}
void Sequence::set_name(const QString &s)
{
name_ = s;
emit SequenceParametersChanged();
}
const int &Sequence::width()
{
return width_;
}
const int &Sequence::height()
{
return height_;
}
void Sequence::set_width(const int& w)
{
width_ = w;
emit SequenceParametersChanged();
}
void Sequence::set_height(const int& h)
{
height_ = h;
emit SequenceParametersChanged();
}
const double &Sequence::frame_rate()
{
return frame_rate_;
}
void Sequence::set_frame_rate(const double& d)
{
frame_rate_ = d;
emit SequenceParametersChanged();
}
const int &Sequence::audio_frequency()
{
return audio_frequency_;
}
void Sequence::set_audio_frequency(const int& f)
{
audio_frequency_ = f;
emit SequenceParametersChanged();
}
const int &Sequence::audio_layout()
{
return audio_layout_;
}
void Sequence::set_audio_layout(const int& l)
{
audio_layout_ = l;
emit SequenceParametersChanged();
}
long Sequence::GetEndFrame() {
long end_frame = 0;
@@ -203,7 +269,7 @@ void Sequence::AddClipsFromGhosts(ComboAction* ca, const QVector<Ghost>& ghosts)
// sequence (red?ish?)
c->set_color(192, 128, 128);
c->set_name(c->media()->to_sequence()->name);
c->set_name(c->media()->to_sequence()->name());
}
c->refresh();
added_clips.append(c);
+25 -7
View File
@@ -37,12 +37,23 @@ public:
void Save(QXmlStreamWriter& stream);
QString name;
int width;
int height;
double frame_rate;
int audio_frequency;
int audio_layout;
const QString& name();
void set_name(const QString& s);
const int& width();
void set_width(const int& w);
const int& height();
void set_height(const int& h);
const double& frame_rate();
void set_frame_rate(const double& d);
const int& audio_frequency();
void set_audio_frequency(const int& f);
const int& audio_layout();
void set_audio_layout(const int& l);
long GetEndFrame();
QVector<Clip*> GetAllClips();
@@ -126,13 +137,20 @@ public:
QVector<Marker> markers;
signals:
void Changed();
void SequenceParametersChanged();
private:
QVector<Track*> tracks_;
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame);
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame, long post_in);
bool SplitSelection(ComboAction* ca, QVector<Selection> selections);
QString name_;
int width_;
int height_;
double frame_rate_;
int audio_frequency_;
int audio_layout_;
};
using SequencePtr = std::shared_ptr<Sequence>;
+6 -6
View File
@@ -75,18 +75,18 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) {
source_fr = m->video_tracks.at(0).video_frame_rate * m->speed;
}
default_clip_in = rescale_frame_number(m->in, source_fr, seq->frame_rate);
default_clip_out = rescale_frame_number(m->out, source_fr, seq->frame_rate);
default_clip_in = rescale_frame_number(m->in, source_fr, seq->frame_rate());
default_clip_out = rescale_frame_number(m->out, source_fr, seq->frame_rate());
}
break;
case MEDIA_TYPE_SEQUENCE:
s = medium->to_sequence().get();
sequence_length = s->GetEndFrame();
if (seq != nullptr) sequence_length = rescale_frame_number(sequence_length, s->frame_rate, seq->frame_rate);
if (seq != nullptr) sequence_length = rescale_frame_number(sequence_length, s->frame_rate(), seq->frame_rate());
can_import = (s != seq && sequence_length != 0);
if (s->using_workarea) {
default_clip_in = rescale_frame_number(s->workarea_in, s->frame_rate, seq->frame_rate);
default_clip_out = rescale_frame_number(s->workarea_out, s->frame_rate, seq->frame_rate);
default_clip_in = rescale_frame_number(s->workarea_in, s->frame_rate(), seq->frame_rate());
default_clip_out = rescale_frame_number(s->workarea_out, s->frame_rate(), seq->frame_rate());
}
break;
default:
@@ -108,7 +108,7 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
if (m->video_tracks.size() > 0 && m->video_tracks.at(0).infinite_length && m->audio_tracks.size() == 0) {
g.out = g.in + 100;
} else {
long length = m->get_length_in_frames(seq->frame_rate);
long length = m->get_length_in_frames(seq->frame_rate());
g.out = entry_point + length - default_clip_in;
if (m->using_inout) {
g.out -= (length - default_clip_out);
+2 -2
View File
@@ -933,8 +933,8 @@ void MainWindow::Retranslate()
debug_log_->setText(tr("Debug Log"));
about_action_->setText(tr("&About..."));
panel_sequence_viewer->set_panel_name(QCoreApplication::translate("Viewer", "Sequence Viewer"));
panel_footage_viewer->set_panel_name(QCoreApplication::translate("Viewer", "Media Viewer"));
panel_sequence_viewer->set_panel_name(QCoreApplication::translate("Viewer", "Sequence Viewer: %1"));
panel_footage_viewer->set_panel_name(QCoreApplication::translate("Viewer", "Media Viewer: %1"));
// the recommended changeEvent() and event() methods of propagating language change messages provided mixed results
// (i.e. different panels failed to translate in different sessions), so we translate them manually here
+6 -6
View File
@@ -9,7 +9,7 @@ int olive::timeline::kTimelineLabelFixedWidth = 200;
TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignment) :
timeline_(timeline),
track_list_(nullptr),
sequence_(nullptr),
alignment_(alignment)
{
QHBoxLayout* layout = new QHBoxLayout(this);
@@ -157,17 +157,18 @@ void TimelineArea::wheelEvent(QWheelEvent *event)
void TimelineArea::RefreshLabels()
{
if (track_list_ == nullptr) {
if (sequence_ == nullptr) {
labels_.clear();
} else {
/* FIXME
labels_.resize(track_list_->TrackCount());
QVector<Track*> track_list = sequence_->GetTrackList(type_);
labels_.resize(track_list.size());
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
labels_[i]->SetTrack(track_list_->TrackAt(i));
labels_[i]->SetTrack(track_list.at(i));
labels_[i]->SetAlignment(alignment_);
switch (alignment_) {
@@ -181,7 +182,6 @@ void TimelineArea::RefreshLabels()
break;
}
}
*/
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ protected:
virtual void resizeEvent(QResizeEvent *event) override;
private:
Timeline* timeline_;
Sequence* track_list_;
Sequence* sequence_;
olive::TrackType type_;
TimelineView* view_;
QVector<TimelineLabelPtr> labels_;
+2 -2
View File
@@ -357,7 +357,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
QPainter p(this);
int yoff = get_marker_offset();
double interval = viewer->seq->frame_rate;
double interval = viewer->seq->frame_rate();
int textWidth = 0;
int lastTextBoundary = INT_MIN;
@@ -389,7 +389,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
// draw text
bool draw_text = false;
if (text_enabled && lineX-textWidth > lastTextBoundary) {
timecode = frame_to_timecode(frame + in_visible, olive::config.timecode_view, viewer->seq->frame_rate);
timecode = frame_to_timecode(frame + in_visible, olive::config.timecode_view, viewer->seq->frame_rate());
fullTextWidth = fm.width(timecode);
textWidth = fullTextWidth>>1;
+6 -6
View File
@@ -209,9 +209,9 @@ void TimelineView::tooltip_timer_timeout() {
QToolTip::showText(QCursor::pos(),
tr("%1\nStart: %2\nEnd: %3\nDuration: %4").arg(
tooltip_clip->name(),
frame_to_timecode(tooltip_clip->timeline_in(), olive::config.timecode_view, sequence()->frame_rate),
frame_to_timecode(tooltip_clip->timeline_out(), olive::config.timecode_view, sequence()->frame_rate),
frame_to_timecode(tooltip_clip->length(), olive::config.timecode_view, sequence()->frame_rate)
frame_to_timecode(tooltip_clip->timeline_in(), olive::config.timecode_view, sequence()->frame_rate()),
frame_to_timecode(tooltip_clip->timeline_out(), olive::config.timecode_view, sequence()->frame_rate()),
frame_to_timecode(tooltip_clip->length(), olive::config.timecode_view, sequence()->frame_rate())
));
}
@@ -1987,9 +1987,9 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
*/
if (ParentTimeline()->importing) {
QToolTip::showText(mapToGlobal(mouse_pos), frame_to_timecode(earliest_in_point, olive::config.timecode_view, sequence()->frame_rate));
QToolTip::showText(mapToGlobal(mouse_pos), frame_to_timecode(earliest_in_point, olive::config.timecode_view, sequence()->frame_rate()));
} else {
QString tip = ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), olive::config.timecode_view, sequence()->frame_rate);
QString tip = ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), olive::config.timecode_view, sequence()->frame_rate());
if (ParentTimeline()->trim_target != nullptr) {
// find which clip is being moved
@@ -2009,7 +2009,7 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
} else {
len += frame_diff;
}
tip += frame_to_timecode(len, olive::config.timecode_view, sequence()->frame_rate);
tip += frame_to_timecode(len, olive::config.timecode_view, sequence()->frame_rate());
}
}
+45 -45
View File
@@ -88,65 +88,65 @@ void ViewerContainer::adjust() {
horizontal_scrollbar->setVisible(false);
vertical_scrollbar->setVisible(false);
int zoomed_width = qRound(double(viewer->seq->width)*zoom);
int zoomed_height = qRound(double(viewer->seq->height)*zoom);
int zoomed_width = qRound(double(viewer->seq->width())*zoom);
int zoomed_height = qRound(double(viewer->seq->height())*zoom);
if (fit || zoomed_width > width() || zoomed_height > height()) {
// if the zoom size is greater than or equal to the available area, only use the available area
if (fit || zoomed_width > width() || zoomed_height > height()) {
// if the zoom size is greater than or equal to the available area, only use the available area
double aspect_ratio = double(viewer->seq->width)/double(viewer->seq->height);
double aspect_ratio = double(viewer->seq->width())/double(viewer->seq->height());
int widget_x = 0;
int widget_y = 0;
int widget_width = width();
int widget_height = height();
int widget_x = 0;
int widget_y = 0;
int widget_width = width();
int widget_height = height();
if (!fit) {
widget_width -= vertical_scrollbar->sizeHint().width();
widget_height -= horizontal_scrollbar->sizeHint().height();
}
if (!fit) {
widget_width -= vertical_scrollbar->sizeHint().width();
widget_height -= horizontal_scrollbar->sizeHint().height();
}
double widget_ar = double(widget_width) / double(widget_height);
double widget_ar = double(widget_width) / double(widget_height);
bool widget_is_wider_than_sequence = widget_ar > aspect_ratio;
bool widget_is_wider_than_sequence = widget_ar > aspect_ratio;
if (widget_is_wider_than_sequence) {
widget_width = widget_height * aspect_ratio;
widget_x = (width() / 2) - (widget_width / 2);
} else {
widget_height = widget_width / aspect_ratio;
widget_y = (height() / 2) - (widget_height / 2);
}
if (widget_is_wider_than_sequence) {
widget_width = widget_height * aspect_ratio;
widget_x = (width() / 2) - (widget_width / 2);
} else {
widget_height = widget_width / aspect_ratio;
widget_y = (height() / 2) - (widget_height / 2);
}
child->move(widget_x, widget_y);
child->resize(widget_width, widget_height);
child->move(widget_x, widget_y);
child->resize(widget_width, widget_height);
if (fit) {
zoom = double(widget_width) / double(viewer->seq->width);
} else if (zoomed_width > width() || zoomed_height > height()) {
horizontal_scrollbar->setVisible(true);
vertical_scrollbar->setVisible(true);
if (fit) {
zoom = double(widget_width) / double(viewer->seq->width());
} else if (zoomed_width > width() || zoomed_height > height()) {
horizontal_scrollbar->setVisible(true);
vertical_scrollbar->setVisible(true);
horizontal_scrollbar->setMaximum(zoomed_width - width());
vertical_scrollbar->setMaximum(zoomed_height - height());
horizontal_scrollbar->setMaximum(zoomed_width - width());
vertical_scrollbar->setMaximum(zoomed_height - height());
horizontal_scrollbar->setValue(horizontal_scrollbar->maximum()/2);
vertical_scrollbar->setValue(vertical_scrollbar->maximum()/2);
horizontal_scrollbar->setValue(horizontal_scrollbar->maximum()/2);
vertical_scrollbar->setValue(vertical_scrollbar->maximum()/2);
adjust_scrollbars();
}
} else {
// if the zoom size is smaller than the available area, scale the surface down
adjust_scrollbars();
}
} else {
// if the zoom size is smaller than the available area, scale the surface down
int zoomed_x = 0;
int zoomed_y = 0;
int zoomed_x = 0;
int zoomed_y = 0;
if (zoomed_width < width()) zoomed_x = (width()>>1)-(zoomed_width>>1);
if (zoomed_height < height()) zoomed_y = (height()>>1)-(zoomed_height>>1);
if (zoomed_width < width()) zoomed_x = (width()>>1)-(zoomed_width>>1);
if (zoomed_height < height()) zoomed_y = (height()>>1)-(zoomed_height>>1);
child->move(zoomed_x, zoomed_y);
child->resize(zoomed_width, zoomed_height);
}
child->move(zoomed_x, zoomed_y);
child->resize(zoomed_width, zoomed_height);
}
}
}
}
@@ -170,5 +170,5 @@ void ViewerContainer::scroll_changed() {
child->set_scroll(
double(horizontal_scrollbar->value())/double(horizontal_scrollbar->maximum()),
double(vertical_scrollbar->value())/double(vertical_scrollbar->maximum())
);
);
}
+9 -9
View File
@@ -266,7 +266,7 @@ QMatrix4x4 ViewerWidget::get_matrix()
{
QMatrix4x4 matrix;
double zoom_factor = container->zoom/(double(width())/double(viewer->seq->width));
double zoom_factor = container->zoom/(double(width())/double(viewer->seq->width()));
if (zoom_factor > 1.0) {
double zoom_size = (zoom_factor*2.0) - 2.0;
@@ -298,7 +298,7 @@ void ViewerWidget::context_destroy() {
EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) {
if (gizmos != nullptr) {
double multiplier = double(viewer->seq->width) / double(width());
double multiplier = double(viewer->seq->width()) / double(width());
QPoint mouse_pos(qRound(x*multiplier), qRound((height()-y)*multiplier));
int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier);
int target_size = 2 * qRound(GIZMO_TARGET_SIZE * multiplier);
@@ -335,7 +335,7 @@ EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) {
void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) {
if (selected_gizmo != nullptr) {
double multiplier = double(viewer->seq->width) / double(width());
double multiplier = double(viewer->seq->width()) / double(width());
int x_movement = qRound((event->pos().x() - drag_start_x)*multiplier);
int y_movement = qRound((event->pos().y() - drag_start_y)*multiplier);
@@ -555,13 +555,13 @@ void ViewerWidget::draw_gizmos() {
pipeline_->bind();
double zoom_factor = container->zoom/(double(width())/double(viewer->seq->width));
double zoom_factor = container->zoom/(double(width())/double(viewer->seq->width()));
QMatrix4x4 matrix;
matrix.ortho(0, viewer->seq->width, 0, viewer->seq->height, -1, 1);
matrix.ortho(0, viewer->seq->width(), 0, viewer->seq->height(), -1, 1);
matrix.scale(zoom_factor, zoom_factor);
matrix.translate(-(viewer->seq->width-(width()/container->zoom))*x_scroll,
-((viewer->seq->height-(height()/container->zoom))*(1.0-y_scroll)));
matrix.translate(-(viewer->seq->width()-(width()/container->zoom))*x_scroll,
-((viewer->seq->height()-(height()/container->zoom))*(1.0-y_scroll)));
// Set transformation matrix
pipeline_->setUniformValue("mvp_matrix", matrix);
@@ -571,7 +571,7 @@ void ViewerWidget::draw_gizmos() {
pipeline_->setUniformValue("color_only_color", QColor(255, 255, 255, 255));
// Set up constants for gizmo sizes
float size_diff = float(viewer->seq->width) / float(width());
float size_diff = float(viewer->seq->width()) / float(width());
float dot_size = GIZMO_DOT_SIZE * size_diff;
float target_size = GIZMO_TARGET_SIZE * size_diff;
@@ -761,7 +761,7 @@ void ViewerWidget::paintGL() {
}
if (window->isVisible()) {
window->set_texture(tex, double(viewer->seq->width)/double(viewer->seq->height), tex_lock);
window->set_texture(tex, double(viewer->seq->width())/double(viewer->seq->height()), tex_lock);
}
tex_lock->unlock();
+18 -18
View File
@@ -824,31 +824,31 @@ void SetSelectionsCommand::doRedo() {
EditSequenceCommand::EditSequenceCommand(Media* i, SequencePtr s) {
item = i;
seq = s;
old_name = s->name;
old_width = s->width;
old_height = s->height;
old_frame_rate = s->frame_rate;
old_audio_frequency = s->audio_frequency;
old_audio_layout = s->audio_layout;
old_name = s->name();
old_width = s->width();
old_height = s->height();
old_frame_rate = s->frame_rate();
old_audio_frequency = s->audio_frequency();
old_audio_layout = s->audio_layout();
}
void EditSequenceCommand::doUndo() {
seq->name = old_name;
seq->width = old_width;
seq->height = old_height;
seq->frame_rate = old_frame_rate;
seq->audio_frequency = old_audio_frequency;
seq->audio_layout = old_audio_layout;
seq->set_name(old_name);
seq->set_width(old_width);
seq->set_height(old_height);
seq->set_frame_rate(old_frame_rate);
seq->set_audio_frequency(old_audio_frequency);
seq->set_audio_layout(old_audio_layout);
update();
}
void EditSequenceCommand::doRedo() {
seq->name = name;
seq->width = width;
seq->height = height;
seq->frame_rate = frame_rate;
seq->audio_frequency = audio_frequency;
seq->audio_layout = audio_layout;
seq->set_name(name);
seq->set_width(width);
seq->set_height(height);
seq->set_frame_rate(frame_rate);
seq->set_audio_frequency(audio_frequency);
seq->set_audio_layout(audio_layout);
update();
}