Revert "fix: replace ZM_COLOUR system with AVPixelFormat for format dispatch"#4786
Merged
connortechnology merged 1 commit intomasterfrom May 2, 2026
Conversation
Contributor
There was a problem hiding this comment.
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.hand 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
Imageformat 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 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 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 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 on lines
+338
to
+339
| conversion_type = 0; | ||
| subpixelorder = ZM_SUBPIX_ORDER_BGR; |
| #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; |
| #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 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; |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #4742