mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-09 00:12:56 +00:00
Merge branch 'shrink-patchcvt-alloc' into 'master'
Calculate staging buffer maximum size in Picture_Convert See merge request kart-krew-dev/ring-racers-internal!2933
This commit is contained in:
commit
1584e8a134
1 changed files with 13 additions and 2 deletions
|
|
@ -117,8 +117,8 @@ void *Picture_PatchConvert(
|
|||
{
|
||||
INT16 x, y;
|
||||
UINT8 *img;
|
||||
UINT8 *imgbuf = Z_Malloc(1<<26, PU_STATIC, NULL);
|
||||
UINT8 *imgptr = imgbuf;
|
||||
UINT8 *imgbuf;
|
||||
UINT8 *imgptr;
|
||||
UINT8 *colpointers, *startofspan;
|
||||
size_t size = 0;
|
||||
patch_t *inpatch = NULL;
|
||||
|
|
@ -160,6 +160,17 @@ void *Picture_PatchConvert(
|
|||
}
|
||||
}
|
||||
|
||||
// Allocate a staging buffer with the maximum size needed for a patch of the same size as the input.
|
||||
|
||||
// round up to nearest multiple of 254-pixel posts, plus 1 more 254-pixel post for paranoia reasons
|
||||
size_t maxcolumnsize = (2 + (inheight - 1) / 256) * 256;
|
||||
// the patch header, and width columns of the max column size
|
||||
size_t maxoutsize = maxcolumnsize * inwidth + (8 + 4 * inwidth);
|
||||
// so, a 512x512 flat should maximally need 393,760 (384.53 KiB) bytes.
|
||||
// quite a bit smaller than 64 megabytes, and much less annoying to the windows debug allocator!
|
||||
imgbuf = Z_Malloc(maxoutsize, PU_STATIC, NULL);
|
||||
imgptr = imgbuf;
|
||||
|
||||
// Write image size and offset
|
||||
WRITEINT16(imgptr, inwidth);
|
||||
WRITEINT16(imgptr, inheight);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue