Jetson Linux API Reference

32.5 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
07_video_convert

Overview

The video scaling and color format conversion sample video_convert demonstrates how to use the NvBuffer APIs defined in nvbuf_utils.h for image color formatting and buffer layout conversion.

NVIDIA® Jetson® provides pitch linear and block linear memory format support. The block-linear memory format complies with Jetson hardware.

This sample creates one or more threads to do conversion, each thread reads frame data from local file and write converted frame data to local file. For a better parallel scheduling, each thread creates its own NvBufferSession when '-s' or '–create-session' option are speficied.

This sample can also been used for video convert performance benchmark. When '–perf' option is speficied, each thread do video conversion in a loop (3000 times) after reading frame data from local file. To reduce benchmark deviation from file IO, input file should be image data instead of video data.

Since this sample needs to read frame data from local file and write converted frame data to local file, pitch linear memory is used in this sample(CPU cannot access block linear buffer).

This sample does not require a camera.


Building and Running

Prerequisites

To build:

  • Enter:
     $ cd jetson_multimedia_api/samples/07_video_convert
     $ make
    

To run

  • Enter:
     $ ./video_convert <in-file> <in-width> <in-height> <in-format> <out-file-prefix> <out-width> <out-height> <out-format> [OPTIONS]
    

Example

   $ ./video_convert ../../data/Picture/nvidia-logo.yuv 1920 1080 YUV420 test.yuv 1920 1080 YUYV
Note
The video_convert 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 jetson_multimedia_api/samples/06_jpeg_decode/
 $ ./jpeg_decode num_files 1 ../../data/Picture/nvidia-logo.jpg ../../data/Picture/nvidia-logo.yuv

Flow

The following diagram shows the flow of data through the sample.


Key Structure and API

nvbuf_utils.h defines all the key structures and APIs to do color conversion by NvBuffer APIs.

Structure

StructureDescription
NvBufferCreateParamsHolds the input parameters for hardware buffer creation.
NvBufferParamsHolds parameters for a hardware buffer.
NvBufferTransformParamsHolds parameters for buffer transform functions.
NvBufferRectHolds coordinates for a rectangle.

API

MethodDescription
NvBufferCreateEx()Allocates a HW buffer.
NvBufferDestroy()Destroys a HW buffer.
NvBufferSessionCreate()Creates a new NvBufferSession for parallel scheduling of buffer transformations and compositions.
NvBufferSessionDestroy()Destroys an existing NvBufferSession.
NvBufferGetParams()Gets buffer parameters.
NvBufferMemMap()Gets the memory-mapped virtual address of the plane.
NvBufferMemUnMap()Unmaps the mapped virtual address of the plane.
NvBufferMemSyncForDevice()Syncs the HW memory cache sync for the device.
NvBufferMemSyncForCpu()Syncs the HW memory cache for the CPU.
NvBufferTransform()Transforms one DMA buffer to another DMA buffer.