libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

codec_comparison_window.h (2305B)


      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 #ifndef TOOLS_COMPARISON_VIEWER_CODEC_COMPARISON_WINDOW_H_
      7 #define TOOLS_COMPARISON_VIEWER_CODEC_COMPARISON_WINDOW_H_
      8 
      9 #include <QDir>
     10 #include <QMainWindow>
     11 #include <QMap>
     12 #include <QSet>
     13 #include <QString>
     14 
     15 #include "lib/jxl/base/common.h"
     16 #include "tools/comparison_viewer/ui_codec_comparison_window.h"
     17 
     18 namespace jpegxl {
     19 namespace tools {
     20 
     21 class CodecComparisonWindow : public QMainWindow {
     22   Q_OBJECT
     23 
     24  public:
     25   explicit CodecComparisonWindow(
     26       const QString& directory,
     27       float intensityTarget = jxl::kDefaultIntensityTarget,
     28       QWidget* parent = nullptr);
     29   ~CodecComparisonWindow() override = default;
     30 
     31  private slots:
     32   void handleImageSetSelection(const QString& imageSetName);
     33   void handleImageSelection(const QString& imageName);
     34 
     35  private:
     36   struct ComparableImage {
     37     // Absolute path to the decoded PNG (or an image that Qt can read).
     38     QString decodedImagePath;
     39     // Size of the encoded image (*not* the PNG).
     40     qint64 byteSize = 0;
     41   };
     42   // Keys are compression levels.
     43   using Codec = QMap<QString, ComparableImage>;
     44   // Keys are codec names.
     45   using Codecs = QMap<QString, Codec>;
     46   // Keys are image names (relative to the image set directory).
     47   using ImageSet = QMap<QString, Codecs>;
     48   // Keys are paths to image sets (relative to the base directory chosen by the
     49   // user).
     50   using ImageSets = QMap<QString, ImageSet>;
     51 
     52   enum class Side { LEFT, RIGHT };
     53 
     54   QString pathToOriginalImage(const QString& imageSet,
     55                               const QString& imageName) const;
     56   ComparableImage currentlySelectedImage(Side side) const;
     57 
     58   void handleCodecChange(Side side);
     59   void updateSideImage(Side side);
     60   void matchSize(Side side);
     61 
     62   void loadDirectory(const QString& directory);
     63   // Recursive, called by loadDirectory.
     64   void browseDirectory(const QDir& directory, int depth = 0);
     65 
     66   Ui::CodecComparisonWindow ui_;
     67 
     68   QDir baseDirectory_;
     69   ImageSets imageSets_;
     70   QSet<QString> visited_;
     71 
     72   const float intensityTarget_;
     73   const QByteArray monitorIccProfile_;
     74 };
     75 
     76 }  // namespace tools
     77 }  // namespace jpegxl
     78 
     79 #endif  // TOOLS_COMPARISON_VIEWER_CODEC_COMPARISON_WINDOW_H_