Jetson Linux Multimedia API Reference

32.4.3 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_08_video_decode_drm.md
Go to the documentation of this file.
1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
2 
3 @page l4t_mm_08_video_decode_drm 08_video_dec_drm
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 to render video stream or UI with the
16 NVIDIA<sup>&reg;</sup> Tegra<sup>&reg;</sup> Direct Rendering Manager (DRM).
17 This sample provides rendering support on non-X11 and lightweight display
18 systems. The DRM is implemented in user-space and is compatible with DRM 2.0.
19 
20 A DRM is a subsystem of the Linux kernel that interfaces with GPUs.
21 
22 The sample supports two running modes, depending on the `--disable-video` option:
23 - If specified, the sample draws only the UI on the screen.
24  The UI is a static JPEG image and a moving color block.
25 - Otherwise, it displays both the decoded video stream and the UI.
26 
27 The sample demonstrates the supported DRM buffer allocation policies:
28 - Allocated by user. UI stream uses this policy.
29 - Allocated by other V4L2 components (decoder or converter), where memory is
30  shared with DRM. Video stream uses this policy.
31 
32 The sample supports these video formats:
33 - H.264
34 - H.265
35 
36 
37 <a name="build_and_run">
38 - - - - - - - - - - - - - - -
39 ## Building and Running ##
40 
41 #### Prerequisites ####
42 * This sample must be run without desktop. Please open a console via SSH or serial connection.
43 * You have followed Steps 1-3 in @ref mmapi_build.
44 * If you are building from your host Linux PC (x86), you have
45  followed Step 4 in @ref mmapi_build.
46 
47 ### To build:
48 * Enter:
49 
50  $ cd $HOME/tegra_multimedia_api/samples/08_video_dec_drm
51  $ make
52 
53 ### Reassign display windows for Jetson AGX Xavier and Jeson Xavier NX:
54 * Since this sample requires two overlay DRM planes and by default Jetson AGX Xavier only has 1 overlay
55  plane for each CRTC, assign 1 primary and 5 overlay planes by below command for Jetson AGX Xavier.
56 
57  $ sudo sh -c 'echo 4 > /sys/class/graphics/fb1/blank'
58  $ sudo sh -c 'echo 4 > /sys/class/graphics/fb2/blank'
59  $ sudo sh -c 'echo 4 > /sys/class/graphics/fb0/blank'
60  $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb1/device/win_mask'
61  $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb2/device/win_mask'
62  $ sudo sh -c 'echo 0x0 > /sys/class/graphics/fb0/device/win_mask'
63  $ sudo sh -c 'echo 0x3f > /sys/class/graphics/fb0/device/win_mask'
64  $ sudo sh -c 'echo 0 > /sys/class/graphics/fb0/blank'
65 
66 ### Ensure the Ubuntu desktop is disabled:
67 
68  $ sudo systemctl stop gdm
69  $ sudo loginctl terminate-seat seat0
70 
71 ### If there are two display outputs, unblank the second inactive display:
72 
73  $ sudo sh -c 'echo 0 > /sys/class/graphics/fb1/blank'
74 
75 ### To run
76 * Enter:
77 
78  $ sudo ./video_dec_drm <in-file> <in-format> [options]
79 
80 ### To view supported options
81 
82  $ ./video_dec_drm --help
83 
84 ### Example: To render only the UI stream
85 
86  $ sudo ./video_dec_drm --disable-video
87 
88 ### Example: To render only the video stream
89 
90  $ sudo ./video_dec_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --disable-ui
91 
92 ### Example: To render the UI and video streams
93 
94  $ sudo ./video_dec_drm ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264
95 
96 ### Enable the Ubuntu desktop after run
97 
98  $ sudo systemctl start gdm
99 
100 
101 <a name="flow">
102 - - - - - - - - - - - - - - -
103 ##Flow
104 The following diagram shows the flow of data through the sample.
105 
106 ![Flow of Data Through the Sample](l4t_mm_08_video_decode_drm_flow.png)
107 
108 The following diagram shows the interactions between the separate threads
109 in the sample.
110 
111 ![Thread Processing](l4t_mm_08_video_decode_drm_thread.png)
112 
113 #### Main Thread
114 If the options include `--disable-video`, the sample does the following:
115 
116 1. Creates DRM renderer for drawing UI.
117 
118 Otherwise:
119 
120 1. Creates the decoder and converter for conversion from YUV422/BL to NV12/PL.
121 2. Sets up the decoder output plane.
122 3. Feeds data into the decoder output plane, until the EOS is reached.
123 
124 #### dec_capture_loop
125 
126 1. Sets up decoder capture plane and converter output/capture plane based on the
127  modes user requested.
128 2. Creates DRM renderer.
129 3. Decodes and converts.
130 4. Dequeues the buffer into the DRM for display.
131 
132 #### ui_renderer_loop
133 
134 1. Draws a static Image on the second plane (the first plane is used for video
135  streaming).
136 2. Draws a moving color block on the third plane.
137 
138 #### render_dequeue_loop:
139 
140 1. Dequeues the buffer from DRM and returns it to the converter capture plane.
141  @note Because the DRM dequeue operation is a blocking call, you must make the
142  call in separate thread from the enqueue operation.
143 2. Detects whether EOS has been reached.
144 
145 
146 
147 
148 - - - - - - - - - - - - - - -
149 <a name="key">
150 ## Key Structure and Classes ##
151 
152 The following tables shows the key classes and functions that this sample uses.
153 
154 |Class |Description|
155 |-------|-----------|
156 |class @ref NvDrmRenderer | Contains elements and functions to render frames with tegra DRM.|
157 |class @ref NvVideoDecoder | Contains all video decoding-related elements and functions.|
158 |class @ref NvVideoConverter | Contains elements and functions for video format conversion.|
159 
160 <br>
161 
162 |Function|Description|
163 |--------|-----------|
164 |ui_render_loop_fcn | Thread function to render the UI image.|
165 |renderer_dequeue_loop_fcn | Thread function to dequeue the flipped frame from NvDrmRenderer().|
166 |conv0_capture_dqbuf_thread_callback | Callback function to enqueue a new frame into NvDrmRenderer. |
167 |conv0_output_dqbuf_thread_callback | Callback function to receive a frame from decoder and process format conversion.|
Helper class for rendering using LibDRM.
Definition: NvDrmRenderer.h:67
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for V4L2 Video Converter.