develop/utils/rocvideodecode/roc_video_dec.h Source File#
roc_video_dec.h
Go to the documentation of this file.
65 } OutputSurfaceMemoryType;
119 explicit RocVideoDecodeException(const std::string& message, const int err_code):_message(message), _err_code(err_code) {}
120 explicit RocVideoDecodeException(const std::string& message):_message(message), _err_code(-1) {}
130 #define ROCDEC_THROW(X, CODE) throw RocVideoDecodeException(" { " + std::string(__func__) + " } " + X , CODE);
138 error_log << #rocDecAPI << " returned " << rocDecGetErrorName(error_code) << " at " <<__FILE__ <<":" << __LINE__;\
216 RocVideoDecoder(int device_id, OutputSurfaceMemoryType out_mem_type, rocDecVideoCodec codec, bool force_zero_latency = false,
217 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,
253 virtual int GetFrameSize() { assert(disp_width_); return disp_width_ * (disp_height_ + (chroma_height_ * num_chroma_planes_)) * byte_per_pixel_; }
319 virtual int DecodeFrame(const uint8_t *data, size_t size, int pkt_flags, int64_t pts = 0, int *num_decoded_pics = nullptr);
344 //void SaveImage(std::string output_file_name, void* dev_mem, OutputImageInfo* image_info, bool is_output_RGB = 0);
355 void GetDeviceinfo(std::string &device_name, std::string &gcn_arch_name, int &pci_bus_id, int &pci_domain_id, int &pci_device_id);
365 virtual void SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info, size_t rgb_image_size = 0);
384 void AddDecoderSessionOverHead(std::thread::id session_id, double duration) { session_overhead_[session_id] += duration; }
409 static int ROCDECAPI HandleVideoSequenceProc(void *p_user_data, RocdecVideoFormat *p_video_format) { return ((RocVideoDecoder *)p_user_data)->HandleVideoSequence(p_video_format); }
414 static int ROCDECAPI HandlePictureDecodeProc(void *p_user_data, RocdecPicParams *p_pic_params) { return ((RocVideoDecoder *)p_user_data)->HandlePictureDecode(p_pic_params); }
419 static int ROCDECAPI HandlePictureDisplayProc(void *p_user_data, RocdecParserDispInfo *p_disp_info) { return ((RocVideoDecoder *)p_user_data)->HandlePictureDisplay(p_disp_info); }
424 static int ROCDECAPI HandleSEIMessagesProc(void *p_user_data, RocdecSeiMessageInfo *p_sei_message_info) { return ((RocVideoDecoder *)p_user_data)->GetSEIMessage(p_sei_message_info); }
512 uint32_t surface_vstride_ = 0, chroma_vstride_ = 0; // vertical stride between planes: used when using internal dev memory
525 std::thread::id decoder_session_id_; // Decoder session identifier. Used to gather session level stats.
526 std::unordered_map<std::thread::id, double> session_overhead_; // Records session overhead of initialization+deinitialization time. Format is (thread id, duration)
Definition: roc_video_dec.h:116
Definition: roc_video_dec.h:200
virtual void ResetSaveFrameToFile()
Helper funtion to close a existing file and dump to new file in case of multiple files using same dec...
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"
int FlushAndReconfigure()
Function to force Reconfigure Flush: needed for random seeking to key frames.
void WaitForDecodeCompletion()
Function to wait for the decode completion of the last submitted picture.
int32_t GetNumOfFlushedFrames()
Get the Num Of Flushed Frames from video decoder object.
Definition: roc_video_dec.h:377
const char * GetCodecFmtName(rocDecVideoCodec codec_id)
Get the name of the output format.
uint32_t GetWidth()
Get the output frame width.
Definition: roc_video_dec.h:228
int GetNumChromaPlanes()
This function is used to get the number of chroma planes.
Definition: roc_video_dec.h:248
virtual int ReconfigureDecoder(RocdecVideoFormat *p_video_format)
This function reconfigure decoder if there is a change in sequence params.
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 displ...
Definition: roc_video_dec.h:419
int HandlePictureDisplay(RocdecParserDispInfo *p_disp_info)
This function gets called after a picture is decoded and available for display. Frames are fetched an...
int GetChromaHeight()
This function is used to get the current chroma height.
Definition: roc_video_dec.h:243
uint32_t GetHeight()
Get the output frame height.
Definition: roc_video_dec.h:238
int GetSEIMessage(RocdecSeiMessageInfo *p_sei_message_info)
This function gets called when all unregistered user SEI messages are parsed for a frame.
uint32_t GetBitDepth()
Get the Bit Depth and BytesPerPixel associated with the pixel format.
Definition: roc_video_dec.h:261
double StopTimer(const std::chrono::_V2::system_clock::time_point &start_time)
Function to get elapsed time.
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...
Definition: roc_video_dec.h:414
bool ReleaseInternalFrames()
function to release all internal frames and clear the vp_frames_q_ (used with reconfigure): Only used...
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...
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.
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
bool CodecSupported(int device_id, rocDecVideoCodec codec_id, uint32_t bit_depth)
Check if the given Video Codec is supported on the given GPU.
std::chrono::_V2::system_clock::time_point StartTimer()
Function to get start time.
virtual int GetFrameSize()
This function is used to get the current frame size based on pixel format.
Definition: roc_video_dec.h:253
const char * GetSurfaceFmtName(rocDecVideoSurfaceFormat surface_format_id)
function to return the name from surface_format_id
bool GetOutputSurfaceInfo(OutputSurfaceInfo **surface_info)
Get the pointer to the Output Image Info.
size_t GetSurfaceSize()
Functions to get the output surface attributes.
Definition: roc_video_dec.h:266
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.
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...
Definition: roc_video_dec.h:424
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
int GetDecodeWidth()
This function is used to get the actual decode width.
Definition: roc_video_dec.h:233
int HandlePictureDecode(RocdecPicParams *p_pic_params)
This function gets called when a picture is ready to be decoded. cuvidDecodePicture is called from th...
bool SetReconfigParams(ReconfigParams *p_reconfig_params, bool b_force_reconfig_flush=false)
Function to set the Reconfig Params object.
int HandleVideoSequence(RocdecVideoFormat *p_video_format)
This function gets called when a sequence is ready to be decoded. The function also gets called when ...
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.
Definition: roc_video_dec.h:409
The AMD rocDecode Library.
@ rocDecVideoSurfaceFormat_YUV444_16Bit
Definition: rocdecode.h:108
@ rocDecVideoSurfaceFormat_YUV420_16Bit
Definition: rocdecode.h:111
The AMD rocParser Library.
Definition: roc_video_dec.h:172
Definition: roc_video_dec.h:164
Definition: roc_video_dec.h:179
uint64_t output_surface_size_in_bytes
Definition: roc_video_dec.h:189
rocDecVideoSurfaceFormat surface_format
Definition: roc_video_dec.h:190
Definition: roc_video_dec.h:194
Definition: roc_video_dec.h:157
Timing Info struct\Used in rocdecParseVideoData API with PFNVIDDISPLAYCALLBACK pfn_display_picture.
Definition: rocdecode.h:1616