|
|
@ -63,9 +63,6 @@ int main(int argc, char** argv) |
|
|
|
float s1 = 0.75f; |
|
|
|
float s1 = 0.75f; |
|
|
|
float t1 = 0.75f; |
|
|
|
float t1 = 0.75f; |
|
|
|
|
|
|
|
|
|
|
|
size_t memory_required = stbr_calculate_memory(in_w, in_h, out_w, out_h, s0, t0, s1, t1, n, STBR_FILTER_CATMULLROM); |
|
|
|
|
|
|
|
void* extra_memory = malloc(memory_required); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cut out the outside 64 pixels all around to test the stride.
|
|
|
|
// Cut out the outside 64 pixels all around to test the stride.
|
|
|
|
int border = 64; |
|
|
|
int border = 64; |
|
|
|
STBR_ASSERT(in_w + border <= w); |
|
|
|
STBR_ASSERT(in_w + border <= w); |
|
|
@ -79,7 +76,7 @@ int main(int argc, char** argv) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ftime(&initial_time_millis); |
|
|
|
ftime(&initial_time_millis); |
|
|
|
for (int i = 0; i < 100; i++) |
|
|
|
for (int i = 0; i < 100; i++) |
|
|
|
stbr_resize_advanced(input_data + w * border * n + border * n, in_w, in_h, w*n, output_data, out_w, out_h, out_stride, n, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB, extra_memory, memory_required); |
|
|
|
stbr_resize_advanced(input_data + w * border * n + border * n, in_w, in_h, w*n, output_data, out_w, out_h, out_stride, n, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB); |
|
|
|
ftime(&final_time_millis); |
|
|
|
ftime(&final_time_millis); |
|
|
|
long lapsed_ms = (long)(final_time_millis.time - initial_time_millis.time) * 1000 + (final_time_millis.millitm - initial_time_millis.millitm); |
|
|
|
long lapsed_ms = (long)(final_time_millis.time - initial_time_millis.time) * 1000 + (final_time_millis.millitm - initial_time_millis.millitm); |
|
|
|
printf("Resample: %dms\n", lapsed_ms); |
|
|
|
printf("Resample: %dms\n", lapsed_ms); |
|
|
@ -91,10 +88,9 @@ int main(int argc, char** argv) |
|
|
|
|
|
|
|
|
|
|
|
printf("Average: %dms\n", average); |
|
|
|
printf("Average: %dms\n", average); |
|
|
|
#else |
|
|
|
#else |
|
|
|
stbr_resize_advanced(input_data + w * border * n + border * n, in_w, in_h, w*n, output_data, out_w, out_h, out_stride, s0, t0, s1, t1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB, extra_memory, memory_required); |
|
|
|
stbr_resize_arbitrary(input_data + w * border * n + border * n, in_w, in_h, w*n, output_data, out_w, out_h, out_stride, s0, t0, s1, t1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
free(extra_memory); |
|
|
|
|
|
|
|
stbi_image_free(input_data); |
|
|
|
stbi_image_free(input_data); |
|
|
|
|
|
|
|
|
|
|
|
stbi_write_png("output.png", out_w, out_h, n, output_data, out_stride); |
|
|
|
stbi_write_png("output.png", out_w, out_h, n, output_data, out_stride); |
|
|
@ -120,12 +116,8 @@ void resize_image(const char* filename, float width_percent, float height_percen |
|
|
|
|
|
|
|
|
|
|
|
unsigned char* output_data = (unsigned char*)malloc(out_w * out_h * n); |
|
|
|
unsigned char* output_data = (unsigned char*)malloc(out_w * out_h * n); |
|
|
|
|
|
|
|
|
|
|
|
size_t memory_required = stbr_calculate_memory(w, h, out_w, out_h, 0, 0, 1, 1, n, filter); |
|
|
|
stbr_resize_arbitrary(input_data, w, h, 0, output_data, out_w, out_h, 0, 0, 0, 1, 1, n, 0, STBR_TYPE_UINT8, filter, edge, colorspace); |
|
|
|
void* extra_memory = malloc(memory_required); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stbr_resize_advanced(input_data, w, h, 0, output_data, out_w, out_h, 0, 0, 0, 1, 1, n, 0, STBR_TYPE_UINT8, filter, edge, colorspace, extra_memory, memory_required); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(extra_memory); |
|
|
|
|
|
|
|
stbi_image_free(input_data); |
|
|
|
stbi_image_free(input_data); |
|
|
|
|
|
|
|
|
|
|
|
stbi_write_png(output_filename, out_w, out_h, n, output_data, 0); |
|
|
|
stbi_write_png(output_filename, out_w, out_h, n, output_data, 0); |
|
|
@ -199,10 +191,7 @@ void test_float(const char* file, float width_percent, float height_percent, stb |
|
|
|
|
|
|
|
|
|
|
|
float* output_data = (float*)malloc(new_w * new_h * n * sizeof(float)); |
|
|
|
float* output_data = (float*)malloc(new_w * new_h * n * sizeof(float)); |
|
|
|
|
|
|
|
|
|
|
|
size_t required = stbr_calculate_memory(w, h, new_w, new_h, 0, 0, 1, 1, n, STBR_FILTER_CATMULLROM); |
|
|
|
stbr_resize_arbitrary(T_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 0, type, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, colorspace); |
|
|
|
void* extra_memory = malloc(required); |
|
|
|
|
|
|
|
stbr_resize_advanced(T_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 0, type, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, colorspace, extra_memory, required); |
|
|
|
|
|
|
|
free(extra_memory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(T_data); |
|
|
|
free(T_data); |
|
|
|
stbi_image_free(input_data); |
|
|
|
stbi_image_free(input_data); |
|
|
@ -264,12 +253,7 @@ void test_subpixel(const char* file, float width_percent, float height_percent, |
|
|
|
|
|
|
|
|
|
|
|
unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); |
|
|
|
unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); |
|
|
|
|
|
|
|
|
|
|
|
size_t tempmem_size = stbr_calculate_memory(w, h, new_w, new_h, 0, 0, s1, t1, n, STBR_FILTER_CATMULLROM); |
|
|
|
stbr_resize_arbitrary(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, s1, t1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB); |
|
|
|
void* tempmem = malloc(tempmem_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stbr_resize_advanced(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, s1, t1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB, tempmem, tempmem_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(tempmem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stbi_image_free(input_data); |
|
|
|
stbi_image_free(input_data); |
|
|
|
|
|
|
|
|
|
|
@ -300,22 +284,17 @@ void test_premul(const char* file) |
|
|
|
|
|
|
|
|
|
|
|
unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); |
|
|
|
unsigned char* output_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(unsigned char)); |
|
|
|
|
|
|
|
|
|
|
|
size_t tempmem_size = stbr_calculate_memory(w, h, new_w, new_h, 0, 0, 1, 1, n, STBR_FILTER_CATMULLROM); |
|
|
|
stbr_resize_arbitrary(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 3, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB); |
|
|
|
void* tempmem = malloc(tempmem_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stbr_resize_advanced(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 3, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB, tempmem, tempmem_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char output[200]; |
|
|
|
char output[200]; |
|
|
|
sprintf(output, "test-output/premul-%s", file); |
|
|
|
sprintf(output, "test-output/premul-%s", file); |
|
|
|
stbi_write_png(output, new_w, new_h, n, output_data, 0); |
|
|
|
stbi_write_png(output, new_w, new_h, n, output_data, 0); |
|
|
|
|
|
|
|
|
|
|
|
stbr_resize_advanced(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB, tempmem, tempmem_size); |
|
|
|
stbr_resize_arbitrary(input_data, w, h, 0, output_data, new_w, new_h, 0, 0, 0, 1, 1, n, 0, STBR_TYPE_UINT8, STBR_FILTER_CATMULLROM, STBR_EDGE_CLAMP, STBR_COLORSPACE_SRGB); |
|
|
|
|
|
|
|
|
|
|
|
sprintf(output, "test-output/nopremul-%s", file); |
|
|
|
sprintf(output, "test-output/nopremul-%s", file); |
|
|
|
stbi_write_png(output, new_w, new_h, n, output_data, 0); |
|
|
|
stbi_write_png(output, new_w, new_h, n, output_data, 0); |
|
|
|
|
|
|
|
|
|
|
|
free(tempmem); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stbi_image_free(input_data); |
|
|
|
stbi_image_free(input_data); |
|
|
|
|
|
|
|
|
|
|
|
free(output_data); |
|
|
|
free(output_data); |
|
|
|