Skip to content

Commit

Permalink
Merge pull request #439 from happycube/issue-433
Browse files Browse the repository at this point in the history
Fix for issue #433
  • Loading branch information
Simon Inns committed Jan 25, 2020
2 parents d33a636 + 263427d commit 45f2eb0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
16 changes: 8 additions & 8 deletions tools/ld-analyse/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16pt; font-weight:600;">ld-analyse</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">ld-decode TBC output analysis application</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">(c) 2018-2019 Simon Inns</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">https://www.domesday86.com</span></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Released under the GPLv3</span></p>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Open-source software&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:16pt; font-weight:600;&quot;&gt;ld-analyse&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;ld-decode TBC output analysis application&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;(c) 2018-2020 Simon Inns&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;https://www.domesday86.com&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;Released under the GPLv3&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;Open-source software&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>
Expand Down
12 changes: 9 additions & 3 deletions tools/ld-analyse/tbcsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
tbcsource.cpp
ld-analyse - TBC output analysis
Copyright (C) 2018-2019 Simon Inns
Copyright (C) 2018-2020 Simon Inns
This file is part of ld-decode-tools.
Expand Down Expand Up @@ -746,8 +746,14 @@ void TbcSource::generateData(qint32 _targetDataPoints)
// Calculate the Capture Quality Index
qreal fieldDoPercent = 100.0 - (static_cast<qreal>(doLength) / static_cast<qreal>(totalDotsPerField * fieldsPerGraphDataPoint));
qreal snrPercent = 0;
if (whiteSnrTotal != 0) snrPercent = (100.0 / 90.0) * (blackSnrTotal + whiteSnrTotal);
else snrPercent = (100.0 / 45.0) * (blackSnrTotal);

// Convert SNR to linear
qreal whiteSnrLinear = pow(whiteSnrTotal / 20, 10);
qreal blackSnrLinear = pow(blackSnrTotal / 20, 10);
qreal snrReferenceLinear = pow(43.0 / 20, 10); // Note: 43 dB is the expected maximum

if (whiteSnrTotal != 0) snrPercent = (100.0 / (snrReferenceLinear * 2)) * (blackSnrLinear + whiteSnrLinear);
else snrPercent = (100.0 / snrReferenceLinear) * blackSnrLinear;
if (snrPercent > 100.0) snrPercent = 100.0;

// Note: The weighting is 1000:1:1 - this is just because dropouts have a greater visual effect
Expand Down
17 changes: 11 additions & 6 deletions tools/ld-discmap/discmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,16 @@ DiscMap::DiscMap(const QFileInfo &metadataFileInfo, const bool &reverseFieldOrde
else penaltyPercent = 100.0;
}

// Add the Black SNR to the quality value (here we consider 45+45 to be 100%)
qint32 bsnr = ldDecodeMetaData->getFieldVitsMetrics(ldDecodeMetaData->getFirstFieldNumber(frameNumber + 1)).bPSNR +
ldDecodeMetaData->getFieldVitsMetrics(ldDecodeMetaData->getSecondFieldNumber(frameNumber + 1)).bPSNR;
// Add the Black SNR to the quality value
// Get the average bPSNR for both fields
qreal bsnr = (ldDecodeMetaData->getFieldVitsMetrics(ldDecodeMetaData->getFirstFieldNumber(frameNumber + 1)).bPSNR +
ldDecodeMetaData->getFieldVitsMetrics(ldDecodeMetaData->getSecondFieldNumber(frameNumber + 1)).bPSNR) / 2.0;

qreal bsnrPercent = (100 / 90) * static_cast<qreal>(bsnr);
// Convert logarithmic to linear and then into percentage
qreal blackSnrLinear = pow(bsnr / 20, 10);
qreal snrReferenceLinear = pow(43.0 / 20, 10); // Note: 43 dB is the expected maximum
qreal bsnrPercent = (100.0 / snrReferenceLinear) * blackSnrLinear;
if (bsnrPercent > 100.0) bsnrPercent = 100.0;

// Calculate the cumulative length of all the dropouts in the frame (by summing both fields)
qint32 totalDotsInFrame = (ldDecodeMetaData->getVideoParameters().fieldHeight * 2) + ldDecodeMetaData->getVideoParameters().fieldWidth;
Expand All @@ -296,8 +301,8 @@ DiscMap::DiscMap(const QFileInfo &metadataFileInfo, const bool &reverseFieldOrde
qint32 syncConfPercent = (ldDecodeMetaData->getField(ldDecodeMetaData->getFirstFieldNumber(frameNumber + 1)).syncConf +
ldDecodeMetaData->getField(ldDecodeMetaData->getSecondFieldNumber(frameNumber + 1)).syncConf) / 2;

m_frames[frameNumber].frameQuality((bsnrPercent + penaltyPercent + syncConfPercent + (frameDoPercent * 1000.0)) / 1004.0);
//qDebug() << "Frame:" << frameNumber << bsnrPercent << penaltyPercent << syncConfPercent << frameDoPercent << "quality =" << m_frames[frameNumber].frameQuality();
m_frames[frameNumber].frameQuality((bsnrPercent + penaltyPercent + static_cast<qreal>(syncConfPercent) + (frameDoPercent * 1000.0)) / 1004.0);
qDebug() << "Frame:" << frameNumber << bsnrPercent << penaltyPercent << syncConfPercent << frameDoPercent << "quality =" << m_frames[frameNumber].frameQuality();
}

}
Expand Down
1 change: 1 addition & 0 deletions tools/ld-discmap/discmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QCoreApplication>
#include <QDebug>
#include <QtMath>

// TBC library includes
#include "lddecodemetadata.h"
Expand Down

0 comments on commit 45f2eb0

Please sign in to comment.