Skip to content

Conversation

@nihui
Copy link
Owner

@nihui nihui commented Apr 20, 2025

No description provided.

@nihui nihui requested a review from Copilot April 20, 2025 16:16
Copy link

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 pull request introduces support for a hardware JPEG encoder (CIX) for the Orion O6 platform by adding a new header file and updating the image write and encode functions to use the new backend when available.

  • Added jpeg_encoder_v4l_cix header with API declarations.
  • Updated imwrite and imencode in highgui.cpp to conditionally use the CIX encoder.
  • Implemented caching of encoder context in imwrite for potential performance improvement.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
highgui/src/jpeg_encoder_v4l_cix.h New header defining API for the CIX JPEG encoder
highgui/src/highgui.cpp Updates in imwrite and imencode to integrate the CIX encoder
Files not reviewed (1)
  • highgui/CMakeLists.txt: Language not supported

}

// cache jpeg_encoder_v4l_cix context
static int old_w = 0;
Copy link

Copilot AI Apr 20, 2025

Choose a reason for hiding this comment

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

The static caching variables used in the CV_WITH_CIX block of imwrite may not be thread-safe. Consider using a mutex or other synchronization mechanism to protect access.

Copilot uses AI. Check for mistakes.
Comment on lines +491 to +492
if (ret == 0)
return true;
Copy link

Copilot AI Apr 20, 2025

Choose a reason for hiding this comment

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

The caching branch in the CV_WITH_CIX block of imwrite does not call deinit() after a successful encode, which might leave resources allocated longer than intended. Ensure that proper resource cleanup is performed if required by the encoder's design.

Suggested change
if (ret == 0)
return true;
if (ret == 0)
{
e.deinit(); // Ensure resources are cleaned up
return true;
}

Copilot uses AI. Check for mistakes.
int ret = e.init(img.cols, img.rows, c, quality);
if (ret == 0)
{
ret = e.encode(img.data, buf);
Copy link

Copilot AI Apr 20, 2025

Choose a reason for hiding this comment

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

In the imencode function's CV_WITH_CIX block, if the encode call fails, deinit() is not invoked, potentially causing resource leaks. Consider calling deinit() on failure as well to ensure proper cleanup.

Copilot uses AI. Check for mistakes.
@nihui nihui merged commit 674c956 into master Apr 21, 2025
@nihui nihui deleted the o6-jpg-enc branch April 21, 2025 15:14
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.

1 participant