From 8289dc8ea032993194c9e567497d46274dc4282c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 12 Jan 2019 15:31:58 +1100 Subject: [PATCH] minor enhancements --- dialogs/debugdialog.cpp | 3 ++- io/exportthread.cpp | 41 ++++++++++++++++++++++------------------- olive.pro | 2 -- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index f9080a50a..9422e56c1 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -8,12 +8,13 @@ DebugDialog* debug_dialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("Debug Log")); + setWindowTitle(tr("Debug Log")); QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); textEdit = new QTextEdit(); + textEdit->setWordWrapMode(QTextOption::NoWrap); layout->addWidget(textEdit); } diff --git a/io/exportthread.cpp b/io/exportthread.cpp index b1153702e..0931b12f3 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -49,7 +49,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, ret = avcodec_send_frame(codec_ctx, frame); if (ret < 0) { qCritical() << "Failed to send frame to encoder." << ret; - ed->export_error = tr("failed to send frame to encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("failed to send frame to encoder (%1)").arg(QString::number(ret)); return false; } @@ -60,7 +60,7 @@ bool ExportThread::encode(AVFormatContext* ofmt_ctx, AVCodecContext* codec_ctx, } else if (ret < 0) { if (ret != AVERROR_EOF) { qCritical() << "Failed to receive packet from encoder." << ret; - ed->export_error = tr("failed to receive packet from encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("failed to receive packet from encoder (%1)").arg(QString::number(ret)); } return false; } @@ -81,7 +81,7 @@ bool ExportThread::setupVideo() { vcodec = avcodec_find_encoder((enum AVCodecID) video_codec); if (!vcodec) { qCritical() << "Could not find video encoder"; - ed->export_error = tr("could not video encoder for %1").arg(QString::number(video_codec)); + ed->export_error = tr("could not video encoder for %1").arg(QString::number(video_codec)); return false; } @@ -90,7 +90,7 @@ bool ExportThread::setupVideo() { video_stream->id = 0; if (!video_stream) { qCritical() << "Could not allocate video stream"; - ed->export_error = tr("could not allocate video stream"); + ed->export_error = tr("could not allocate video stream"); return false; } @@ -99,7 +99,7 @@ bool ExportThread::setupVideo() { vcodec_ctx = avcodec_alloc_context3(vcodec); if (!vcodec_ctx) { qCritical() << "Could not allocate video encoding context"; - ed->export_error = tr("could not allocate video encoding context"); + ed->export_error = tr("could not allocate video encoding context"); return false; } @@ -133,10 +133,13 @@ bool ExportThread::setupVideo() { } } - ret = avcodec_open2(vcodec_ctx, vcodec, nullptr); + AVDictionary* opts = nullptr; + av_dict_set(&opts, "threads", "auto", 0); + + ret = avcodec_open2(vcodec_ctx, vcodec, &opts); if (ret < 0) { qCritical() << "Could not open output video encoder." << ret; - ed->export_error = tr("could not open output video encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output video encoder (%1)").arg(QString::number(ret)); return false; } @@ -144,7 +147,7 @@ bool ExportThread::setupVideo() { ret = avcodec_parameters_from_context(video_stream->codecpar, vcodec_ctx); if (ret < 0) { qCritical() << "Could not copy video encoder parameters to output stream." << ret; - ed->export_error = tr("could not copy video encoder parameters to output stream (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not copy video encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -188,7 +191,7 @@ bool ExportThread::setupAudio() { acodec = avcodec_find_encoder(static_cast(audio_codec)); if (!acodec) { qCritical() << "Could not find audio encoder"; - ed->export_error = tr("could not audio encoder for %1").arg(QString::number(audio_codec)); + ed->export_error = tr("could not audio encoder for %1").arg(QString::number(audio_codec)); return false; } @@ -197,7 +200,7 @@ bool ExportThread::setupAudio() { audio_stream->id = 1; if (!audio_stream) { qCritical() << "Could not allocate audio stream"; - ed->export_error = tr("could not allocate audio stream"); + ed->export_error = tr("could not allocate audio stream"); return false; } @@ -206,7 +209,7 @@ bool ExportThread::setupAudio() { acodec_ctx = avcodec_alloc_context3(acodec); if (!acodec_ctx) { qCritical() << "Could not find allocate audio encoding context"; - ed->export_error = tr("could not allocate audio encoding context"); + ed->export_error = tr("could not allocate audio encoding context"); return false; } @@ -231,7 +234,7 @@ bool ExportThread::setupAudio() { ret = avcodec_open2(acodec_ctx, acodec, nullptr); if (ret < 0) { qCritical() << "Could not open output audio encoder." << ret; - ed->export_error = tr("could not open output audio encoder (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output audio encoder (%1)").arg(QString::number(ret)); return false; } @@ -239,7 +242,7 @@ bool ExportThread::setupAudio() { ret = avcodec_parameters_from_context(audio_stream->codecpar, acodec_ctx); if (ret < 0) { qCritical() << "Could not copy audio encoder parameters to output stream." << ret; - ed->export_error = tr("could not copy audio encoder parameters to output stream (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not copy audio encoder parameters to output stream (%1)").arg(QString::number(ret)); return false; } @@ -269,7 +272,7 @@ bool ExportThread::setupAudio() { ret = av_frame_get_buffer(audio_frame, 0); if (ret < 0) { qCritical() << "Could not allocate audio buffer." << ret; - ed->export_error = tr("could not allocate audio buffer (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not allocate audio buffer (%1)").arg(QString::number(ret)); return false; } aframe_bytes = av_samples_get_buffer_size(nullptr, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); @@ -291,7 +294,7 @@ bool ExportThread::setupContainer() { avformat_alloc_output_context2(&fmt_ctx, nullptr, nullptr, c_filename); if (!fmt_ctx) { qCritical() << "Could not create output context"; - ed->export_error = tr("could not create output format context"); + ed->export_error = tr("could not create output format context"); return false; } @@ -300,7 +303,7 @@ bool ExportThread::setupContainer() { ret = avio_open(&fmt_ctx->pb, c_filename, AVIO_FLAG_WRITE); if (ret < 0) { qCritical() << "Could not open output file." << ret; - ed->export_error = tr("could not open output file (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not open output file (%1)").arg(QString::number(ret)); return false; } @@ -312,7 +315,7 @@ void ExportThread::run() { if (!panel_sequence_viewer->viewer_widget->context()->makeCurrent(&surface)) { qCritical() << "Make current failed"; - ed->export_error = tr("could not make OpenGL context current"); + ed->export_error = tr("could not make OpenGL context current"); return; } @@ -331,7 +334,7 @@ void ExportThread::run() { ret = avformat_write_header(fmt_ctx, nullptr); if (ret < 0) { qCritical() << "Could not write output file header." << ret; - ed->export_error = tr("could not write output file header (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not write output file header (%1)").arg(QString::number(ret)); continueEncode = false; } } @@ -440,7 +443,7 @@ void ExportThread::run() { ret = av_write_trailer(fmt_ctx); if (ret < 0) { qCritical() << "Could not write output file trailer." << ret; - ed->export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret)); + ed->export_error = tr("could not write output file trailer (%1)").arg(QString::number(ret)); continueEncode = false; } diff --git a/olive.pro b/olive.pro index 116daabcf..e47ba1c0a 100644 --- a/olive.pro +++ b/olive.pro @@ -27,8 +27,6 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 -QMAKE_CXXFLAGS += -std=c++11 -Wextra -Wshadow -Wnon-virtual-dtor -pedantic - # Tries to get the current Git short hash system("which git") { GITHASHVAR = $$system(git --git-dir $$PWD/.git --work-tree $$PWD log -1 --format=%h)