Added a new function to get RgbStride (#352)
* re-org videodecodeRGB sample * minor fix * removed un-necessary include * minor fix * added GetRgbStride utility function for RGB stride * fix for review comments --------- Co-authored-by: Aryan Salmanpour <aryan.salmanpour@amd.com>
This commit is contained in:
@@ -119,15 +119,8 @@ void ColorSpaceConversionThread(std::atomic<bool>& continue_processing, bool con
|
||||
}
|
||||
|
||||
if (convert_to_rgb) {
|
||||
int rgb_width;
|
||||
if (p_surf_info->bit_depth == 8) {
|
||||
rgb_width = (p_surf_info->output_width + 1) & ~1; // has to be a multiple of 2 for hip colorconvert kernels
|
||||
rgb_image_size = ((e_output_format == bgr) || (e_output_format == rgb)) ? rgb_width * p_surf_info->output_height * 3 : rgb_width * p_surf_info->output_height * 4;
|
||||
} else {
|
||||
rgb_width = (p_surf_info->output_width + 1) & ~1;
|
||||
rgb_image_size = ((e_output_format == bgr) || (e_output_format == rgb)) ? rgb_width * p_surf_info->output_height * 3 : ((e_output_format == bgr48) || (e_output_format == rgb48)) ?
|
||||
rgb_width * p_surf_info->output_height * 6 : rgb_width * p_surf_info->output_height * 8;
|
||||
}
|
||||
uint32_t rgb_stride = post_proc.GetRgbStride(e_output_format, p_surf_info);
|
||||
rgb_image_size = p_surf_info->output_height * rgb_stride;
|
||||
if (p_rgb_dev_mem == nullptr) {
|
||||
hip_status = hipMalloc(&p_rgb_dev_mem, rgb_image_size);
|
||||
if (hip_status != hipSuccess) {
|
||||
|
||||
@@ -103,6 +103,17 @@ class VideoPostProcess {
|
||||
else if (e_output_format == rgba64)
|
||||
P016ToColor64<RGBA64>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 8 * rgb_width, surf_info->output_width,
|
||||
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
|
||||
}
|
||||
};
|
||||
uint32_t GetRgbStride(OutputFormatEnum e_output_format, OutputSurfaceInfo *surf_info) {
|
||||
uint32_t rgb_stride;
|
||||
uint32_t rgb_width = (surf_info->output_width + 1) & ~1; // has to be a multiple of 2 for hip colorconvert kernels
|
||||
if (surf_info->bit_depth == 8) {
|
||||
rgb_stride = ((e_output_format == bgr) || (e_output_format == rgb)) ? rgb_width * 3 : rgb_width * 4; // bgr/bgra/rgb/rgba
|
||||
} else {
|
||||
rgb_stride = ((e_output_format == bgr) || (e_output_format == rgb)) ? rgb_width * 3 :
|
||||
((e_output_format == bgr48) || (e_output_format == rgb48)) ? rgb_width * 6 : rgb_width * 8;
|
||||
}
|
||||
return rgb_stride;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user