From 15456e1ee1725c0a5b0009b2e61fae04a641bbea Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 26 Aug 2024 16:33:59 +0200 Subject: [PATCH 1/3] [warnings] fix implicit widening conversion --- channels/cliprdr/cliprdr_common.c | 4 +- channels/encomsp/client/encomsp_main.c | 2 +- channels/rdp2tcp/client/rdp2tcp_main.c | 2 +- channels/rdpgfx/server/rdpgfx_main.c | 2 +- channels/rdpsnd/client/alsa/rdpsnd_alsa.c | 4 +- channels/rdpsnd/client/pulse/rdpsnd_pulse.c | 2 +- channels/rdpsnd/server/rdpsnd_main.c | 2 +- channels/tsmf/client/alsa/tsmf_alsa.c | 6 +- channels/tsmf/client/tsmf_media.c | 2 +- channels/urbdrc/client/data_transfer.c | 2 +- .../urbdrc/client/libusb/libusb_udevice.c | 4 +- channels/video/client/video_main.c | 6 +- client/Wayland/wlf_pointer.c | 8 +- client/Wayland/wlfreerdp.c | 4 +- client/X11/xf_tsmf.c | 29 +-- client/common/client_cliprdr_file.c | 4 +- libfreerdp/cache/persistent.c | 2 +- libfreerdp/codec/bitmap.c | 28 +-- libfreerdp/codec/clear.c | 4 +- libfreerdp/codec/color.c | 44 ++--- libfreerdp/codec/dsp.c | 3 +- libfreerdp/codec/h264.c | 2 +- libfreerdp/codec/ncrush.c | 10 +- libfreerdp/codec/nsc.c | 2 +- libfreerdp/codec/nsc_encode.c | 4 +- libfreerdp/codec/planar.c | 28 +-- libfreerdp/codec/progressive.c | 8 +- libfreerdp/codec/region.c | 2 +- libfreerdp/codec/rfx.c | 8 +- libfreerdp/codec/rfx_decode.c | 12 +- libfreerdp/codec/rfx_dwt.c | 16 +- libfreerdp/codec/rfx_encode.c | 14 +- libfreerdp/codec/sse/nsc_sse2.c | 49 ++--- libfreerdp/codec/sse/rfx_sse2.c | 22 +-- libfreerdp/codec/test/TestFreeRDPCodecClear.c | 2 +- .../codec/test/TestFreeRDPCodecInterleaved.c | 6 +- .../codec/test/TestFreeRDPCodecPlanar.c | 17 +- .../codec/test/TestFreeRDPCodecProgressive.c | 10 +- .../codec/test/TestFreeRDPCodecRemoteFX.c | 6 +- libfreerdp/codec/yuv.c | 83 ++++----- libfreerdp/core/gateway/http.c | 2 +- libfreerdp/core/orders.c | 12 +- libfreerdp/gdi/gdi.c | 4 +- libfreerdp/gdi/gfx.c | 12 +- libfreerdp/gdi/region.c | 3 +- libfreerdp/gdi/test/TestGdiCreate.c | 2 +- libfreerdp/gdi/test/TestGdiRect.c | 2 +- libfreerdp/gdi/test/helpers.c | 2 +- libfreerdp/primitives/prim_YCoCg.c | 8 +- libfreerdp/primitives/prim_YUV.c | 172 +++++++++--------- libfreerdp/primitives/prim_alphaComp.c | 4 +- libfreerdp/primitives/sse/prim_YUV_ssse3.c | 122 ++++++------- .../primitives/test/TestPrimitivesAlphaComp.c | 2 +- .../primitives/test/TestPrimitivesColors.c | 18 +- .../primitives/test/TestPrimitivesYCoCg.c | 2 +- .../primitives/test/TestPrimitivesYUV.c | 44 ++--- libfreerdp/utils/test/TestRingBuffer.c | 2 +- rdtk/librdtk/rdtk_nine_patch.c | 8 +- rdtk/librdtk/rdtk_surface.c | 2 +- server/Sample/sfreerdp.c | 4 +- server/proxy/pf_channel.c | 4 +- server/shadow/X11/x11_shadow.c | 2 +- server/shadow/shadow_client.c | 2 +- server/shadow/shadow_encoder.c | 4 +- winpr/libwinpr/ncrypt/ncrypt_pkcs11.c | 4 +- winpr/libwinpr/smartcard/smartcard_pcsc.c | 2 +- winpr/libwinpr/synch/timer.c | 4 +- winpr/libwinpr/utils/image.c | 8 +- winpr/libwinpr/utils/print.c | 4 +- 69 files changed, 467 insertions(+), 459 deletions(-) diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c index 65320414a..6c726db68 100644 --- a/channels/cliprdr/cliprdr_common.c +++ b/channels/cliprdr/cliprdr_common.c @@ -404,9 +404,9 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL else if (!useLongFormatNames) { const size_t cap = Stream_Capacity(sub1); - formatList->numFormats = (cap / 36); + formatList->numFormats = (cap / 36ULL); - if ((formatList->numFormats * 36) != cap) + if ((36ULL * formatList->numFormats) != cap) { WLog_ERR(TAG, "Invalid short format list length: %" PRIuz "", cap); return ERROR_INTERNAL_ERROR; diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c index e6dc2834d..93f43885a 100644 --- a/channels/encomsp/client/encomsp_main.c +++ b/channels/encomsp/client/encomsp_main.c @@ -100,7 +100,7 @@ static UINT encomsp_read_unicode_string(wStream* s, ENCOMSP_UNICODE_STRING* str) if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, str->cchString, sizeof(WCHAR))) return ERROR_INVALID_DATA; - Stream_Read(s, &(str->wString), (str->cchString * 2)); /* String (variable) */ + Stream_Read(s, &(str->wString), (sizeof(WCHAR) * str->cchString)); /* String (variable) */ return CHANNEL_RC_OK; } diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index 21b2e6a80..ae2314636 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -134,7 +134,7 @@ static DWORD WINAPI copyThread(void* data) { DWORD status = WAIT_OBJECT_0; Plugin* plugin = (Plugin*)data; - size_t const bufsize = 16 * 1024; + size_t const bufsize = 16ULL * 1024ULL; while (status == WAIT_OBJECT_0) { diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c index 0a3fabc1b..c9e49fa8c 100644 --- a/channels/rdpgfx/server/rdpgfx_main.c +++ b/channels/rdpgfx/server/rdpgfx_main.c @@ -501,7 +501,7 @@ static INLINE UINT32 rdpgfx_estimate_h264_avc420(const RDPGFX_AVC420_BITMAP_STRE { /* H264 metadata + H264 stream. See rdpgfx_write_h264_avc420 */ return sizeof(UINT32) /* numRegionRects */ - + 10 /* regionRects + quantQualityVals */ + + 10ULL /* regionRects + quantQualityVals */ * havc420->meta.numRegionRects + havc420->length; } diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index 9751bbe22..9cf33b2dd 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -145,8 +145,8 @@ static int rdpsnd_alsa_set_sw_params(rdpsndAlsaPlugin* alsa) SND_PCM_CHECK("snd_pcm_sw_params_malloc", status); status = snd_pcm_sw_params_current(alsa->pcm_handle, sw_params); SND_PCM_CHECK("snd_pcm_sw_params_current", status); - status = snd_pcm_sw_params_set_avail_min(alsa->pcm_handle, sw_params, - (alsa->aformat.nChannels * alsa->actual_channels)); + status = snd_pcm_sw_params_set_avail_min( + alsa->pcm_handle, sw_params, (1ULL * alsa->aformat.nChannels * alsa->actual_channels)); SND_PCM_CHECK("snd_pcm_sw_params_set_avail_min", status); status = snd_pcm_sw_params_set_start_threshold(alsa->pcm_handle, sw_params, alsa->aformat.nBlockAlign); diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 2b09680de..a9ca154ea 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -405,7 +405,7 @@ static BOOL rdpsnd_pulse_open_stream(rdpsndDevicePlugin* device) if (pulse->latency > 0) { buffer_attr.maxlength = UINT32_MAX; - buffer_attr.tlength = pa_usec_to_bytes(pulse->latency * 1000, &pulse->sample_spec); + buffer_attr.tlength = pa_usec_to_bytes(1000ULL * pulse->latency, &pulse->sample_spec); buffer_attr.prebuf = UINT32_MAX; buffer_attr.minreq = UINT32_MAX; buffer_attr.fragsize = UINT32_MAX; diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index 73f970c42..f840e4cdf 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -376,7 +376,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context, UINT16 cli switch (format->wFormatTag) { case WAVE_FORMAT_DVI_ADPCM: - bs = (format->nBlockAlign - 4 * format->nChannels) * 4; + bs = 4ULL * (format->nBlockAlign - 4ULL * format->nChannels); context->priv->out_frames -= context->priv->out_frames % bs; if (context->priv->out_frames < bs) diff --git a/channels/tsmf/client/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c index 04d42a089..e39102ee0 100644 --- a/channels/tsmf/client/alsa/tsmf_alsa.c +++ b/channels/tsmf/client/alsa/tsmf_alsa.c @@ -146,15 +146,13 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data int frames = 0; const BYTE* end = NULL; const BYTE* pindex = NULL; - int rbytes_per_frame = 0; - int sbytes_per_frame = 0; TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio; DEBUG_TSMF("data_size %" PRIu32 "", data_size); if (alsa->out_handle) { - sbytes_per_frame = alsa->source_channels * alsa->bytes_per_sample; - rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_sample; + const size_t sbytes_per_frame = 1ULL * alsa->source_channels * alsa->bytes_per_sample; + const size_t rbytes_per_frame = 1ULL * alsa->actual_channels * alsa->bytes_per_sample; pindex = src; end = pindex + data_size; diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 878ba0dfd..0fbe2c475 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -52,7 +52,7 @@ #define AUDIO_TOLERANCE 10000000LL /* 1 second = 10,000,000 100ns units*/ -#define VIDEO_ADJUST_MAX 10 * 1000 * 1000 +#define VIDEO_ADJUST_MAX 10ULL * 1000ULL * 1000ULL #define MAX_ACK_TIME 666667 diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index 5f9a6e0e4..c516acaaa 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -855,7 +855,7 @@ static UINT urb_isoch_transfer(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callbac return ERROR_INVALID_DATA; packetDescriptorData = Stream_Pointer(s); - Stream_Seek(s, NumberOfPackets * 12); + Stream_Seek(s, 12ULL * NumberOfPackets); if (!Stream_CheckAndLogRequiredLength(TAG, s, sizeof(UINT32))) return ERROR_INVALID_DATA; diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index 4604e1aaf..7d6019ecd 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -1213,7 +1213,7 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* ASYNC_TRANSFER_USER_DATA* user_data = NULL; struct libusb_transfer* iso_transfer = NULL; URBDRC_PLUGIN* urbdrc = NULL; - size_t outSize = (NumberOfPackets * 12); + size_t outSize = (12ULL * NumberOfPackets); uint32_t streamID = 0x40000000 | RequestId; if (!pdev || !pdev->urbdrc) @@ -1230,7 +1230,7 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK* user_data->StartFrame = StartFrame; if (!Buffer) - Stream_Seek(user_data->data, (NumberOfPackets * 12)); + Stream_Seek(user_data->data, (12ULL * NumberOfPackets)); if (NumberOfPackets > 0) { diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c index a23f54c5f..513ef5804 100644 --- a/channels/video/client/video_main.c +++ b/channels/video/client/video_main.c @@ -183,7 +183,7 @@ static BOOL PresentationContext_ref(PresentationContext* presentation) static PresentationContext* PresentationContext_new(VideoClientContext* video, BYTE PresentationId, UINT32 x, UINT32 y, UINT32 width, UINT32 height) { - size_t s = width * height * 4ULL; + size_t s = 4ULL * width * height; VideoClientContextPriv* priv = NULL; PresentationContext* ret = NULL; @@ -647,9 +647,9 @@ static UINT video_control_send_client_notification(VideoClientContext* context, /* TSMM_CLIENT_NOTIFICATION_FRAMERATE_OVERRIDE */ Stream_Write_UINT32(s, notif->FramerateOverride.Flags); Stream_Write_UINT32(s, notif->FramerateOverride.DesiredFrameRate); - Stream_Zero(s, 4 * 2); + Stream_Zero(s, 4ULL * 2ULL); - cbSize += 4 * 4; + cbSize += 4UL * 4UL; } else { diff --git a/client/Wayland/wlf_pointer.c b/client/Wayland/wlf_pointer.c index 6fba40bbe..eebc4ba19 100644 --- a/client/Wayland/wlf_pointer.c +++ b/client/Wayland/wlf_pointer.c @@ -39,7 +39,7 @@ static BOOL wlf_Pointer_New(rdpContext* context, rdpPointer* pointer) if (!ptr) return FALSE; - ptr->size = pointer->width * pointer->height * 4ULL; + ptr->size = 4ULL * pointer->width * pointer->height; ptr->data = winpr_aligned_malloc(ptr->size, 16); if (!ptr->data) @@ -92,7 +92,7 @@ static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer) !wlf_scale_coordinates(context, &w, &h, FALSE)) return FALSE; - size = w * h * 4ULL; + size = 4ULL * w * h; data = malloc(size); if (!data) @@ -103,8 +103,8 @@ static BOOL wlf_Pointer_Set(rdpContext* context, rdpPointer* pointer) area.right = (UINT16)pointer->width; area.bottom = (UINT16)pointer->height; - if (!wlf_copy_image(ptr->data, pointer->width * 4, pointer->width, pointer->height, data, w * 4, - w, h, &area, + if (!wlf_copy_image(ptr->data, 4ULL * pointer->width, pointer->width, pointer->height, data, + 4ULL * w, w, h, &area, freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))) goto fail; diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index a0bef14eb..8bff5ed0d 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -754,8 +754,8 @@ BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t s } else { - const size_t baseSrcOffset = area->top * srcStride + area->left * 4; - const size_t baseDstOffset = area->top * dstStride + area->left * 4; + const size_t baseSrcOffset = 1ULL * area->top * srcStride + 4ULL * area->left; + const size_t baseDstOffset = 1ULL * area->top * dstStride + 4ULL * area->left; const size_t width = MIN((size_t)area->right - area->left, dstWidth - area->left); const size_t height = MIN((size_t)area->bottom - area->top, dstHeight - area->top); const BYTE* psrc = (const BYTE*)src; diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index b54fd0188..c61051a70 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -226,29 +226,30 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM if (image->pitches[0] == event->frameWidth) { CopyMemory(image->data + image->offsets[0], event->frameData, - event->frameWidth * event->frameHeight); + 1ULL * event->frameWidth * event->frameHeight); } else { for (int i = 0; i < event->frameHeight; i++) { - CopyMemory(image->data + image->offsets[0] + i * image->pitches[0], - event->frameData + i * event->frameWidth, event->frameWidth); + CopyMemory(image->data + 1ULL * image->offsets[0] + + 1ULL * i * image->pitches[0], + event->frameData + 1ULL * i * event->frameWidth, event->frameWidth); } } /* UV */ /* Conversion between I420 and YV12 is to simply swap U and V */ if (!converti420yv12) { - data1 = event->frameData + event->frameWidth * event->frameHeight; - data2 = event->frameData + event->frameWidth * event->frameHeight + - event->frameWidth * event->frameHeight / 4; + data1 = event->frameData + 1ULL * event->frameWidth * event->frameHeight; + data2 = event->frameData + 1ULL * event->frameWidth * event->frameHeight + + 1ULL * event->frameWidth * event->frameHeight / 4; } else { - data2 = event->frameData + event->frameWidth * event->frameHeight; - data1 = event->frameData + event->frameWidth * event->frameHeight + - event->frameWidth * event->frameHeight / 4; + data2 = event->frameData + 1ULL * event->frameWidth * event->frameHeight; + data1 = event->frameData + 1ULL * event->frameWidth * event->frameHeight + + 1ULL * event->frameWidth * event->frameHeight / 4; image->id = pixfmt == RDP_PIXFMT_I420 ? RDP_PIXFMT_YV12 : RDP_PIXFMT_I420; } @@ -263,10 +264,12 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM { for (int i = 0; i < event->frameHeight / 2; i++) { - CopyMemory(image->data + image->offsets[1] + i * image->pitches[1], - data1 + i * event->frameWidth / 2, event->frameWidth / 2); - CopyMemory(image->data + image->offsets[2] + i * image->pitches[2], - data2 + i * event->frameWidth / 2, event->frameWidth / 2); + CopyMemory(image->data + 1ULL * image->offsets[1] + + 1ULL * i * image->pitches[1], + data1 + 1ULL * i * event->frameWidth / 2, event->frameWidth / 2); + CopyMemory(image->data + 1ULL * image->offsets[2] + + 1ULL * i * image->pitches[2], + data2 + 1ULL * i * event->frameWidth / 2, event->frameWidth / 2); } } break; diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 12a1ed3da..7c21cdaa6 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -979,7 +979,7 @@ static void cliprdr_file_fuse_read(fuse_req_t fuse_req, fuse_ino_t fuse_ino, siz return; } - size = MIN(size, 8 * 1024 * 1024); + size = MIN(size, 8ULL * 1024ULL * 1024ULL); result = request_file_range_async(file_context, fuse_file, fuse_req, offset, size); HashTable_Unlock(file_context->inode_table); @@ -1910,7 +1910,7 @@ static BOOL set_selection_for_clip_data_entry(CliprdrFileContext* file_context, filetime += file->ftLastWriteTime.dwLowDateTime; fuse_file->last_write_time_unix = - filetime / (10 * 1000 * 1000) - WIN32_FILETIME_TO_UNIX_EPOCH; + 1ULL * filetime / (10ULL * 1000ULL * 1000ULL) - WIN32_FILETIME_TO_UNIX_EPOCH; fuse_file->has_last_write_time = TRUE; } diff --git a/libfreerdp/cache/persistent.c b/libfreerdp/cache/persistent.c index 62e352f7a..47c47867d 100644 --- a/libfreerdp/cache/persistent.c +++ b/libfreerdp/cache/persistent.c @@ -207,7 +207,7 @@ static int persistent_cache_read_v3(rdpPersistentCache* persistent) if (fread((void*)&entry, sizeof(entry), 1, persistent->fp) != 1) break; - if (fseek(persistent->fp, (entry.width * entry.height * 4), SEEK_CUR) != 0) + if (fseek(persistent->fp, (4ULL * entry.width * entry.height), SEEK_CUR) != 0) break; persistent->count++; diff --git a/libfreerdp/codec/bitmap.c b/libfreerdp/codec/bitmap.c index fcb2b734e..bd99837b7 100644 --- a/libfreerdp/codec/bitmap.c +++ b/libfreerdp/codec/bitmap.c @@ -152,7 +152,7 @@ static INLINE UINT16 out_copy_count_2(UINT16 in_count, wStream* WINPR_RESTRICT i Stream_Write_UINT16(in_s, in_count); } - Stream_Write(in_s, Stream_Buffer(in_data), in_count * 2); + Stream_Write(in_s, Stream_Buffer(in_data), 2ULL * in_count); } Stream_SetPosition(in_data, 0); @@ -184,7 +184,7 @@ static INLINE UINT16 out_copy_count_3(UINT16 in_count, wStream* WINPR_RESTRICT i Stream_Write_UINT16(in_s, in_count); } - Stream_Write(in_s, Stream_Pointer(in_data), in_count * 3); + Stream_Write(in_s, Stream_Pointer(in_data), 3ULL * in_count); } Stream_SetPosition(in_data, 0); @@ -484,16 +484,16 @@ static INLINE SSIZE_T freerdp_bitmap_compress_24(const void* WINPR_RESTRICT srcD UINT16 fom_count = 0; size_t fom_mask_len = 0; const char* start = (const char*)srcData; - const char* line = start + width * start_line * 4; + const char* line = start + 4ULL * width * start_line; const char* last_line = NULL; while ((line >= start) && (out_count < 32768)) { - size_t i = Stream_GetPosition(s) + count * 3U; + size_t i = Stream_GetPosition(s) + 3ULL * count; - if ((i - (color_count * 3) >= byte_limit) && (i - (bicolor_count * 3) >= byte_limit) && - (i - (fill_count * 3) >= byte_limit) && (i - (mix_count * 3) >= byte_limit) && - (i - (fom_count * 3) >= byte_limit)) + if ((i - (3ULL * color_count) >= byte_limit) && + (i - (3ULL * bicolor_count) >= byte_limit) && (i - (3ULL * fill_count) >= byte_limit) && + (i - (3ULL * mix_count) >= byte_limit) && (i - (3ULL * fom_count) >= byte_limit)) { break; } @@ -692,7 +692,7 @@ static INLINE SSIZE_T freerdp_bitmap_compress_24(const void* WINPR_RESTRICT srcD } last_line = line; - line = line - width * 4; + line = line - 4ULL * width; start_line--; lines_sent++; } @@ -790,16 +790,16 @@ static INLINE SSIZE_T freerdp_bitmap_compress_16(const void* WINPR_RESTRICT srcD UINT16 fom_count = 0; size_t fom_mask_len = 0; const char* start = (const char*)srcData; - const char* line = start + width * start_line * 2; + const char* line = start + 2ULL * width * start_line; const char* last_line = NULL; while ((line >= start) && (out_count < 32768)) { - size_t i = Stream_GetPosition(s) + count * 2; + size_t i = Stream_GetPosition(s) + 2ULL * count; - if ((i - (color_count * 2) >= byte_limit) && (i - (bicolor_count * 2) >= byte_limit) && - (i - (fill_count * 2) >= byte_limit) && (i - (mix_count * 2) >= byte_limit) && - (i - (fom_count * 2) >= byte_limit)) + if ((i - (2ULL * color_count) >= byte_limit) && + (i - (2ULL * bicolor_count) >= byte_limit) && (i - (2ULL * fill_count) >= byte_limit) && + (i - (2ULL * mix_count) >= byte_limit) && (i - (2ULL * fom_count) >= byte_limit)) { break; } @@ -996,7 +996,7 @@ static INLINE SSIZE_T freerdp_bitmap_compress_16(const void* WINPR_RESTRICT srcD } last_line = line; - line = line - width * 2; + line = line - 2ULL * width; start_line--; lines_sent++; } diff --git a/libfreerdp/codec/clear.c b/libfreerdp/codec/clear.c index d7e77737b..bab38d203 100644 --- a/libfreerdp/codec/clear.c +++ b/libfreerdp/codec/clear.c @@ -721,7 +721,7 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* WINPR_RESTRICT clear, if (!resize_vbar_entry(clear, vBarShortEntry)) return FALSE; - for (UINT32 y = 0; y < vBarShortPixelCount; y++) + for (size_t y = 0; y < vBarShortPixelCount; y++) { BYTE r = 0; BYTE g = 0; @@ -820,7 +820,7 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* WINPR_RESTRICT clear, return FALSE; } } - for (UINT32 x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { UINT32 color = 0; color = FreeRDPReadColor(&pSrcPixel[x * FreeRDPGetBytesPerPixel(clear->format)], diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index 614a68cd0..d423231a3 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -56,7 +56,7 @@ BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* WINPR_RESTR if (!dstData) return NULL; - ZeroMemory(dstData, width * height); + ZeroMemory(dstData, 1ULL * width * height); BYTE* dstp = dstData; for (UINT32 y = 0; y < height; y++) @@ -94,13 +94,13 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds const UINT32 monoStep = (nWidth + 7) / 8; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { BYTE* pDstLine = &pDstData[((nYDst + y) * nDstStep)]; UINT32 monoBit = 0x80; const BYTE* monoBits = &pSrcData[monoStep * y]; - for (UINT32 x = 0; x < nWidth; x++) + for (size_t x = 0; x < nWidth; x++) { BYTE* pDstPixel = &pDstLine[((nXDst + x) * FreeRDPGetBytesPerPixel(DstFormat))]; BOOL monoPixel = (*monoBits & monoBit) ? TRUE : FALSE; @@ -163,7 +163,7 @@ static void fill_gdi_palette_for_icon(const BYTE* colorTable, UINT16 cbColorTabl for (UINT16 i = 0; i < cbColorTable / 4; i++) { - palette->palette[i] = FreeRDPReadColor_int(&colorTable[4 * i], palette->format); + palette->palette[i] = FreeRDPReadColor_int(&colorTable[4ULL * i], palette->format); } } @@ -260,7 +260,7 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* WINPR_RESTRICT pDstData, UINT32 Dst for (UINT32 y = 0; y < nHeight; y++) { - maskByte = &bitsMask[stride * (nHeight - 1 - y)]; + maskByte = &bitsMask[1ULL * stride * (nHeight - 1 - y)]; nextBit = 0x80; for (UINT32 x = 0; x < nWidth; x++) @@ -319,12 +319,12 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp( if (andStep * nHeight > andMaskLength) return FALSE; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* andBits = NULL; const BYTE* xorBits = NULL; - BYTE* pDstPixel = - &pDstData[((nYDst + y) * nDstStep) + (nXDst * FreeRDPGetBytesPerPixel(DstFormat))]; + BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) + + (1ULL * nXDst * FreeRDPGetBytesPerPixel(DstFormat))]; xorBit = andBit = 0x80; if (!vFlip) @@ -417,12 +417,12 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp( return FALSE; } - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* xorBits = NULL; const BYTE* andBits = NULL; - BYTE* pDstPixel = - &pDstData[((nYDst + y) * nDstStep) + (nXDst * FreeRDPGetBytesPerPixel(DstFormat))]; + BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) + + (1ULL * nXDst * FreeRDPGetBytesPerPixel(DstFormat))]; andBit = 0x80; if (!vFlip) @@ -554,10 +554,10 @@ static INLINE BOOL overlapping(const BYTE* pDstData, UINT32 nXDst, UINT32 nYDst, UINT32 nYSrc, UINT32 nSrcStep, UINT32 srcBytesPerPixel, UINT32 nWidth, UINT32 nHeight) { - const BYTE* pDstStart = &pDstData[nXDst * dstBytesPerPixel + nYDst * nDstStep]; - const BYTE* pDstEnd = pDstStart + nHeight * nDstStep; - const BYTE* pSrcStart = &pSrcData[nXSrc * srcBytesPerPixel + nYSrc * nSrcStep]; - const BYTE* pSrcEnd = pSrcStart + nHeight * nSrcStep; + const BYTE* pDstStart = &pDstData[1ULL * nXDst * dstBytesPerPixel + 1ULL * nYDst * nDstStep]; + const BYTE* pDstEnd = pDstStart + 1ULL * nHeight * nDstStep; + const BYTE* pSrcStart = &pSrcData[1ULL * nXSrc * srcBytesPerPixel + 1ULL * nYSrc * nSrcStep]; + const BYTE* pSrcEnd = pSrcStart + 1ULL * nHeight * nSrcStep; WINPR_UNUSED(nWidth); @@ -819,10 +819,10 @@ BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep const BYTE* srcLine = &pSrcData[srcVMultiplier * (y + nYSrc) * nSrcStep + srcVOffset]; BYTE* dstLine = &pDstData[dstVMultiplier * (y + nYDst) * nDstStep + dstVOffset]; - UINT32 color = FreeRDPReadColor_int(&srcLine[nXSrc * srcByte], SrcFormat); + UINT32 color = FreeRDPReadColor_int(&srcLine[1ULL * nXSrc * srcByte], SrcFormat); UINT32 oldColor = color; UINT32 dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette); - FreeRDPWriteColor_int(&dstLine[nXDst * dstByte], DstFormat, dstColor); + FreeRDPWriteColor_int(&dstLine[1ULL * nXDst * dstByte], DstFormat, dstColor); for (SSIZE_T x = 1; x < nWidth; x++) { color = FreeRDPReadColor_int(&srcLine[(x + nXSrc) * srcByte], SrcFormat); @@ -889,18 +889,18 @@ BOOL freerdp_image_fill(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, UINT32 n if (nDstStep == 0) nDstStep = (nXDst + nWidth) * FreeRDPGetBytesPerPixel(DstFormat); - pFirstDstLine = &pDstData[nYDst * nDstStep]; - pFirstDstLineXOffset = &pFirstDstLine[nXDst * bpp]; + pFirstDstLine = &pDstData[1ULL * nYDst * nDstStep]; + pFirstDstLineXOffset = &pFirstDstLine[1ULL * nXDst * bpp]; - for (UINT32 x = 0; x < nWidth; x++) + for (size_t x = 0; x < nWidth; x++) { BYTE* pDst = &pFirstDstLine[(x + nXDst) * bpp]; FreeRDPWriteColor_int(pDst, DstFormat, color); } - for (UINT32 y = 1; y < nHeight; y++) + for (size_t y = 1; y < nHeight; y++) { - BYTE* pDstLine = &pDstData[(y + nYDst) * nDstStep + nXDst * bpp]; + BYTE* pDstLine = &pDstData[(y + nYDst) * nDstStep + 1ULL * nXDst * bpp]; memcpy(pDstLine, pFirstDstLineXOffset, 1ull * nWidth * bpp); } diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c index a291ee687..b32f8aa6b 100644 --- a/libfreerdp/codec/dsp.c +++ b/libfreerdp/codec/dsp.c @@ -1481,7 +1481,8 @@ BOOL freerdp_dsp_context_reset(FREERDP_DSP_CONTEXT* WINPR_RESTRICT context, size_t min_frame_data = 1ull * context->common.format.wBitsPerSample * context->common.format.nChannels * FramesPerPacket; size_t data_per_block = - (context->common.format.nBlockAlign - 4 * context->common.format.nChannels) * 8; + (1ULL * context->common.format.nBlockAlign - 4ULL * context->common.format.nChannels) * + 8ULL; size_t nb_block_per_packet = min_frame_data / data_per_block; if (min_frame_data % data_per_block) diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 27556131f..426caff34 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -168,7 +168,7 @@ static INLINE BOOL diff_tile(const RECTANGLE_16* regionRect, BYTE* pYUVData[3], if (regionRect->right / 2u > iStride[2]) return FALSE; - for (UINT16 y = regionRect->top; y < regionRect->bottom; y++) + for (size_t y = regionRect->top; y < regionRect->bottom; y++) { const BYTE* cur0 = &pYUVData[0][y * iStride[0]]; const BYTE* cur1 = &pYUVData[1][y * iStride[1]]; diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index 44dc78f22..bd04884bf 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -2679,7 +2679,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize if (IndexLEC * 2ull >= ARRAYSIZE(HuffCodeLEC)) return -1; - CodeLEC = get_word(&HuffCodeLEC[IndexLEC * 2]); + CodeLEC = get_word(&HuffCodeLEC[2ULL * IndexLEC]); if (BitLength > 15) return -1006; @@ -2773,7 +2773,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize if (IndexLEC * 2ull >= ARRAYSIZE(HuffCodeLEC)) return -1; - CodeLEC = get_word(&HuffCodeLEC[IndexLEC * 2]); + CodeLEC = get_word(&HuffCodeLEC[2ULL * IndexLEC]); if (BitLength > 15) return -1008; @@ -2820,7 +2820,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize BitLength = HuffLengthLEC[IndexLEC]; if (IndexLEC * 2ull >= ARRAYSIZE(HuffCodeLEC)) return -1; - CodeLEC = get_word(&HuffCodeLEC[IndexLEC * 2]); + CodeLEC = get_word(&HuffCodeLEC[2ULL * IndexLEC]); if (BitLength >= 15) return -1011; @@ -2879,7 +2879,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize if (IndexLEC * 2ull >= ARRAYSIZE(HuffCodeLEC)) return -1; BitLength = HuffLengthLEC[IndexLEC]; - CodeLEC = get_word(&HuffCodeLEC[IndexLEC * 2]); + CodeLEC = get_word(&HuffCodeLEC[2ULL * IndexLEC]); if (BitLength > 15) return -1014; @@ -2903,7 +2903,7 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize if (BitLength > 15) return -1015; - bits = get_word(&HuffCodeLEC[IndexLEC * 2]); + bits = get_word(&HuffCodeLEC[2ULL * IndexLEC]); NCrushWriteBits(&DstPtr, &accumulator, &offset, bits, BitLength); NCrushWriteFinish(&DstPtr, accumulator); const intptr_t dsize = DstPtr - pDstData; diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index c89cd9e43..17fa8f0d4 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -64,7 +64,7 @@ static BOOL nsc_decode(NSC_CONTEXT* WINPR_RESTRICT context) if (!bmpdata) return FALSE; - for (UINT32 y = 0; y < context->height; y++) + for (size_t y = 0; y < context->height; y++) { const BYTE* yplane = NULL; const BYTE* coplane = NULL; diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index b2fb8287c..c6c28ed02 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -113,7 +113,7 @@ fail: static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* WINPR_RESTRICT context, const BYTE* WINPR_RESTRICT data, UINT32 scanline) { - UINT16 y = 0; + size_t y = 0; UINT16 rw = 0; BYTE ccl = 0; const BYTE* src = NULL; @@ -287,7 +287,7 @@ static BOOL nsc_encode_subsampling(NSC_CONTEXT* WINPR_RESTRICT context) if (tempWidth > context->priv->PlaneBuffersLength / tempHeight) return FALSE; - for (UINT32 y = 0; y < tempHeight >> 1; y++) + for (size_t y = 0; y < tempHeight >> 1; y++) { BYTE* co_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1); BYTE* cg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1); diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index e2573124e..663c62da5 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -250,7 +250,7 @@ static INLINE INT32 planar_decompress_plane_rle_only(const BYTE* WINPR_RESTRICT for (INT32 y = 0; y < (INT32)nHeight; y++) { - BYTE* dstp = &pDstData[((y) * (INT32)nWidth)]; + BYTE* dstp = &pDstData[(1ULL * (y) * (INT32)nWidth)]; pixel = 0; currentScanline = dstp; @@ -464,7 +464,7 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* WINPR_RESTRICT pSrcD pixel = deltaValue; } - deltaValue = previousScanline[x * 4] + pixel; + deltaValue = previousScanline[4LL * x] + pixel; *dstp = deltaValue; dstp += 4; x++; @@ -473,7 +473,7 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* WINPR_RESTRICT pSrcD while (nRunLength > 0) { - deltaValue = previousScanline[x * 4] + pixel; + deltaValue = previousScanline[4LL * x] + pixel; *dstp = deltaValue; dstp += 4; x++; @@ -679,7 +679,7 @@ static BOOL planar_subsample_expand(const BYTE* WINPR_RESTRICT plane, size_t pla return FALSE; } - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* src = plane + y / 2 * nPlaneWidth; @@ -1130,7 +1130,7 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* WINPR_RESTR UINT32 k = 0; for (UINT32 i = 0; i < height; i++) { - const BYTE* pixel = &data[scanline * (UINT32)i]; + const BYTE* pixel = &data[1ULL * scanline * (UINT32)i]; for (UINT32 j = 0; j < width; j++) { @@ -1148,7 +1148,7 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* WINPR_RESTR for (INT64 i = (INT64)height - 1; i >= 0; i--) { - const BYTE* pixel = &data[scanline * (UINT32)i]; + const BYTE* pixel = &data[1ULL * scanline * (UINT32)i]; for (UINT32 j = 0; j < width; j++) { @@ -1728,14 +1728,14 @@ BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* WINPR_RESTRICT c return FALSE; context->rlePlanesBuffer = tmp; - context->planes[0] = &context->planesBuffer[context->maxPlaneSize * 0]; - context->planes[1] = &context->planesBuffer[context->maxPlaneSize * 1]; - context->planes[2] = &context->planesBuffer[context->maxPlaneSize * 2]; - context->planes[3] = &context->planesBuffer[context->maxPlaneSize * 3]; - context->deltaPlanes[0] = &context->deltaPlanesBuffer[context->maxPlaneSize * 0]; - context->deltaPlanes[1] = &context->deltaPlanesBuffer[context->maxPlaneSize * 1]; - context->deltaPlanes[2] = &context->deltaPlanesBuffer[context->maxPlaneSize * 2]; - context->deltaPlanes[3] = &context->deltaPlanesBuffer[context->maxPlaneSize * 3]; + context->planes[0] = &context->planesBuffer[0ULL * context->maxPlaneSize]; + context->planes[1] = &context->planesBuffer[1ULL * context->maxPlaneSize]; + context->planes[2] = &context->planesBuffer[2ULL * context->maxPlaneSize]; + context->planes[3] = &context->planesBuffer[3ULL * context->maxPlaneSize]; + context->deltaPlanes[0] = &context->deltaPlanesBuffer[0ULL * context->maxPlaneSize]; + context->deltaPlanes[1] = &context->deltaPlanesBuffer[1ULL * context->maxPlaneSize]; + context->deltaPlanes[2] = &context->deltaPlanesBuffer[2ULL * context->maxPlaneSize]; + context->deltaPlanes[3] = &context->deltaPlanesBuffer[3ULL * context->maxPlaneSize]; } return TRUE; } diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index df38f6848..9442157b3 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -393,12 +393,12 @@ static INLINE RFX_PROGRESSIVE_TILE* progressive_tile_new(void) goto fail; memset(tile->data, 0xFF, dataLen); - size_t signLen = (8192 + 32) * 3; + size_t signLen = (8192ULL + 32ULL) * 3ULL; tile->sign = (BYTE*)winpr_aligned_malloc(signLen, 16); if (!tile->sign) goto fail; - size_t currentLen = (8192 + 32) * 3; + size_t currentLen = (8192ULL + 32ULL) * 3ULL; tile->current = (BYTE*)winpr_aligned_malloc(currentLen, 16); if (!tile->current) goto fail; @@ -884,7 +884,7 @@ static INLINE int progressive_rfx_decode_component( if (status < 0) return status; - CopyMemory(sign, buffer, 4096 * 2); + CopyMemory(sign, buffer, 4096ULL * 2ULL); if (!extrapolate) { rfx_differential_decode(buffer + 4032, 64); @@ -2622,7 +2622,7 @@ PROGRESSIVE_CONTEXT* progressive_context_new_ex(BOOL Compressor, UINT32 Threadin progressive->rects = Stream_New(NULL, 1024); if (!progressive->rects) goto fail; - progressive->bufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16); + progressive->bufferPool = BufferPool_New(TRUE, (8192LL + 32LL) * 3LL, 16); if (!progressive->bufferPool) goto fail; progressive->SurfaceContexts = HashTable_New(TRUE); diff --git a/libfreerdp/codec/region.c b/libfreerdp/codec/region.c index ba7f3d2a4..77076b943 100644 --- a/libfreerdp/codec/region.c +++ b/libfreerdp/codec/region.c @@ -523,7 +523,7 @@ BOOL region16_union_rect(REGION16* dst, const REGION16* src, const RECTANGLE_16* return TRUE; } - newItems = allocateRegion((1 + region16_n_rects(src)) * 4); + newItems = allocateRegion((1ULL + 4ULL * region16_n_rects(src))); if (!newItems) return FALSE; diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index c5cafeda7..3717f9225 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -156,7 +156,7 @@ static INLINE void rfx_tile_init(void* obj) static INLINE void* rfx_decoder_tile_new(const void* val) { - const size_t size = 4 * 64 * 64; + const size_t size = 4ULL * 64ULL * 64ULL; RFX_TILE* tile = NULL; WINPR_UNUSED(val); @@ -259,7 +259,7 @@ RFX_CONTEXT* rfx_context_new_ex(BOOL encoder, UINT32 ThreadingFlags) * * We then multiply by 3 to use a single, partioned buffer for all 3 channels. */ - priv->BufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16); + priv->BufferPool = BufferPool_New(TRUE, (8192ULL + 32ULL) * 3ULL, 16); if (!priv->BufferPool) goto fail; @@ -577,7 +577,7 @@ static INLINE BOOL rfx_process_message_channels(RFX_CONTEXT* WINPR_RESTRICT cont } /* Now, only the first monitor can be used, therefore the other channels will be ignored. */ - Stream_Seek(s, 5 * (numChannels - 1)); + Stream_Seek(s, 5ULL * (numChannels - 1)); WLog_Print(context->priv->log, WLOG_DEBUG, "numChannels %" PRIu8 " id %" PRIu8 ", %" PRIu16 "x%" PRIu16 ".", numChannels, channelId, context->width, context->height); @@ -2303,7 +2303,7 @@ static INLINE BOOL rfx_write_progressive_region(RFX_CONTEXT* WINPR_RESTRICT rfx, */ for (UINT16 i = 0; i < msg->numQuant; i++) { - const UINT32* qv = &msg->quantVals[i * 10]; + const UINT32* qv = &msg->quantVals[10ULL * i]; /* RFX_COMPONENT_CODEC_QUANT */ Stream_Write_UINT8(s, (UINT8)(qv[0] + (qv[2] << 4))); /* LL3 (4-bit), HL3 (4-bit) */ Stream_Write_UINT8(s, (UINT8)(qv[1] + (qv[3] << 4))); /* LH3 (4-bit), HH3 (4-bit) */ diff --git a/libfreerdp/codec/rfx_decode.c b/libfreerdp/codec/rfx_decode.c index fd7baa33d..5c5fbcf74 100644 --- a/libfreerdp/codec/rfx_decode.c +++ b/libfreerdp/codec/rfx_decode.c @@ -79,13 +79,13 @@ BOOL rfx_decode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, const RFX_TILE* WINPR_R static const prim_size_t roi_64x64 = { 64, 64 }; const primitives_t* prims = primitives_get(); PROFILER_ENTER(context->priv->prof_rfx_decode_rgb) - y_quants = context->quants + (tile->quantIdxY * 10); - cb_quants = context->quants + (tile->quantIdxCb * 10); - cr_quants = context->quants + (tile->quantIdxCr * 10); + y_quants = context->quants + (10ULL * tile->quantIdxY); + cb_quants = context->quants + (10ULL * tile->quantIdxCb); + cr_quants = context->quants + (10ULL * tile->quantIdxCr); pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1); - pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */ - pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */ - pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */ + pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL])); /* y_r_buffer */ + pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL])); /* cb_g_buffer */ + pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL])); /* cr_b_buffer */ rfx_decode_component(context, y_quants, tile->YData, tile->YLen, pSrcDst[0]); /* YData */ rfx_decode_component(context, cb_quants, tile->CbData, tile->CbLen, pSrcDst[1]); /* CbData */ rfx_decode_component(context, cr_quants, tile->CrData, tile->CrLen, pSrcDst[2]); /* CrData */ diff --git a/libfreerdp/codec/rfx_dwt.c b/libfreerdp/codec/rfx_dwt.c index 466f3246a..b06fc8cf1 100644 --- a/libfreerdp/codec/rfx_dwt.c +++ b/libfreerdp/codec/rfx_dwt.c @@ -136,9 +136,9 @@ static void rfx_dwt_2d_encode_block(INT16* WINPR_RESTRICT buffer, INT16* WINPR_R for (UINT32 n = 0; n < subband_width; n++) { UINT32 y = n << 1; - l = dwt + n * total_width + x; - h = l + subband_width * total_width; - src = buffer + y * total_width + x; + l = dwt + 1ULL * n * total_width + x; + h = l + 1ULL * subband_width * total_width; + src = buffer + 1ULL * y * total_width + x; /* H */ *h = (src[total_width] - @@ -155,15 +155,15 @@ static void rfx_dwt_2d_encode_block(INT16* WINPR_RESTRICT buffer, INT16* WINPR_R /* The lower part L generates LL(3) and HL(0). */ /* The higher part H generates LH(1) and HH(2). */ - ll = buffer + subband_width * subband_width * 3; + ll = buffer + 3ULL * subband_width * subband_width; hl = buffer; l_src = dwt; - lh = buffer + subband_width * subband_width; - hh = buffer + subband_width * subband_width * 2; - h_src = dwt + subband_width * subband_width * 2; + lh = buffer + 1ULL * subband_width * subband_width; + hh = buffer + 2ULL * subband_width * subband_width; + h_src = dwt + 2ULL * subband_width * subband_width; - for (UINT32 y = 0; y < subband_width; y++) + for (size_t y = 0; y < subband_width; y++) { /* L */ for (UINT32 n = 0; n < subband_width; n++) diff --git a/libfreerdp/codec/rfx_encode.c b/libfreerdp/codec/rfx_encode.c index aadbc7c8a..9d509458a 100644 --- a/libfreerdp/codec/rfx_encode.c +++ b/libfreerdp/codec/rfx_encode.c @@ -58,7 +58,7 @@ static void rfx_encode_format_rgb(const BYTE* WINPR_RESTRICT rgb_data, int width for (int y = 0; y < height; y++) { - src = rgb_data + y * rowstride; + src = rgb_data + 1ULL * y * rowstride; switch (pixel_format) { @@ -280,12 +280,12 @@ void rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, RFX_TILE* WINPR_RESTRIC return; YLen = CbLen = CrLen = 0; - YQuant = context->quants + (tile->quantIdxY * 10); - CbQuant = context->quants + (tile->quantIdxCb * 10); - CrQuant = context->quants + (tile->quantIdxCr * 10); - pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */ - pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */ - pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */ + YQuant = context->quants + (10ULL * tile->quantIdxY); + CbQuant = context->quants + (10ULL * tile->quantIdxCb); + CrQuant = context->quants + (10ULL * tile->quantIdxCr); + pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL])); /* y_r_buffer */ + pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL])); /* cb_g_buffer */ + pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL])); /* cr_b_buffer */ PROFILER_ENTER(context->priv->prof_rfx_encode_rgb) PROFILER_ENTER(context->priv->prof_rfx_encode_format_rgb) rfx_encode_format_rgb(tile->data, tile->width, tile->height, tile->scanline, diff --git a/libfreerdp/codec/sse/nsc_sse2.c b/libfreerdp/codec/sse/nsc_sse2.c index 327f6ed99..6c680aa25 100644 --- a/libfreerdp/codec/sse/nsc_sse2.c +++ b/libfreerdp/codec/sse/nsc_sse2.c @@ -46,7 +46,7 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* data, UINT32 scanline) { - UINT16 y = 0; + size_t y = 0; UINT16 rw = 0; BYTE ccl = 0; const BYTE* src = NULL; @@ -247,27 +247,30 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* dat case PIXEL_FORMAT_RGB8: { - r_val = _mm_set_epi16( - context->palette[(*(src + 7)) * 3], context->palette[(*(src + 6)) * 3], - context->palette[(*(src + 5)) * 3], context->palette[(*(src + 4)) * 3], - context->palette[(*(src + 3)) * 3], context->palette[(*(src + 2)) * 3], - context->palette[(*(src + 1)) * 3], context->palette[(*src) * 3]); - g_val = _mm_set_epi16(context->palette[(*(src + 7)) * 3 + 1], - context->palette[(*(src + 6)) * 3 + 1], - context->palette[(*(src + 5)) * 3 + 1], - context->palette[(*(src + 4)) * 3 + 1], - context->palette[(*(src + 3)) * 3 + 1], - context->palette[(*(src + 2)) * 3 + 1], - context->palette[(*(src + 1)) * 3 + 1], - context->palette[(*src) * 3 + 1]); - b_val = _mm_set_epi16(context->palette[(*(src + 7)) * 3 + 2], - context->palette[(*(src + 6)) * 3 + 2], - context->palette[(*(src + 5)) * 3 + 2], - context->palette[(*(src + 4)) * 3 + 2], - context->palette[(*(src + 3)) * 3 + 2], - context->palette[(*(src + 2)) * 3 + 2], - context->palette[(*(src + 1)) * 3 + 2], - context->palette[(*src) * 3 + 2]); + r_val = _mm_set_epi16(context->palette[(*(src + 7ULL)) * 3ULL], + context->palette[(*(src + 6ULL)) * 3ULL], + context->palette[(*(src + 5ULL)) * 3ULL], + context->palette[(*(src + 4ULL)) * 3ULL], + context->palette[(*(src + 3ULL)) * 3ULL], + context->palette[(*(src + 2ULL)) * 3ULL], + context->palette[(*(src + 1ULL)) * 3ULL], + context->palette[(*src) * 3ULL]); + g_val = _mm_set_epi16(context->palette[(*(src + 7ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 6ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 5ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 4ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 3ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 2ULL)) * 3ULL + 1ULL], + context->palette[(*(src + 1ULL)) * 3ULL + 1ULL], + context->palette[(*src) * 3ULL + 1ULL]); + b_val = _mm_set_epi16(context->palette[(*(src + 7ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 6ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 5ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 4ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 3ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 2ULL)) * 3ULL + 2ULL], + context->palette[(*(src + 1ULL)) * 3ULL + 2ULL], + context->palette[(*src) * 3ULL + 2ULL]); src += 8; } @@ -341,7 +344,7 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context) tempWidth = ROUND_UP_TO(context->width, 8); tempHeight = ROUND_UP_TO(context->height, 2); - for (UINT32 y = 0; y < tempHeight >> 1; y++) + for (size_t y = 0; y < tempHeight >> 1; y++) { co_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1); cg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1); diff --git a/libfreerdp/codec/sse/rfx_sse2.c b/libfreerdp/codec/sse/rfx_sse2.c index 4762e7aad..ab553fb40 100644 --- a/libfreerdp/codec/sse/rfx_sse2.c +++ b/libfreerdp/codec/sse/rfx_sse2.c @@ -321,19 +321,19 @@ rfx_dwt_2d_decode_block_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RESTRICT INT16* ll = NULL; INT16* l_dst = NULL; INT16* h_dst = NULL; - _mm_prefetch_buffer((char*)idwt, subband_width * 4 * sizeof(INT16)); + _mm_prefetch_buffer((char*)idwt, 4ULL * subband_width * sizeof(INT16)); /* Inverse DWT in horizontal direction, results in 2 sub-bands in L, H order in tmp buffer idwt. */ /* The 4 sub-bands are stored in HL(0), LH(1), HH(2), LL(3) order. */ /* The lower part L uses LL(3) and HL(0). */ /* The higher part H uses LH(1) and HH(2). */ - ll = buffer + subband_width * subband_width * 3; + ll = buffer + 3ULL * subband_width * subband_width; hl = buffer; l_dst = idwt; rfx_dwt_2d_decode_block_horiz_sse2(ll, hl, l_dst, subband_width); - lh = buffer + subband_width * subband_width; - hh = buffer + subband_width * subband_width * 2; - h_dst = idwt + subband_width * subband_width * 2; + lh = buffer + 1ULL * subband_width * subband_width; + hh = buffer + 2ULL * subband_width * subband_width; + h_dst = idwt + 2ULL * subband_width * subband_width; rfx_dwt_2d_decode_block_horiz_sse2(lh, hh, h_dst, subband_width); /* Inverse DWT in vertical direction, results are stored in original buffer. */ rfx_dwt_2d_decode_block_vert_sse2(l_dst, h_dst, buffer, subband_width); @@ -371,7 +371,7 @@ rfx_dwt_2d_encode_block_vert_sse2(INT16* WINPR_RESTRICT src, INT16* WINPR_RESTRI src_2n_1 = _mm_load_si128((__m128i*)(src + total_width)); if (n < subband_width - 1) - src_2n_2 = _mm_load_si128((__m128i*)(src + 2 * total_width)); + src_2n_2 = _mm_load_si128((__m128i*)(src + 2ULL * total_width)); else src_2n_2 = src_2n; @@ -461,19 +461,19 @@ rfx_dwt_2d_encode_block_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RESTRICT INT16* ll = NULL; INT16* l_src = NULL; INT16* h_src = NULL; - _mm_prefetch_buffer((char*)dwt, subband_width * 4 * sizeof(INT16)); + _mm_prefetch_buffer((char*)dwt, 4ULL * subband_width * sizeof(INT16)); /* DWT in vertical direction, results in 2 sub-bands in L, H order in tmp buffer dwt. */ l_src = dwt; - h_src = dwt + subband_width * subband_width * 2; + h_src = dwt + 2ULL * subband_width * subband_width; rfx_dwt_2d_encode_block_vert_sse2(buffer, l_src, h_src, subband_width); /* DWT in horizontal direction, results in 4 sub-bands in HL(0), LH(1), HH(2), LL(3) order, * stored in original buffer. */ /* The lower part L generates LL(3) and HL(0). */ /* The higher part H generates LH(1) and HH(2). */ - ll = buffer + subband_width * subband_width * 3; + ll = buffer + 3ULL * subband_width * subband_width; hl = buffer; - lh = buffer + subband_width * subband_width; - hh = buffer + subband_width * subband_width * 2; + lh = buffer + 1ULL * subband_width * subband_width; + hh = buffer + 2ULL * subband_width * subband_width; rfx_dwt_2d_encode_block_horiz_sse2(l_src, ll, hl, subband_width); rfx_dwt_2d_encode_block_horiz_sse2(h_src, lh, hh, subband_width); } diff --git a/libfreerdp/codec/test/TestFreeRDPCodecClear.c b/libfreerdp/codec/test/TestFreeRDPCodecClear.c index 10f2ac7c4..7bb3a9d54 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecClear.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecClear.c @@ -51,7 +51,7 @@ static BOOL test_ClearDecompressExample(UINT32 nr, UINT32 width, UINT32 height, { BOOL rc = FALSE; int status = 0; - BYTE* pDstData = calloc(width * height, 4); + BYTE* pDstData = calloc(4ULL * width, height); CLEAR_CONTEXT* clear = clear_context_new(FALSE); if (!clear || !pDstData) diff --git a/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c b/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c index e8cbb6a24..6158b96ea 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c @@ -29,7 +29,7 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc const UINT32 y = 0; const UINT32 format = PIXEL_FORMAT_RGBX32; const UINT32 bstep = FreeRDPGetBytesPerPixel(format); - const size_t step = (w + 13) * 4; + const size_t step = (13ULL + w) * 4ULL; const size_t SrcSize = step * h; const float maxDiff = 4.0f * ((bpp < 24) ? 2.0f : 1.0f); UINT32 DstSize = SrcSize; @@ -74,8 +74,8 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc BYTE dr = 0; BYTE dg = 0; BYTE db = 0; - const UINT32 srcColor = FreeRDPReadColor(&srcLine[j * bstep], format); - const UINT32 dstColor = FreeRDPReadColor(&dstLine[j * bstep], format); + const UINT32 srcColor = FreeRDPReadColor(&srcLine[1ULL * j * bstep], format); + const UINT32 dstColor = FreeRDPReadColor(&dstLine[1ULL * j * bstep], format); FreeRDPSplitColor(srcColor, format, &r, &g, &b, NULL, NULL); FreeRDPSplitColor(dstColor, format, &dr, &dg, &db, NULL, NULL); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c b/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c index 1d892cece..4f692df68 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c @@ -5461,12 +5461,12 @@ static BOOL CompareBitmap(const BYTE* srcA, UINT32 srcAFormat, const BYTE* srcB, maxDiff = 0.0; } - for (UINT32 y = 0; y < height; y++) + for (size_t y = 0; y < height; y++) { - const BYTE* lineA = &srcA[width * FreeRDPGetBytesPerPixel(srcAFormat) * y]; - const BYTE* lineB = &srcB[width * FreeRDPGetBytesPerPixel(srcBFormat) * y]; + const BYTE* lineA = &srcA[y * width * FreeRDPGetBytesPerPixel(srcAFormat)]; + const BYTE* lineB = &srcB[y * width * FreeRDPGetBytesPerPixel(srcBFormat)]; - for (UINT32 x = 0; x < width; x++) + for (size_t x = 0; x < width; x++) { BYTE sR = 0; BYTE sG = 0; @@ -5508,7 +5508,8 @@ static BOOL RunTestPlanar(BITMAP_PLANAR_CONTEXT* planar, const BYTE* srcBitmap, UINT32 dstSize = 0; BYTE* compressedBitmap = freerdp_bitmap_compress_planar(planar, srcBitmap, srcFormat, width, height, 0, NULL, &dstSize); - BYTE* decompressedBitmap = (BYTE*)calloc(height, width * FreeRDPGetBytesPerPixel(dstFormat)); + BYTE* decompressedBitmap = + (BYTE*)calloc(height, 1ULL * width * FreeRDPGetBytesPerPixel(dstFormat)); (void)printf("%s [%s] --> [%s]: ", __func__, FreeRDPGetColorFormatName(srcFormat), FreeRDPGetColorFormatName(dstFormat)); (void)fflush(stdout); @@ -5572,11 +5573,11 @@ static BOOL RunTestPlanarSingleColor(BITMAP_PLANAR_CONTEXT* planar, const UINT32 if (!bmp || !decompressedBitmap) goto fail_loop; - for (UINT32 y = 0; y < height; y++) + for (size_t y = 0; y < height; y++) { - BYTE* line = &bmp[width * FreeRDPGetBytesPerPixel(srcFormat) * y]; + BYTE* line = &bmp[y * width * FreeRDPGetBytesPerPixel(srcFormat)]; - for (UINT32 x = 0; x < width; x++) + for (size_t x = 0; x < width; x++) { FreeRDPWriteColor(line, srcFormat, color); line += FreeRDPGetBytesPerPixel(srcFormat); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index ef7d1e0ee..0bba985c3 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -164,7 +164,7 @@ static void test_fill_image_alpha_channel(BYTE* data, int width, int height, BYT { for (int j = 0; j < width; j++) { - pixel = (UINT32*)&data[((i * width) + j) * 4]; + pixel = (UINT32*)&data[((1ULL * i * width) + j) * 4ULL]; *pixel = ((*pixel & 0x00FFFFFF) | (value << 24)); } } @@ -561,7 +561,7 @@ static BYTE* test_progressive_load_bitmap(char* path, char* file, size_t* size, return NULL; buffer = image->data; - *size = image->height * image->scanline; + *size = 1ULL * image->height * image->scanline; test_fill_image_alpha_channel(image->data, image->width, image->height, 0xFF); test_image_fill_unused_quarters(image->data, image->scanline, image->width, image->height, quarter, 0xFF000000); @@ -951,7 +951,7 @@ static int test_progressive_ms_sample(char* ms_sample_path) count = 4; progressive = progressive_context_new(FALSE); - g_DstData = winpr_aligned_malloc(g_DstStep * g_Height, 16); + g_DstData = winpr_aligned_malloc(1LL * g_DstStep * g_Height, 16); progressive_create_surface_context(progressive, 0, g_Width, g_Height); /* image 1 */ @@ -1083,11 +1083,11 @@ static BOOL test_encode_decode(const char* path) dstImage->data = resultData; winpr_image_write(dstImage, "/tmp/test.bmp"); } - for (UINT32 y = 0; y < image->height; y++) + for (size_t y = 0; y < image->height; y++) { const BYTE* orig = &image->data[y * image->scanline]; const BYTE* dec = &resultData[y * image->scanline]; - for (UINT32 x = 0; x < image->width; x++) + for (size_t x = 0; x < image->width; x++) { const BYTE* po = &orig[x * 4]; const BYTE* pd = &dec[x * 4]; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c index be67cea70..61226486e 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c @@ -795,9 +795,9 @@ static UINT32 srefImage 0x00129bf5 }; -#define IMG_WIDTH 64 -#define IMG_HEIGHT 64 -#define FORMAT_SIZE 4 +#define IMG_WIDTH 64ULL +#define IMG_HEIGHT 64ULL +#define FORMAT_SIZE 4ULL #define FORMAT PIXEL_FORMAT_XRGB32 static INLINE size_t fuzzyCompare(BYTE b1, BYTE b2) diff --git a/libfreerdp/codec/yuv.c b/libfreerdp/codec/yuv.c index fc687d182..249522b33 100644 --- a/libfreerdp/codec/yuv.c +++ b/libfreerdp/codec/yuv.c @@ -83,12 +83,12 @@ static INLINE BOOL avc420_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3], const INT32 width = rect->right - rect->left; const INT32 height = rect->bottom - rect->top; - BYTE* pDstPoint = - pDstData + rect->top * nDstStep + rect->left * FreeRDPGetBytesPerPixel(DstFormat); + BYTE* pDstPoint = pDstData + 1ULL * rect->top * nDstStep + + 1ULL * rect->left * FreeRDPGetBytesPerPixel(DstFormat); - pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left; - pYUVPoint[1] = pYUVData[1] + rect->top / 2 * iStride[1] + rect->left / 2; - pYUVPoint[2] = pYUVData[2] + rect->top / 2 * iStride[2] + rect->left / 2; + pYUVPoint[0] = pYUVData[0] + 1ULL * rect->top * iStride[0] + rect->left; + pYUVPoint[1] = pYUVData[1] + 1ULL * rect->top / 2 * iStride[1] + rect->left / 2; + pYUVPoint[2] = pYUVData[2] + 1ULL * rect->top / 2 * iStride[2] + rect->left / 2; roi.width = width; roi.height = height; @@ -116,12 +116,12 @@ static INLINE BOOL avc444_yuv_to_rgb(const BYTE* WINPR_RESTRICT pYUVData[3], const INT32 width = rect->right - rect->left; const INT32 height = rect->bottom - rect->top; - BYTE* pDstPoint = - pDstData + rect->top * nDstStep + rect->left * FreeRDPGetBytesPerPixel(DstFormat); + BYTE* pDstPoint = pDstData + 1ULL * rect->top * nDstStep + + 1ULL * rect->left * FreeRDPGetBytesPerPixel(DstFormat); - pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left; - pYUVPoint[1] = pYUVData[1] + rect->top * iStride[1] + rect->left; - pYUVPoint[2] = pYUVData[2] + rect->top * iStride[2] + rect->left; + pYUVPoint[0] = pYUVData[0] + 1ULL * rect->top * iStride[0] + rect->left; + pYUVPoint[1] = pYUVData[1] + 1ULL * rect->top * iStride[1] + rect->left; + pYUVPoint[2] = pYUVData[2] + 1ULL * rect->top * iStride[2] + rect->left; roi.width = width; roi.height = height; @@ -663,13 +663,14 @@ static void CALLBACK yuv420_encode_work_callback(PTP_CALLBACK_INSTANCE instance, roi.width = param->rect.right - param->rect.left; roi.height = param->rect.bottom - param->rect.top; - src = param->pSrcData + param->nSrcStep * param->rect.top + - param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); - pYUVData[0] = param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; - pYUVData[1] = - param->pYUVLumaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; - pYUVData[2] = - param->pYUVLumaData[2] + param->rect.top / 2 * param->iStride[2] + param->rect.left / 2; + src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + + 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); + pYUVData[0] = + param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; + pYUVData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + + param->rect.left / 2; + pYUVData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + + param->rect.left / 2; if (prims->RGBToYUV420_8u_P3AC4R(src, param->SrcFormat, param->nSrcStep, pYUVData, param->iStride, &roi) != PRIMITIVES_SUCCESS) @@ -694,20 +695,20 @@ static void CALLBACK yuv444v1_encode_work_callback(PTP_CALLBACK_INSTANCE instanc roi.width = param->rect.right - param->rect.left; roi.height = param->rect.bottom - param->rect.top; - src = param->pSrcData + param->nSrcStep * param->rect.top + - param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); + src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + + 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); pYUVLumaData[0] = - param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; - pYUVLumaData[1] = - param->pYUVLumaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; - pYUVLumaData[2] = - param->pYUVLumaData[2] + param->rect.top / 2 * param->iStride[2] + param->rect.left / 2; + param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; + pYUVLumaData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + + param->rect.left / 2; + pYUVLumaData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + + param->rect.left / 2; pYUVChromaData[0] = - param->pYUVChromaData[0] + param->rect.top * param->iStride[0] + param->rect.left; - pYUVChromaData[1] = - param->pYUVChromaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; - pYUVChromaData[2] = - param->pYUVChromaData[2] + param->rect.top / 2 * param->iStride[2] + param->rect.left / 2; + param->pYUVChromaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; + pYUVChromaData[1] = param->pYUVChromaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + + param->rect.left / 2; + pYUVChromaData[2] = param->pYUVChromaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + + param->rect.left / 2; if (prims->RGBToAVC444YUV(src, param->SrcFormat, param->nSrcStep, pYUVLumaData, param->iStride, pYUVChromaData, param->iStride, &roi) != PRIMITIVES_SUCCESS) { @@ -731,20 +732,20 @@ static void CALLBACK yuv444v2_encode_work_callback(PTP_CALLBACK_INSTANCE instanc roi.width = param->rect.right - param->rect.left; roi.height = param->rect.bottom - param->rect.top; - src = param->pSrcData + param->nSrcStep * param->rect.top + - param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); + src = param->pSrcData + 1ULL * param->nSrcStep * param->rect.top + + 1ULL * param->rect.left * FreeRDPGetBytesPerPixel(param->SrcFormat); pYUVLumaData[0] = - param->pYUVLumaData[0] + param->rect.top * param->iStride[0] + param->rect.left; - pYUVLumaData[1] = - param->pYUVLumaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; - pYUVLumaData[2] = - param->pYUVLumaData[2] + param->rect.top / 2 * param->iStride[2] + param->rect.left / 2; + param->pYUVLumaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; + pYUVLumaData[1] = param->pYUVLumaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + + param->rect.left / 2; + pYUVLumaData[2] = param->pYUVLumaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + + param->rect.left / 2; pYUVChromaData[0] = - param->pYUVChromaData[0] + param->rect.top * param->iStride[0] + param->rect.left; - pYUVChromaData[1] = - param->pYUVChromaData[1] + param->rect.top / 2 * param->iStride[1] + param->rect.left / 2; - pYUVChromaData[2] = - param->pYUVChromaData[2] + param->rect.top / 2 * param->iStride[2] + param->rect.left / 2; + param->pYUVChromaData[0] + 1ULL * param->rect.top * param->iStride[0] + param->rect.left; + pYUVChromaData[1] = param->pYUVChromaData[1] + 1ULL * param->rect.top / 2 * param->iStride[1] + + param->rect.left / 2; + pYUVChromaData[2] = param->pYUVChromaData[2] + 1ULL * param->rect.top / 2 * param->iStride[2] + + param->rect.left / 2; if (prims->RGBToAVC444YUVv2(src, param->SrcFormat, param->nSrcStep, pYUVLumaData, param->iStride, pYUVChromaData, param->iStride, &roi) != PRIMITIVES_SUCCESS) diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index 1e14abbe8..a278a9d56 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -43,7 +43,7 @@ #define TAG FREERDP_TAG("core.gateway.http") -#define RESPONSE_SIZE_LIMIT 64 * 1024 * 1024 +#define RESPONSE_SIZE_LIMIT 64ULL * 1024ULL * 1024ULL #define WEBSOCKET_MAGIC_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index d799d4da4..0dff91170 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2754,7 +2754,7 @@ BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_g if (*flags & CG_GLYPH_UNICODE_PRESENT) { - Stream_Zero(s, cache_glyph->cGlyphs * 2); + Stream_Zero(s, 2ULL * cache_glyph->cGlyphs); } return TRUE; @@ -2860,7 +2860,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* c if (*flags & CG_GLYPH_UNICODE_PRESENT) { - Stream_Zero(s, cache_glyph_v2->cGlyphs * 2); + Stream_Zero(s, 2ULL * cache_glyph_v2->cGlyphs); } return TRUE; @@ -2886,7 +2886,7 @@ static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BY for (size_t k = 0; k < bytesPerPixel; k++) { - const size_t dstIndex = ((y * 8 + x) * bytesPerPixel) + k; + const size_t dstIndex = ((8ULL * y + x) * bytesPerPixel) + k; const size_t srcIndex = (index * bytesPerPixel) + k; if (dstIndex >= outSize) return FALSE; @@ -2975,7 +2975,7 @@ static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStre for (int i = 7; i >= 0; i--) { - Stream_Read(s, &cache_brush->data[i * scanline], scanline); + Stream_Read(s, &cache_brush->data[1LL * i * scanline], scanline); } } } @@ -3052,7 +3052,7 @@ BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_b for (int i = 7; i >= 0; i--) { - Stream_Write(s, &cache_brush->data[i * scanline], scanline); + Stream_Write(s, &cache_brush->data[1LL * i * scanline], scanline); } } } @@ -3096,7 +3096,7 @@ update_read_create_offscreen_bitmap_order(wStream* s, if (deleteList->cIndices > deleteList->sIndices) { UINT16* new_indices = NULL; - new_indices = (UINT16*)realloc(deleteList->indices, deleteList->cIndices * 2); + new_indices = (UINT16*)realloc(deleteList->indices, 2ULL * deleteList->cIndices); if (!new_indices) return FALSE; diff --git a/libfreerdp/gdi/gdi.c b/libfreerdp/gdi/gdi.c index 35bc41ed7..495c12092 100644 --- a/libfreerdp/gdi/gdi.c +++ b/libfreerdp/gdi/gdi.c @@ -608,7 +608,7 @@ static BOOL gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) case GDI_BS_HATCHED: { const BYTE* hatched = NULL; - hatched = GDI_BS_HATCHED_PATTERNS + (8 * brush->hatch); + hatched = GDI_BS_HATCHED_PATTERNS + (8ULL * brush->hatch); if (!freerdp_image_copy_from_monochrome(data, gdi->drawing->hdc->format, 0, 0, 0, 8, 8, hatched, backColor, foreColor, &gdi->palette)) @@ -880,7 +880,7 @@ static BOOL gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) HGDI_BITMAP hBmp = NULL; UINT32 brushFormat = 0; BYTE* data = (BYTE*)winpr_aligned_malloc( - 8 * 8 * FreeRDPGetBytesPerPixel(gdi->drawing->hdc->format), 16); + 8ULL * 8ULL * FreeRDPGetBytesPerPixel(gdi->drawing->hdc->format), 16); if (!data) { diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index d4aa03b41..ef0148278 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -751,11 +751,11 @@ static BOOL gdi_apply_alpha(BYTE* data, UINT32 format, UINT32 stride, RECTANGLE_ const UINT32 bpp = FreeRDPGetBytesPerPixel(format); WINPR_ASSERT(rect); - for (UINT32 y = rect->top; y < rect->bottom; y++) + for (size_t y = rect->top; y < rect->bottom; y++) { - BYTE* line = &data[stride * y]; + BYTE* line = &data[y * stride]; - for (UINT32 x = first ? rect->left + startOffsetX : rect->left; x < rect->right; x++) + for (size_t x = first ? rect->left + startOffsetX : rect->left; x < rect->right; x++) { BYTE r = 0; BYTE g = 0; @@ -825,11 +825,11 @@ static UINT gdi_SurfaceCommand_Alpha(rdpGdi* gdi, RdpgfxClientContext* context, if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, cmd->height, cmd->width)) return ERROR_INVALID_DATA; - for (UINT32 y = cmd->top; y < cmd->top + cmd->height; y++) + for (size_t y = cmd->top; y < cmd->top + cmd->height; y++) { - BYTE* line = &surface->data[surface->scanline * y]; + BYTE* line = &surface->data[y * surface->scanline]; - for (UINT32 x = cmd->left; x < cmd->left + cmd->width; x++) + for (size_t x = cmd->left; x < cmd->left + cmd->width; x++) { UINT32 color = 0; BYTE r = 0; diff --git a/libfreerdp/gdi/region.c b/libfreerdp/gdi/region.c index 58493a9e4..df122e90e 100644 --- a/libfreerdp/gdi/region.c +++ b/libfreerdp/gdi/region.c @@ -622,9 +622,8 @@ INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, INT32 x, INT32 y, INT32 w, INT32 h if ((hdc->hwnd->ninvalid + 1) > (INT64)hdc->hwnd->count) { - size_t new_cnt = 0; HGDI_RGN new_rgn = NULL; - new_cnt = hdc->hwnd->count * 2; + size_t new_cnt = 2ULL * hdc->hwnd->count; if (new_cnt > UINT32_MAX) return FALSE; diff --git a/libfreerdp/gdi/test/TestGdiCreate.c b/libfreerdp/gdi/test/TestGdiCreate.c index d68dd08bd..01c113f81 100644 --- a/libfreerdp/gdi/test/TestGdiCreate.c +++ b/libfreerdp/gdi/test/TestGdiCreate.c @@ -91,7 +91,7 @@ static int test_gdi_CreateBitmap(void) width = 32; height = 16; - if (!(data = (BYTE*)winpr_aligned_malloc(width * height * 4, 16))) + if (!(data = (BYTE*)winpr_aligned_malloc(4ULL * width * height, 16))) { printf("failed to allocate aligned bitmap data memory\n"); return -1; diff --git a/libfreerdp/gdi/test/TestGdiRect.c b/libfreerdp/gdi/test/TestGdiRect.c index 87cf577b0..7e86b0246 100644 --- a/libfreerdp/gdi/test/TestGdiRect.c +++ b/libfreerdp/gdi/test/TestGdiRect.c @@ -96,7 +96,7 @@ static int test_gdi_FillRect(void) } hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height); - ZeroMemory(hBitmap->data, width * height * FreeRDPGetBytesPerPixel(hdc->format)); + ZeroMemory(hBitmap->data, 1ULL * width * height * FreeRDPGetBytesPerPixel(hdc->format)); gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); color = FreeRDPGetColor(PIXEL_FORMAT_ARGB32, 0xAA, 0xBB, 0xCC, 0xFF); hBrush = gdi_CreateSolidBrush(color); diff --git a/libfreerdp/gdi/test/helpers.c b/libfreerdp/gdi/test/helpers.c index 2f237bc4e..45d00b4bb 100644 --- a/libfreerdp/gdi/test/helpers.c +++ b/libfreerdp/gdi/test/helpers.c @@ -30,7 +30,7 @@ HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat, UINT32 Src if (DstStride == 0) DstStride = nWidth * FreeRDPGetBytesPerPixel(DstFormat); - data = winpr_aligned_malloc(DstStride * nHeight, 16); + data = winpr_aligned_malloc(1ULL * DstStride * nHeight, 16); if (!data) return NULL; diff --git a/libfreerdp/primitives/prim_YCoCg.c b/libfreerdp/primitives/prim_YCoCg.c index 4a36f1e9e..98873870c 100644 --- a/libfreerdp/primitives/prim_YCoCg.c +++ b/libfreerdp/primitives/prim_YCoCg.c @@ -41,11 +41,11 @@ static pstatus_t general_YCoCgToRGB_8u_AC4R(const BYTE* pSrc, INT32 srcStep, BYT const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE); - for (UINT32 y = 0; y < height; y++) + for (size_t y = 0; y < height; y++) { - const BYTE* sptr = &pSrc[srcStep * y]; - BYTE* dptr = &pDst[dstStep * y]; - for (UINT32 x = 0; x < width; x++) + const BYTE* sptr = &pSrc[y * srcStep]; + BYTE* dptr = &pDst[y * dstStep]; + for (size_t x = 0; x < width; x++) { /* Note: shifts must be done before sign-conversion. */ const INT16 Cg = convert(*sptr++, shift); diff --git a/libfreerdp/primitives/prim_YUV.c b/libfreerdp/primitives/prim_YUV.c index e0d6d5812..0ab03d16e 100644 --- a/libfreerdp/primitives/prim_YUV.c +++ b/libfreerdp/primitives/prim_YUV.c @@ -44,38 +44,38 @@ static pstatus_t general_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[3 const UINT32 evenY = 0; const UINT32 oddX = 1; const UINT32 evenX = 0; - const BYTE* pSrc[3] = { pSrcRaw[0] + roi->top * srcStep[0] + roi->left, - pSrcRaw[1] + roi->top / 2 * srcStep[1] + roi->left / 2, - pSrcRaw[2] + roi->top / 2 * srcStep[2] + roi->left / 2 }; - BYTE* pDst[3] = { pDstRaw[0] + roi->top * dstStep[0] + roi->left, - pDstRaw[1] + roi->top * dstStep[1] + roi->left, - pDstRaw[2] + roi->top * dstStep[2] + roi->left }; + const BYTE* pSrc[3] = { pSrcRaw[0] + 1ULL * roi->top * srcStep[0] + roi->left, + pSrcRaw[1] + 1ULL * roi->top / 2 * srcStep[1] + roi->left / 2, + pSrcRaw[2] + 1ULL * roi->top / 2 * srcStep[2] + roi->left / 2 }; + BYTE* pDst[3] = { pDstRaw[0] + 1ULL * roi->top * dstStep[0] + roi->left, + pDstRaw[1] + 1ULL * roi->top * dstStep[1] + roi->left, + pDstRaw[2] + 1ULL * roi->top * dstStep[2] + roi->left }; /* Y data is already here... */ /* B1 */ - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { - const BYTE* Ym = pSrc[0] + srcStep[0] * y; + const BYTE* Ym = pSrc[0] + y * srcStep[0]; BYTE* pY = pDst[0] + dstStep[0] * y; memcpy(pY, Ym, nWidth); } /* The first half of U, V are already here part of this frame. */ /* B2 and B3 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { - const UINT32 val2y = (2 * y + evenY); + const UINT32 val2y = (2ULL * y + evenY); const UINT32 val2y1 = val2y + oddY; - const BYTE* Um = pSrc[1] + srcStep[1] * y; - const BYTE* Vm = pSrc[2] + srcStep[2] * y; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; - BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; + const BYTE* Um = pSrc[1] + y * srcStep[1]; + const BYTE* Vm = pSrc[2] + y * srcStep[2]; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; + BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; + BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; - for (UINT32 x = 0; x < halfWidth; x++) + for (size_t x = 0; x < halfWidth; x++) { - const UINT32 val2x = 2 * x + evenX; + const UINT32 val2x = 2UL * x + evenX; const UINT32 val2x1 = val2x + oddX; pU[val2x] = Um[x]; pV[val2x] = Vm[x]; @@ -106,10 +106,10 @@ static pstatus_t general_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 { const UINT32 val2y = (y * 2 + evenY); const UINT32 val2y1 = val2y + oddY; - BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; + BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; + BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; if (val2y1 > nHeight) continue; @@ -157,23 +157,23 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR /* The auxilary frame is aligned to multiples of 16x16. * We need the padded height for B4 and B5 conversion. */ const UINT32 padHeigth = nHeight + 16 - nHeight % 16; - const BYTE* pSrc[3] = { pSrcRaw[0] + roi->top * srcStep[0] + roi->left, - pSrcRaw[1] + roi->top / 2 * srcStep[1] + roi->left / 2, - pSrcRaw[2] + roi->top / 2 * srcStep[2] + roi->left / 2 }; - BYTE* pDst[3] = { pDstRaw[0] + roi->top * dstStep[0] + roi->left, - pDstRaw[1] + roi->top * dstStep[1] + roi->left, - pDstRaw[2] + roi->top * dstStep[2] + roi->left }; + const BYTE* pSrc[3] = { pSrcRaw[0] + 1ULL * roi->top * srcStep[0] + roi->left, + pSrcRaw[1] + 1ULL * roi->top / 2 * srcStep[1] + roi->left / 2, + pSrcRaw[2] + 1ULL * roi->top / 2 * srcStep[2] + roi->left / 2 }; + BYTE* pDst[3] = { pDstRaw[0] + 1ULL * roi->top * dstStep[0] + roi->left, + pDstRaw[1] + 1ULL * roi->top * dstStep[1] + roi->left, + pDstRaw[2] + 1ULL * roi->top * dstStep[2] + roi->left }; /* The second half of U and V is a bit more tricky... */ /* B4 and B5 */ - for (UINT32 y = 0; y < padHeigth; y++) + for (size_t y = 0; y < padHeigth; y++) { - const BYTE* Ya = pSrc[0] + srcStep[0] * y; + const BYTE* Ya = pSrc[0] + y * srcStep[0]; BYTE* pX = NULL; if ((y) % mod < (mod + 1) / 2) { - const UINT32 pos = (2 * uY++ + oddY); + const size_t pos = (2 * uY++ + oddY); if (pos >= nHeight) continue; @@ -182,7 +182,7 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR } else { - const UINT32 pos = (2 * vY++ + oddY); + const size_t pos = (2 * vY++ + oddY); if (pos >= nHeight) continue; @@ -194,15 +194,15 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR } /* B6 and B7 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { - const UINT32 val2y = (y * 2 + evenY); - const BYTE* Ua = pSrc[1] + srcStep[1] * y; - const BYTE* Va = pSrc[2] + srcStep[2] * y; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; + const UINT32 val2y = (y * 2ULL + evenY); + const BYTE* Ua = pSrc[1] + y * srcStep[1]; + const BYTE* Va = pSrc[2] + y * srcStep[2]; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; - for (UINT32 x = 0; x < halfWidth; x++) + for (size_t x = 0; x < halfWidth; x++) { const UINT32 val2x1 = (x * 2 + oddX); pU[val2x1] = Ua[x]; @@ -230,12 +230,12 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ for (UINT32 y = 0; y < nHeight; y++) { const UINT32 yTop = y + roi->top; - const BYTE* pYaU = pSrc[0] + srcStep[0] * yTop + roi->left / 2; + const BYTE* pYaU = pSrc[0] + 1ULL * srcStep[0] * yTop + roi->left / 2; const BYTE* pYaV = pYaU + nTotalWidth / 2; - BYTE* pU = pDst[1] + dstStep[1] * yTop + roi->left; - BYTE* pV = pDst[2] + dstStep[2] * yTop + roi->left; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * yTop + roi->left; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * yTop + roi->left; - for (UINT32 x = 0; x < halfWidth; x++) + for (size_t x = 0; x < halfWidth; x++) { const UINT32 odd = 2 * x + 1; pU[odd] = *pYaU++; @@ -244,16 +244,16 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ } /* B6 - B9 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { const BYTE* pUaU = pSrc[1] + srcStep[1] * (y + roi->top / 2) + roi->left / 4; const BYTE* pUaV = pUaU + nTotalWidth / 4; const BYTE* pVaU = pSrc[2] + srcStep[2] * (y + roi->top / 2) + roi->left / 4; const BYTE* pVaV = pVaU + nTotalWidth / 4; - BYTE* pU = pDst[1] + dstStep[1] * (2 * y + 1 + roi->top) + roi->left; - BYTE* pV = pDst[2] + dstStep[2] * (2 * y + 1 + roi->top) + roi->left; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * (2ULL * y + 1 + roi->top) + roi->left; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * (2ULL * y + 1 + roi->top) + roi->left; - for (UINT32 x = 0; x < quaterWidth; x++) + for (size_t x = 0; x < quaterWidth; x++) { pU[4 * x + 0] = *pUaU++; pV[4 * x + 0] = *pUaV++; @@ -314,7 +314,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT halfHeight = (roi->height + 1) / 2; /* B1 */ - for (UINT32 y = 0; y < roi->height; y++) + for (size_t y = 0; y < roi->height; y++) { const BYTE* pSrcY = pSrc[0] + y * srcStep[0]; BYTE* pY = pMainDst[0] + y * dstMainStep[0]; @@ -322,16 +322,16 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B2 and B3 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { - const BYTE* pSrcU = pSrc[1] + 2 * y * srcStep[1]; - const BYTE* pSrcV = pSrc[2] + 2 * y * srcStep[2]; - const BYTE* pSrcU1 = pSrc[1] + (2 * y + 1) * srcStep[1]; - const BYTE* pSrcV1 = pSrc[2] + (2 * y + 1) * srcStep[2]; + const BYTE* pSrcU = pSrc[1] + 2ULL * y * srcStep[1]; + const BYTE* pSrcV = pSrc[2] + 2ULL * y * srcStep[2]; + const BYTE* pSrcU1 = pSrc[1] + (2ULL * y + 1ULL) * srcStep[1]; + const BYTE* pSrcV1 = pSrc[2] + (2ULL * y + 1ULL) * srcStep[2]; BYTE* pU = pMainDst[1] + y * dstMainStep[1]; BYTE* pV = pMainDst[2] + y * dstMainStep[2]; - for (UINT32 x = 0; x < halfWidth; x++) + for (size_t x = 0; x < halfWidth; x++) { /* Filter */ const INT32 u = pSrcU[2 * x] + pSrcU[2 * x + 1] + pSrcU1[2 * x] + pSrcU1[2 * x + 1]; @@ -342,13 +342,13 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B4 and B5 */ - for (UINT32 y = 0; y < padHeigth; y++) + for (size_t y = 0; y < padHeigth; y++) { BYTE* pY = pAuxDst[0] + y * dstAuxStep[0]; if (y % 16 < 8) { - const UINT32 pos = (2 * uY++ + 1); + const size_t pos = (2 * uY++ + 1); const BYTE* pSrcU = pSrc[1] + pos * srcStep[1]; if (pos >= roi->height) @@ -358,7 +358,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } else { - const UINT32 pos = (2 * vY++ + 1); + const size_t pos = (2 * vY++ + 1); const BYTE* pSrcV = pSrc[2] + pos * srcStep[2]; if (pos >= roi->height) @@ -369,14 +369,14 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B6 and B7 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { const BYTE* pSrcU = pSrc[1] + 2 * y * srcStep[1]; const BYTE* pSrcV = pSrc[2] + 2 * y * srcStep[2]; BYTE* pU = pAuxDst[1] + y * dstAuxStep[1]; BYTE* pV = pAuxDst[2] + y * dstAuxStep[2]; - for (UINT32 x = 0; x < halfWidth; x++) + for (size_t x = 0; x < halfWidth; x++) { pU[x] = pSrcU[2 * x + 1]; pV[x] = pSrcV[2 * x + 1]; @@ -402,14 +402,14 @@ static pstatus_t general_YUV444ToRGB_8u_P3AC4R_general(const BYTE* const WINPR_R const UINT32 nWidth = roi->width; const UINT32 nHeight = roi->height; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* pY = pSrc[0] + y * srcStep[0]; const BYTE* pU = pSrc[1] + y * srcStep[1]; const BYTE* pV = pSrc[2] + y * srcStep[2]; BYTE* pRGB = pDst + y * dstStep; - for (UINT32 x = 0; x < nWidth; x++) + for (size_t x = 0; x < nWidth; x++) { const BYTE Y = pY[x]; const BYTE U = pU[x]; @@ -439,14 +439,14 @@ static pstatus_t general_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const WINPR_REST const UINT32 nWidth = roi->width; const UINT32 nHeight = roi->height; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* pY = pSrc[0] + y * srcStep[0]; const BYTE* pU = pSrc[1] + y * srcStep[1]; const BYTE* pV = pSrc[2] + y * srcStep[2]; BYTE* pRGB = pDst + y * dstStep; - for (UINT32 x = 0; x < nWidth; x++) + for (size_t x = 0; x < nWidth; x++) { const BYTE Y = pY[x]; const BYTE U = pU[x]; @@ -641,14 +641,14 @@ static pstatus_t general_RGBToYUV444_8u_P3AC4R(const BYTE* WINPR_RESTRICT pSrc, nWidth = roi->width; nHeight = roi->height; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { const BYTE* pRGB = pSrc + y * srcStep; BYTE* pY = pDst[0] + y * dstStep[0]; BYTE* pU = pDst[1] + y * dstStep[1]; BYTE* pV = pDst[2] + y * dstStep[2]; - for (UINT32 x = 0; x < nWidth; x++) + for (size_t x = 0; x < nWidth; x++) { BYTE B = 0; BYTE G = 0; @@ -669,7 +669,7 @@ static INLINE pstatus_t general_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc const UINT32 dstStep[3], const prim_size_t* WINPR_RESTRICT roi) { - UINT32 i = 0; + size_t i = 0; size_t x1 = 0; size_t x2 = 4; size_t x3 = srcStep; @@ -681,14 +681,14 @@ static INLINE pstatus_t general_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (UINT32 y = i = 0; y < roi->height; y += 2, i++) + for (size_t y = i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; BYTE* udst = pDst[1] + i * dstStep[1]; BYTE* vdst = pDst[2] + i * dstStep[2]; - for (UINT32 x = 0; x < roi->width; x += 2) + for (size_t x = 0; x < roi->width; x += 2) { BYTE R = 0; BYTE G = 0; @@ -758,7 +758,7 @@ static INLINE pstatus_t general_RGBToYUV420_RGBX(const BYTE* WINPR_RESTRICT pSrc UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (UINT32 y = 0, i = 0; y < roi->height; y += 2, i++) + for (size_t y = 0, i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; @@ -836,14 +836,14 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* WINPR_RESTRICT pSrc, UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (UINT32 y = 0, i = 0; y < roi->height; y += 2, i++) + for (size_t y = 0, i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; BYTE* udst = pDst[1] + i * dstStep[1]; BYTE* vdst = pDst[2] + i * dstStep[2]; - for (UINT32 x = 0; x < roi->width; x += 2) + for (size_t x = 0; x < roi->width; x += 2) { BYTE R = 0; BYTE G = 0; @@ -899,7 +899,7 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* WINPR_RESTRICT pSrc, *udst++ = RGB2U(Ra, Ga, Ba); *vdst++ = RGB2V(Ra, Ga, Ba); ydst += 2; - src += 2 * bpp; + src += 2ULL * bpp; } } @@ -1043,9 +1043,9 @@ static INLINE pstatus_t general_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT p * Note: * Read information in function general_RGBToAVC444YUV_ANY below ! */ - const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep; + const BYTE* pMaxSrc = pSrc + 1ULL * (roi->height - 1) * srcStep; - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BOOL last = (y >= (roi->height - 1)); const BYTE* srcEven = y < roi->height ? pSrc + y * srcStep : pMaxSrc; @@ -1056,8 +1056,8 @@ static INLINE pstatus_t general_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT p BYTE* b1Odd = !last ? (b1Even + dst1Step[0]) : NULL; BYTE* b2 = pDst1[1] + (y / 2) * dst1Step[1]; BYTE* b3 = pDst1[2] + (y / 2) * dst1Step[2]; - BYTE* b4 = pDst2[0] + dst2Step[0] * n; - BYTE* b5 = b4 + 8 * dst2Step[0]; + BYTE* b4 = pDst2[0] + 1ULL * dst2Step[0] * n; + BYTE* b5 = b4 + 8ULL * dst2Step[0]; BYTE* b6 = pDst2[1] + (y / 2) * dst2Step[1]; BYTE* b7 = pDst2[2] + (y / 2) * dst2Step[2]; general_RGBToAVC444YUV_BGRX_DOUBLE_ROW(srcEven, srcOdd, b1Even, b1Odd, b2, b3, b4, b5, b6, @@ -1184,9 +1184,9 @@ static INLINE pstatus_t general_RGBToAVC444YUV_RGBX(const BYTE* WINPR_RESTRICT p * Note: * Read information in function general_RGBToAVC444YUV_ANY below ! */ - const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep; + const BYTE* pMaxSrc = pSrc + 1ULL * (roi->height - 1) * srcStep; - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BOOL last = (y >= (roi->height - 1)); const BYTE* srcEven = y < roi->height ? pSrc + y * srcStep : pMaxSrc; @@ -1197,8 +1197,8 @@ static INLINE pstatus_t general_RGBToAVC444YUV_RGBX(const BYTE* WINPR_RESTRICT p BYTE* b1Odd = !last ? (b1Even + dst1Step[0]) : NULL; BYTE* b2 = pDst1[1] + (y / 2) * dst1Step[1]; BYTE* b3 = pDst1[2] + (y / 2) * dst1Step[2]; - BYTE* b4 = pDst2[0] + dst2Step[0] * n; - BYTE* b5 = b4 + 8 * dst2Step[0]; + BYTE* b4 = pDst2[0] + 1ULL * dst2Step[0] * n; + BYTE* b5 = b4 + 8ULL * dst2Step[0]; BYTE* b6 = pDst2[1] + (y / 2) * dst2Step[1]; BYTE* b7 = pDst2[2] + (y / 2) * dst2Step[2]; general_RGBToAVC444YUV_RGBX_DOUBLE_ROW(srcEven, srcOdd, b1Even, b1Odd, b2, b3, b4, b5, b6, @@ -1385,9 +1385,9 @@ static INLINE pstatus_t general_RGBToAVC444YUV_ANY( * } * */ - const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep; + const BYTE* pMaxSrc = pSrc + 1ULL * (roi->height - 1) * srcStep; - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BOOL last = (y >= (roi->height - 1)); const BYTE* srcEven = y < roi->height ? pSrc + y * srcStep : pMaxSrc; @@ -1398,8 +1398,8 @@ static INLINE pstatus_t general_RGBToAVC444YUV_ANY( BYTE* b1Odd = !last ? (b1Even + dst1Step[0]) : NULL; BYTE* b2 = pDst1[1] + (y / 2) * dst1Step[1]; BYTE* b3 = pDst1[2] + (y / 2) * dst1Step[2]; - BYTE* b4 = pDst2[0] + dst2Step[0] * n; - BYTE* b5 = b4 + 8 * dst2Step[0]; + BYTE* b4 = pDst2[0] + 1ULL * dst2Step[0] * n; + BYTE* b5 = b4 + 8ULL * dst2Step[0]; BYTE* b6 = pDst2[1] + (y / 2) * dst2Step[1]; BYTE* b7 = pDst2[2] + (y / 2) * dst2Step[2]; general_RGBToAVC444YUV_ANY_DOUBLE_ROW(srcEven, srcOdd, srcFormat, b1Even, b1Odd, b2, b3, b4, @@ -1651,7 +1651,7 @@ static INLINE pstatus_t general_RGBToAVC444YUVv2_ANY( if (roi->height < 1 || roi->width < 1) return !PRIMITIVES_SUCCESS; - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BYTE* srcEven = (pSrc + y * srcStep); const BYTE* srcOdd = (y < roi->height - 1) ? (srcEven + srcStep) : NULL; @@ -1818,7 +1818,7 @@ static INLINE pstatus_t general_RGBToAVC444YUVv2_BGRX(const BYTE* WINPR_RESTRICT if (roi->height < 1 || roi->width < 1) return !PRIMITIVES_SUCCESS; - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BYTE* srcEven = (pSrc + y * srcStep); const BYTE* srcOdd = (y < roi->height - 1) ? (srcEven + srcStep) : NULL; diff --git a/libfreerdp/primitives/prim_alphaComp.c b/libfreerdp/primitives/prim_alphaComp.c index 5657d70f2..3b3b9de5d 100644 --- a/libfreerdp/primitives/prim_alphaComp.c +++ b/libfreerdp/primitives/prim_alphaComp.c @@ -37,13 +37,13 @@ static pstatus_t general_alphaComp_argb(const BYTE* pSrc1, UINT32 src1Step, cons UINT32 src2Step, BYTE* pDst, UINT32 dstStep, UINT32 width, UINT32 height) { - for (UINT32 y = 0; y < height; y++) + for (size_t y = 0; y < height; y++) { const UINT32* sptr1 = (const UINT32*)(pSrc1 + y * src1Step); const UINT32* sptr2 = (const UINT32*)(pSrc2 + y * src2Step); UINT32* dptr = (UINT32*)(pDst + y * dstStep); - for (UINT32 x = 0; x < width; x++) + for (size_t x = 0; x < width; x++) { const UINT32 src1 = *sptr1++; const UINT32 src2 = *sptr2++; diff --git a/libfreerdp/primitives/sse/prim_YUV_ssse3.c b/libfreerdp/primitives/sse/prim_YUV_ssse3.c index 063a27a4b..d0bc27cfa 100644 --- a/libfreerdp/primitives/sse/prim_YUV_ssse3.c +++ b/libfreerdp/primitives/sse/prim_YUV_ssse3.c @@ -160,7 +160,7 @@ static pstatus_t ssse3_YUV420ToRGB_BGRX(const BYTE* const WINPR_RESTRICT pSrc[], const UINT32 pad = roi->width % 16; const __m128i duplicate = _mm_set_epi8(7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0); - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { __m128i* dst = (__m128i*)(pDst + dstStep * y); const BYTE* YData = pSrc[0] + y * srcStep[0]; @@ -229,14 +229,14 @@ static pstatus_t ssse3_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const WINPR_RESTRI const UINT32 nHeight = roi->height; const UINT32 pad = roi->width % 16; - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { __m128i* dst = (__m128i*)(pDst + dstStep * y); const BYTE* YData = pSrc[0] + y * srcStep[0]; const BYTE* UData = pSrc[1] + y * srcStep[1]; const BYTE* VData = pSrc[2] + y * srcStep[2]; - for (UINT32 x = 0; x < nWidth - pad; x += 16) + for (size_t x = 0; x < nWidth - pad; x += 16) { __m128i Y = _mm_load_si128((const __m128i*)YData); __m128i U = _mm_load_si128((const __m128i*)UData); @@ -250,7 +250,7 @@ static pstatus_t ssse3_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const WINPR_RESTRI dst = ssse3_YUV444Pixel(dst, Y, U, V, 3); } - for (UINT32 x = 0; x < pad; x++) + for (size_t x = 0; x < pad; x++) { const BYTE Y = *YData++; const BYTE U = *UData++; @@ -472,10 +472,10 @@ static pstatus_t ssse3_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT32 ssse3_RGBToYUV420_BGRX_UV(line1, line2, udst, vdst, roi->width); ssse3_RGBToYUV420_BGRX_Y(line1, ydst, roi->width); ssse3_RGBToYUV420_BGRX_Y(line2, ydst + dstStep[0], roi->width); - argb += 2 * srcStep; - ydst += 2 * dstStep[0]; - udst += 1 * dstStep[1]; - vdst += 1 * dstStep[2]; + argb += 2ULL * srcStep; + ydst += 2ULL * dstStep[0]; + udst += 1ULL * dstStep[1]; + vdst += 1ULL * dstStep[2]; } if (roi->height & 1) @@ -722,7 +722,7 @@ static pstatus_t ssse3_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT const UINT32 dst2Step[], const prim_size_t* WINPR_RESTRICT roi) { - const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep; + const BYTE* pMaxSrc = pSrc + 1ULL * (roi->height - 1) * srcStep; if (roi->height < 1 || roi->width < 1) return !PRIMITIVES_SUCCESS; @@ -731,7 +731,7 @@ static pstatus_t ssse3_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT return generic->RGBToAVC444YUV(pSrc, srcFormat, srcStep, pDst1, dst1Step, pDst2, dst2Step, roi); - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BOOL last = (y >= (roi->height - 1)); const BYTE* srcEven = y < roi->height ? pSrc + y * srcStep : pMaxSrc; @@ -742,8 +742,8 @@ static pstatus_t ssse3_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT BYTE* b1Odd = !last ? (b1Even + dst1Step[0]) : NULL; BYTE* b2 = pDst1[1] + (y / 2) * dst1Step[1]; BYTE* b3 = pDst1[2] + (y / 2) * dst1Step[2]; - BYTE* b4 = pDst2[0] + dst2Step[0] * n; - BYTE* b5 = b4 + 8 * dst2Step[0]; + BYTE* b4 = pDst2[0] + 1ULL * dst2Step[0] * n; + BYTE* b5 = b4 + 8ULL * dst2Step[0]; BYTE* b6 = pDst2[1] + (y / 2) * dst2Step[1]; BYTE* b7 = pDst2[2] + (y / 2) * dst2Step[2]; ssse3_RGBToAVC444YUV_BGRX_DOUBLE_ROW(srcEven, srcOdd, b1Even, b1Odd, b2, b3, b4, b5, b6, b7, @@ -1043,7 +1043,7 @@ static pstatus_t ssse3_RGBToAVC444YUVv2_BGRX(const BYTE* WINPR_RESTRICT pSrc, UI return generic->RGBToAVC444YUVv2(pSrc, srcFormat, srcStep, pDst1, dst1Step, pDst2, dst2Step, roi); - for (UINT32 y = 0; y < roi->height; y += 2) + for (size_t y = 0; y < roi->height; y += 2) { const BYTE* srcEven = (pSrc + y * srcStep); const BYTE* srcOdd = (srcEven + srcStep); @@ -1100,36 +1100,36 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], const UINT32 evenY = 0; const UINT32 oddX = 1; const UINT32 evenX = 0; - const BYTE* pSrc[3] = { pSrcRaw[0] + roi->top * srcStep[0] + roi->left, - pSrcRaw[1] + roi->top / 2 * srcStep[1] + roi->left / 2, - pSrcRaw[2] + roi->top / 2 * srcStep[2] + roi->left / 2 }; - BYTE* pDst[3] = { pDstRaw[0] + roi->top * dstStep[0] + roi->left, - pDstRaw[1] + roi->top * dstStep[1] + roi->left, - pDstRaw[2] + roi->top * dstStep[2] + roi->left }; + const BYTE* pSrc[3] = { pSrcRaw[0] + 1ULL * roi->top * srcStep[0] + roi->left, + pSrcRaw[1] + 1ULL * roi->top / 2 * srcStep[1] + roi->left / 2, + pSrcRaw[2] + 1ULL * roi->top / 2 * srcStep[2] + roi->left / 2 }; + BYTE* pDst[3] = { pDstRaw[0] + 1ULL * roi->top * dstStep[0] + roi->left, + pDstRaw[1] + 1ULL * roi->top * dstStep[1] + roi->left, + pDstRaw[2] + 1ULL * roi->top * dstStep[2] + roi->left }; /* Y data is already here... */ /* B1 */ - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { - const BYTE* Ym = pSrc[0] + srcStep[0] * y; - BYTE* pY = pDst[0] + dstStep[0] * y; + const BYTE* Ym = pSrc[0] + y * srcStep[0]; + BYTE* pY = pDst[0] + y * dstStep[0]; memcpy(pY, Ym, nWidth); } /* The first half of U, V are already here part of this frame. */ /* B2 and B3 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { - const UINT32 val2y = (2 * y + evenY); - const UINT32 val2y1 = val2y + oddY; - const BYTE* Um = pSrc[1] + srcStep[1] * y; - const BYTE* Vm = pSrc[2] + srcStep[2] * y; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; - BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; + const size_t val2y = (2 * y + evenY); + const size_t val2y1 = val2y + oddY; + const BYTE* Um = pSrc[1] + 1ULL * srcStep[1] * y; + const BYTE* Vm = pSrc[2] + 1ULL * srcStep[2] * y; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; + BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; + BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; - UINT32 x = 0; + size_t x = 0; for (; x < halfWidth - halfPad; x += 16) { const __m128i unpackHigh = _mm_set_epi8(7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0); @@ -1139,10 +1139,10 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], const __m128i u = _mm_loadu_si128((const __m128i*)&Um[x]); const __m128i uHigh = _mm_shuffle_epi8(u, unpackHigh); const __m128i uLow = _mm_shuffle_epi8(u, unpackLow); - _mm_storeu_si128((__m128i*)&pU[2 * x], uHigh); - _mm_storeu_si128((__m128i*)&pU[2 * x + 16], uLow); - _mm_storeu_si128((__m128i*)&pU1[2 * x], uHigh); - _mm_storeu_si128((__m128i*)&pU1[2 * x + 16], uLow); + _mm_storeu_si128((__m128i*)&pU[2ULL * x], uHigh); + _mm_storeu_si128((__m128i*)&pU[2ULL * x + 16], uLow); + _mm_storeu_si128((__m128i*)&pU1[2ULL * x], uHigh); + _mm_storeu_si128((__m128i*)&pU1[2ULL * x + 16], uLow); } { const __m128i u = _mm_loadu_si128((const __m128i*)&Vm[x]); @@ -1207,15 +1207,15 @@ static pstatus_t ssse3_ChromaFilter(BYTE* WINPR_RESTRICT pDst[], const UINT32 ds const UINT32 halfPad = halfWidth % 16; /* Filter */ - for (UINT32 y = roi->top; y < halfHeight + roi->top; y++) + for (size_t y = roi->top; y < halfHeight + roi->top; y++) { - UINT32 x = roi->left; + size_t x = roi->left; const UINT32 val2y = (y * 2 + evenY); const UINT32 val2y1 = val2y + oddY; - BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; - BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; - BYTE* pU = pDst[1] + dstStep[1] * val2y; - BYTE* pV = pDst[2] + dstStep[2] * val2y; + BYTE* pU1 = pDst[1] + 1ULL * dstStep[1] * val2y1; + BYTE* pV1 = pDst[2] + 1ULL * dstStep[2] * val2y1; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * val2y; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * val2y; if (val2y1 > nHeight) continue; @@ -1269,21 +1269,21 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw /* The auxilary frame is aligned to multiples of 16x16. * We need the padded height for B4 and B5 conversion. */ const UINT32 padHeigth = nHeight + 16 - nHeight % 16; - const BYTE* pSrc[3] = { pSrcRaw[0] + roi->top * srcStep[0] + roi->left, - pSrcRaw[1] + roi->top / 2 * srcStep[1] + roi->left / 2, - pSrcRaw[2] + roi->top / 2 * srcStep[2] + roi->left / 2 }; - BYTE* pDst[3] = { pDstRaw[0] + roi->top * dstStep[0] + roi->left, - pDstRaw[1] + roi->top * dstStep[1] + roi->left, - pDstRaw[2] + roi->top * dstStep[2] + roi->left }; + const BYTE* pSrc[3] = { pSrcRaw[0] + 1ULL * roi->top * srcStep[0] + roi->left, + pSrcRaw[1] + 1ULL * roi->top / 2 * srcStep[1] + roi->left / 2, + pSrcRaw[2] + 1ULL * roi->top / 2 * srcStep[2] + roi->left / 2 }; + BYTE* pDst[3] = { pDstRaw[0] + 1ULL * roi->top * dstStep[0] + roi->left, + pDstRaw[1] + 1ULL * roi->top * dstStep[1] + roi->left, + pDstRaw[2] + 1ULL * roi->top * dstStep[2] + roi->left }; const __m128i zero = _mm_setzero_si128(); const __m128i mask = _mm_set_epi8(0, (char)0x80, 0, (char)0x80, 0, (char)0x80, 0, (char)0x80, 0, (char)0x80, 0, (char)0x80, 0, (char)0x80, 0, (char)0x80); /* The second half of U and V is a bit more tricky... */ /* B4 and B5 */ - for (UINT32 y = 0; y < padHeigth; y++) + for (size_t y = 0; y < padHeigth; y++) { - const BYTE* Ya = pSrc[0] + srcStep[0] * y; + const BYTE* Ya = pSrc[0] + 1ULL * srcStep[0] * y; BYTE* pX = NULL; if ((y) % mod < (mod + 1) / 2) @@ -1293,7 +1293,7 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw if (pos >= nHeight) continue; - pX = pDst[1] + dstStep[1] * pos; + pX = pDst[1] + 1ULL * dstStep[1] * pos; } else { @@ -1302,22 +1302,22 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw if (pos >= nHeight) continue; - pX = pDst[2] + dstStep[2] * pos; + pX = pDst[2] + 1ULL * dstStep[2] * pos; } memcpy(pX, Ya, nWidth); } /* B6 and B7 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { - const UINT32 val2y = (y * 2 + evenY); + const size_t val2y = (y * 2 + evenY); const BYTE* Ua = pSrc[1] + srcStep[1] * y; const BYTE* Va = pSrc[2] + srcStep[2] * y; BYTE* pU = pDst[1] + dstStep[1] * val2y; BYTE* pV = pDst[2] + dstStep[2] * val2y; - UINT32 x = 0; + size_t x = 0; for (; x < halfWidth - halfPad; x += 16) { { @@ -1374,15 +1374,15 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] (char)0x80, 2, (char)0x80, 1, (char)0x80, 0); /* B4 and B5: odd UV values for width/2, height */ - for (UINT32 y = 0; y < nHeight; y++) + for (size_t y = 0; y < nHeight; y++) { - const UINT32 yTop = y + roi->top; + const size_t yTop = y + roi->top; const BYTE* pYaU = pSrc[0] + srcStep[0] * yTop + roi->left / 2; const BYTE* pYaV = pYaU + nTotalWidth / 2; - BYTE* pU = pDst[1] + dstStep[1] * yTop + roi->left; - BYTE* pV = pDst[2] + dstStep[2] * yTop + roi->left; + BYTE* pU = pDst[1] + 1ULL * dstStep[1] * yTop + roi->left; + BYTE* pV = pDst[2] + 1ULL * dstStep[2] * yTop + roi->left; - UINT32 x = 0; + size_t x = 0; for (; x < halfWidth - halfPad; x += 16) { { @@ -1410,7 +1410,7 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] } /* B6 - B9 */ - for (UINT32 y = 0; y < halfHeight; y++) + for (size_t y = 0; y < halfHeight; y++) { const BYTE* pUaU = pSrc[1] + srcStep[1] * (y + roi->top / 2) + roi->left / 4; const BYTE* pUaV = pUaU + nTotalWidth / 4; diff --git a/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c index 5aecc2e0f..78fce4889 100644 --- a/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c +++ b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c @@ -29,7 +29,7 @@ #define TOLERANCE 1 static inline const UINT32* PIXEL(const BYTE* _addr_, UINT32 _bytes_, UINT32 _x_, UINT32 _y_) { - const BYTE* addr = _addr_ + _x_ * sizeof(UINT32) + _y_ * _bytes_; + const BYTE* addr = _addr_ + 1ULL * _x_ * sizeof(UINT32) + 1ULL * _y_ * _bytes_; return (const UINT32*)addr; } diff --git a/libfreerdp/primitives/test/TestPrimitivesColors.c b/libfreerdp/primitives/test/TestPrimitivesColors.c index c297b4fe1..c44dafde5 100644 --- a/libfreerdp/primitives/test/TestPrimitivesColors.c +++ b/libfreerdp/primitives/test/TestPrimitivesColors.c @@ -35,11 +35,11 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) PROFILER_DEFINE(optProf) PROFILER_CREATE(genericProf, "RGBToRGB_16s8u_P3AC4R-GENERIC") PROFILER_CREATE(optProf, "RGBToRGB_16s8u_P3AC4R-OPTIMIZED") - r = winpr_aligned_calloc(1, rgbStride * roi.height, 16); - g = winpr_aligned_calloc(1, rgbStride * roi.height, 16); - b = winpr_aligned_calloc(1, rgbStride * roi.height, 16); - out1 = winpr_aligned_calloc(1, dstStride * roi.height, 16); - out2 = winpr_aligned_calloc(1, dstStride * roi.height, 16); + r = winpr_aligned_calloc(1, 1ULL * rgbStride * roi.height, 16); + g = winpr_aligned_calloc(1, 1ULL * rgbStride * roi.height, 16); + b = winpr_aligned_calloc(1, 1ULL * rgbStride * roi.height, 16); + out1 = winpr_aligned_calloc(1, 1ULL * dstStride * roi.height, 16); + out2 = winpr_aligned_calloc(1, 1ULL * dstStride * roi.height, 16); if (!r || !g || !b || !out1 || !out2) goto fail; @@ -57,9 +57,9 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) } } #else - winpr_RAND(r, rgbStride * roi.height); - winpr_RAND(g, rgbStride * roi.height); - winpr_RAND(b, rgbStride * roi.height); + winpr_RAND(r, 1ULL * rgbStride * roi.height); + winpr_RAND(g, 1ULL * rgbStride * roi.height); + winpr_RAND(b, 1ULL * rgbStride * roi.height); #endif ptrs[0] = r; ptrs[1] = g; @@ -79,7 +79,7 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) PROFILER_EXIT(optProf) - if (memcmp(out1, out2, dstStride * roi.height) != 0) + if (memcmp(out1, out2, 1ULL * dstStride * roi.height) != 0) { for (UINT64 i = 0; i < 1ull * roi.width * roi.height; ++i) { diff --git a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c index 10a87546d..f6b9821e6 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c @@ -67,7 +67,7 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height) if (status != PRIMITIVES_SUCCESS) goto loop_fail; - if (memcmp(out_c, out_sse, dstStride * height) != 0) + if (memcmp(out_c, out_sse, 1ULL * dstStride * height) != 0) { for (size_t i = 0; i < 1ull * width * height; ++i) { diff --git a/libfreerdp/primitives/test/TestPrimitivesYUV.c b/libfreerdp/primitives/test/TestPrimitivesYUV.c index e3e79d3e4..c07d9d70f 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYUV.c +++ b/libfreerdp/primitives/test/TestPrimitivesYUV.c @@ -187,8 +187,8 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) const BYTE** cpv; BYTE** pv; } cnv; - UINT32 awidth = 0; - UINT32 aheight = 0; + size_t awidth = 0; + size_t aheight = 0; BOOL rc = FALSE; BYTE* luma[3] = { 0 }; BYTE* chroma[3] = { 0 }; @@ -283,10 +283,10 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) PROFILER_EXIT(yuvCombine) - for (UINT32 x = 0; x < 3; x++) + for (size_t x = 0; x < 3; x++) { size_t halfStride = ((x > 0) ? awidth / 2 : awidth); - size_t size = aheight * awidth; + size_t size = 1ULL * aheight * awidth; size_t halfSize = ((x > 0) ? halfStride * aheight / 2 : awidth * aheight); if (!check_padding(luma[x], halfSize, padding, "luma")) @@ -327,9 +327,9 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) goto fail; } - for (UINT32 i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) { - for (UINT32 y = 0; y < roi.height; y++) + for (size_t y = 0; y < roi.height; y++) { UINT32 w = roi.width; UINT32 lstride = lumaStride[i]; @@ -403,7 +403,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) size_t size = 0; size_t uvsize = 0; size_t uvwidth = 0; - size_t padding = 100 * 16; + size_t padding = 100ULL * 16ULL; UINT32 stride = 0; const UINT32 formats[] = { PIXEL_FORMAT_XRGB32, PIXEL_FORMAT_XBGR32, PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_ABGR32, PIXEL_FORMAT_RGBA32, PIXEL_FORMAT_RGBX32, @@ -415,8 +415,8 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) /* Buffers need to be 16x16 aligned. */ awidth = roi.width + 16 - roi.width % 16; aheight = roi.height + 16 - roi.height % 16; - stride = awidth * sizeof(UINT32); - size = awidth * aheight; + stride = 1ULL * awidth * sizeof(UINT32); + size = 1ULL * awidth * aheight; if (use444) { @@ -454,7 +454,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) if (!(yuv[2] = set_padding(uvsize, padding))) goto fail; - for (UINT32 y = 0; y < roi.height; y++) + for (size_t y = 0; y < roi.height; y++) { BYTE* line = &rgb[y * stride]; @@ -568,7 +568,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) (!check_padding(yuv[2], uvsize, padding, "V"))) goto fail; - for (UINT32 y = 0; y < roi.height; y++) + for (size_t y = 0; y < roi.height; y++) { BYTE* srgb = &rgb[y * stride]; BYTE* drgb = &rgb_dst[y * stride]; @@ -595,9 +595,9 @@ fail: static BOOL allocate_yuv420(BYTE** planes, UINT32 width, UINT32 height, UINT32 padding) { - const size_t size = width * height; - const size_t uvwidth = (width + 1) / 2; - const size_t uvsize = (height + 1) / 2 * uvwidth; + const size_t size = 1ULL * width * height; + const size_t uvwidth = (1ULL + width) / 2; + const size_t uvsize = (1ULL + height) / 2 * uvwidth; if (!(planes[0] = set_padding(size, padding))) goto fail; @@ -630,7 +630,7 @@ static void free_yuv420(BYTE** planes, UINT32 padding) } static BOOL check_yuv420(BYTE** planes, UINT32 width, UINT32 height, UINT32 padding) { - const size_t size = width * height; + const size_t size = 1ULL * width * height; const size_t uvwidth = (width + 1) / 2; const size_t uvsize = (height + 1) / 2 * uvwidth; const BOOL yOk = check_padding(planes[0], size, padding, "Y"); @@ -662,9 +662,9 @@ static BOOL compare_yuv420(BYTE** planesA, BYTE** planesB, UINT32 width, UINT32 UINT32 padding) { BOOL rc = TRUE; - const size_t size = width * height; - const size_t uvwidth = (width + 1) / 2; - const size_t uvsize = (height + 1) / 2 * uvwidth; + const size_t size = 1ULL * width * height; + const size_t uvwidth = (1ULL * width + 1) / 2; + const size_t uvsize = (1ULL * height + 1) / 2 * uvwidth; if (check_for_mismatches(planesA[0], planesB[0], size)) { @@ -720,9 +720,9 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U if (aheight % 16 != 0) aheight += 16 - roi.height % 16; - stride = awidth * sizeof(UINT32); - size = awidth * aheight; - uvwidth = (awidth + 1) / 2; + stride = 1ULL * awidth * sizeof(UINT32); + size = 1ULL * awidth * aheight; + uvwidth = 1ULL * (awidth + 1) / 2; if (!prims || !generic) return FALSE; @@ -765,7 +765,7 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U if (!allocate_yuv420(chromaGeneric, awidth, aheight, padding)) goto fail; - for (UINT32 y = 0; y < roi.height; y++) + for (size_t y = 0; y < roi.height; y++) { BYTE* line = &rgb[y * stride]; diff --git a/libfreerdp/utils/test/TestRingBuffer.c b/libfreerdp/utils/test/TestRingBuffer.c index e19b3b3b8..e88e86e54 100644 --- a/libfreerdp/utils/test/TestRingBuffer.c +++ b/libfreerdp/utils/test/TestRingBuffer.c @@ -207,7 +207,7 @@ int TestRingBuffer(int argc, char* argv[]) return -1; } } - ringbuffer_commit_read_bytes(&ringBuffer, 50 * 1000); + ringbuffer_commit_read_bytes(&ringBuffer, 50ULL * 1000ULL); (void)fprintf(stderr, "ok\n"); ringbuffer_destroy(&ringBuffer); diff --git a/rdtk/librdtk/rdtk_nine_patch.c b/rdtk/librdtk/rdtk_nine_patch.c index 7cf5975cb..8afb6f4dc 100644 --- a/rdtk/librdtk/rdtk_nine_patch.c +++ b/rdtk/librdtk/rdtk_nine_patch.c @@ -269,7 +269,8 @@ static BOOL rdtk_nine_patch_get_scale_ht(rdtkNinePatch* ninePatch, wImage* image for (uint32_t y = 1; y < image->height - 1; y++) { - const uint32_t* pixel = (const uint32_t*)&image->data[image->scanline * y]; /* (1, 0) */ + const uint32_t* pixel = + (const uint32_t*)&image->data[1ULL * image->scanline * y]; /* (1, 0) */ if (beg < 0) { if (*pixel) @@ -312,8 +313,9 @@ static BOOL rdtk_nine_patch_get_fill_lr(rdtkNinePatch* ninePatch, wImage* image) for (uint32_t x = 1; x < image->width - 1; x++) { - const uint32_t* pixel = (uint32_t*)&image->data[((image->height - 1) * image->scanline) + - x * sizeof(uint32_t)]; /* (1, height - 1) */ + const uint32_t* pixel = + (uint32_t*)&image->data[((1ULL * image->height - 1ULL) * image->scanline) + + x * sizeof(uint32_t)]; /* (1, height - 1) */ if (beg < 0) { if (*pixel) diff --git a/rdtk/librdtk/rdtk_surface.c b/rdtk/librdtk/rdtk_surface.c index d8df46945..c6eaef151 100644 --- a/rdtk/librdtk/rdtk_surface.c +++ b/rdtk/librdtk/rdtk_surface.c @@ -30,7 +30,7 @@ int rdtk_surface_fill(rdtkSurface* surface, uint16_t x, uint16_t y, uint16_t wid for (uint32_t i = y; i < y * 1ul + height; i++) { - uint8_t* line = &surface->data[i * surface->scanline]; + uint8_t* line = &surface->data[1ULL * i * surface->scanline]; for (uint32_t j = x; j < x * 1ul + width; j++) { uint32_t* pixel = (uint32_t*)&line[j + 4ul]; diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index c95b50f1f..defae1451 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -362,10 +362,10 @@ static BOOL test_peer_load_icon(freerdp_peer* client) goto out_fail; /* background with same size, which will be used to erase the icon from old position */ - if (!(context->bg_data = calloc(context->image->height, context->image->width * 3))) + if (!(context->bg_data = calloc(context->image->height, 3ULL * context->image->width))) goto out_fail; - memset(context->bg_data, 0xA0, context->image->height * context->image->width * 3ull); + memset(context->bg_data, 0xA0, 3ULL * context->image->height * context->image->width); return TRUE; out_fail: context->bg_data = NULL; diff --git a/server/proxy/pf_channel.c b/server/proxy/pf_channel.c index 1d771beeb..baec62ffe 100644 --- a/server/proxy/pf_channel.c +++ b/server/proxy/pf_channel.c @@ -48,14 +48,14 @@ static BOOL channelTracker_resetCurrentPacket(ChannelStateTracker* tracker) if (tracker->currentPacket) { const size_t cap = Stream_Capacity(tracker->currentPacket); - if (cap < 1 * 1000 * 1000) + if (cap < 1ULL * 1000ULL * 1000ULL) create = FALSE; else Stream_Free(tracker->currentPacket, TRUE); } if (create) - tracker->currentPacket = Stream_New(NULL, 10 * 1024); + tracker->currentPacket = Stream_New(NULL, 10ULL * 1024ULL); if (!tracker->currentPacket) return FALSE; Stream_SetPosition(tracker->currentPacket, 0); diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index bddbaa7a3..aa95ab092 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -1351,7 +1351,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) subsystem->cursorMaxWidth = 256; subsystem->cursorMaxHeight = 256; subsystem->cursorPixels = - winpr_aligned_malloc(subsystem->cursorMaxWidth * subsystem->cursorMaxHeight * 4ull, 16); + winpr_aligned_malloc(4ULL * subsystem->cursorMaxWidth * subsystem->cursorMaxHeight, 16); if (!subsystem->cursorPixels) return -1; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 5577ad4e1..96fdcad81 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -1079,7 +1079,7 @@ static INLINE UINT32 rdpgfx_estimate_h264_avc420(RDPGFX_AVC420_BITMAP_STREAM* ha /* H264 metadata + H264 stream. See rdpgfx_write_h264_avc420 */ WINPR_ASSERT(havc420); return sizeof(UINT32) /* numRegionRects */ - + 10 /* regionRects + quantQualityVals */ + + 10ULL /* regionRects + quantQualityVals */ * havc420->meta.numRegionRects + havc420->length; } diff --git a/server/shadow/shadow_encoder.c b/server/shadow/shadow_encoder.c index 05c91b03d..b569b6264 100644 --- a/server/shadow/shadow_encoder.c +++ b/server/shadow/shadow_encoder.c @@ -101,7 +101,7 @@ static int shadow_encoder_init_grid(rdpShadowEncoder* encoder) { for (UINT32 j = 0; j < encoder->gridWidth; j++) { - UINT32 k = (i * encoder->gridWidth) + j; + const size_t k = (1ULL * i * encoder->gridWidth) + j; encoder->grid[k] = &(encoder->gridBuffer[k * tileSize]); } } @@ -292,7 +292,7 @@ static int shadow_encoder_init(rdpShadowEncoder* encoder) shadow_encoder_init_grid(encoder); if (!encoder->bs) - encoder->bs = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4ULL); + encoder->bs = Stream_New(NULL, 4ULL * encoder->maxTileWidth * encoder->maxTileHeight); if (!encoder->bs) return -1; diff --git a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c index 5103aec48..ea96c8442 100644 --- a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c +++ b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c @@ -533,7 +533,7 @@ static BOOL convertKeyType(CK_KEY_TYPE k, LPWSTR dest, DWORD len, DWORD* outlen) if (dest) { - memcpy(dest, r, retLen * 2); + memcpy(dest, r, sizeof(WCHAR) * retLen); dest[retLen] = 0; } } @@ -798,7 +798,7 @@ static SECURITY_STATUS NCryptP11EnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR p (1 + (sizeof(key->slotId) * 2) /*slotId*/ + 1 + (key->idLen * 2) + 1) * 2; convertKeyType(key->keyType, NULL, 0, &algoSz); - KEYNAME_SZ += (algoSz + 1) * 2; + KEYNAME_SZ += (1ULL + algoSz) * 2ULL; keyName = calloc(1, sizeof(*keyName) + KEYNAME_SZ); if (!keyName) diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index fd48ca9d4..02887ecfd 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -1140,7 +1140,7 @@ static LONG WINAPI PCSC_SCardListCardsW(SCARDCONTEXT hContext, LPCBYTE pbAtr, *pcchCards = outputLen; if (autoAllocate) { - output = malloc(outputLen * 2); + output = calloc(outputLen, sizeof(WCHAR)); if (!output) return SCARD_E_NO_MEMORY; diff --git a/winpr/libwinpr/synch/timer.c b/winpr/libwinpr/synch/timer.c index 354382c95..7f3f81704 100644 --- a/winpr/libwinpr/synch/timer.c +++ b/winpr/libwinpr/synch/timer.c @@ -516,8 +516,8 @@ BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPerio if (lPeriod > 0) { - timer->timeout.it_interval.tv_sec = (lPeriod / 1000); /* seconds */ - timer->timeout.it_interval.tv_nsec = ((lPeriod % 1000) * 1000000); /* nanoseconds */ + timer->timeout.it_interval.tv_sec = (lPeriod / 1000ULL); /* seconds */ + timer->timeout.it_interval.tv_nsec = (1000000ULL * (lPeriod % 1000ULL)); /* nanoseconds */ } if (lpDueTime->QuadPart != 0) diff --git a/winpr/libwinpr/utils/image.c b/winpr/libwinpr/utils/image.c index c4d6a957c..b5d7b9f32 100644 --- a/winpr/libwinpr/utils/image.c +++ b/winpr/libwinpr/utils/image.c @@ -273,7 +273,7 @@ static void* winpr_bitmap_write_buffer(const BYTE* data, size_t size, UINT32 wid goto fail; Stream_Write(s, bmp_header, WINPR_IMAGE_BMP_HEADER_LEN); - if (!Stream_EnsureRemainingCapacity(s, stride * height * 1ull)) + if (!Stream_EnsureRemainingCapacity(s, 1ULL * stride * height)) goto fail; for (size_t y = 0; y < height; y++) @@ -677,7 +677,7 @@ SSIZE_T winpr_convert_from_jpeg(const BYTE* comp_data, size_t comp_data_bytes, U if (!jpeg_start_decompress(&cinfo)) goto fail; - size_t stride = cinfo.image_width * cinfo.num_components; + size_t stride = 1ULL * cinfo.image_width * cinfo.num_components; decomp_data = calloc(stride, cinfo.image_height); if (decomp_data) @@ -947,9 +947,9 @@ static void* winpr_read_png_from_buffer(const void* data, size_t SrcSize, size_t row_pointers = png_get_rows(png_ptr, info_ptr); if (row_pointers) { - const size_t stride = width * bpp / 8ull; + const size_t stride = 1ULL * width * bpp / 8ull; const size_t png_stride = png_get_rowbytes(png_ptr, info_ptr); - const size_t size = width * height * bpp / 8ull; + const size_t size = 1ULL * width * height * bpp / 8ull; const size_t copybytes = stride > png_stride ? png_stride : stride; rc = malloc(size); diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c index 750398379..7005a97fd 100644 --- a/winpr/libwinpr/utils/print.c +++ b/winpr/libwinpr/utils/print.c @@ -53,8 +53,8 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length) * ASIC line 'ab..cd' * zero terminator '\0' */ - const size_t blen = - (maxlen + 3) + (WINPR_HEXDUMP_LINE_LENGTH * 3) + 3 + WINPR_HEXDUMP_LINE_LENGTH + 1; + const size_t blen = (maxlen + 3ULL) + (WINPR_HEXDUMP_LINE_LENGTH * 3ULL) + 3ULL + + WINPR_HEXDUMP_LINE_LENGTH + 1ULL; size_t pos = 0; char* buffer = NULL; From 6a5d6d0514ecbd512b24fd3a44e82d41e74dc2c5 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 29 Aug 2024 10:38:26 +0200 Subject: [PATCH 2/3] [ci,clang-tidy] disable uninitialize va_list warning --- .clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-tidy b/.clang-tidy index 9d0657b0a..d5dfd97ce 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -26,6 +26,7 @@ Checks: > -cert-dcl16-c, -cert-env33-c, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + -clang-analyzer-valist.Uninitialized, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-owning-memory, -cppcoreguidelines-avoid-do-while, From af813a0929f88800bb368646236390a154fd199b Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 29 Aug 2024 10:41:07 +0200 Subject: [PATCH 3/3] [cmake,clang-tidy] do not use explicit .clang-tidy if not explicitly added the nearest .clang-tidy file to the compiled source is used. --- channels/tsmf/client/tsmf_media.c | 2 +- cmake/ClangTidy.cmake | 2 +- libfreerdp/cache/persistent.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 0fbe2c475..40e69520e 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -52,7 +52,7 @@ #define AUDIO_TOLERANCE 10000000LL /* 1 second = 10,000,000 100ns units*/ -#define VIDEO_ADJUST_MAX 10ULL * 1000ULL * 1000ULL +#define VIDEO_ADJUST_MAX (10ULL * 1000ULL * 1000ULL) #define MAX_ACK_TIME 666667 diff --git a/cmake/ClangTidy.cmake b/cmake/ClangTidy.cmake index b596f78fc..4298a043c 100644 --- a/cmake/ClangTidy.cmake +++ b/cmake/ClangTidy.cmake @@ -4,7 +4,7 @@ if (BUILD_WITH_CLANG_TIDY) include(ClangDetectTool) clang_detect_tool(CLANG_TIDY_EXE clang-tidy REQUIRED) - set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" --config-file=${CMAKE_SOURCE_DIR}/.clang-tidy) + set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}") set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_COMMAND}" --extra-arg=-std=gnu11) set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}" --extra-arg=-std=gnu++17) diff --git a/libfreerdp/cache/persistent.c b/libfreerdp/cache/persistent.c index 47c47867d..36133fc98 100644 --- a/libfreerdp/cache/persistent.c +++ b/libfreerdp/cache/persistent.c @@ -207,7 +207,7 @@ static int persistent_cache_read_v3(rdpPersistentCache* persistent) if (fread((void*)&entry, sizeof(entry), 1, persistent->fp) != 1) break; - if (fseek(persistent->fp, (4ULL * entry.width * entry.height), SEEK_CUR) != 0) + if (_fseeki64(persistent->fp, (4LL * entry.width * entry.height), SEEK_CUR) != 0) break; persistent->count++;