From b80b1849aa01a285e80ffdd80a7a676bf88dbd3e Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Tue, 12 Mar 2024 12:24:58 +0100 Subject: [PATCH 01/17] . --- html/header.html | 2 +- html/header_doxygen.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/header.html b/html/header.html index ecc1a89c..e5a601c5 100644 --- a/html/header.html +++ b/html/header.html @@ -23,7 +23,7 @@
Logo

- Latest stable version: 3.3.4        Current pre-release: 3.3.5 (2024/03/04) + Latest stable version: 3.3.5


diff --git a/html/header_doxygen.html b/html/header_doxygen.html index 0fc62a88..381cff27 100644 --- a/html/header_doxygen.html +++ b/html/header_doxygen.html @@ -26,7 +26,7 @@
Logo

- Latest stable version: 3.3.4        Current pre-release: 3.3.5 (2024/03/04) + Latest stable version: 3.3.5


From 5ad84dcc2aeb728b57405dab79f318bf2ef84bd3 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Wed, 13 Mar 2024 16:52:54 +0100 Subject: [PATCH 02/17] Start work on v.3.3.6. --- CImg.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 9d776d6a..c59e7cdc 100644 --- a/CImg.h +++ b/CImg.h @@ -54,7 +54,7 @@ // Set version number of the library. #ifndef cimg_version -#define cimg_version 335 +#define cimg_version 336 /*----------------------------------------------------------- # @@ -23385,7 +23385,8 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(code); +// (l_opcode>'y').move_to(code); + (l_opcode>'y').move_to(code_begin); // A string litteral is initialized only once } else { // Vector values provided as list of items arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s Date: Thu, 14 Mar 2024 09:37:42 +0100 Subject: [PATCH 03/17] . --- CImg.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CImg.h b/CImg.h index c59e7cdc..d4d5c859 100644 --- a/CImg.h +++ b/CImg.h @@ -17763,7 +17763,8 @@ namespace cimg_library { if (arg1==~0U) { // Create new variable if (is_vector(arg3)) { // Vector variable - arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); +// arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); + arg1 = copy(arg3); set_reserved_vector(arg1); // Prevent from being used in further optimization } else { // Scalar variable if (is_const) arg1 = arg3; @@ -23363,8 +23364,11 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(code); - return_new_comp = true; +// (l_opcode>'y').move_to(code); + if (!is_inside_begin) code.swap(code_begin); + (l_opcode>'y').move_to(code_begin); + if (!is_inside_begin) code.swap(code_begin); +// return_new_comp = true; _cimg_mp_return(pos); } From e80d43565625d81a122fa3c5a007d607368fd632 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Thu, 14 Mar 2024 09:38:07 +0100 Subject: [PATCH 04/17] . --- CImg.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CImg.h b/CImg.h index d4d5c859..7256a9f8 100644 --- a/CImg.h +++ b/CImg.h @@ -23390,7 +23390,9 @@ namespace cimg_library { CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); // (l_opcode>'y').move_to(code); + if (!is_inside_begin) code.swap(code_begin); (l_opcode>'y').move_to(code_begin); // A string litteral is initialized only once + if (!is_inside_begin) code.swap(code_begin); } else { // Vector values provided as list of items arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s Date: Thu, 14 Mar 2024 19:24:53 +0100 Subject: [PATCH 05/17] . --- CImg.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/CImg.h b/CImg.h index 7256a9f8..b02b208c 100644 --- a/CImg.h +++ b/CImg.h @@ -23365,9 +23365,7 @@ namespace cimg_library { CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); // (l_opcode>'y').move_to(code); - if (!is_inside_begin) code.swap(code_begin); - (l_opcode>'y').move_to(code_begin); - if (!is_inside_begin) code.swap(code_begin); + (l_opcode>'y').move_to(is_inside_begin?code:code_begin); // return_new_comp = true; _cimg_mp_return(pos); } @@ -23389,10 +23387,8 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); -// (l_opcode>'y').move_to(code); - if (!is_inside_begin) code.swap(code_begin); - (l_opcode>'y').move_to(code_begin); // A string litteral is initialized only once - if (!is_inside_begin) code.swap(code_begin); + // (l_opcode>'y').move_to(code); + (l_opcode>'y').move_to(is_inside_begin?code:code_begin); } else { // Vector values provided as list of items arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s Date: Thu, 14 Mar 2024 21:39:20 +0100 Subject: [PATCH 06/17] . --- CImg.h | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CImg.h b/CImg.h index b02b208c..ba68d0b8 100644 --- a/CImg.h +++ b/CImg.h @@ -17235,13 +17235,14 @@ namespace cimg_library { return_new_comp = false; // Bits of 'block_flags' tell about in which code block we currently are: - // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(). + // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(), 5: is_new_assignment const bool is_inside_critical = (bool)(block_flags&1), is_inside_begin = (bool)(block_flags&2), is_inside_begin_t = (bool)(block_flags&4), is_inside_end = (bool)(block_flags&8), - is_inside_end_t = (bool)(block_flags&16); + is_inside_end_t = (bool)(block_flags&16), + is_new_assignment = (bool)(block_flags&32); // 'p_ref' is a 'unsigned int[7]' used to return a reference to an image or vector value // linked to the returned memory slot (reference that cannot be determined at compile time). @@ -17756,15 +17757,14 @@ namespace cimg_library { // Assign variable (direct). get_variable_pos(variable_name,arg1,arg2); - arg3 = compile(s + 1,se,depth1,0,block_flags); + arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; + arg3 = compile(s + 1,se,depth1,0,block_flags|(arg1==~0U?32:0)); is_sth = return_new_comp; // is arg3 a new blank object? if (is_const) _cimg_mp_check_const_scalar(arg3,2,0); - arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; if (arg1==~0U) { // Create new variable if (is_vector(arg3)) { // Vector variable -// arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); - arg1 = copy(arg3); + arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); set_reserved_vector(arg1); // Prevent from being used in further optimization } else { // Scalar variable if (is_const) arg1 = arg3; @@ -23364,9 +23364,8 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); -// (l_opcode>'y').move_to(code); - (l_opcode>'y').move_to(is_inside_begin?code:code_begin); -// return_new_comp = true; + (l_opcode>'y').move_to(is_inside_begin || is_new_assignment?code:code_begin); + return_new_comp = is_new_assignment; _cimg_mp_return(pos); } @@ -23387,9 +23386,9 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - // (l_opcode>'y').move_to(code); - (l_opcode>'y').move_to(is_inside_begin?code:code_begin); + (l_opcode>'y').move_to(is_inside_begin || is_new_assignment?code:code_begin); } else { // Vector values provided as list of items + is_sth = true; // Is constant values? arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s Date: Thu, 14 Mar 2024 22:08:45 +0100 Subject: [PATCH 07/17] . --- CImg.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index ba68d0b8..e3d2c23c 100644 --- a/CImg.h +++ b/CImg.h @@ -23387,13 +23387,15 @@ namespace cimg_library { CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); (l_opcode>'y').move_to(is_inside_begin || is_new_assignment?code:code_begin); - } else { // Vector values provided as list of items + return_new_comp = is_new_assignment; + } else { // Vector values provided as a list of items is_sth = true; // Is constant values? arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s::sequence(arg3,arg2 + 1,arg2 + arg3).move_to(l_opcode); @@ -23407,8 +23409,8 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); + return_new_comp = is_sth && is_new_assignment; } - return_new_comp = is_new_assignment; _cimg_mp_return(pos); } From 1e66676890714cc6db99befaa922cf860819173d Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 07:16:42 +0100 Subject: [PATCH 08/17] . --- CImg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CImg.h b/CImg.h index e3d2c23c..4419eebb 100644 --- a/CImg.h +++ b/CImg.h @@ -17181,7 +17181,7 @@ namespace cimg_library { // Compilation procedure. unsigned int compile(char *ss, char *se, const unsigned int depth, unsigned int *const p_ref, - const unsigned char block_flags) { + unsigned char block_flags) { if (depth>256) { cimg::strellipsize(expr,64); throw CImgArgumentException("[" cimg_appname "_math_parser] " @@ -17243,6 +17243,7 @@ namespace cimg_library { is_inside_end = (bool)(block_flags&8), is_inside_end_t = (bool)(block_flags&16), is_new_assignment = (bool)(block_flags&32); + block_flags&=-32; // 'p_ref' is a 'unsigned int[7]' used to return a reference to an image or vector value // linked to the returned memory slot (reference that cannot be determined at compile time). From 2f16f80267a064da177fd904fed4450e1dafba3c Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 08:12:37 +0100 Subject: [PATCH 09/17] . --- CImg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 4419eebb..aa5b390d 100644 --- a/CImg.h +++ b/CImg.h @@ -17243,7 +17243,7 @@ namespace cimg_library { is_inside_end = (bool)(block_flags&8), is_inside_end_t = (bool)(block_flags&16), is_new_assignment = (bool)(block_flags&32); - block_flags&=-32; +// block_flags&=-32; // 'p_ref' is a 'unsigned int[7]' used to return a reference to an image or vector value // linked to the returned memory slot (reference that cannot be determined at compile time). @@ -17286,7 +17286,7 @@ namespace cimg_library { variable_name.assign(65); if (cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep)==1) { nb = 1; - val = (double)std::strtol(variable_name,0,2); + val = (double)std::strtoll(variable_name,0,2); } if (is_sth) val = -val; variable_name.assign(); From 4f72810aef11a229ec8d06a800e5572ccb43c04f Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 08:43:39 +0100 Subject: [PATCH 10/17] . --- CImg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index aa5b390d..588ac68a 100644 --- a/CImg.h +++ b/CImg.h @@ -17274,14 +17274,14 @@ namespace cimg_library { if (!cimg::strcasecmp(s,"inf")) { val = cimg::type::inf(); nb = 1; } else if (!cimg::strcasecmp(s,"nan")) { val = cimg::type::nan(); nb = 1; } if (nb==1 && is_sth) val = -val; - } else if (*s=='0' && (s[1]=='x' || s[1]=='X')) { // Hexadecimal litteral + } else if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]!='-') { // Hexadecimal litteral is_sth = *ss=='-'; if (cimg_sscanf(s + 2,"%x%c",&arg1,&sep)==1) { nb = 1; val = (double)arg1; if (is_sth) val = -val; } - } else if (*s=='0' && (s[1]=='b' || s[1]=='B')) { // Binary litteral + } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && s[2]!='-') { // Binary litteral is_sth = *ss=='-'; variable_name.assign(65); if (cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep)==1) { From 561e753487f027ee5bb86aefc2b6650216a7ac1e Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 08:58:30 +0100 Subject: [PATCH 11/17] . --- CImg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CImg.h b/CImg.h index 588ac68a..6ceb01d7 100644 --- a/CImg.h +++ b/CImg.h @@ -28401,7 +28401,7 @@ namespace cimg_library { int err = 0; char sep; - if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]>32) { // Hexadecimal number + if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]>32 && s[2]!='-') { // Hexadecimal number unsigned int ival; err = cimg_sscanf(s + 2,"%x%c",&ival,&sep); if (err>0) val = (double)ival; From c88456d552a2076d6a8452837ae7dc154a20a1d5 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 10:46:50 +0100 Subject: [PATCH 12/17] . --- CImg.h | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/CImg.h b/CImg.h index 6ceb01d7..46c0c742 100644 --- a/CImg.h +++ b/CImg.h @@ -17268,30 +17268,23 @@ namespace cimg_library { // Look for a single value or a pre-defined variable. int nb = 0; - s = ss + (*ss=='+' || *ss=='-'?1:0); + is_sth = *ss=='-'; + s = ss + (*ss=='+' || is_sth?1:0); if (*s=='i' || *s=='I' || *s=='n' || *s=='N') { // Particular cases : +/-NaN and +/-Inf - is_sth = *ss=='-'; if (!cimg::strcasecmp(s,"inf")) { val = cimg::type::inf(); nb = 1; } else if (!cimg::strcasecmp(s,"nan")) { val = cimg::type::nan(); nb = 1; } - if (nb==1 && is_sth) val = -val; } else if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]!='-') { // Hexadecimal litteral - is_sth = *ss=='-'; - if (cimg_sscanf(s + 2,"%x%c",&arg1,&sep)==1) { - nb = 1; - val = (double)arg1; - if (is_sth) val = -val; - } + cimg_uint64 num; + if ((nb = cimg_sscanf(s + 2,"%lx%c",&num,&sep))==1 || (nb==2 && sep=='%')) + val = (double)num; } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && s[2]!='-') { // Binary litteral - is_sth = *ss=='-'; variable_name.assign(65); - if (cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep)==1) { - nb = 1; + if ((nb = cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep))==1 || (nb==2 && sep=='%')) val = (double)std::strtoll(variable_name,0,2); - } - if (is_sth) val = -val; variable_name.assign(); } - if (!nb) nb = cimg_sscanf(ss,"%lf%c%c",&val,&(sep=0),&(end=0)); + if (is_sth && nb) val = -val; + else if (!nb) nb = cimg_sscanf(ss,"%lf%c%c",&val,&(sep=0),&(end=0)); if (nb==1) _cimg_mp_const_scalar(val); if (nb==2 && sep=='%') _cimg_mp_const_scalar(val/100); @@ -28400,11 +28393,13 @@ namespace cimg_library { if (is_negative || *s=='+') ++s; int err = 0; char sep; - - if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]>32 && s[2]!='-') { // Hexadecimal number - unsigned int ival; - err = cimg_sscanf(s + 2,"%x%c",&ival,&sep); - if (err>0) val = (double)ival; + if (*s=='0' && (s[1]=='x' || s[1]=='X') && + ((s[2]>='0' && s[2]<='9') || (s[2]>='a' && s[2]<='f') || (s[2]>='a' && s[2]<='f'))) { // Hexadecimal number + val = (double)std::strtoll(s + 2,0,16); + err = 1; + } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && (s[2]=='0' || s[2]=='1')) { // Binary number + val = (double)std::strtoll(s + 2,0,2); + err = 1; } else if (*s>32) { // Decimal number err = cimg_sscanf(s,"%lf%c",&val,&sep); #if cimg_OS==2 From 01203e2425c51c76a1dd8b0da222d5f1c35516ce Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 13:47:57 +0100 Subject: [PATCH 13/17] . --- CImg.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CImg.h b/CImg.h index 46c0c742..4f7cdaff 100644 --- a/CImg.h +++ b/CImg.h @@ -17235,15 +17235,15 @@ namespace cimg_library { return_new_comp = false; // Bits of 'block_flags' tell about in which code block we currently are: - // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(), 5: is_new_assignment + // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(), 5: is_new_variable_assignment const bool is_inside_critical = (bool)(block_flags&1), is_inside_begin = (bool)(block_flags&2), is_inside_begin_t = (bool)(block_flags&4), is_inside_end = (bool)(block_flags&8), is_inside_end_t = (bool)(block_flags&16), - is_new_assignment = (bool)(block_flags&32); -// block_flags&=-32; + is_new_variable_assignment = (bool)(block_flags&32); + block_flags&=31; // Deeper calls to 'compile()' won't automatically pass 'is_new_variable_assigment=true' // 'p_ref' is a 'unsigned int[7]' used to return a reference to an image or vector value // linked to the returned memory slot (reference that cannot be determined at compile time). @@ -17759,6 +17759,7 @@ namespace cimg_library { if (arg1==~0U) { // Create new variable if (is_vector(arg3)) { // Vector variable arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); +// arg1 = copy(arg3); set_reserved_vector(arg1); // Prevent from being used in further optimization } else { // Scalar variable if (is_const) arg1 = arg3; @@ -23358,8 +23359,8 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(is_inside_begin || is_new_assignment?code:code_begin); - return_new_comp = is_new_assignment; + (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); + return_new_comp = is_new_variable_assignment; _cimg_mp_return(pos); } @@ -23380,8 +23381,8 @@ namespace cimg_library { CImg::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode); CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); - (l_opcode>'y').move_to(is_inside_begin || is_new_assignment?code:code_begin); - return_new_comp = is_new_assignment; + (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); + return_new_comp = is_new_variable_assignment; } else { // Vector values provided as a list of items is_sth = true; // Is constant values? arg1 = 0; // Number of specified values @@ -23403,7 +23404,7 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = is_sth && is_new_assignment; + return_new_comp = is_sth && is_new_variable_assignment; } _cimg_mp_return(pos); } From 663216b49bf0e5a0468e3bded1c699e3f6805356 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 16:55:59 +0100 Subject: [PATCH 14/17] . --- CImg.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CImg.h b/CImg.h index 4f7cdaff..629c8c5c 100644 --- a/CImg.h +++ b/CImg.h @@ -17094,7 +17094,7 @@ namespace cimg_library { mem[_cimg_mp_slot_nan] = cimg::type::nan(); // nan // Set value property : - // { -1 = reserved (e.g. variable) | 0 = computation value | + // { -1 = reserved (e.g. variable) | 0 = computation scalar | // 1 = compile-time constant | N>1 = constant ptr to vector[N-1] }. memtype.assign(mem._width,1,1,1,0); for (unsigned int i = 0; i<_cimg_mp_slot_x; ++i) memtype[i] = 1; @@ -17759,7 +17759,6 @@ namespace cimg_library { if (arg1==~0U) { // Create new variable if (is_vector(arg3)) { // Vector variable arg1 = is_sth || is_comp_vector(arg3)?arg3:copy(arg3); -// arg1 = copy(arg3); set_reserved_vector(arg1); // Prevent from being used in further optimization } else { // Scalar variable if (is_const) arg1 = arg3; @@ -23361,6 +23360,7 @@ namespace cimg_library { std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); return_new_comp = is_new_variable_assignment; + if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization _cimg_mp_return(pos); } @@ -23383,14 +23383,18 @@ namespace cimg_library { std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); return_new_comp = is_new_variable_assignment; + if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization } else { // Vector values provided as a list of items - is_sth = true; // Is constant values? + is_sth = true; // Can vector be defined once in 'begin()'? arg1 = 0; // Number of specified values if (*ss1!=']') for (s = ss1; s::sequence(arg3,arg2 + 1,arg2 + arg3).move_to(l_opcode); @@ -23403,8 +23407,10 @@ namespace cimg_library { l_opcode.insert(CImg::vector((ulongT)mp_vector_init,pos,0,arg1),0); (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; - opcode.move_to(code); - return_new_comp = is_sth && is_new_variable_assignment; +// opcode.move_to(code); + opcode.move_to(!is_sth || is_inside_begin || is_new_variable_assignment?code:code_begin); + return_new_comp = !is_sth && is_new_variable_assignment; + if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization } _cimg_mp_return(pos); } From b1a66122ee0776b61db54510f7dd3ac9ad29a715 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 17:54:05 +0100 Subject: [PATCH 15/17] . --- CImg.h | 228 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/CImg.h b/CImg.h index 629c8c5c..5470bff8 100644 --- a/CImg.h +++ b/CImg.h @@ -16981,7 +16981,7 @@ namespace cimg_library { unsigned int mempos, mem_img_median, mem_img_norm, mem_img_index, debug_indent, result_dim, result_end_dim, break_type, constcache_size; - bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, need_input_copy, return_new_comp; + bool is_parallelizable, is_noncritical_run, is_end_code, is_fill, need_input_copy, return_comp; double *result, *result_end; cimg_uint64 rng; const char *const calling_function, *s_op, *ss_op; @@ -17093,9 +17093,9 @@ namespace cimg_library { mem[29] = DBL_EPSILON; // eps mem[_cimg_mp_slot_nan] = cimg::type::nan(); // nan - // Set value property : + // Type property for each value in memory : // { -1 = reserved (e.g. variable) | 0 = computation scalar | - // 1 = compile-time constant | N>1 = constant ptr to vector[N-1] }. + // 1 = compile-time constant | N>1 = start of a vector(#N-1) }. memtype.assign(mem._width,1,1,1,0); for (unsigned int i = 0; i<_cimg_mp_slot_x; ++i) memtype[i] = 1; memtype[_cimg_mp_slot_t] = memtype[_cimg_mp_slot_x] = memtype[_cimg_mp_slot_y] = @@ -17232,7 +17232,7 @@ namespace cimg_library { *s, *ps, *ns, *s0, *s1, *s2, *s3, sep = 0, end = 0; double val = 0, val1, val2; mp_func op; - return_new_comp = false; + return_comp = false; // Bits of 'block_flags' tell about in which code block we currently are: // 0: critical(), 1: begin(), 2: begin_t(), 3: end(), 4: end_t(), 5: is_new_variable_assignment @@ -17329,7 +17329,7 @@ namespace cimg_library { need_input_copy = true; pos = vector(imgin._spectrum); CImg::vector((ulongT)mp_Joff,pos,0,0,imgin._spectrum).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); case 'R' : if (reserved_label[(int)'R']!=~0U) _cimg_mp_return(reserved_label[(int)'R']); @@ -17753,7 +17753,7 @@ namespace cimg_library { get_variable_pos(variable_name,arg1,arg2); arg1 = arg2!=~0U?reserved_label[arg2]:arg1!=~0U?variable_pos[arg1]:~0U; arg3 = compile(s + 1,se,depth1,0,block_flags|(arg1==~0U?32:0)); - is_sth = return_new_comp; // is arg3 a new blank object? + is_sth = return_comp; // is arg3 a new blank object? if (is_const) _cimg_mp_check_const_scalar(arg3,2,0); if (arg1==~0U) { // Create new variable @@ -17799,7 +17799,7 @@ namespace cimg_library { } else // Scalar CImg::vector((ulongT)mp_copy,arg1,arg3).move_to(code); } - return_new_comp = false; + return_comp = false; _cimg_mp_return(arg1); } @@ -18198,7 +18198,7 @@ namespace cimg_library { if (arg4) pos = vector(arg4); else pos = scalar(); CImg::vector((ulongT)mp_if,pos,arg1,arg2,arg3, p3 - p2,code._width - p3,arg4).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18216,7 +18216,7 @@ namespace cimg_library { if (!arg1) _cimg_mp_scalar1(mp_bool,arg2); pos = scalar(); CImg::vector((ulongT)mp_logical_or,pos,arg1,arg2,code._width - p2).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18235,7 +18235,7 @@ namespace cimg_library { pos = scalar(); CImg::vector((ulongT)mp_logical_and,pos,arg1,arg2,code._width - p2). move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18288,7 +18288,7 @@ namespace cimg_library { if (p1 && p2 && p1!=p2) _cimg_mp_return(1); pos = scalar(); CImg::vector((ulongT)mp_vector_neq,pos,arg1,p1,arg2,p2,11,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18308,7 +18308,7 @@ namespace cimg_library { if (p1 && p2 && p1!=p2) _cimg_mp_return(0); pos = scalar(); CImg::vector((ulongT)mp_vector_eq,pos,arg1,p1,arg2,p2,11,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18499,7 +18499,7 @@ namespace cimg_library { if (is_vector(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_mul,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_vector(arg1) && is_scalar(arg2)) _cimg_mp_vector2_vs(mp_mul,arg1,arg2); @@ -18521,14 +18521,14 @@ namespace cimg_library { if (is_vector(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_div_vv,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_vector(arg1) && is_scalar(arg2)) _cimg_mp_vector2_vs(mp_div,arg1,arg2); if (is_scalar(arg1) && is_vector(arg2)) { pos = vector(2); CImg::vector((ulongT)mp_complex_div_sv,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1) && is_const_scalar(arg2)) @@ -18545,7 +18545,7 @@ namespace cimg_library { if (p2>0 && (ulongT)size(arg1)==(ulongT)p2*p2) { // Particular case of matrix multiplication pos = vector(p2); CImg::vector((ulongT)mp_matrix_mul,pos,arg1,arg2,p2,p2,1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } _cimg_mp_check_type(arg2,2,3,size(arg1)); @@ -18661,7 +18661,7 @@ namespace cimg_library { else CImg::vector((ulongT)mp_complex_pow_ss,pos,arg1,arg2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18895,7 +18895,7 @@ namespace cimg_library { CImg::vector((ulongT)(is_relative?mp_Joff:mp_Ioff), pos,arg1,arg2==~0U?_cimg_mp_boundary:arg2,p2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -18955,7 +18955,7 @@ namespace cimg_library { arg3 = (unsigned int)mem[arg3]; pos = vector(arg3); CImg::vector((ulongT)mp_vector_crop,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19068,7 +19068,7 @@ namespace cimg_library { arg4==~0U?_cimg_mp_interpolation:arg4, arg5==~0U?_cimg_mp_boundary:arg5,p2).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19246,13 +19246,13 @@ namespace cimg_library { if (p2) { pos = vector(p2); std::memset(&mem[pos] + 1,0,p2*sizeof(double)); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } else _cimg_mp_return(0); } pos = opcode[1] = p2?vector(p2):scalar(); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19405,7 +19405,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_conj,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_conj,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19424,7 +19424,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_exp,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_exp,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19435,7 +19435,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_log,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_log,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19446,7 +19446,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_cos,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_cos,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19457,7 +19457,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sin,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sin,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19468,7 +19468,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sqr,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sqr,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19479,7 +19479,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sqrt,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sqrt,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19490,7 +19490,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_tan,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_tan,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19501,7 +19501,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_cosh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_cosh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19512,7 +19512,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_sinh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_sinh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19523,7 +19523,7 @@ namespace cimg_library { pos = vector(2); if (is_scalar(arg1)) CImg::vector((ulongT)mp_complex_tanh,pos,arg1,0).move_to(code); else CImg::vector((ulongT)mp_complex_tanh,pos,arg1 + 1,arg1 + 2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19827,7 +19827,7 @@ namespace cimg_library { opcode[9],opcode[10],opcode[11],opcode[12], // 11-14: dx,dy,dz,dc opcode[13]).move_to(code); // 15: boundary conditions } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19840,7 +19840,7 @@ namespace cimg_library { _cimg_mp_check_type(arg2,2,2,3); pos = vector(3); CImg::vector((ulongT)mp_cross,pos,arg1,arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -19903,7 +19903,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_cumulate,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20035,7 +20035,7 @@ namespace cimg_library { opcode[22] = (ulongT)yend; opcode[23] = (ulongT)zend; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -20070,7 +20070,7 @@ namespace cimg_library { p2 = imglist[p3]._spectrum; if (p2>1) pos = vector(p2); else pos = scalar(); // Return vector or scalar result CImg::vector((ulongT)mp_da_back_or_pop,pos,p2,p1,is_pop_heap?2:is_pop?1:0).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20176,7 +20176,7 @@ namespace cimg_library { CImg::vector((ulongT)mp_date,pos,size(pos), arg1,arg1==~0U?~0U:size(arg1), arg2,arg2==~0U?~0U:size(arg2)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20287,7 +20287,7 @@ namespace cimg_library { opcode[1] = pos; opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20574,7 +20574,7 @@ namespace cimg_library { p1 = (unsigned int)cimg::round(std::sqrt((float)size(arg1))); pos = vector((p1 + 1)*p1); CImg::vector((ulongT)mp_matrix_eig,pos,arg1,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20626,7 +20626,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; pos = vector(p1); CImg::vector((ulongT)mp_vector_equalize,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20688,7 +20688,7 @@ namespace cimg_library { p2 = arg2*arg3*arg4*arg5; if (p2) pos = vector(p2); else pos = scalar(); CImg::vector((ulongT)mp_expr,pos,arg1,p1,arg2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20699,7 +20699,7 @@ namespace cimg_library { p1 = (unsigned int)mem[arg1]; pos = vector(p1*p1); CImg::vector((ulongT)mp_eye,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -20920,7 +20920,7 @@ namespace cimg_library { _cimg_mp_check_type(arg1,1,2,0); pos = scalar(); CImg::vector((ulongT)mp_fsize,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -20984,7 +20984,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; if (arg2) pos = vector(arg2); else pos = scalar(); CImg::vector((ulongT)mp_get,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -21022,7 +21022,7 @@ namespace cimg_library { arg2 = (unsigned int)mem[arg2]; pos = vector(arg2); CImg::vector((ulongT)mp_vector_histogram,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -21037,7 +21037,7 @@ namespace cimg_library { } else { if (ss3!=se1) break; p1 = ~0U; } pos = scalar(); CImg::vector((ulongT)mp_image_median,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21050,7 +21050,7 @@ namespace cimg_library { } else { if (ss3!=se1) break; p1 = ~0U; } pos = scalar(); CImg::vector((ulongT)mp_image_norm,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21074,7 +21074,7 @@ namespace cimg_library { if (arg4) pos = vector(arg4); else pos = scalar(); CImg::vector((ulongT)mp_if,pos,arg1,arg2,arg3, p3 - p2,code._width - p3,arg4).move_to(code,p2); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21116,7 +21116,7 @@ namespace cimg_library { std::max(p1,1U),arg3); pos = vector(arg5?p1:p1/arg3); CImg::vector((ulongT)mp_vector_index,pos,arg1,p1,arg2,p2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21160,7 +21160,7 @@ namespace cimg_library { } pos = arg6?vector(arg6):scalar(); CImg::vector((ulongT)mp_inrange,pos,arg6,arg1,p1,arg2,p2,arg3,p3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21215,7 +21215,7 @@ namespace cimg_library { } pos = vector(p1); CImg::vector((ulongT)mp_matrix_invert,pos,arg1,p2,p3,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } if (is_const_scalar(arg1)) _cimg_mp_const_scalar(1/mem[arg1]); @@ -21248,7 +21248,7 @@ namespace cimg_library { arg1 = compile(ss6,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isdir,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21257,7 +21257,7 @@ namespace cimg_library { arg1 = compile(ss7,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isfile,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21276,7 +21276,7 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21351,7 +21351,7 @@ namespace cimg_library { arg1 = compile(ss + 10,se1,depth1,0,block_flags); pos = scalar(); CImg::vector((ulongT)mp_isvarname,pos,arg1,(ulongT)size(arg1)).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } } @@ -21388,7 +21388,7 @@ namespace cimg_library { _cimg_mp_check_type(arg2,2,2,p1); pos = vector(p1); CImg::vector((ulongT)mp_vector_lerp,pos,p1,arg1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21471,7 +21471,7 @@ namespace cimg_library { } pos = vector(p1*arg4); CImg::vector((ulongT)mp_map,pos,arg1,arg2,p1,p2,arg3,arg4,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21501,7 +21501,7 @@ namespace cimg_library { } pos = vector(arg4*p3); CImg::vector((ulongT)mp_matrix_mul,pos,arg1,arg2,arg4,arg5,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21537,7 +21537,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_mirror,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21605,7 +21605,7 @@ namespace cimg_library { } pos = vector(wS*wD); CImg::vector((ulongT)mp_mproj,pos,arg1,wS,hS,arg3,wD,arg5,arg6,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21696,7 +21696,7 @@ namespace cimg_library { } else arg1 = 1024; pos = vector(arg1); CImg::vector((ulongT)mp_name,pos,p1,arg1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -21726,7 +21726,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_noise,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21754,7 +21754,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_normalize,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21782,7 +21782,7 @@ namespace cimg_library { _cimg_mp_check_type(arg1,1,1,0); pos = vector(4); CImg::vector((ulongT)mp_o2c,pos,p1,arg1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -21836,7 +21836,7 @@ namespace cimg_library { std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5); pos = vector(arg2*arg3*arg4*arg5); CImg::vector((ulongT)mp_vector_permute,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -21971,7 +21971,7 @@ namespace cimg_library { if (arg5!=~0U) _cimg_mp_check_type(arg5,p3 + 4,1,0); pos = vector(arg1); CImg::vector((ulongT)mp_vector_rand,pos,arg1,arg2,arg3,arg4,p2,arg5).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22124,7 +22124,7 @@ namespace cimg_library { opcode[2] = (ulongT)p1; opcode.move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } else { // Image @@ -22164,7 +22164,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_vector_reverse,pos,arg1,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22215,7 +22215,7 @@ namespace cimg_library { pos = vector(4); CImg::vector((ulongT)mp_rot2d,pos,arg1).move_to(code); } - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22256,7 +22256,7 @@ namespace cimg_library { opcode[1] = pos; opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } #endif @@ -22322,7 +22322,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_shift,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22398,7 +22398,7 @@ namespace cimg_library { } pos = vector(arg6*p3); CImg::vector((ulongT)mp_solve,pos,arg1,arg2,arg6,arg5,p3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22423,7 +22423,7 @@ namespace cimg_library { p1 = size(arg1); pos = vector(p1); CImg::vector((ulongT)mp_sort,pos,arg1,p1,arg2,arg3,arg4).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22459,7 +22459,7 @@ namespace cimg_library { } else { if (ss6!=se1) break; p1 = ~0U; } pos = vector(14); CImg::vector((ulongT)mp_image_stats,pos,p1).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22521,7 +22521,7 @@ namespace cimg_library { p1 = size(arg1); pos = scalar(); CImg::vector((ulongT)mp_s2v,pos,arg1,p1,arg2,arg3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22558,7 +22558,7 @@ namespace cimg_library { opcode[2] = arg1; opcode[3] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22583,7 +22583,7 @@ namespace cimg_library { } pos = vector(p1 + p2 + p2*p2); CImg::vector((ulongT)mp_matrix_svd,pos,arg1,p2,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22762,7 +22762,7 @@ namespace cimg_library { } pos = vector(p3*p2); CImg::vector((ulongT)mp_transpose,pos,arg1,p2,p3).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -22785,7 +22785,7 @@ namespace cimg_library { arg2 = s10) pos = is_comp_vector(arg1)?arg1:((return_new_comp = true), vector(p1)); + if (p1>0) pos = is_comp_vector(arg1)?arg1:((return_comp = true), vector(p1)); else { pos = scalar(); if (is_const_scalar(arg1) && is_const_scalar(arg2)) { @@ -22868,7 +22868,7 @@ namespace cimg_library { (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22928,7 +22928,7 @@ namespace cimg_library { opcode[2] = p1; opcode[3] = opcode._height; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -22952,7 +22952,7 @@ namespace cimg_library { } pos = vector(p1); CImg::vector((ulongT)mp_v2s,pos,p1,arg1,size(arg1),arg2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } break; @@ -23050,7 +23050,7 @@ namespace cimg_library { opcode[0] = (ulongT)mp_vector_warp; opcode[1] = (ulongT)pos; opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23122,7 +23122,7 @@ namespace cimg_library { } opcode[1] = pos = scalar(); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23223,7 +23223,7 @@ namespace cimg_library { opcode[2] = opcode._height; if (is_sth) _cimg_mp_const_scalar(op(*this)); opcode.move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); } @@ -23359,8 +23359,8 @@ namespace cimg_library { CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); - return_new_comp = is_new_variable_assignment; - if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization + return_comp = is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization _cimg_mp_return(pos); } @@ -23382,8 +23382,8 @@ namespace cimg_library { CImg(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode); std::memcpy((char*)l_opcode[1]._data,variable_name,arg1); (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin); - return_new_comp = is_new_variable_assignment; - if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization + return_comp = is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization } else { // Vector values provided as a list of items is_sth = true; // Can vector be defined once in 'begin()'? arg1 = 0; // Number of specified values @@ -23409,8 +23409,8 @@ namespace cimg_library { opcode[2] = opcode._height; // opcode.move_to(code); opcode.move_to(!is_sth || is_inside_begin || is_new_variable_assignment?code:code_begin); - return_new_comp = !is_sth && is_new_variable_assignment; - if (!return_new_comp) set_reserved_vector(pos); // Prevent from being used in further optimization + return_comp = !is_sth && is_new_variable_assignment; + if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization } _cimg_mp_return(pos); } @@ -23451,7 +23451,7 @@ namespace cimg_library { if (!p2) _cimg_mp_return(0); pos = vector(p2); CImg::vector((ulongT)mp_list_Joff,pos,p1,0,0,p2).move_to(code); - return_new_comp = true; + return_comp = true; _cimg_mp_return(pos); case 'R' : // R#ind if (!imglist) _cimg_mp_return(0); @@ -24203,7 +24203,7 @@ namespace cimg_library { // (this forces a copy to be made. Use 'same()' for cases where you may want to return 'arg'). unsigned int copy(const unsigned int arg) { const unsigned int siz = size(arg); - return_new_comp = true; + return_comp = true; if (siz) { // Vector const unsigned int pos = vector(siz); CImg::vector((ulongT)mp_vector_copy,pos,arg,siz).move_to(code); @@ -24216,15 +24216,15 @@ namespace cimg_library { // (this avoids a copy to be made when possible. Use 'copy()' to force the copy of a value). unsigned int same(const unsigned int arg) { if (is_const_scalar(arg)) return arg; - if (is_comp_scalar(arg)) { return_new_comp = true; return arg; } + if (is_comp_scalar(arg)) { return_comp = true; return arg; } const unsigned int siz = size(arg); if (siz) { // Vector - if (is_comp_vector(arg)) { return_new_comp = true; return arg; } + if (is_comp_vector(arg)) { return_comp = true; return arg; } const unsigned int pos = vector(siz); CImg::vector((ulongT)mp_vector_copy,pos,arg,siz).move_to(code); return pos; } - return_new_comp = true; + return_comp = true; return scalar1(mp_copy,arg); // Scalar } @@ -24238,14 +24238,14 @@ namespace cimg_library { unsigned int scalar0(const mp_func op) { const unsigned int pos = scalar(); CImg::vector((ulongT)op,pos).move_to(code); - return_new_comp = true; + return_comp = true; return pos; } unsigned int scalar1(const mp_func op, const unsigned int arg1) { const unsigned int pos = arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1) && op!=mp_copy?arg1: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1).move_to(code); return pos; } @@ -24254,7 +24254,7 @@ namespace cimg_library { const unsigned int pos = arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1)?arg1: arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2).move_to(code); return pos; } @@ -24265,7 +24265,7 @@ namespace cimg_library { arg1!=~0U && arg1>_cimg_mp_slot_c && is_comp_scalar(arg1)?arg1: arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3).move_to(code); return pos; } @@ -24278,7 +24278,7 @@ namespace cimg_library { arg2!=~0U && arg2>_cimg_mp_slot_c && is_comp_scalar(arg2)?arg2: arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4).move_to(code); return pos; } @@ -24292,7 +24292,7 @@ namespace cimg_library { arg3!=~0U && arg3>_cimg_mp_slot_c && is_comp_scalar(arg3)?arg3: arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5).move_to(code); return pos; } @@ -24307,7 +24307,7 @@ namespace cimg_library { arg4!=~0U && arg4>_cimg_mp_slot_c && is_comp_scalar(arg4)?arg4: arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: arg6!=~0U && arg6>_cimg_mp_slot_c && is_comp_scalar(arg6)?arg6: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5,arg6).move_to(code); return pos; } @@ -24324,7 +24324,7 @@ namespace cimg_library { arg5!=~0U && arg5>_cimg_mp_slot_c && is_comp_scalar(arg5)?arg5: arg6!=~0U && arg6>_cimg_mp_slot_c && is_comp_scalar(arg6)?arg6: arg7!=~0U && arg7>_cimg_mp_slot_c && is_comp_scalar(arg7)?arg7: - ((return_new_comp = true), scalar()); + ((return_comp = true), scalar()); CImg::vector((ulongT)op,pos,arg1,arg2,arg3,arg4,arg5,arg6,arg7).move_to(code); return pos; } @@ -24353,7 +24353,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,1,siz,(ulongT)op,arg1).move_to(code); else { code.insert(siz); @@ -24367,7 +24367,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1:is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_vv,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24381,7 +24381,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24395,7 +24395,7 @@ namespace cimg_library { const unsigned int siz = size(arg2), pos = is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_sv,pos,2,siz,(ulongT)op,arg1,arg2).move_to(code); else { code.insert(siz); @@ -24410,7 +24410,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,3,siz,(ulongT)op,arg1,arg2,arg3).move_to(code); else { code.insert(siz); @@ -24425,7 +24425,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1:is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_vv,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { @@ -24442,7 +24442,7 @@ namespace cimg_library { const unsigned int siz = size(arg1), pos = is_comp_vector(arg1)?arg1: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_v,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { @@ -24459,7 +24459,7 @@ namespace cimg_library { const unsigned int siz = size(arg2), pos = is_comp_vector(arg2)?arg2: - ((return_new_comp = true), vector(siz)); + ((return_comp = true), vector(siz)); if (siz>24) CImg::vector((ulongT)mp_vector_map_sv,pos,4,siz,(ulongT)op,arg1,arg2,arg3,arg4).move_to(code); else { From 2799b2d4435bd9c67c27e326410a6662e798e959 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 18:06:33 +0100 Subject: [PATCH 16/17] . --- CImg.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CImg.h b/CImg.h index 5470bff8..27da6423 100644 --- a/CImg.h +++ b/CImg.h @@ -23390,10 +23390,7 @@ namespace cimg_library { if (*ss1!=']') for (s = ss1; s::vector((ulongT)mp_vector_init,pos,0,arg1),0); (l_opcode>'y').move_to(opcode); opcode[2] = opcode._height; -// opcode.move_to(code); opcode.move_to(!is_sth || is_inside_begin || is_new_variable_assignment?code:code_begin); return_comp = !is_sth && is_new_variable_assignment; if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization From f293acec1ca60278eceda260c9482b5eb0ec8e29 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Fri, 15 Mar 2024 18:51:25 +0100 Subject: [PATCH 17/17] Filter 'Spatial Blend Multi-Layers': Fix math so that all images have the same areas by default. --- CImg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CImg.h b/CImg.h index 27da6423..17c7600d 100644 --- a/CImg.h +++ b/CImg.h @@ -17273,11 +17273,11 @@ namespace cimg_library { if (*s=='i' || *s=='I' || *s=='n' || *s=='N') { // Particular cases : +/-NaN and +/-Inf if (!cimg::strcasecmp(s,"inf")) { val = cimg::type::inf(); nb = 1; } else if (!cimg::strcasecmp(s,"nan")) { val = cimg::type::nan(); nb = 1; } - } else if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]!='-') { // Hexadecimal litteral + } else if (*s=='0' && (s[1]=='x' || s[1]=='X') && s[2]!='-') { // Hexadecimal literal cimg_uint64 num; if ((nb = cimg_sscanf(s + 2,"%lx%c",&num,&sep))==1 || (nb==2 && sep=='%')) val = (double)num; - } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && s[2]!='-') { // Binary litteral + } else if (*s=='0' && (s[1]=='b' || s[1]=='B') && s[2]!='-') { // Binary literal variable_name.assign(65); if ((nb = cimg_sscanf(s + 2,"%64[01]%c",variable_name.data(),&sep))==1 || (nb==2 && sep=='%')) val = (double)std::strtoll(variable_name,0,2);