L4T Multimedia API Reference

32.3.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_video_decode_cuda.md
Go to the documentation of this file.
1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
2 
3 @page l4t_mm_video_decode_cuda 02_video_dec_cuda
4 @{
5 
6  - [Overview](#overview)
7  - [Building and Running](#build_and_run)
8  - [Flow](#flow)
9  - [Key Structure and Classes](#key)
10 
11 - - - - - - - - - - - - - - -
12 <a name="overview">
13 ## Overview ##
14 
15 This sample demonstrates how the buffer allocated by the libv4l2
16 component is used to decode H.265/H.264 video streams, and how CUDA is
17 used aid in rendering images without extra memory copy operations.
18 
19 Supported video formats:
20 - H.264
21 - H.265
22 
23 <a name="build_and_run">
24 - - - - - - - - - - - - - - -
25 ## Building and Running ##
26 
27 #### Prerequisites ####
28 * You have followed Steps 1-3 in @ref mmapi_build.
29 * If you are building from your host Linux PC (x86), you have
30  followed Step 4 in @ref mmapi_build.
31 
32 ### To build:
33 * Enter:
34 
35  $ cd $HOME/tegra_multimedia_api/samples/02_video_dec_cuda
36  $ make
37 
38 ### To run
39 * Enter:
40 
41  $ ./video_dec_cuda <in-file> <in-format> [options]
42 
43 ### Example
44 
45  $ ./video_dec_cuda ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264
46 
47 <a name="flow">
48 - - - - - - - - - - - - - - -
49 ##Flow
50 The following diagram shows the flow of data through the sample.
51 
52 ![](l4t_mm_video_dec_cuda.jpg)
53 
54 #### Additional Details
55 
56 The main flow of this sample is as follows:
57 
58 Tegra provides pitch linear and block linear memory format support on
59 input and output. Input and output memory formats do not need to
60 match.
61 
62  ret = ctx->conv->setOutputPlaneFormat(format.fmt.pix_mp.pixelformat,
63  format.fmt.pix_mp.width,
64  format.fmt.pix_mp.height,
65  NvVideoConverter::LAYOUT_BLOCK);
66 
67 This call sets up libv4l2 output plane, i.e., for receiving input as
68 YUV data for decoder, in block linear format. This is the format that
69 complies with Tegra hardware.
70 
71  ret = ctx->conv->setCapturePlaneFormat(format.fmt.pix_mp.pixelformat,
72  format.fmt.pix_mp.width,
73  format.fmt.pix_mp.height,
74  NvVideoConverter::LAYOUT_PITCH);
75 
76 This call sets up the libv4l2 capture plane in pitch linear
77 format. This is the format that is common to the software
78 implementation.
79 
80 `NvEGLImageFromFd` is syntax error that
81 returns an EGLImage pointer from file descriptor buffer that is
82 allocated by by the member function of [NvVideoDecoder](classNvVideoDecoder.html) base class. An
83 EGLImage buffer is then used by CUDA to render a black box on
84 the display. This is implemented in a separate common routine using
85 EGLImage.
86 
87 - - - - - - - - - - - - - - -
88 <a name="key">
89 ## Key Structure and Classes ##
90 
91 This sample uses the following key structures and classes:
92 
93 |Element|Description|
94 |---|---|
95 |[NvVideoDecoder](classNvVideoDecoder.html)|Contains all video decoding-related elements and functions.|
96 |[NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions for video format conversion.|
97 |[NvEglRenderer](classNvEglRenderer.html)|Contains all EGL display rendering-related functions.|
98 |egl_image|The EGLImage used for CUDA processing.|
99 |conv_output_plane_buf_queue|Output plane queue for video conversion.|
100 |dec_capture_loop|The thread handler for decoding capture loop.|
101 
102 %NvVideoDecoder packages all video decoding-related elements and
103 functions. Key members used in the sample are:
104 
105 |Member|Description|
106 |---|---|
107 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5)|V4l2 output plane.|
108 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|V4l2 capture plane.|
109 |[createVideoDecoder](classNvVideoDecoder.html#a47980b18e6f22f1a53c3af732321483d)|Static function to create video decode object.|
110 |[subscribeEvent](classNvV4l2Element.html#a7fd9f21268d5fdc979065b1b04b93220)|Subscribe event.|
111 |[setExtControls](classNvV4l2Element.html#aaec1f40b777bb98870f18766690d7984)|Set external control to V4l2 device.|
112 |[setOutputPlaneFormat](classNvVideoDecoder.html#a7cacbe8afce830495c25514cbd7c8efe)|Set output plane format.|
113 |[setCapturePlaneFormat](classNvVideoDecoder.html#abc20773d70cfafed881238dfda6046ce)|Set capture plane format.|
114 |[getControl](classNvV4l2Element.html#a204f7b6d6f8a4540db8bdcdffe5621ad)|TBD|
115 |[dqEvent](classNvV4l2Element.html#aa475b35ff3fa8ac35b5619c35474f38c)|Dqueue the event which report by V4l2 device.|
116 |[isInError](classNvV4l2Element.html#aa60303288ff142ea08e53fa1dc7a72bf)|Check if under error state.|
117 
118 %NvVideoConverter packages all video converting-related elements and
119 functions. Key members used in the sample are:
120 
121 |Member|Description|
122 |---|---|
123 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5)|The output plane.|
124 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|The capture plane.|
125 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c)|TBD|
126 |setOutputPlaneFormat|Set output plane format.|
127 |setCapturePlaneFormat|Set capture plane format.|
128 
129 Both %NvVideoDecoder and %NvVideoConverter contain 2 key elements:
130 `output_plane` and `capture_plane`. These 2 objects belong to the same
131 class type [NvV4l2ElementPlane](group__l4t_mm__nvv4lelementplane__group.html). Key members used in the sample are:
132 
133 |Element|Description|
134 |---|---|
135 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345)|Setup the plane of V4l2 element.|
136 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c)|Destroy the plane of V4l2 element.|
137 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316)|Start/Stop the stream.|
138 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Set the callback function of dqueue buffer thread.|
139 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd)|Start the thread of dqueue buffer.|
140 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87)|Stop the thread of dqueue buffer.|
141 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95)|Queue V4l2 buffer.|
142 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd)|Dqueue V4l2 buffer.|
143 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787)|Get the number of V4l2 buffer.|
144 |getNumQueuedBuffers|Get the number of V4l2 buffer which under queue.|
145 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f)|TBD|
146 
147 Two global functions are used to create and destroy EGLImage from the
148 dmabuf file descriptor:
149 
150 |Function|Description|
151 |---|---|
152 |NvEGLImageFromFd|Create EGLImage from dmabuf file descriptor.|
153 |NvDestroyEGLImage|Destroy the EGLImage.|
154 
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)
Creates an instance of EGLImage from a 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)
Destroys an EGLImage object.