Skip to content

Revert "fix: replace ZM_COLOUR system with AVPixelFormat for format dispatch"#4786

Merged
connortechnology merged 1 commit intomasterfrom
revert-4742-fix/deprecate-zm-colour-use-avpixelformat
May 2, 2026
Merged

Revert "fix: replace ZM_COLOUR system with AVPixelFormat for format dispatch"#4786
connortechnology merged 1 commit intomasterfrom
revert-4742-fix/deprecate-zm-colour-use-avpixelformat

Conversation

@connortechnology
Copy link
Copy Markdown
Member

Reverts #4742

Copilot AI review requested due to automatic review settings May 2, 2026 22:26
@connortechnology connortechnology merged commit cfdcc1d into master May 2, 2026
5 of 9 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts #4742 by removing the AVPixelFormat-based dispatch helpers/tests and returning pixel-format decisions to the legacy ZM_COLOUR_* / ZM_SUBPIX_ORDER_* flow across cameras, monitor decode, and image handling.

Changes:

  • Removes zm_pixformat.h and its associated Catch2 tests, and drops the UI deprecation notice for the Colours setting.
  • Restores legacy pixel format selection logic in camera constructors, FFmpeg helpers, MPEG setup, and monitor decode paths.
  • Refactors Image format dispatch back to colours/subpixelorder checks throughout JPEG/overlay/delta/deinterlace paths.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
web/skins/classic/views/monitor.php Removes deprecated Colours-setting hint in the classic UI monitor view.
web/lang/en_gb.php Removes the deprecated Colours-setting translation string.
tests/zm_pixformat.cpp Deletes pixel-format helper unit tests (Catch2).
tests/CMakeLists.txt Removes zm_pixformat.cpp from the test target sources.
src/zm_rgb.h Restores legacy colour/subpixel constants and removes deprecation notes/extra YUV422 subpixel constants.
src/zm_remote_camera_rtsp.cpp Reverts pixel-format dispatch to colours checks in RTSP camera setup.
src/zm_mpeg.cpp Reverts codec pixel format selection to legacy switch logic.
src/zm_monitor.cpp Reverts monitor pipeline format handling and signal/zone checks to legacy colour-based logic.
src/zm_local_camera.cpp Reverts V4L palette/target-colours matching logic to legacy checks.
src/zm_libvnc_camera.cpp Reverts VNC camera format selection to legacy colour-based logic.
src/zm_libvlc_camera.cpp Reverts LibVLC camera format selection to legacy colour-based logic.
src/zm_image.h Removes PixFormat() accessor and AVPixelFormat helper header include.
src/zm_image.cpp Reverts many Image format paths to colours/subpixelorder checks; removes pixformat helper usage.
src/zm_ffmpeg_camera.cpp Reverts FFmpeg camera constructor format selection to legacy colour-based logic.
src/zm_ffmpeg.cpp Reverts GetFFMPEGPixelFormat() to legacy mapping logic (removes helper).
src/zm_camera.h Removes stored pixelFormat member/accessor and restores colours/subpixelorder as primary members.
src/zm_camera.cpp Reverts camera linesize/imagesize computation and stream format assignment to legacy code.
src/zm_pixformat.h Deletes the AVPixelFormat helper header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/zm_image.cpp
Comment on lines +745 to +755
switch(static_cast<AVPixelFormat>(frame->format)) {
case AV_PIX_FMT_RGBA:
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
colours = ZM_COLOUR_RGB32;
break;
case AV_PIX_FMT_YUV420P:
colours = ZM_COLOUR_GRAY8;
break;
default:
Debug(1, "Unimplemented format");
break;
Comment thread src/zm_image.cpp
Comment on lines 708 to 733
@@ -766,9 +727,8 @@ uint8_t* Image::WriteBuffer(
width = p_width;
height = p_height;
colours = p_colours;
linesize = static_cast<unsigned int>(av_linesize);
linesize = p_width * p_colours;
subpixelorder = p_subpixelorder;
imagePixFormat = p_pixfmt;
pixels = height*width;
size = newsize;
Comment thread src/zm_image.cpp
Comment on lines +5467 to +5480
if ( colours == ZM_COLOUR_RGB32 ) {
return AV_PIX_FMT_RGBA;
} else if ( colours == ZM_COLOUR_RGB24 ) {
if ( subpixelorder == ZM_SUBPIX_ORDER_BGR) {
return AV_PIX_FMT_BGR24;
} else {
return AV_PIX_FMT_RGB24;
}
} else if ( colours == ZM_COLOUR_GRAY8 ) {
return AV_PIX_FMT_GRAY8;
} else {
Error("Unknown colours (%d)",colours);
return AV_PIX_FMT_RGBA;
}
Comment thread src/zm_local_camera.cpp
Comment on lines +338 to +339
conversion_type = 0;
subpixelorder = ZM_SUBPIX_ORDER_BGR;
Comment thread src/zm_image.cpp
#else
Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead.");
readjpg_dcinfo->out_color_space = JCS_RGB;
cinfo->out_color_space = JCS_RGB;
Comment thread src/zm_image.cpp
#else
Warning("libjpeg-turbo is required for reading a JPEG directly into a BGR24 buffer, reading into a RGB24 buffer instead.");
decodejpg_dcinfo->out_color_space = JCS_RGB;
cinfo->out_color_space = JCS_RGB;
Comment thread src/zm_image.cpp
Comment on lines 741 to +748
height = frame->height;
buffer = frame->data[0];
linesize = frame->linesize[0];
imagePixFormat = static_cast<AVPixelFormat>(frame->format);

// av_image_get_buffer_size returns int (negative on error). Assigning a
// negative value into the unsigned size/allocation members would wrap to
// huge and break later bounds-dependent code, so check first.
int av_size = av_image_get_buffer_size(imagePixFormat, frame->width, frame->height, 32);
bool fmt_ok = (av_size >= 0)
&& zm_colours_from_pixformat(imagePixFormat, colours, subpixelorder);
if (!fmt_ok) {
Error("AssignDirect: unsupported pixel format %d on frame %dx%d (av_size=%d)",
frame->format, frame->width, frame->height, av_size);
// Leave the Image in an explicit invalid state — don't keep stale
// size/linesize/colours that don't match imagePixFormat.
imagePixFormat = AV_PIX_FMT_NONE;
colours = 0;
subpixelorder = 0;
size = 0;
allocation = 0;
linesize = 0;
pixels = 0;
} else {
allocation = size = static_cast<unsigned int>(av_size);
pixels = width * height;
allocation = size = av_image_get_buffer_size(static_cast<AVPixelFormat>(frame->format), frame->width, frame->height, 32);
switch(static_cast<AVPixelFormat>(frame->format)) {
case AV_PIX_FMT_RGBA:
subpixelorder = ZM_SUBPIX_ORDER_RGBA;
colours = ZM_COLOUR_RGB32;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants