shithub: imgtools

Download patch

ref: 5383442fa1cba98ca2f8638e9f8ef556d1f439ae
parent: 4a924242a625638ac4e2c7e6169950d981d36e2e
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Apr 23 06:05:14 EDT 2021

redefine stbir__edge_wrap as a macro for a speed up

--- a/stb_image_resize.h
+++ b/stb_image_resize.h
@@ -981,13 +981,9 @@
     }
 }
 
-stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max)
-{
-    // avoid per-pixel switch
-    if (n >= 0 && n < max)
-        return n;
-    return stbir__edge_wrap_slow(edge, n, max);
-}
+#define stbir__edge_wrap(edge, n, max) \
+    (((n) >= 0 && (n) < (max)) ? (n) : stbir__edge_wrap_slow((edge), (n), (max)))
+    // ^ avoid per-pixel switch ^
 
 // What input pixels contribute to this output pixel?
 static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out)