From 5ee7061624d1a30179771b62c4c9d7ae6ee888dc Mon Sep 17 00:00:00 2001 From: sladro Date: Fri, 26 Dec 2025 16:26:27 +0800 Subject: [PATCH] =?UTF-8?q?xiufuyolo=E7=9F=BF=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/osd/osd_node.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/osd/osd_node.cpp b/plugins/osd/osd_node.cpp index c0f9767..dfbdee1 100644 --- a/plugins/osd/osd_node.cpp +++ b/plugins/osd/osd_node.cpp @@ -366,13 +366,17 @@ private: int w = frame->width; int h = frame->height; - int stride = frame->stride > 0 ? frame->stride : w * 3; uint8_t* data = frame->data; PixelFormat fmt = frame->format; - bool supported = (fmt == PixelFormat::RGB || fmt == PixelFormat::BGR || fmt == PixelFormat::NV12); - if (!supported) { - return; + // Calculate correct byte stride based on format + int stride; + if (fmt == PixelFormat::RGB || fmt == PixelFormat::BGR) { + stride = w * 3; // 3 bytes per pixel + } else if (fmt == PixelFormat::NV12 || fmt == PixelFormat::YUV420) { + stride = w; // Y plane stride + } else { + return; // Unsupported format } for (const auto& det : frame->det->items) {