diff --git a/include/freerdp/codec/rfx.h b/include/freerdp/codec/rfx.h index 278af87c9..ffdbd5e2e 100644 --- a/include/freerdp/codec/rfx.h +++ b/include/freerdp/codec/rfx.h @@ -183,16 +183,19 @@ extern "C" FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message); FREERDP_API BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects, - int num_rects, BYTE* image_data, int width, int height, - int rowstride); + size_t num_rects, const BYTE* image_data, UINT32 width, + UINT32 height, UINT32 rowstride); FREERDP_API RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, - int numRects, BYTE* data, int width, int height, - int scanline); + size_t numRects, const BYTE* data, UINT32 width, + UINT32 height, size_t scanline); + FREERDP_API RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, - int numRects, BYTE* data, int width, int height, - int scanline, int* numMessages, int maxDataSize); - FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message); + size_t numRects, const BYTE* data, UINT32 width, + UINT32 height, UINT32 scanline, + size_t* numMessages, size_t maxDataSize); + FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, + const RFX_MESSAGE* message); FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height); diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 382f70cbd..d829ff413 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -385,6 +385,11 @@ static RFX_TILE* rfx_message_get_tile(RFX_MESSAGE* message, UINT32 index) return message->tiles[index]; } +static const RFX_RECT* rfx_message_get_rect_const(const RFX_MESSAGE* message, UINT32 index) +{ + return &message->rects[index]; +} + static RFX_RECT* rfx_message_get_rect(RFX_MESSAGE* message, UINT32 index) { return &message->rects[index]; @@ -637,7 +642,7 @@ static BOOL rfx_process_message_frame_end(RFX_CONTEXT* context, RFX_MESSAGE* mes static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType) { - int i; + UINT16 i; UINT16 regionType; UINT16 numTileSets; RFX_RECT* tmpRects; @@ -1428,8 +1433,8 @@ static BOOL setupWorkers(RFX_CONTEXT* context, int nbTiles) return TRUE; } -RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, int numRects, - BYTE* data, int w, int h, int s) +RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, size_t numRects, + const BYTE* data, UINT32 w, UINT32 h, size_t s) { const UINT32 width = (UINT32)w; const UINT32 height = (UINT32)h; @@ -1567,7 +1572,8 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects, int tile->allocated = FALSE; } - tile->data = &data[(ay * scanline) + (ax * bytesPerPixel)]; + /* Cast away const */ + tile->data = (BYTE*)&data[(ay * scanline) + (ax * bytesPerPixel)]; tile->quantIdxY = context->quantIdxY; tile->quantIdxCb = context->quantIdxCb; tile->quantIdxCr = context->quantIdxCr; @@ -1663,10 +1669,10 @@ skip_encoding_loop: return NULL; } -static RFX_MESSAGE* rfx_split_message(RFX_CONTEXT* context, RFX_MESSAGE* message, int* numMessages, - int maxDataSize) +static RFX_MESSAGE* rfx_split_message(RFX_CONTEXT* context, RFX_MESSAGE* message, + size_t* numMessages, size_t maxDataSize) { - int i, j; + size_t i, j; UINT32 tileDataSize; RFX_MESSAGE* messages; maxDataSize -= 1024; /* reserve enough space for headers */ @@ -1716,9 +1722,9 @@ free_messages: return NULL; } -RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, int numRects, - BYTE* data, int width, int height, int scanline, int* numMessages, - int maxDataSize) +RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, size_t numRects, + const BYTE* data, UINT32 width, UINT32 height, UINT32 scanline, + size_t* numMessages, size_t maxDataSize) { RFX_MESSAGE* message; RFX_MESSAGE* messageList; @@ -1737,7 +1743,7 @@ RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects, in return messageList; } -static BOOL rfx_write_message_tileset(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) +static BOOL rfx_write_message_tileset(RFX_CONTEXT* context, wStream* s, const RFX_MESSAGE* message) { int i; RFX_TILE* tile; @@ -1784,7 +1790,8 @@ static BOOL rfx_write_message_tileset(RFX_CONTEXT* context, wStream* s, RFX_MESS return TRUE; } -static BOOL rfx_write_message_frame_begin(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) +static BOOL rfx_write_message_frame_begin(RFX_CONTEXT* context, wStream* s, + const RFX_MESSAGE* message) { if (!Stream_EnsureRemainingCapacity(s, 14)) return FALSE; @@ -1798,7 +1805,7 @@ static BOOL rfx_write_message_frame_begin(RFX_CONTEXT* context, wStream* s, RFX_ return TRUE; } -static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) +static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s, const RFX_MESSAGE* message) { int i; UINT32 blockLen; @@ -1816,7 +1823,7 @@ static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s, RFX_MESSA for (i = 0; i < message->numRects; i++) { - const RFX_RECT* rect = rfx_message_get_rect(message, i); + const RFX_RECT* rect = rfx_message_get_rect_const(message, i); /* Clipping rectangles are relative to destLeft, destTop */ Stream_Write_UINT16(s, rect->x); /* x (2 bytes) */ Stream_Write_UINT16(s, rect->y); /* y (2 bytes) */ @@ -1829,7 +1836,8 @@ static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s, RFX_MESSA return TRUE; } -static BOOL rfx_write_message_frame_end(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) +static BOOL rfx_write_message_frame_end(RFX_CONTEXT* context, wStream* s, + const RFX_MESSAGE* message) { if (!Stream_EnsureRemainingCapacity(s, 8)) return FALSE; @@ -1841,7 +1849,7 @@ static BOOL rfx_write_message_frame_end(RFX_CONTEXT* context, wStream* s, RFX_ME return TRUE; } -BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) +BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, const RFX_MESSAGE* message) { if (context->state == RFX_STATE_SEND_HEADERS) { @@ -1862,8 +1870,8 @@ BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message) return TRUE; } -BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects, int numRects, - BYTE* data, int width, int height, int scanline) +BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s, const RFX_RECT* rects, size_t numRects, + const BYTE* data, UINT32 width, UINT32 height, UINT32 scanline) { RFX_MESSAGE* message; BOOL ret = TRUE; diff --git a/libfreerdp/codec/rfx_decode.c b/libfreerdp/codec/rfx_decode.c index 8e130ae5c..69866c744 100644 --- a/libfreerdp/codec/rfx_decode.c +++ b/libfreerdp/codec/rfx_decode.c @@ -62,7 +62,7 @@ static void rfx_decode_component(RFX_CONTEXT* context, const UINT32* quantizatio /* rfx_decode_ycbcr_to_rgb code now resides in the primitives library. */ /* stride is bytes between rows in the output buffer. */ -BOOL rfx_decode_rgb(RFX_CONTEXT* context, RFX_TILE* tile, BYTE* rgb_buffer, int stride) +BOOL rfx_decode_rgb(RFX_CONTEXT* context, const RFX_TILE* tile, BYTE* rgb_buffer, UINT32 stride) { BOOL rc = TRUE; BYTE* pBuffer; diff --git a/libfreerdp/codec/rfx_decode.h b/libfreerdp/codec/rfx_decode.h index 11dcf9f5f..638d45fe6 100644 --- a/libfreerdp/codec/rfx_decode.h +++ b/libfreerdp/codec/rfx_decode.h @@ -24,7 +24,7 @@ #include /* stride is bytes between rows in the output buffer. */ -FREERDP_LOCAL BOOL rfx_decode_rgb(RFX_CONTEXT* context, RFX_TILE* tile, BYTE* rgb_buffer, - int stride); +FREERDP_LOCAL BOOL rfx_decode_rgb(RFX_CONTEXT* context, const RFX_TILE* tile, BYTE* rgb_buffer, + UINT32 stride); #endif /* FREERDP_LIB_CODEC_RFX_DECODE_H */