Skip to content

Commit

Permalink
Increase the output image size for rgb and rgb_planar (#54)
Browse files Browse the repository at this point in the history
* Increase the output image size for rgb and rgb_planar to avoi

* code clean up
  • Loading branch information
AryanSalmanpour authored Sep 10, 2024
1 parent 7b321a8 commit 459f12b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions samples/rocjpeg_samples_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,12 @@ class RocJpegUtils {
case ROCJPEG_OUTPUT_RGB:
num_channels = 1;
output_image.pitch[0] = (is_roi_valid ? roi_width : widths[0]) * 3;
channel_sizes[0] = output_image.pitch[0] * (is_roi_valid ? roi_height : heights[0]);
channel_sizes[0] = align(output_image.pitch[0] * (is_roi_valid ? roi_height : heights[0]), mem_alignment);
break;
case ROCJPEG_OUTPUT_RGB_PLANAR:
num_channels = 3;
output_image.pitch[2] = output_image.pitch[1] = output_image.pitch[0] = is_roi_valid ? roi_width : widths[0];
channel_sizes[2] = channel_sizes[1] = channel_sizes[0] = output_image.pitch[0] * (is_roi_valid ? roi_height : heights[0]);
channel_sizes[2] = channel_sizes[1] = channel_sizes[0] = align(output_image.pitch[0] * (is_roi_valid ? roi_height : heights[0]), mem_alignment);
break;
default:
std::cout << "Unknown output format!" << std::endl;
Expand Down Expand Up @@ -620,6 +620,7 @@ class RocJpegUtils {
}

private:
static const int mem_alignment = 1024 * 1024;
/**
* @brief Shows the help message and exits.
*
Expand All @@ -645,5 +646,17 @@ class RocJpegUtils {
}
exit(0);
}
/**
* @brief Aligns a value to a specified alignment.
*
* This function takes a value and aligns it to the specified alignment. It returns the aligned value.
*
* @param value The value to be aligned.
* @param alignment The alignment value.
* @return The aligned value.
*/
static inline int align(int value, int alignment) {
return (value + alignment - 1) & ~(alignment - 1);
}
};
#endif //ROC_JPEG_SAMPLES_COMMON

0 comments on commit 459f12b

Please sign in to comment.