Coverage Report

Created: 2025-06-22 08:04

/src/libjxl/lib/jxl/enc_dot_dictionary.cc
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
#include "lib/jxl/enc_dot_dictionary.h"
7
8
#include <array>
9
#include <cstddef>
10
#include <cstring>
11
12
#include "lib/jxl/base/override.h"
13
#include "lib/jxl/base/rect.h"
14
#include "lib/jxl/base/status.h"
15
#include "lib/jxl/chroma_from_luma.h"
16
#include "lib/jxl/enc_detect_dots.h"
17
#include "lib/jxl/enc_params.h"
18
#include "lib/jxl/image.h"
19
20
namespace jxl {
21
22
// Private implementation of Dictionary Encode/Decode
23
namespace {
24
25
/* Quantization constants for Ellipse dots */
26
const size_t kEllipsePosQ = 2;        // Quantization level for the position
27
const double kEllipseMinSigma = 0.1;  // Minimum sigma value
28
const double kEllipseMaxSigma = 3.1;  // Maximum Sigma value
29
const size_t kEllipseSigmaQ = 16;     // Number of quantization levels for sigma
30
const size_t kEllipseAngleQ = 8;      // Quantization level for the angle
31
// TODO(user): fix these values.
32
const std::array<double, 3> kEllipseMinIntensity{{-0.05, 0.0, -0.5}};
33
const std::array<double, 3> kEllipseMaxIntensity{{0.05, 1.0, 0.4}};
34
const std::array<size_t, 3> kEllipseIntensityQ{{10, 36, 10}};
35
}  // namespace
36
37
StatusOr<std::vector<PatchInfo>> FindDotDictionary(
38
    const CompressParams& cparams, const Image3F& opsin, const Rect& rect,
39
0
    const ColorCorrelation& color_correlation, ThreadPool* pool) {
40
0
  if (ApplyOverride(cparams.dots,
41
0
                    cparams.butteraugli_distance >= kMinButteraugliForDots)) {
42
0
    GaussianDetectParams ellipse_params;
43
0
    ellipse_params.t_high = 0.04;
44
0
    ellipse_params.t_low = 0.02;
45
0
    ellipse_params.maxWinSize = 5;
46
0
    ellipse_params.maxL2Loss = 0.005;
47
0
    ellipse_params.maxCustomLoss = 300;
48
0
    ellipse_params.minIntensity = 0.12;
49
0
    ellipse_params.maxDistMeanMode = 1.0;
50
0
    ellipse_params.maxNegPixels = 0;
51
0
    ellipse_params.minScore = 12.0;
52
0
    ellipse_params.maxCC = 100;
53
0
    ellipse_params.percCC = 100;
54
0
    EllipseQuantParams qParams{rect.xsize(),
55
0
                               rect.ysize(),
56
0
                               kEllipsePosQ,
57
0
                               kEllipseMinSigma,
58
0
                               kEllipseMaxSigma,
59
0
                               kEllipseSigmaQ,
60
0
                               kEllipseAngleQ,
61
0
                               kEllipseMinIntensity,
62
0
                               kEllipseMaxIntensity,
63
0
                               kEllipseIntensityQ,
64
0
                               kEllipsePosQ <= 5,
65
0
                               color_correlation.YtoXRatio(0),
66
0
                               color_correlation.YtoBRatio(0)};
67
68
0
    return DetectGaussianEllipses(opsin, rect, ellipse_params, qParams, pool);
69
0
  }
70
0
  std::vector<PatchInfo> nothing;
71
0
  return nothing;
72
0
}
73
}  // namespace jxl