Jetson Linux API Reference

32.7.5 Release
transform_unit_sample (nvbuf_utils pixel format conversion)

Overview

The NVIDIA buffering utility, nvbuf_utils provide a wrapper to simplify the use case of applications/plugins for buffering and transform, composite, or blending.

The transform unit sample demonstrates the use of nvbuf_utils for conversion from one pixel-format to another. Supported pixel formats, filters, composites and other properties are described in the nvbuf_utils.

Supported pixel formats are:

  • NV12
  • NV21
  • NV12_709
  • ARGB32
  • XRGB32
  • YUV420
  • YVU420
  • YUV420_709


Building and Running

Prerequisites

To build

  • Enter:
     $ cd /usr/src/jetson_multimedia_api/samples/unittest_samples/transform_unit_sample
     $ make
    

To run

  • Enter:
     $ ./transform_sample <in-file> <in-pix-fmt> <in-width> <in-height> <out-file> <out-pixfmt>
    

To view supported options

Enter:

   $ ./transform_sample --help

Example

  $ ./transform_sample ../../data/Video/sample_outdoor_car_1080p_10fps.yuv
  yuv420 1920 1080 sample_outdoor_car_1080p_10fps_nv12.yuv nv12


Flow

The following steps show the flow through this sample.

  1. Create input and output DMA mapped hardware buffers.
  2. Define the transformation parameters.
  3. Call the NvBufferTransform which transforms the input DMA buffer to the output DMA buffer, both exported as fd.
  4. The application writes the transformed buffer into a file.


Key Structure and Classes

The sample uses the nvbuf_utils functions:

Element Description
NvBufferMemMap Gets mem mapped virtual Address of the plane.
NvBufferMemUnMap Unmaps mapped virtual Address of the plane.
NvBufferGetParams Gets the buffer parameters.
NvBufferCreateEx Allocates a hardware buffer.
NvBufferMemSyncForCpu Syncs hw memory cache for the CPU.
NvBufferMemSyncForDevice Syncs hw memory cache for the device.
NvBufferTransform Transforms one DMA buffer to another DMA buffer.
NvBufferDestroy Destroys hw buffer.