///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
-// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
#include "model_options.h"
#include "model_preferences.h"
#include "model_sysinfo.h"
+#include "model_clipInfo.h"
#include "job_object.h"
#include "mediainfo.h"
log("\nPROCESS ABORTED BY USER !!!"); \
setStatus(JobStatus_Aborted); \
if(QFileInfo(m_outputFileName).exists() && (QFileInfo(m_outputFileName).size() == 0)) QFile::remove(m_outputFileName); \
- return; \
+ return 0; \
} \
else if(!(OK_FLAG)) \
{ \
setStatus(JobStatus_Failed); \
if(QFileInfo(m_outputFileName).exists() && (QFileInfo(m_outputFileName).size() == 0)) QFile::remove(m_outputFileName); \
- return; \
+ return 0; \
} \
} \
while(0)
void EncodeThread::run(void)
{
-#if !defined(_DEBUG)
- __try
- {
- checkedRun();
- }
- __except(1)
+ m_progress = 0;
+ m_status = JobStatus_Starting;
+
+ AbstractThread::run();
+
+ if (m_exception)
{
- qWarning("STRUCTURED EXCEPTION ERROR IN ENCODE THREAD !!!");
+ log(tr("UNHANDLED EXCEPTION ERROR IN THREAD !!!"));
+ setStatus(JobStatus_Failed);
}
-#else
- checkedRun();
-#endif
if(m_jobObject)
{
}
}
-void EncodeThread::checkedRun(void)
-{
- m_progress = 0;
- m_status = JobStatus_Starting;
-
- try
- {
- try
- {
- ExecutionStateHandler executionStateHandler;
- encode();
- }
- catch(const std::exception &e)
- {
- log(tr("EXCEPTION ERROR IN THREAD: ").append(QString::fromLatin1(e.what())));
- setStatus(JobStatus_Failed);
- }
- catch(char *msg)
- {
- log(tr("EXCEPTION ERROR IN THREAD: ").append(QString::fromLatin1(msg)));
- setStatus(JobStatus_Failed);
- }
- catch(...)
- {
- log(tr("UNHANDLED EXCEPTION ERROR IN THREAD !!!"));
- setStatus(JobStatus_Failed);
- }
- }
- catch(...)
- {
- MUtils::OS::fatal_exit(L"Unhandeled exception error in encode thread!");
- }
-}
-
void EncodeThread::start(Priority priority)
{
qDebug("Thread starting...");
m_pause = false;
while(m_semaphorePaused.tryAcquire(1, 0));
- QThread::start(priority);
+ AbstractThread::start(priority);
}
///////////////////////////////////////////////////////////////////////////////
// Encode functions
///////////////////////////////////////////////////////////////////////////////
-void EncodeThread::encode(void)
+int EncodeThread::threadMain(void)
{
QDateTime startTime = QDateTime::currentDateTime();
log(tr("\n--- SETTINGS ---\n"));
log(tr("Encoder : %1").arg(m_encoder->getName()));
log(tr("Source : %1").arg(m_pipedSource ? m_pipedSource->getName() : tr("Native")));
- log(tr("RC Mode : %1").arg(OptionsModel::rcMode2String(m_options->rcMode())));
+ log(tr("RC Mode : %1").arg(m_encoder->getEncoderInfo().rcModeToString(m_options->rcMode())));
log(tr("Preset : %1").arg(m_options->preset()));
log(tr("Tuning : %1").arg(m_options->tune()));
log(tr("Profile : %1").arg(m_options->profile()));
log(tr("Custom : %1").arg(m_options->customEncParams().isEmpty() ? tr("<None>") : m_options->customEncParams()));
bool ok = false;
- unsigned int frames = 0;
+ ClipInfo clipInfo;
// -----------------------------------------------------------------------------------
// Check Versions
if(m_pipedSource)
{
log(tr("\n--- GET SOURCE INFO ---\n"));
- ok = m_pipedSource->checkSourceProperties(frames);
+ ok = m_pipedSource->checkSourceProperties(clipInfo);
CHECK_STATUS(m_abort, ok);
}
// -----------------------------------------------------------------------------------
//Run encoding passes
- if(m_options->rcMode() == OptionsModel::RCMode_2Pass)
+ if(m_encoder->getEncoderInfo().rcModeToType(m_options->rcMode()) == AbstractEncoderInfo::RC_TYPE_MULTIPASS)
{
const QString passLogFile = getPasslogFile(m_outputFileName);
log(tr("\n--- ENCODING PASS #1 ---\n"));
- ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames, 1, passLogFile);
+ ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo, 1, passLogFile);
CHECK_STATUS(m_abort, ok);
log(tr("\n--- ENCODING PASS #2 ---\n"));
- ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames, 2, passLogFile);
+ ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo, 2, passLogFile);
CHECK_STATUS(m_abort, ok);
}
else
{
log(tr("\n--- ENCODING VIDEO ---\n"));
- ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, frames);
+ ok = m_encoder->runEncodingPass(m_pipedSource, m_outputFileName, clipInfo);
CHECK_STATUS(m_abort, ok);
}
int timePassed = startTime.secsTo(QDateTime::currentDateTime());
log(tr("Job finished at %1, %2. Process took %3 minutes, %4 seconds.").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate), QString::number(timePassed / 60), QString::number(timePassed % 60)));
setStatus(JobStatus_Completed);
+
+ return 1; /*completed*/
}
///////////////////////////////////////////////////////////////////////////////
void EncodeThread::log(const QString &text)
{
- emit messageLogged(m_jobId, text);
+ emit messageLogged(m_jobId, QDateTime::currentMSecsSinceEpoch(), text);
}
void EncodeThread::setStatus(const JobStatus &newStatus)