Defines a helper class for V4L2 Video Converter.
Use video converter for color space conversion, scaling, and conversion between hardware buffer memory (V4L2_MEMORY_MMAP/ V4L2_MEMORY_DMABUF
) and software buffer memory (V4L2_MEMORY_USERPTR
).
The video converter device node is "/dev/nvhost-vic"
. The category name for the converter is "NVVIDCONV"
.
Refer to V4L2 Video Converter for more information on the converter.
Definition at line 64 of file NvVideoConverter.h.
Public Member Functions | |
~NvVideoConverter () | |
int | setCapturePlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type) |
Sets the format on the converter output plane. More... | |
int | setOutputPlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type) |
Sets the format on the converter output plane. More... | |
int | setOutputPlaneBufferLayout (enum v4l2_nv_buffer_layout type) |
Sets the buffer layout of the output plane buffers. More... | |
int | setCapturePlaneBufferLayout (enum v4l2_nv_buffer_layout type) |
Sets the buffer layout of the capture plane buffers. More... | |
int | setInterpolationMethod (enum v4l2_interpolation_method method) |
Sets the interpolation(filter) method used for scaling. More... | |
int | setFlipMethod (enum v4l2_flip_method method) |
Sets the flip method. More... | |
int | setTnrAlgorithm (enum v4l2_tnr_algorithm algorithm) |
Sets the TNR(Temporal Noise Reduction) algorithm to use. More... | |
int | setYUVRescale (enum v4l2_yuv_rescale_method method) |
Sets the YUV Rescale method to use. More... | |
int | setCropRect (uint32_t left, uint32_t top, uint32_t width, uint32_t height) |
Set the cropping rectangle for the converter. More... | |
int | setDestRect (uint32_t left, uint32_t top, uint32_t width, uint32_t height) |
Sets the destnation rectangle for the converter. More... | |
int | waitForIdle (uint32_t max_wait_ms) |
Waits until all buffers queued on the output plane are converted and dequeued from the capture plane. 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... | |
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 NvVideoConverter * | createVideoConverter (const char *name, int flags=0) |
Creates a new V4L2 Video Converter 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... | |
NvVideoConverter::~NvVideoConverter | ( | ) |
|
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.
|
static |
Creates a new V4L2 Video Converter object named name.
This method internally calls v4l2_open
on the converter dev node "/dev/nvhost-vic"
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.
|
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. |
|
virtualinherited |
Enables profiling for the V4l2Element.
Must be called before setting either plane formats.
Reimplemented from NvElement.
|
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. |
|
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 NvVideoConverter::setCapturePlaneBufferLayout | ( | enum v4l2_nv_buffer_layout | type | ) |
Sets the buffer layout of the capture plane buffers.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_VIDEO_CONVERT_CAPTURE_PLANE_LAYOUT. Must be called before setFormat() on any of the planes.
[in] | type | Type of layout, one of enum v4l2_nv_buffer_layout. |
int NvVideoConverter::setCapturePlaneFormat | ( | uint32_t | pixfmt, |
uint32_t | width, | ||
uint32_t | height, | ||
enum v4l2_nv_buffer_layout | type | ||
) |
Sets the format on the converter output plane.
Calls VIDIOC_S_FMT
IOCTL internally on the capture plane.
[in] | pixfmt | One of the raw V4L2 pixel formats. |
[in] | width | Width of the output buffers in pixels. |
[in] | height | Height of the output buffers in pixels. |
[in] | type | Layout of the buffers in plane, one of enum v4l2_nv_buffer_layout. |
|
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 NvVideoConverter::setCropRect | ( | uint32_t | left, |
uint32_t | top, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Set the cropping rectangle for the converter.
Calls the VIDIOC_S_SELECTION internally on the capture plane. Must be called before setFormat() on any of the planes.
[in] | left | Horizontal offset of the rectangle, in pixels. |
[in] | top | Verticaal offset of the rectangle, in pixels. |
[in] | width | Width of the rectangle, in pixels. |
[in] | height | Height of the rectangle, in pixels. |
int NvVideoConverter::setDestRect | ( | uint32_t | left, |
uint32_t | top, | ||
uint32_t | width, | ||
uint32_t | height | ||
) |
Sets the destnation rectangle for the converter.
Calls the VIDIOC_S_SELECTION internally on output plane. Must be called before setFormat() on any of the planes.
[in] | left | Horizontal offset of the rectangle, in pixels |
[in] | top | Verticaal offset of the rectangle, in pixels |
[in] | width | Width of the rectangle, in pixels |
[in] | height | Height of the rectangle, in pixels |
|
inherited |
Sets the value of several controls.
Calls VIDIOC_S_EXT_CTRLS
IOCTL internally.
[in] | ctl | A pointer to the controls to set. |
int NvVideoConverter::setFlipMethod | ( | enum v4l2_flip_method | method | ) |
Sets the flip method.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_VIDEO_CONVERT_FLIP_METHOD. Must be called before setFormat() on any of the planes.
[in] | method | Type of flip method, one of enum v4l2_flip_method. |
int NvVideoConverter::setInterpolationMethod | ( | enum v4l2_interpolation_method | method | ) |
Sets the interpolation(filter) method used for scaling.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_VIDEO_CONVERT_INTERPOLATION_METHOD. Must be called before setFormat() on any of the planes.
[in] | method | Type of interpolation method, one of enum v4l2_interpolation_method. |
int NvVideoConverter::setOutputPlaneBufferLayout | ( | enum v4l2_nv_buffer_layout | type | ) |
Sets the buffer layout of the output plane buffers.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with control ID V4L2_CID_VIDEO_CONVERT_OUTPUT_PLANE_LAYOUT. Must be called before setFormat() on any of the planes.
[in] | type | Type of layout, one of enum v4l2_nv_buffer_layout. |
int NvVideoConverter::setOutputPlaneFormat | ( | uint32_t | pixfmt, |
uint32_t | width, | ||
uint32_t | height, | ||
enum v4l2_nv_buffer_layout | type | ||
) |
Sets the format on the converter 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 output buffers in pixels. |
[in] | height | Height of the output buffers in pixels. |
[in] | type | Layout of the buffers in plane, one of enum v4l2_nv_buffer_layout. |
int NvVideoConverter::setTnrAlgorithm | ( | enum v4l2_tnr_algorithm | algorithm | ) |
Sets the TNR(Temporal Noise Reduction) algorithm to use.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_VIDEO_CONVERT_TNR_ALGORITHM. Must be called before setForma() on any of the planes.
[in] | algorithm | Type of TNR algorithm to use, one of enum v4l2_tnr_algorithm. |
int NvVideoConverter::setYUVRescale | ( | enum v4l2_yuv_rescale_method | method | ) |
Sets the YUV Rescale method to use.
Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_VIDEO_CONVERT_YUV_RESCALE_METHOD. Must be called before setFormat() on any of the planes.
[in] | method | Type of YUV Rescale method to use, one of enum v4l2_yuv_rescale_method. |
|
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. |
|
virtual |
Waits until all buffers queued on the output plane are converted and dequeued from the capture plane.
This is a blocking call.
[in] | max_wait_ms | Maximum time to wait in milliseconds |
Reimplemented from NvV4l2Element.
|
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.