Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
H264EncoderNVCodecHelper::Detail Class Reference
Collaboration diagram for H264EncoderNVCodecHelper::Detail:
Collaboration graph

Public Member Functions

 Detail (uint32_t &bitRateKbps, apracucontext_sp &cuContext, uint32_t &gopLength, uint32_t &frameRate, H264EncoderNVCodecProps::H264CodecProfile profile, bool enableBFrames, uint32_t &bufferThres)
 
bool init (uint32_t width, uint32_t height, uint32_t pitch, ImageMetadata::ImageType imageType, std::function< frame_sp(size_t)> _makeFrame, std::function< void(frame_sp &, frame_sp &)> _send)
 
bool encode (frame_sp &frame)
 
void endEncode ()
 
bool getSPSPPS (void *&buffer, size_t &size, int &width, int &height)
 
 ~Detail ()
 

Private Member Functions

void unload ()
 
void createDefaultEncoderParams (NV_ENC_INITIALIZE_PARAMS *pIntializeParams)
 
int GetCapabilityValue (GUID guidCodec, NV_ENC_CAPS capsToQuery)
 
void initializeEncoder ()
 
NV_ENC_REGISTERED_PTR RegisterResource (void *pBuffer, NV_ENC_INPUT_RESOURCE_TYPE eResourceType, int width, int height, int pitch, NV_ENC_BUFFER_FORMAT bufferFormat, NV_ENC_BUFFER_USAGE bufferUsage)
 
void processOutput ()
 
bool is_not_empty () const
 Checks if there are free output bitstreams available and allocates more if needed.
 
bool is_output_available () const
 Checks if there are any busy output bitstreams or if the encoder is not running.
 
void doubleOutputBuffers (uint32_t bufferLength) const
 Allocates additional output bitstream buffers.
 

Static Private Member Functions

static GUID asNvidiaGUID (H264EncoderNVCodecProps::H264CodecProfile profileEnum)
 

Private Attributes

std::thread m_thread
 
bool m_bRunning
 
uint32_t m_nWidth
 
uint32_t m_nHeight
 
uint32_t m_nPitch
 
NV_ENC_BUFFER_FORMAT m_eBufferFormat
 
uint32_t m_nBitRateKbps
 
uint32_t m_nGopLength
 
uint32_t m_nFrameRate
 
H264EncoderNVCodecProps::H264CodecProfile m_nProfile
 
bool m_bEnableBFrames
 
uint32_t m_nBufferThres
 
NV_ENC_INITIALIZE_PARAMS m_initializeParams
 
NV_ENC_CONFIG m_encodeConfig
 
int32_t m_nEncoderBuffer
 
NV_ENC_CAPS_PARAM m_nencodeParam
 
std::function< frame_sp(size_t)> makeFrame
 
std::function< void(frame_sp &, frame_sp &)> send
 
frame_sp m_spsppsFrame
 
NV_ENC_SEQUENCE_PARAM_PAYLOAD m_spsppsPayload
 
uint32_t m_nOutSPSPPSPayloadSize
 
boost::shared_ptr< H264EncoderNVCodecPropsmProps
 
boost::shared_ptr< NVCodecResourcesm_nvcodecResources
 

Constructor & Destructor Documentation

◆ Detail()

H264EncoderNVCodecHelper::Detail::Detail ( uint32_t & bitRateKbps,
apracucontext_sp & cuContext,
uint32_t & gopLength,
uint32_t & frameRate,
H264EncoderNVCodecProps::H264CodecProfile profile,
bool enableBFrames,
uint32_t & bufferThres )
inline

◆ ~Detail()

H264EncoderNVCodecHelper::Detail::~Detail ( )
inline
Here is the call graph for this function:

Member Function Documentation

◆ asNvidiaGUID()

static GUID H264EncoderNVCodecHelper::Detail::asNvidiaGUID ( H264EncoderNVCodecProps::H264CodecProfile profileEnum)
inlinestaticprivate
Here is the caller graph for this function:

◆ createDefaultEncoderParams()

void H264EncoderNVCodecHelper::Detail::createDefaultEncoderParams ( NV_ENC_INITIALIZE_PARAMS * pIntializeParams)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doubleOutputBuffers()

void H264EncoderNVCodecHelper::Detail::doubleOutputBuffers ( uint32_t bufferLength) const
inlineprivate

Allocates additional output bitstream buffers.

This function allocates a specified number of additional output bitstream buffers and adds them to the encoder buffer. It uses the NVIDIA Video Codec SDK to create the bitstream buffers and updates the internal queue of output bitstreams.

Parameters
bufferLengthThe number of additional output bitstream buffers to allocate.
Note
This function is called internally by is_not_empty when more buffers are needed.
Warning
Ensure that the NVIDIA Video Codec SDK is properly initialized before calling this function.
Here is the caller graph for this function:

◆ encode()

bool H264EncoderNVCodecHelper::Detail::encode ( frame_sp & frame)
inline
Here is the call graph for this function:

◆ endEncode()

void H264EncoderNVCodecHelper::Detail::endEncode ( )
inline

◆ GetCapabilityValue()

int H264EncoderNVCodecHelper::Detail::GetCapabilityValue ( GUID guidCodec,
NV_ENC_CAPS capsToQuery )
inlineprivate
Here is the caller graph for this function:

◆ getSPSPPS()

bool H264EncoderNVCodecHelper::Detail::getSPSPPS ( void *& buffer,
size_t & size,
int & width,
int & height )
inline

◆ init()

bool H264EncoderNVCodecHelper::Detail::init ( uint32_t width,
uint32_t height,
uint32_t pitch,
ImageMetadata::ImageType imageType,
std::function< frame_sp(size_t)> _makeFrame,
std::function< void(frame_sp &, frame_sp &)> _send )
inline
Here is the call graph for this function:

◆ initializeEncoder()

void H264EncoderNVCodecHelper::Detail::initializeEncoder ( )
inlineprivate
Here is the caller graph for this function:

◆ is_not_empty()

bool H264EncoderNVCodecHelper::Detail::is_not_empty ( ) const
inlineprivate

Checks if there are free output bitstreams available and allocates more if needed.

This function checks the availability of free output bitstreams. If there are no free output bitstreams and the number of busy streams is below a predefined threshold, it allocates additional output bitstreams to the encoder buffer.

The function first checks the number of busy output bitstreams. If there are no free output bitstreams and the number of busy streams is below m_nBufferThres, it calculates the buffer length to be allocated and doubles the output buffers by calling doubleOutputBuffers. It then logs the allocation and increments the count of free output bitstreams. If there are free output bitstreams, it logs a message indicating the current state.

Returns
true if there are free output bitstreams available, false otherwise.
Note
This function modifies the state of m_nvcodecResources->m_nFreeOutputBitstreams.
Warning
Ensure thread safety when calling this function in a multi-threaded environment.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_output_available()

bool H264EncoderNVCodecHelper::Detail::is_output_available ( ) const
inlineprivate

Checks if there are any busy output bitstreams or if the encoder is not running.

This function returns true if there are any busy output bitstreams or if the encoder is not running. It helps determine if there are any output bitstreams currently being processed or if the encoding process has stopped.

Returns
true if there are busy output bitstreams or the encoder is not running, false otherwise.
Note
This function does not modify any state.
Here is the caller graph for this function:

◆ processOutput()

void H264EncoderNVCodecHelper::Detail::processOutput ( )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterResource()

NV_ENC_REGISTERED_PTR H264EncoderNVCodecHelper::Detail::RegisterResource ( void * pBuffer,
NV_ENC_INPUT_RESOURCE_TYPE eResourceType,
int width,
int height,
int pitch,
NV_ENC_BUFFER_FORMAT bufferFormat,
NV_ENC_BUFFER_USAGE bufferUsage )
inlineprivate
Here is the caller graph for this function:

◆ unload()

void H264EncoderNVCodecHelper::Detail::unload ( )
inlineprivate
Here is the caller graph for this function:

Member Data Documentation

◆ m_bEnableBFrames

bool H264EncoderNVCodecHelper::Detail::m_bEnableBFrames
private

◆ m_bRunning

bool H264EncoderNVCodecHelper::Detail::m_bRunning
private

◆ m_eBufferFormat

NV_ENC_BUFFER_FORMAT H264EncoderNVCodecHelper::Detail::m_eBufferFormat
private

◆ m_encodeConfig

NV_ENC_CONFIG H264EncoderNVCodecHelper::Detail::m_encodeConfig
private

◆ m_initializeParams

NV_ENC_INITIALIZE_PARAMS H264EncoderNVCodecHelper::Detail::m_initializeParams
private

◆ m_nBitRateKbps

uint32_t H264EncoderNVCodecHelper::Detail::m_nBitRateKbps
private

◆ m_nBufferThres

uint32_t H264EncoderNVCodecHelper::Detail::m_nBufferThres
private

◆ m_nencodeParam

NV_ENC_CAPS_PARAM H264EncoderNVCodecHelper::Detail::m_nencodeParam
private

◆ m_nEncoderBuffer

int32_t H264EncoderNVCodecHelper::Detail::m_nEncoderBuffer
private

◆ m_nFrameRate

uint32_t H264EncoderNVCodecHelper::Detail::m_nFrameRate
private

◆ m_nGopLength

uint32_t H264EncoderNVCodecHelper::Detail::m_nGopLength
private

◆ m_nHeight

uint32_t H264EncoderNVCodecHelper::Detail::m_nHeight
private

◆ m_nOutSPSPPSPayloadSize

uint32_t H264EncoderNVCodecHelper::Detail::m_nOutSPSPPSPayloadSize
private

◆ m_nPitch

uint32_t H264EncoderNVCodecHelper::Detail::m_nPitch
private

◆ m_nProfile

H264EncoderNVCodecProps::H264CodecProfile H264EncoderNVCodecHelper::Detail::m_nProfile
private

◆ m_nvcodecResources

boost::shared_ptr<NVCodecResources> H264EncoderNVCodecHelper::Detail::m_nvcodecResources
private

◆ m_nWidth

uint32_t H264EncoderNVCodecHelper::Detail::m_nWidth
private

◆ m_spsppsFrame

frame_sp H264EncoderNVCodecHelper::Detail::m_spsppsFrame
private

◆ m_spsppsPayload

NV_ENC_SEQUENCE_PARAM_PAYLOAD H264EncoderNVCodecHelper::Detail::m_spsppsPayload
private

◆ m_thread

std::thread H264EncoderNVCodecHelper::Detail::m_thread
private

◆ makeFrame

std::function<frame_sp(size_t)> H264EncoderNVCodecHelper::Detail::makeFrame
private

◆ mProps

boost::shared_ptr<H264EncoderNVCodecProps> H264EncoderNVCodecHelper::Detail::mProps
private

◆ send

std::function<void(frame_sp&, frame_sp&)> H264EncoderNVCodecHelper::Detail::send
private

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