![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "common/interpolation.h"#include "common/darktable.h"#include "common/math.h"#include "control/conf.h"#include <assert.h>#include <glib.h>#include <inttypes.h>#include <stddef.h>#include <stdint.h>
Include dependency graph for interpolation.c:Macros | |
| #define | RESAMPLING_BORDER_MODE BORDER_REPLICATE |
| #define | INTERPOLATION_BORDER_MODE BORDER_MIRROR |
| #define | MAX_HALF_FILTER_WIDTH 3 |
| #define | DEBUG_PRINT_VERBOSE 0 |
| #define | DT_LANCZOS_EPSILON (1e-9f) |
| #define | MAX_KERNEL_REQ ((2 * (MAX_HALF_FILTER_WIDTH) + 3) & (~3)) |
Enumerations | |
| enum | border_mode { BORDER_REPLICATE , BORDER_WRAP , BORDER_MIRROR , BORDER_CLAMP } |
Functions | |
| static ssize_t | _clip (ssize_t i, const ssize_t min, const ssize_t max, enum border_mode mode) |
| static void | _prepare_tap_boundaries (int *tap_first, int *tap_last, const enum border_mode mode, const int filterwidth, const int t, const int max) |
| static float | _maketaps_bilinear (float *taps, const size_t num_taps, const float width, const float first_tap, const float interval) |
| static float | _maketaps_bicubic (float *taps, const size_t num_taps, const float width, const float first_tap, const float interval) |
| static float | _maketaps_lanczos (float *taps, const size_t num_taps, const float width, const float first_tap, const float interval) |
| static float | _compute_upsampling_kernel (const struct dt_interpolation *itor, float *kernel, int *first, float t) |
| static void | _compute_downsampling_kernel (const struct dt_interpolation *itor, int *taps, int *first, float *kernel, float *norm, const float outoinratio, const int xout) |
| float | dt_interpolation_compute_sample (const struct dt_interpolation *itor, const float *in, const float x, const float y, const int width, const int height, const int samplestride, const int linestride) |
| void | dt_interpolation_compute_pixel4c (const struct dt_interpolation *itor, const float *in, float *out, const float x, const float y, const int width, const int height, const int linestride) |
| const struct dt_interpolation * | dt_interpolation_new (enum dt_interpolation_type type) |
| static gboolean | _prepare_resampling_plan (const struct dt_interpolation *itor, const int in, const int in_x0, const int out, const int out_x0, const float scale, int **plength, float **pkernel, int **pindex, int **pmeta) |
| static void | _interpolation_resample_plain (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
| void | dt_interpolation_resample (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
| void | dt_interpolation_resample_roi (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
| static void | _interpolation_resample_1c_plain (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
| void | dt_interpolation_resample_1c (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
| void | dt_interpolation_resample_roi_1c (const struct dt_interpolation *itor, float *out, const dt_iop_roi_t *const roi_out, const float *const in, const dt_iop_roi_t *const roi_in) |
Variables | |
| static const struct dt_interpolation | dt_interpolator [] |
| #define DEBUG_PRINT_VERBOSE 0 |
| #define DT_LANCZOS_EPSILON (1e-9f) |
| #define INTERPOLATION_BORDER_MODE BORDER_MIRROR |
| #define MAX_HALF_FILTER_WIDTH 3 |
| #define MAX_KERNEL_REQ ((2 * (MAX_HALF_FILTER_WIDTH) + 3) & (~3)) |
| #define RESAMPLING_BORDER_MODE BORDER_REPLICATE |
| enum border_mode |
|
inlinestatic |
Clip into specified range
| idx | index to filter |
| length | length of line |
References BORDER_CLAMP, BORDER_MIRROR, BORDER_REPLICATE, and BORDER_WRAP.
Referenced by _prepare_resampling_plan(), dt_interpolation_compute_pixel4c(), and dt_interpolation_compute_sample().
|
inlinestatic |
Computes a downsampling filtering kernel (vectorized version, four taps per inner loop iteration)
| itor | [in] Interpolator used |
| kernelsize | [out] Number of taps |
| kernel | [out] resulting taps (at least itor->width/inoout + 4 elements for no overflow) |
| norm | [out] Kernel norm |
| first | [out] index of the first sample for which the kernel is to be applied |
| outoinratio | [in] "out samples" over "in samples" ratio |
| xout | [in] Output coordinate |
References ceil_fast(), kernel(), dt_interpolation::maketaps, and dt_interpolation::width.
Referenced by _prepare_resampling_plan().
|
inlinestatic |
References f(), kernel(), dt_interpolation::maketaps, and dt_interpolation::width.
Referenced by _prepare_resampling_plan(), dt_interpolation_compute_pixel4c(), and dt_interpolation_compute_sample().
|
static |
References _prepare_resampling_plan(), dt_free_align, dt_iop_roi_t::height, dt_iop_roi_t::scale, dt_iop_roi_t::width, dt_iop_roi_t::x, and dt_iop_roi_t::y.
Referenced by dt_interpolation_resample_1c().
|
static |
|
static |
References for_four_channels.
|
static |
References for_four_channels.
|
static |
References DT_LANCZOS_EPSILON, dt_vector_sin(), eps, for_four_channels, M_PI_F, sign(), and width.
|
static |
Prepares a 1D resampling plan
This consists of the following information
How to apply the resampling plan:
This until you reach the number of output pixels
| itor | interpolator used to resample |
| in | [in] Number of input samples |
| out | [in] Number of output samples |
| plength | [out] Array of lengths for each pixel filtering (number of taps/indexes to use). This array mus be freed with dt_free_align() when you're done with the plan. |
| pkernel | [out] Array of filter kernel taps |
| pindex | [out] Array of sample indexes to be used for applying each kernel tap arrays of information |
| pmeta | [out] Array of int triplets (length, kernel, index) telling where to start for an arbitrary out position meta[3*out] |
References _clip(), _compute_downsampling_kernel(), _compute_upsampling_kernel(), _prepare_tap_boundaries(), ceil_fast(), dt_alloc_align, DT_CACHELINE_BYTES, dt_round_size(), FALSE, kernel(), meta, RESAMPLING_BORDER_MODE, TRUE, void(), and dt_interpolation::width.
Referenced by _interpolation_resample_1c_plain(), and _interpolation_resample_plain().
|
inlinestatic |
References BORDER_CLAMP.
Referenced by _prepare_resampling_plan(), dt_interpolation_compute_pixel4c(), and dt_interpolation_compute_sample().
| void dt_interpolation_compute_pixel4c | ( | const struct dt_interpolation * | itor, |
| const float * | in, | ||
| float * | out, | ||
| const float | x, | ||
| const float | y, | ||
| const int | width, | ||
| const int | height, | ||
| const int | linestride | ||
| ) |
Compute an interpolated 4 component pixel.
This function computes a full 4 component pixel. This helps a bit speedwise as interpolation coordinates are supposed to be the same for all components. Thus we can share horizontal and vertical interpolation kernels across all components
NB: a pixel is to be four floats big in stride
| in | Pointer to the input image |
| out | Pointer to the output sample |
| itor | interpolator to be used |
| x | X-Coordinate of the requested sample |
| y | Y-Coordinate of the requested sample |
| width | Width of the input image |
| height | Width of the input image |
| linestride | Stride in number of pixels for complete line |
References _clip(), _compute_upsampling_kernel(), _prepare_tap_boundaries(), BORDER_CLAMP, copy_pixel(), DT_ALIGNED_ARRAY, for_each_channel, height, INTERPOLATION_BORDER_MODE, MAX_HALF_FILTER_WIDTH, MAX_KERNEL_REQ, width, and dt_interpolation::width.
Referenced by apply_global_distortion_map(), distort_mask(), process(), and process().
| float dt_interpolation_compute_sample | ( | const struct dt_interpolation * | itor, |
| const float * | in, | ||
| const float | x, | ||
| const float | y, | ||
| const int | width, | ||
| const int | height, | ||
| const int | samplestride, | ||
| const int | linestride | ||
| ) |
Compute a single interpolated sample.
This function computes a single interpolated sample. Implied costs are:
| in | Input image |
| itor | interpolator to be used |
| x | X-Coordinate of the requested sample |
| y | Y-Coordinate of the requested sample |
| width | Width of the input image |
| height | Width of the input image |
| samplestride | Stride in bytes for a sample |
| linestride | Stride in bytes for complete line |
References _clip(), _compute_upsampling_kernel(), _prepare_tap_boundaries(), BORDER_CLAMP, DT_ALIGNED_ARRAY, height, INTERPOLATION_BORDER_MODE, MAX_HALF_FILTER_WIDTH, MAX_KERNEL_REQ, width, and dt_interpolation::width.
Referenced by apply_global_distortion_map(), distort_mask(), and process().
| const struct dt_interpolation * dt_interpolation_new | ( | enum dt_interpolation_type | type | ) |
Get an interpolator from type
| type | Interpolator to search for |
References dt_conf_get_string_const(), DT_INTERPOLATION_DEFAULT, DT_INTERPOLATION_DEFAULT_WARP, DT_INTERPOLATION_FIRST, DT_INTERPOLATION_LAST, DT_INTERPOLATION_USERPREF, DT_INTERPOLATION_USERPREF_WARP, dt_interpolator, name, and type.
Referenced by _aspect_ratio_get(), _ratio_get_aspect(), apply_global_distortion_map(), distort_mask(), dt_iop_clip_and_zoom(), dt_iop_clip_and_zoom_roi(), modify_roi_in(), modify_roi_in(), modify_roi_out(), process(), and process().
| void dt_interpolation_resample | ( | const struct dt_interpolation * | itor, |
| float * | out, | ||
| const dt_iop_roi_t *const | roi_out, | ||
| const float *const | in, | ||
| const dt_iop_roi_t *const | roi_in | ||
| ) |
Applies resampling (re-scaling) on full input and output buffers. roi_in and roi_out define the part of the buffers that is affected.
References _interpolation_resample_plain().
Referenced by dt_interpolation_resample_roi(), and dt_iop_clip_and_zoom().
| void dt_interpolation_resample_1c | ( | const struct dt_interpolation * | itor, |
| float * | out, | ||
| const dt_iop_roi_t *const | roi_out, | ||
| const float *const | in, | ||
| const dt_iop_roi_t *const | roi_in | ||
| ) |
Applies resampling (re-scaling) on full input and output buffers. roi_in and roi_out define the part of the buffers that is affected.
References _interpolation_resample_1c_plain().
Referenced by dt_interpolation_resample_roi_1c().
| void dt_interpolation_resample_roi | ( | const struct dt_interpolation * | itor, |
| float * | out, | ||
| const dt_iop_roi_t *const | roi_out, | ||
| const float *const | in, | ||
| const dt_iop_roi_t *const | roi_in | ||
| ) |
Applies resampling (re-scaling) on a specific region-of-interest of an image. The input and output buffers hold exactly those roi's. roi_in and roi_out define the relative positions of the roi's within the full input and output image, respectively.
References dt_interpolation_resample(), dt_iop_roi_t::x, and dt_iop_roi_t::y.
Referenced by dt_iop_clip_and_zoom_roi().
| void dt_interpolation_resample_roi_1c | ( | const struct dt_interpolation * | itor, |
| float * | out, | ||
| const dt_iop_roi_t *const | roi_out, | ||
| const float *const | in, | ||
| const dt_iop_roi_t *const | roi_in | ||
| ) |
Applies resampling (re-scaling) on a specific region-of-interest of an image. The input and output buffers hold exactly those roi's. roi_in and roi_out define the relative positions of the roi's within the full input and output image, respectively.
References dt_interpolation_resample_1c(), dt_iop_roi_t::x, and dt_iop_roi_t::y.
Referenced by distort_mask().
|
static |
Referenced by dt_interpolation_new().