libjxl

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

enc_comparator.h (2114B)


      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 LIB_JXL_ENC_COMPARATOR_H_
      7 #define LIB_JXL_ENC_COMPARATOR_H_
      8 
      9 #include "lib/jxl/base/data_parallel.h"
     10 #include "lib/jxl/base/status.h"
     11 #include "lib/jxl/image.h"
     12 #include "lib/jxl/image_bundle.h"
     13 
     14 namespace jxl {
     15 
     16 class Comparator {
     17  public:
     18   virtual ~Comparator() = default;
     19 
     20   // Sets the reference image, the first to compare
     21   // Image must be in linear sRGB (gamma expanded) in range 0.0f-1.0f as
     22   // the range from standard black point to standard white point, but values
     23   // outside permitted.
     24   virtual Status SetReferenceImage(const ImageBundle& ref) = 0;
     25 
     26   // Sets the actual image (with loss), the second to compare
     27   // Image must be in linear sRGB (gamma expanded) in range 0.0f-1.0f as
     28   // the range from standard black point to standard white point, but values
     29   // outside permitted.
     30   // In diffmap it outputs the local score per pixel, while in score it outputs
     31   // a single score. Any one may be set to nullptr to not compute it.
     32   virtual Status CompareWith(const ImageBundle& actual, ImageF* diffmap,
     33                              float* score) = 0;
     34 
     35   // Quality thresholds for diffmap and score values.
     36   // The good score must represent a value where the images are considered to
     37   // be perceptually indistinguishable (but not identical)
     38   // The bad value must be larger than good to indicate "lower means better"
     39   // and smaller than good to indicate "higher means better"
     40   virtual float GoodQualityScore() const = 0;
     41   virtual float BadQualityScore() const = 0;
     42 };
     43 
     44 // Computes the score given images in any RGB color model, optionally with
     45 // alpha channel.
     46 Status ComputeScore(const ImageBundle& rgb0, const ImageBundle& rgb1,
     47                     Comparator* comparator, const JxlCmsInterface& cms,
     48                     float* score, ImageF* diffmap = nullptr,
     49                     ThreadPool* pool = nullptr, bool ignore_alpha = false);
     50 
     51 }  // namespace jxl
     52 
     53 #endif  // LIB_JXL_ENC_COMPARATOR_H_