1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
3 @page l4t_mm_jpeg_encode 05_jpeg_encode
6 - [Overview](#overview)
7 - [Building and Running](#build_and_run)
9 - [Key Structure and Classes](#key)
11 - - - - - - - - - - - - - - -
15 This sample demonstrates how to:
17 * Use the libv4l2 conversion component
function to allocate buffer
19 * Use the JPEG encode component to encode YUV data to a file.
21 This sample does not require a camera.
23 <a name=
"build_and_run">
24 - - - - - - - - - - - - - - -
25 ## Building and Running ##
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.
35 $ cd $HOME/multimedia_api/samples/05_jpeg_encode
41 $ ./jpeg_encode <in-file> <in-width> <in-height> <out-file> [OPTIONS]
45 $ ./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 test.jpg
47 @note The `jpeg_encode` sample consumes a YUV file. If you
do not already have a YUV file,
48 you can use the `jpeg_decode` sample to generate one. For example:
50 $ cd $HOME/multimedia_api/samples/06_jpeg_decode/
51 $ ./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
this sample.
57 
59 #### Additional Details
61 The output plane is used to receive input and the capture plane is used to produce output.
62 The YUV data format prior to entering the JPEG encoder can be block, linear, or pitch linear.
63 This results in 2 different encode processes: [encodeFromFD](classNvJPEGEncoder.html#a4c7f16d4d8ee39fcc52279ee14418fea) and [encodeFromBuffer](classNvJPEGEncoder.html#a445e1de7f368f3a92af98a789d10172b).
64 `encodeFromFD` allows JPEG encode hardware to process the data directly.
65 `encodeFromBuffer` requires extra format conversion prior to writing to the JPEG file.
67 - - - - - - - - - - - - - - -
69 ## Key Structure and Classes ##
71 The `
struct context_t` global structure manages all of the resources in the application.
75 |
class [
NvVideoConverter](classNvVideoConverter.html)|Contains elements and functions regarding video format conversion.|
76 |
class [NvJpegEncoder](classNvJPEGEncoder.html)|Contains elements and functions to encode JPEG images.|
82 |[output_plane](classNvV4l2Element.html#aaba251827cef1b23e7c42f776e95fee5)|V4l2 output plane.|
83 |[capture_plane](classNvV4l2Element.html#a91806d7ed13b4b2c48758e8a02f46c6d)|V4l2 capture plane.|
84 |[waitForIdle](classNvVideoConverter.html#a2f5d1a234427862adf9cae7323b5e24c)|Wait until all queued output plane buffers are processed and dequeued from the capture plane.|
85 |[setOutputPlaneFormat](classNvVideoConverter.html#a38b53f4d1e2c357360893756f417faf6)|Set output plane format.|
86 |[setCapturePlaneFormat](classNvVideoConverter.html#ad91e70f0e8b5f5a8b4deefa5a26ffe85)|Set capture plane format.|
92 |[setupPlane](classNvV4l2ElementPlane.html#a89959f455e5222f686187cc826b1b345)|Setup the plane of V4l2 element.|
93 |[deinitPlane](classNvV4l2ElementPlane.html#af89cfe87d8f818beb0478bcf5b72574c)|Destroy the plane of V4l2 element.|
94 |[setStreamStatus](classNvV4l2ElementPlane.html#a03164dde4d7ab41f3e92b41e13059316)|Start/Stop the stream.|
95 |[setDQThreadCallback](classNvV4l2ElementPlane.html#a37f213325e0e4857180f5b2319317d6a)|Set the callback
function of the dqueue buffer thread.|
96 |[startDQThread](classNvV4l2ElementPlane.html#a31f77f5e5ed1f320caa44a868a7cbedd)|Start the thread of the dqueue buffer.|
97 |[stopDQThread](classNvV4l2ElementPlane.html#aa798d14493de321fa90aeab6d944ca87)|Stop the thread of the dqueue buffer.|
98 |[qBuffer](classNvV4l2ElementPlane.html#af4d52964fcfd37082f47682e457f5e95)|Queue the V4l2 buffer.|
99 |[dqBuffer](classNvV4l2ElementPlane.html#a8dfcbc666ee6f36a02abfb1170ae05cd)|Dequeue the V4l2 buffer.|
100 |[getNumBuffers](classNvV4l2ElementPlane.html#ac5cd394a7e0a4afd69395759aeac8787)|Get the number of the V4l2 buffer.|
102 |[getNthBuffer](classNvV4l2ElementPlane.html#a868d438908f3d267dd4af1033133892f)| Get the \c %
NvBuffer at Index N.|
104 The %NvJpegEncoder
class contains all of the functions
for JPEG encoding. Key members used are:
108 |[encodeFromFd](classNvJPEGEncoder.html#a4c7f16d4d8ee39fcc52279ee14418fea)|Encode from FD of buffer exported by V4L2 element.|
109 |[encodeFromBuffer](classNvJPEGEncoder.html#a445e1de7f368f3a92af98a789d10172b)|Encode from pointers of buffer data.|
Defines a helper class for V4L2 Video Decoder.
Defines a helper class for operations performed on a V4L2 Element 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.