![]() |
NVIDIA DRIVE OS Linux SDK API Reference5.1.6.0 Release |
The NvMediaIEP object takes uncompressed image data and turns it into a codec specific bitstream.
Only H.264, H.265 and VP9 encoding is supported.
Data Structures | |
struct | NvMediaIEP |
Holds the image encoder object created by NvMediaIEPCreate. More... | |
Macros | |
#define | NVMEDIA_IEP_VERSION_MAJOR 2 |
Major Version number. More... | |
#define | NVMEDIA_IEP_VERSION_MINOR 6 |
Minor Version number. More... | |
Enumerations | |
enum | NvMediaIEPType { NVMEDIA_IMAGE_ENCODE_H264, NVMEDIA_IMAGE_ENCODE_HEVC, NVMEDIA_IMAGE_ENCODE_VP9, NVMEDIA_IMAGE_ENCODE_VP8 } |
Image encode type. More... | |
Functions | |
NvMediaStatus | NvMediaIEPGetVersion (NvMediaVersion *version) |
Checks the version compatibility for the NvMedia IEP library. More... | |
NvMediaIEP * | NvMediaIEPCreate (const NvMediaDevice *device, NvMediaIEPType encodeType, void *initParams, NvMediaSurfaceType inputFormat, uint8_t maxInputBuffering, uint8_t maxOutputBuffering, NvMediaEncoderInstanceId instanceId) |
Creates an encoder object capable of turning a stream of surfaces of the "inputFormat" into a bitstream of the specified "codec". More... | |
void | NvMediaIEPDestroy (const NvMediaIEP *encoder) |
Destroys an NvMedia image encoder. More... | |
NvMediaStatus | NvMediaIEPFeedFrame (const NvMediaIEP *encoder, NvMediaImage *frame, const NvMediaRect *sourceRect, void *picParams, NvMediaEncoderInstanceId instanceId) |
Encodes the specified frame. More... | |
NvMediaStatus | NvMediaIEPSetConfiguration (const NvMediaIEP *encoder, void *configuration) |
Sets the encoder configuration. More... | |
NvMediaStatus | NvMediaIEPGetBitsEx (const NvMediaIEP *encoder, uint32_t *numBytes, uint32_t numBitstreamBuffers, NvMediaBitstreamBuffer *bitstreams, void *extradata) |
Returns the bitstream for a slice or frame. More... | |
NvMediaStatus | NvMediaIEPBitsAvailable (const NvMediaIEP *encoder, uint32_t *numBytesAvailable, NvMediaBlockingType blockingType, uint32_t millisecondTimeout) |
Returns the encode status and number of bytes available for the next frame (if any). More... | |
NvMediaStatus | NvMediaIEPGetAttribute (const NvMediaIEP *encoder, NvMediaEncAttrType attrType, uint32_t attrSize, void *AttributeData) |
Gets the encoder attribute for the current encoding session. More... | |
#define NVMEDIA_IEP_VERSION_MAJOR 2 |
Major Version number.
Definition at line 38 of file nvmedia_iep.h.
#define NVMEDIA_IEP_VERSION_MINOR 6 |
Minor Version number.
Definition at line 40 of file nvmedia_iep.h.
enum NvMediaIEPType |
Image encode type.
Enumerator | |
---|---|
NVMEDIA_IMAGE_ENCODE_H264 |
H.264 encode. |
NVMEDIA_IMAGE_ENCODE_HEVC | |
NVMEDIA_IMAGE_ENCODE_VP9 | |
NVMEDIA_IMAGE_ENCODE_VP8 |
Definition at line 45 of file nvmedia_iep.h.
NvMediaStatus NvMediaIEPBitsAvailable | ( | const NvMediaIEP * | encoder, |
uint32_t * | numBytesAvailable, | ||
NvMediaBlockingType | blockingType, | ||
uint32_t | millisecondTimeout | ||
) |
Returns the encode status and number of bytes available for the next frame (if any).
The specific behavior depends on the specified NvMediaBlockingType. It is safe to call this function from a separate thread.
[in] | encoder | The encoder to use. |
[in] | numBytesAvailable | The number of bytes available in the next encoded frame. This is valid only when the return value is NVMEDIA_STATUS_OK. |
[in] | blockingType | Blocking type. The following are supported blocking types: NVMEDIA_ENCODE_BLOCKING_TYPE_NEVER This type never blocks so millisecondTimeout is ignored. The following are possible return values: NVMEDIA_STATUS_OK NVMEDIA_STATUS_PENDING or NVMEDIA_STATUS_NONE_PENDING. NVMEDIA_ENCODE_BLOCKING_TYPE_IF_PENDING Same as NVMEDIA_ENCODE_BLOCKING_TYPE_NEVER except that NVMEDIA_STATUS_PENDING will never be returned. If an encode is pending this function will block until the status changes to NVMEDIA_STATUS_OK or until the timeout has occurred. Possible return values: NVMEDIA_STATUS_OK, NVMEDIA_STATUS_NONE_PENDING, NVMEDIA_STATUS_TIMED_OUT. NVMEDIA_ENCODE_BLOCKING_TYPE_ALWAYS This function returns only when NVMEDIA_STATUS_OK or NVMEDIA_STATUS_TIMED_OUT. It blocks until those conditions are satisfied. |
[in] | millisecondTimeout | Timeout in milliseconds or NVMEDIA_VIDEO_ENCODER_TIMEOUT_INFINITE if a timeout is not desired. |
NvMediaIEP* NvMediaIEPCreate | ( | const NvMediaDevice * | device, |
NvMediaIEPType | encodeType, | ||
void * | initParams, | ||
NvMediaSurfaceType | inputFormat, | ||
uint8_t | maxInputBuffering, | ||
uint8_t | maxOutputBuffering, | ||
NvMediaEncoderInstanceId | instanceId | ||
) |
Creates an encoder object capable of turning a stream of surfaces of the "inputFormat" into a bitstream of the specified "codec".
Surfaces are feed to the encoder with NvMediaIEPFeedFrame and bitstream buffers are retrieved with NvMediaIEPGetBitsEx.
[in] | device | The device this image encoder will use. |
[in] | encodeType | The encode type, which can be: NVMEDIA_IMAGE_ENCODE_H264 NVMEDIA_IMAGE_ENCODE_HEVC NVMEDIA_IMAGE_ENCODE_VP9 |
[in] | initParams | The encode parameters, which can be: Supported encode parameter structures: NvMediaEncodeInitializeParamsH264 NvMediaEncodeInitializeParamsH265 NvMediaEncodeInitializeParamsVP9 |
[in] | inputFormat | Must be obtained by /ref NvMediaSurfaceFormatGetType with: NVM_SURF_FMT_SET_ATTR_YUV(attr, YUV, 420, SEMI_PLANAR, UINT, [8/10], BL) NVM_SURF_FMT_SET_ATTR_YUV(attr, YUV, 444, SEMI_PLANAR, UINT, [8/10], BL) |
[in] | maxInputBuffering | Maximum number of frames in the encode pipeline at any time. For example, if maxInputBuffering==1 , NvMediaIEPFeedFrame is blocked until the previous encode completes. If maxInputBuffering==2 , NvMediaIEPFeedFrame accepts one frame while another is still being encoded by the hardware, but will block if two are still being encoded. maxInputBuffering is clamped between 1 and 16. This field is ignored for YUV inputs which do not require a pre-processing pipeline before the encode hardware. |
[in] | maxOutputBuffering | Maximum number of frames of encoded bitstream that can be held by the NvMediaIEP before it must be retrieved using NvMediaIEPGetBitsEx(). This number must be greater than or equal to maxInputBuffering and is clamped to between maxInputBuffering and 16. If maxOutputBuffering frames worth of encoded bitstream are yet unretrived by NvMediaIEPGetBitsEx NvMediaIEPFeedFrame returns NVMEDIA_STATUS_INSUFFICIENT_BUFFERING. One or more frames must be retrived with NvMediaIEPGetBitsEx() before frame feeding can continue. |
[in] | instanceId | The ID of the encoder engine instance. The following instances are supported: NVMEDIA_ENCODER_INSTANCE_0 NVMEDIA_ENCODER_INSTANCE_1 NVMEDIA_ENCODER_INSTANCE_AUTO |
void NvMediaIEPDestroy | ( | const NvMediaIEP * | encoder | ) |
Destroys an NvMedia image encoder.
[in] | encoder | The encoder to destroy. |
NvMediaStatus NvMediaIEPFeedFrame | ( | const NvMediaIEP * | encoder, |
NvMediaImage * | frame, | ||
const NvMediaRect * | sourceRect, | ||
void * | picParams, | ||
NvMediaEncoderInstanceId | instanceId | ||
) |
Encodes the specified frame.
This function returns NVMEDIA_STATUS_INSUFFICIENT_BUFFERING if NvMediaIEPGetBitsEx has not been called frequently enough and the maximum internal bitstream buffering has been exhausted. The MaxOutputBuffering argument passed to NvMediaIEPCreate() specifies the maximum buffering.
[in] | encoder | The encoder to use. |
[in] | frame | The frame, which must be of the same sourceType as in the NvMediaIEP. There is no limit on the size of this surface. The source rectangle specified by sourceRect is scaled to the stream dimensions. |
[in] | sourceRect | The rectangle on the source, which is scaled to the stream dimensions. A value of NULL specifies a rectangle the full size of the source surface. The source can be flipped horizontally or vertically, by swapping the left and right or top and bottom coordinates. This parameter is valid only for RGB type input surfaces. |
[in] | picParams | Picture parameters used for the frame. Supported picture parameter structures: NvMediaEncodePicParamsH264 NvMediaEncodePicParamsH265 NvMediaEncodePicParamsVP9 |
[in] | instanceId | The ID of the encoder engine instance. The following instances are supported if NVMEDIA_ENCODER_INSTANCE_AUTO was used in NvMediaIEPCreate API, else this parameter is ignored: NVMEDIA_ENCODER_INSTANCE_0 NVMEDIA_ENCODER_INSTANCE_1 |
NvMediaStatus NvMediaIEPGetAttribute | ( | const NvMediaIEP * | encoder, |
NvMediaEncAttrType | attrType, | ||
uint32_t | attrSize, | ||
void * | AttributeData | ||
) |
Gets the encoder attribute for the current encoding session.
This function can be called after passing the first frame for encoding. It can be used to get header information (SPS/PPS/VPS) for the current encoding session. Additionally, it can be extended for further requirements, by implementing proper data structures.
Before calling this function, you must pass the first frame for encoding.
[in] | encoder | A pointer to the encoder to use. |
[in] | attrType | Attribute type as defined in NvMediaEncAttrType. |
[in] | attrSize | Size of the data structure associated with attribute. |
[out] | AttributeData | A pointer to data structure associated with the attribute. |
NvMediaStatus NvMediaIEPGetBitsEx | ( | const NvMediaIEP * | encoder, |
uint32_t * | numBytes, | ||
uint32_t | numBitstreamBuffers, | ||
NvMediaBitstreamBuffer * | bitstreams, | ||
void * | extradata | ||
) |
Returns the bitstream for a slice or frame.
It is safe to call this function from a separate thread.
When slice Level output is enabled, this function must be called repeatedly. until the output extradata field bEndOfFrame
is not set to NVMEDIA_TRUE
. With every call to NvMediaIEPGetBitsEx, the function returns the bitstream for a slice or frame.
When slice level output is not enabled, the return value and behavior is the same as that of NvMediaIEPBitsAvailable() when called with NVMEDIA_ENCODE_BLOCKING_TYPE_NEVER, except that when NVMEDIA_STATUS_OK is returned, the buffer is filled in addition to the numBytes.
[in] | encoder | A pointer to the encoder to use. |
[out] | numBytes | Size of the filled bitstream. |
[in] | numBitstreamBuffers | The number of bitstreams. |
[in,out] | bitstreams | A pointer to the buffer to be filled with the encoded data. |
[out] | extradata | Output extradata required by application. The output extra data buffer to be filled by the encoder. |
NvMediaStatus NvMediaIEPGetVersion | ( | NvMediaVersion * | version | ) |
Checks the version compatibility for the NvMedia IEP library.
[in] | version | A pointer to a NvMediaVersion structure of the client. |
NvMediaStatus NvMediaIEPSetConfiguration | ( | const NvMediaIEP * | encoder, |
void * | configuration | ||
) |
Sets the encoder configuration.
The values in the configuration take effect only at the start of the next GOP.
[in] | encoder | A pointer to the encoder to use. |
[in] | configuration | Configuration data. Supported configuration structures: NvMediaEncodeConfigH264 NvMediaEncodeConfigH265 NvMediaEncodeConfigVP9 |