videodecodeRGB sample re-org for rocPyDecode (#343)

* re-org videodecodeRGB sample

* minor fix

* removed un-necessary include

* minor fix
This commit is contained in:
Rajy Rawther
2024-05-07 14:11:57 -07:00
zatwierdzone przez GitHub
rodzic 1943aad663
commit 95f90982eb
5 zmienionych plików z 157 dodań i 143 usunięć
+1
Wyświetl plik
@@ -149,6 +149,7 @@ if(HIP_FOUND AND Libva_FOUND)
install(FILES utils/colorspace_kernels.h DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES utils/resize_kernels.cpp DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES utils/resize_kernels.h DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES utils/video_post_process.h DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/utils COMPONENT dev)
install(FILES data/videos/AMD_driving_virtual_20-H265.mp4 data/videos/AMD_driving_virtual_20-H264.mp4 DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/video COMPONENT dev)
# install license information - {ROCM_PATH}/share/doc/rocdecode
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+8 -109
Wyświetl plik
@@ -41,13 +41,8 @@ THE SOFTWARE.
#include <atomic>
#include "video_demuxer.h"
#include "roc_video_dec.h"
#include "colorspace_kernels.h"
#include "resize_kernels.h"
#include "video_post_process.h"
FILE *fpOut = nullptr;
enum OutputFormatEnum {
native = 0, bgr, bgr48, rgb, rgb48, bgra, bgra64, rgba, rgba64
};
std::vector<std::string> st_output_format_name = {"native", "bgr", "bgr48", "rgb", "rgb48", "bgra", "bgra64", "rgba", "rgba64"};
void ShowHelpAndExit(const char *option = NULL) {
@@ -56,113 +51,20 @@ void ShowHelpAndExit(const char *option = NULL) {
<< "-o Output File Path - dumps output if requested; optional" << std::endl
<< "-d GPU device ID (0 for the first device, 1 for the second, etc.); optional; default: 0" << std::endl
<< "-of Output Format name - (native, bgr, bgr48, rgb, rgb48, bgra, bgra64, rgba, rgba64; converts native YUV frame to RGB image format; optional; default: 0" << std::endl
<< "-resize WxH - (where W is resize width and H is resize height) optional; default: no resize " << std::endl
<< "-crop crop rectangle for output (not used when using interopped decoded frame); optional; default: 0" << std::endl;
exit(0);
}
void DumpRGBImage(std::string outputfileName, void* pdevMem, OutputSurfaceInfo *surf_info, int rgb_image_size) {
if (fpOut == nullptr) {
fpOut = fopen(outputfileName.c_str(), "wb");
}
uint8_t *hstPtr = nullptr;
hstPtr = new uint8_t [rgb_image_size];
hipError_t hip_status = hipSuccess;
hip_status = hipMemcpyDtoH((void *)hstPtr, pdevMem, rgb_image_size);
if (hip_status != hipSuccess) {
std::cout << "ERROR: hipMemcpyDtoH failed! (" << hip_status << ")" << std::endl;
delete [] hstPtr;
return;
}
if (fpOut) {
fwrite(hstPtr, 1, rgb_image_size, fpOut);
}
if (hstPtr != nullptr) {
delete [] hstPtr;
hstPtr = nullptr;
}
}
void ColorConvertYUV2RGB(uint8_t *p_src, OutputSurfaceInfo *surf_info, uint8_t *rgb_dev_mem_ptr, OutputFormatEnum e_output_format, hipStream_t hip_stream) {
int rgb_width = (surf_info->output_width + 1) & ~1; // has to be a multiple of 2 for hip colorconvert kernels
// todo:: get color standard from the decoder
if (surf_info->surface_format == rocDecVideoSurfaceFormat_YUV444) {
if (e_output_format == bgr)
YUV444ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra)
YUV444ToColor32<BGRA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
YUV444ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgba)
YUV444ToColor32<RGBA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
} else if (surf_info->surface_format == rocDecVideoSurfaceFormat_NV12) {
if (e_output_format == bgr)
Nv12ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra)
Nv12ToColor32<BGRA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
Nv12ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgba)
Nv12ToColor32<RGBA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
}
if (surf_info->surface_format == rocDecVideoSurfaceFormat_YUV444_16Bit) {
if (e_output_format == bgr)
YUV444P16ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
YUV444P16ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgr48)
YUV444P16ToColor48<BGR48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb48)
YUV444P16ToColor48<RGB48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra64)
YUV444P16ToColor64<BGRA64>(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);
else if (e_output_format == rgba64)
YUV444P16ToColor64<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);
} else if (surf_info->surface_format == rocDecVideoSurfaceFormat_P016) {
if (e_output_format == bgr)
P016ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
P016ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgr48)
P016ToColor48<BGR48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb48)
P016ToColor48<RGB48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra64)
P016ToColor64<BGRA64>(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);
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);
}
}
constexpr int frame_buffers_size = 2;
std::queue<uint8_t*> frame_queue[frame_buffers_size];
std::mutex mutex[frame_buffers_size];
std::condition_variable cv[frame_buffers_size];
void ColorSpaceConversionThread(std::atomic<bool>& continue_processing, bool convert_to_rgb, Dim *p_resize_dim, OutputSurfaceInfo **surf_info, OutputSurfaceInfo **res_surf_info,
OutputFormatEnum e_output_format, uint8_t *p_rgb_dev_mem, uint8_t *p_resize_dev_mem, bool dump_output_frames, std::string &output_file_path, RocVideoDecoder &viddec, bool b_generate_md5) {
OutputFormatEnum e_output_format, uint8_t *p_rgb_dev_mem, uint8_t *p_resize_dev_mem, bool dump_output_frames,
std::string &output_file_path, RocVideoDecoder &viddec, VideoPostProcess &post_proc, bool b_generate_md5) {
size_t rgb_image_size, resize_image_size;
hipError_t hip_status = hipSuccess;
@@ -233,11 +135,11 @@ void ColorSpaceConversionThread(std::atomic<bool>& continue_processing, bool con
return;
}
}
ColorConvertYUV2RGB(out_frame, p_surf_info, p_rgb_dev_mem, e_output_format, viddec.GetStream());
post_proc.ColorConvertYUV2RGB(out_frame, p_surf_info, p_rgb_dev_mem, e_output_format, viddec.GetStream());
}
if (dump_output_frames) {
if (convert_to_rgb)
DumpRGBImage(output_file_path, p_rgb_dev_mem, p_surf_info, rgb_image_size);
viddec.SaveFrameToFile(output_file_path, p_rgb_dev_mem, p_surf_info, rgb_image_size);
else
viddec.SaveFrameToFile(output_file_path, out_frame, p_surf_info);
}
@@ -360,6 +262,7 @@ int main(int argc, char **argv) {
VideoDemuxer demuxer(input_file_path.c_str());
rocDecVideoCodec rocdec_codec_id = AVCodec2RocDecVideoCodec(demuxer.GetCodecID());
RocVideoDecoder viddec(device_id, mem_type, rocdec_codec_id, false, p_crop_rect);
VideoPostProcess post_process;
std::string device_name, gcn_arch_name;
int pci_bus_id, pci_domain_id, pci_device_id;
@@ -389,7 +292,7 @@ int main(int argc, char **argv) {
convert_to_rgb = e_output_format != native;
std::atomic<bool> continue_processing(true);
std::thread color_space_conversion_thread(ColorSpaceConversionThread, std::ref(continue_processing), std::ref(convert_to_rgb), &resize_dim, &surf_info, &resize_surf_info, std::ref(e_output_format),
std::ref(p_rgb_dev_mem), std::ref(p_resize_dev_mem), std::ref(dump_output_frames), std::ref(output_file_path), std::ref(viddec), b_generate_md5);
std::ref(p_rgb_dev_mem), std::ref(p_resize_dev_mem), std::ref(dump_output_frames), std::ref(output_file_path), std::ref(viddec), std::ref(post_process), b_generate_md5);
auto startTime = std::chrono::high_resolution_clock::now();
do {
@@ -451,10 +354,6 @@ int main(int argc, char **argv) {
return -1;
}
}
if (fpOut) {
fclose(fpOut);
fpOut = nullptr;
}
for (int i = 0; i < frame_buffers_size; i++) {
hip_status = hipFree(frame_buffers[i]);
if (hip_status != hipSuccess) {
+38 -33
Wyświetl plik
@@ -884,9 +884,10 @@ bool RocVideoDecoder::ReleaseInternalFrames() {
}
void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info) {
void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info, size_t rgb_image_size) {
uint8_t *hst_ptr = nullptr;
uint64_t output_image_size = surf_info->output_surface_size_in_bytes;
bool is_rgb = (rgb_image_size != 0);
uint64_t output_image_size = is_rgb ? rgb_image_size : surf_info->output_surface_size_in_bytes;
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL || surf_info->mem_type == OUT_SURFACE_MEM_DEV_COPIED) {
if (hst_ptr == nullptr) {
hst_ptr = new uint8_t [output_image_size];
@@ -901,10 +902,6 @@ void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_m
} else
hst_ptr = static_cast<uint8_t *> (surf_mem);
uint8_t *tmp_hst_ptr = hst_ptr;
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) {
tmp_hst_ptr += ((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + (disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel;
}
if (current_output_filename.empty()) {
current_output_filename = output_file_name;
@@ -936,39 +933,47 @@ void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_m
fp_out_ = fopen(output_file_name.c_str(), "wb");
}
if (fp_out_) {
int img_width = surf_info->output_width;
int img_height = surf_info->output_height;
int output_stride = surf_info->output_pitch;
if (img_width * surf_info->bytes_per_pixel == output_stride && img_height == surf_info->output_vstride) {
fwrite(hst_ptr, 1, output_image_size, fp_out_);
} else {
uint32_t width = surf_info->output_width * surf_info->bytes_per_pixel;
if (surf_info->bit_depth <= 16) {
for (int i = 0; i < surf_info->output_height; i++) {
fwrite(tmp_hst_ptr, 1, width, fp_out_);
tmp_hst_ptr += output_stride;
}
// dump chroma
uint8_t *uv_hst_ptr = hst_ptr + output_stride * surf_info->output_vstride;
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) {
uv_hst_ptr += (num_chroma_planes_ == 1) ? (((disp_rect_.top + crop_rect_.top) >> 1) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel):
((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel);
}
for (int i = 0; i < chroma_height_; i++) {
fwrite(uv_hst_ptr, 1, width, fp_out_);
uv_hst_ptr += output_stride;
}
if (num_chroma_planes_ == 2) {
uv_hst_ptr = hst_ptr + output_stride * (surf_info->output_vstride + chroma_vstride_);
if (!is_rgb) {
uint8_t *tmp_hst_ptr = hst_ptr;
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) {
tmp_hst_ptr += ((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + (disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel;
}
int img_width = surf_info->output_width;
int img_height = surf_info->output_height;
int output_stride = surf_info->output_pitch;
if (img_width * surf_info->bytes_per_pixel == output_stride && img_height == surf_info->output_vstride) {
fwrite(hst_ptr, 1, output_image_size, fp_out_);
} else {
uint32_t width = surf_info->output_width * surf_info->bytes_per_pixel;
if (surf_info->bit_depth <= 16) {
for (int i = 0; i < surf_info->output_height; i++) {
fwrite(tmp_hst_ptr, 1, width, fp_out_);
tmp_hst_ptr += output_stride;
}
// dump chroma
uint8_t *uv_hst_ptr = hst_ptr + output_stride * surf_info->output_vstride;
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) {
uv_hst_ptr += ((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel);
uv_hst_ptr += (num_chroma_planes_ == 1) ? (((disp_rect_.top + crop_rect_.top) >> 1) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel):
((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel);
}
for (int i = 0; i < chroma_height_; i++) {
fwrite(uv_hst_ptr, 1, width, fp_out_);
uv_hst_ptr += output_stride;
}
}
}
if (num_chroma_planes_ == 2) {
uv_hst_ptr = hst_ptr + output_stride * (surf_info->output_vstride + chroma_vstride_);
if (surf_info->mem_type == OUT_SURFACE_MEM_DEV_INTERNAL) {
uv_hst_ptr += ((disp_rect_.top + crop_rect_.top) * surf_info->output_pitch) + ((disp_rect_.left + crop_rect_.left) * surf_info->bytes_per_pixel);
}
for (int i = 0; i < chroma_height_; i++) {
fwrite(uv_hst_ptr, 1, width, fp_out_);
uv_hst_ptr += output_stride;
}
}
}
}
} else {
fwrite(hst_ptr, 1, rgb_image_size, fp_out_);
}
}
+2 -1
Wyświetl plik
@@ -319,8 +319,9 @@ class RocVideoDecoder {
* @param output_file_name - Output file name
* @param dev_mem - pointer to surface memory
* @param surf_info - surface info
* @param rgb_image_size - image size for rgb (optional). A non_zero value indicates the surf_mem holds an rgb interleaved image and the entire size will be dumped to file
*/
void SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info);
void SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info, size_t rgb_image_size = 0);
/**
* @brief Helper funtion to close a existing file and dump to new file in case of multiple files using same decoder
+108
Wyświetl plik
@@ -0,0 +1,108 @@
/*
Copyright (c) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#include "colorspace_kernels.h"
#include "resize_kernels.h"
#include "rocvideodecode/roc_video_dec.h" //for OutputSurfaceInfo
enum OutputFormatEnum {
native = 0, bgr, bgr48, rgb, rgb48, bgra, bgra64, rgba, rgba64
};
class VideoPostProcess {
public:
VideoPostProcess(){};
~VideoPostProcess(){};
void ColorConvertYUV2RGB(uint8_t *p_src, OutputSurfaceInfo *surf_info, uint8_t *rgb_dev_mem_ptr, OutputFormatEnum e_output_format, hipStream_t hip_stream) {
int rgb_width = (surf_info->output_width + 1) & ~1; // has to be a multiple of 2 for hip colorconvert kernels
// todo:: get color standard from the decoder
if (surf_info->surface_format == rocDecVideoSurfaceFormat_YUV444) {
if (e_output_format == bgr)
YUV444ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra)
YUV444ToColor32<BGRA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
YUV444ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgba)
YUV444ToColor32<RGBA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
} else if (surf_info->surface_format == rocDecVideoSurfaceFormat_NV12) {
if (e_output_format == bgr)
Nv12ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra)
Nv12ToColor32<BGRA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
Nv12ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgba)
Nv12ToColor32<RGBA32>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 4 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
}
if (surf_info->surface_format == rocDecVideoSurfaceFormat_YUV444_16Bit) {
if (e_output_format == bgr)
YUV444P16ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
YUV444P16ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgr48)
YUV444P16ToColor48<BGR48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb48)
YUV444P16ToColor48<RGB48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra64)
YUV444P16ToColor64<BGRA64>(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);
else if (e_output_format == rgba64)
YUV444P16ToColor64<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);
} else if (surf_info->surface_format == rocDecVideoSurfaceFormat_P016) {
if (e_output_format == bgr)
P016ToColor24<BGR24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb)
P016ToColor24<RGB24>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 3 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgr48)
P016ToColor48<BGR48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == rgb48)
P016ToColor48<RGB48>(p_src, surf_info->output_pitch, static_cast<uint8_t *>(rgb_dev_mem_ptr), 6 * rgb_width, surf_info->output_width,
surf_info->output_height, surf_info->output_vstride, 0, hip_stream);
else if (e_output_format == bgra64)
P016ToColor64<BGRA64>(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);
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);
}
};
};