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#pragma once
20
21// Top-level Bayer/X-Trans CPU drivers and the hybrid OpenCL driver.
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/opencl.h"
26#include "develop/imageop.h"
28
30 const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid,
31 void *const restrict ovoid, const dt_iop_roi_t *const roi_in,
32 const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips);
33
34// CPU driver for Fujifilm X-Trans sensors; same start-to-finish flow as
35// process_harmonic_bayer, with X-Trans gather/scatter/knee access.
36//
37// MATHS/FLOW BRIDGE -- identical 8-step orchestration to process_harmonic_bayer (see its header for the
38// step-by-step map): step 1a gather (_interpolate_and_mask_xtrans, through the 6x6 X-Trans bilinear
39// lookup) -> step 2 knee (_hl_knee_estimate/_apply, 6x6 binning) -> step 1b depth + segmentation
40// (annotated below) -> steps 3-8 per region (_region_guided_filter, CFA-agnostic, shared with Bayer) ->
41// remosaic + composite (_remosaic_and_replace_xtrans). Only the CFA-touching endpoints differ.
43 const dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid,
44 void *const restrict ovoid, const dt_iop_roi_t *const roi_in,
45 const dt_iop_roi_t *const roi_out, const dt_aligned_pixel_t clips);
46
47#ifdef HAVE_OPENCL
48// Top-level OpenCL entry point for the harmonic-transposition mode (called from highlights.c
49// when the pipe runs on a GPU). First fires the env-gated CPU-vs-GPU self-tests (each a
50// no-op unless its HL_*_TEST variable is set), then runs the hybrid driver: GPU gather
51// (bilinear interpolation + clip mask + feathering), the reconstruction middle (fully on GPU
52// when possible, otherwise on downloaded host planes), and the GPU remosaic. Any GPU failure
53// falls back to _harmonic_cl_roundtrip (bit-identical CPU path through a host roundtrip).
54//
55// MATHS/PIPELINE BRIDGE (article §"The OpenCL pipe"): the hybrid CPU-orchestrated GPU driver. GPU gather
56// (step 1a: kernel_highlights_bilinear_and_mask + box_blur -> [R,G,B,norm] planes and clip mask, on
57// device) and GPU remosaic (the terminal composite) BRACKET a middle that runs one of three ways, in
58// preference order: (1) _harmonic_reconstruct_cl -- steps 2 + 1b + 3-8 device-resident, small regions
59// offloaded per the ~1 Mpx routing threshold, only masks/depth/partials crossing the bus; (2) if the
60// device middle cannot run (fp64 device, grain requested, oversized hole), the working planes are pulled
61// down and _harmonic_reconstruct_host runs the CPU middle, then the reconstruction is uploaded and the
62// GPU remosaic still runs; (3) if any GPU gather/remosaic step itself fails, the whole thing falls back
63// to _harmonic_cl_roundtrip (bit-identical to the CPU path). The article steps 3-8 maths live in
64// _region_guided_filter_cl / _region_guided_filter; this driver is pure host<->device routing glue.
65cl_int process_harmonic_cl(struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe,
66 const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out,
67 const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out,
68 const dt_aligned_pixel_t clips);
69#endif
void *const ovoid
float dt_aligned_pixel_t[4]
int process_harmonic_xtrans(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:201
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:698
int process_harmonic_bayer(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:39
Region of interest passed through the pixelpipe.
Definition imageop.h:72