From 8b18d58aa0eb17a64b0f9d2f24be5de08cf6b0d3 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 8 Jul 2026 23:40:08 -0500 Subject: [PATCH] Add workaround for interoperability issue with out-of-tree FFmpeg zero-copy v4l2m2m patches and libplacebo Fixes #1786 --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index d8ed30d3..3a7b2a10 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -10,6 +10,7 @@ #include extern "C" { +#include #include } @@ -1146,6 +1147,24 @@ bool PlVkRenderer::testRenderFrame(AVFrame *frame) } #endif + if (frame->format == AV_PIX_FMT_DRM_PRIME) { + auto drmFrame = (AVDRMFrameDescriptor*)frame->data[0]; + + // This can happen with out-of-tree FFmpeg patches if the V4L2 + // format lacks a mapping to a DRM format. + if (drmFrame->nb_layers == 0) { + return false; + } + + // Current versions of libplacebo only support one plane per layer + // and will assert if provided a frame that violates this constraint. + for (int i = 0; i < drmFrame->nb_layers; i++) { + if (drmFrame->layers[i].nb_planes != 1) { + return false; + } + } + } + // Test if the frame can be mapped to libplacebo pl_frame mappedFrame; if (!mapAvFrameToPlacebo(frame, &mappedFrame)) {