mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-08-03 08:46:44 -04:00
The "Target image is already colourised, colours: 1" warning fired from Image::Colourise() during zone alarm overlay on YUV420P monitors, even with ZM_COLOUR_JPEG_FILES off. monitor->Colours() returns 1 for both GRAY8 and planar YUV420P (the GRAY8 alias), so zm_zone.cpp misclassified YUV420P monitors as grayscale and built an RGB24 alarm highlight. Overlaying that RGB24 highlight onto the YUV420P analysis_image hit the RGB-on-mono branch, which calls Colourise() - valid only for GRAY8. Colourise() warned and bailed, after which the per-pixel loop walked the 1.5x planar buffer as 3x packed RGB (out-of-bounds write). Resolve the real capture format via zm_pixformat_from_colours() so true GRAY8 still upgrades to an RGB24 highlight while YUV420P keeps its format. Add a YUV420P output branch to HighlightEdges (single alarm colour written to luma and the shared chroma sample, transparent elsewhere) and a YUV420P-on-YUV420P branch to Overlay (copies luma where non-zero, copies each chroma sample when any covered luma pixel is marked). Colourise() is now only reached for GRAY8. Add Catch2 coverage for the YUV420P Overlay masking and HighlightEdges output. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>