I working on an application written in C++ which has to handle some data stored in a continues memory space which are interpreted as a 3D array. For an efficient data processing, I have to change the data order in the memory.
So me do an example: The original data are located in the memory and I have data access through a datapointer (uint16_t*) which is interpreted as 3D Array and has the dimension: x=4 y=4 z=3 In the memory the data are located as the following: (d_x,y,z)
d_0,0,0 | d_1,0,0 | d_2,0,0 | d_3,0,0 | d_0,1,0 | d_1,1,0 | d_2,1,0 | d_3,1,0 | .... | d_3,0,2 | d_3,1,2 | d_3,2,2 | d_3,3,2 |
Now I would to have the data in the order z,y,x:
d_0,0,0 | d_0,0,1 | d_0,0,2 | d_0,1,0 | d_0,1,1 | d_0,1,2 | .... | d_2,3,2 | d_3,3,0 | d_3,3,1 | d_3,3,2 |
I did an implementation with the following Loops:
for (uint32_t z = 0; z < zSize; curFrm++) {
for (uint32_t y = 0; y < ySize; y++) {
for (uint32_t x = 0; x < xSize; x++) {
uint32_t readPos = z * xSize * ySize + y * xSize + x;
uint32_t outPos = y * xSize * zSize + x * zSize + z;
*(dataOutPtr + outPos) = *(dataInPtr + readPos);
}
}
}
Does anyone now how to speed up this algorithm? Is it possible to do some parts in a concurrency execution or does any one now a other solution for the reordering of 3D data?
Many thanks!!
Aucun commentaire:
Enregistrer un commentaire