#include <NvVideoEncoder.h>
Public Member Functions | |
~NvVideoEncoder () | |
int | setOutputPlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height) |
Sets the format on the encoder output plane. | |
int | setCapturePlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height, uint32_t sizeimage) |
Sets the format on the encoder capture plane. | |
int | setFrameRate (uint32_t framerate_num, uint32_t framerate_den) |
Set the encode framerate. | |
int | setBitrate (uint32_t bitrate) |
Set the encoder bitrate. | |
int | setProfile (uint32_t profile) |
Set the encoder profile. | |
int | setLevel (enum v4l2_mpeg_video_h264_level level) |
Set the encoder level. | |
int | setRateControlMode (enum v4l2_mpeg_video_bitrate_mode mode) |
Set the encoder rate control mode. | |
int | setIFrameInterval (uint32_t interval) |
Set the encoder I-frame interval. | |
int | setIDRInterval (uint32_t interval) |
Set the encoder IDR interval. | |
int | forceIDR () |
Force an IDR frame. | |
int | setTemporalTradeoff (v4l2_enc_temporal_tradeoff_level_type level) |
Set the encoder Temporal Tradeoff. | |
int | setSliceLength (v4l2_enc_slice_length_type type, uint32_t length) |
Set the encoder output slice length. | |
int | setROIParams (uint32_t buffer_index, v4l2_enc_frame_ROI_params ¶ms) |
Set the Region of Interest parameters for the next buffer which will be queued on output plane with index buffer_index. | |
int | setVirtualBufferSize (uint32_t size) |
Set the virtual buffer size of the encoder. | |
int | setNumReferenceFrames (uint32_t num_frames) |
Set the number of reference frames of the encoder. | |
int | setSliceIntrarefresh (uint32_t interval) |
Set slice intrareferesh interval params. | |
int | setNumBFrames (uint32_t num) |
Set the number of B frames two P frames. | |
int | setInsertSpsPpsAtIdrEnabled (bool enabled) |
Enabled/disable insert SPS PPS at every IDR. | |
int | enableMotionVectorReporting () |
Enable video encoder output motion vector metadata reporting. | |
int | getMetadata (uint32_t buffer_index, v4l2_ctrl_videoenc_outputbuf_metadata &enc_metadata) |
Get metadata for encoded capture plane buffer. | |
int | getMotionVectors (uint32_t buffer_index, v4l2_ctrl_videoenc_outputbuf_metadata_MV &enc_mv_metadata) |
Get motion vector metadata for encoded capture plane buffer. | |
int | setQpRange (uint32_t MinQpI, uint32_t MaxQpI, uint32_t MinQpP, uint32_t MaxQpP, uint32_t MinQpB, uint32_t MaxQpB) |
Set QP values for I/P/B frames. | |
Static Public Member Functions | |
static NvVideoEncoder * | createVideoEncoder (const char *name, int flags=0) |
Create a new V4L2 Video Encoder named name. | |
Private Member Functions | |
NvVideoEncoder (const char *name, int flags) | |
Contructor used by createVideoEncoder. | |
Static Private Attributes | |
static const NvElementProfiler::ProfilerField | valid_fields |
The video encoder device node is "/dev/nvhost-msenc". The category name for encoder is "NVENC".
Refer to V4L2 Video Encoder for more information on the converter.
Definition at line 49 of file NvVideoEncoder.h.
NvVideoEncoder::~NvVideoEncoder | ( | ) |
Definition at line 90 of file NvVideoEncoder.cpp.
NvVideoEncoder::NvVideoEncoder | ( | const char * | name, | |
int | flags | |||
) | [private] |
NvVideoEncoder * NvVideoEncoder::createVideoEncoder | ( | const char * | name, | |
int | flags = 0 | |||
) | [static] |
Create a new V4L2 Video Encoder named name.
This function 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 should be opened.
The device is opened in blocking mode which can be modified by passing the O_NONBLOCK flag to this method.
Definition at line 79 of file NvVideoEncoder.cpp.
int NvVideoEncoder::enableMotionVectorReporting | ( | ) |
Enable 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.
Definition at line 534 of file NvVideoEncoder.cpp.
int NvVideoEncoder::forceIDR | ( | ) |
Force 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.
[in] | interval | Interval between two IDR frames, in number of frames |
Definition at line 323 of file NvVideoEncoder.cpp.
int NvVideoEncoder::getMetadata | ( | uint32_t | buffer_index, | |
v4l2_ctrl_videoenc_outputbuf_metadata & | enc_metadata | |||
) |
Get metadata for 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 which 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] | Reference | to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata to be filled |
Definition at line 557 of file NvVideoEncoder.cpp.
int NvVideoEncoder::getMotionVectors | ( | uint32_t | buffer_index, | |
v4l2_ctrl_videoenc_outputbuf_metadata_MV & | enc_mv_metadata | |||
) |
Get motion vector metadata for 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 which 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] | Reference | to the metadata structure v4l2_ctrl_videoenc_outputbuf_metadata_MV to be filled |
Definition at line 581 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setBitrate | ( | uint32_t | bitrate | ) |
Set the encoder bitrate.
Calls the VIDIOC_S_EXT_CTRLS ioctl internally with Control id V4L2_CID_MPEG_VIDEO_BITRATE. Can be called anytime after setFormat on both the planes.
[in] | bitrate | Bitrate of the encoded stream, in bits per second |
Definition at line 167 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setCapturePlaneFormat | ( | uint32_t | pixfmt, | |
uint32_t | width, | |||
uint32_t | height, | |||
uint32_t | sizeimage | |||
) |
Sets the format on the encoder 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 |
Definition at line 124 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setFrameRate | ( | uint32_t | framerate_num, | |
uint32_t | framerate_den | |||
) |
Set the encode framerate.
Calls the VIDIOC_S_PARM ioctl on the encoder capture plane. Can b called anytime after setFormat on both the planes.
[in] | framerate_num | Numerator part of the framerate fraction |
[in] | framerate_den | Denominator part of the framerate fraction |
Definition at line 152 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setIDRInterval | ( | uint32_t | interval | ) |
Set 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 |
Definition at line 300 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setIFrameInterval | ( | uint32_t | interval | ) |
Set 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 |
Definition at line 277 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setInsertSpsPpsAtIdrEnabled | ( | bool | enabled | ) |
Enabled/disable 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 wether to enable/disable the control. |
Definition at line 511 of file NvVideoEncoder.cpp.
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.
[in] | level | Level to be used for encoding, one of enum v4l2_mpeg_video_h264_level |
Definition at line 225 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setNumBFrames | ( | uint32_t | num | ) |
Set the number of B frames two 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. |
Definition at line 488 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setNumReferenceFrames | ( | uint32_t | num_frames | ) |
Set 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. |
Definition at line 440 of file NvVideoEncoder.cpp.
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.
[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 |
Definition at line 95 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setProfile | ( | uint32_t | profile | ) |
Set 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 |
Definition at line 191 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setQpRange | ( | uint32_t | MinQpI, | |
uint32_t | MaxQpI, | |||
uint32_t | MinQpP, | |||
uint32_t | MaxQpP, | |||
uint32_t | MinQpB, | |||
uint32_t | MaxQpB | |||
) |
Set 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 |
Definition at line 605 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setRateControlMode | ( | enum v4l2_mpeg_video_bitrate_mode | mode | ) |
Set 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 |
Definition at line 254 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setROIParams | ( | uint32_t | buffer_index, | |
v4l2_enc_frame_ROI_params & | params | |||
) |
Set the Region of Interest 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_ROI_PARAMS. Must be called after requesting buffer on both the planes.
[in] | buffer_index | Index of output plane buffer on which the ROI params should be applied. |
[in] | params | Parameters to be applied on the frame, structure of type v4l2_enc_frame_ROI_params |
Definition at line 392 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setSliceIntrarefresh | ( | uint32_t | interval | ) |
Set slice intrareferesh 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 intrarefresh interval, in number of slices. |
Definition at line 464 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setSliceLength | ( | v4l2_enc_slice_length_type | type, | |
uint32_t | length | |||
) |
Set 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 type is V4L2_ENC_SLICE_LENGTH_TYPE_BITS, else in number of MBs if type is V4L2_ENC_SLICE_LENGTH_TYPE_MBLK |
Definition at line 367 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setTemporalTradeoff | ( | v4l2_enc_temporal_tradeoff_level_type | level | ) |
Set 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 |
Definition at line 344 of file NvVideoEncoder.cpp.
int NvVideoEncoder::setVirtualBufferSize | ( | uint32_t | size | ) |
Set 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. |
Definition at line 417 of file NvVideoEncoder.cpp.
const NvElementProfiler::ProfilerField NvVideoEncoder::valid_fields [static, private] |
Initial value:
NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS | NvElementProfiler::PROFILER_FIELD_LATENCIES | NvElementProfiler::PROFILER_FIELD_FPS
Definition at line 383 of file NvVideoEncoder.h.