Skip to content

Commit

Permalink
graphics.c: Fix windowing function to be more exact and prevent asymm…
Browse files Browse the repository at this point in the history
…etric results
  • Loading branch information
lilith committed Sep 25, 2020
1 parent cf3f3f4 commit fee4501
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 133 deletions.
4 changes: 2 additions & 2 deletions c_components/lib/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ flow_interpolation_line_contributions_create(flow_c * context, const uint32_t ou
for (u = 0; u < output_line_size; u++) {
const double center_src_pixel = ((double)u + 0.5) / scale_factor - 0.5;

const int left_edge = (int)floor(center_src_pixel) - ((allocated_window_size - 1) / 2);
const int right_edge = left_edge + allocated_window_size - 1;
const int left_edge = (int)ceil(center_src_pixel - details->window/downscale_factor -0.0001);
const int right_edge = (int)floor(center_src_pixel + details->window/downscale_factor +0.0001);

const uint32_t left_src_pixel = (uint32_t)int_max(0, left_edge);
const uint32_t right_src_pixel = (uint32_t)int_min(right_edge, (int)input_line_size - 1);
Expand Down
8 changes: 5 additions & 3 deletions c_components/tests/test_weighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ TEST_CASE("Verify weights are symmetric and bounded", "[fastscaling]")
// filter, 2, from, 200, to, 300, weights, src, 0, (0.00001, 0.00200, 1.2200), 1, ...
int32_t filter_id = 1;
int32_t scalings[] = { /*downscale to 1px*/ 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 17, 1,
/*upscale from 2px*/ 2, 3, 2, 4, 2, 5, 2, 17,
/*other*/ 11, 7, 7, 3, 8, 4 };
/*upscale from 2px*/ 2, 3, 2, 4, 2, 5, 2, 17,
/*other*/ 11, 7, 7, 3,
/* IDCT kernel sizes */ 8, 8, 8, 7, 8, 6, 8, 5, 8, 4, 8, 3, 8, 2, 8, 1 };

flow_interpolation_filter first_filter = flow_interpolation_filter_NCubicSharp;
flow_interpolation_filter first_filter = flow_interpolation_filter_RobidouxFast;
//flow_interpolation_filter first_filter = flow_interpolation_filter_NCubicSharp;
flow_interpolation_filter last_filter = flow_interpolation_filter_NCubicSharp;
uint32_t scaling_ix;
for (filter_id = (int32_t)first_filter; filter_id <= (int32_t)last_filter; filter_id++) {
Expand Down
Loading

0 comments on commit fee4501

Please sign in to comment.