L4T Multimedia API Reference

32.3.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NvVideoEncoder.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA CORPORATION nor the names of its
13  * contributors may be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
45 #ifndef __NV_VIDEO_ENCODER_H__
46 #define __NV_VIDEO_ENCODER_H__
47 
48 #include "NvV4l2Element.h"
49 
60 {
61 public:
76  static NvVideoEncoder *createVideoEncoder(const char *name, int flags = 0);
77 
79 
92  int setOutputPlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height);
105  int setCapturePlaneFormat(uint32_t pixfmt, uint32_t width,
106  uint32_t height, uint32_t sizeimage);
107 
119  int setFrameRate(uint32_t framerate_num, uint32_t framerate_den);
120 
132  int setBitrate(uint32_t bitrate);
133 
145  int setPeakBitrate(uint32_t peak_bitrate);
146 
159  int setProfile(uint32_t profile);
160 
168  int setEncoderCommand(int cmd, int flags);
169 
182  int setLevel(uint32_t level);
183 
196  int setMaxPerfMode(int flag);
209  int setConstantQp(int qp_value);
210 
223  int setRateControlMode(enum v4l2_mpeg_video_bitrate_mode mode);
224 
236  int setIFrameInterval(uint32_t interval);
237 
249  int setIDRInterval(uint32_t interval);
250 
260  int forceIDR();
261 
275 
289  int setSliceLength(v4l2_enc_slice_length_type type, uint32_t length);
290 
303 
318  int setROIParams(uint32_t buffer_index, v4l2_enc_frame_ROI_params & params);
319 
332 
345 
358 
371 
386  int SetInputMetaParams(uint32_t buffer_index, v4l2_ctrl_videoenc_input_metadata &params);
387 
398  int setVirtualBufferSize(uint32_t size);
399 
410  int setNumReferenceFrames(uint32_t num_frames);
411 
422  int setSliceIntrarefresh(uint32_t interval);
423 
434  int setNumBFrames(uint32_t num);
435 
447  int setInsertSpsPpsAtIdrEnabled(bool enabled);
448 
460  int setCABAC(bool enabled);
461 
473  int setSliceLevelEncode(bool enabled);
474 
485 
501  int getMetadata(uint32_t buffer_index,
503 
519  int getMotionVectors(uint32_t buffer_index,
521 
537  int setQpRange(uint32_t MinQpI, uint32_t MaxQpI, uint32_t MinQpP,
538  uint32_t MaxQpP, uint32_t MinQpB, uint32_t MaxQpB);
539 
551  int setInsertVuiEnabled(bool enabled);
552 
564  int setExtendedColorFormat(bool enabled);
565 
577  int setInsertAudEnabled(bool enabled);
578 
590  int setAlliFramesEncode(bool enabled);
591 
598  int DevicePoll(v4l2_ctrl_video_device_poll *devicepoll);
599 
604  int SetPollInterrupt();
605 
610  int ClearPollInterrupt();
611 
612 private:
616  NvVideoEncoder(const char *name, int flags);
617 
618  static const NvElementProfiler::ProfilerField valid_fields =
622 };
625 #endif
int setConstantQp(int qp_value)
Sets the encoder constant qp.
Holds the encoder frame ROI parameters to be used with V4L2_CID_MPEG_VIDEOENC_ROI_PARAMS IOCTL...
Holds the encoder output metadata for a frame, to be used with V4L2_CID_MPEG_VIDEOENC_METADATA IOCTL...
int setMaxPerfMode(int flag)
Sets the encoder for maximum performance.
int setExtendedColorFormat(bool enabled)
Enables/disables extended color format.
int setRateControlMode(enum v4l2_mpeg_video_bitrate_mode mode)
Sets the encoder rate control mode.
NVIDIA Multimedia API: V4L2 Helper Class
int setSliceLength(v4l2_enc_slice_length_type type, uint32_t length)
Sets the encoder output slice length.
v4l2_enc_temporal_tradeoff_level_type
Specifies the types of encoder temporal tradeoff levels.
int setTemporalTradeoff(v4l2_enc_temporal_tradeoff_level_type level)
Sets the encoder Temporal Tradeoff.
Defines a helper class for V4L2 based components.
Definition: NvV4l2Element.h:65
int setFrameRate(uint32_t framerate_num, uint32_t framerate_den)
Sets the encode framerate.
int setProfile(uint32_t profile)
Sets the encoder profile.
int enableMotionVectorReporting()
Enables video encoder output motion vector metadata reporting.
static const ProfilerField PROFILER_FIELD_FPS
v4l2_enc_slice_length_type
Enum specifying the type of slice length.
int getMetadata(uint32_t buffer_index, v4l2_ctrl_videoenc_outputbuf_metadata &enc_metadata)
Gets metadata for the encoded capture plane buffer.
int setCABAC(bool enabled)
Enables/disables CABAC entropy encoding for H264.
int setCapturePlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height, uint32_t sizeimage)
Sets the format on the converter capture plane.
Holds the params to configure encoder for external rps control to be used with V4L2_CID_MPEG_VIDEOENC...
Holds the params to configure encoder for external rate control mode to be used with V4L2_CID_MPEG_VI...
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 o...
int enableROI(v4l2_enc_enable_roi_param &params)
Enables External ROI.
static const ProfilerField PROFILER_FIELD_TOTAL_UNITS
int setNumReferenceFrames(uint32_t num_frames)
Sets the number of reference frames of the encoder.
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 ...
int setAlliFramesEncode(bool enabled)
Enables/disables all i-frame encode.
int setInsertVuiEnabled(bool enabled)
Enables/disables insert VUI.
int setHWPresetType(v4l2_enc_hw_preset_type type)
Sets the encoder HW Preset Type.
Defines a helper class for V4L2 Video Encoder.
int setBitrate(uint32_t bitrate)
Sets the encoder bitrate.
int setIDRInterval(uint32_t interval)
Sets the encoder IDR interval.
int setInsertAudEnabled(bool enabled)
Enables/disables insert AUD.
int SetPollInterrupt()
Sets the polling interrupt, now if the application calls Poll, the device should not block...
int setOutputPlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height)
Sets the format on the encoder output plane.
static NvVideoEncoder * createVideoEncoder(const char *name, int flags=0)
Creates a new V4L2 Video Encoder object named name.
Holds the params to configure encoder for ROI parameters encoding.
Holds the motion vector parameters for one complete frame.
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.
int setEncoderCommand(int cmd, int flags)
Sets the encoder command.
v4l2_enc_hw_preset_type
Specifies the encoder HW Preset type.
int setLevel(uint32_t level)
Set the encoder level.
int ClearPollInterrupt()
Clears the polling interrupt, now if the application calls Poll, the device should block until the ev...
int setInsertSpsPpsAtIdrEnabled(bool enabled)
Enables/disables insert SPS PPS at every IDR.
int setVirtualBufferSize(uint32_t size)
Sets the virtual buffer size of the encoder.
int setIFrameInterval(uint32_t interval)
Sets the encoder I-frame interval.
int enableExternalRPS(v4l2_enc_enable_ext_rps_ctr &params)
Enable External RPS.
int setPeakBitrate(uint32_t peak_bitrate)
Sets the encoder peak bitrate.
int enableReconCRC(v4l2_enc_enable_reconcrc_param &params)
Enables Recon CRC.
Holds the encoder frame input metadata parameters.
int enableExternalRC(v4l2_enc_enable_ext_rate_ctr &params)
Enable External Picture RC.
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 buf...
int setNumBFrames(uint32_t num)
Sets the number of B frames to P frames.
int setSliceLevelEncode(bool enabled)
Enables/disables Slice level encoding for H264 / HEVC.
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.
int setSliceIntrarefresh(uint32_t interval)
Sets slice intra-refresh interval params.
Holds the params to configure encoder for Reconstructed CRC encoding.
int forceIDR()
Forces an IDR frame.
static const ProfilerField PROFILER_FIELD_LATENCIES