diff --git a/effects/paneffect.cpp b/effects/paneffect.cpp index d18427825..a7f932da5 100644 --- a/effects/paneffect.cpp +++ b/effects/paneffect.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "ui/collapsiblewidget.h" @@ -53,7 +54,7 @@ void PanEffect::process_audio(quint8 *samples, int nb_bytes) { float val = pan_val->value()*0.01; if (val < 0) { // affect right channel - right_sample *= (1-abs(val)); + right_sample *= (1-std::abs(val)); } else { // affect left channel left_sample *= (1-val); diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index 651f14a5b..0c6f02c11 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -9,6 +9,7 @@ extern "C" { #include +#include #include #include } @@ -44,7 +45,7 @@ void PreviewGenerator::run() { SwsContext* sws_ctx; SwrContext* swr_ctx; AVFrame* temp_frame = av_frame_alloc(); - AVCodecContext* codec_ctx[fmt_ctx->nb_streams]; + AVCodecContext** codec_ctx = new AVCodecContext* [fmt_ctx->nb_streams]; for (unsigned int i=0;inb_streams;i++) { AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id); codec_ctx[i] = avcodec_alloc_context3(codec); @@ -172,6 +173,7 @@ void PreviewGenerator::run() { for (unsigned int i=0;inb_streams;i++) { avcodec_close(codec_ctx[i]); } + delete [] codec_ctx; } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 86722328f..e2442322a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -318,3 +318,10 @@ void MainWindow::on_actionPlay_Pause_triggered() panel_timeline->toggle_play(); } } + +void MainWindow::on_actionCrash_triggered() +{ + // intentionally tries to crash the program - mostly used for debugging + Timeline* temp; + temp->snapped = true; +} diff --git a/mainwindow.h b/mainwindow.h index 6e220f0d9..3d74f69e6 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -85,6 +85,8 @@ private slots: void on_actionPlay_Pause_triggered(); + void on_actionCrash_triggered(); + private: Ui::MainWindow *ui; void setup_layout(); diff --git a/mainwindow.ui b/mainwindow.ui index 176ca7439..4acd10e05 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -24,7 +24,7 @@ 0 0 653 - 34 + 17 @@ -84,6 +84,7 @@ &Help + @@ -361,6 +362,11 @@ End + + + Crash + + diff --git a/olive.pro b/olive.pro index 63afc3e49..4c714479c 100644 --- a/olive.pro +++ b/olive.pro @@ -95,7 +95,7 @@ FORMS += \ dialogs/exportdialog.ui win32 { - LIBS += -L../ffmpeg/lib -lavutil -lavformat -lavcodec -lswscale -lswresample opengl32.lib + LIBS += -L../ffmpeg/lib -lavutil -lavformat -lavcodec -lswscale -lswresample -lopengl32 INCLUDEPATH = ../ffmpeg/include RC_FILE = icons/win.rc } diff --git a/olive.pro.user b/olive.pro.user index 720492dac..946790bd8 100644 --- a/olive.pro.user +++ b/olive.pro.user @@ -1,336 +1,318 @@ - - - - - - EnvironmentId - {be57d5b1-e5ae-4026-9f48-bb6e01f50d4e} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop Qt 5.5.1 GCC 64bit - Desktop Qt 5.5.1 GCC 64bit - qt.55.gcc_64_kit - 0 - 0 - 0 - - /home/matt/Documents/build-olive-Desktop_Qt_5_5_1_GCC_64bit-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/matt/build-olive-Desktop_Qt_5_5_1_GCC_64bit-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - /home/matt/build-olive-Desktop_Qt_5_5_1_GCC_64bit-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - Profile - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy Configuration - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - olive - - Qt4ProjectManager.Qt4RunConfiguration:/home/matt/olive/olive.pro - true - - olive.pro - false - - /home/matt/Documents/build-olive-Desktop_Qt_5_5_1_GCC_64bit-Debug - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - + + + + + + EnvironmentId + {3af06612-75ce-48d7-b444-7dc372f1566d} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.11.0 MSVC2017 64bit + Desktop Qt 5.11.0 MSVC2017 64bit + qt.qt5.5110.win64_msvc2017_64_kit + 0 + 0 + 0 + + C:/Users/Matt/Documents/temp + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + C:/Users/Matt/Desktop/build-olive-Desktop_Qt_5_11_0_MSVC2017_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + C:/Users/Matt/Desktop/build-olive-Desktop_Qt_5_11_0_MSVC2017_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + olive + + Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Matt/Desktop/olive/olive.pro + true + + olive.pro + false + + C:/Users/Matt/Documents/temp + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/project/sequence.cpp b/project/sequence.cpp index 813f01a73..0c71a8f58 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -45,14 +45,14 @@ void Sequence::delete_clip(int i) { } long Sequence::getEndFrame() { - long end = 0; - for (int j=0;jtimeline_out > end) { end = c->timeline_out; - } - } - return end; + } + } + return end; } void Sequence::get_track_limits(int* video_tracks, int* audio_tracks) { diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 823385b25..78a44261b 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -760,11 +760,16 @@ int color_brightness(int r, int g, int b) { } void TimelineWidget::redraw_clips() { + qDebug() << "redraw called"; + // Draw clips int panel_width = panel_timeline->getScreenPointFromFrame(sequence->getEndFrame()) + 100; - setMinimumWidth(panel_width); - clip_pixmap = QPixmap(panel_width, height()); + if (minimumWidth() != panel_width) { + setMinimumWidth(panel_width); + clip_pixmap = QPixmap(panel_width, height()); + } + clip_pixmap.fill(Qt::transparent); QPainter clip_painter(&clip_pixmap); int video_track_limit = 0; @@ -782,41 +787,41 @@ void TimelineWidget::redraw_clips() { clip_painter.fillRect(clip_rect, QColor(clip->color_r, clip->color_g, clip->color_b)); // draw thumbnail/waveform - if (clip->media_stream->preview_lock.tryLock()) { - if (clip->media_stream->preview_done) { - if (clip->track < 0) { - int thumb_y = clip_painter.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; - int thumb_height = clip_rect.height()-thumb_y; - if (thumb_height > thumb_y) { // at small clip heights, don't even draw it - QRect thumb_rect(clip_rect.x(), clip_rect.y()+thumb_y, (thumb_height*((float)clip->media_stream->preview.width()/(float)clip->media_stream->preview.height())), thumb_height); - clip_painter.drawImage(thumb_rect, clip->media_stream->preview); - } - } else { - long length = clip->media->get_length_in_frames(clip->sequence->frame_rate); - int waveform_x = ((float)clip->clip_in/(float)length) * clip->media_stream->preview.width(); - int waveform_width = (((float)clip->getLength()/(float)length) * clip->media_stream->preview.width()); - qDebug() << waveform_x << waveform_width; - QRect source(waveform_x, 0, waveform_width, clip->media_stream->preview.height()); - clip_painter.drawImage(clip_rect, clip->media_stream->preview, source); + if (clip->media_stream->preview_done) { + if (clip->track < 0) { + int thumb_y = clip_painter.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; + int thumb_height = clip_rect.height()-thumb_y; + int thumb_width = (thumb_height*((float)clip->media_stream->preview.width()/(float)clip->media_stream->preview.height())); + if (thumb_height > thumb_y && clip_rect.width() > thumb_width) { // at small clip heights, don't even draw it + QRect thumb_rect(clip_rect.x(), clip_rect.y()+thumb_y, thumb_width, thumb_height); + clip_painter.drawImage(thumb_rect, clip->media_stream->preview); } + } else { + long length = clip->media->get_length_in_frames(clip->sequence->frame_rate); + int waveform_x = ((float)clip->clip_in/(float)length) * clip->media_stream->preview.width(); + int waveform_width = (((float)clip->getLength()/(float)length) * clip->media_stream->preview.width()); + QRect source(waveform_x, 0, waveform_width, clip->media_stream->preview.height()); + clip_painter.drawImage(clip_rect, clip->media_stream->preview, source); } - clip->media_stream->preview_lock.unlock(); } + // top left bevel clip_painter.setPen(Qt::white); clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft()); clip_painter.drawLine(clip_rect.topLeft(), clip_rect.topRight()); - clip_painter.setPen(Qt::gray); - clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight()); - clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight()); + // draw text if (color_brightness(clip->color_r, clip->color_g, clip->color_b) > 160) { + // set to black if color is bright clip_painter.setPen(Qt::black); - } else { - clip_painter.setPen(Qt::white); } QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING, clip_rect.height() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING); clip_painter.drawText(text_rect, 0, clip->name, &text_rect); + + // bottom right gray + clip_painter.setPen(Qt::gray); + clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight()); + clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight()); } }