From cec2f43b32feffeb58d798e11a69d8fb213a6fa9 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 1 Feb 2022 11:52:09 +0100 Subject: [PATCH] fixed some (mostly Windows) warnings --- src/audio/playback/dump.cpp | 1 + src/audio/types.cpp | 3 ++ src/config_win32.h | 1 + src/hd-rum-translator/hd-rum-translator.cpp | 6 ++-- src/rtp/audio_decoders.cpp | 2 +- src/rtp/rs.h | 4 +-- src/rtp/rtp.c | 2 +- src/rtp/rtpdec_h264.c | 1 + src/rtp/video_decoders.cpp | 4 +-- src/utils/jpeg_reader.c | 8 +++++ src/utils/nat.c | 4 +-- src/video_capture/DirectShowGrabber.cpp | 36 ++++++++++----------- src/video_capture/testcard2.c | 8 ++--- src/video_codec.c | 6 ++-- 14 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/audio/playback/dump.cpp b/src/audio/playback/dump.cpp index a400c4aac..873742d86 100644 --- a/src/audio/playback/dump.cpp +++ b/src/audio/playback/dump.cpp @@ -38,6 +38,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #include "config_unix.h" +#include "config_win32.h" #endif #include diff --git a/src/audio/types.cpp b/src/audio/types.cpp index 3e695754c..f77fc7b12 100644 --- a/src/audio/types.cpp +++ b/src/audio/types.cpp @@ -403,6 +403,9 @@ bool audio_frame2::resample([[maybe_unused]] audio_frame2_resampler & resampler_ channels = move(new_channels); return true; #else + UNUSED(resampler_state.resample_from); + UNUSED(resampler_state.resample_to); + UNUSED(resampler_state.resample_ch_count); LOG(LOG_LEVEL_ERROR) << "Audio frame resampler: cannot resample, SpeexDSP was not compiled in!\n"; return false; #endif diff --git a/src/config_win32.h b/src/config_win32.h index d681df50e..2e6151aec 100644 --- a/src/config_win32.h +++ b/src/config_win32.h @@ -277,6 +277,7 @@ void ShowMessage(int level, char *msg); #define CLOSESOCKET closesocket +#undef ATTRIBUTE #ifdef _MSC_VER #define ATTRIBUTE(a) #else diff --git a/src/hd-rum-translator/hd-rum-translator.cpp b/src/hd-rum-translator/hd-rum-translator.cpp index 2276c5103..f023f4149 100644 --- a/src/hd-rum-translator/hd-rum-translator.cpp +++ b/src/hd-rum-translator/hd-rum-translator.cpp @@ -290,7 +290,7 @@ static struct response *change_replica_type(struct hd_rum_translator_state *s, static VOID CALLBACK wsa_deleter(DWORD /* dwErrorCode */, DWORD /* dwNumberOfBytesTransfered */, LPOVERLAPPED lpOverlapped, long unsigned int) { - struct wsa_aux_storage *aux = (struct wsa_aux_storage *) ((char *) lpOverlapped->hEvent + OFFSET); + struct wsa_aux_storage *aux = (struct wsa_aux_storage *)(void *) ((char *) lpOverlapped->hEvent + OFFSET); if (--aux->ref == 0) { free(aux->overlapped); free(lpOverlapped->hEvent); @@ -446,7 +446,7 @@ static void *writer(void *arg) ref++; } } - struct wsa_aux_storage *aux = (struct wsa_aux_storage *) ((char *) s->qhead->buf + OFFSET); + struct wsa_aux_storage *aux = (struct wsa_aux_storage *)(void *) ((char *) s->qhead->buf + OFFSET); memset(aux, 0, sizeof *aux); aux->overlapped = (WSAOVERLAPPED *) calloc(ref, sizeof(WSAOVERLAPPED)); aux->ref = ref; @@ -852,7 +852,6 @@ int main(int argc, char **argv) } uint64_t received_data = 0; - uint64_t received_pkts = 0; struct timeval t0; gettimeofday(&t0, NULL); @@ -865,7 +864,6 @@ int main(int argc, char **argv) && (state.qtail->size = udp_recv_timeout(sock_in, state.qtail->buf, SIZE, &timeout)) > 0 && !should_exit) { received_data += state.qtail->size; - received_pkts += 1; state.qtail = state.qtail->next; diff --git a/src/rtp/audio_decoders.cpp b/src/rtp/audio_decoders.cpp index 61268a6b8..f4cfd27a4 100644 --- a/src/rtp/audio_decoders.cpp +++ b/src/rtp/audio_decoders.cpp @@ -630,7 +630,7 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st char plaintext[cdata->data->data_len]; // plaintext will be actually shorter size_t main_hdr_len = PT_AUDIO_HAS_FEC(pt) ? sizeof(fec_payload_hdr_t) : sizeof(audio_payload_hdr_t); if (PT_AUDIO_IS_ENCRYPTED(pt)) { - uint32_t encryption_hdr = ntohl(*(uint32_t *) (cdata->data->data + main_hdr_len)); + uint32_t encryption_hdr = ntohl(*(uint32_t *)(void *) (cdata->data->data + main_hdr_len)); crypto_mode = (enum openssl_mode) (encryption_hdr >> 24); if (crypto_mode == MODE_AES128_NONE || crypto_mode > MODE_AES128_MAX) { log_msg(LOG_LEVEL_WARNING, "Unknown cipher mode: %d\n", (int) crypto_mode); diff --git a/src/rtp/rs.h b/src/rtp/rs.h index e05691f15..ac9c36922 100644 --- a/src/rtp/rs.h +++ b/src/rtp/rs.h @@ -50,10 +50,10 @@ struct rs : public fec { rs(unsigned int k, unsigned int n); rs(const char *cfg); virtual ~rs(); - std::shared_ptr encode(std::shared_ptr frame); + std::shared_ptr encode(std::shared_ptr frame) override; virtual audio_frame2 encode(audio_frame2 const &) override; bool decode(char *in, int in_len, char **out, int *len, - const std::map &); + const std::map &) override; private: int get_ss(int hdr_len, int len); diff --git a/src/rtp/rtp.c b/src/rtp/rtp.c index c0bcae633..6aed1f6d5 100644 --- a/src/rtp/rtp.c +++ b/src/rtp/rtp.c @@ -2865,7 +2865,7 @@ rtp_send_data_hdr(struct rtp *session, #else d = buffer = (uint8_t *) malloc(20 + RTP_PACKET_HEADER_SIZE); #endif - packet = (rtp_packet *) buffer; + packet = (rtp_packet *)(void *) buffer; #ifdef WIN32 send_vector[0].buf = (char *) (buffer + RTP_PACKET_HEADER_SIZE); diff --git a/src/rtp/rtpdec_h264.c b/src/rtp/rtpdec_h264.c index 23b45b337..be3cb0405 100644 --- a/src/rtp/rtpdec_h264.c +++ b/src/rtp/rtpdec_h264.c @@ -43,6 +43,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #include "config_unix.h" +#include "config_win32.h" #endif // HAVE_CONFIG_H #include "debug.h" #include "perf.h" diff --git a/src/rtp/video_decoders.cpp b/src/rtp/video_decoders.cpp index 0f077f793..d1ebc2606 100644 --- a/src/rtp/video_decoders.cpp +++ b/src/rtp/video_decoders.cpp @@ -214,7 +214,7 @@ struct reported_statistics_cumul { ~reported_statistics_cumul() { print(); } - long int last_buffer_number = -1; ///< last received buffer ID + long long int last_buffer_number = -1; ///< last received buffer ID chrono::steady_clock::time_point t_last = chrono::steady_clock::now(); unsigned long int displayed = 0, dropped = 0, corrupted = 0, missing = 0; atomic_ulong fec_ok = 0, fec_corrected = 0, fec_nok = 0; @@ -242,7 +242,7 @@ struct reported_statistics_cumul { } void update(int buffer_number) { if (last_buffer_number != -1) { - long int diff = buffer_number - + long long int diff = buffer_number - ((last_buffer_number + 1) & ((1U<comp_count ) { param->interleaved = false; } + if (length < 1 + comp_count * 2 + 3) { + log_msg(LOG_LEVEL_ERROR, "[JPEG] [Error] Wrong SOS length: %d\n", length); + return -1; + } // Collect the component-spec parameters for ( int comp = 0; comp < comp_count; comp++ ) diff --git a/src/utils/nat.c b/src/utils/nat.c index 5516b3553..86b40c474 100644 --- a/src/utils/nat.c +++ b/src/utils/nat.c @@ -337,7 +337,7 @@ static bool nat_pmp_add_mapping(natpmp_t *natpmp, int privateport, int publicpor fd_set fds; struct timeval timeout = { 0 }; FD_ZERO(&fds); - FD_SET(natpmp->s, &fds); + FD_SET((fd_t) natpmp->s, &fds); r = getnatpmprequesttimeout(natpmp, &timeout); if (r != 0) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "NAT PMP - getnatpmprequesttimeout returned %d (%s)\n", @@ -398,7 +398,7 @@ static bool setup_nat_pmp(struct ug_nat_traverse *state, int video_rx_port, int fd_set fds; struct timeval timeout; FD_ZERO(&fds); - FD_SET(natpmp.s, &fds); + FD_SET((fd_t) natpmp.s, &fds); getnatpmprequesttimeout(&natpmp, &timeout); r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout); if(r<0) { diff --git a/src/video_capture/DirectShowGrabber.cpp b/src/video_capture/DirectShowGrabber.cpp index e57410e8a..7192a5bd9 100644 --- a/src/video_capture/DirectShowGrabber.cpp +++ b/src/video_capture/DirectShowGrabber.cpp @@ -1409,24 +1409,24 @@ static const struct { const CHAR *pName; const WCHAR *wszName; codec_t ug_codec; -} BitCountMap[] = { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24", BGR, - &MEDIASUBTYPE_RGB32, 32, "RGB 32", L"RGB 32", RGBA, - &MEDIASUBTYPE_ARGB32, 32, "ARGB 32", L"ARGB 32", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay", VIDEO_CODEC_NONE, - &GUID_I420 , 12, "I420", L"I420", VIDEO_CODEC_NONE, - &MEDIASUBTYPE_YUY2, 12, "YUY2", L"YUY2", YUYV, - &GUID_R210, 12, "r210", L"r210", VIDEO_CODEC_NONE, - &GUID_v210, 12, "v210", L"v210", v210, - &GUID_V210, 12, "V210", L"V210", v210, - &MEDIASUBTYPE_UYVY, 12, "UYVY", L"UYVY", UYVY, - &GUID_HDYC, 12, "HDYC", L"HDYC", UYVY, - &MEDIASUBTYPE_MJPG, 0, "MJPG", L"MJPG", MJPG, - &GUID_NULL, 0, "UNKNOWN", L"UNKNOWN", VIDEO_CODEC_NONE +} BitCountMap[] = { { &MEDIASUBTYPE_RGB1, 1, "RGB Monochrome", L"RGB Monochrome", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_RGB4, 4, "RGB VGA", L"RGB VGA", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_RGB8, 8, "RGB 8", L"RGB 8", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_RGB565, 16, "RGB 565 (16 bit)", L"RGB 565 (16 bit)", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_RGB555, 16, "RGB 555 (16 bit)", L"RGB 555 (16 bit)", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_RGB24, 24, "RGB 24", L"RGB 24", BGR }, + { &MEDIASUBTYPE_RGB32, 32, "RGB 32", L"RGB 32", RGBA }, + { &MEDIASUBTYPE_ARGB32, 32, "ARGB 32", L"ARGB 32", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_Overlay, 0, "Overlay", L"Overlay", VIDEO_CODEC_NONE }, + { &GUID_I420 , 12, "I420", L"I420", VIDEO_CODEC_NONE }, + { &MEDIASUBTYPE_YUY2, 12, "YUY2", L"YUY2", YUYV }, + { &GUID_R210, 12, "r210", L"r210", VIDEO_CODEC_NONE }, + { &GUID_v210, 12, "v210", L"v210", v210 }, + { &GUID_V210, 12, "V210", L"V210", v210 }, + { &MEDIASUBTYPE_UYVY, 12, "UYVY", L"UYVY", UYVY }, + { &GUID_HDYC, 12, "HDYC", L"HDYC", UYVY }, + { &MEDIASUBTYPE_MJPG, 0, "MJPG", L"MJPG", MJPG }, + { &GUID_NULL, 0, "UNKNOWN", L"UNKNOWN", VIDEO_CODEC_NONE }, }; static codec_t get_ug_codec(const GUID *pSubtype) diff --git a/src/video_capture/testcard2.c b/src/video_capture/testcard2.c index 323ce5ba6..1f78bc0b4 100644 --- a/src/video_capture/testcard2.c +++ b/src/video_capture/testcard2.c @@ -321,7 +321,7 @@ void * vidcap_testcard2_thread(void *arg) #ifdef HAVE_LIBSDL_TTF TTF_Font * font = NULL; - unsigned char *banner = malloc(vc_get_datalen(s->desc.width, BANNER_HEIGHT, RGBA)); + uint32_t *banner = malloc(vc_get_datalen(s->desc.width, BANNER_HEIGHT, RGBA)); if(TTF_Init() == -1) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to initialize SDL_ttf: %s\n", @@ -412,15 +412,15 @@ void * vidcap_testcard2_thread(void *arg) long xoff = ((long) s->desc.width - text->w) / 2; long yoff = (BANNER_HEIGHT - text->h) / 2; for (int i = 0 ; i < text->h; i++) { - uint32_t *d = (uint32_t*)banner + xoff + (i + yoff) * s->desc.width; - for (int j = 0 ; j < MIN(text->w, s->desc.width - xoff); j++) { + uint32_t *d = banner + xoff + (i + yoff) * s->desc.width; + for (int j = 0 ; j < MIN(text->w, (int) s->desc.width - xoff); j++) { if (((char *)text->pixels) [i * text->pitch + j]) { *d = 0x00000000U; } d++; } } - testcard_convert_buffer(RGBA, s->desc.color_spec, tmp + (s->desc.height - BANNER_MARGIN_BOTTOM - BANNER_HEIGHT) * vc_get_linesize(s->desc.width, s->desc.color_spec), banner, s->desc.width, BANNER_HEIGHT); + testcard_convert_buffer(RGBA, s->desc.color_spec, tmp + (s->desc.height - BANNER_MARGIN_BOTTOM - BANNER_HEIGHT) * vc_get_linesize(s->desc.width, s->desc.color_spec), (unsigned char *) banner, s->desc.width, BANNER_HEIGHT); SDL_FreeSurface(text); #endif diff --git a/src/video_codec.c b/src/video_codec.c index d0f9da8c9..6e7e19ee9 100644 --- a/src/video_codec.c +++ b/src/video_codec.c @@ -2008,8 +2008,10 @@ static void vc_copylineRG48toR10k(unsigned char * __restrict dst, const unsigned UNUSED(rshift); UNUSED(gshift); UNUSED(bshift); - const uint16_t *in = (const uint16_t *) src; - uint32_t *out = (uint32_t *) dst; + assert((uintptr_t) src % sizeof(uint16_t) == 0); + assert((uintptr_t) dst % sizeof(uint32_t) == 0); + const uint16_t *in = (const uint16_t *)(const void *) src; + uint32_t *out = (uint32_t *)(void *) dst; OPTIMIZED_FOR (int x = 0; x <= dst_len - 4; x += 4) { #ifdef WORDS_BIGENDIAN *out++ = r << 22U | g << 12U | b << 2U | 0x3FU; /// @todo just a stub