[codec,rfx] clean up free functions

* automatically set message->freeRects internally
This commit is contained in:
Armin Novak 2023-04-05 10:43:03 +02:00 committed by akallabeth
parent 77f4d96fef
commit fcf3d0517e
2 changed files with 10 additions and 13 deletions

View File

@ -2747,8 +2747,6 @@ int progressive_compress(PROGRESSIVE_CONTEXT* progressive, const BYTE* pSrcData,
goto fail; goto fail;
} }
message->freeRects = TRUE;
rc = progressive_rfx_write_message_progressive_simple(progressive, s, message); rc = progressive_rfx_write_message_progressive_simple(progressive, s, message);
rfx_message_free(progressive->rfx_context, message); rfx_message_free(progressive->rfx_context, message);
if (!rc) if (!rc)

View File

@ -1511,10 +1511,9 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, siz
const UINT32 width = (UINT32)w; const UINT32 width = (UINT32)w;
const UINT32 height = (UINT32)h; const UINT32 height = (UINT32)h;
const UINT32 scanline = (UINT32)s; const UINT32 scanline = (UINT32)s;
UINT32 i, maxNbTiles = 0, maxTilesX, maxTilesY; UINT32 maxNbTiles = 0, maxTilesX, maxTilesY;
UINT32 xIdx, yIdx, regionNbRects; UINT32 regionNbRects;
UINT32 gridRelX, gridRelY, ax, ay, bytesPerPixel; UINT32 ax, ay, bytesPerPixel;
RFX_RECT* rfxRect;
RFX_MESSAGE* message = NULL; RFX_MESSAGE* message = NULL;
PTP_WORK* workObject = NULL; PTP_WORK* workObject = NULL;
RFX_TILE_COMPOSE_WORK_PARAM* workParam = NULL; RFX_TILE_COMPOSE_WORK_PARAM* workParam = NULL;
@ -1583,13 +1582,15 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, siz
regionRect = region16_rects(&rectsRegion, &regionNbRects); regionRect = region16_rects(&rectsRegion, &regionNbRects);
message->freeRects = TRUE;
if (!(message->rects = winpr_aligned_calloc(regionNbRects, sizeof(RFX_RECT), 32))) if (!(message->rects = winpr_aligned_calloc(regionNbRects, sizeof(RFX_RECT), 32)))
goto skip_encoding_loop; goto skip_encoding_loop;
message->numRects = regionNbRects; message->numRects = regionNbRects;
for (i = 0, rfxRect = message->rects; i < regionNbRects; i++, regionRect++, rfxRect++) for (UINT32 i = 0; i < regionNbRects; i++, regionRect++)
{ {
RFX_RECT* rfxRect = &message->rects[i];
UINT32 startTileX = regionRect->left / 64; UINT32 startTileX = regionRect->left / 64;
UINT32 endTileX = (regionRect->right - 1) / 64; UINT32 endTileX = (regionRect->right - 1) / 64;
UINT32 startTileY = regionRect->top / 64; UINT32 startTileY = regionRect->top / 64;
@ -1599,7 +1600,7 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, siz
rfxRect->width = (regionRect->right - regionRect->left); rfxRect->width = (regionRect->right - regionRect->left);
rfxRect->height = (regionRect->bottom - regionRect->top); rfxRect->height = (regionRect->bottom - regionRect->top);
for (yIdx = startTileY, gridRelY = startTileY * 64; yIdx <= endTileY; for (UINT32 yIdx = startTileY, gridRelY = startTileY * 64; yIdx <= endTileY;
yIdx++, gridRelY += 64) yIdx++, gridRelY += 64)
{ {
UINT32 tileHeight = 64; UINT32 tileHeight = 64;
@ -1610,7 +1611,7 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, siz
currentTileRect.top = gridRelY; currentTileRect.top = gridRelY;
currentTileRect.bottom = gridRelY + tileHeight; currentTileRect.bottom = gridRelY + tileHeight;
for (xIdx = startTileX, gridRelX = startTileX * 64; xIdx <= endTileX; for (UINT32 xIdx = startTileX, gridRelX = startTileX * 64; xIdx <= endTileX;
xIdx++, gridRelX += 64) xIdx++, gridRelX += 64)
{ {
union union
@ -1719,7 +1720,7 @@ skip_encoding_loop:
message->tilesDataSize = 0; message->tilesDataSize = 0;
workObject = context->priv->workObjects; workObject = context->priv->workObjects;
for (i = 0; i < message->numTiles; i++) for (UINT32 i = 0; i < message->numTiles; i++)
{ {
RFX_TILE* tile = message->tiles[i]; RFX_TILE* tile = message->tiles[i];
@ -1820,7 +1821,6 @@ RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, si
RFX_MESSAGE* messageList = rfx_split_message(context, message, numMessages, maxDataSize); RFX_MESSAGE* messageList = rfx_split_message(context, message, numMessages, maxDataSize);
if (!messageList) if (!messageList)
{ {
message->freeRects = TRUE;
rfx_message_free(context, message); rfx_message_free(context, message);
return NULL; return NULL;
} }
@ -1971,8 +1971,7 @@ BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects
if (!message) if (!message)
return FALSE; return FALSE;
BOOL ret = rfx_write_message(context, s, message); const BOOL ret = rfx_write_message(context, s, message);
message->freeRects = TRUE;
rfx_message_free(context, message); rfx_message_free(context, message);
return ret; return ret;
} }