many fixes and improvements

This commit is contained in:
itsmattkc
2018-07-19 13:02:35 +01:00
parent 33f8d7274a
commit c375cd3ee7
10 changed files with 239 additions and 228 deletions
+5 -4
View File
@@ -275,11 +275,10 @@ void Project::delete_selected_media() {
}
for (int i=0;i<items.size();i++) {
/*
delete_media(item);
delete item;*/
// send delete command to the TimelineAction
if (get_type_from_tree(items.at(i)) == MEDIA_TYPE_SEQUENCE) {
redraw = true;
}
ta->delete_media(items.at(i));
}
undo_stack.push(ta);
@@ -288,6 +287,8 @@ void Project::delete_selected_media() {
if (redraw) {
panel_timeline->redraw_all_clips(true);
}
project_changed = true;
} else {
delete ta;
}
+19 -19
View File
@@ -121,12 +121,14 @@ void Timeline::next_cut() {
void Timeline::reset_all_audio() {
// reset all clip audio
for (int i=0;i<sequence->clip_count();i++) {
Clip* c = sequence->get_clip(i);
if (c != NULL) {
c->reset_audio = true;
c->frame_sample_index = 0;
c->audio_buffer_write = 0;
if (sequence != NULL) {
for (int i=0;i<sequence->clip_count();i++) {
Clip* c = sequence->get_clip(i);
if (c != NULL) {
c->reset_audio = true;
c->frame_sample_index = 0;
c->audio_buffer_write = 0;
}
}
}
ui->audio_monitor->reset();
@@ -247,23 +249,21 @@ void Timeline::repaint_timeline() {
ui->audio_monitor->update();
last_frame = playhead;
}
panel_viewer->update_playhead_timecode();
panel_viewer->update_playhead_timecode(playhead);
}
void Timeline::redraw_all_clips(bool changed) {
if (sequence != NULL) {
if (changed) {
project_changed = true;
if (!playing) reset_all_audio();
panel_viewer->viewer_widget->update();
}
ui->video_area->redraw_clips();
ui->audio_area->redraw_clips();
ui->headers->update();
panel_viewer->update_end_timecode();
if (changed) {
project_changed = true;
if (!playing) reset_all_audio();
panel_viewer->viewer_widget->update();
}
ui->video_area->redraw_clips();
ui->audio_area->redraw_clips();
ui->headers->update();
panel_viewer->update_end_timecode();
}
void Timeline::select_all() {
+50 -42
View File
@@ -24,6 +24,9 @@ Viewer::Viewer(QWidget *parent) :
viewer_widget = ui->openGLWidget;
timecode_view = TIMECODE_DROP;
update_sequence();
update_playhead_timecode(0);
update_end_timecode();
}
Viewer::~Viewer()
@@ -32,8 +35,8 @@ Viewer::~Viewer()
delete ui;
}
QString Viewer::frame_to_timecode(long f) {
if (timecode_view == TIMECODE_FRAMES) {
QString Viewer::frame_to_timecode(long f, int view, double frame_rate) {
if (view == TIMECODE_FRAMES) {
return QString::number(f);
}
@@ -44,49 +47,47 @@ QString Viewer::frame_to_timecode(long f) {
int frames = 0;
QString token = ":";
if (sequence != NULL) {
if (timecode_view == TIMECODE_DROP && frame_rate_is_droppable(sequence->frame_rate)) {
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
//Code by David Heidelberger, adapted from Andrew Duncan, further adapted for Olive by Olive Team
//Given an int called framenumber and a double called framerate
//Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.
if (view == TIMECODE_DROP && frame_rate_is_droppable(frame_rate)) {
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
//Code by David Heidelberger, adapted from Andrew Duncan, further adapted for Olive by Olive Team
//Given an int called framenumber and a double called framerate
//Framerate should be 29.97, 59.94, or 23.976, otherwise the calculations will be off.
int d;
int m;
int d;
int m;
int dropFrames = round(sequence->frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int framesPerHour = round(sequence->frame_rate*60*60); //Number of frames in an hour
int framesPer24Hours = framesPerHour*24; //Number of frames in a day - timecode rolls over after 24 hours
int framesPer10Minutes = round(sequence->frame_rate * 60 * 10); //Number of frames per ten minutes
int framesPerMinute = (round(sequence->frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
int dropFrames = round(frame_rate * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
int framesPerHour = round(frame_rate*60*60); //Number of frames in an hour
int framesPer24Hours = framesPerHour*24; //Number of frames in a day - timecode rolls over after 24 hours
int framesPer10Minutes = round(frame_rate * 60 * 10); //Number of frames per ten minutes
int framesPerMinute = (round(frame_rate)*60)- dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
//If framenumber is greater than 24 hrs, next operation will rollover clock
f = f % framesPer24Hours; //% is the modulus operator, which returns a remainder. a % b = the remainder of a/b
//If framenumber is greater than 24 hrs, next operation will rollover clock
f = f % framesPer24Hours; //% is the modulus operator, which returns a remainder. a % b = the remainder of a/b
d = f / framesPer10Minutes; // \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)
m = f % framesPer10Minutes;
d = f / framesPer10Minutes; // \ means integer division, which is a/b without a remainder. Some languages you could use floor(a/b)
m = f % framesPer10Minutes;
//In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.
if (m > dropFrames) {
f = f + (dropFrames*9*d) + dropFrames * ((m - dropFrames) / framesPerMinute);
} else {
f = f + dropFrames*9*d;
}
int frRound = round(sequence->frame_rate);
frames = f % frRound;
secs = (f / frRound) % 60;
mins = ((f / frRound) / 60) % 60;
hours = (((f / frRound) / 60) / 60);
token = ";";
//In the original post, the next line read m>1, which only worked for 29.97. Jean-Baptiste Mardelle correctly pointed out that m should be compared to dropFrames.
if (m > dropFrames) {
f = f + (dropFrames*9*d) + dropFrames * ((m - dropFrames) / framesPerMinute);
} else {
int int_fps = qRound(sequence->frame_rate);
hours = f/ (3600 * int_fps);
mins = f / (60*int_fps) % 60;
secs = f/int_fps % 60;
frames = f%int_fps;
f = f + dropFrames*9*d;
}
int frRound = round(frame_rate);
frames = f % frRound;
secs = (f / frRound) % 60;
mins = ((f / frRound) / 60) % 60;
hours = (((f / frRound) / 60) / 60);
token = ";";
} else {
int int_fps = qRound(frame_rate);
hours = f/ (3600 * int_fps);
mins = f / (60*int_fps) % 60;
secs = f/int_fps % 60;
frames = f%int_fps;
}
return QString(QString::number(hours).rightJustified(2, '0') +
":" + QString::number(mins).rightJustified(2, '0') +
@@ -99,12 +100,16 @@ bool frame_rate_is_droppable(float rate) {
return (rate == 23.976f || rate == 29.97f || rate == 59.94f);
}
void Viewer::update_playhead_timecode() {
ui->currentTimecode->setText(frame_to_timecode(panel_timeline->playhead));
void Viewer::update_playhead_timecode(long p) {
ui->currentTimecode->setText(frame_to_timecode(p, timecode_view, (sequence != NULL) ? sequence->frame_rate : 30));
}
void Viewer::update_end_timecode() {
ui->endTimecode->setText(frame_to_timecode(sequence->getEndFrame()));
if (sequence == NULL) {
ui->endTimecode->setText(frame_to_timecode(0, timecode_view, 30));
} else {
ui->endTimecode->setText(frame_to_timecode(sequence->getEndFrame(), timecode_view, sequence->frame_rate));
}
}
void Viewer::update_sequence() {
@@ -127,11 +132,14 @@ void Viewer::update_sequence() {
timecode_view = TIMECODE_NONDROP;
}
update_playhead_timecode();
update_playhead_timecode(panel_timeline->playhead);
update_end_timecode();
ui->glViewerPane->aspect_ratio = (float) sequence->width / (float) sequence->height;
ui->glViewerPane->adjust();
} else {
update_playhead_timecode(0);
update_end_timecode();
}
update();
+2 -2
View File
@@ -28,7 +28,7 @@ public:
void compose();
void set_playpause_icon(bool play);
int timecode_view;
void update_playhead_timecode();
void update_playhead_timecode(long p);
void update_end_timecode();
ViewerWidget* viewer_widget;
@@ -46,7 +46,7 @@ private slots:
void on_pushButton_3_clicked();
private:
QString frame_to_timecode(long f);
QString frame_to_timecode(long f, int view, double frame_rate);
};
#endif // VIEWER_H