Blender V4.3
COM_deriche_gaussian_coefficients.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <cstdint>
8#include <memory>
9
10#include "BLI_map.hh"
12
14
16
17class Context;
18
19/* ------------------------------------------------------------------------------------------------
20 * Deriche Gaussian Coefficients Key.
21 */
23 public:
24 float sigma;
25
27
28 uint64_t hash() const;
29};
30
32
33/* -------------------------------------------------------------------------------------------------
34 * Deriche Gaussian Coefficients.
35 *
36 * A caches resource that computes and caches the coefficients of the fourth order IIR filter
37 * approximating a Gaussian filter computed using Deriche's design method. This is based on the
38 * following paper:
39 *
40 * Deriche, Rachid. Recursively implementating the Gaussian and its derivatives. Diss. INRIA,
41 * 1993.
42 */
44 private:
45 /* The d_ii coefficients in Equation (28) and (29). Those are the same for the causal and non
46 * causal filters as can be seen in Equation (31). */
47 double4 feedback_coefficients_;
48 /* The n_ii^+ coefficients in Equation (28). */
49 double4 causal_feedforward_coefficients_;
50 /* The n_ii^- coefficients in Equation (29). */
51 double4 non_causal_feedforward_coefficients_;
52 /* The difference equation in Equation (28) rely on previous outputs to compute the new output,
53 * and those previous outputs need to be properly initialized somehow. To do Neumann boundary
54 * condition, we multiply the boundary value with this coefficient to simulate an infinite stream
55 * of the boundary value. See the implementation for more information. */
56 double causal_boundary_coefficient_;
57 /* Same as causal_boundary_coefficient_ but for the non causal filter. */
58 double non_causal_boundary_coefficient_;
59
60 public:
61 DericheGaussianCoefficients(Context &context, float sigma);
62
63 const double4 &feedback_coefficients() const;
66 double causal_boundary_coefficient() const;
68};
69
70/* ------------------------------------------------------------------------------------------------
71 * Deriche Gaussian Coefficients Container.
72 */
74 private:
76
77 public:
78 void reset() override;
79
80 /* Check if there is an available DericheGaussianCoefficients cached resource with the given
81 * parameters in the container, if one exists, return it, otherwise, return a newly created one
82 * and add it to the container. In both cases, tag the cached resource as needed to keep it
83 * cached for the next evaluation. */
84 DericheGaussianCoefficients &get(Context &context, float sigma);
85};
86
87} // namespace blender::realtime_compositor
DericheGaussianCoefficients & get(Context &context, float sigma)
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
unsigned __int64 uint64_t
Definition stdint.h:90