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]
45 The following diagram shows the flow of data through the sample.
47 
49 The `video_convert` sample converts color format from YV12 to RGB or NV12 to YV12
50 etc. NVIDIA<sup>®</sup> Tegra<sup>®</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`.
55 ret = ctx.conv0->setOutputPlaneFormat(ctx.in_pixfmt, \
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`.
65 ret = ctx.conv0->setCapturePlaneFormat(ctx.out_pixfmt, \
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,
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.
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
88 ret = ctx.conv1->setOutputPlaneFormat(ctx.in_pixfmt, \
92 ret = ctx.conv1->setCapturePlaneFormat(ctx.out_pixfmt, \
97 The block-linear memory format complies with Tegra hardware.
101 - - - - - - - - - - - - - - -
102 ## Key Structure and Classes ##
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
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.
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.
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.|
122 ### %NvVideoConverter ###
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.
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.|
138 ### %NvV4l2ElementPlane ###
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.
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.|
155 |[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.