From 46d58e55a35aa501a7e6135a6dc7abbea9498a5c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 2 Jan 2026 01:46:20 -0600 Subject: [PATCH] Add macro for printing FourCC values --- app/streaming/video/ffmpeg-renderers/drm.cpp | 8 ++++---- app/streaming/video/ffmpeg-renderers/renderer.h | 12 ++++++++++++ app/streaming/video/ffmpeg-renderers/vaapi.cpp | 15 ++++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/drm.cpp b/app/streaming/video/ffmpeg-renderers/drm.cpp index cc4d118d..af0882ea 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.cpp +++ b/app/streaming/video/ffmpeg-renderers/drm.cpp @@ -1261,15 +1261,15 @@ bool DrmRenderer::addFbForFrame(AVFrame *frame, uint32_t* newFbId, bool testMode if (!formatMatch) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "Selected DRM plane doesn't support chosen decoding format: %08x", - drmFrame->layers[0].format); + "Selected DRM plane doesn't support chosen decoding format: " FOURCC_FMT, + FOURCC_FMT_ARGS(drmFrame->layers[0].format)); drmModeRmFB(m_DrmFd, *newFbId); return false; } SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Selected DRM plane supports chosen decoding format: %08x", - drmFrame->layers[0].format); + "Selected DRM plane supports chosen decoding format: " FOURCC_FMT, + FOURCC_FMT_ARGS(drmFrame->layers[0].format)); // TODO: We can also check the modifier support using the IN_FORMATS property, // but checking format alone is probably enough for real world cases since we're diff --git a/app/streaming/video/ffmpeg-renderers/renderer.h b/app/streaming/video/ffmpeg-renderers/renderer.h index 79cc0750..80154d65 100644 --- a/app/streaming/video/ffmpeg-renderers/renderer.h +++ b/app/streaming/video/ffmpeg-renderers/renderer.h @@ -16,6 +16,18 @@ extern "C" { #endif } +#ifndef FOURCC_FMT +#define FOURCC_FMT "%c%c%c%c" +#endif + +#ifndef FOURCC_FMT_ARGS +#define FOURCC_FMT_ARGS(f) \ + (char)((f) & 0xFF), \ + (char)(((f) >> 8) & 0xFF), \ + (char)(((f) >> 16) & 0xFF), \ + (char)(((f) >> 24) & 0xFF) +#endif + #ifdef HAVE_EGL #define MESA_EGL_NO_X11_HEADERS #define EGL_NO_X11 diff --git a/app/streaming/video/ffmpeg-renderers/vaapi.cpp b/app/streaming/video/ffmpeg-renderers/vaapi.cpp index 33dd3ccb..ae7c5da9 100644 --- a/app/streaming/video/ffmpeg-renderers/vaapi.cpp +++ b/app/streaming/video/ffmpeg-renderers/vaapi.cpp @@ -1102,15 +1102,15 @@ VAAPIRenderer::initializeEGL(EGLDisplay dpy, } else if (!m_EglImageFactory.supportsImportingModifier(dpy, descriptor.layers[0].drm_format, descriptor.objects[0].drm_format_modifier)) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Exporting separate layers due to lack of support for importing format and modifier: %08x %016" PRIx64, - descriptor.layers[0].drm_format, + "Exporting separate layers due to lack of support for importing format and modifier: " FOURCC_FMT " %016" PRIx64, + FOURCC_FMT_ARGS(descriptor.layers[0].drm_format), descriptor.objects[0].drm_format_modifier); m_EglExportType = EglExportType::Separate; } else { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Exporting composed layers with format and modifier: %08x %016" PRIx64, - descriptor.layers[0].drm_format, + "Exporting composed layers with format and modifier: " FOURCC_FMT " %016" PRIx64, + FOURCC_FMT_ARGS(descriptor.layers[0].drm_format), descriptor.objects[0].drm_format_modifier); m_EglExportType = EglExportType::Composed; } @@ -1126,13 +1126,14 @@ VAAPIRenderer::initializeEGL(EGLDisplay dpy, for (uint32_t i = 0; i < descriptor.num_layers; i++) { if (!m_EglImageFactory.supportsImportingFormat(dpy, descriptor.layers[i].drm_format)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, - "EGL implementation lacks support for importing format: %08x", descriptor.layers[0].drm_format); + "EGL implementation lacks support for importing format: " FOURCC_FMT, + FOURCC_FMT_ARGS(descriptor.layers[i].drm_format)); } else if (!m_EglImageFactory.supportsImportingModifier(dpy, descriptor.layers[i].drm_format, descriptor.objects[descriptor.layers[i].object_index[0]].drm_format_modifier)) { SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, - "EGL implementation lacks support for importing format and modifier: %08x %016" PRIx64, - descriptor.layers[i].drm_format, + "EGL implementation lacks support for importing format and modifier: " FOURCC_FMT " %016" PRIx64, + FOURCC_FMT_ARGS(descriptor.layers[i].drm_format), descriptor.objects[descriptor.layers[i].object_index[0]].drm_format_modifier); } }