Coverage Report

Created: 2025-06-16 07:00

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