compare_codecs.cc (2538B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #include <stdlib.h> 7 8 #include <QApplication> 9 #include <QCommandLineParser> 10 #include <QMessageBox> 11 #include <QString> 12 #include <QStringList> 13 14 #include "tools/comparison_viewer/codec_comparison_window.h" 15 16 int main(int argc, char** argv) { 17 QApplication application(argc, argv); 18 19 QCommandLineParser parser; 20 parser.setApplicationDescription( 21 QCoreApplication::translate("compare_codecs", "Codec comparison tool")); 22 parser.addHelpOption(); 23 24 QCommandLineOption intensityTargetOption( 25 {"intensity-target", "intensity_target", "i"}, 26 QCoreApplication::translate("compare_codecs", 27 "The peak luminance of the display."), 28 QCoreApplication::translate("compare_codecs", "nits"), 29 QString::number(jxl::kDefaultIntensityTarget)); 30 parser.addOption(intensityTargetOption); 31 32 parser.addPositionalArgument( 33 "folders", QCoreApplication::translate("compare_codecs", "Image folders"), 34 "<folders>..."); 35 36 parser.process(application); 37 38 bool ok; 39 const float intensityTarget = 40 parser.value(intensityTargetOption).toFloat(&ok); 41 if (!ok) { 42 parser.showHelp(EXIT_FAILURE); 43 } 44 45 QStringList folders = parser.positionalArguments(); 46 47 if (folders.empty()) { 48 QMessageBox message; 49 message.setIcon(QMessageBox::Information); 50 message.setWindowTitle( 51 QCoreApplication::translate("CodecComparisonWindow", "Usage")); 52 message.setText(QCoreApplication::translate( 53 "CodecComparisonWindow", "Please specify a directory to use.")); 54 message.setDetailedText(QCoreApplication::translate( 55 "CodecComparisonWindow", 56 "That directory should contain images in the following layout:\n" 57 "- .../<image name>/original.png (optional)\n" 58 "- .../<image_name>/<codec_name>/<compression_level>.<ext>\n" 59 "- .../<image_name>/<codec_name>/<compression_level>.png (optional for " 60 "formats that Qt can load)\n" 61 "With arbitrary nesting allowed before that. (The \"...\" part is " 62 "referred to as an \"image set\" by the tool.")); 63 message.exec(); 64 return EXIT_FAILURE; 65 } 66 67 for (const QString& folder : folders) { 68 auto* const window = 69 new jpegxl::tools::CodecComparisonWindow(folder, intensityTarget); 70 window->setAttribute(Qt::WA_DeleteOnClose); 71 window->show(); 72 } 73 74 return application.exec(); 75 }