L4T Multimedia API Reference

27.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nvee_video_decode_cuda.md
Go to the documentation of this file.
1 Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
2 
3 @page ee_video_decode_cuda Video CUDA Decode Sample
4 @{
5 
6  - [Overview](#overview)
7  - [Key Structure and Classes](#key)
8 
9 - - - - - - - - - - - - - - -
10 <a name="overview">
11 ## Overview ##
12 
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.
16 
17 ![](nvee_video_dec_cuda.jpg)
18 
19 Supported video formats:
20 - H.264
21 - H.265
22 
23 #### Additional Details
24 
25 The main flow of this sample is as follows:
26 
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
29 match.
30 
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);
35 
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.
39 
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);
44 
45 This call sets up the libv4l2 capture plane in pitch linear
46 format. This is the format that is common to the software
47 implementation.
48 
49 `NvEGLImageFromFd` is syntax error that
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
54 EGLImage.
55 
56 - - - - - - - - - - - - - - -
57 <a name="key">
58 ## Key Structure and Classes ##
59 
60 This sample uses the following key structures and classes:
61 
62 |Element|Description|
63 |---|---|
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.|
70 
71 %NvVideoDecoder packages all video decoding-related elements and
72 functions. Key members used in the sample are:
73 
74 |Member|Description|
75 |---|---|
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.|
86 
87 %NvVideoConverter packages all video converting-related elements and
88 functions. Key members used in the sample are:
89 
90 |Member|Description|
91 |---|---|
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.|
97 
98 Both %NvVideoDecoder and %NvVideoConverter contain 2 key elements:
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:
101 
102 |Element|Description|
103 |---|---|
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|
115 
116 Two global functions are used to create and destroy EGLImage from the
117 dmabuf file descriptor:
118 
119 |Function|Description|
120 |---|---|
121 |NvEGLImageFromFd|Create EGLImage from dmabuf file descriptor.|
122 |NvDestroyEGLImage|Destroy the EGLImage.|
123 
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.
Definition: NvEglRenderer.h:74
int NvDestroyEGLImage(EGLDisplay display, EGLImageKHR eglImage)
This method must be used for destroying EGLImage object.