many comfort features and fixed audio bug

This commit is contained in:
itsmattkc
2018-07-06 16:07:01 +01:00
parent 77defa4ce9
commit 31da8e0a0f
11 changed files with 83 additions and 31 deletions
+2 -2
View File
@@ -35,11 +35,11 @@ TransformEffect::TransformEffect(Clip* c) : Effect(c) {
ui_layout->addWidget(new QLabel("Scale:"), 1, 0);
scale_x = new LabelSlider();
scale_x->set_minimum_value(0);
scale_x->set_maximum_value(1200);
scale_x->set_maximum_value(3000);
ui_layout->addWidget(scale_x, 1, 1);
scale_y = new LabelSlider();
scale_y->set_minimum_value(0);
scale_y->set_maximum_value(1200);
scale_y->set_maximum_value(3000);
ui_layout->addWidget(scale_y, 1, 2);
uniform_scale_box = new QCheckBox();
+12 -2
View File
@@ -51,7 +51,7 @@ MainWindow::MainWindow(QWidget *parent) :
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
@@ -79,7 +79,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui->centralWidget->setMaximumSize(0, 0);
setDockNestingEnabled(true);
// TODO maybe replace these with non-pointers later on?
panel_project = new Project(this);
panel_effect_controls = new EffectControls(this);
@@ -495,6 +494,8 @@ void MainWindow::on_actionNon_Drop_Frame_triggered()
void MainWindow::toolMenu_About_To_Be_Shown() {
ui->actionEdit_Tool_Also_Seeks->setChecked(panel_timeline->edit_tool_also_seeks);
ui->actionEdit_Tool_Selects_Links->setChecked(panel_timeline->edit_tool_selects_links);
ui->actionSelecting_Also_Seeks->setChecked(panel_timeline->select_also_seeks);
ui->actionSeek_to_the_End_of_Pastes->setChecked(panel_timeline->paste_seeks);
}
void MainWindow::on_actionEdit_Tool_Selects_Links_triggered() {
@@ -510,3 +511,12 @@ void MainWindow::on_actionDuplicate_triggered() {
panel_project->duplicate_selected();
}
}
void MainWindow::on_actionSelecting_Also_Seeks_triggered() {
panel_timeline->select_also_seeks = !panel_timeline->select_also_seeks;
}
void MainWindow::on_actionSeek_to_the_End_of_Pastes_triggered()
{
panel_timeline->paste_seeks = !panel_timeline->paste_seeks;
}
+4
View File
@@ -131,6 +131,10 @@ private slots:
void on_actionDuplicate_triggered();
void on_actionSelecting_Also_Seeks_triggered();
void on_actionSeek_to_the_End_of_Pastes_triggered();
private:
Ui::MainWindow *ui;
void setup_layout();
+19 -1
View File
@@ -24,7 +24,7 @@
<x>0</x>
<y>0</y>
<width>653</width>
<height>29</height>
<height>17</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@@ -126,8 +126,10 @@
<addaction name="actionSlip_Tool"/>
<addaction name="separator"/>
<addaction name="actionToggle_Snapping"/>
<addaction name="actionSelecting_Also_Seeks"/>
<addaction name="actionEdit_Tool_Also_Seeks"/>
<addaction name="actionEdit_Tool_Selects_Links"/>
<addaction name="actionSeek_to_the_End_of_Pastes"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="separator"/>
@@ -538,6 +540,22 @@
<string>Ctrl+D</string>
</property>
</action>
<action name="actionSelecting_Also_Seeks">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Selecting Also Seeks</string>
</property>
</action>
<action name="actionSeek_to_the_End_of_Pastes">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Seek to the End of Pastes</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.2, 2018-07-05T22:05:57. -->
<!-- Written by QtCreator 4.6.2, 2018-07-06T04:54:40. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
+8
View File
@@ -34,6 +34,8 @@ Timeline::Timeline(QWidget *parent) :
rect_select_proc = false;
edit_tool_selects_links = false;
edit_tool_also_seeks = false;
select_also_seeks = false;
paste_seeks = true;
snapping = true;
last_frame = 0;
playhead = 0;
@@ -623,12 +625,14 @@ void Timeline::paste() {
}
delete_areas_and_relink(delete_areas);
long paste_end = 0;
QVector<Clip*> added_clips;
for (int i=0;i<clip_clipboard.size();i++) {
Clip* c = clip_clipboard.at(i);
Clip* cc = c->copy();
cc->timeline_in += playhead;
cc->timeline_out += playhead;
if (cc->timeline_out > paste_end) paste_end = cc->timeline_out;
cc->sequence = sequence;
added_clips.append(cc);
sequence->add_clip(cc);
@@ -637,6 +641,10 @@ void Timeline::paste() {
relink_clips_using_ids(clip_clipboard, added_clips);
redraw_all_clips(true);
if (paste_seeks) {
seek(paste_end);
}
}
}
+2
View File
@@ -101,8 +101,10 @@ public:
QTimer playback_updater;
// shared information
bool select_also_seeks;
bool edit_tool_selects_links;
bool edit_tool_also_seeks;
bool paste_seeks;
int tool;
long cursor_frame;
int cursor_track;
+1 -1
View File
@@ -56,7 +56,7 @@ void clear_audio_ibuffer() {
int get_buffer_offset_from_frame(long frame) {
if (frame >= audio_ibuffer_frame) {
return av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(sequence->audio_layout), ((frame-audio_ibuffer_frame)/sequence->frame_rate)*sequence->audio_frequency, AV_SAMPLE_FMT_S16, 1);
return av_samples_get_buffer_size(NULL, av_get_channel_layout_nb_channels(sequence->audio_layout), qRound(((frame-audio_ibuffer_frame)/sequence->frame_rate)*sequence->audio_frequency), AV_SAMPLE_FMT_S16, 1);
} else {
qDebug() << "[WARNING] get_buffer_offset_from_frame called incorrectly";
return 0;
+8 -2
View File
@@ -36,10 +36,9 @@ void cache_audio_worker(Clip* c) {
c->need_new_audio_frame = false;
if (c->audio_just_reset) {
// get precise sample offset for the elected clip_in from this audio frame
float target_sts = 0;
if (c->audio_target_frame < c->timeline_in) {
target_sts = playhead_to_seconds(c, c->clip_in);
target_sts = clip_frame_to_seconds(c, c->clip_in);
} else {
target_sts = playhead_to_seconds(c, c->audio_target_frame);
}
@@ -82,6 +81,13 @@ void cache_audio_worker(Clip* c) {
retrieve_next_frame_raw_data(c, frame);
nb_bytes = av_samples_get_buffer_size(NULL, frame->channels, frame->nb_samples, static_cast<AVSampleFormat>(frame->format), 1);
c->frame_sample_index -= nb_bytes;
// code DISGUSTINGLY copy/pasted from above
int offset = audio_ibuffer_read - c->audio_buffer_write;
if (offset > 0) {
c->audio_buffer_write += offset;
c->frame_sample_index += offset;
}
}
while (c->frame_sample_index < nb_bytes) {
if (c->audio_buffer_write >= audio_ibuffer_read+half_buffer || c->audio_buffer_write >= get_buffer_offset_from_frame(c->timeline_out)) {
+1 -1
View File
@@ -175,7 +175,7 @@ void get_clip_frame(Clip* c, long playhead) {
float playhead_to_seconds(Clip* c, long playhead) {
// returns time in seconds
return (std::max((long) 0, playhead - c->timeline_in) + c->clip_in)/c->sequence->frame_rate;
return (qMax((long) 0, playhead - c->timeline_in) + c->clip_in)/c->sequence->frame_rate;
}
long seconds_to_clip_frame(Clip* c, float seconds) {
+25 -21
View File
@@ -224,6 +224,10 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
if (clip != NULL) {
panel_timeline->selections.append({clip->timeline_in, clip->timeline_out, clip->track});
if (panel_timeline->select_also_seeks) {
panel_timeline->seek(clip->timeline_in);
}
// if alt is not down, select links
if (!(event->modifiers() & Qt::AltModifier)) {
for (int i=0;i<clip->linked.size();i++) {
@@ -440,7 +444,7 @@ void TimelineWidget::init_ghosts() {
g.old_in = g.in;
g.old_out = g.out;
g.old_track = g.track;
g.old_clip_in = g.clip_in;
g.old_clip_in = g.clip_in;
if (panel_timeline->trim_target > -1 || panel_timeline->tool == TIMELINE_TOOL_SLIP) {
// used for trim ops
@@ -567,30 +571,30 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
}
validate_snapping(g, &frame_diff);
}
}
// resize ghosts
for (int i=0;i<panel_timeline->ghosts.size();i++) {
Ghost& g = panel_timeline->ghosts[i];
// resize ghosts
for (int i=0;i<panel_timeline->ghosts.size();i++) {
Ghost& g = panel_timeline->ghosts[i];
if (panel_timeline->trim_in) {
g.in = g.old_in + frame_diff;
g.clip_in = g.old_clip_in + frame_diff;
} else {
g.out = g.old_out + frame_diff;
}
}
if (panel_timeline->trim_in) {
g.in = g.old_in + frame_diff;
g.clip_in = g.old_clip_in + frame_diff;
} else {
g.out = g.old_out + frame_diff;
}
}
// resize selections
for (int i=0;i<panel_timeline->selections.size();i++) {
Selection& s = panel_timeline->selections[i];
// resize selections
for (int i=0;i<panel_timeline->selections.size();i++) {
Selection& s = panel_timeline->selections[i];
if (panel_timeline->trim_in) {
s.in = s.old_in + frame_diff;
} else {
s.out = s.old_out + frame_diff;
}
}
if (panel_timeline->trim_in) {
s.in = s.old_in + frame_diff;
} else {
s.out = s.old_out + frame_diff;
}
}
} else if (panel_timeline->tool == TIMELINE_TOOL_POINTER || panel_timeline->importing) { // only move clips on pointer (not ripple or rolling)
// validate ghosts
for (int i=0;i<panel_timeline->ghosts.size();i++) {