-
-
Notifications
You must be signed in to change notification settings - Fork 443
hw jpg encoder for orion o6 #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,9 @@ | |||||||||||||||
| #if CV_WITH_RPI | ||||||||||||||||
| #include "jpeg_encoder_v4l_rpi.h" | ||||||||||||||||
| #endif | ||||||||||||||||
| #if CV_WITH_CIX | ||||||||||||||||
| #include "jpeg_encoder_v4l_cix.h" | ||||||||||||||||
| #endif | ||||||||||||||||
| #if defined __linux__ && !__ANDROID__ | ||||||||||||||||
| #include "display_fb.h" | ||||||||||||||||
| #endif | ||||||||||||||||
|
|
@@ -454,6 +457,56 @@ bool imwrite(const String& filename, InputArray _img, const std::vector<int>& pa | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| // fallback to stb_image_write | ||||||||||||||||
| } | ||||||||||||||||
| #endif | ||||||||||||||||
| #if CV_WITH_CIX | ||||||||||||||||
| if (jpeg_encoder_v4l_cix::supported(img.cols, img.rows, c)) | ||||||||||||||||
| { | ||||||||||||||||
| // anything to bgr | ||||||||||||||||
| if (!img.isContinuous()) | ||||||||||||||||
| { | ||||||||||||||||
| img = img.clone(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| int quality = 95; | ||||||||||||||||
| for (size_t i = 0; i < params.size(); i += 2) | ||||||||||||||||
| { | ||||||||||||||||
| if (params[i] == IMWRITE_JPEG_QUALITY) | ||||||||||||||||
| { | ||||||||||||||||
| quality = params[i + 1]; | ||||||||||||||||
| break; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // cache jpeg_encoder_v4l_cix context | ||||||||||||||||
| static int old_w = 0; | ||||||||||||||||
| static int old_h = 0; | ||||||||||||||||
| static int old_ch = 0; | ||||||||||||||||
| static int old_quality = 0; | ||||||||||||||||
| static jpeg_encoder_v4l_cix e; | ||||||||||||||||
| if (img.cols == old_w && img.rows == old_h && c == old_ch && quality == old_quality) | ||||||||||||||||
| { | ||||||||||||||||
| int ret = e.encode(img.data, filename.c_str()); | ||||||||||||||||
| if (ret == 0) | ||||||||||||||||
| return true; | ||||||||||||||||
|
Comment on lines
+491
to
+492
|
||||||||||||||||
| if (ret == 0) | |
| return true; | |
| if (ret == 0) | |
| { | |
| e.deinit(); // Ensure resources are cleaned up | |
| return true; | |
| } |
Copilot
AI
Apr 20, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.