memory bug fixes
This commit is contained in:
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)
|
template<typename callable, typename ... argst> int threaded_execute(callable &&fptr, int64_t psize, argst&&... args)
|
||||||
{
|
{
|
||||||
int ret = amsimage_success;
|
int ret = amsimage_success;
|
||||||
int nthreads;
|
int nthreads = 1;
|
||||||
int I;
|
int I = 0;
|
||||||
std::vector<std::thread*> threads;
|
std::vector<std::thread*> threads;
|
||||||
|
|
||||||
if(psize<amsimage_threadpsz)
|
if(psize<amsimage_threadpsz)
|
||||||
@ -28,6 +28,14 @@ template<typename callable, typename ... argst> int threaded_execute(callable &&
|
|||||||
nthreads = (nthreads<=0) ? 1 : nthreads;
|
nthreads = (nthreads<=0) ? 1 : nthreads;
|
||||||
nthreads = (nthreads>amsimage_maxthreads) ? amsimage_maxthreads : nthreads;
|
nthreads = (nthreads>amsimage_maxthreads) ? amsimage_maxthreads : nthreads;
|
||||||
threads.resize(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++) threads[I] = NULL;
|
||||||
for(I=0;I<nthreads;I++)
|
for(I=0;I<nthreads;I++)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ namespace ams
|
|||||||
int res;
|
int res;
|
||||||
if(this!=&other)
|
if(this!=&other)
|
||||||
{
|
{
|
||||||
res = this->resize(Nx,Ny);
|
res = this->resize(other.Nx,other.Ny);
|
||||||
if(res==amsimage_success)
|
if(res==amsimage_success)
|
||||||
{
|
{
|
||||||
imglib4::amsimage_plane_copy(
|
imglib4::amsimage_plane_copy(
|
||||||
@ -55,7 +55,7 @@ namespace ams
|
|||||||
int res;
|
int res;
|
||||||
if(this!=&other)
|
if(this!=&other)
|
||||||
{
|
{
|
||||||
res = this->resize(Nx,Ny);
|
res = this->resize(other.Nx,other.Ny);
|
||||||
if(res==amsimage_success)
|
if(res==amsimage_success)
|
||||||
{
|
{
|
||||||
imglib4::amsimage_plane_copy(
|
imglib4::amsimage_plane_copy(
|
||||||
@ -630,8 +630,8 @@ namespace ams
|
|||||||
Ix = I%dx;
|
Ix = I%dx;
|
||||||
Iy = I/dx;
|
Iy = I/dx;
|
||||||
|
|
||||||
Ia = (Ix + x0) + (Iy + y0)*imgto->Ny;
|
Ia = (Ix + x0) + (Iy + y0)*imgto->Nx;
|
||||||
Ib = Ix + Iy*imgfrom->Ny;
|
Ib = Ix + Iy*imgfrom->Nx;
|
||||||
|
|
||||||
v1 = imgto->data[Ia];
|
v1 = imgto->data[Ia];
|
||||||
v2 = imgfrom->data[Ib];
|
v2 = imgfrom->data[Ib];
|
||||||
|
@ -613,8 +613,8 @@ namespace ams
|
|||||||
Ix = I%dx;
|
Ix = I%dx;
|
||||||
Iy = I/dx;
|
Iy = I/dx;
|
||||||
|
|
||||||
Ia = (Ix + x0) + (Iy + y0)*imgto->Ny;
|
Ia = (Ix + x0) + (Iy + y0)*imgto->Nx;
|
||||||
Ib = Ix + Iy*imgfrom->Ny;
|
Ib = Ix + Iy*imgfrom->Nx;
|
||||||
|
|
||||||
r1 = imgto->data[0 + 4*Ia];
|
r1 = imgto->data[0 + 4*Ia];
|
||||||
g1 = imgto->data[1 + 4*Ia];
|
g1 = imgto->data[1 + 4*Ia];
|
||||||
|
@ -546,13 +546,13 @@ void amsfloatimage_region_castcopy2_tf(
|
|||||||
bi = (int)(datafrom[2 + 4*Ib]*255.0);
|
bi = (int)(datafrom[2 + 4*Ib]*255.0);
|
||||||
ai = (int)(datafrom[3 + 4*Ib]*255.0);
|
ai = (int)(datafrom[3 + 4*Ib]*255.0);
|
||||||
ri = (ri<0) ? 0 : ri;
|
ri = (ri<0) ? 0 : ri;
|
||||||
gi = (ri<0) ? 0 : gi;
|
gi = (gi<0) ? 0 : gi;
|
||||||
bi = (ri<0) ? 0 : bi;
|
bi = (bi<0) ? 0 : bi;
|
||||||
ai = (ri<0) ? 0 : ai;
|
ai = (ai<0) ? 0 : ai;
|
||||||
ri = (ri>255) ? 255 : ri;
|
ri = (ri>255) ? 255 : ri;
|
||||||
gi = (ri>255) ? 255 : gi;
|
gi = (gi>255) ? 255 : gi;
|
||||||
bi = (ri>255) ? 255 : bi;
|
bi = (bi>255) ? 255 : bi;
|
||||||
ai = (ri>255) ? 255 : ai;
|
ai = (ai>255) ? 255 : ai;
|
||||||
|
|
||||||
datato[0 + 4*Ia] = (uint8_t)ri;
|
datato[0 + 4*Ia] = (uint8_t)ri;
|
||||||
datato[1 + 4*Ia] = (uint8_t)gi;
|
datato[1 + 4*Ia] = (uint8_t)gi;
|
||||||
|
@ -6,10 +6,10 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
//amscppimglib4_test1();
|
amscppimglib4_test1();
|
||||||
//amscppimglib4_test2();
|
amscppimglib4_test2();
|
||||||
amscppimglib4_bitplane_alloc_tests();
|
amscppimglib4_bitplane_alloc_tests();
|
||||||
//amscppimglib4_image_alloc_tests();
|
amscppimglib4_image_alloc_tests();
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user