Skip to content

Commit 69f1c0b

Browse files
committed
Changed "mse" to more generic "distortion"
Signed-off-by: Pierre-Anthony Lemieux <pal@sandflow.com>
1 parent e59e603 commit 69f1c0b

6 files changed

Lines changed: 51 additions & 51 deletions

File tree

src/bin/exrmetrics/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) Contributors to the OpenEXR Project.
33

4-
add_openexr_bin_program(exrmetrics SOURCES main.cpp exrmetrics.cpp mseutils.cpp)
4+
add_openexr_bin_program(exrmetrics SOURCES main.cpp exrmetrics.cpp distortionUtils.cpp)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
// Copyright (c) Contributors to the OpenEXR Project.
33

4-
#include "mseutils.h"
4+
#include "distortionUtils.h"
55

66
#include <cmath>
77
#include <limits>
@@ -10,7 +10,7 @@ using IMATH_NAMESPACE::half;
1010

1111
template <>
1212
void
13-
accumMSE<half> (
13+
accumLogMSE<half> (
1414
const half* orig,
1515
const half* reread,
1616
uint64_t pixelsInChannel,
@@ -34,7 +34,7 @@ accumMSE<half> (
3434

3535
template <>
3636
void
37-
accumMSE<float> (
37+
accumLogMSE<float> (
3838
const float* orig,
3939
const float* reread,
4040
uint64_t pixelsInChannel,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
// SPDX-License-Identifier: BSD-3-Clause
22
// Copyright (c) Contributors to the OpenEXR Project.
33

4-
#ifndef INCLUDED_MSE_UTILS_H
5-
#define INCLUDED_MSE_UTILS_H
4+
#ifndef INCLUDED_DISTORTION_UTILS_H
5+
#define INCLUDED_DISTORTION_UTILS_H
66

77
#include <half.h>
88
#include <cstdint>
99

1010
template <typename T>
11-
void accumMSE (
11+
void accumLogMSE (
1212
const T* orig,
1313
const T* reread,
1414
uint64_t pixelsInChannel,
1515
double& sumSq,
1616
uint64_t& count);
1717

1818
template <>
19-
void accumMSE<IMATH_NAMESPACE::half> (
19+
void accumLogMSE<IMATH_NAMESPACE::half> (
2020
const IMATH_NAMESPACE::half* orig,
2121
const IMATH_NAMESPACE::half* reread,
2222
uint64_t pixelsInChannel,
2323
double& sumSq,
2424
uint64_t& count);
2525

2626
template <>
27-
void accumMSE<float> (
27+
void accumLogMSE<float> (
2828
const float* orig,
2929
const float* reread,
3030
uint64_t pixelsInChannel,

src/bin/exrmetrics/exrmetrics.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66

77
#include "exrmetrics.h"
8-
#include "mseutils.h"
8+
#include "distortionUtils.h"
99

1010
#include "ImfChannelList.h"
1111
#include "ImfDeepFrameBuffer.h"
@@ -995,7 +995,7 @@ exrmetrics (
995995
bool reread,
996996
PixelMode pixelMode,
997997
bool verbose,
998-
bool computeMSE)
998+
bool computeDistortion)
999999
{
10001000

10011001
if (verbose)
@@ -1088,7 +1088,7 @@ exrmetrics (
10881088
if (!isinf (level) && level >= -1 && !compressionSet)
10891089
{
10901090
throw runtime_error (
1091-
"-l option only works for DWAA/DWAB,ZIP/ZIPS or ZSTD compression");
1091+
"-l option only works for DWAA/DWAB, HTJ2KL256,ZIP/ZIPS or ZSTD compression");
10921092
}
10931093

10941094
vector<partData> parts (part == -1 ? in.parts () : 1);
@@ -1179,14 +1179,14 @@ exrmetrics (
11791179
}
11801180

11811181
//
1182-
// compute MSE vs. re-read data
1182+
// compute distortion vs. re-read data
11831183
//
1184-
if (computeMSE && write && reread)
1184+
if (computeDistortion && write && reread)
11851185
{
11861186
for (size_t p = 0; p < parts.size (); ++p)
11871187
{
1188-
metrics.stats[p].mseCount = 0;
1189-
metrics.stats[p].mse = std::numeric_limits<double>::quiet_NaN ();
1188+
metrics.stats[p].distortionCount = 0;
1189+
metrics.stats[p].distortion = std::numeric_limits<double>::quiet_NaN ();
11901190
string partType = outHeaders[p].type ();
11911191
if (partType != SCANLINEIMAGE && partType != TILEDIMAGE) continue;
11921192

@@ -1251,8 +1251,8 @@ exrmetrics (
12511251

12521252
if (i.channel ().type == HALF)
12531253
{
1254-
metrics.stats[p].mseKind = MSE_LOG_HALF;
1255-
accumMSE (
1254+
metrics.stats[p].metricKind = LOG_MSE_HALF;
1255+
accumLogMSE (
12561256
reinterpret_cast<const half*> (origData),
12571257
reinterpret_cast<const half*> (rereadData),
12581258
pixelsInChannel,
@@ -1261,8 +1261,8 @@ exrmetrics (
12611261
}
12621262
else if (i.channel ().type == FLOAT)
12631263
{
1264-
metrics.stats[p].mseKind = MSE_LOG_FLOAT;
1265-
accumMSE (
1264+
metrics.stats[p].metricKind = LOG_MSE_FLOAT;
1265+
accumLogMSE (
12661266
reinterpret_cast<const float*> (origData),
12671267
reinterpret_cast<const float*> (rereadData),
12681268
pixelsInChannel,
@@ -1271,8 +1271,8 @@ exrmetrics (
12711271
}
12721272
}
12731273

1274-
metrics.stats[p].mseCount = count;
1275-
metrics.stats[p].mse =
1274+
metrics.stats[p].distortionCount = count;
1275+
metrics.stats[p].distortion =
12761276
count > 0 ? sumSq / count
12771277
: std::numeric_limits<double>::quiet_NaN ();
12781278
}

src/bin/exrmetrics/exrmetrics.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ struct partSizeData
4444
std::string partType = "";
4545
};
4646

47-
enum MSEKind
47+
enum DistortionMetric
4848
{
49-
MSE_NONE,
50-
MSE_LOG_HALF,
51-
MSE_LOG_FLOAT,
49+
DISTORTION_METRIC_NONE,
50+
LOG_MSE_HALF,
51+
LOG_MSE_FLOAT,
5252
};
5353

5454
struct partStats
@@ -65,9 +65,9 @@ struct partStats
6565
rereadPerf; // for deep, times reading the sample count, otherwise times reading the entire data
6666
uint64_t sizeOnDisk = 0; // record compressed size of part on disk.
6767

68-
MSEKind mseKind = MSE_NONE;
69-
double mse = std::numeric_limits<double>::quiet_NaN ();
70-
uint64_t mseCount = 0;
68+
DistortionMetric metricKind = DISTORTION_METRIC_NONE; // kind of distortion metric used
69+
double distortion = std::numeric_limits<double>::quiet_NaN (); // distortion computed using the distortion metric
70+
uint64_t distortionCount = 0; // number of samples used to compute the distortion
7171

7272
partSizeData sizeData;
7373
};
@@ -91,6 +91,6 @@ fileMetrics exrmetrics (
9191
bool reread,
9292
PixelMode pixelMode,
9393
bool verbose,
94-
bool computeMSE = false);
94+
bool computeDistortion = false);
9595

9696
#endif

src/bin/exrmetrics/main.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
6565
" -t n Use a pool of n worker threads for processing files.\n"
6666
" Default is single threaded (no thread pool)\n"
6767
"\n"
68-
" -l level set DWA or ZIP compression level\n"
68+
" -l level set compression level for DWA, ZIP and lossy HTJ2K\n"
6969
"\n"
7070
" -z,--compression list list of compression methods to test\n"
7171
" ("
@@ -92,7 +92,7 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
9292
" --csv print output in csv mode. If passes>1, show median timing\n"
9393
" default is JSON mode\n"
9494
" --passes num write and re-read file num times (default 1)\n"
95-
" --mse compute LogMSE per part, comparing original vs. re-read after compression.\n"
95+
" --distortion compute LogMSE per part, comparing original vs. re-read after compression.\n"
9696
" Parts must have uniform half or float channel types. Samples that are non-finite\n"
9797
" in the original are skipped. Samples that are finite in the original and not finite\n"
9898
" in the re-read result in Nan."
@@ -126,7 +126,7 @@ struct options
126126
bool outputPartSizeOnDisk = false;
127127
bool verbose = false;
128128
bool csv = false;
129-
bool computeMSE = false;
129+
bool computeDistortion = false;
130130
std::vector<PixelMode> pixelModes;
131131
std::vector<OPENEXR_IMF_NAMESPACE::Compression> compressions;
132132

@@ -266,7 +266,7 @@ jsonStats (
266266
bool partSize,
267267
bool raw,
268268
bool stats,
269-
bool computeMSE)
269+
bool computeDistortion)
270270
{
271271

272272
static const char* lastFileName = nullptr;
@@ -393,7 +393,7 @@ jsonStats (
393393
printPartStats (
394394
out, run.metrics.totalStats, " ", timing,false, raw, stats);
395395
}
396-
if (timing && run.metrics.stats.size () > 1 || computeMSE)
396+
if (timing && run.metrics.stats.size () > 1 || computeDistortion)
397397
{
398398
out << ",\n";
399399
out << " \"parts\":\n";
@@ -402,11 +402,11 @@ jsonStats (
402402
{
403403
out << " {\n";
404404
out << " \"part\": " << part;
405-
if (computeMSE)
405+
if (computeDistortion)
406406
{
407407
out << ",\n";
408408
out << " \"" << "log_mse"
409-
<< "\": " << run.metrics.stats[part].mse;
409+
<< "\": " << run.metrics.stats[part].distortion;
410410
}
411411
if (timing)
412412
{
@@ -440,7 +440,7 @@ jsonStats (
440440
}
441441

442442
void
443-
csvStats (ostream& out, list<runData>& data, bool outputSizeData, int timing, bool computeMSE)
443+
csvStats (ostream& out, list<runData>& data, bool outputSizeData, int timing, bool computeDistortion)
444444
{
445445
out << "file name";
446446
if (outputSizeData)
@@ -449,7 +449,7 @@ csvStats (ostream& out, list<runData>& data, bool outputSizeData, int timing, bo
449449
}
450450
out << ",compression,pixel mode";
451451
if (outputSizeData) { out << ",output size"; }
452-
if (computeMSE) { out << ",mse"; }
452+
if (computeDistortion) { out << ",distortion"; }
453453
if (timing & options::TIME_READ)
454454
{
455455
out << ",count read time";
@@ -486,15 +486,15 @@ csvStats (ostream& out, list<runData>& data, bool outputSizeData, int timing, bo
486486
out << ',' << compName << ',' << modeName (run.mode);
487487

488488
if (outputSizeData) { out << ',' << run.metrics.outputFileSize; }
489-
if (computeMSE)
489+
if (computeDistortion)
490490
out << ',';
491491
for (size_t p = 0; p < run.metrics.stats.size (); ++p)
492492
{
493493
if (p > 0) { out << '|'; }
494-
switch (run.metrics.stats[p].mseKind) {
495-
case MSE_LOG_HALF:
496-
case MSE_LOG_FLOAT:
497-
out << "log_mse:" << run.metrics.stats[p].mse;
494+
switch (run.metrics.stats[p].metricKind) {
495+
case LOG_MSE_HALF:
496+
case LOG_MSE_FLOAT:
497+
out << "log_mse:" << run.metrics.stats[p].distortion;
498498
break;
499499
default:
500500
out << "---";
@@ -576,12 +576,12 @@ main (int argc, char** argv)
576576
opts.passes,
577577
opts.outFile || opts.outputSizeData ||
578578
opts.timing & options::TIME_WRITE ||
579-
opts.computeMSE,
579+
opts.computeDistortion,
580580
opts.timing & options::TIME_REREAD ||
581-
opts.computeMSE,
581+
opts.computeDistortion,
582582
mode,
583583
opts.verbose,
584-
opts.computeMSE);
584+
opts.computeDistortion);
585585
data.push_back (d);
586586
}
587587
}
@@ -604,12 +604,12 @@ main (int argc, char** argv)
604604

605605
if (opts.csv)
606606
{
607-
csvStats (cout, data, opts.outputSizeData, opts.timing, opts.computeMSE);
607+
csvStats (cout, data, opts.outputSizeData, opts.timing, opts.computeDistortion);
608608
}
609609
else
610610
{
611611
jsonStats (
612-
cout, data, opts.outputSizeData, opts.timing, showPartSizeOnDisk, true, true, opts.computeMSE);
612+
cout, data, opts.outputSizeData, opts.timing, showPartSizeOnDisk, true, true, opts.computeDistortion);
613613
}
614614
}
615615

@@ -940,9 +940,9 @@ options::parse (int argc, char* argv[])
940940
outputPartSizeOnDisk = true;
941941
i += 1;
942942
}
943-
else if (!strcmp (argv[i], "--mse"))
943+
else if (!strcmp (argv[i], "--distortion"))
944944
{
945-
computeMSE = true;
945+
computeDistortion = true;
946946
i += 1;
947947
}
948948
else if (!strcmp (argv[i], "-i"))

0 commit comments

Comments
 (0)