1 Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 @page ee_video_decode_cuda Video CUDA Decode Sample
6 - [Overview](#overview)
7 - [Key Structure and Classes](#key)
9 - - - - - - - - - - - - - - -
13 This sample demonstrates how the buffer allocated by the libv4l2
14 component is used to decode H.265/H.264 video streams, and how CUDA is
15 used aid in rendering images without extra memory copy operations.
17 
19 Supported video formats:
23 #### Additional Details
25 The main flow of
this sample is as follows:
27 Tegra provides pitch linear and block linear memory format support on
28 input and output. Input and output memory formats
do not need to
31 ret = ctx->conv->setOutputPlaneFormat(format.fmt.pix_mp.pixelformat,
32 format.fmt.pix_mp.width,
33 format.fmt.pix_mp.height,
34 NvVideoConverter::LAYOUT_BLOCK);
36 This call sets up libv4l2 output plane, i.e.,
for receiving input as
37 YUV data
for decoder, in block linear format. This is the format that
38 complies with Tegra hardware.
40 ret = ctx->conv->setCapturePlaneFormat(format.fmt.pix_mp.pixelformat,
41 format.fmt.pix_mp.width,
42 format.fmt.pix_mp.height,
43 NvVideoConverter::LAYOUT_PITCH);
45 This call sets up the libv4l2 capture plane in pitch linear
46 format. This is the format that is common to the software
50 returns an EGLImage pointer from file descriptor buffer that is
51 allocated by by the member
function of [
NvVideoDecoder](classNvVideoDecoder.html) base
class. An
52 EGLImage buffer is then used by CUDA to render a black box on
53 the display. This is implemented in a separate common routine
using
56 - - - - - - - - - - - - - - -
58 ## Key Structure and Classes ##
60 This sample uses the following key structures and classes:
64 |[
NvVideoDecoder](classNvVideoDecoder.html)|Contains all video decoding-related elements and functions.|
65 |[
NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions
for video format conversion.|
66 |[
NvEglRenderer](classNvEglRenderer.html)|Contains all EGL display rendering-related functions.|
67 |egl_image|The EGLImage used
for CUDA processing.|
68 |conv_output_plane_buf_queue|Output plane queue
for video conversion.|
69 |dec_capture_loop|The thread handler
for decoding capture loop.|
72 functions. Key members used in the sample are:
76 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5)|V4l2 output plane.|
77 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|V4l2 capture plane.|
78 |[createVideoDecoder](classNvVideoDecoder.html#a47980b18e6f22f1a53c3af732321483d)|Static
function to create video decode
object.|
79 |[subscribeEvent](classNvV4l2Element.html#a7fd9f21268d5fdc979065b1b04b93220)|Subscribe
event.|
80 |[setExtControls](classNvV4l2Element.html#aaec1f40b777bb98870f18766690d7984)|Set external control to V4l2 device.|
81 |[setOutputPlaneFormat](classNvVideoDecoder.html#a7cacbe8afce830495c25514cbd7c8efe)|Set output plane format.|
82 |[setCapturePlaneFormat](classNvVideoDecoder.html#abc20773d70cfafed881238dfda6046ce)|Set capture plane format.|
83 |[getControl](classNvV4l2Element.html#a204f7b6d6f8a4540db8bdcdffe5621ad)|TBD|
84 |[dqEvent](classNvV4l2Element.html#aa475b35ff3fa8ac35b5619c35474f38c)|Dqueue the event which report by V4l2 device.|
85 |[isInError](classNvV4l2Element.html#aa60303288ff142ea08e53fa1dc7a72bf)|Check
if under error state.|
88 functions. Key members used in the sample are:
92 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5)|The output plane.|
93 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|The capture plane.|
94 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c)|TBD|
95 |setOutputPlaneFormat|Set output plane format.|
96 |setCapturePlaneFormat|Set capture plane format.|
99 `output_plane` and `capture_plane`. These 2 objects belong to the same
100 class type [
NvV4l2ElementPlane](group__ee__nvv4lelementplane__group.html). Key members used in the sample are:
102 |Element|Description|
104 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345)|Setup the plane of V4l2 element.|
105 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c)|Destroy the plane of V4l2 element.|
106 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316)|Start/Stop the stream.|
107 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Set the callback
function of dqueue buffer thread.|
108 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd)|Start the thread of dqueue buffer.|
109 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87)|Stop the thread of dqueue buffer.|
110 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95)|Queue V4l2 buffer.|
111 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd)|Dqueue V4l2 buffer.|
112 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787)|Get the number of V4l2 buffer.|
113 |getNumQueuedBuffers|Get the number of V4l2 buffer which under queue.|
114 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f)|TBD|
116 Two global functions are used to create and destroy EGLImage from the
117 dmabuf file descriptor:
119 |Function|Description|
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for operations performed on a V4L2 Element plane.
EGLImageKHR NvEGLImageFromFd(EGLDisplay display, int dmabuf_fd)
This method must be used for getting EGLImage from dmabuf-fd.
Defines a helper class for V4L2 Video Converter.
NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0.
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.