Skip to content
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

Increase the output image size for rgb and rgb_planar #54

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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