57 for(
int y = 0; y <
height; y++)
60 float *
const px = pixels + ((size_t)y *
width +
x) * 4;
70 const int in_width,
const int in_height,
float *
const out)
76 if(sx > in_width - 1) sx = in_width - 1;
77 if(sy > in_height - 1) sy = in_height - 1;
84 const int out_x,
const int out_y,
85 const int out_width,
const int out_height)
88 float *
const in = malloc((
size_t)in_width * in_height * 4 *
sizeof(
float));
89 float *
const out = malloc((
size_t)out_width * out_height * 4 *
sizeof(
float));
94 const dt_iop_roi_t roi_in = { .x = 0, .y = 0, .width = in_width, .height = in_height, .scale = 1.0f };
95 const dt_iop_roi_t roi_out = { .x = out_x, .y = out_y, .width = out_width, .height = out_height,
101 for(
int y = 0; y < out_height; y++)
102 for(
int x = 0;
x < out_width;
x++)
104 float expected[2] = { 0.0f, 0.0f };
106 const float *
const px =
out + ((size_t)y * out_width +
x) * 4;
167int main(
int argc,
char *argv[])
169 const struct CMUnitTest tests[] = {
178 return cmocka_run_group_tests(tests, NULL, NULL);
#define assert_float_equal(a, b, epsilon)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_colormatrix_t dt_aligned_pixel_t out
const struct dt_interpolation * dt_interpolation_new(enum dt_interpolation_type type)
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)
@ DT_INTERPOLATION_BILINEAR
const float uint32_t state[4]
Region of interest passed through the pixelpipe.
static void _fill_identifiable(float *const pixels, const int width, const int height)
A pixel whose channels encode its coordinates, so a misplaced copy is identifiable.
static void test_window_transposed_source(void **state)
static void test_window_entirely_outside(void **state)
static void test_window_single_pixel_source(void **state)
static void _expected_pixel(const int x, const int y, const int dx, const int dy, const int in_width, const int in_height, float *const out)
What BORDER_REPLICATE says the output pixel at (x, y) must be.
static void test_window_contained(void **state)
static void test_window_negative_offset(void **state)
static void _check_window(const int in_width, const int in_height, const int out_x, const int out_y, const int out_width, const int out_height)
Resample one window and check every output pixel against the replicate rule.
static void test_window_taller_than_source(void **state)
static void test_window_wider_than_source(void **state)