Jetson Linux API Reference

39.2 Release
transform_unit_sample (NvBufSurfTransform pixel format conversion)

Overview

The NvBufSurface API, defined in nvbufsurface.h, and the NvBufSurfTransform API, defined in nvbufsurftransform.h, 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 the NvBufSurfTransform API for conversion from one pixel-format to another using either VIC or GPU. Supported pixel formats, filters, composites and other properties are described in nvbufsurface.h and nvbufsurftransform.h.

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> <enable-gpu>
    

To view supported options

Enter:

   $ ./transform_sample --help

Example to do transform using VIC

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

Example to do transform using GPU

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


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 NvBufSurfTransform 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 following NvBufSurface and NvBufSurfTransform functions:

Element Description
NvBufSurfaceMap Gets the mem mapped virtual address of the plane.
NvBufSurfaceUnMap Unmaps the mapped virtual address of the plane.
NvBufSurfaceAllocate Allocates a hardware buffer.
NvBufSurfaceSyncForCpu Syncs the hardware memory cache for the CPU.
NvBufSurfaceSyncForDevice Syncs the hardware memory cache for the device.
NvBufSurfTransform Transforms one DMA buffer to another DMA buffer.
NvBufSurfaceDestroy Destroys the hardware buffer.