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 `video_convert` demonstrates how to use the
15 NvBuffer APIs defined in `nvbuf_utils.h`
for image color formatting and buffer layout
18 NVIDIA<sup>®</sup> Jetson<sup>®</sup> provides pitch linear and
19 block linear memory format support.
20 The block-linear memory format complies with Jetson hardware.
22 This sample creates one or more threads to
do conversion, each thread reads frame data from
23 local file and write converted frame data to local file. For a better parallel scheduling,
24 each thread creates its own
NvBufferSession when
'-s' or
'--create-session' option are speficied.
26 This sample can also been used
for video convert performance benchmark. When
'--perf' option is
27 speficied, each thread
do video conversion in a loop (3000 times) after reading frame data from
28 local file. To reduce benchmark deviation from file IO, input file should be image data instead of
31 Since
this sample needs to read frame data from local file and write converted frame data to
32 local file, pitch linear memory is used in
this sample(CPU cannot access block linear buffer).
34 This sample does not require a camera.
37 <a name=
"build_and_run">
38 - - - - - - - - - - - - - - -
39 ## Building and Running ##
41 #### Prerequisites ####
42 * You have followed Steps 1-3 in @ref mmapi_build.
43 * If you are building from your host Linux PC (x86), you have
44 followed Step 4 in @ref mmapi_build.
50 $ cd jetson_multimedia_api/samples/07_video_convert
56 $ ./video_convert <in-file> <in-width> <in-height> <in-format> <out-file-prefix> <out-width> <out-height> <out-format> [OPTIONS]
60 $ ./video_convert ../../data/Picture/nvidia-logo.yuv 1920 1080 YUV420 test.yuv 1920 1080 YUYV
62 @note The `video_convert` sample consumes a YUV file. If you
do not already have a YUV file,
63 you can use the `jpeg_decode` sample to generate one. For example:
65 $ cd jetson_multimedia_api/samples/06_jpeg_decode/
66 $ ./jpeg_decode num_files 1 ../../data/Picture/nvidia-logo.jpg ../../data/Picture/nvidia-logo.yuv
71 The following diagram shows the flow of data through the sample.
73 
76 - - - - - - - - - - - - - - -
77 ## Key Structure and API ##
79 `nvbuf_utils.h` defines all the key structures and APIs to
do color
84 |Structure|Description|
85 |---------------------|---|
86 |[
NvBufferCreateParams](group__ee__nvbuffering__group.html#ga0834b004efe8bca7a98c876042f57918)|Holds the input parameters
for hardware buffer creation.|
87 |[
NvBufferParams](group__ee__nvbuffering__group.html#ga70c3f1e37eda1d7195800ffdafadfb31)|Holds parameters
for a hardware buffer.|
88 |[
NvBufferTransformParams](group__ee__nvbuffering__group.html#gad0b4c32bd1d0edef1f11b4560ea00916)|Holds parameters
for buffer transform functions.|
89 |[
NvBufferRect](structNvBufferRect.html)|Holds coordinates
for a rectangle.|
94 |---------------------|---|
95 |[
NvBufferCreateEx()](group__ee__nvbuffering__group.html#ga5d21823c3ab5f07f55ccea64deb01e96)|Allocates a HW buffer.|
96 |[
NvBufferDestroy()](group__ee__nvbuffering__group.html#gab03cbe902e747420f02bb5b509b05968)|Destroys a HW buffer.|
97 |[
NvBufferSessionCreate()](group__ee__nvbuffering__group.html#gaaf4abfe7cb3ba3c49ea37d33ad246ea5)|Creates a
new NvBufferSession for parallel scheduling of buffer transformations and compositions.|
99 |[
NvBufferGetParams()](group__ee__nvbuffering__group.html#gabd39426181a52065586917dfd470fa5a)|Gets buffer parameters.|
100 |[
NvBufferMemMap()](group__ee__nvbuffering__group.html#gab6760a1b12067b32a80e7aa9e2a98d2b)|Gets the memory-mapped
virtual address of the plane.|
101 |[
NvBufferMemUnMap()](group__ee__nvbuffering__group.html#ga5fd173847091ba84802f8f7e00ffda52)|Unmaps the mapped
virtual address of the plane.|
102 |[
NvBufferMemSyncForDevice()](group__ee__nvbuffering__group.html#ga4a52fd88a031be9cca774b2c6ff98e4e)|Syncs the HW memory cache sync
for the device.|
103 |[
NvBufferMemSyncForCpu()](group__ee__nvbuffering__group.html#ga8c26b181329a181b41498b06a4f66602)|Syncs the HW memory cache
for the CPU.|
104 |[
NvBufferTransform()](group__ee__nvbuffering__group.html#ga6f79642157d9930b43bd6a775a92dca9)|Transforms one DMA buffer to another DMA buffer.|
int NvBufferMemUnMap(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Unmaps the mapped virtual address of the plane.
int NvBufferMemSyncForCpu(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the HW memory cache for the CPU.
int NvBufferMemMap(int dmabuf_fd, unsigned int plane, NvBufferMemFlags memflag, void **pVirtAddr)
Gets the memory-mapped virtual address of the plane.
NvBufferSession NvBufferSessionCreate(void)
Creates a new NvBufferSession for parallel scheduling of buffer transformations and compositions...
Class representing a buffer.
struct _NvBufferParams NvBufferParams
Holds parameters for a hardware buffer.
int NvBufferMemSyncForDevice(int dmabuf_fd, unsigned int plane, void **pVirtAddr)
Syncs the hardware memory cache for the device.
int NvBufferTransform(int src_dmabuf_fd, int dst_dmabuf_fd, NvBufferTransformParams *transform_params)
Transforms one DMA buffer to another DMA buffer.
void NvBufferSessionDestroy(NvBufferSession session)
Destroys an existing NvBufferSession.
Holds the input parameters for hardware buffer creation.
int NvBufferGetParams(int dmabuf_fd, NvBufferParams *params)
Gets buffer parameters.
int NvBufferDestroy(int dmabuf_fd)
Destroys a HW buffer.
int NvBufferCreateEx(int *dmabuf_fd, NvBufferCreateParams *input_params)
Allocates a hardware buffer.
Holds coordinates for a rectangle.
struct _NvBufferSession * NvBufferSession
Holds an opaque NvBuffer session type required for parallel buffer tranformations and compositions...