-
Notifications
You must be signed in to change notification settings - Fork 14
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
rocDecode integration in rocAL #253
base: develop
Are you sure you want to change the base?
Conversation
fiona-gladwin
commented
Dec 18, 2024
- Add support for rocDecode hardware decoder in rocAL
- Add support to create sequences using the seek operation in rocDecode, works seamlessly for H265 videos.
Requires VideoDemuxer to have .cpp file
Facing seg fault
Add utils folder to rocAL hip to compile with rocDecode
This reverts commit 21b0538.
Revert additional changes
@fiona-gladwin failing to compile
|
@kiritigowda This PR requires PR #479 of rocDecode to be merged for successful compilation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the review comments
# | ||
# MIT License | ||
# | ||
# Copyright (c) 2024 Advanced Micro Devices, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025
find_path(ROCDECODE_INCLUDE_DIRS | ||
NAMES rocdecode.h rocparser.h | ||
HINTS | ||
$ENV{rocDecode_PATH}/include/rocdecode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is rocDecode_PATH? did you mean ROCM_PATH
find_library(ROCDECODE_LIBRARIES | ||
NAMES rocdecode | ||
HINTS | ||
$ENV{rocDecode_PATH}/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. Please copy FindrocDecode from rocDecode repo instead
RocDecVideoDecoder(); | ||
VideoDecoder::Status Initialize(const char *src_filename, int device_id = 0) override; | ||
VideoDecoder::Status Decode(unsigned char *output_buffer, unsigned seek_frame_number, size_t sequence_length, size_t stride, int out_width, int out_height, int out_stride, AVPixelFormat out_format) override; | ||
int seek_frame(AVRational avg_frame_rate, AVRational time_base, unsigned frame_number) override { return 0; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use same function name style for all functions here. Here snake and camel cases are mixed
#include "video_decoder.h" | ||
|
||
#ifdef ROCAL_VIDEO | ||
#if ENABLE_HIP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should get rid of ENABLE_HIP and ENABLE_ROCDECODE flags
} | ||
|
||
// Seeks to the frame_number in the video file and decodes each frame in the sequence. | ||
VideoDecoder::Status RocDecVideoDecoder::Decode(unsigned char *out_buffer, unsigned seek_frame_number, size_t sequence_length, size_t stride, int out_width, int out_height, int out_stride, AVPixelFormat out_pix_format) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename out_buffer to output_buffer_ptr
return Status::FAILED; | ||
} | ||
// Take the min of sequence length and num frames to avoid out of bounds memory error | ||
int required_n_frames = std::min(static_cast<int>(sequence_length), n_frame_returned); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the sequence_length always <= n_frame_returned. In line#144 please check if n_frame_returned < sequence_length and return error.
Remove this line
} | ||
// Take the min of sequence length and num frames to avoid out of bounds memory error | ||
int required_n_frames = std::min(static_cast<int>(sequence_length), n_frame_returned); | ||
for (int i = 0; i < required_n_frames; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change it to sequence_length. What if there in not enough frames in the sequence when there is EOF?
int required_n_frames = std::min(static_cast<int>(sequence_length), n_frame_returned); | ||
for (int i = 0; i < required_n_frames; i++) { | ||
uint8_t *pframe = _rocvid_decoder->GetFrame(&pts); | ||
if (dts >= requested_frame_dts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is the dts value updated here. We are only returning pts in the call
@@ -102,6 +102,12 @@ void VideoLoader::set_output(Tensor *output_tensor) { | |||
_output_mem_size = ((_output_tensor->info().data_size() + 8) & ~7); // Making output size as a multiple of 8 to support vectorized load and store in RPP | |||
} | |||
|
|||
void VideoLoader::set_gpu_device_id(int device_id) { | |||
if (device_id < 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please set to 0 here as default instead