Jetson Linux Multimedia API Reference

32.4.3 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multimedia_api/ll_samples/docs/l4t_mm_vid_scal_col_fmt_conv.md
Go to the documentation of this file.
1 Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
2 
3 @page nvvid_scal_col_group 07_video_convert
4 @{
5 
6  - [Overview](#overview)
7  - [Building and Running](#build_and_run)
8  - [Key Structure and Classes](#key)
9 
10 - - - - - - - - - - - - - - -
11 <a name="overview">
12 ## Overview ##
13 
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
16 conversion.
17 
18 NVIDIA<sup>&reg;</sup> Jetson<sup>&reg;</sup> provides pitch linear and
19 block linear memory format support.
20 The block-linear memory format complies with Jetson hardware.
21 
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.
25 
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
29 video data.
30 
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).
33 
34 This sample does not require a camera.
35 
36 
37 <a name="build_and_run">
38 - - - - - - - - - - - - - - -
39 ## Building and Running ##
40 
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.
45 
46 
47 ### To build:
48 * Enter:
49 
50  $ cd jetson_multimedia_api/samples/07_video_convert
51  $ make
52 
53 ### To run
54 * Enter:
55 
56  $ ./video_convert <in-file> <in-width> <in-height> <in-format> <out-file-prefix> <out-width> <out-height> <out-format> [OPTIONS]
57 
58 ### Example
59 
60  $ ./video_convert ../../data/Picture/nvidia-logo.yuv 1920 1080 YUV420 test.yuv 1920 1080 YUYV
61 
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:
64 
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
67 
68 <a name="flow">
69 ## Flow
70 
71 The following diagram shows the flow of data through the sample.
72 
73 ![ ](l4t_mm_video_converter.jpg)
74 
75 <a name="key">
76 - - - - - - - - - - - - - - -
77 ## Key Structure and API ##
78 
79 `nvbuf_utils.h` defines all the key structures and APIs to do color
80 conversion by NvBuffer APIs.
81 
82 ### Structure ###
83 
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.|
90 
91 ### API ###
92 
93 |Method|Description|
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.|
98 |[NvBufferSessionDestroy()](group__ee__nvbuffering__group.html#gadfe38cd5888e934c754a638d7ea7243e)|Destroys an existing NvBufferSession.|
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.
Definition: NvBuffer.h:85
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.
Definition: nvbuf_utils.h:397
int NvBufferGetParams(int dmabuf_fd, NvBufferParams *params)
Gets buffer parameters.
Holds parameters for buffer transform functions.
Definition: nvbuf_utils.h:508
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.
Definition: nvbuf_utils.h:358
struct _NvBufferSession * NvBufferSession
Holds an opaque NvBuffer session type required for parallel buffer tranformations and compositions...
Definition: nvbuf_utils.h:376