L4T Multimedia API Reference

28.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_vid_scal_col_fmt_conv.md
Go to the documentation of this file.
1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
2 
3 @page nvvid_scal_col_group 07_video_convert
4 @{
5 
6  - [Overview](#overview)
7  - [Building and Running](#build_and_run)
8  - [Key Structure and Classes](#key)
9 
10 - - - - - - - - - - - - - - -
11 <a name="overview">
12 ## Overview ##
13 
14 The video scaling and color format conversion sample demonstrates how to use the
15 libv4l2 video conversion component for image color formatting and buffer layout
16 conversion.
17 
18 This sample does not require a camera.
19 
20 
21 <a name="build_and_run">
22 - - - - - - - - - - - - - - -
23 ## Building and Running ##
24 
25 #### Prerequisites ####
26 * You have followed Steps 1-3 in @ref mmapi_build.
27 * If you are building from your host Linux PC (x86), you have
28  followed Step 4 in @ref mmapi_build.
29 
30 
31 ### To build:
32 * Enter:
33 
34  $ cd $HOME/tegra_multimedia_api/samples/07_video_convert
35  $ make
36 
37 ### To run
38 * Enter:
39 
40  $ ./video_convert <in-file> <in-width> <in-height> <in-format> <out-file> <out-width> <out-height> <out-format> [OPTIONS]
41 
42 <a name="flow">
43 ## Flow
44 
45 The following diagram shows the flow of data through the sample.
46 
47 ![ ](l4t_mm_video_converter.jpg)
48 
49 The `video_convert` sample converts color format from YV12 to RGB or NV12 to YV12
50 etc. NVIDIA<sup>&reg;</sup> Tegra<sup>&reg;</sup> provides pitch linear and
51 block linear memory format support on input and output. Input and output memory
52 formats do not need to match. For example, for YV12 to RGB conversion, set the
53 format argument to `YV12`.
54 
55  ret = ctx.conv0->setOutputPlaneFormat(ctx.in_pixfmt, \
56  ctx.in_width, \
57  ctx.in_height, \
59 
60 The above call in the sample sets up a libv4l2 output plane, i.e., receiving
61 input YUV data reading from file, as a pitch-linear memory format. For example,
62 for YV12 to RGB conversion, set the format argument to `RGB`.
63 
64 
65  ret = ctx.conv0->setCapturePlaneFormat(ctx.out_pixfmt, \
66  ctx.out_width, \
67  ctx.out_height, \
69 
70 The above call in the sample sets up a libv4l2 capture plane.
71 In this case, it specifies that the libv4l2 capture plane must have pitch-linear
72 memory format, the most common one. Therefore, if the command line indicates the
73 capture plane is instead block-linear (via the `--input-nvbl` option), the
74 sample adapts to this request by initializing two `NvVideoConverter` objects,
75 where:
76 - First object converts pitch-linear memory format to block-linear memory
77  format. Because the input buffer is block-linear, this object is effectively blocked
78  and the block-linear input buffers are diverted to the second converter.
79 
80  ret = ctx.conv0->setCapturePlaneFormat(ctx.in_pixfmt, \
81  ctx.in_width, \
82  ctx.in_height, \
84 - Second object (the main one) converts block-linear memory format to
85  pitch-linear memory format. This allows the pitch-linear output buffer to be
86  dumped to a file.
87 
88  ret = ctx.conv1->setOutputPlaneFormat(ctx.in_pixfmt, \
89  ctx.in_width, \
90  ctx.in_height, \
92  ret = ctx.conv1->setCapturePlaneFormat(ctx.out_pixfmt, \
93  ctx.out_width, \
94  ctx.out_height, \
96 
97 The block-linear memory format complies with Tegra hardware.
98 
99 
100 <a name="key">
101 - - - - - - - - - - - - - - -
102 ## Key Structure and Classes ##
103 
104 `v412_videoconvert_test.h` exposes the `context_t` global structure to
105 manage all the resources in the application. The key fields in that
106 structure are:
107 - [NvVideoConverter](classNvVideoConverter.html) *conv. Performs video format conversion.
108 - `std::queue < \c %NvBuffer * > *conv_output_plane_buf_queue`.
109  Holds an output plane queue for the second video converter.
110 
111 ### %NvVideoDecoder ###
112 
113 The [NvVideoDecoder](classNvVideoDecoder.html) class creates a new V4L2 Video Decoder.
114 The following table describes the key %NvVideoDecoder members that this sample uses.
115 
116 |Method|Description|
117 |---------------------|---|
118 |[setCapturePlaneFormat](classNvVideoDecoder.html#abc20773d70cfafed881238dfda6046ce)|Sets the format on the decoder capture plane.|
119 |[setOutputPlaneFormat](classNvVideoDecoder.html#a7cacbe8afce830495c25514cbd7c8efe) |Sets the format on the decoder output plane.|
120 
121 
122 ### %NvVideoConverter ###
123 
124 The [NvVideoConverter](classNvVideoConverter.html) class packages all video converting related elements and functions.
125 It performs color space conversion, scaling and
126 conversion between hardware buffer memory and software buffer memory.
127 The following table describes the key %NvVideoConverter members that this sample uses.
128 
129 |Member|Description|
130 |-------------|---|
131 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the output plane.|
132 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the capture plane.|
133 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c) |Waits until all the buffers queued on the output plane are converted and dequeued from the capture plane. This is a blocking method.|
134 |[setCapturePlaneFormat](classNvVideoConverter.html#ad91e70f0e8b5f5a8b4deefa5a26ffe85)|Sets the format on the converter capture plane.|
135 |[setOutputPlaneFormat](classNvVideoConverter.html#a38b53f4d1e2c357360893756f417faf6) |Sets the format on the converter output plane.|
136 
137 
138 ### %NvV4l2ElementPlane ###
139 
140 [NvV4l2ElementPlane](group__l4t_mm__nvv4lelementplane__group.html) creates an [NVv4l2Element](classNvV4l2Element.html) plane.
141 The following table describes the key %NvV4l2ElementPlane members used in this sample.
142 
143 |Member |Description|
144 |-------------------|---|
145 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345) |Sets up the plane of V4l2 element.|
146 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) |Destroys the plane of V4l2 element.|
147 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) |Starts/Stops the stream.|
148 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Sets the callback function of the `dqueue` buffer thread.|
149 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) |Starts the thread of the `dqueue` buffer.|
150 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) |Stops the thread of the `dqueue` buffer.|
151 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) |Queues a V4l2 buffer from the plane.|
152 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) |Dequeues a V4l2 buffer from the plane.|
153 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) |Gets the number of the V4l2 buffer.|
154 |[getNumQueuedBuffers](#NvV4l2ElementPlane::getNumQueuedBuffers) |Gets the number of the V4l2 buffer in the queue.|
155 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f) |Gets the \c %NvBuffer queue object at index N.|
156 
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for operations performed on a V4L2 Element plane.
int setCapturePlaneFormat(uint32_t pixfmt, uint32_t width, uint32_t height, enum v4l2_nv_buffer_layout type)
Sets the format on the converter output plane.
Class representing a buffer.
Definition: NvBuffer.h:85
Defines a helper class for V4L2 Video Converter.
uint32_t getNumQueuedBuffers()
Gets the number of buffers currently queued on the plane.