diff --git a/tools/ld-dropout-correct/correctorpool.cpp b/tools/ld-dropout-correct/correctorpool.cpp index 24ccac09a..3654061e0 100644 --- a/tools/ld-dropout-correct/correctorpool.cpp +++ b/tools/ld-dropout-correct/correctorpool.cpp @@ -4,6 +4,7 @@ ld-dropout-correct - Dropout correction for ld-decode Copyright (C) 2018-2020 Simon Inns + Copyright (C) 2019-2020 Adam Sampson This file is part of ld-decode-tools. @@ -24,8 +25,6 @@ #include "correctorpool.h" -#include - CorrectorPool::CorrectorPool(QString _outputFilename, QString _outputJsonFilename, qint32 _maxThreads, QVector &_ldDecodeMetaData, QVector &_sourceVideos, bool _reverse, bool _intraField, bool _overCorrect, QObject *parent) @@ -83,6 +82,11 @@ bool CorrectorPool::process() // Show some information for the user qInfo() << "Using" << maxThreads << "threads to process" << ldDecodeMetaData[0]->getNumberOfFrames() << "frames"; + // Initialise reporting + sameSourceConcealmentTotal = 0; + multiSourceConcealmentTotal = 0; + multiSourceCorrectionTotal = 0; + // Initialise processing state inputFrameNumber = 1; outputFrameNumber = 1; @@ -246,7 +250,8 @@ bool CorrectorPool::getInputFrame(qint32& frameNumber, bool CorrectorPool::setOutputFrame(qint32 frameNumber, SourceVideo::Data firstTargetFieldData, SourceVideo::Data secondTargetFieldData, qint32 firstFieldSeqNo, qint32 secondFieldSeqNo, - qint32 sameSourceReplacement, qint32 multiSourceReplacement, qint32 totalReplacementDistance) + qint32 sameSourceConcealment, qint32 multiSourceConcealment, + qint32 multiSourceCorrection, qint32 totalReplacementDistance) { QMutexLocker locker(&outputMutex); @@ -258,8 +263,9 @@ bool CorrectorPool::setOutputFrame(qint32 frameNumber, pendingFrame.secondFieldSeqNo = secondFieldSeqNo; // Get statistics - pendingFrame.sameSourceReplacement = sameSourceReplacement; - pendingFrame.multiSourceReplacement = multiSourceReplacement; + pendingFrame.sameSourceConcealment = sameSourceConcealment; + pendingFrame.multiSourceConcealment = multiSourceConcealment; + pendingFrame.multiSourceCorrection = multiSourceCorrection; pendingFrame.totalReplacementDistance = totalReplacementDistance; pendingOutputFrames[frameNumber] = pendingFrame; @@ -290,12 +296,25 @@ bool CorrectorPool::setOutputFrame(qint32 frameNumber, // Show debug qreal avgReplacementDistance = 0; - if (outputFrame.sameSourceReplacement + outputFrame.multiSourceReplacement > 0) { + if (outputFrame.sameSourceConcealment + outputFrame.multiSourceConcealment + outputFrame.multiSourceCorrection > 0) { avgReplacementDistance = static_cast(outputFrame.totalReplacementDistance) / - static_cast(outputFrame.sameSourceReplacement + outputFrame.multiSourceReplacement); + static_cast(outputFrame.sameSourceConcealment + outputFrame.multiSourceConcealment + + outputFrame.multiSourceCorrection); + qDebug().nospace() << "Processed frame " << outputFrameNumber << " with " << outputFrame.sameSourceConcealment + + outputFrame.multiSourceConcealment + + outputFrame.multiSourceCorrection << " changes (" << + outputFrame.sameSourceConcealment << ", " << + outputFrame.multiSourceConcealment << ", " << + outputFrame.multiSourceCorrection << " - avg dist. " << + avgReplacementDistance << ")"; + } else { + qDebug() << "Processed frame" << outputFrameNumber << "- no dropouts"; } - qDebug() << "Processed frame" << outputFrameNumber << "- Replacements" << outputFrame.sameSourceReplacement << "same source," << - outputFrame.multiSourceReplacement << "multi-source - Average replacement distance of" << avgReplacementDistance; + + // Tally the statistics + multiSourceConcealmentTotal += outputFrame.multiSourceConcealment; + multiSourceCorrectionTotal += outputFrame.multiSourceCorrection; + sameSourceConcealmentTotal += outputFrame.sameSourceConcealment; if (outputFrameNumber % 100 == 0) { qInfo() << "Processed and written frame" << outputFrameNumber; @@ -438,3 +457,19 @@ bool CorrectorPool::writeOutputField(const SourceVideo::Data &fieldData) { return targetVideo.write(reinterpret_cast(fieldData.data()), 2 * fieldData.size()); } + +// Getters for reporting +qint32 CorrectorPool::getSameSourceConcealmentTotal() +{ + return sameSourceConcealmentTotal; +} + +qint32 CorrectorPool::getMultiSourceConcealmentTotal() +{ + return multiSourceConcealmentTotal; +} + +qint32 CorrectorPool::getMultiSourceCorrectionTotal() +{ + return multiSourceCorrectionTotal; +} diff --git a/tools/ld-dropout-correct/correctorpool.h b/tools/ld-dropout-correct/correctorpool.h index 28000157f..ffd0f70e2 100644 --- a/tools/ld-dropout-correct/correctorpool.h +++ b/tools/ld-dropout-correct/correctorpool.h @@ -4,6 +4,7 @@ ld-dropout-correct - Dropout correction for ld-decode Copyright (C) 2018-2020 Simon Inns + Copyright (C) 2019-2020 Adam Sampson This file is part of ld-decode-tools. @@ -55,7 +56,12 @@ class CorrectorPool : public QObject bool setOutputFrame(qint32 frameNumber, SourceVideo::Data firstTargetFieldData, SourceVideo::Data secondTargetFieldData, qint32 firstFieldSeqNo, qint32 secondFieldSeqNo, - qint32 sameSourceReplacement, qint32 multiSourceReplacement, qint32 totalReplacementDistance); + qint32 sameSourceReplacement, qint32 multiSourceReplacement, qint32 multiSourceCorrection, qint32 totalReplacementDistance); + + // Reporting methods + qint32 getSameSourceConcealmentTotal(); + qint32 getMultiSourceConcealmentTotal(); + qint32 getMultiSourceCorrectionTotal(); private: QString outputFilename; @@ -87,8 +93,9 @@ class CorrectorPool : public QObject qint32 secondFieldSeqNo; // Statistics - qint32 sameSourceReplacement; - qint32 multiSourceReplacement; + qint32 sameSourceConcealment; + qint32 multiSourceConcealment; + qint32 multiSourceCorrection; qint32 totalReplacementDistance; }; @@ -101,6 +108,11 @@ class CorrectorPool : public QObject QVector sourceMinimumVbiFrame; QVector sourceMaximumVbiFrame; + // Reporting information + qint32 sameSourceConcealmentTotal; + qint32 multiSourceConcealmentTotal; + qint32 multiSourceCorrectionTotal; + bool setMinAndMaxVbiFrames(); qint32 convertSequentialFrameNumberToVbi(qint32 sequentialFrameNumber, qint32 sourceNumber); qint32 convertVbiFrameNumberToSequential(qint32 vbiFrameNumber, qint32 sourceNumber); diff --git a/tools/ld-dropout-correct/dropoutcorrect.cpp b/tools/ld-dropout-correct/dropoutcorrect.cpp index 2989e6b26..977c12536 100644 --- a/tools/ld-dropout-correct/dropoutcorrect.cpp +++ b/tools/ld-dropout-correct/dropoutcorrect.cpp @@ -4,7 +4,7 @@ ld-dropout-correct - Dropout correction for ld-decode Copyright (C) 2018-2020 Simon Inns - Copyright (C) 2019 Adam Sampson + Copyright (C) 2019-2020 Adam Sampson This file is part of ld-decode-tools. @@ -60,8 +60,9 @@ void DropOutCorrect::run() } // Reset statistics - statistics.sameSourceReplacement = 0; - statistics.multiSourceReplacement = 0; + statistics.sameSourceConcealment = 0; + statistics.multiSourceConcealment = 0; + statistics.multiSourceCorrection = 0; statistics.totalReplacementDistance = 0; qint32 totalAvailableSources = firstFieldSeqNo.size(); @@ -113,7 +114,7 @@ void DropOutCorrect::run() // Return the processed fields correctorPool.setOutputFrame(frameNumber, firstFieldData[0], secondFieldData[0], firstFieldSeqNo[0], secondFieldSeqNo[0], - statistics.sameSourceReplacement, statistics.multiSourceReplacement, statistics.totalReplacementDistance); + statistics.sameSourceConcealment, statistics.multiSourceConcealment, statistics.multiSourceCorrection ,statistics.totalReplacementDistance); } } @@ -514,8 +515,12 @@ void DropOutCorrect::correctDropOut(const DropOutLocation &dropOut, } } - // Statistics - if (replacement.sourceNumber == 0) statistics.sameSourceReplacement++; - else statistics.multiSourceReplacement++; + // Update statistics + if (replacement.sourceNumber == 0) statistics.sameSourceConcealment++; + else { + if (replacement.distance == 0) statistics.multiSourceCorrection++; + else statistics.multiSourceConcealment++; + } statistics.totalReplacementDistance += replacement.distance; } + diff --git a/tools/ld-dropout-correct/dropoutcorrect.h b/tools/ld-dropout-correct/dropoutcorrect.h index 449786dfe..159d81fe7 100644 --- a/tools/ld-dropout-correct/dropoutcorrect.h +++ b/tools/ld-dropout-correct/dropoutcorrect.h @@ -4,6 +4,7 @@ ld-dropout-correct - Dropout correction for ld-decode Copyright (C) 2018-2020 Simon Inns + Copyright (C) 2019-2020 Adam Sampson This file is part of ld-decode-tools. @@ -74,8 +75,9 @@ class DropOutCorrect : public QThread // Statistics struct Statistics { - qint32 sameSourceReplacement; - qint32 multiSourceReplacement; + qint32 sameSourceConcealment; + qint32 multiSourceConcealment; + qint32 multiSourceCorrection; qint32 totalReplacementDistance; }; diff --git a/tools/ld-dropout-correct/main.cpp b/tools/ld-dropout-correct/main.cpp index 8a13821f6..b417db5f4 100644 --- a/tools/ld-dropout-correct/main.cpp +++ b/tools/ld-dropout-correct/main.cpp @@ -4,6 +4,7 @@ ld-dropout-correct - Dropout correction for ld-decode Copyright (C) 2018-2020 Simon Inns + Copyright (C) 2019-2020 Adam Sampson This file is part of ld-decode-tools. @@ -77,7 +78,7 @@ int main(int argc, char *argv[]) // Option to select over correct mode (-o) QCommandLineOption setOverCorrectOption(QStringList() << "o" << "overcorrect", - QCoreApplication::translate("main", "Over correct mode (use on heavily damaged sources)")); + QCoreApplication::translate("main", "Over correct mode (use on heavily damaged single sources)")); parser.addOption(setOverCorrectOption); // Force intra-field correction only @@ -293,7 +294,7 @@ int main(int argc, char *argv[]) } if (!videoParameters.isMapped) { - qInfo() << "Source video" << i << "has not been mapped - run ld-discmap on all source video and try again"; + qInfo() << "Source video" << i << "has not been mapped - run ld-discmap on all source videos and try again"; qInfo() << "Multi-source dropout correction relies on accurate VBI frame numbering to match source frames together"; return 1; } @@ -308,6 +309,24 @@ int main(int argc, char *argv[]) reverse, intraField, overCorrect); if (!correctorPool.process()) result = 1; + // Report on the result of the correction process + if (totalNumberOfInputFiles > 1) { + // Multisource correction report + qInfo() << "Multi-source correction from" << totalNumberOfInputFiles << "sources:"; + qInfo() << " Corrections (same source):" << correctorPool.getSameSourceConcealmentTotal(); + qInfo() << " Concealments (multi-source):" << correctorPool.getMultiSourceConcealmentTotal(); + qInfo() << " Corrections (multi-source):" << correctorPool.getMultiSourceCorrectionTotal(); + qInfo() << " Total:" << correctorPool.getSameSourceConcealmentTotal() + + correctorPool.getMultiSourceConcealmentTotal() + + correctorPool.getMultiSourceCorrectionTotal(); + } else { + // Single source correction report + qInfo() << "Single source correction:"; + qInfo() << " Total concealments:" << correctorPool.getSameSourceConcealmentTotal() + + correctorPool.getMultiSourceConcealmentTotal() + + correctorPool.getMultiSourceCorrectionTotal(); + } + // Close open source video files for (qint32 i = 0; i < totalNumberOfInputFiles; i++) sourceVideos[i]->close();