1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
3 @page nvvid_scal_col_group 07_video_convert
6 - [Overview](#overview)
7 - [Building and Running](#build_and_run)
8 - [Key Structure and Classes](#key)
10 - - - - - - - - - - - - - - -
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
18 This sample does not require a camera.
21 <a name=
"build_and_run">
22 - - - - - - - - - - - - - - -
23 ## Building and Running ##
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.
34 $ cd $HOME/tegra_multimedia_api/samples/07_video_convert
40 $ ./video_convert <in-file> <in-width> <in-height> <in-format> <out-file> <out-width> <out-height> <out-format> [OPTIONS]
44 $ ./video_convert ../../data/Picture/nvidia-logo.yuv 1920 1080 YUV420M test.yuv 1920 1080 YUYV
46 @note The `video_convert` sample consumes a YUV file. If you
do not already have a YUV file,
47 you can use the `jpeg_decode` sample to generate one. For example:
49 $ cd $HOME/tegra_multimedia_api/samples/06_jpeg_decode/
50 $ ./jpeg_decode num_files 1 ../../data/Picture/nvidia-logo.jpg ../../data/Picture/nvidia-logo.yuv
55 The following diagram shows the flow of data through the sample.
57 
59 The `video_convert` sample converts color format from YV12 to RGB or NV12 to YV12
60 etc. NVIDIA<sup>®</sup> Tegra<sup>®</sup> provides pitch linear and
61 block linear memory format support on input and output. Input and output memory
62 formats
do not need to match. For example,
for YV12 to RGB conversion, set the
63 format argument to `YV12`.
65 ret = ctx.conv0->setOutputPlaneFormat(ctx.in_pixfmt, \
70 The above call in the sample sets up a libv4l2 output plane, i.e., receiving
71 input YUV data reading from file, as a pitch-linear memory format. For example,
72 for YV12 to RGB conversion, set the format argument to `RGB`.
75 ret = ctx.conv0->setCapturePlaneFormat(ctx.out_pixfmt, \
80 The above call in the sample sets up a libv4l2 capture plane.
81 In
this case, it specifies that the libv4l2 capture plane must have pitch-linear
82 memory format, the most common one. Therefore,
if the command line indicates the
83 capture plane is instead block-linear (via the `--input-nvbl` option), the
84 sample adapts to
this request by initializing two `
NvVideoConverter` objects,
86 - First
object converts pitch-linear memory format to block-linear memory
87 format. Because the input buffer is block-linear,
this object is effectively blocked
88 and the block-linear input buffers are diverted to the second converter.
94 - Second object (the main one) converts block-linear memory format to
95 pitch-linear memory format. This allows the pitch-linear output buffer to be
98 ret = ctx.conv1->setOutputPlaneFormat(ctx.in_pixfmt, \
102 ret = ctx.conv1->setCapturePlaneFormat(ctx.out_pixfmt, \
107 The block-linear memory format complies with Tegra hardware.
111 - - - - - - - - - - - - - - -
112 ## Key Structure and Classes ##
114 `v412_videoconvert_test.h` exposes the `context_t` global structure to
115 manage all the resources in the application. The key fields in that
117 - [
NvVideoConverter](classNvVideoConverter.html) *conv. Performs video format conversion.
118 - `std::queue < \c %NvBuffer * > *conv_output_plane_buf_queue`.
119 Holds an output plane queue
for the second video converter.
123 The [
NvVideoDecoder](classNvVideoDecoder.html)
class creates a new V4L2 Video Decoder.
124 The following table describes the key %
NvVideoDecoder members that
this sample uses.
127 |---------------------|---|
128 |[setCapturePlaneFormat](classNvVideoDecoder.html#abc20773d70cfafed881238dfda6046ce)|Sets the format on the decoder capture plane.|
129 |[setOutputPlaneFormat](classNvVideoDecoder.html#a7cacbe8afce830495c25514cbd7c8efe) |Sets the format on the decoder output plane.|
132 ### %NvVideoConverter ###
134 The [
NvVideoConverter](classNvVideoConverter.html)
class packages all video converting related elements and functions.
135 It performs color space conversion, scaling and
136 conversion between hardware buffer memory and software buffer memory.
137 The following table describes the key %
NvVideoConverter members that
this sample uses.
141 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5) |Holds the output plane.|
142 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|Holds the capture plane.|
143 |[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.|
144 |[setCapturePlaneFormat](classNvVideoConverter.html#ad91e70f0e8b5f5a8b4deefa5a26ffe85)|Sets the format on the converter capture plane.|
145 |[setOutputPlaneFormat](classNvVideoConverter.html#a38b53f4d1e2c357360893756f417faf6) |Sets the format on the converter output plane.|
148 ### %NvV4l2ElementPlane ###
150 [
NvV4l2ElementPlane](group__l4t_mm__nvv4lelementplane__group.html) creates an [NVv4l2Element](classNvV4l2Element.html) plane.
151 The following table describes the key %
NvV4l2ElementPlane members used in
this sample.
153 |Member |Description|
154 |-------------------|---|
155 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345) |Sets up the plane of V4l2 element.|
156 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c) |Destroys the plane of V4l2 element.|
157 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316) |Starts/Stops the stream.|
158 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Sets the callback
function of the `dqueue` buffer thread.|
159 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd) |Starts the thread of the `dqueue` buffer.|
160 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87) |Stops the thread of the `dqueue` buffer.|
161 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95) |Queues a V4l2 buffer from the plane.|
162 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd) |Dequeues a V4l2 buffer from the plane.|
163 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787) |Gets the number of the V4l2 buffer.|
165 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f) |Gets the \c %
NvBuffer queue
object at index N.|
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.
Defines a helper class for V4L2 Video Converter.
uint32_t getNumQueuedBuffers()
Gets the number of buffers currently queued on the plane.