# NvVideoDecoder Class Reference

Helper class for V4L2 Video Decoder. More...

`#include <NvVideoDecoder.h>`

Inheritance diagram for NvVideoDecoder:

List of all members.

## Public Member Functions

| ~NvVideoDecoder ()
int | setCapturePlaneFormat (uint32_t pixfmt, uint32_t width, uint32_t height)
| Sets the format on the decoder output plane.
int | setOutputPlaneFormat (uint32_t pixfmt, uint32_t sizeimage)
| Sets the format on the decoder output plane.
int | disableCompleteFrameInputBuffer ()
| Inform decoder input buffers may not contain complete frames.
int | disableDPB ()
| Disable display picture buffer.
int | getMinimumCapturePlaneBuffers (int &num)
| Get the minimum number of buffers to be requested on decoder capture plane.
int | setSkipFrames (enum v4l2_skip_frames_type skip_frames)
| Set skip-frames parameter of the decoder.
int | enableMetadataReporting ()
| Enable video decoder output metadata reporting.
int | getMetadata (uint32_t buffer_index, v4l2_ctrl_videodec_outputbuf_metadata &metadata)
| Get metadata for decoded capture plane buffer.

## Static Public Member Functions

static NvVideoDecoder * | createVideoDecoder (const char *name, int flags=0)
| Create a new V4L2 Video Decoder named name.

## Private Member Functions

| NvVideoDecoder (const char *name, int flags)
| Contructor used by createVideoDecoder.

## Static Private Attributes

static const NvElementProfiler::ProfilerField | valid_fields

## Detailed Description

Helper class for V4L2 Video Decoder.

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

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

Definition at line 48 of file NvVideoDecoder.h.

## Constructor & Destructor Documentation

NvVideoDecoder::~NvVideoDecoder | ( |  | ) |

Definition at line 85 of file NvVideoDecoder.cpp.

NvVideoDecoder::NvVideoDecoder | ( | const char * | name,
|  | int | flags |
| ) |  |  | `[private]`

Contructor used by createVideoDecoder.

Definition at line 68 of file NvVideoDecoder.cpp.

## Member Function Documentation

NvVideoDecoder * NvVideoDecoder::createVideoDecoder | ( | const char * | name,
|  | int | flags = `0` |
| ) |  |  | `[static]`

Create a new V4L2 Video Decoder named name.

This function 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.

Definition at line 74 of file NvVideoDecoder.cpp.

int NvVideoDecoder::disableCompleteFrameInputBuffer | ( |  | ) |

Inform decoder 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. Must be called before setFormat on any of the planes.

Returns:
  0 for success, -1 for failure

Definition at line 165 of file NvVideoDecoder.cpp.

int NvVideoDecoder::disableDPB | ( |  | ) |

Disable 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 for failure

Definition at line 144 of file NvVideoDecoder.cpp.

int NvVideoDecoder::enableMetadataReporting | ( |  | ) |

Enable 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 for failure

Definition at line 214 of file NvVideoDecoder.cpp.

int NvVideoDecoder::getMetadata | ( | uint32_t | buffer_index,
|  | v4l2_ctrl_videodec_outputbuf_metadata & | metadata |
| ) |  |  |

Get metadata for decoded capture plane buffer.

Calls the VIDIOC_S_EXT_CTRLS ioctl internally with Control id V4L2_CID_MPEG_VIDEODEC_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.

Parameters:

  `[in]` | buffer_index | Index of the capture plane buffer whose metadata is required
  `[in,out]` | Reference | to the metadata structure v4l2_ctrl_videodec_outputbuf_metadata to be filled

Returns:
  0 for success, -1 for failure

Definition at line 235 of file NvVideoDecoder.cpp.

int NvVideoDecoder::getMinimumCapturePlaneBuffers | ( | int & | num | ) |

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

Calls the VIDIOC_G_CTRL ioctl internally with Control id V4L2_CID_MIN_BUFFERS_FOR_CAPTURE. Is valid after the first V4L2_RESOLUTION_CHANGE_EVENT and may change after each subsequent event.

Parameters:

  `[out]` | num | Pointer to integer to return the number of buffers

Returns:
  0 for success, -1 for failure

Definition at line 185 of file NvVideoDecoder.cpp.

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]` | 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

Returns:
  0 for success, -1 for failure.

Definition at line 90 of file NvVideoDecoder.cpp.

int NvVideoDecoder::setOutputPlaneFormat | ( | uint32_t | pixfmt,
|  | uint32_t | sizeimage |
| ) |  |  |

Sets the format on the decoder output plane.

Calls VIDIOC_S_FMT ioctl internally on the output plane.

Parameters:

  `[in]` | pixfmt | One of the coded V4L2 pixel formats
  `[in]` | sizeimage | Maximum size of the buffers on the output plane containing encoded data in bytes

Returns:
  0 for success, -1 for failure.

Definition at line 119 of file NvVideoDecoder.cpp.

int NvVideoDecoder::setSkipFrames | ( | enum v4l2_skip_frames_type | skip_frames | ) |

Set 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_frames | Type of frames to skip decoding, one of enum v4l2_skip_frames_type

Returns:
  0 for success, -1 for failure

Definition at line 192 of file NvVideoDecoder.cpp.

## Member Data Documentation

const NvElementProfiler::ProfilerField NvVideoDecoder::valid_fields `[static, private]`

Initial value:

                NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS |
                NvElementProfiler::PROFILER_FIELD_FPS

Definition at line 176 of file NvVideoDecoder.h.

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

- include/NvVideoDecoder.h
- samples/common/classes/NvVideoDecoder.cpp