RocVideoDecoder API reference#
2026-09-23
4 min read time
The RocVideoDecoder utility class is exposed in utils/rocvideodecode/roc_video_dec.h.
-
class RocVideoDecoder#
- #include <roc_video_dec.h>
High-level video decoder utility class that wraps the rocDecode core APIs to create, control, and destroy the hardware decoder, and to decode and retrieve frames on the GPU.
Public 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, bool skip_init = false)#
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
-
inline uint32_t GetWidth()#
Get the output frame width.
-
inline int GetDecodeWidth()#
This function is used to get the actual decode width.
-
inline uint32_t GetHeight()#
Get the output frame height.
-
inline int GetChromaHeight()#
This function is used to get the current chroma height.
-
inline int GetNumChromaPlanes()#
This function is used to get the number of chroma planes.
-
inline virtual int GetFrameSize()#
This function is used to get the current frame size based on pixel format.
-
inline uint32_t GetBitDepth()#
Get the Bit Depth and BytesPerPixel associated with the pixel format.
- Returns:
uint32_t
-
inline size_t GetSurfaceSize()#
Functions to get the output surface attributes.
-
const char *GetCodecFmtName(rocDecVideoCodec codec_id)#
Get the name of the output format.
- Parameters:
codec_id –
- Returns:
std::string
-
const char *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*
-
virtual bool GetOutputSurfaceInfo(OutputSurfaceInfo **surface_info)#
Get the pointer to the Output Image Info.
- Parameters:
surface_info – ptr to output surface info
- Returns:
true
- Returns:
false
-
bool 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
- Returns:
false : fail
-
int FlushAndReconfigure()#
Function to force Reconfigure Flush: needed for random seeking to key frames.
- Returns:
int 1: Success 0: Fail
-
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 available for display
- Parameters:
data – - pointer to the data buffer that is to be decoded
size – - size of the data buffer in bytes
pts – - presentation timestamp
flags – - video packet flags
num_decoded_pics – - number of pictures decoded in this call
- Returns:
int - num of frames to display
-
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”
- Parameters:
pTimestamp – - timestamp of the frame to be released (unmapped)
b_flushing – - true when flushing
- Returns:
true - success
- Returns:
false - failed
-
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
Get the Device info for the current device
- 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
device_name –
gcn_arch_name –
pci_bus_id –
pci_domain_id –
pci_device_id –
-
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.
- 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
-
virtual void ResetSaveFrameToFile()#
Helper function to close an existing file and dump to new file in case of multiple files using same decoder.
-
inline int32_t GetNumOfFlushedFrames()#
Get the Num Of Flushed Frames from video decoder object.
- Returns:
int32_t
-
void WaitForDecodeCompletion()#
Function to wait for the decode completion of the last submitted picture.
-
bool 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
-
virtual int ReconfigureDecoder(RocdecVideoFormat *p_video_format)#
This function reconfigure decoder if there is a change in sequence params.
-
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, bool skip_init = false)#