RPP JPEG Compression Distortion HOST#531
Conversation
r-abishek
commented
Mar 26, 2025
- Adds JPEG Compression Distortion augmentation for HOST on U8/F32/F16/I8.
- Adds relevant unit/perf/QA tests.
Add inverse DCT function Add ycbCr to RGB conversion Add test suite support
RPP Jpeg Compression distortion Tensor Support
Fix CI failures - JPEG HOST
Jpeg compression distortion - resolved review comments
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new JPEG Compression Distortion augmentation for the HOST backend, including support for U8, F32, F16, and I8 data types, along with corresponding unit, performance, and QA tests.
- Added new augmentation mappings and enum entries across header and source files.
- Implemented the jpeg_compression_distortion functions for various data types in tensor geometric augmentation modules.
- Updated test suites and API documentation to integrate and validate the new augmentation.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| utilities/test_suite/rpp_test_suite_image.h | Added mapping entry and enum for JPEG Compression Distortion. |
| utilities/test_suite/common.py | Updated augmentation map with the new JPEG compression case. |
| utilities/test_suite/HOST/runImageTests.py | Adjusted the test range to include the new augmentation. |
| utilities/test_suite/HOST/Tensor_image_host.cpp | Introduced a new test case branch for JPEG Compression Distortion. |
| src/modules/tensor/rppt_tensor_geometric_augmentations.cpp | Added the main JPEG compression distortion function for HOST. |
| src/include/tensor/host_tensor_executors.hpp | Declared new function prototypes for the augmentation methods. |
| src/include/common/cpu/rpp_cpu_simd_math.hpp | Added a helper function for rounding away from zero. |
| src/include/common/cpu/rpp_cpu_simd_load_store.hpp | Included new load/store functions handling larger packed data blocks. |
| api/rppt_tensor_geometric_augmentations.h | Provided API documentation for the new augmentation function. |
| CHANGELOG.md | Updated the changelog to include JPEG Compression Distortion. |
rrawther
left a comment
There was a problem hiding this comment.
I have added few comments. Let's discuss the rest over a call
RPP JPEG Compression distortion HOST - review comments resolution
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #531 +/- ##
===========================================
+ Coverage 54.82% 55.56% +0.74%
===========================================
Files 293 294 +1
Lines 118516 120606 +2090
===========================================
+ Hits 64972 67007 +2035
- Misses 53544 53599 +55
🚀 New features to boost your workflow:
|
| temp[6] = x[2] - x[5]; | ||
| temp[7] = x[4] - x[3]; | ||
|
|
||
| temp[8] = temp[0] + temp[3]; |
There was a problem hiding this comment.
please combine temp[0] and temp[3] computation here and use only T temp[4] like
temp[8] = x[0] + x[7] + x[3] + x[4];
| if (row < colLimit && col < rowLimit) | ||
| { | ||
| Rpp32s idx = srcRowIdx + col * wStride; | ||
| if constexpr (std::is_same<T, Rpp32f>::value || std::is_same<T, Rpp16f>::value) |
There was a problem hiding this comment.
I think if we have a way to combine this with the formula it is better code
mul_factor = 1.0 * mul_table(rgb_data_type) , then use it in line 354
| r *= ONE_OVER_255; | ||
| g *= ONE_OVER_255; | ||
| b *= ONE_OVER_255; | ||
| dstPtrR[dstIdx] = static_cast<T>((r < 0.0f) ? 0.0f : (r > 1.0f) ? 1.0f : r); |
There was a problem hiding this comment.
check if std::max std::min combo is better. Should use an inline clamp function
There was a problem hiding this comment.
Changed to an inline function, and computing the clamp function using conditional operators is faster than using the combination of std::min and std::max.
RPP JPEG compression HOST : Resolve review comments
|
@r-abishek - needs conflicts resolved |
|
@kiritigowda Resolved. Docs CI failing to pull commit. |
rrawther
left a comment
There was a problem hiding this comment.
Added few more comments
| Rpp32f avgB = (b[id1] + b[id2] + b[id3] + b[id4]) / 4.0f; | ||
|
|
||
| // Convert to Cb/Cr and center around 0 | ||
| Rpp32s chromaIdx = (row / 2) * 8 + (col / 2); |
There was a problem hiding this comment.
please use ( >> 1) instead of /2
| for (Rpp32s col = 0; col < 16; col += 2) | ||
| { | ||
| Rpp32s id1 = (row * 16) + col; | ||
| Rpp32s id2 = (row * 16) + col + 1; |
There was a problem hiding this comment.
please change it to id2 = id1 + 1, also u can use in place in line#392 and get rid of id2. Same for id4
| Rpp32s id3 = (row + 1) * 16 + col; | ||
| Rpp32s id4 = (row + 1) * 16 + col + 1; | ||
|
|
||
| Rpp32f avgR = (r[id1] + r[id2] + r[id3] + r[id4]) / 4.0f; |
|
|
||
| // Convert YCbCr to RGB | ||
| Rpp32f yVal = y[yIdx] + 128.0f; | ||
| yVal = clamp(yVal, 0.0f, 255.0f); |
There was a problem hiding this comment.
why is this required. Please remove
| Rpp32f r = yVal + 1.402f * currCr; | ||
| Rpp32f g = yVal - 0.344136f * currCb - 0.714136f * currCr; | ||
| Rpp32f b = yVal + 1.772f * currCb; | ||
|
|
There was a problem hiding this comment.
I suggest clamping values here so it is int clamp between 0 and 255
There was a problem hiding this comment.
moved the all the clamps
| r *= ONE_OVER_255; | ||
| g *= ONE_OVER_255; | ||
| b *= ONE_OVER_255; | ||
| dstPtrR[dstIdx] = static_cast<T>(clamp(r, 0.0f, 1.0f)); |
| r -= 128; | ||
| g -= 128; | ||
| b -= 128; | ||
| dstPtrR[dstIdx] = static_cast<T>(clamp(r, -128.0f, 127.0f)); |
rrawther
left a comment
There was a problem hiding this comment.
@HazarathKumarM : Are all the comments resolved for this PR?
yes Rajy |