RocVideoDecoder Class Reference#
Public Member Functions | |
RocVideoDecoder (int device_id, OutputSurfaceMemoryType out_mem_type, rocDecVideoCodec codec, bool force_zero_latency=false, const Rect *p_crop_rect=nullptr, bool extract_user_SEI_Message=false, uint32_t disp_delay=0, int max_width=0, int max_height=0, uint32_t clk_rate=1000) | |
Construct a new Roc Video Decoder object. More... | |
rocDecVideoCodec | GetCodecId () |
hipStream_t | GetStream () |
uint32_t | GetWidth () |
Get the output frame width. | |
int | GetDecodeWidth () |
This function is used to get the actual decode width. | |
uint32_t | GetHeight () |
Get the output frame height. | |
int | GetChromaHeight () |
This function is used to get the current chroma height. | |
int | GetNumChromaPlanes () |
This function is used to get the number of chroma planes. | |
virtual int | GetFrameSize () |
This function is used to get the current frame size based on pixel format. | |
uint32_t | GetBitDepth () |
Get the Bit Depth and BytesPerPixel associated with the pixel format. More... | |
uint32_t | GetBytePerPixel () |
size_t | GetSurfaceSize () |
Functions to get the output surface attributes. | |
uint32_t | GetSurfaceStride () |
const char * | GetCodecFmtName (rocDecVideoCodec codec_id) |
Get the name of the output format. More... | |
const char * | GetSurfaceFmtName (rocDecVideoSurfaceFormat surface_format_id) |
function to return the name from surface_format_id More... | |
bool | GetOutputSurfaceInfo (OutputSurfaceInfo **surface_info) |
Get the pointer to the Output Image Info. More... | |
bool | SetReconfigParams (ReconfigParams *p_reconfig_params, bool b_force_reconfig_flush=false) |
Function to set the Reconfig Params object. More... | |
int | FlushAndReconfigure () |
Function to force Reconfigure Flush: needed for random seeking to key frames. More... | |
virtual int | DecodeFrame (const uint8_t *data, size_t size, int pkt_flags, int64_t pts=0, int *num_decoded_pics=nullptr) |
this function decodes a frame and returns the number of frames avalable for display More... | |
virtual uint8_t * | GetFrame (int64_t *pts) |
This function returns a decoded frame and timestamp. This should be called in a loop fetching all the available frames. | |
virtual bool | ReleaseFrame (int64_t pTimestamp, bool b_flushing=false) |
function to release frame after use by the application: Only used with "OUT_SURFACE_MEM_DEV_INTERNAL" More... | |
void | GetDeviceinfo (std::string &device_name, std::string &gcn_arch_name, int &pci_bus_id, int &pci_domain_id, int &pci_device_id) |
utility function to save image to a file More... | |
virtual void | SaveFrameToFile (std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info, size_t rgb_image_size=0) |
Helper function to dump decoded output surface to file. More... | |
virtual void | ResetSaveFrameToFile () |
Helper funtion to close a existing file and dump to new file in case of multiple files using same decoder. | |
int32_t | GetNumOfFlushedFrames () |
Get the Num Of Flushed Frames from video decoder object. More... | |
void | WaitForDecodeCompletion () |
Function to wait for the decode completion of the last submitted picture. | |
void | AddDecoderSessionOverHead (std::thread::id session_id, double duration) |
double | GetDecoderSessionOverHead (std::thread::id session_id) |
bool | CodecSupported (int device_id, rocDecVideoCodec codec_id, uint32_t bit_depth) |
Check if the given Video Codec is supported on the given GPU. More... | |
virtual int | ReconfigureDecoder (RocdecVideoFormat *p_video_format) |
This function reconfigure decoder if there is a change in sequence params. | |
Protected Member Functions | |
int | HandleVideoSequence (RocdecVideoFormat *p_video_format) |
This function gets called when a sequence is ready to be decoded. The function also gets called when there is format change. | |
int | HandlePictureDecode (RocdecPicParams *p_pic_params) |
This function gets called when a picture is ready to be decoded. cuvidDecodePicture is called from this function to decode the picture. | |
int | HandlePictureDisplay (RocdecParserDispInfo *p_disp_info) |
This function gets called after a picture is decoded and available for display. Frames are fetched and stored in internal buffer. | |
int | GetSEIMessage (RocdecSeiMessageInfo *p_sei_message_info) |
This function gets called when all unregistered user SEI messages are parsed for a frame. | |
bool | ReleaseInternalFrames () |
function to release all internal frames and clear the vp_frames_q_ (used with reconfigure): Only used with "OUT_SURFACE_MEM_DEV_INTERNAL" More... | |
bool | InitHIP (int device_id) |
Function to Initialize GPU-HIP. | |
std::chrono::_V2::system_clock::time_point | StartTimer () |
Function to get start time. | |
double | StopTimer (const std::chrono::_V2::system_clock::time_point &start_time) |
Function to get elapsed time. | |
Static Protected Member Functions | |
static int ROCDECAPI | HandleVideoSequenceProc (void *p_user_data, RocdecVideoFormat *p_video_format) |
Callback function to be registered for getting a callback when decoding of sequence starts. | |
static int ROCDECAPI | HandlePictureDecodeProc (void *p_user_data, RocdecPicParams *p_pic_params) |
Callback function to be registered for getting a callback when a decoded frame is ready to be decoded. | |
static int ROCDECAPI | HandlePictureDisplayProc (void *p_user_data, RocdecParserDispInfo *p_disp_info) |
Callback function to be registered for getting a callback when a decoded frame is available for display. | |
static int ROCDECAPI | HandleSEIMessagesProc (void *p_user_data, RocdecSeiMessageInfo *p_sei_message_info) |
Callback function to be registered for getting a callback when all the unregistered user SEI Messages are parsed for a frame. | |
Protected Attributes | |
int | num_devices_ |
int | device_id_ |
RocdecVideoParser | rocdec_parser_ = nullptr |
rocDecDecoderHandle | roc_decoder_ = nullptr |
OutputSurfaceMemoryType | out_mem_type_ = OUT_SURFACE_MEM_DEV_INTERNAL |
bool | b_extract_sei_message_ = false |
bool | b_force_zero_latency_ = false |
uint32_t | disp_delay_ |
ReconfigParams * | p_reconfig_params_ = nullptr |
bool | b_force_recofig_flush_ = false |
int32_t | num_frames_flushed_during_reconfig_ = 0 |
hipDeviceProp_t | hip_dev_prop_ |
hipStream_t | hip_stream_ |
rocDecVideoCodec | codec_id_ = rocDecVideoCodec_NumCodecs |
rocDecVideoChromaFormat | video_chroma_format_ = rocDecVideoChromaFormat_420 |
rocDecVideoSurfaceFormat | video_surface_format_ = rocDecVideoSurfaceFormat_NV12 |
RocdecSeiMessageInfo * | curr_sei_message_ptr_ = nullptr |
RocdecSeiMessageInfo | sei_message_display_q_ [MAX_FRAME_NUM] |
RocdecVideoFormat * | curr_video_format_ptr_ = nullptr |
int | output_frame_cnt_ = 0 |
int | output_frame_cnt_ret_ = 0 |
int | decoded_pic_cnt_ = 0 |
int | decode_poc_ = 0 |
int | pic_num_in_dec_order_ [MAX_FRAME_NUM] |
int | num_alloced_frames_ = 0 |
int | last_decode_surf_idx_ = 0 |
std::ostringstream | input_video_info_str_ |
int | bitdepth_minus_8_ = 0 |
uint32_t | byte_per_pixel_ = 1 |
uint32_t | coded_width_ = 0 |
uint32_t | disp_width_ = 0 |
uint32_t | coded_height_ = 0 |
uint32_t | disp_height_ = 0 |
uint32_t | target_width_ = 0 |
uint32_t | target_height_ = 0 |
int | max_width_ = 0 |
int | max_height_ = 0 |
uint32_t | chroma_height_ = 0 |
uint32_t | chroma_width_ = 0 |
uint32_t | num_chroma_planes_ = 0 |
uint32_t | num_components_ = 0 |
uint32_t | surface_stride_ = 0 |
uint32_t | surface_vstride_ = 0 |
uint32_t | chroma_vstride_ = 0 |
size_t | surface_size_ = 0 |
OutputSurfaceInfo | output_surface_info_ = {} |
std::mutex | mtx_vp_frame_ |
std::vector< DecFrameBuffer > | vp_frames_ |
std::queue< DecFrameBuffer > | vp_frames_q_ |
Rect | disp_rect_ = {} |
Rect | crop_rect_ = {} |
FILE * | fp_sei_ = NULL |
FILE * | fp_out_ = NULL |
bool | is_decoder_reconfigured_ = false |
std::string | current_output_filename = "" |
uint32_t | extra_output_file_count_ = 0 |
std::thread::id | decoder_session_id_ |
std::unordered_map< std::thread::id, double > | session_overhead_ |
Constructor & Destructor Documentation
◆ RocVideoDecoder()
RocVideoDecoder::RocVideoDecoder | ( | int | device_id, |
OutputSurfaceMemoryType | out_mem_type, | ||
rocDecVideoCodec | codec, | ||
bool | force_zero_latency = false , |
||
const Rect * | p_crop_rect = nullptr , |
||
bool | extract_user_SEI_Message = false , |
||
uint32_t | disp_delay = 0 , |
||
int | max_width = 0 , |
||
int | max_height = 0 , |
||
uint32_t | clk_rate = 1000 |
||
) |
Construct a new Roc Video Decoder object.
- Parameters
-
device_id : device_id to initialize HIP and VCN out_mem_type : out_mem_type for the decoded surface codec : codec type force_zero_latency : to force zero latency (output in decoding orde) p_crop_rect : to crop output extract_user_SEI_Message : enable to extract SEI disp_delay : output delayed by #disp_delay surfaces max_width : Max. width for the output surface max_height : Max. height for the output surface clk_rate : FPS clock-rate
Member Function Documentation
◆ CodecSupported()
bool RocVideoDecoder::CodecSupported | ( | int | device_id, |
rocDecVideoCodec | codec_id, | ||
uint32_t | bit_depth | ||
) |
Check if the given Video Codec is supported on the given GPU.
- Returns
- rocDecStatus
◆ DecodeFrame()
|
virtual |
this function decodes a frame and returns the number of frames avalable for display
- Parameters
-
data - pointer to the data buffer that is to be decode size - size of the data buffer in bytes pts - presentation timestamp flags - video packet flags num_decoded_pics - nummber of pictures decoded in this call
- Returns
- int - num of frames to display
◆ FlushAndReconfigure()
int RocVideoDecoder::FlushAndReconfigure | ( | ) |
Function to force Reconfigure Flush: needed for random seeking to key frames.
- Returns
- int 1: Success 0: Fail
◆ GetBitDepth()
|
inline |
Get the Bit Depth and BytesPerPixel associated with the pixel format.
- Returns
- uint32_t
◆ GetCodecFmtName()
const char* RocVideoDecoder::GetCodecFmtName | ( | rocDecVideoCodec | codec_id | ) |
Get the name of the output format.
- Parameters
-
codec_id
- Returns
- std::string
◆ GetDeviceinfo()
void RocVideoDecoder::GetDeviceinfo | ( | std::string & | device_name, |
std::string & | gcn_arch_name, | ||
int & | pci_bus_id, | ||
int & | pci_domain_id, | ||
int & | pci_device_id | ||
) |
utility function to save image to a file
- Parameters
-
output_file_name - file to write dev_mem - dev_memory pointer of the frame image_info - output image info is_output_RGB - to write in RGB
Get the Device info for the current device
- Parameters
-
device_name gcn_arch_name pci_bus_id pci_domain_id pci_device_id
◆ GetNumOfFlushedFrames()
|
inline |
Get the Num Of Flushed Frames from video decoder object.
- Returns
- int32_t
◆ GetOutputSurfaceInfo()
bool RocVideoDecoder::GetOutputSurfaceInfo | ( | OutputSurfaceInfo ** | surface_info | ) |
Get the pointer to the Output Image Info.
- Parameters
-
surface_info ptr to output surface info
- Returns
- true
- false
◆ GetSurfaceFmtName()
const char* RocVideoDecoder::GetSurfaceFmtName | ( | rocDecVideoSurfaceFormat | surface_format_id | ) |
function to return the name from surface_format_id
- Parameters
-
surface_format_id - enum for surface format
- Returns
- const char*
◆ ReleaseFrame()
|
virtual |
function to release frame after use by the application: Only used with "OUT_SURFACE_MEM_DEV_INTERNAL"
- Parameters
-
pTimestamp - timestamp of the frame to be released (unmapped) b_flushing - true when flushing
- Returns
- true - success
- false - falied
◆ ReleaseInternalFrames()
|
protected |
function to release all internal frames and clear the vp_frames_q_ (used with reconfigure): Only used with "OUT_SURFACE_MEM_DEV_INTERNAL"
- Returns
- true - success
- false - falied
◆ SaveFrameToFile()
|
virtual |
Helper function to dump decoded output surface to file.
- Parameters
-
output_file_name - Output file name dev_mem - pointer to surface memory surf_info - surface info 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
◆ SetReconfigParams()
bool RocVideoDecoder::SetReconfigParams | ( | ReconfigParams * | p_reconfig_params, |
bool | b_force_reconfig_flush = false |
||
) |
Function to set the Reconfig Params object.
- Parameters
-
p_reconfig_params pointer to reconfig params struct
- Returns
- true : success
- false : fail
The documentation for this class was generated from the following file:
- latest/utils/rocvideodecode/roc_video_dec.h