From 9d185e0a40f31932579a29b4e56ca4f671c5dc92 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 3 Sep 2018 12:58:21 +1000 Subject: [PATCH] several small bug fixes --- icons/win.rc | 1 - olive.pro | 6 ++-- panels/effectcontrols.cpp | 14 ++------- panels/effectcontrols.h | 3 +- playback/playback.cpp | 10 +++--- ui/keyframeview.cpp | 66 ++++++++++++++++++++++++--------------- ui/keyframeview.h | 1 - ui/viewerwidget.cpp | 18 +++++++++-- 8 files changed, 68 insertions(+), 51 deletions(-) delete mode 100644 icons/win.rc diff --git a/icons/win.rc b/icons/win.rc deleted file mode 100644 index 33edf5ce5..000000000 --- a/icons/win.rc +++ /dev/null @@ -1 +0,0 @@ -olicon ICON "olive.ico" \ No newline at end of file diff --git a/olive.pro b/olive.pro index 8fd5b6f2d..c9a7cc0ed 100644 --- a/olive.pro +++ b/olive.pro @@ -145,10 +145,8 @@ FORMS += \ dialogs/preferencesdialog.ui win32 { - LIBS += -L../ffmpeg/lib -lopengl32 - INCLUDEPATH = ../ffmpeg/include - RC_FILE = icons/win.rc - LIBS += -lavutil -lavformat -lavcodec -lswscale -lswresample + RC_ICONS = icons/olive.ico + LIBS += -lavutil -lavformat -lavcodec -lswscale -lswresample -lopengl32 } mac { diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 7d438dff3..bad91b69a 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -143,8 +143,7 @@ void EffectControls::show_effect_menu(bool video, bool transitions) { } void EffectControls::clear_effects(bool clear_cache) { - // clear existing clips - ui->keyframeView->effects.clear(); + // clear existing clips QVBoxLayout* video_layout = static_cast(ui->video_effect_area->layout()); QVBoxLayout* audio_layout = static_cast(ui->audio_effect_area->layout()); QLayoutItem* item; @@ -176,15 +175,10 @@ void EffectControls::deselect_all_effects(QWidget* sender) { void EffectControls::load_effects() { // load in new clips - long effects_in = LONG_MAX; - long effects_out = 0; for (int i=0;iget_clip(selected_clips.at(i)); - effects_in = qMin(effects_in, c->timeline_in); - effects_out = qMax(effects_out, c->timeline_out); for (int j=0;jeffects.size();j++) { Effect* e = c->effects.at(j); - ui->keyframeView->effects.append(e); CollapsibleWidget* container = e->container; if (c->track < 0) { static_cast(ui->video_effect_area->layout())->addWidget(container); @@ -199,12 +193,8 @@ void EffectControls::load_effects() { if (selected_clips.size() > 0) { ui->keyframeView->setMinimumHeight(ui->effects_area->height()); ui->keyframeView->setEnabled(true); - ui->keyframeView->visible_in = effects_in; - ui->keyframeView->visible_out = effects_out; - ui->keyframeView->update(); - - ui->headers->set_visible_in(effects_in); ui->headers->setVisible(true); + ui->keyframeView->update(); } } diff --git a/panels/effectcontrols.h b/panels/effectcontrols.h index 6d9df4aca..8f2e214e7 100644 --- a/panels/effectcontrols.h +++ b/panels/effectcontrols.h @@ -40,6 +40,8 @@ public: bool keyframe_focus(); void delete_selected_keyframes(); + QVector selected_clips; + double zoom; public slots: void update_keyframes(); @@ -55,7 +57,6 @@ private slots: private: Ui::EffectControls *ui; - QVector selected_clips; void show_effect_menu(bool video, bool transitions); void load_effects(); void load_keyframes(); diff --git a/playback/playback.cpp b/playback/playback.cpp index 7b960de4f..3b5112062 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -94,9 +94,9 @@ void cache_clip(Clip* clip, long playhead, bool write_A, bool write_B, bool rese } bool get_clip_frame(Clip* c, long playhead) { - if (c->open) { + if (c->finished_opening) { long sequence_clip_time = playhead - c->timeline_in + c->clip_in; - long clip_time = refactor_frame_number(sequence_clip_time, c->sequence->frame_rate, av_q2d(av_guess_frame_rate(c->formatCtx, c->stream, c->frame))); + long clip_time = refactor_frame_number(sequence_clip_time, c->sequence->frame_rate, av_q2d(c->stream->avg_frame_rate)); // do we need to update the texture? MediaStream* ms = static_cast(c->media)->get_stream_from_file_index(c->track < 0, c->media_stream); @@ -133,6 +133,7 @@ bool get_clip_frame(Clip* c, long playhead) { c->cache_A.mutex.unlock(); } } else { + // frame is coming but isn't here yet, no need to reset cache no_frame = true; } } else if (c->cache_B.written && clip_time >= c->cache_B.offset && clip_time < c->cache_B.offset + c->cache_size) { @@ -145,6 +146,7 @@ bool get_clip_frame(Clip* c, long playhead) { c->cache_B.mutex.unlock(); } } else { + // frame is coming but isn't here yet, no need to reset cache no_frame = true; } } else { @@ -158,14 +160,14 @@ bool get_clip_frame(Clip* c, long playhead) { current_frame = cache[clip_time - cache_offset]; } - // determine whether we should start filling the other cache + // determine whether we should s1tart filling the other cache if (!using_cache_A || !using_cache_B) { if (c->lock.tryLock()) { bool write_A = (!using_cache_A && !c->cache_A.unread); bool write_B = (!using_cache_B && !c->cache_B.unread); if (write_A || write_B) { // if we have no cache and need to seek, start us at the current playhead, otherwise start at the end of the current cache - cache_clip(c, (cache_needs_reset) ? clip_time : cache_offset + c->cache_size, write_A, write_B, cache_needs_reset, NULL); + cache_clip(c, (cache_needs_reset) ? qMax(clip_time, 0L) : cache_offset + c->cache_size, write_A, write_B, cache_needs_reset, NULL); } c->lock.unlock(); } diff --git a/ui/keyframeview.cpp b/ui/keyframeview.cpp index ccffdf894..caac06c48 100644 --- a/ui/keyframeview.cpp +++ b/ui/keyframeview.cpp @@ -10,6 +10,7 @@ #include "project/undo.h" #include "panels/viewer.h" #include "ui/viewerwidget.h" +#include "project/sequence.h" #include #include @@ -27,36 +28,49 @@ KeyframeView::KeyframeView(QWidget *parent) : QWidget(parent), mousedown(false), } void KeyframeView::paintEvent(QPaintEvent*) { - QPainter p(this); + QPainter p(this); + + rowY.clear(); + rows.clear(); + + long effects_in = LONG_MAX; + long effects_out = 0; + + for (int j=0;jselected_clips.size();j++) { + Clip* c = sequence->get_clip(panel_effect_controls->selected_clips.at(j)); + effects_in = qMin(effects_in, c->timeline_in); + effects_out = qMax(effects_out, c->timeline_out); + for (int i=0;ieffects.size();i++) { + Effect* e = c->effects.at(i); + if (e->container->is_expanded()) { + for (int j=0;jrow_count();j++) { + EffectRow* row = e->row(j); + + QLabel* label = row->label; + QWidget* contents = e->container->contents; + + int keyframe_y = label->y() + (label->height()>>1) + mapFrom(panel_effect_controls, contents->mapTo(panel_effect_controls, contents->pos())).y() - e->container->title_bar->height(); + for (int k=0;kkeyframe_times.size();k++) { + bool keyframe_selected = keyframeIsSelected(row, k); + long keyframe_frame = adjust_row_keyframe(row, row->keyframe_times.at(k)); + if (dragging && keyframe_selected) keyframe_frame += frame_diff; + draw_keyframe(p, getScreenPointFromFrame(panel_effect_controls->zoom, keyframe_frame), keyframe_y, keyframe_selected); + } + + rows.append(row); + rowY.append(keyframe_y); + } + } + } + } + + visible_in = effects_in; + visible_out = effects_out; int width = getScreenPointFromFrame(panel_effect_controls->zoom, visible_out - visible_in); setMinimumWidth(width); header->setMinimumWidth(width); - - rowY.clear(); - rows.clear(); - for (int i=0;icontainer->is_expanded()) { - for (int j=0;jrow_count();j++) { - EffectRow* row = e->row(j); - - QLabel* label = row->label; - QWidget* contents = e->container->contents; - - int keyframe_y = label->y() + (label->height()>>1) + mapFrom(panel_effect_controls, contents->mapTo(panel_effect_controls, contents->pos())).y() - e->container->title_bar->height(); - for (int k=0;kkeyframe_times.size();k++) { - bool keyframe_selected = keyframeIsSelected(row, k); - long keyframe_frame = adjust_row_keyframe(row, row->keyframe_times.at(k)); - if (dragging && keyframe_selected) keyframe_frame += frame_diff; - draw_keyframe(p, getScreenPointFromFrame(panel_effect_controls->zoom, keyframe_frame), keyframe_y, keyframe_selected); - } - - rows.append(row); - rowY.append(keyframe_y); - } - } - } + header->set_visible_in(effects_in); if (rowY.size() > 0) { int playhead_x = getScreenPointFromFrame(panel_effect_controls->zoom, panel_timeline->playhead-visible_in); diff --git a/ui/keyframeview.h b/ui/keyframeview.h index ec62761c9..bc08512e6 100644 --- a/ui/keyframeview.h +++ b/ui/keyframeview.h @@ -13,7 +13,6 @@ class KeyframeView : public QWidget { Q_OBJECT public: KeyframeView(QWidget* parent = 0); - QVector effects; void delete_selected_keyframes(); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 1566b4b4b..c815c3711 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -163,6 +163,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { int half_width = s->width/2; int half_height = s->height/2; if (rendering || nest != NULL) half_height = -half_height; + glPushMatrix(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0, 1.0, 1.0, 1.0); glLoadIdentity(); @@ -189,7 +190,7 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { Sequence* cs = static_cast(c->media); video_width = cs->width; video_height = cs->height; - textureID = compose_sequence(c, render_audio); + textureID = -1; } if (textureID == 0) { @@ -203,6 +204,17 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { c->fbo[1] = new QOpenGLFramebufferObject(video_width, video_height); } + // clear fbos + c->fbo[0]->bind(); + glClear(GL_COLOR_BUFFER_BIT); + c->fbo[0]->release(); + c->fbo[1]->bind(); + glClear(GL_COLOR_BUFFER_BIT); + c->fbo[1]->release(); + + // for nested sequences + if (textureID == -1) textureID = compose_sequence(c, render_audio); + glViewport(0, 0, video_width, video_height); GLuint composite_texture = draw_clip(c->fbo[0], textureID); @@ -261,7 +273,6 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { // EFFECT CODE END if (nest != NULL) { -// if (nest->fbo == NULL) nest->fbo = new QOpenGLFramebufferObject(s->width, s->height); nest->fbo[0]->bind(); glViewport(0, 0, s->width, s->height); } else if (rendering) { @@ -305,6 +316,8 @@ GLuint ViewerWidget::compose_sequence(Clip* nest, bool render_audio) { } } + glPopMatrix(); + return (nest != NULL && nest->fbo != NULL) ? nest->fbo[0]->texture() : 0; } @@ -325,6 +338,7 @@ void ViewerWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT); // compose video preview + glClearColor(0, 0, 0, 0); compose_sequence(NULL, (panel_timeline->playing || rendering)); if (texture_failed) {