memory bug fixes

This commit is contained in:
2025-06-14 10:41:22 -04:00
parent 92169317f2
commit 566c04f6e8
26 changed files with 25 additions and 17 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,8 +12,8 @@ namespace imglib4
template<typename callable, typename ... argst> int threaded_execute(callable &&fptr, int64_t psize, argst&&... args)
{
int ret = amsimage_success;
int nthreads;
int I;
int nthreads = 1;
int I = 0;
std::vector<std::thread*> threads;
if(psize<amsimage_threadpsz)
@@ -28,6 +28,14 @@ template<typename callable, typename ... argst> int threaded_execute(callable &&
nthreads = (nthreads<=0) ? 1 : nthreads;
nthreads = (nthreads>amsimage_maxthreads) ? amsimage_maxthreads : nthreads;
threads.resize(nthreads);
if(threads.size()!=nthreads)
{
//fallback to single threaded execution
nthreads = 1;
I = 0;
fptr(I,nthreads,std::forward<argst>(args)...);
return amsimage_success;
}
for(I=0;I<nthreads;I++) threads[I] = NULL;
for(I=0;I<nthreads;I++)
{
@@ -22,7 +22,7 @@ namespace ams
int res;
if(this!=&other)
{
res = this->resize(Nx,Ny);
res = this->resize(other.Nx,other.Ny);
if(res==amsimage_success)
{
imglib4::amsimage_plane_copy(
@@ -55,7 +55,7 @@ namespace ams
int res;
if(this!=&other)
{
res = this->resize(Nx,Ny);
res = this->resize(other.Nx,other.Ny);
if(res==amsimage_success)
{
imglib4::amsimage_plane_copy(
@@ -630,8 +630,8 @@ namespace ams
Ix = I%dx;
Iy = I/dx;
Ia = (Ix + x0) + (Iy + y0)*imgto->Ny;
Ib = Ix + Iy*imgfrom->Ny;
Ia = (Ix + x0) + (Iy + y0)*imgto->Nx;
Ib = Ix + Iy*imgfrom->Nx;
v1 = imgto->data[Ia];
v2 = imgfrom->data[Ib];
@@ -613,8 +613,8 @@ namespace ams
Ix = I%dx;
Iy = I/dx;
Ia = (Ix + x0) + (Iy + y0)*imgto->Ny;
Ib = Ix + Iy*imgfrom->Ny;
Ia = (Ix + x0) + (Iy + y0)*imgto->Nx;
Ib = Ix + Iy*imgfrom->Nx;
r1 = imgto->data[0 + 4*Ia];
g1 = imgto->data[1 + 4*Ia];
+6 -6
View File
@@ -546,13 +546,13 @@ void amsfloatimage_region_castcopy2_tf(
bi = (int)(datafrom[2 + 4*Ib]*255.0);
ai = (int)(datafrom[3 + 4*Ib]*255.0);
ri = (ri<0) ? 0 : ri;
gi = (ri<0) ? 0 : gi;
bi = (ri<0) ? 0 : bi;
ai = (ri<0) ? 0 : ai;
gi = (gi<0) ? 0 : gi;
bi = (bi<0) ? 0 : bi;
ai = (ai<0) ? 0 : ai;
ri = (ri>255) ? 255 : ri;
gi = (ri>255) ? 255 : gi;
bi = (ri>255) ? 255 : bi;
ai = (ri>255) ? 255 : ai;
gi = (gi>255) ? 255 : gi;
bi = (bi>255) ? 255 : bi;
ai = (ai>255) ? 255 : ai;
datato[0 + 4*Ia] = (uint8_t)ri;
datato[1 + 4*Ia] = (uint8_t)gi;
+3 -3
View File
@@ -6,10 +6,10 @@ int main(int argc, char* argv[])
{
int ret = 0;
//amscppimglib4_test1();
//amscppimglib4_test2();
amscppimglib4_test1();
amscppimglib4_test2();
amscppimglib4_bitplane_alloc_tests();
//amscppimglib4_image_alloc_tests();
amscppimglib4_image_alloc_tests();
return ret;