Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
blur.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with darktable. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21// Gaussian blur helpers + per-region blur, and the OpenCL blur / device-timing runtime prelude.
22// Public API of this highlights harmonic-transposition module (a compiled TU). Include
23// this header to call into the module; internals are static in the .c. See common.h.
24
25#include "common/darktable.h"
26#include "common/gaussian.h"
27#include "common/opencl.h"
29
30dt_gaussian_t *_hl_gauss_get(const int width, const int height, const int channels, const float sigma);
31
32void _hl_gauss_cache_flush(void);
33
34static inline void _region_blur(const float *const restrict in, float *const restrict out, const int region_w,
35 const int region_h, const float sigma)
36{
37 dt_gaussian_t *const gaussian = _hl_gauss_get(region_w, region_h, 4, sigma); // cached, do not free
38
39 if(!gaussian)
40 {
41 memcpy(out, in, (size_t)region_w * region_h * 4 * sizeof(float));
42 return;
43 }
44
46}
47
48#ifdef HAVE_OPENCL
49// GPU counterpart of _region_blur: the exact same Young-van-Vliet recursive gaussian, through
50// the existing dt_gaussian OpenCL implementation. in/out are 4-channel image2d of the region.
51dt_gaussian_cl_t *_region_blur_handle(const int devid, const int region_w, const int region_h, const float sigma);
52
53// One-shot gaussian blur of a 4-channel region image on the GPU (init + blur + free).
54// Mirrors _region_blur on the CPU: any change here must be mirrored there and re-validated
55// with the HL_BLURCL_TEST self-test (_region_blur_cl_selftest).
56cl_int _region_blur_cl(const int devid, cl_mem in, cl_mem out, const int region_w, const int region_h,
57 const float sigma);
58#endif
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
static void _region_blur(const float *const restrict in, float *const restrict out, const int region_w, const int region_h, const float sigma)
Definition blur.h:34
dt_gaussian_t * _hl_gauss_get(const int width, const int height, const int channels, const float sigma)
Definition blur.c:30
void _hl_gauss_cache_flush(void)
Definition blur.c:49
cl_int _region_blur_cl(const int devid, cl_mem in, cl_mem out, const int region_w, const int region_h, const float sigma)
Definition blur.c:76
dt_gaussian_cl_t * _region_blur_handle(const int devid, const int region_w, const int region_h, const float sigma)
Definition blur.c:69
const dt_colormatrix_t dt_aligned_pixel_t out
static float gaussian(float x, float std)
Definition filmic.c:397
void dt_gaussian_blur_4c(dt_gaussian_t *g, const float *const in, float *const out)
Definition gaussian.c:325
const float sigma