summaryrefslogtreecommitdiffstats
path: root/third_party/jpeg-xl/lib/jxl/loop_filter.h
blob: e4b418ba2bcb886e7e8139b9acc953b2a21a1242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#ifndef LIB_JXL_LOOP_FILTER_H_
#define LIB_JXL_LOOP_FILTER_H_

// Parameters for loop filter(s), stored in each frame.

#include <stddef.h>
#include <stdint.h>

#include "lib/jxl/base/compiler_specific.h"
#include "lib/jxl/base/status.h"
#include "lib/jxl/dec_bit_reader.h"
#include "lib/jxl/field_encodings.h"

namespace jxl {

struct LoopFilter : public Fields {
  LoopFilter();
  JXL_FIELDS_NAME(LoopFilter)

  Status VisitFields(Visitor* JXL_RESTRICT visitor) override;

  size_t Padding() const {
    static const size_t padding_per_epf_iter[4] = {0, 2, 3, 6};
    return padding_per_epf_iter[epf_iters] + (gab ? 1 : 0);
  }

  mutable bool all_default;

  // --- Gaborish convolution
  bool gab;

  bool gab_custom;
  float gab_x_weight1;
  float gab_x_weight2;
  float gab_y_weight1;
  float gab_y_weight2;
  float gab_b_weight1;
  float gab_b_weight2;

  // --- Edge-preserving filter

  // Number of EPF stages to apply. 0 means EPF disabled. 1 applies only the
  // first stage, 2 applies both stages and 3 applies the first stage twice and
  // the second stage once.
  uint32_t epf_iters;

  bool epf_sharp_custom;
  enum { kEpfSharpEntries = 8 };
  float epf_sharp_lut[kEpfSharpEntries];

  bool epf_weight_custom;      // Custom weight params
  float epf_channel_scale[3];  // Relative weight of each channel
  float epf_pass1_zeroflush;   // Minimum weight for first pass
  float epf_pass2_zeroflush;   // Minimum weight for second pass

  bool epf_sigma_custom;        // Custom sigma parameters
  float epf_quant_mul;          // Sigma is ~ this * quant
  float epf_pass0_sigma_scale;  // Multiplier for sigma in pass 0
  float epf_pass2_sigma_scale;  // Multiplier for sigma in the second pass
  float epf_border_sad_mul;     // (inverse) multiplier for sigma on borders

  float epf_sigma_for_modular;

  uint64_t extensions;

  bool nonserialized_is_modular = false;
};

}  // namespace jxl

#endif  // LIB_JXL_LOOP_FILTER_H_