Defines a helper class for V4L2 Video Encoder.
The video encoder device node is "/dev/nvhost-msenc"
. The category name for the encoder is "NVENC"
.
Refer to V4L2 Video Encoder for more information on the encoder.
Definition at line 61 of file NvVideoEncoder.h.
Public Member Functions | |
~NvVideoEncoder () | |
int | setOutputPlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_colorspace cs=V4L2_COLORSPACE_SMPTE170M) |
Sets the format on the encoder output plane. More... | |
int | setCapturePlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height, uint32_t sizeimage) |
Sets the format on the converter capture plane. More... | |
int | setFrameRate (uint32_t framerate_num, uint32_t framerate_den) |
Sets the encode framerate. More... | |
int | setBitrate (uint32_t bitrate) |
Sets the encoder bitrate. More... | |
int | setPeakBitrate (uint32_t peak_bitrate) |
Sets the encoder peak bitrate. More... | |
int | setProfile (uint32_t profile) |
Sets the encoder profile. More... | |
int | setEncoderCommand (int cmd, int flags) |
Sets the encoder command. More... | |
int | setLevel (uint32_t level) |
Set the encoder level. More... | |
int | setMaxPerfMode (int flag) |
Sets the encoder for maximum performance. More... | |
int | setConstantQp (bool enabled_rc) |
Sets constant QP for encoder. More... | |
int | setRateControlMode (enum v4l2_mpeg_video_bitrate_mode mode) |
Sets the encoder rate control mode. More... | |
int | setIFrameInterval (uint32_t interval) |
Sets the encoder I-frame interval. More... | |
int | setIDRInterval (uint32_t interval) |
Sets the encoder IDR interval. More... | |
int | forceIDR () |
Forces an IDR frame. More... | |
int | setTemporalTradeoff (v4l2_enc_temporal_tradeoff_level_type level) |
Sets the encoder Temporal Tradeoff. More... | |
int | setSliceLength (v4l2_enc_slice_length_type type, uint32_t length) |
Sets the encoder output slice length. More... | |
int | setHWPresetType (v4l2_enc_hw_preset_type type) |
Sets the encoder HW Preset Type. More... | |
int | setROIParams (uint32_t buffer_index, v4l2_enc_frame_ROI_params ¶ms) |
Sets the Region of Interest (ROI) parameters for the next buffer, which will be queued on the output plane with index buffer_index. More... | |
int | setPPEInitParams (v4l2_enc_ppe_init_params ¶ms) |
Sets the preprocessing enhancement (PPE) initialization parameters at the start of the session. More... | |
int | enableROI (v4l2_enc_enable_roi_param ¶ms) |
Enables External ROI. More... | |
int | enableReconCRC (v4l2_enc_enable_reconcrc_param ¶ms) |
Enables Recon CRC. More... | |
int | enableExternalRPS (v4l2_enc_enable_ext_rps_ctr ¶ms) |
Enable External RPS. More... | |
int | enableExternalRC (v4l2_enc_enable_ext_rate_ctr ¶ms) |
Enable External Picture RC. More... | |
int | enableAV1Tile (v4l2_enc_av1_tile_config ¶ms) |
Enable AV1 Multi-tile configuration. More... | |
int | setAV1SsimRdo (bool enabled) |
Enable AV1 variance based SSIM RDO. More... | |
int | setAV1DisableCDFUpdate (bool disabled) |
Disable AV1 CDF update in the symbol decoding process. More... | |
int | setAV1ErrResilienceMode (bool enabled) |
Enable Error Resilient Mode for AV1. More... | |
int | setAV1FrameIDPresentFlag (bool enabled) |
Enable AV1 frame_id_numbers_present_flag. More... | |
int | enableAV1TileGroups (bool enabled) |
Enable AV1 frame_id_numbers_present_flag. More... | |
int | SetInputMetaParams (uint32_t buffer_index, v4l2_ctrl_videoenc_input_metadata ¶ms) |
Set input Metadata parameters for the next buffer which will be queued on output plane with index buffer_index. More... | |
int | setVirtualBufferSize (uint32_t size) |
Sets the virtual buffer size of the encoder. More... | |
int | setNumReferenceFrames (uint32_t num_frames) |
Sets the number of reference frames of the encoder. More... | |
int | setSliceIntrarefresh (uint32_t interval) |
Sets slice intra-refresh interval params. More... | |
int | setNumBFrames (uint32_t num) |
Sets the number of B frames to P frames. More... | |
int | setInsertSpsPpsAtIdrEnabled (bool enabled) |
Enables/disables insert SPS PPS at every IDR. More... | |
int | setCABAC (bool enabled) |
Enables/disables CABAC entropy encoding for H264. More... | |
int | setSliceLevelEncode (bool enabled) |
Enables/disables Slice level encoding for H264 / HEVC. More... | |
int | enableMotionVectorReporting () |
Enables video encoder output motion vector metadata reporting. More... | |
int | getMetadata (uint32_t buffer_index, v4l2_ctrl_videoenc_outputbuf_metadata &enc_metadata) |
Gets metadata for the encoded capture plane buffer. More... | |
int | getMotionVectors (uint32_t buffer_index, v4l2_ctrl_videoenc_outputbuf_metadata_MV &enc_mv_metadata) |
Gets motion vector metadata for the encoded capture plane buffer. More... | |
int | setQpRange (uint32_t MinQpI, uint32_t MaxQpI, uint32_t MinQpP, uint32_t MaxQpP, uint32_t MinQpB, uint32_t MaxQpB) |
Sets QP values for I/P/B frames. More... | |
int | setSampleAspectRatioWidth (uint32_t sar_width) |
Sets Sample Aspect Ratio width for VUI encoding. More... | |
int | setSampleAspectRatioHeight (uint32_t sar_height) |
Sets Sample Aspect Ratio height for VUI encoding. More... | |
int | setInsertVuiEnabled (bool enabled) |
Enables/disables insert VUI. More... | |
int | setExtendedColorFormat (bool enabled) |
Enables/disables extended color format. More... | |
int | setInsertAudEnabled (bool enabled) |
Enables/disables insert AUD. More... | |
int | setAlliFramesEncode (bool enabled) |
Enables/disables all i-frame encode. More... | |
int | setPocType (uint32_t pocType) |
Sets the encoder Picture Order Control type. More... | |
int | setInitQP (uint32_t IinitQP, uint32_t PinitQP, uint32_t BinitQP) |
Sets the initial QP for I/P/B frames. More... | |
int | setFramesToEncode (uint32_t framesToEncode) |
Sets the number of frames to encode. More... | |
int | setChromaFactorIDC (uint8_t crfactor) |
Sets the H.265 encoder Chroma Format IDC. More... | |
int | setLossless (bool enabled) |
Sets the lossless encoding for H.264/H.265. More... | |
int | setDisableAMP (bool enabled) |
Sets the Disable AMP types to true for H.265. More... | |
int | enableTwoPassCBR () |
Sets whether to enable two pass CBR for H.264/H.265. More... | |
int | DevicePoll (v4l2_ctrl_video_device_poll *devicepoll) |
Issues Poll on the device which blocks until : a) Either there is something to dequeue from capture or output plane or any events. More... | |
int | SetPollInterrupt () |
Sets the polling interrupt, now if the application calls Poll, the device should not block, in other words polling is disabled. More... | |
int | ClearPollInterrupt () |
Clears the polling interrupt, now if the application calls Poll, the device should block until the event is triggered, in other words polling is enabled. More... | |
int | subscribeEvent (uint32_t type, uint32_t id, uint32_t flags) |
Subscribes to an V4L2 event. More... | |
int | dqEvent (struct v4l2_event &event, uint32_t max_wait_ms) |
Dequeues an event from the element. More... | |
int | setControl (uint32_t id, int32_t value) |
Sets the value of a control. More... | |
int | getControl (uint32_t id, int32_t &value) |
Gets the value of a control. More... | |
int | setExtControls (struct v4l2_ext_controls &ctl) |
Sets the value of several controls. More... | |
int | getExtControls (struct v4l2_ext_controls &ctl) |
Gets the value of several controls. More... | |
virtual int | isInError () |
int | abort () |
Terminates processing of queued buffers immediately. More... | |
virtual int | waitForIdle (uint32_t max_wait_ms) |
Waits until the element processes all the output plane buffers. More... | |
void | enableProfiling () |
Enables profiling for the V4l2Element. More... | |
void | getProfilingData (NvElementProfiler::NvElementProfilerData &data) |
Gets profiling data for the element. More... | |
void | printProfilingStats (std::ostream &out_stream=std::cout) |
Prints profiling data for the element to an output stream. More... | |
bool | isProfilingEnabled () |
Checks whether profiling is enabled for the element. More... | |
Static Public Member Functions | |
static NvVideoEncoder * | createVideoEncoder (const char *name, int flags=0) |
Creates a new V4L2 Video Encoder object named name. More... | |
Data Fields | |
NvV4l2ElementPlane | output_plane |
Sets the output plane. More... | |
NvV4l2ElementPlane | capture_plane |
Sets the capture plane. More... | |
void * | app_data |
A pointer to the application-specific data. More... | |
Protected Attributes | |
int | fd |
Specifies the FD of the device opened using v4l2_open . More... | |
uint32_t | output_plane_pixfmt |
Pixel format of output plane buffers. More... | |
uint32_t | capture_plane_pixfmt |
Pixel format of capture plane buffers. More... | |
int | is_in_error |
Indicates if an error was encountered during the operation of the element. More... | |
const char * | comp_name |
Specifies the name of the component, for debugging. More... | |
NvElementProfiler | profiler |
Profiler for the element. More... | |
NvVideoEncoder::~NvVideoEncoder | ( | ) |
|
inherited |
Terminates processing of queued buffers immediately.
All the buffers are returned to the application.
Calls VIDIOC_STREAMOFF IOCTL on both of the planes internally.
int NvVideoEncoder::ClearPollInterrupt | ( | ) |
Clears the polling interrupt, now if the application calls Poll, the device should block until the event is triggered, in other words polling is enabled.
|
static |
Creates a new V4L2 Video Encoder object named name.
This method internally calls v4l2_open
on the encoder dev node "/dev/nvhost-msenc"
and checks for V4L2_CAP_VIDEO_M2M_MPLANE
capability on the device. This method allows the caller to specify additional flags with which the device must be opened.
The device is opened in blocking mode, which can be modified by passing the O_NONBLOCK flag to this method.
int NvVideoEncoder::DevicePoll | ( | v4l2_ctrl_video_device_poll * | devicepoll | ) |
Issues Poll on the device which blocks until : a) Either there is something to dequeue from capture or output plane or any events.
b) Poll was interrupted by a call to the device using V4L2_CID_SET_POLL_INTERRUPT c) Application has already interrupted polling by V4L2_CID_SET_POLL_INTERRUPT
|
inherited |
Dequeues an event from the element.
Calls VIDIOC_DQEVENT
IOCTL internally. The caller can specify the maximum time to wait for dequeuing the event. The call blocks until an event is dequeued successfully or timeout is reached.
[in,out] | event | A reference to the v4l2_event structure to fill. |
[in] | max_wait_ms | Specifies the max wait time for dequeuing an event, in milliseconds. |
int NvVideoEncoder::enableAV1Tile | ( | v4l2_enc_av1_tile_config & | params | ) |
Enable AV1 Multi-tile configuration.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_TILE_CONFIGURATION. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | params | Parameters to be applied, structure of type #v4l2_enc_av1_tile_config |
int NvVideoEncoder::enableAV1TileGroups | ( | bool | enabled | ) |
Enable AV1 frame_id_numbers_present_flag.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_ENABLE_TILE_GROUPS. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::enableExternalRC | ( | v4l2_enc_enable_ext_rate_ctr & | params | ) |
Enable External Picture RC.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_EXTERNAL_RATE_CONTROL. Must be called after requesting buffer on both the planes.
[in] | params | Parameters to be applied on the frame, structure of type #v4l2_enc_enable_ext_rate_ctr |
int NvVideoEncoder::enableExternalRPS | ( | v4l2_enc_enable_ext_rps_ctr & | params | ) |
Enable External RPS.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_EXTERNAL_RPS_CONTROL. Must be called after requesting buffer on both the planes.
[in] | params | Parameters to be applied on the frame, structure of type v4l2_enc_enable_ext_rps_ctr |
int NvVideoEncoder::enableMotionVectorReporting | ( | ) |
Enables video encoder output motion vector metadata reporting.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_METADATA_MV. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
|
virtualinherited |
Enables profiling for the V4l2Element.
Must be called before setting either plane formats.
Reimplemented from NvElement.
int NvVideoEncoder::enableReconCRC | ( | v4l2_enc_enable_reconcrc_param & | params | ) |
Enables Recon CRC.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_RECONCRC_PARAM. Must be called after requesting buffer on both the planes.
[in] | params | Parameters to be applied on the frame, structure of type v4l2_enc_enable_reconcrc_param. |
int NvVideoEncoder::enableROI | ( | v4l2_enc_enable_roi_param & | params | ) |
Enables External ROI.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_ROI_PARAM. Must be called after requesting buffer on both the planes.
[in] | params | Parameters to be applied on the frame, structure of type v4l2_enc_enable_roi_param. |
int NvVideoEncoder::enableTwoPassCBR | ( | ) |
Sets whether to enable two pass CBR for H.264/H.265.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_TWO_PASS_CBR. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
int NvVideoEncoder::forceIDR | ( | ) |
Forces an IDR frame.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE
. Must be called after setFormat on both the planes.
|
inherited |
Gets the value of a control.
Calls VIDIOC_G_CTRL
IOCTL internally.
[in] | id | ID of the control to get. |
[out] | value | A reference to the variable into which the control value is read. |
|
inherited |
Gets the value of several controls.
Calls VIDIOC_G_EXT_CTRLS
IOCTL internally.
[in,out] | ctl | A pointer to the controls to get. |
int NvVideoEncoder::getMetadata | ( | uint32_t | buffer_index, |
v4l2_ctrl_videoenc_outputbuf_metadata & | enc_metadata | ||
) |
Gets metadata for the encoded capture plane buffer.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_METADATA. Must be called for a buffer that has been dequeued from the capture plane. The returned metadata corresponds to the last dequeued buffer with index buffer_index.
[in] | buffer_index | Index of the capture plane buffer whose metadata is required. |
[in,out] | enc_metadata | Reference to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata to be filled. |
int NvVideoEncoder::getMotionVectors | ( | uint32_t | buffer_index, |
v4l2_ctrl_videoenc_outputbuf_metadata_MV & | enc_mv_metadata | ||
) |
Gets motion vector metadata for the encoded capture plane buffer.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_METADATA_MV. Must be called for a buffer that has been dequeued from the capture plane. The returned metadata corresponds to the last dequeued buffer with index buffer_index.
[in] | buffer_index | Index of the capture plane buffer whose metadata is required. |
[in,out] | enc_mv_metadata | Reference to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata_MV to be filled. |
|
inherited |
Gets profiling data for the element.
|
virtualinherited |
Reimplemented from NvElement.
|
inherited |
Checks whether profiling is enabled for the element.
|
inherited |
Prints profiling data for the element to an output stream.
[in] | out_stream | Output stream of type std::ostream to print the data to. It takes the default value std::cout if not specified. |
int NvVideoEncoder::setAlliFramesEncode | ( | bool | enabled | ) |
Enables/disables all i-frame encode.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_ALLIFRAME_ENCODE
. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setAV1DisableCDFUpdate | ( | bool | disabled | ) |
Disable AV1 CDF update in the symbol decoding process.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_DISABLE_CDF_UPDATE. The value true disables the CDF update. Must be called after setFormat on both the planes.
[in] | disabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setAV1ErrResilienceMode | ( | bool | enabled | ) |
Enable Error Resilient Mode for AV1.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_ERR_RESILIENT_MODE. The value true disables the control. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setAV1FrameIDPresentFlag | ( | bool | enabled | ) |
Enable AV1 frame_id_numbers_present_flag.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_ENABLE_FRAMEID_NUMBERS. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setAV1SsimRdo | ( | bool | enabled | ) |
Enable AV1 variance based SSIM RDO.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_AV1_ENABLE_SSIMRDO. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setBitrate | ( | uint32_t | bitrate | ) |
Sets the encoder bitrate.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_BITRATE
. Can be called any time after setFormat on both the planes.
[in] | bitrate | Bitrate of the encoded stream, in bits per second. |
int NvVideoEncoder::setCABAC | ( | bool | enabled | ) |
Enables/disables CABAC entropy encoding for H264.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setCapturePlaneFormat | ( | uint32_t | pixfmt, |
uint32_t | width, | ||
uint32_t | height, | ||
uint32_t | sizeimage | ||
) |
Sets the format on the converter capture plane.
Calls VIDIOC_S_FMT
IOCTL internally on the capture plane.
[in] | pixfmt | One of the coded V4L2 pixel formats. |
[in] | width | Width of the input buffers in pixels. |
[in] | height | Height of the input buffers in pixels. |
[in] | sizeimage | Maximum size of the encoded buffers on the capture. plane in bytes |
int NvVideoEncoder::setChromaFactorIDC | ( | uint8_t | crfactor | ) |
Sets the H.265 encoder Chroma Format IDC.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_H265_CHROMA_FACTOR_IDC. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | crfactor | Set chroma_factor_idc for the encoder. |
int NvVideoEncoder::setConstantQp | ( | bool | enabled_rc | ) |
Sets constant QP for encoder.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE
to enable/disable rate control. If the value false is given, it disables RC and set constant QP parameters. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | enabled_rc | Boolean value indicating whether to enable/disable the control. |
|
inherited |
Sets the value of a control.
Calls VIDIOC_S_CTRL
IOCTL internally.
[in] | id | ID of the control to be set. |
[in] | value | Value to be set on the control. |
int NvVideoEncoder::setDisableAMP | ( | bool | enabled | ) |
Sets the Disable AMP types to true for H.265.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_H265_DISABLE_AMP. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | enabled | Indicates whether to enable or disable the control. |
int NvVideoEncoder::setEncoderCommand | ( | int | cmd, |
int | flags | ||
) |
Sets the encoder command.
Calls the VIDIOC_ENCODER_CMD internally with encoder commands.
|
inherited |
Sets the value of several controls.
Calls VIDIOC_S_EXT_CTRLS
IOCTL internally.
[in] | ctl | A pointer to the controls to set. |
int NvVideoEncoder::setExtendedColorFormat | ( | bool | enabled | ) |
Enables/disables extended color format.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_EXTEDED_COLORFORMAT
. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setFrameRate | ( | uint32_t | framerate_num, |
uint32_t | framerate_den | ||
) |
Sets the encode framerate.
Calls the VIDIOC_S_PARM IOCTL on the encoder capture plane. Can be called any time after setFormat on both the planes.
[in] | framerate_num | Numerator part of the framerate fraction. |
[in] | framerate_den | Denominator part of the framerate fraction. |
int NvVideoEncoder::setFramesToEncode | ( | uint32_t | framesToEncode | ) |
Sets the number of frames to encode.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_FRAMES_TO_ENCODE. Must be called after setFormat on both the planes.
[in] | framesToEncode | Set the number of frames to encode. |
int NvVideoEncoder::setHWPresetType | ( | v4l2_enc_hw_preset_type | type | ) |
Sets the encoder HW Preset Type.
Calls the VIDIOC_S_EXT_CTRLS ioctl internally with Control ID V4L2_CID_MPEG_VIDEOENC_HW_PRESET_TYPE_PARAM. Must be called after setFormat() on both the planes and before requestBuffers
on any of the planes.
[in] | type | HW Preset Type, one of enum v4l2_enc_hw_preset_type_param. |
int NvVideoEncoder::setIDRInterval | ( | uint32_t | interval | ) |
Sets the encoder IDR interval.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_IDR_INTERVAL. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | interval | Interval between two IDR frames, in number of frames. |
int NvVideoEncoder::setIFrameInterval | ( | uint32_t | interval | ) |
Sets the encoder I-frame interval.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_GOP_SIZE
. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | interval | Interval between two I frames, in number of frames. |
int NvVideoEncoder::setInitQP | ( | uint32_t | IinitQP, |
uint32_t | PinitQP, | ||
uint32_t | BinitQP | ||
) |
Sets the initial QP for I/P/B frames.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with control Id V4L2_CID_MPEG_VIDEOENC_INIT_FRAME_QP. Must be called after setFormat on both the planes.
[in] | IinitQP | Qp Value for I frame. |
[in] | PinitQP | Qp Value for P frame. |
[in] | BinitQP | Qp Value for B frame. |
int NvVideoEncoder::SetInputMetaParams | ( | uint32_t | buffer_index, |
v4l2_ctrl_videoenc_input_metadata & | params | ||
) |
Set input Metadata parameters for the next buffer which will be queued on output plane with index buffer_index.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_INPUT_METADATA. Must be called after requesting buffer on both the planes.
[in] | buffer_index | Index of output plane buffer on which the external RC params should be applied. |
[in] | params | Parameters to be applied on the frame, structure of type v4l2_ctrl_videoenc_input_metadata |
int NvVideoEncoder::setInsertAudEnabled | ( | bool | enabled | ) |
Enables/disables insert AUD.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_AUD_SAR_ENABLE
. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setInsertSpsPpsAtIdrEnabled | ( | bool | enabled | ) |
Enables/disables insert SPS PPS at every IDR.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_INSERT_SPS_PPS_AT_IDR. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setInsertVuiEnabled | ( | bool | enabled | ) |
Enables/disables insert VUI.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_INSERT_VUI
. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setLevel | ( | uint32_t | level | ) |
Set the encoder level.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_LEVEL
or V4L2_CID_MPEG_VIDEOENC_H265_LEVEL, depending on encoder type. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | level | Level to be used for encoding |
int NvVideoEncoder::setLossless | ( | bool | enabled | ) |
Sets the lossless encoding for H.264/H.265.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_LOSSLESS. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | enabled | Indicates whether to enable or disable the control. |
int NvVideoEncoder::setMaxPerfMode | ( | int | flag | ) |
Sets the encoder for maximum performance.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_MAX_PERFORMANCE. Must be called after setFormat on both the planes and before requestBuffers on any of the planes.
[in] | flag | Integer variable to indicate whether max performance is to be enabled/disabled. |
int NvVideoEncoder::setNumBFrames | ( | uint32_t | num | ) |
Sets the number of B frames to P frames.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_NUM_BFRAMES. Must be called after setFormat on both the planes.
[in] | num | Number of B frames. |
int NvVideoEncoder::setNumReferenceFrames | ( | uint32_t | num_frames | ) |
Sets the number of reference frames of the encoder.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_NUM_REFERENCE_FRAMES. Must be called after setFormat on both the planes.
[in] | num_frames | Number of reference frames. |
int NvVideoEncoder::setOutputPlaneFormat | ( | uint32_t | pixfmt, |
uint32_t | width, | ||
uint32_t | height, | ||
enum v4l2_colorspace | cs = V4L2_COLORSPACE_SMPTE170M |
||
) |
Sets the format on the encoder output plane.
Calls VIDIOC_S_FMT
IOCTL internally on the output plane.
[in] | pixfmt | One of the raw V4L2 pixel formats. |
[in] | width | Width of the input buffers in pixels. |
[in] | height | Height of the input buffers in pixels. |
int NvVideoEncoder::setPeakBitrate | ( | uint32_t | peak_bitrate | ) |
Sets the encoder peak bitrate.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_BITRATE_PEAK
. Can be called any time after setFormat on both the planes. Takes effect in VBR mode
[in] | peak_bitrate | Peak Bitrate of the encoded stream, in bits per second. |
int NvVideoEncoder::setPocType | ( | uint32_t | pocType | ) |
Sets the encoder Picture Order Control type.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_POC_TYPE. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | pocType | Set the Picture Order Count for the encoder. |
int NvVideoEncoder::SetPollInterrupt | ( | ) |
Sets the polling interrupt, now if the application calls Poll, the device should not block, in other words polling is disabled.
int NvVideoEncoder::setPPEInitParams | ( | v4l2_enc_ppe_init_params & | params | ) |
Sets the preprocessing enhancement (PPE) initialization parameters at the start of the session.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_PPE_INIT_PARAMS. Must be called after requesting buffer on both the planes.
[in] | params | A reference to the parameters to be applied on the frame, structure of type v4l2_enc_ppe_init_params. |
int NvVideoEncoder::setProfile | ( | uint32_t | profile | ) |
Sets the encoder profile.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_PROFILE
or V4L2_CID_MPEG_VIDEO_H265_PROFILE, depending on the encoder type. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | profile | Profile to be used for encoding. |
int NvVideoEncoder::setQpRange | ( | uint32_t | MinQpI, |
uint32_t | MaxQpI, | ||
uint32_t | MinQpP, | ||
uint32_t | MaxQpP, | ||
uint32_t | MinQpB, | ||
uint32_t | MaxQpB | ||
) |
Sets QP values for I/P/B frames.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with control Id V4L2_CID_MPEG_VIDEOENC_QP_RANGE. Must be called after setFormat on both the planes.
[in] | MinQpI | Minimum Qp Value for I frame. |
[in] | MaxQpI | Minimum Qp Value for I frame. |
[in] | MinQpP | Minimum Qp Value for P frame. |
[in] | MaxQpP | Minimum Qp Value for P frame. |
[in] | MinQpB | Minimum Qp Value for B frame. |
[in] | MaxQpB | Minimum Qp Value for B frame. |
int NvVideoEncoder::setRateControlMode | ( | enum v4l2_mpeg_video_bitrate_mode | mode | ) |
Sets the encoder rate control mode.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_BITRATE_MODE
. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | mode | Type of rate control, one of enum v4l2_mpeg_video_bitrate_mode. |
int NvVideoEncoder::setROIParams | ( | uint32_t | buffer_index, |
v4l2_enc_frame_ROI_params & | params | ||
) |
Sets the Region of Interest (ROI) parameters for the next buffer, which will be queued on the output plane with index buffer_index.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ROI_PARAMS. Must be called after requesting buffer on both the planes.
[in] | buffer_index | Index of the output plane buffer to apply the ROI params. |
[in] | params | A reference to the parameters to be applied on the frame, structure of type v4l2_enc_frame_ROI_params. |
int NvVideoEncoder::setSampleAspectRatioHeight | ( | uint32_t | sar_height | ) |
Sets Sample Aspect Ratio height for VUI encoding.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with control Id V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT
or V4L2_CID_MPEG_VIDEOENC_H265_VUI_EXT_SAR_HEIGHT, depending on the encoder type. Must be called after setFormat on both the planes.
[in] | sar_height | SAR for height. |
int NvVideoEncoder::setSampleAspectRatioWidth | ( | uint32_t | sar_width | ) |
Sets Sample Aspect Ratio width for VUI encoding.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with control Id V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH
or V4L2_CID_MPEG_VIDEOENC_H265_VUI_EXT_SAR_WIDTH, depending on the encoder type. Must be called after setFormat on both the planes.
[in] | sar_width | SAR for width. |
int NvVideoEncoder::setSliceIntrarefresh | ( | uint32_t | interval | ) |
Sets slice intra-refresh interval params.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM. Must be called after setFormat on both the planes.
[in] | interval | Slice intra-refresh interval, in number of slices. |
int NvVideoEncoder::setSliceLength | ( | v4l2_enc_slice_length_type | type, |
uint32_t | length | ||
) |
Sets the encoder output slice length.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_SLICE_LENGTH_PARAM. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | type | Slice length type, one of enum v4l2_enc_slice_length_type. |
[in] | length | Length of the slice, in bytes if the type is V4L2_ENC_SLICE_LENGTH_TYPE_BITS, else in number of MBs if the type is V4L2_ENC_SLICE_LENGTH_TYPE_MBLK. |
int NvVideoEncoder::setSliceLevelEncode | ( | bool | enabled | ) |
Enables/disables Slice level encoding for H264 / HEVC.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_ENABLE_SLICE_LEVEL_ENCODE. Must be called after setFormat on both the planes.
[in] | enabled | Boolean value indicating whether to enable/disable the control. |
int NvVideoEncoder::setTemporalTradeoff | ( | v4l2_enc_temporal_tradeoff_level_type | level | ) |
Sets the encoder Temporal Tradeoff.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_TEMPORAL_TRADEOFF_LEVEL. Must be called after setFormat on both the planes and before requestBuffers
on any of the planes.
[in] | level | Temporal tradeoff level, one of v4l2_enc_temporal_tradeoff_level_type. |
int NvVideoEncoder::setVirtualBufferSize | ( | uint32_t | size | ) |
Sets the virtual buffer size of the encoder.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEOENC_VIRTUALBUFFER_SIZE. Must be called after setFormat on both the planes.
[in] | size | Virtual buffer size, in bytes. |
|
inherited |
Subscribes to an V4L2 event.
Calls VIDIOC_SUBSCRIBE_EVENT
IOCTL internally.
[in] | type | Type of the event. |
[in] | id | ID of the event source. |
[in] | flags | Event flags. |
|
virtualinherited |
Waits until the element processes all the output plane buffers.
Objects extending V4l2Element
must implement this because the idle condition is component-specific.
[in] | max_wait_ms | Max time to wait in milliseconds. |
|
inherited |
A pointer to the application-specific data.
Definition at line 169 of file NvV4l2Element.h.
|
inherited |
Sets the capture plane.
Capture plane of the element
Definition at line 145 of file NvV4l2Element.h.
|
protectedinherited |
Pixel format of capture plane buffers.
Definition at line 182 of file NvV4l2Element.h.
|
protectedinherited |
Specifies the name of the component, for debugging.
Definition at line 122 of file NvElement.h.
|
protectedinherited |
Specifies the FD of the device opened using v4l2_open
.
Definition at line 179 of file NvV4l2Element.h.
|
protectedinherited |
Indicates if an error was encountered during the operation of the element.
Definition at line 120 of file NvElement.h.
Referenced by NvElement::isInError().
|
inherited |
|
protectedinherited |
Pixel format of output plane buffers.
Definition at line 181 of file NvV4l2Element.h.
|
protectedinherited |
Profiler for the element.
Definition at line 124 of file NvElement.h.