|
22 | 22 | #define STB_IMAGE_RESIZE_STATIC
|
23 | 23 | #include "stb_image_resize.h"
|
24 | 24 |
|
| 25 | +#include "util.h" |
| 26 | + |
25 | 27 | const char* rng_type_to_str[] = {
|
26 | 28 | "std_default",
|
27 | 29 | "cuda",
|
@@ -825,7 +827,6 @@ int main(int argc, const char* argv[]) {
|
825 | 827 | bool vae_decode_only = true;
|
826 | 828 | uint8_t* input_image_buffer = NULL;
|
827 | 829 | uint8_t* control_image_buffer = NULL;
|
828 |
| - uint8_t* mask_image_buffer = NULL; |
829 | 830 |
|
830 | 831 | if (params.mode == IMG2IMG || params.mode == IMG2VID) {
|
831 | 832 | vae_decode_only = false;
|
@@ -999,15 +1000,18 @@ int main(int argc, const char* argv[]) {
|
999 | 1000 | free_sd_ctx(sd_ctx);
|
1000 | 1001 | return 0;
|
1001 | 1002 | } else {
|
| 1003 | + uint8_t* mask_image_buffer = NULL; |
1002 | 1004 | if (params.mask_path != "") {
|
1003 | 1005 | int c = 0;
|
1004 | 1006 | mask_image_buffer = stbi_load(params.mask_path.c_str(), ¶ms.width, ¶ms.height, &c, 1);
|
1005 | 1007 | } else {
|
1006 | 1008 | std::vector<uint8_t> arr(params.width * params.height, 255);
|
1007 |
| - for (uint8_t dummy_arr : arr) if (dummy_arr) break; // dummy cycle to avoid -O3 optimization |
| 1009 | + // do not remove this LOG_DEBUG line, or -O3 may destroy arr[] |
| 1010 | + // before assigning to mask_image_buffer |
| 1011 | + LOG_DEBUG("img2img: created array with 0x%x fill", arr[0]); |
1008 | 1012 | mask_image_buffer = arr.data();
|
1009 | 1013 | }
|
1010 |
| - sd_image_t mask_image = {(uint32_t)params.width, |
| 1014 | + const sd_image_t mask_image = {(uint32_t)params.width, |
1011 | 1015 | (uint32_t)params.height,
|
1012 | 1016 | 1,
|
1013 | 1017 | mask_image_buffer};
|
|
0 commit comments