Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
process.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#ifndef DT_IOP_HIGHLIGHTS_PROCESS_H
20#define DT_IOP_HIGHLIGHTS_PROCESS_H
21
22// Top-level CFA-agnostic CPU driver and the hybrid OpenCL driver.
23// Public API of this highlights harmonic-transposition module (a compiled TU). Include
24// this header to call into the module; internals are static in the .c. See common.h.
25
26#include "develop/imageop.h"
27
28// Single CPU driver for the harmonic-transposition reconstruction, for Bayer, X-Trans and
29// already-demosaiced (non-raw / sRAW) input alike. The reconstruction middle is CFA-agnostic (it works
30// on interpolated RGB planes and masks); only the disposable-demosaic gather and the remosaic scatter
31// branch on the sensor layout, selected internally from the roi-shifted CFA descriptor via
32// _hl_cfa_strategy().
33//
34// MATHS/FLOW BRIDGE -- 8-step orchestration: step 1a gather (_interpolate_and_mask{,_xtrans,_passthrough})
35// -> step 2 knee (_hl_knee_estimate/_apply) -> step 1b depth + segmentation -> steps 3-8 per region
36// (_region_guided_filter, CFA-agnostic) -> remosaic + composite (_remosaic_and_replace{,_xtrans,
37// _passthrough}). Only the CFA-touching endpoints differ.
38int process_harmonic(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe,
39 const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid,
40 void *const restrict ovoid, const dt_iop_roi_t *const roi_in,
41 const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips);
42
43#ifdef HAVE_OPENCL
44// Top-level OpenCL entry point for the harmonic-transposition mode (called from highlights.c
45// when the pipe runs on a GPU). First fires the env-gated CPU-vs-GPU self-tests (each a
46// no-op unless its HL_*_TEST variable is set), then runs the hybrid driver: GPU gather
47// (bilinear interpolation + clip mask + feathering), the reconstruction middle (fully on GPU
48// when possible, otherwise on downloaded host planes), and the GPU remosaic. Any GPU failure
49// falls back to _harmonic_cl_roundtrip (bit-identical CPU path through a host roundtrip).
50//
51// MATHS/PIPELINE BRIDGE (article §"The OpenCL pipe"): the hybrid CPU-orchestrated GPU driver. GPU gather
52// (step 1a: kernel_highlights_bilinear_and_mask + box_blur -> [R,G,B,norm] planes and clip mask, on
53// device) and GPU remosaic (the terminal composite) BRACKET a middle that runs one of three ways, in
54// preference order: (1) _harmonic_reconstruct_cl -- steps 2 + 1b + 3-8 device-resident, small regions
55// offloaded per the ~1 Mpx routing threshold, only masks/depth/partials crossing the bus; (2) if the
56// device middle cannot run (fp64 device, grain requested, oversized hole), the working planes are pulled
57// down and _harmonic_reconstruct_host runs the CPU middle, then the reconstruction is uploaded and the
58// GPU remosaic still runs; (3) if any GPU gather/remosaic step itself fails, the whole thing falls back
59// to _harmonic_cl_roundtrip (bit-identical to the CPU path). The article steps 3-8 maths live in
60// _region_guided_filter_cl / _region_guided_filter; this driver is pure host<->device routing glue.
61cl_int process_harmonic_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe,
62 const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out,
63 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out,
64 const dt_aligned_pixel_t clips);
65
66#endif
67#endif // DT_IOP_HIGHLIGHTS_PROCESS_H
void *const ovoid
int process_harmonic(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
Definition process.c:42
cl_int process_harmonic_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips)
Definition process.c:619
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
Definition simd.h:53
Region of interest passed through the pixelpipe.
Definition format.h:49