From 2d15382e3115b011fa21987bb707369573c7c76f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 21 Dec 2023 18:12:19 -0600 Subject: [PATCH] Fix libplacebo renderer build on Windows --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 6 +++--- app/streaming/video/ffmpeg-renderers/plvk.h | 4 ++++ app/streaming/video/ffmpeg-renderers/plvk_c.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index 2eb8eb6f..9d671577 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -31,7 +31,7 @@ static const char *k_OptionalDeviceExtensions[] = { VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, -#ifdef _WIN32 +#ifdef Q_OS_WIN32 VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, #endif @@ -350,7 +350,7 @@ bool PlVkRenderer::initialize(PDECODER_PARAMETERS params) } vkInstParams.get_proc_addr = (PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr(); vkInstParams.extensions = instanceExtensions.data(); - vkInstParams.num_extensions = instanceExtensions.size(); + vkInstParams.num_extensions = (int)instanceExtensions.size(); m_PlVkInstance = pl_vk_inst_create(m_Log, &vkInstParams); if (m_PlVkInstance == nullptr) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, @@ -735,7 +735,7 @@ void PlVkRenderer::renderFrame(AVFrame *frame) targetFrame.crop.y1 = dst.y + dst.h; // Render the video image and overlays into the swapchain buffer - targetFrame.num_overlays = overlays.size(); + targetFrame.num_overlays = (int)overlays.size(); targetFrame.overlays = overlays.data(); if (!pl_render_image(m_Renderer, &mappedFrame, &targetFrame, &pl_render_fast_params)) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, diff --git a/app/streaming/video/ffmpeg-renderers/plvk.h b/app/streaming/video/ffmpeg-renderers/plvk.h index 6683da86..366c74c0 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.h +++ b/app/streaming/video/ffmpeg-renderers/plvk.h @@ -2,6 +2,10 @@ #include "renderer.h" +#ifdef Q_OS_WIN32 +#define VK_USE_PLATFORM_WIN32_KHR +#endif + #include #include #include diff --git a/app/streaming/video/ffmpeg-renderers/plvk_c.c b/app/streaming/video/ffmpeg-renderers/plvk_c.c index da2ad81d..d189f28f 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk_c.c +++ b/app/streaming/video/ffmpeg-renderers/plvk_c.c @@ -1,9 +1,20 @@ // This compilation unit contains the implementations of libplacebo header-only libraries. // These must be compiled as C code, so they cannot be placed inside plvk.cpp. +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4068) // unknown pragma +#pragma warning(disable: 4244) // double -> float truncation warning +#pragma warning(disable: 4267) // size_t -> int truncation warning +#endif + #define PL_LIBAV_IMPLEMENTATION 1 #include +#ifdef _MSC_VER +#pragma warning(pop) +#endif + // Provide a dummy implementation of av_stream_get_side_data() to avoid having to link with libavformat uint8_t *av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, size_t *size) {