L4T Multimedia API Reference

31.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NvVideoEncoder Class Reference

Detailed Description

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 59 of file NvVideoEncoder.h.

Inheritance diagram for NvVideoEncoder:
Collaboration diagram for NvVideoEncoder:

Public Member Functions

 ~NvVideoEncoder ()
 
int setOutputPlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height)
 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 (enum v4l2_mpeg_video_h264_level level)
 Set the encoder level. More...
 
int setConstantQp (int qp_value)
 Sets the encoder constant qp. 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 &params)
 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 enableROI (v4l2_enc_enable_roi_param &params)
 Enables External ROI. More...
 
int enableReconCRC (v4l2_enc_enable_reconcrc_param &params)
 Enables Recon CRC. More...
 
int enableExternalRPS (v4l2_enc_enable_ext_rps_ctr &params)
 Enable External RPS. More...
 
int enableExternalRC (v4l2_enc_enable_ext_rate_ctr &params)
 Enable External Picture RC. More...
 
int 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. 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 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 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 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 NvVideoEncodercreateVideoEncoder (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...
 

Constructor & Destructor Documentation

NvVideoEncoder::~NvVideoEncoder ( )

Member Function Documentation

int NvV4l2Element::abort ( )
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.

Returns
0 for success, -1 otherwise.
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 NvVideoEncoder* NvVideoEncoder::createVideoEncoder ( const char *  name,
int  flags = 0 
)
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.

Returns
Reference to the newly created encoder object, else NULL in case of failure during initialization.
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

int NvV4l2Element::dqEvent ( struct v4l2_event &  event,
uint32_t  max_wait_ms 
)
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.

Parameters
[in,out]eventA reference to the v4l2_event structure to fill.
[in]max_wait_msSpecifies the max wait time for dequeuing an event, in milliseconds.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]paramsParameters to be applied on the frame, structure of type #v4l2_enc_enable_ext_rate_ctr
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]paramsParameters to be applied on the frame, structure of type v4l2_enc_enable_ext_rps_ctr
Returns
0 for success, -1 otherwise.
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.

Returns
0 for success, -1 otherwise.
void NvV4l2Element::enableProfiling ( )
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.

Parameters
[in]paramsParameters to be applied on the frame, structure of type v4l2_enc_enable_reconcrc_param.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]paramsParameters to be applied on the frame, structure of type v4l2_enc_enable_roi_param.
Returns
0 for success, -1 otherwise.
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.

Returns
0 for success, -1 otherwise.
int NvV4l2Element::getControl ( uint32_t  id,
int32_t &  value 
)
inherited

Gets the value of a control.

Calls VIDIOC_G_CTRL IOCTL internally.

Parameters
[in]idID of the control to get.
[out]valueA reference to the variable into which the control value is read.
Returns
0 for success, -1 otherwise.
int NvV4l2Element::getExtControls ( struct v4l2_ext_controls &  ctl)
inherited

Gets the value of several controls.

Calls VIDIOC_G_EXT_CTRLS IOCTL internally.

Parameters
[in,out]ctlA pointer to the controls to get.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]buffer_indexIndex of the capture plane buffer whose metadata is required.
[in,out]enc_metadataReference to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata to be filled.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]buffer_indexIndex of the capture plane buffer whose metadata is required.
[in,out]enc_mv_metadataReference to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata_MV to be filled.
Returns
0 for success, -1 otherwise.
void NvElement::getProfilingData ( NvElementProfiler::NvElementProfilerData data)
inherited

Gets profiling data for the element.

Returns
A constant reference to the element's profiling data.
virtual int NvV4l2Element::isInError ( )
virtualinherited

Reimplemented from NvElement.

bool NvElement::isProfilingEnabled ( )
inherited

Checks whether profiling is enabled for the element.

Returns
Boolean value indicating if profiling is enabled.
void NvElement::printProfilingStats ( std::ostream &  out_stream = std::cout)
inherited

Prints profiling data for the element to an output stream.

Parameters
[in]out_streamOutput stream of type std::ostream to print the data to. It takes the default value std::cout if not specified.
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.

Parameters
[in]bitrateBitrate of the encoded stream, in bits per second.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]pixfmtOne of the coded V4L2 pixel formats.
[in]widthWidth of the input buffers in pixels.
[in]heightHeight of the input buffers in pixels.
[in]sizeimageMaximum size of the encoded buffers on the capture. plane in bytes
Returns
0 for success, -1 otherwise.
int NvVideoEncoder::setConstantQp ( int  qp_value)

Sets the encoder constant qp.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE, V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, and V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP. Must be called after setFormat on both the planes and before requestBuffers on any of the planes.

Parameters
[in]qp_valueQp value
Returns
0 for success, -1 otherwise.
int NvV4l2Element::setControl ( uint32_t  id,
int32_t  value 
)
inherited

Sets the value of a control.

Calls VIDIOC_S_CTRL IOCTL internally.

Parameters
[in]idID of the control to be set.
[in]valueValue to be set on the control.
Returns
0 for success, -1 otherwise.
int NvVideoEncoder::setEncoderCommand ( int  cmd,
int  flags 
)

Sets the encoder command.

Calls the VIDIOC_ENCODER_CMD internally with encoder commands.

Returns
0 for succes, -1 otherwise.
int NvV4l2Element::setExtControls ( struct v4l2_ext_controls &  ctl)
inherited

Sets the value of several controls.

Calls VIDIOC_S_EXT_CTRLS IOCTL internally.

Parameters
[in]ctlA pointer to the controls to set.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]enabledBoolean value indicating whether to enable/disable the control.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]framerate_numNumerator part of the framerate fraction.
[in]framerate_denDenominator part of the framerate fraction.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]typeHW Preset Type, one of enum v4l2_enc_hw_preset_type_param.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]intervalInterval between two IDR frames, in number of frames.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]intervalInterval between two I frames, in number of frames.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]buffer_indexIndex of output plane buffer on which the external RC params should be applied.
[in]paramsParameters to be applied on the frame, structure of type v4l2_ctrl_videoenc_input_metadata
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]enabledBoolean value indicating whether to enable/disable the control.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]enabledBoolean value indicating whether to enable/disable the control.
Returns
0 for success, -1 otherwise.
int NvVideoEncoder::setInsertVuiEnabled ( bool  enabled)

Enables/disables insert VUI.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE. Must be called after setFormat on both the planes.

Parameters
[in]enabledBoolean value indicating whether to enable/disable the control.
Returns
0 for success, -1 otherwise.
int NvVideoEncoder::setLevel ( enum v4l2_mpeg_video_h264_level  level)

Set the encoder level.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_H264_LEVEL. Must be called after setFormat on both the planes and before requestBuffers on any of the planes.

Parameters
[in]levelLevel to be used for encoding, one of enum v4l2_mpeg_video_h264_level
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]numNumber of B frames.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]num_framesNumber of reference frames.
Returns
0 for success, -1 otherwise.
int NvVideoEncoder::setOutputPlaneFormat ( uint32_t  pixfmt,
uint32_t  width,
uint32_t  height 
)

Sets the format on the encoder output plane.

Calls VIDIOC_S_FMT IOCTL internally on the output plane.

Precondition
Applications must set the capture plane format using setCapturePlaneFormat before calling this method.
Parameters
[in]pixfmtOne of the raw V4L2 pixel formats.
[in]widthWidth of the input buffers in pixels.
[in]heightHeight of the input buffers in pixels.
Returns
0 for success, -1 otherwise.
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

Parameters
[in]peak_bitratePeak Bitrate of the encoded stream, in bits per second.
Returns
0 for success, -1 otherwise.
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::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.

Parameters
[in]profileProfile to be used for encoding.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]MinQpIMinimum Qp Value for I frame.
[in]MaxQpIMinimum Qp Value for I frame.
[in]MinQpPMinimum Qp Value for P frame.
[in]MaxQpPMinimum Qp Value for P frame.
[in]MinQpBMinimum Qp Value for B frame.
[in]MaxQpBMinimum Qp Value for B frame.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]modeType of rate control, one of enum v4l2_mpeg_video_bitrate_mode.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]buffer_indexIndex of the output plane buffer to apply the ROI params.
[in]paramsA reference to the parameters to be applied on the frame, structure of type v4l2_enc_frame_ROI_params.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]intervalSlice intra-refresh interval, in number of slices.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]typeSlice length type, one of enum v4l2_enc_slice_length_type.
[in]lengthLength 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.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]levelTemporal tradeoff level, one of v4l2_enc_temporal_tradeoff_level_type.
Returns
0 for success, -1 otherwise.
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.

Parameters
[in]sizeVirtual buffer size, in bytes.
Returns
0 for success, -1 otherwise.
int NvV4l2Element::subscribeEvent ( uint32_t  type,
uint32_t  id,
uint32_t  flags 
)
inherited

Subscribes to an V4L2 event.

Calls VIDIOC_SUBSCRIBE_EVENT IOCTL internally.

Parameters
[in]typeType of the event.
[in]idID of the event source.
[in]flagsEvent flags.
Returns
0 for success, -1 otherwise.
virtual int NvV4l2Element::waitForIdle ( uint32_t  max_wait_ms)
virtualinherited

Waits until the element processes all the output plane buffers.

Objects extending V4l2Element must implement this because the idle condition is component-specific.

Parameters
[in]max_wait_msMax time to wait in milliseconds.
Returns
0 for success, -1 otherwise.

Reimplemented in NvVideoConverter.

Field Documentation

void* NvV4l2Element::app_data
inherited

A pointer to the application-specific data.

Definition at line 169 of file NvV4l2Element.h.

NvV4l2ElementPlane NvV4l2Element::capture_plane
inherited

Sets the capture plane.

Capture plane of the element

Definition at line 145 of file NvV4l2Element.h.

uint32_t NvV4l2Element::capture_plane_pixfmt
protectedinherited

Pixel format of capture plane buffers.

Definition at line 182 of file NvV4l2Element.h.

const char* NvElement::comp_name
protectedinherited

Specifies the name of the component, for debugging.

Definition at line 122 of file NvElement.h.

int NvV4l2Element::fd
protectedinherited

Specifies the FD of the device opened using v4l2_open.

Definition at line 179 of file NvV4l2Element.h.

int NvElement::is_in_error
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().

NvV4l2ElementPlane NvV4l2Element::output_plane
inherited

Sets the output plane.

Output plane of the element

Definition at line 141 of file NvV4l2Element.h.

uint32_t NvV4l2Element::output_plane_pixfmt
protectedinherited

Pixel format of output plane buffers.

Definition at line 181 of file NvV4l2Element.h.

NvElementProfiler NvElement::profiler
protectedinherited

Profiler for the element.

Definition at line 124 of file NvElement.h.


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