![]() |
Jetson Linux Multimedia API Reference32.4.2 Release |
This sample demonstrates how to:
This sample does not require a camera.
$ cd $HOME/tegra_multimedia_api/samples/05_jpeg_encode $ make
$ ./jpeg_encode <in-file> <in-width> <in-height> <out-file> [OPTIONS]
$ ./jpeg_encode ../../data/Picture/nvidia-logo.yuv 1920 1080 test.jpg
jpeg_encode
sample consumes a YUV file. If you do not already have a YUV file, you can use the jpeg_decode
sample to generate one. For example: $ cd $HOME/tegra_multimedia_api/samples/06_jpeg_decode/ $ ./jpeg_decode num_files 1 ../../data/Picture/nvidia-logo.jpg ../../data/Picture/nvidia-logo.yuv
The following diagram shows the flow of data through this sample.
The output plane is used to receive input and the capture plane is used to produce output. The YUV data format prior to entering the JPEG encoder can be block, linear, or pitch linear. This results in 2 different encode processes: encodeFromFD and encodeFromBuffer. encodeFromFD
allows JPEG encode hardware to process the data directly. encodeFromBuffer
requires extra format conversion prior to writing to the JPEG file.
The struct context_t
global structure manages all of the resources in the application.
NvVideoDecoder | Description |
---|---|
class NvVideoConverter | Contains elements and functions regarding video format conversion. |
class NvJpegEncoder | Contains elements and functions to encode JPEG images. |
NvVideoConverter contains all video converting related elements and functions. Key members of NvVideoConverter
used in the sample are:
NvVideoConverter Member | Description |
---|---|
output_plane | V4l2 output plane. |
capture_plane | V4l2 capture plane. |
waitForIdle | Wait until all queued output plane buffers are processed and dequeued from the capture plane. |
setOutputPlaneFormat | Set output plane format. |
setCapturePlaneFormat | Set capture plane format. |
The NvVideoConverter elements output_plane
and capture_plane
belong to the NvV4l2ElementPlane class. Key members of NvV4l2ElementPlane
used in the sample are as follows:
Element | Description |
---|---|
setupPlane | Setup the plane of V4l2 element. |
deinitPlane | Destroy the plane of V4l2 element. |
setStreamStatus | Start/Stop the stream. |
setDQThreadCallback | Set the callback function of the dqueue buffer thread. |
startDQThread | Start the thread of the dqueue buffer. |
stopDQThread | Stop the thread of the dqueue buffer. |
qBuffer | Queue the V4l2 buffer. |
dqBuffer | Dequeue the V4l2 buffer. |
getNumBuffers | Get the number of the V4l2 buffer. |
getNumQueuedBuffers | Get the number of the V4l2 buffer under queue. |
getNthBuffer | Get the NvBuffer at Index N. |
The NvJpegEncoder class contains all of the functions for JPEG encoding. Key members used are:
NvV4l2ElementPlane | Description |
---|---|
encodeFromFd | Encode from FD of buffer exported by V4L2 element. |
encodeFromBuffer | Encode from pointers of buffer data. |