From fd592b9cf1513e6b2e0edf95258b3f1e3ea240e3 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 30 May 2024 00:48:48 +0200 Subject: [PATCH] [codec,nsc] add INLINE and restrict keywords --- include/freerdp/codec/color.h | 3 ++- include/freerdp/codec/nsc.h | 26 ++++++++++++++----------- libfreerdp/codec/color.c | 2 +- libfreerdp/codec/nsc.c | 12 ++++++------ libfreerdp/codec/nsc_encode.c | 36 ++++++++++++++++++++--------------- libfreerdp/codec/nsc_encode.h | 3 ++- 6 files changed, 47 insertions(+), 35 deletions(-) diff --git a/include/freerdp/codec/color.h b/include/freerdp/codec/color.h index f96a8fd75..9dab0df16 100644 --- a/include/freerdp/codec/color.h +++ b/include/freerdp/codec/color.h @@ -280,7 +280,8 @@ typedef struct gdi_palette gdiPalette; * @return A buffer allocated with winpr_aligned_malloc(width * height, 16) * if successful, NULL otherwise. */ - FREERDP_API BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* data); + FREERDP_API BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, + const BYTE* WINPR_RESTRICT data); /*** * diff --git a/include/freerdp/codec/nsc.h b/include/freerdp/codec/nsc.h index a0a266d4a..5e81d1249 100644 --- a/include/freerdp/codec/nsc.h +++ b/include/freerdp/codec/nsc.h @@ -50,21 +50,25 @@ extern "C" UINT32 pixel_format)); #endif - FREERDP_API BOOL nsc_context_set_parameters(NSC_CONTEXT* context, NSC_PARAMETER what, - UINT32 value); + FREERDP_API BOOL nsc_context_set_parameters(NSC_CONTEXT* WINPR_RESTRICT context, + NSC_PARAMETER what, UINT32 value); - FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* context, UINT16 bpp, UINT32 width, - UINT32 height, const BYTE* data, UINT32 length, - BYTE* pDstData, UINT32 DstFormat, UINT32 nDstStride, - UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, - UINT32 flip); - FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s, const BYTE* bmpdata, - UINT32 width, UINT32 height, UINT32 rowstride); - FREERDP_API BOOL nsc_decompose_message(NSC_CONTEXT* context, wStream* s, BYTE* bmpdata, + FREERDP_API BOOL nsc_process_message(NSC_CONTEXT* WINPR_RESTRICT context, UINT16 bpp, + UINT32 width, UINT32 height, const BYTE* data, + UINT32 length, BYTE* pDstData, UINT32 DstFormat, + UINT32 nDstStride, UINT32 nXDst, UINT32 nYDst, + UINT32 nWidth, UINT32 nHeight, UINT32 flip); + FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* WINPR_RESTRICT context, + wStream* WINPR_RESTRICT s, + const BYTE* WINPR_RESTRICT bmpdata, UINT32 width, + UINT32 height, UINT32 rowstride); + FREERDP_API BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context, + wStream* WINPR_RESTRICT s, BYTE* WINPR_RESTRICT bmpdata, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT32 rowstride, UINT32 format, UINT32 flip); - FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height); + FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* WINPR_RESTRICT context, UINT32 width, + UINT32 height); FREERDP_API void nsc_context_free(NSC_CONTEXT* context); diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index a7cc42229..5344362f7 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -51,7 +51,7 @@ static INLINE DWORD FreeRDPAreColorFormatsEqualNoAlpha_int(DWORD first, DWORD se return (first & mask) == (second & mask); } -BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* data) +BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* WINPR_RESTRICT data) { /* * converts a 1-bit-per-pixel glyph to a one-byte-per-pixel glyph: diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 8bf3da88a..fd3183519 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -46,7 +46,7 @@ } while (0) #endif -static BOOL nsc_decode(NSC_CONTEXT* context) +static BOOL nsc_decode(NSC_CONTEXT* WINPR_RESTRICT context) { UINT16 rw = 0; BYTE shift = 0; @@ -188,7 +188,7 @@ static BOOL nsc_rle_decode(const BYTE* WINPR_RESTRICT in, size_t inSize, BYTE* W return TRUE; } -static BOOL nsc_rle_decompress_data(NSC_CONTEXT* context) +static BOOL nsc_rle_decompress_data(NSC_CONTEXT* WINPR_RESTRICT context) { if (!context) return FALSE; @@ -236,7 +236,7 @@ static BOOL nsc_rle_decompress_data(NSC_CONTEXT* context) return TRUE; } -static BOOL nsc_stream_initialize(NSC_CONTEXT* context, wStream* s) +static BOOL nsc_stream_initialize(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s) { WINPR_ASSERT(context); WINPR_ASSERT(context->priv); @@ -265,7 +265,7 @@ static BOOL nsc_stream_initialize(NSC_CONTEXT* context, wStream* s) return Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, total); } -static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s) +static BOOL nsc_context_initialize(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s) { if (!nsc_stream_initialize(context, s)) return FALSE; @@ -317,7 +317,7 @@ static BOOL nsc_context_initialize(NSC_CONTEXT* context, wStream* s) return TRUE; } -static void nsc_profiler_print(NSC_CONTEXT_PRIV* priv) +static void nsc_profiler_print(NSC_CONTEXT_PRIV* WINPR_RESTRICT priv) { WINPR_UNUSED(priv); @@ -329,7 +329,7 @@ static void nsc_profiler_print(NSC_CONTEXT_PRIV* priv) PROFILER_PRINT_FOOTER } -BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height) +BOOL nsc_context_reset(NSC_CONTEXT* WINPR_RESTRICT context, UINT32 width, UINT32 height) { if (!context) return FALSE; diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index b101a15cf..b2fb8287c 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -54,9 +54,10 @@ typedef struct UINT8 ChromaSubsamplingLevel; } NSC_MESSAGE; -static BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s, const NSC_MESSAGE* message); +static BOOL nsc_write_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s, + const NSC_MESSAGE* WINPR_RESTRICT message); -static BOOL nsc_context_initialize_encode(NSC_CONTEXT* context) +static BOOL nsc_context_initialize_encode(NSC_CONTEXT* WINPR_RESTRICT context) { UINT32 length = 0; UINT32 tempWidth = 0; @@ -109,7 +110,8 @@ fail: return FALSE; } -static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UINT32 scanline) +static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* WINPR_RESTRICT context, + const BYTE* WINPR_RESTRICT data, UINT32 scanline) { UINT16 y = 0; UINT16 rw = 0; @@ -268,7 +270,7 @@ static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UI return TRUE; } -static BOOL nsc_encode_subsampling(NSC_CONTEXT* context) +static BOOL nsc_encode_subsampling(NSC_CONTEXT* WINPR_RESTRICT context) { UINT32 tempWidth = 0; UINT32 tempHeight = 0; @@ -312,7 +314,8 @@ static BOOL nsc_encode_subsampling(NSC_CONTEXT* context) return TRUE; } -BOOL nsc_encode(NSC_CONTEXT* context, const BYTE* bmpdata, UINT32 rowstride) +BOOL nsc_encode(NSC_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT bmpdata, + UINT32 rowstride) { if (!context || !bmpdata || (rowstride == 0)) return FALSE; @@ -329,7 +332,8 @@ BOOL nsc_encode(NSC_CONTEXT* context, const BYTE* bmpdata, UINT32 rowstride) return TRUE; } -static UINT32 nsc_rle_encode(const BYTE* in, BYTE* out, UINT32 originalSize) +static UINT32 nsc_rle_encode(const BYTE* WINPR_RESTRICT in, BYTE* WINPR_RESTRICT out, + UINT32 originalSize) { UINT32 left = 0; UINT32 runlength = 1; @@ -383,7 +387,7 @@ static UINT32 nsc_rle_encode(const BYTE* in, BYTE* out, UINT32 originalSize) return planeSize; } -static void nsc_rle_compress_data(NSC_CONTEXT* context) +static void nsc_rle_compress_data(NSC_CONTEXT* WINPR_RESTRICT context) { UINT32 planeSize = 0; UINT32 originalSize = 0; @@ -412,8 +416,8 @@ static void nsc_rle_compress_data(NSC_CONTEXT* context) } } -static UINT32 nsc_compute_byte_count(NSC_CONTEXT* context, UINT32* ByteCount, UINT32 width, - UINT32 height) +static UINT32 nsc_compute_byte_count(NSC_CONTEXT* WINPR_RESTRICT context, + UINT32* WINPR_RESTRICT ByteCount, UINT32 width, UINT32 height) { UINT32 tempWidth = 0; UINT32 tempHeight = 0; @@ -440,7 +444,8 @@ static UINT32 nsc_compute_byte_count(NSC_CONTEXT* context, UINT32* ByteCount, UI return maxPlaneSize; } -BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s, const NSC_MESSAGE* message) +BOOL nsc_write_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s, + const NSC_MESSAGE* WINPR_RESTRICT message) { UINT32 totalPlaneByteCount = 0; totalPlaneByteCount = message->LumaPlaneByteCount + message->OrangeChromaPlaneByteCount + @@ -476,8 +481,9 @@ BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s, const NSC_MESSAGE* mess return TRUE; } -BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s, const BYTE* WINPR_RESTRICT data, - UINT32 width, UINT32 height, UINT32 scanline) +BOOL nsc_compose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s, + const BYTE* WINPR_RESTRICT data, UINT32 width, UINT32 height, + UINT32 scanline) { BOOL rc = 0; NSC_MESSAGE message = { 0 }; @@ -515,9 +521,9 @@ BOOL nsc_compose_message(NSC_CONTEXT* context, wStream* s, const BYTE* WINPR_RES return nsc_write_message(context, s, &message); } -BOOL nsc_decompose_message(NSC_CONTEXT* context, wStream* s, BYTE* WINPR_RESTRICT bmpdata, UINT32 x, - UINT32 y, UINT32 width, UINT32 height, UINT32 rowstride, UINT32 format, - UINT32 flip) +BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s, + BYTE* WINPR_RESTRICT bmpdata, UINT32 x, UINT32 y, UINT32 width, + UINT32 height, UINT32 rowstride, UINT32 format, UINT32 flip) { size_t size = Stream_GetRemainingLength(s); diff --git a/libfreerdp/codec/nsc_encode.h b/libfreerdp/codec/nsc_encode.h index a84a519f4..8a50e3205 100644 --- a/libfreerdp/codec/nsc_encode.h +++ b/libfreerdp/codec/nsc_encode.h @@ -24,6 +24,7 @@ #include -FREERDP_LOCAL BOOL nsc_encode(NSC_CONTEXT* context, const BYTE* bmpdata, UINT32 rowstride); +FREERDP_LOCAL BOOL nsc_encode(NSC_CONTEXT* WINPR_RESTRICT context, + const BYTE* WINPR_RESTRICT bmpdata, UINT32 rowstride); #endif /* FREERDP_LIB_CODEC_NSC_ENCODE_H */