Skip to content

Commit

Permalink
Added further source availablity checks to ld-diffdod
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Inns committed Jan 3, 2020
1 parent 98aac24 commit 1f15828
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/ld-diffdod/diffdod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ bool Diffdod::process(QVector<QString> inputFilenames, bool reverse,
length = tbcSources.getMaximumVbiFrameNumber() - vbiStartFrame + 1;
if (length == -1) length = tbcSources.getMaximumVbiFrameNumber() - tbcSources.getMinimumVbiFrameNumber() + 1;

// Verify frame source availablity
qInfo() << "";
qInfo() << "Verifying VBI frame multi-source availablity:";
tbcSources.verifySources(vbiStartFrame, length);

qInfo() << "Processing" << length << "frames starting from VBI frame" << vbiStartFrame;
if (!tbcSources.saveSources(vbiStartFrame, length, dodThreshold, noLumaClip)) {
qCritical() << "Saving source failed!";
Expand Down
26 changes: 26 additions & 0 deletions tools/ld-diffdod/tbcsources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,32 @@ qint32 TbcSources::getMaximumVbiFrameNumber()
return maximumFrameNumber;
}

// Verify that at least 3 sources are available for every VBI frame
void TbcSources::verifySources(qint32 vbiStartFrame, qint32 length)
{
qint32 uncorrectableFrameCount = 0;

// Process the sources frame by frame
for (qint32 vbiFrame = vbiStartFrame; vbiFrame < vbiStartFrame + length; vbiFrame++) {
// Check how many source frames are available for the current frame
QVector<qint32> availableSourcesForFrame = getAvailableSourcesForFrame(vbiFrame);

// DiffDOD requires at least three source frames. If 3 sources are not available leave any existing DO records in place
// and output a warning to the user
if (availableSourcesForFrame.size() < 3) {
// Differential DOD requires at least 3 valid source frames
qInfo().nospace() << "Frame #" << vbiFrame << " has only " << availableSourcesForFrame.size() << " source frames available - cannot correct";
uncorrectableFrameCount++;
}
}

if (uncorrectableFrameCount != 0) {
qInfo() << "Warning:" << uncorrectableFrameCount << "frame(s) cannot be corrected!";
} else {
qInfo() << "All frames have at least 3 sources available";
}
}

// Private methods ----------------------------------------------------------------------------------------------------

// Perform differential dropout detection to determine (for each source) which frame pixels are valid
Expand Down
1 change: 1 addition & 0 deletions tools/ld-diffdod/tbcsources.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TbcSources : public QObject
qint32 getNumberOfAvailableSources();
qint32 getMinimumVbiFrameNumber();
qint32 getMaximumVbiFrameNumber();
void verifySources(qint32 vbiStartFrame, qint32 length);

private:
// Source definition
Expand Down

0 comments on commit 1f15828

Please sign in to comment.