-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Description
Describe the bug
When I try to up sample an image (232x232 px) to 300x300 px, stb_image_resize2 crashes.
The content of image does not matter, the key issue is input/output size.
- If I change the output size to 302x302 px, it still crashes. But with output size as 303x303 px, no crash.
- If I keep the scaling factor (i.e. 232/300) but change the size, it
- still crashes when performing 464x464 -> 600x600
- but does not crash when performing 387x387 -> 500x500
Crash only occurs when using the point sampling filter STBIR_FILTER_POINT_SAMPLE
. I am not familiar with image processing, so is it wrong to use point sampling filter for up sampling, or I use it in a wrong form?
The stack trace from Visual Studio debugger:
stbir__horizontal_gather_4_channels_with_2_coeffs(float * output_buffer, unsigned int output_sub_size, const float * decode_buffer, const stbir__contributors * horizontal_contributors, const float * horizontal_coefficients, int coefficient_width) line 10013
stbir__resample_horizontal_gather(const stbir__info * stbir_info, float * output_buffer, const float * input_buffer) line 5992
stbir__decode_and_resample_for_vertical_gather_loop(const stbir__info * stbir_info, stbir__per_split_info * split_info, int n) line 6051
stbir__vertical_gather_loop(const stbir__info * stbir_info, stbir__per_split_info * split_info, int split_count) line 6105
stbir__perform_resize(const stbir__info * info, int split_start, int split_count) line 7089
stbir_resize_extended(STBIR_RESIZE * resize) line 7713
stbir_resize(const void * input_pixels, int input_w, int input_h, int input_stride_in_bytes, void * output_pixels, int output_w, int output_h, int output_stride_in_bytes, stbir_pixel_layout pixel_layout, stbir_datatype data_type, stbir_edge edge, stbir_filter filter) line 7883
main() line 19
To Reproduce
Steps to reproduce the behavior:
- Use the stb_image_resize2.h (on commit
f75e8d1cad7d90d72ef7a4661f1b994ef78b4e31
) - Create a minimal test example like this:
#include <cstring>
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize2.h"
int main()
{
int input_w = 232;
int input_h = 232;
int output_w = 300;
int output_h = 300;
unsigned char* input = new unsigned char[input_w * input_h * 4];
std::memset(input, 0, input_w * input_h * 4);
unsigned char* output = new unsigned char[output_w * output_h * 4];
stbir_resize(
input, input_w, input_h, 0,
output, output_w, output_h, 0,
STBIR_RGBA, STBIR_TYPE_UINT8, STBIR_EDGE_CLAMP, STBIR_FILTER_POINT_SAMPLE
);
delete[] input;
delete[] output;
return 0;
}
- Build and run it
- The program crashes
Expected behavior
The program should exit normally and return 0.
Metadata
Metadata
Assignees
Labels
No labels