RocVideoDecoder Class Reference

RocVideoDecoder Class Reference#

rocDecode: RocVideoDecoder Class Reference
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.
 
int GetFrameSize ()
 This function is used to get the current frame size based on pixel format.
 
int GetFrameSizePitched ()
 This function is used to get the current frame size based on pitch.
 
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...
 
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...
 
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.
 
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...
 
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...
 
void ResetSaveFrameToFile ()
 Helper funtion to close a existing file and dump to new file in case of multiple files using same decoder.
 
void InitMd5 ()
 Helper function to start MD5 calculation.
 
void UpdateMd5ForDataBuffer (void *pDevMem, int rgb_image_size)
 
void UpdateMd5ForFrame (void *surf_mem, OutputSurfaceInfo *surf_info)
 Helper function to dump decoded output surface to file. More...
 
void FinalizeMd5 (uint8_t **digest)
 Helper function to complete MD5 calculation. More...
 
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...
 

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
hip_ctx
b_use_device_mem
codec
device_id
b_low_latency
device_frame_pitched
p_crop_rect
extract_user_SEI_Message
max_width
max_height
clk_rate
force_zero_latency

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()

int RocVideoDecoder::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

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

◆ FinalizeMd5()

void RocVideoDecoder::FinalizeMd5 ( uint8_t **  digest)

Helper function to complete MD5 calculation.

Parameters
[out]digestPointer to the 16 byte message digest

◆ FlushAndReconfigure()

int RocVideoDecoder::FlushAndReconfigure ( )

Function to force Reconfigure Flush: needed for random seeking to key frames.

Returns
int 1: Success 0: Fail

◆ GetBitDepth()

uint32_t RocVideoDecoder::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()

int32_t RocVideoDecoder::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_infoptr 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()

bool RocVideoDecoder::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"

Parameters
pTimestamp- timestamp of the frame to be released (unmapped)
b_flushing- true when flushing
Returns
true - success
false - falied

◆ SaveFrameToFile()

void RocVideoDecoder::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.

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_paramspointer to reconfig params struct
Returns
true : success
false : fail

◆ UpdateMd5ForFrame()

void RocVideoDecoder::UpdateMd5ForFrame ( void *  surf_mem,
OutputSurfaceInfo surf_info 
)

Helper function to dump decoded output surface to file.

Parameters
dev_mem- pointer to surface memory
surf_info- surface info

The documentation for this class was generated from the following file: