Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
NvDecoder Class Reference

Base class for decoder interface. More...

#include <H264DecoderNvCodecHelper.h>

Inheritance diagram for NvDecoder:
Inheritance graph
Collaboration diagram for NvDecoder:
Collaboration graph

Public Member Functions

 NvDecoder (CUcontext cuContext, int nWidth, int nHeight, bool bUseDeviceFrame, cudaVideoCodec eCodec, std::mutex *pMutex=NULL, bool bLowLatency=false, bool bDeviceFramePitched=false, const Rect *pCropRect=NULL, const Dim *pResizeDim=NULL, int maxWidth=0, int maxHeight=0)
 This function is used to initialize the decoder session. Application must call this function to initialize the decoder, before starting to decode any frames.
 
 NvDecoder ()
 
 ~NvDecoder ()
 
CUcontext GetContext ()
 This function is used to get the current CUDA context.
 
int GetWidth ()
 This function is used to get the current decode width.
 
int GetHeight ()
 This function is used to get the current decode height.
 
int GetFrameSize ()
 This function is used to get the current frame size based on pixel format.
 
int GetDeviceFramePitch ()
 This function is used to get the pitch of the device buffer holding the decoded frame.
 
int GetBitDepth ()
 This function is used to get the bit depth associated with the pixel format.
 
CUVIDEOFORMAT GetVideoFormatInfo ()
 This function is used to get information about the video stream (codec, display parameters etc)
 
std::string GetVideoInfo () const
 This function is used to print information about the video stream.
 
bool Decode (const uint8_t *pData, int nSize, uint8_t ***pppFrame, int *pnFrameReturned, uint32_t flags=0, int64_t **ppTimestamp=NULL, int64_t timestamp=0, CUstream stream=0)
 This function decodes a frame and returns frames that are available for display. The frames should be used or buffered before making subsequent calls to the Decode function again.
 
bool DecodeLockFrame (const uint8_t *pData, int nSize, uint8_t ***pppFrame, int *pnFrameReturned, uint32_t flags=0, int64_t **ppTimestamp=NULL, int64_t timestamp=0, CUstream stream=0)
 This function decodes a frame and returns the locked frame buffers This makes the buffers available for use by the application without the buffers getting overwritten, even if subsequent decode calls are made. The frame buffers remain locked, until UnlockFrame() is called.
 
void UnlockFrame (uint8_t **ppFrame, int nFrame)
 This function unlocks the frame buffer and makes the frame buffers available for write again.
 
int setReconfigParams (const Rect *pCropRect, const Dim *pResizeDim)
 This function allow app to set decoder reconfig params.
 

Private Member Functions

int HandleVideoSequence (CUVIDEOFORMAT *pVideoFormat)
 This function gets called when a sequence is ready to be decoded. The function also gets called when there is format change.
 
int HandlePictureDecode (CUVIDPICPARAMS *pPicParams)
 This function gets called when a picture is ready to be decoded. cuvidDecodePicture is called from this function to decode the picture.
 
int HandlePictureDisplay (CUVIDPARSERDISPINFO *pDispInfo)
 This function gets called after a picture is decoded and available for display. Frames are fetched and stored in internal buffer.
 
int ReconfigureDecoder (CUVIDEOFORMAT *pVideoFormat)
 This function reconfigure decoder if there is a change in sequence params.
 

Static Private Member Functions

static int CUDAAPI HandleVideoSequenceProc (void *pUserData, CUVIDEOFORMAT *pVideoFormat)
 Callback function to be registered for getting a callback when decoding of sequence starts.
 
static int CUDAAPI HandlePictureDecodeProc (void *pUserData, CUVIDPICPARAMS *pPicParams)
 Callback function to be registered for getting a callback when a decoded frame is ready to be decoded.
 
static int CUDAAPI HandlePictureDisplayProc (void *pUserData, CUVIDPARSERDISPINFO *pDispInfo)
 Callback function to be registered for getting a callback when a decoded frame is available for display.
 

Private Attributes

CUcontext m_cuContext = NULL
 
CUvideoctxlock m_ctxLock
 
std::mutex * m_pMutex
 
CUvideoparser m_hParser = NULL
 
CUvideodecoder m_hDecoder = NULL
 
bool m_bUseDeviceFrame
 
unsigned int m_nWidth = 0
 
unsigned int m_nHeight = 0
 
int m_nSurfaceHeight = 0
 
int m_nSurfaceWidth = 0
 
cudaVideoCodec m_eCodec = cudaVideoCodec_NumCodecs
 
cudaVideoChromaFormat m_eChromaFormat
 
int m_nBitDepthMinus8 = 0
 
CUVIDEOFORMAT m_videoFormat = {}
 
Rect m_displayRect = {}
 
std::vector< uint8_t * > m_vpFrame
 
std::vector< uint8_t * > m_vpFrameRet
 
std::vector< int64_t > m_vTimestamp
 
int m_nDecodedFrame = 0
 
int m_nDecodedFrameReturned = 0
 
int m_nDecodePicCnt = 0
 
int m_nPicNumInDecodeOrder [32]
 
bool m_bEndDecodeDone = false
 
std::mutex m_mtxVPFrame
 
int m_nFrameAlloc = 0
 
CUstream m_cuvidStream = 0
 
bool m_bDeviceFramePitched = false
 
size_t m_nDeviceFramePitch = 0
 
Rect m_cropRect = {}
 
Dim m_resizeDim = {}
 
std::ostringstream m_videoInfo
 
unsigned int m_nMaxWidth = 0
 
unsigned int m_nMaxHeight = 0
 
bool m_bReconfigExternal = false
 
bool m_bReconfigExtPPChange = false
 

Detailed Description

Base class for decoder interface.

Constructor & Destructor Documentation

◆ NvDecoder() [1/2]

NvDecoder::NvDecoder ( CUcontext cuContext,
int nWidth,
int nHeight,
bool bUseDeviceFrame,
cudaVideoCodec eCodec,
std::mutex * pMutex = NULL,
bool bLowLatency = false,
bool bDeviceFramePitched = false,
const Rect * pCropRect = NULL,
const Dim * pResizeDim = NULL,
int maxWidth = 0,
int maxHeight = 0 )

This function is used to initialize the decoder session. Application must call this function to initialize the decoder, before starting to decode any frames.

Here is the call graph for this function:

◆ NvDecoder() [2/2]

NvDecoder::NvDecoder ( )
inline
Here is the caller graph for this function:

◆ ~NvDecoder()

NvDecoder::~NvDecoder ( )

Member Function Documentation

◆ Decode()

bool NvDecoder::Decode ( const uint8_t * pData,
int nSize,
uint8_t *** pppFrame,
int * pnFrameReturned,
uint32_t flags = 0,
int64_t ** ppTimestamp = NULL,
int64_t timestamp = 0,
CUstream stream = 0 )

This function decodes a frame and returns frames that are available for display. The frames should be used or buffered before making subsequent calls to the Decode function again.

Here is the caller graph for this function:

◆ DecodeLockFrame()

bool NvDecoder::DecodeLockFrame ( const uint8_t * pData,
int nSize,
uint8_t *** pppFrame,
int * pnFrameReturned,
uint32_t flags = 0,
int64_t ** ppTimestamp = NULL,
int64_t timestamp = 0,
CUstream stream = 0 )

This function decodes a frame and returns the locked frame buffers This makes the buffers available for use by the application without the buffers getting overwritten, even if subsequent decode calls are made. The frame buffers remain locked, until UnlockFrame() is called.

Here is the call graph for this function:

◆ GetBitDepth()

int NvDecoder::GetBitDepth ( )
inline

This function is used to get the bit depth associated with the pixel format.

◆ GetContext()

CUcontext NvDecoder::GetContext ( )
inline

This function is used to get the current CUDA context.

◆ GetDeviceFramePitch()

int NvDecoder::GetDeviceFramePitch ( )
inline

This function is used to get the pitch of the device buffer holding the decoded frame.

◆ GetFrameSize()

int NvDecoder::GetFrameSize ( )
inline

This function is used to get the current frame size based on pixel format.

Here is the caller graph for this function:

◆ GetHeight()

int NvDecoder::GetHeight ( )
inline

This function is used to get the current decode height.

◆ GetVideoFormatInfo()

CUVIDEOFORMAT NvDecoder::GetVideoFormatInfo ( )
inline

This function is used to get information about the video stream (codec, display parameters etc)

◆ GetVideoInfo()

std::string NvDecoder::GetVideoInfo ( ) const
inline

This function is used to print information about the video stream.

◆ GetWidth()

int NvDecoder::GetWidth ( )
inline

This function is used to get the current decode width.

◆ HandlePictureDecode()

int NvDecoder::HandlePictureDecode ( CUVIDPICPARAMS * pPicParams)
private

This function gets called when a picture is ready to be decoded. cuvidDecodePicture is called from this function to decode the picture.

◆ HandlePictureDecodeProc()

static int CUDAAPI NvDecoder::HandlePictureDecodeProc ( void * pUserData,
CUVIDPICPARAMS * pPicParams )
inlinestaticprivate

Callback function to be registered for getting a callback when a decoded frame is ready to be decoded.

Here is the caller graph for this function:

◆ HandlePictureDisplay()

int NvDecoder::HandlePictureDisplay ( CUVIDPARSERDISPINFO * pDispInfo)
private

This function gets called after a picture is decoded and available for display. Frames are fetched and stored in internal buffer.

Here is the call graph for this function:

◆ HandlePictureDisplayProc()

static int CUDAAPI NvDecoder::HandlePictureDisplayProc ( void * pUserData,
CUVIDPARSERDISPINFO * pDispInfo )
inlinestaticprivate

Callback function to be registered for getting a callback when a decoded frame is available for display.

Here is the caller graph for this function:

◆ HandleVideoSequence()

int NvDecoder::HandleVideoSequence ( CUVIDEOFORMAT * pVideoFormat)
private

This function gets called when a sequence is ready to be decoded. The function also gets called when there is format change.

◆ HandleVideoSequenceProc()

static int CUDAAPI NvDecoder::HandleVideoSequenceProc ( void * pUserData,
CUVIDEOFORMAT * pVideoFormat )
inlinestaticprivate

Callback function to be registered for getting a callback when decoding of sequence starts.

Here is the caller graph for this function:

◆ ReconfigureDecoder()

int NvDecoder::ReconfigureDecoder ( CUVIDEOFORMAT * pVideoFormat)
private

This function reconfigure decoder if there is a change in sequence params.

◆ setReconfigParams()

int NvDecoder::setReconfigParams ( const Rect * pCropRect,
const Dim * pResizeDim )

This function allow app to set decoder reconfig params.

◆ UnlockFrame()

void NvDecoder::UnlockFrame ( uint8_t ** ppFrame,
int nFrame )

This function unlocks the frame buffer and makes the frame buffers available for write again.

Member Data Documentation

◆ m_bDeviceFramePitched

bool NvDecoder::m_bDeviceFramePitched = false
private

◆ m_bEndDecodeDone

bool NvDecoder::m_bEndDecodeDone = false
private

◆ m_bReconfigExternal

bool NvDecoder::m_bReconfigExternal = false
private

◆ m_bReconfigExtPPChange

bool NvDecoder::m_bReconfigExtPPChange = false
private

◆ m_bUseDeviceFrame

bool NvDecoder::m_bUseDeviceFrame
private

◆ m_cropRect

Rect NvDecoder::m_cropRect = {}
private

◆ m_ctxLock

CUvideoctxlock NvDecoder::m_ctxLock
private

◆ m_cuContext

CUcontext NvDecoder::m_cuContext = NULL
private

◆ m_cuvidStream

CUstream NvDecoder::m_cuvidStream = 0
private

◆ m_displayRect

Rect NvDecoder::m_displayRect = {}
private

◆ m_eChromaFormat

cudaVideoChromaFormat NvDecoder::m_eChromaFormat
private

◆ m_eCodec

cudaVideoCodec NvDecoder::m_eCodec = cudaVideoCodec_NumCodecs
private

◆ m_hDecoder

CUvideodecoder NvDecoder::m_hDecoder = NULL
private

◆ m_hParser

CUvideoparser NvDecoder::m_hParser = NULL
private

◆ m_mtxVPFrame

std::mutex NvDecoder::m_mtxVPFrame
private

◆ m_nBitDepthMinus8

int NvDecoder::m_nBitDepthMinus8 = 0
private

◆ m_nDecodedFrame

int NvDecoder::m_nDecodedFrame = 0
private

◆ m_nDecodedFrameReturned

int NvDecoder::m_nDecodedFrameReturned = 0
private

◆ m_nDecodePicCnt

int NvDecoder::m_nDecodePicCnt = 0
private

◆ m_nDeviceFramePitch

size_t NvDecoder::m_nDeviceFramePitch = 0
private

◆ m_nFrameAlloc

int NvDecoder::m_nFrameAlloc = 0
private

◆ m_nHeight

unsigned int NvDecoder::m_nHeight = 0
private

◆ m_nMaxHeight

unsigned int NvDecoder::m_nMaxHeight = 0
private

◆ m_nMaxWidth

unsigned int NvDecoder::m_nMaxWidth = 0
private

◆ m_nPicNumInDecodeOrder

int NvDecoder::m_nPicNumInDecodeOrder[32]
private

◆ m_nSurfaceHeight

int NvDecoder::m_nSurfaceHeight = 0
private

◆ m_nSurfaceWidth

int NvDecoder::m_nSurfaceWidth = 0
private

◆ m_nWidth

unsigned int NvDecoder::m_nWidth = 0
private

◆ m_pMutex

std::mutex* NvDecoder::m_pMutex
private

◆ m_resizeDim

Dim NvDecoder::m_resizeDim = {}
private

◆ m_videoFormat

CUVIDEOFORMAT NvDecoder::m_videoFormat = {}
private

◆ m_videoInfo

std::ostringstream NvDecoder::m_videoInfo
private

◆ m_vpFrame

std::vector<uint8_t*> NvDecoder::m_vpFrame
private

◆ m_vpFrameRet

std::vector<uint8_t*> NvDecoder::m_vpFrameRet
private

◆ m_vTimestamp

std::vector<int64_t> NvDecoder::m_vTimestamp
private

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