43 int AnchorStepX,
int AnchorStepY,
49 int LastYCell = SizeY - AnchorStepY;
50 for (
int y = 0; y < LastYCell; y += AnchorStepY)
53 for (
int x = 0; x < SizeX; x += AnchorStepX)
55 TYPE StartValue = a_Array[Idx];
56 TYPE EndValue = a_Array[Idx + SizeX * AnchorStepY];
57 TYPE
Diff = EndValue - StartValue;
58 for (
int CellY = 1; CellY < AnchorStepY; CellY++)
60 a_Array[Idx + SizeX * CellY] = StartValue +
Diff * CellY / AnchorStepY;
67 int LastXCell = SizeX - AnchorStepX;
68 for (
int y = 0; y < SizeY; y++)
71 for (
int x = 0; x < LastXCell; x += AnchorStepX)
73 TYPE StartValue = a_Array[Idx];
74 TYPE EndValue = a_Array[Idx + AnchorStepX];
75 TYPE
Diff = EndValue - StartValue;
76 for (
int CellX = 1; CellX < AnchorStepX; CellX++)
78 a_Array[Idx + CellX] = StartValue + CellX *
Diff / AnchorStepX;
95 int a_SrcSizeX,
int a_SrcSizeY,
97 int a_UpscaleX,
int a_UpscaleY
102 const int MAX_UPSCALE_X = 129;
103 const int MAX_UPSCALE_Y = 129;
111 ASSERT(a_UpscaleX < MAX_UPSCALE_X);
112 ASSERT(a_UpscaleY < MAX_UPSCALE_Y);
115 TYPE RatioX[MAX_UPSCALE_X];
116 TYPE RatioY[MAX_UPSCALE_Y];
117 for (
int x = 0; x <= a_UpscaleX; x++)
119 RatioX[x] =
static_cast<TYPE
>(x) / a_UpscaleX;
121 for (
int y = 0; y <= a_UpscaleY; y++)
123 RatioY[y] =
static_cast<TYPE
>(y) / a_UpscaleY;
126 const int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
127 [[maybe_unused]]
const int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
130 for (
int y = 0; y < (a_SrcSizeY - 1); y++)
132 int DstY = y * a_UpscaleY;
133 int idx = y * a_SrcSizeX;
134 for (
int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
136 int DstX = x * a_UpscaleX;
137 TYPE LoXLoY = a_Src[idx];
138 TYPE LoXHiY = a_Src[idx + a_SrcSizeX];
139 TYPE HiXLoY = a_Src[idx + 1];
140 TYPE HiXHiY = a_Src[idx + 1 + a_SrcSizeX];
141 for (
int CellY = 0; CellY <= a_UpscaleY; CellY++)
143 int DestIdx = (DstY + CellY) * DstSizeX + DstX;
144 ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY);
145 TYPE LoXInY = LoXLoY + (LoXHiY - LoXLoY) * RatioY[CellY];
146 TYPE HiXInY = HiXLoY + (HiXHiY - HiXLoY) * RatioY[CellY];
147 for (
int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
149 a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
166 int a_SrcSizeX,
int a_SrcSizeY,
int a_SrcSizeZ,
168 int a_UpscaleX,
int a_UpscaleY,
int a_UpscaleZ
173 const int MAX_UPSCALE_X = 128;
174 const int MAX_UPSCALE_Y = 128;
175 const int MAX_UPSCALE_Z = 128;
185 ASSERT(a_UpscaleX <= MAX_UPSCALE_X);
186 ASSERT(a_UpscaleY <= MAX_UPSCALE_Y);
187 ASSERT(a_UpscaleZ <= MAX_UPSCALE_Z);
190 TYPE RatioX[MAX_UPSCALE_X];
191 TYPE RatioY[MAX_UPSCALE_Y];
192 TYPE RatioZ[MAX_UPSCALE_Z];
193 for (
int x = 0; x <= a_UpscaleX; x++)
195 RatioX[x] =
static_cast<TYPE
>(x) / a_UpscaleX;
197 for (
int y = 0; y <= a_UpscaleY; y++)
199 RatioY[y] =
static_cast<TYPE
>(y) / a_UpscaleY;
201 for (
int z = 0; z <= a_UpscaleZ; z++)
203 RatioZ[z] =
static_cast<TYPE
>(z) / a_UpscaleZ;
206 const int DstSizeX = (a_SrcSizeX - 1) * a_UpscaleX + 1;
207 const int DstSizeY = (a_SrcSizeY - 1) * a_UpscaleY + 1;
208 [[maybe_unused]]
const int DstSizeZ = (a_SrcSizeZ - 1) * a_UpscaleZ + 1;
211 for (
int z = 0; z < (a_SrcSizeZ - 1); z++)
213 int DstZ = z * a_UpscaleZ;
214 for (
int y = 0; y < (a_SrcSizeY - 1); y++)
216 int DstY = y * a_UpscaleY;
217 int idx = y * a_SrcSizeX + z * a_SrcSizeX * a_SrcSizeY;
218 for (
int x = 0; x < (a_SrcSizeX - 1); x++, idx++)
220 int DstX = x * a_UpscaleX;
221 TYPE LoXLoYLoZ = a_Src[idx];
222 TYPE LoXLoYHiZ = a_Src[idx + a_SrcSizeX * a_SrcSizeY];
223 TYPE LoXHiYLoZ = a_Src[idx + a_SrcSizeX];
224 TYPE LoXHiYHiZ = a_Src[idx + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
225 TYPE HiXLoYLoZ = a_Src[idx + 1];
226 TYPE HiXLoYHiZ = a_Src[idx + 1 + a_SrcSizeX * a_SrcSizeY];
227 TYPE HiXHiYLoZ = a_Src[idx + 1 + a_SrcSizeX];
228 TYPE HiXHiYHiZ = a_Src[idx + 1 + a_SrcSizeX + a_SrcSizeX * a_SrcSizeY];
229 for (
int CellZ = 0; CellZ <= a_UpscaleZ; CellZ++)
231 TYPE LoXLoYInZ = LoXLoYLoZ + (LoXLoYHiZ - LoXLoYLoZ) * RatioZ[CellZ];
232 TYPE LoXHiYInZ = LoXHiYLoZ + (LoXHiYHiZ - LoXHiYLoZ) * RatioZ[CellZ];
233 TYPE HiXLoYInZ = HiXLoYLoZ + (HiXLoYHiZ - HiXLoYLoZ) * RatioZ[CellZ];
234 TYPE HiXHiYInZ = HiXHiYLoZ + (HiXHiYHiZ - HiXHiYLoZ) * RatioZ[CellZ];
235 for (
int CellY = 0; CellY <= a_UpscaleY; CellY++)
237 int DestIdx = (DstZ + CellZ) * DstSizeX * DstSizeY + (DstY + CellY) * DstSizeX + DstX;
238 ASSERT(DestIdx + a_UpscaleX < DstSizeX * DstSizeY * DstSizeZ);
239 TYPE LoXInY = LoXLoYInZ + (LoXHiYInZ - LoXLoYInZ) * RatioY[CellY];
240 TYPE HiXInY = HiXLoYInZ + (HiXHiYInZ - HiXLoYInZ) * RatioY[CellY];
241 for (
int CellX = 0; CellX <= a_UpscaleX; CellX++, DestIdx++)
243 a_Dst[DestIdx] = LoXInY + (HiXInY - LoXInY) * RatioX[CellX];
T Diff(T a_Val1, T a_Val2)
void LinearUpscale3DArray(TYPE *a_Src, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, TYPE *a_Dst, int a_UpscaleX, int a_UpscaleY, int a_UpscaleZ)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
void LinearUpscale2DArrayInPlace(TYPE *a_Array)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
void LinearUpscale2DArray(TYPE *a_Src, int a_SrcSizeX, int a_SrcSizeY, TYPE *a_Dst, int a_UpscaleX, int a_UpscaleY)
Linearly interpolates values in the array between the equidistant anchor points (upscales).