Skip to content

Commit

Permalink
Preview: switch outputs 0-9 by num keys
Browse files Browse the repository at this point in the history
BUG REPORT PLEASE
Restrictions:
    - Can only switch among 0-9
    - Can only switch when not during playback
    - Script checking, encoding, benchmarking and jobs will be using output index 0 ONLY
Note to self:
    - VSScript doesn't list output nodes like in Python
    - Some members are extended to arrays with length 10 to prevent a messy cache management but there might still be bugs to be found
  • Loading branch information
YomikoR committed Nov 11, 2021
1 parent 44d9188 commit 6ee67d4
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 81 deletions.
2 changes: 1 addition & 1 deletion common-src/jobs/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ bool vsedit::Job::initialize()
{
bool scriptProcessorInitialized =
m_pVapourSynthScriptProcessor->initialize(
m_properties.scriptText, m_properties.scriptName);
m_properties.scriptText, m_properties.scriptName, 0);
if(!scriptProcessorInitialized)
{
emit signalLogMessage(tr("Failed to initialize script.\n%1")
Expand Down
10 changes: 10 additions & 0 deletions common-src/settings/settings_definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ const char ACTION_ID_TOGGLE_COMMENT[] = "toggle_comment";
const char ACTION_ID_SHUTDOWN_SERVER_AND_EXIT[] = "shutdown_server_and_exit";
const char ACTION_ID_SET_TRUSTED_CLIENTS_ADDRESSES[] =
"set_trusted_clients_addresses";
const char ACTION_ID_SET_OUTPUT_INDEX_0[] = "switch_to_output_index_0";
const char ACTION_ID_SET_OUTPUT_INDEX_1[] = "switch_to_output_index_1";
const char ACTION_ID_SET_OUTPUT_INDEX_2[] = "switch_to_output_index_2";
const char ACTION_ID_SET_OUTPUT_INDEX_3[] = "switch_to_output_index_3";
const char ACTION_ID_SET_OUTPUT_INDEX_4[] = "switch_to_output_index_4";
const char ACTION_ID_SET_OUTPUT_INDEX_5[] = "switch_to_output_index_5";
const char ACTION_ID_SET_OUTPUT_INDEX_6[] = "switch_to_output_index_6";
const char ACTION_ID_SET_OUTPUT_INDEX_7[] = "switch_to_output_index_7";
const char ACTION_ID_SET_OUTPUT_INDEX_8[] = "switch_to_output_index_8";
const char ACTION_ID_SET_OUTPUT_INDEX_9[] = "switch_to_output_index_9";

//==============================================================================

Expand Down
10 changes: 10 additions & 0 deletions common-src/settings/settings_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ extern const char ACTION_ID_MOVE_TEXT_BLOCK_DOWN[];
extern const char ACTION_ID_TOGGLE_COMMENT[];
extern const char ACTION_ID_SHUTDOWN_SERVER_AND_EXIT[];
extern const char ACTION_ID_SET_TRUSTED_CLIENTS_ADDRESSES[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_0[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_1[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_2[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_3[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_4[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_5[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_6[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_7[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_8[];
extern const char ACTION_ID_SET_OUTPUT_INDEX_9[];

//==============================================================================

Expand Down
20 changes: 20 additions & 0 deletions common-src/settings/settings_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,26 @@ void SettingsManager::initializeStandardActions()
QIcon(":exit.png"), QKeySequence()},
{ACTION_ID_SET_TRUSTED_CLIENTS_ADDRESSES,
tr("Set trusted clients addresses"), QIcon(), QKeySequence()},
{ACTION_ID_SET_OUTPUT_INDEX_0, tr("Switch to output index 0"),
QIcon(), QKeySequence(Qt::Key_0)},
{ACTION_ID_SET_OUTPUT_INDEX_1, tr("Switch to output index 1"),
QIcon(), QKeySequence(Qt::Key_1)},
{ACTION_ID_SET_OUTPUT_INDEX_2, tr("Switch to output index 2"),
QIcon(), QKeySequence(Qt::Key_2)},
{ACTION_ID_SET_OUTPUT_INDEX_3, tr("Switch to output index 3"),
QIcon(), QKeySequence(Qt::Key_3)},
{ACTION_ID_SET_OUTPUT_INDEX_4, tr("Switch to output index 4"),
QIcon(), QKeySequence(Qt::Key_4)},
{ACTION_ID_SET_OUTPUT_INDEX_5, tr("Switch to output index 5"),
QIcon(), QKeySequence(Qt::Key_5)},
{ACTION_ID_SET_OUTPUT_INDEX_6, tr("Switch to output index 6"),
QIcon(), QKeySequence(Qt::Key_6)},
{ACTION_ID_SET_OUTPUT_INDEX_7, tr("Switch to output index 7"),
QIcon(), QKeySequence(Qt::Key_7)},
{ACTION_ID_SET_OUTPUT_INDEX_8, tr("Switch to output index 8"),
QIcon(), QKeySequence(Qt::Key_8)},
{ACTION_ID_SET_OUTPUT_INDEX_9, tr("Switch to output index 9"),
QIcon(), QKeySequence(Qt::Key_9)},
};
}

Expand Down
14 changes: 8 additions & 6 deletions common-src/vapoursynth/vapoursynth_script_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ VapourSynthScriptProcessor::~VapourSynthScriptProcessor()
//==============================================================================

bool VapourSynthScriptProcessor::initialize(const QString& a_script,
const QString& a_scriptName)
const QString& a_scriptName, int a_outputIndex)
{
if(m_initialized || m_finalizing)
{
Expand Down Expand Up @@ -119,10 +119,12 @@ bool VapourSynthScriptProcessor::initialize(const QString& a_script,
return false;
}

VSNodeRef * pOutputNode = m_pVSScriptLibrary->getOutput(m_pVSScript, 0);
VSNodeRef * pOutputNode = m_pVSScriptLibrary->getOutput(
m_pVSScript, a_outputIndex);
if(!pOutputNode)
{
m_error = tr("Failed to get the script output node.");
m_error = tr("Failed to get the script output node with index %1.")
.arg(a_outputIndex);
emit signalWriteLogMessage(mtCritical, m_error);
finalize();
return false;
Expand All @@ -144,7 +146,7 @@ bool VapourSynthScriptProcessor::initialize(const QString& a_script,
}

// END OF bool VapourSynthScriptProcessor::initialize(const QString& a_script,
// const QString& a_scriptName)
// const QString& a_scriptName, int a_outputIndex)
//==============================================================================

bool VapourSynthScriptProcessor::finalize()
Expand Down Expand Up @@ -216,7 +218,7 @@ const VSVideoInfo * VapourSynthScriptProcessor::videoInfo(int a_outputIndex)
m_pVSScriptLibrary->getOutput(m_pVSScript, a_outputIndex);
if(!pNode)
{
m_error = tr("Couldn't resolve output node number %1.")
m_error = tr("Couldn't resolve output node index %1.")
.arg(a_outputIndex);
emit signalWriteLogMessage(mtCritical, m_error);
return nullptr;
Expand Down Expand Up @@ -784,7 +786,7 @@ NodePair & VapourSynthScriptProcessor::getNodePair(int a_outputIndex,
m_pVSScriptLibrary->getOutput(m_pVSScript, a_outputIndex);
if(!nodePair.pOutputNode)
{
m_error = tr("Couldn't resolve output node number %1.")
m_error = tr("Couldn't resolve output node index %1.")
.arg(a_outputIndex);
emit signalWriteLogMessage(mtCritical, m_error);
return nodePair;
Expand Down
3 changes: 2 additions & 1 deletion common-src/vapoursynth/vapoursynth_script_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class VapourSynthScriptProcessor : public QObject

virtual ~VapourSynthScriptProcessor();

bool initialize(const QString& a_script, const QString& a_scriptName);
bool initialize(const QString& a_script, const QString& a_scriptName,
int a_outputIndex);

bool finalize();

Expand Down
2 changes: 1 addition & 1 deletion vsedit-job-server-watcher/src/jobs/job_edit_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void JobEditDialog::slotEncodingFramesFromVideoButtonClicked()

VapourSynthScriptProcessor processor(m_pSettingsManager,
m_pVSScriptLibrary);
bool initialized = processor.initialize(script, scriptName);
bool initialized = processor.initialize(script, scriptName, 0);
if(!initialized)
return;

Expand Down
6 changes: 3 additions & 3 deletions vsedit/src/frame_consumers/benchmark_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ void ScriptBenchmarkDialog::call()
m_ui.feedbackTextEdit->addEntry(text);
m_ui.metricsEdit->clear();
int firstFrame = 0;
int lastFrame = m_cpVideoInfo->numFrames - 1;
int lastFrame = m_cpVideoInfo[0]->numFrames - 1;
m_ui.fromFrameSpinBox->setMaximum(lastFrame);
m_ui.toFrameSpinBox->setMaximum(lastFrame);
m_ui.processingProgressBar->setMaximum(m_cpVideoInfo->numFrames);
m_ui.processingProgressBar->setMaximum(m_cpVideoInfo[0]->numFrames);
m_ui.processingProgressBar->setValue(0);

if(m_lastFromFrame >= 0)
Expand Down Expand Up @@ -158,7 +158,7 @@ void ScriptBenchmarkDialog::slotWriteLogMessage(int a_messageType,
void ScriptBenchmarkDialog::slotWholeVideoButtonPressed()
{
Q_ASSERT(m_cpVideoInfo);
int lastFrame = m_cpVideoInfo->numFrames - 1;
int lastFrame = m_cpVideoInfo[0]->numFrames - 1;
m_ui.fromFrameSpinBox->setValue(0);
m_ui.toFrameSpinBox->setValue(lastFrame);
}
Expand Down
2 changes: 1 addition & 1 deletion vsedit/src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void MainWindow::slotCheckScript()
this, SLOT(slotWriteLogMessage(int, const QString &)));

bool correct = tempProcessor.initialize(m_ui.scriptEdit->text(),
m_scriptFilePath);
m_scriptFilePath, 0);
if(correct)
{
QString message = tr("Script was successfully evaluated. "
Expand Down
Loading

0 comments on commit 6ee67d4

Please sign in to comment.