From 02e6be6b4757ad05a6e4c60fd617d4fcb5f0978c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 18 Apr 2026 18:38:10 -0400 Subject: [PATCH] fix: handle YUVJ422P/YUV422P in zm_colours_from_pixformat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MJPEG decoder outputs AV_PIX_FMT_YUVJ422P which was not handled by zm_colours_from_pixformat, causing "Unknown pixelformat 13 yuvj422p" errors and leaving imagePixFormat stale — resulting in random image corruption. Add YUV422P and YUVJ422P cases to zm_colours_from_pixformat and zm_bytes_per_pixel in zm_pixformat.h. refs #4735 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/zm_pixformat.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/zm_pixformat.h b/src/zm_pixformat.h index 85dba4d7f..caa70eb76 100644 --- a/src/zm_pixformat.h +++ b/src/zm_pixformat.h @@ -61,6 +61,11 @@ inline bool zm_colours_from_pixformat(AVPixelFormat fmt, colours = ZM_COLOUR_GRAY8; subpixelorder = ZM_SUBPIX_ORDER_YUVJ420P; return true; + case AV_PIX_FMT_YUV422P: + case AV_PIX_FMT_YUVJ422P: + colours = ZM_COLOUR_GRAY8; // Y-plane is 1 byte/pixel + subpixelorder = ZM_SUBPIX_ORDER_NONE; + return true; case AV_PIX_FMT_RGB24: colours = ZM_COLOUR_RGB24; subpixelorder = ZM_SUBPIX_ORDER_RGB; @@ -97,6 +102,8 @@ inline unsigned int zm_bytes_per_pixel(AVPixelFormat fmt) { case AV_PIX_FMT_GRAY8: case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVJ420P: + case AV_PIX_FMT_YUV422P: + case AV_PIX_FMT_YUVJ422P: return 1; case AV_PIX_FMT_RGB24: case AV_PIX_FMT_BGR24: