Skip to content

Commit 148f4ec

Browse files
Redesign pixelpipe input scaling
Analysis: With current pixelpipe and cache design we must reprocess the full pipe whenever we zoom in/out or drag around, as we select another area and thus the hash won't match. Solution: 1. Decouple crop&scale from demosaic module and introduce a "pipescale" module that presents the currently chosen roi. 2. Make sure modules before pipescale always process full image data. 3. By doing so we will have a 100% cache hit rate for the pipescale modulule if there are no changed parameters in any of the modules before. As those modules before pipescale could include very performance costly algorithms the UI will now be far more responsive. 4. The default pipescale position is now right after demosaicing, the current implementation allows dragging it's position further up the pipe so it could also include costly stuff like denoising or even notorious modules like dehaze as that loves to be processed with full image data. 5. As we now always have full image data available before and including demosaicing all raw-only modules can use simplified code reducing code and complexity. It will also be possible to provide details mask while demosaic tiling. 6. The scale module is also available for non-raw files allowing crop&scale to be done **after** colorin. (One problem here so far: the preview pipe scaling is not fixed so far) 7. The low quality demosaicers are gone as we always have full data to be processed.
1 parent ea7e23e commit 148f4ec

File tree

6 files changed

+245
-293
lines changed

6 files changed

+245
-293
lines changed

src/common/iop_order.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const dt_iop_order_entry_t legacy_order[] = {
8888
{ { 6.0f }, "hotpixels", 0},
8989
{ { 7.0f }, "rawdenoise", 0},
9090
{ { 8.0f }, "demosaic", 0},
91+
{ { 8.5f }, "pipescale", 0},
9192
{ { 9.0f }, "mask_manager", 0},
9293
{ {10.0f }, "denoiseprofile", 0},
9394
{ {11.0f }, "tonemap", 0},
@@ -184,6 +185,7 @@ const dt_iop_order_entry_t v30_order[] = {
184185
{ { 6.0f }, "hotpixels", 0},
185186
{ { 7.0f }, "rawdenoise", 0},
186187
{ { 8.0f }, "demosaic", 0},
188+
{ { 8.5f }, "pipescale", 0},
187189
{ { 9.0f }, "denoiseprofile", 0},
188190
{ {10.0f }, "bilateral", 0},
189191
{ {11.0f }, "rotatepixels", 0},
@@ -301,6 +303,7 @@ const dt_iop_order_entry_t v50_order[] = {
301303
{ { 6.0f }, "hotpixels", 0},
302304
{ { 7.0f }, "rawdenoise", 0},
303305
{ { 8.0f }, "demosaic", 0},
306+
{ { 8.5f }, "pipescale", 0},
304307
{ { 9.0f }, "denoiseprofile", 0},
305308
{ {10.0f }, "bilateral", 0},
306309
{ {11.0f }, "rotatepixels", 0},
@@ -420,6 +423,7 @@ const dt_iop_order_entry_t v30_jpg_order[] = {
420423
{ { 6.0f }, "hotpixels", 0 },
421424
{ { 7.0f }, "rawdenoise", 0 },
422425
{ { 8.0f }, "demosaic", 0 },
426+
{ { 8.5f }, "pipescale", 0},
423427
// all the modules between [8; 28] expect linear RGB, so they need to be moved after colorin
424428
{ { 28.0f }, "colorin", 0 },
425429
// moved modules : (copy-pasted in the same order)
@@ -540,6 +544,7 @@ const dt_iop_order_entry_t v50_jpg_order[] = {
540544
{ { 6.0f }, "hotpixels", 0 },
541545
{ { 7.0f }, "rawdenoise", 0 },
542546
{ { 8.0f }, "demosaic", 0 },
547+
{ { 8.5f }, "pipescale", 0},
543548
// all the modules between [8; 28] expect linear RGB, so they need to be moved after colorin
544549
{ { 28.0f }, "colorin", 0 },
545550
// moved modules : (copy-pasted in the same order)
@@ -1179,6 +1184,7 @@ GList *dt_ioppr_get_iop_order_list(const dt_imgid_t imgid,
11791184
_insert_before(iop_order_list, "filmicrgb", "sigmoid");
11801185
_insert_before(iop_order_list, "colorbalancergb", "colorequal");
11811186
_insert_before(iop_order_list, "highlights", "rasterfile");
1187+
_insert_before(iop_order_list, "denoiseprofile", "pipescale"); // ????
11821188
}
11831189
}
11841190
else if(version >= DT_IOP_ORDER_LEGACY

src/develop/pixelpipe_hb.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,9 +1737,6 @@ static gboolean _dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe,
17371737
// 3b) recurse and obtain output array in &input
17381738

17391739
// get region of interest which is needed in input
1740-
if(dt_pipe_shutdown(pipe))
1741-
return TRUE;
1742-
17431740
module->modify_roi_in(module, piece, roi_out, &roi_in);
17441741
if((darktable.unmuted & DT_DEBUG_PIPE) && memcmp(roi_out, &roi_in, sizeof(dt_iop_roi_t)))
17451742
{
@@ -1775,18 +1772,11 @@ static gboolean _dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe,
17751772
const size_t out_bpp = dt_iop_buffer_dsc_to_bpp(*out_format);
17761773

17771774
// reserve new cache line: output
1778-
if(dt_pipe_shutdown(pipe))
1779-
return TRUE;
1780-
17811775
const gboolean important = module
17821776
&& (pipe->mask_display == DT_DEV_PIXELPIPE_DISPLAY_NONE)
1783-
&& (((pipe->type & DT_DEV_PIXELPIPE_PREVIEW)
1784-
&& dt_iop_module_is(module->so, "colorout"))
1785-
|| ((pipe->type & DT_DEV_PIXELPIPE_FULL)
1786-
&& dt_iop_module_is(module->so, "gamma")));
1777+
&& dt_iop_module_is(module->so, "pipescale");
17871778

1788-
dt_dev_pixelpipe_cache_get(pipe, hash, bufsize,
1789-
output, out_format, module, important);
1779+
dt_dev_pixelpipe_cache_get(pipe, hash, bufsize, output, out_format, module, important);
17901780

17911781
if(dt_pipe_shutdown(pipe))
17921782
return TRUE;
@@ -2546,8 +2536,8 @@ static gboolean _dev_pixelpipe_process_rec(dt_dev_pixelpipe_t *pipe,
25462536
&& dev->gui_attached
25472537
&& ((module == dt_dev_gui_module())
25482538
|| darktable.develop->history_last_module == module
2549-
|| dt_iop_module_is(module->so, "colorout")
2550-
|| dt_iop_module_is(module->so, "finalscale"));
2539+
|| dt_iop_module_is(module->so, "finalscale")
2540+
|| dt_iop_module_is(module->so, "pipescale"));
25512541

25522542
if(important_cl)
25532543
{

src/iop/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ add_iop(sigmoid "sigmoid.c")
155155
add_iop(primaries "primaries.c")
156156
add_iop(colorequal "colorequal.c")
157157
add_iop(rasterfile "rasterfile.c")
158+
add_iop(pipescale "pipescale.c")
158159

159160
if(Rsvg2_FOUND)
160161
add_iop(watermark "watermark.c")

src/iop/cacorrect.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,37 +1215,6 @@ DT_OMP_PRAGMA(barrier)
12151215
/*==================================================================================
12161216
* end raw therapee code
12171217
*==================================================================================*/
1218-
void modify_roi_out(dt_iop_module_t *self,
1219-
dt_dev_pixelpipe_iop_t *piece,
1220-
dt_iop_roi_t *roi_out,
1221-
const dt_iop_roi_t *const roi_in)
1222-
{
1223-
*roi_out = *roi_in;
1224-
roi_out->x = MAX(0, roi_in->x);
1225-
roi_out->y = MAX(0, roi_in->y);
1226-
}
1227-
void modify_roi_in(dt_iop_module_t *self,
1228-
dt_dev_pixelpipe_iop_t *piece,
1229-
const dt_iop_roi_t *const roi_out,
1230-
dt_iop_roi_t *roi_in)
1231-
{
1232-
*roi_in = *roi_out;
1233-
roi_in->x = 0;
1234-
roi_in->y = 0;
1235-
roi_in->width = piece->buf_in.width;
1236-
roi_in->height = piece->buf_in.height;
1237-
roi_in->scale = 1.0f;
1238-
}
1239-
1240-
void distort_mask(dt_iop_module_t *self,
1241-
dt_dev_pixelpipe_iop_t *piece,
1242-
const float *const in,
1243-
float *const out,
1244-
const dt_iop_roi_t *const roi_in,
1245-
const dt_iop_roi_t *const roi_out)
1246-
{
1247-
dt_iop_copy_image_roi(out, in, 1, roi_in, roi_out);
1248-
}
12491218

12501219
void reload_defaults(dt_iop_module_t *self)
12511220
{

0 commit comments

Comments
 (0)