L4T Multimedia API Reference

32.3.1 Release

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

Detailed Description

Defines a helper class for V4L2 Video Decoder.

The video decoder device node is /dev/nvhost-nvdec. The category name for the decoder is "NVDEC".

Refer to V4L2 Video Decoder for more information on the decoder.

Definition at line 58 of file NvVideoDecoder.h.

Inheritance diagram for NvVideoDecoder:
Collaboration diagram for NvVideoDecoder:

Public Member Functions

 ~NvVideoDecoder ()
 
int setCapturePlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height)
 Sets the format on the decoder output plane. More...
 
int setOutputPlaneFormat (uint32_t pixfmt, uint32_t sizeimage)
 Sets the format on the decoder output plane. More...
 
int disableCompleteFrameInputBuffer ()
 Informs the decoder that input buffers may not contain complete frames. More...
 
int setFrameInputMode (unsigned int ctrl_value)
 Informs the decoder that input buffers may not contain complete frames. More...
 
int disableDPB ()
 Disables the display picture buffer. More...
 
int getMinimumCapturePlaneBuffers (int &num)
 Gets the minimum number of buffers to be requested on the decoder capture plane. More...
 
int setSkipFrames (enum v4l2_skip_frames_type skip_frames)
 Sets the skip-frames parameter of the decoder. More...
 
int setMaxPerfMode (int flag)
 Sets the decoder for maximum performance. More...
 
int enableMetadataReporting ()
 Enables video decoder output metadata reporting. More...
 
int checkifMasteringDisplayDataPresent (v4l2_ctrl_video_displaydata &displaydata)
 
int MasteringDisplayData (v4l2_ctrl_video_hdrmasteringdisplaydata *hdrmasteringdisplaydata)
 
int getMetadata (uint32_t buffer_index, v4l2_ctrl_videodec_outputbuf_metadata &metadata)
 Gets metadata for the decoded capture plane buffer. More...
 
int getInputMetadata (uint32_t buffer_index, v4l2_ctrl_videodec_inputbuf_metadata &input_metadata)
 Gets metadata for the decoder output plane buffer. 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 NvVideoDecodercreateVideoDecoder (const char *name, int flags=0)
 Creates a new V4L2 Video Decoder 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

NvVideoDecoder::~NvVideoDecoder ( )

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 NvVideoDecoder::checkifMasteringDisplayDataPresent ( v4l2_ctrl_video_displaydata displaydata)
int NvVideoDecoder::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 NvVideoDecoder* NvVideoDecoder::createVideoDecoder ( const char *  name,
int  flags = 0 
)
static

Creates a new V4L2 Video Decoder object named name.

This method internally calls v4l2_open on the decoder dev node "/dev/nvhost-nvdec" 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.

Returns
Reference to the newly created decoder object else NULL in case of failure during initialization.
int NvVideoDecoder::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 NvVideoDecoder::disableCompleteFrameInputBuffer ( )

Informs the decoder that input buffers may not contain complete frames.

Deprecated interface, Use setFrameInputMode instead.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_DISABLE_COMPLETE_FRAME_INPUT.

Returns
0 for success, -1 otherwise.
int NvVideoDecoder::disableDPB ( )

Disables the display picture buffer.

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

Returns
0 for success, -1 otherwise.
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 NvVideoDecoder::enableMetadataReporting ( )

Enables video decoder output metadata reporting.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_ERROR_REPORTING. 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 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 NvVideoDecoder::getInputMetadata ( uint32_t  buffer_index,
v4l2_ctrl_videodec_inputbuf_metadata input_metadata 
)

Gets metadata for the decoder output plane buffer.

Calls the VIDIOC_G_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEODEC_INPUT_METADATA. Must be called for a buffer that has been dequeued from the output plane. The returned metadata corresponds to the last dequeued buffer with index buffer_index.

Parameters
[in]buffer_indexIndex of the output plane buffer whose metadata is required.
[in,out]input_metadataReference to the metadata structure v4l2_ctrl_videodec_inputbuf_metadata to be filled.
Returns
0 for success, -1 otherwise.
int NvVideoDecoder::getMetadata ( uint32_t  buffer_index,
v4l2_ctrl_videodec_outputbuf_metadata metadata 
)

Gets metadata for the decoded capture plane buffer.

Calls the VIDIOC_G_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEODEC_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]metadataReference to the metadata structure v4l2_ctrl_videodec_outputbuf_metadata to be filled.
Returns
0 for success, -1 otherwise.
int NvVideoDecoder::getMinimumCapturePlaneBuffers ( int &  num)

Gets the minimum number of buffers to be requested on the decoder capture plane.

Calls the VIDIOC_G_CTRL IOCTL internally with Control ID V4L2_CID_MIN_BUFFERS_FOR_CAPTURE. It is valid after the first V4L2_RESOLUTION_CHANGE_EVENT and may change after each subsequent event.

Parameters
[out]numA reference to the integer to return the number of buffers.
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.
int NvVideoDecoder::MasteringDisplayData ( v4l2_ctrl_video_hdrmasteringdisplaydata hdrmasteringdisplaydata)
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 NvVideoDecoder::setCapturePlaneFormat ( uint32_t  pixfmt,
uint32_t  width,
uint32_t  height 
)

Sets the format on the decoder output plane.

Calls VIDIOC_S_FMT IOCTL internally on the capture plane.

Parameters
[in]pixfmtOne of the raw V4L2 pixel formats.
[in]widthWidth of the output buffers in pixels.
[in]heightHeight of the output buffers in pixels.
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 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 NvVideoDecoder::setFrameInputMode ( unsigned int  ctrl_value)

Informs the decoder that input buffers may not contain complete frames.

Calls the VIDIOC_S_EXT_CTRLS IOCTL internally with Control ID V4L2_CID_MPEG_VIDEO_DISABLE_COMPLETE_FRAME_INPUT.

Parameters
[in]ctrl_valuecontrol value to disable complete frame input buffer.
Returns
0 for success, -1 otherwise.
int NvVideoDecoder::setMaxPerfMode ( int  flag)

Sets the decoder 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.

Parameters
[in]flagInteger variable to indicate whether max performance is to be enabled/disabled.
Returns
0 for success, -1 otherwise.
int NvVideoDecoder::setOutputPlaneFormat ( uint32_t  pixfmt,
uint32_t  sizeimage 
)

Sets the format on the decoder output plane.

Calls the VIDIOC_S_FMT IOCTL internally on the output plane.

Parameters
[in]pixfmtOne of the coded V4L2 pixel formats.
[in]sizeimageMaximum size of the buffers on the output plane. containing encoded data in bytes.
Returns
0 for success, -1 otherwise.
int NvVideoDecoder::SetPollInterrupt ( )

Sets the polling interrupt, now if the application calls Poll, the device should not block, in other words polling is disabled.

int NvVideoDecoder::setSkipFrames ( enum v4l2_skip_frames_type  skip_frames)

Sets the skip-frames parameter of the decoder.

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

Parameters
[in]skip_framesType of frames to skip decoding, one of enum v4l2_skip_frames_type.
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: