NVIDIA DRIVE 5.0 Linux SDK API Reference

5.0.5.0 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Image JPEG Decoder

Detailed Description

The NvMediaIJPD object takes a JPEG bitstream and decompress it to image data.

Data Structures

struct  NVMEDIAJPEGDecAttributes
 Holds image JPEG decoder attributes. More...
 
struct  NVMEDIAJPEGDecInfo
 Holds image JPEG decoder stream information. More...
 
struct  NvMediaIJPD
 Holds information for decoding a JPEG stream into an image surface. More...
 

Macros

#define NVMEDIA_IJPD_VERSION_MAJOR   1
 Major version number. More...
 
#define NVMEDIA_IJPD_VERSION_MINOR   2
 Minor version number. More...
 
#define NVMEDIA_JPEG_DEC_ATTRIBUTE_ALPHA_VALUE
 JPEG decode set alpha. More...
 
#define NVMEDIA_JPEG_DEC_ATTRIBUTE_COLOR_STANDARD
 JPEG decode set color standard. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_0
 JPEG decode render flag rotate 0. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_90
 JPEG decode render flag rotate 90. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_180
 JPEG decode render flag rotate 180. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_270
 JPEG decode render flag rotate 270. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_FLIP_HORIZONTAL
 JPEG decode render flag flip horizontal. More...
 
#define NVMEDIA_IJPD_RENDER_FLAG_FLIP_VERTICAL
 JPEG decode render flag flip vertical. More...
 

Functions

NvMediaStatus NvMediaIJPDGetVersion (NvMediaVersion *version)
 Gets the version compatibility for the NvMedia IJPGD library. More...
 
NvMediaIJPDNvMediaIJPDCreate (NvMediaDevice *device, uint16_t maxWidth, uint16_t maxHeight, uint32_t maxBitstreamBytes, uint8_t supportPartialAccel)
 Creates a JPEG decoder object capable of decoding a JPEG stream into an image surface. More...
 
void NvMediaIJPDDestroy (NvMediaIJPD *decoder)
 Destroys an NvMedia image JPEG decoder. More...
 
NvMediaStatus NvMediaIJPDResize (NvMediaIJPD *decoder, uint16_t maxWidth, uint16_t maxHeight, uint32_t maxBitstreamBytes)
 Resizes an existing image JPEG decoder. More...
 
NvMediaStatus NvMediaIJPDSetAttributes (NvMediaIJPD *decoder, uint32_t attributeMask, void *attributes)
 Sets attributes of an existing image JPEG decoder. More...
 
NvMediaStatus NvMediaIJPDGetInfo (NVMEDIAJPEGDecInfo *info, uint32_t numBitstreamBuffers, const NvMediaBitstreamBuffer *bitstreams)
 A helper function that determines whether the JPEG decoder HW engine can decode the input JPEG stream. More...
 
NvMediaStatus NvMediaIJPDRender (NvMediaIJPD *decoder, NvMediaImage *output, const NvMediaRect *srcRect, const NvMediaRect *dstRect, uint8_t downscaleLog2, uint32_t numBitstreamBuffers, const NvMediaBitstreamBuffer *bitstreams, uint32_t flags)
 Decodes a JPEG image. More...
 
NvMediaStatus NvMediaIJPDRenderYUV (NvMediaIJPD *decoder, NvMediaImage *output, uint8_t downscaleLog2, uint32_t numBitstreamBuffers, const NvMediaBitstreamBuffer *bitstreams, uint32_t flags)
 Decodes a JPEG image into YUV format. More...
 

Macro Definition Documentation

#define NVMEDIA_IJPD_RENDER_FLAG_FLIP_HORIZONTAL

JPEG decode render flag flip horizontal.

Definition at line 72 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_RENDER_FLAG_FLIP_VERTICAL

JPEG decode render flag flip vertical.

Definition at line 77 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_0

JPEG decode render flag rotate 0.

Definition at line 52 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_180

JPEG decode render flag rotate 180.

Definition at line 62 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_270

JPEG decode render flag rotate 270.

Definition at line 67 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_RENDER_FLAG_ROTATE_90

JPEG decode render flag rotate 90.

Definition at line 57 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_VERSION_MAJOR   1

Major version number.

Definition at line 34 of file nvmedia_ijpd.h.

#define NVMEDIA_IJPD_VERSION_MINOR   2

Minor version number.

Definition at line 36 of file nvmedia_ijpd.h.

#define NVMEDIA_JPEG_DEC_ATTRIBUTE_ALPHA_VALUE

JPEG decode set alpha.

Definition at line 42 of file nvmedia_ijpd.h.

#define NVMEDIA_JPEG_DEC_ATTRIBUTE_COLOR_STANDARD

JPEG decode set color standard.

Definition at line 47 of file nvmedia_ijpd.h.

Function Documentation

NvMediaIJPD* NvMediaIJPDCreate ( NvMediaDevice device,
uint16_t  maxWidth,
uint16_t  maxHeight,
uint32_t  maxBitstreamBytes,
uint8_t  supportPartialAccel 
)

Creates a JPEG decoder object capable of decoding a JPEG stream into an image surface.

Parameters
[in]deviceThe device this image JPEG decoder will use.
[in]maxWidthThe maximum width of output surface to support. you can use NvMediaIJPDResize() to enlarge this limit for an existing decoder.
[in]maxHeightThe maximum height of output surface to support. You can use NvMediaIJPDResize() to enlarge this limit for an existing decoder.
[in]maxBitstreamBytesThe maximum JPEG bitstream size in bytes to support. Use NvMediaIJPDResize() to enlarge this limit for an existing decoder.
[in]supportPartialAccelIndicates that the JPEG decode object supports partial acceleration.
If it does, set this argument to the character '1' (true).
If it does not, set this argument to the character '0' (false).
Return values
NvMediaIJPDThe new image JPEG decoder handle or NULL if unsuccessful.
void NvMediaIJPDDestroy ( NvMediaIJPD decoder)

Destroys an NvMedia image JPEG decoder.

Parameters
[in]decoderA pointer to the JPEG decoder to destroy.
NvMediaStatus NvMediaIJPDGetInfo ( NVMEDIAJPEGDecInfo info,
uint32_t  numBitstreamBuffers,
const NvMediaBitstreamBuffer bitstreams 
)

A helper function that determines whether the JPEG decoder HW engine can decode the input JPEG stream.

Possible outcomes are:

  • Decode possible. If JPEG decoder supports decode of this stream, this function returns NVMEDIA_STATUS_OK and the NVMEDIAJPEGDecInfo info will be filled out. This function also determines whether you must allocate the NvMediaIJPD object when you call NvMediaIJPDCreate(). You specify that object with the NvMediaIJPDCreate() supportPartialAccel parameter.
  • Decode not possible. If JPEG decoder cannot decode this stream, this function returns NVMEDIA_STATUS_NOT_SUPPORTED.
Parameters
[in,out]infoA pointer to the information to be filled.
[in]numBitstreamBuffersThe number of bitstream buffers.
[in]bitstreamsThe bitstream buffer.
Returns
NvMediaStatus The completion status of the operation. Possible values are:
NvMediaStatus NvMediaIJPDGetVersion ( NvMediaVersion version)

Gets the version compatibility for the NvMedia IJPGD library.

Parameters
[in]versionA pointer to a NvMediaVersion structure of the client.
Returns
NvMediaStatus The status of the operation. Possible values are:
NVMEDIA_STATUS_OK
NVMEDIA_STATUS_BAD_PARAMETER if the pointer is invalid.
NvMediaStatus NvMediaIJPDRender ( NvMediaIJPD decoder,
NvMediaImage output,
const NvMediaRect srcRect,
const NvMediaRect dstRect,
uint8_t  downscaleLog2,
uint32_t  numBitstreamBuffers,
const NvMediaBitstreamBuffer bitstreams,
uint32_t  flags 
)

Decodes a JPEG image.

The decode pipeline produces a result equivalent to the following sequence:

  1. Decodes the full JPEG image.
  2. Downscales the 8x8 block padded image by the downscaleLog2 factor. That is, a "width" by "height" JPEG is downscaled to:

    ((width + 7) & ~7) >> downscaleLog2
    

    by

    ((height + 7) & ~7) >> downscaleLog2
    
  3. From the downscaled image, removes the rectangle described by srcRect and optionally (a) mirrors the image horizontally and/or vertically and/or (b) rotates the image.
  4. Scales the transformed source rectangle to the dstRect on the output surface.
Specifying Dimensions

The JPEG decoder object must have maxWidth and maxHeight values that are greater than or equal to the post-downscale JPEG image. Additionally, it must have a maxBitstreamBytes value that is greater than or equal to the total number of bytes in the bitstream buffers. You set these values when you create the JPEG decoder object with NvMediaIJPDCreate(). Alternatively, you can user NvMediaIJPDResize() to change the dimensions of an existing JPEG decoder object.

If the JPEG decoder object has inadequate dimensions, NvMediaIJPDRender() returns NVMEDIA_STATUS_INSUFFICIENT_BUFFERING.

Supporting Partial Acceleration

If the JPEG stream requires partial acceleration, created the JPEG decoder object with supportPartialAccel set to '1'. Otherwise, the function returns NVMEDIA_STATUS_BAD_PARAMETER.

Use NvMediaIJPDGetInfo() to determine whether a stream requires paritialAccel.

Determining Supported JPEG Streams

If the JPEG stream is not supported, the function returns NVMEDIA_STATUS_NOT_SUPPORTED.

Use NvMediaIJPDGetInfo() to determine whether a stream is unsupported.

Note
NvMediaIJPDRender() with the NVJPG 1.0 codec does not support rotation.
Parameters
[in]decoderA pointer to the JPEG decoder to use.
[in]outputThe video surface to render to. This surface type must be obtained by NvMediaSurfaceFormatGetType with NVM_SURF_FMT_SET_ATTR_RGBA(attr, RGBA, UINT, 8, PL)
[in]srcRectThe source rectangle. The rectangle from the post-downscaled image to be transformed and scaled to the dstRect. You can achieve horizontal and/or vertical mirroring by swapping the left-right and/or top-bottom coordinates. If NULL, the full post-downscaled surface is implied.
[in]dstRectThe destination rectangle on the output surface. If NULL, a rectangle the full size of the output surface is implied.
[in]downscaleLog2A value clamped between 0 and 3 inclusive, gives downscale factors of 1 to 8.
[in]numBitstreamBuffersThe number of bitstream buffers.
[in]bitstreamsThe bitstream buffer. NvMediaIJPDRender() copies the data out of these buffers so the caller is free to reuse them as soon as NvMediaIJPDRender() returns.
[in]flagsFlags that specify a clockwise rotation of the source in degrees and horizontal and vertical flipping. If both are specified, the image is flipped before it is rotated. You can set the flags argument to any one of the following:
  • NVMEDIA_RENDER_FLAG_ROTATE_0
  • NVMEDIA_RENDER_FLAG_ROTATE_90
  • NVMEDIA_RENDER_FLAG_ROTATE_180
  • NVMEDIA_RENDER_FLAG_ROTATE_270
Additionally, you can use the bitwise OR operation to apply either or both of the following:
  • NVMEDIA_RENDER_FLAG_FLIP_HORIZONTAL
  • NVMEDIA_RENDER_FLAG_FLIP_VERTICAL
Returns
NvMediaStatus The completion status of the operation. Possible values are:
NvMediaStatus NvMediaIJPDRenderYUV ( NvMediaIJPD decoder,
NvMediaImage output,
uint8_t  downscaleLog2,
uint32_t  numBitstreamBuffers,
const NvMediaBitstreamBuffer bitstreams,
uint32_t  flags 
)

Decodes a JPEG image into YUV format.

This function is similar to NvMediaIJPDRender() except that the output surface is in YUV format, not RGBA format. Also, clipping and scaling (other than downscaleLog2 scaling) are not supported, so there are no source or destination rectangle parameters.

Note
NvMediaIJPDRenderYUV() with the NVJPG 1.0 codec has the following limitations:
  • It supports chroma subsample conversion to 420 and 420H from any input format except 400.
  • It does not simultaneously support downscaleLog2 and subsample conversion.
Parameters
[in]decoderA pointer to the JPEG decoder to use.
[in]outputThe video surface to render to. This surface type must be obtained by /ref NvMediaSurfaceFormatGetType with: NVM_SURF_FMT_SET_ATTR_YUV(attr, YUV, 420, SEMI_PLANAR/PLANAR, UINT, 8, PL) NVM_SURF_FMT_SET_ATTR_YUV(attr, YUV, 422, SEMI_PLANAR/PLANAR, UINT, 8, PL) NVM_SURF_FMT_SET_ATTR_YUV(attr, YUV, 444, SEMI_PLANAR/PLANAR, UINT, 8, PL)
[in]downscaleLog2A value between 0 and 3 inclusive that gives downscale factors of 1 to 8.
[in]numBitstreamBuffersThe number of bitstream buffers.
[in]bitstreamsThe bitstream buffer. NvMediaIJPDRenderYUV() copies the data out of these buffers so the caller is free to reuse them as soon as NvMediaIJPDRenderYUV() returns.
[in]flagsFlags that specify a clockwise rotation of the source in degrees and horizontal and vertical flipping. If both are specified, flipping is performed before rotating. You can set the flags argument to any one of the following:
  • NVMEDIA_RENDER_FLAG_ROTATE_0
  • NVMEDIA_RENDER_FLAG_ROTATE_90
  • NVMEDIA_RENDER_FLAG_ROTATE_180
  • NVMEDIA_RENDER_FLAG_ROTATE_270
Additionally, you can use the bitwise OR operation to apply either or both of the following:
  • NVMEDIA_RENDER_FLAG_FLIP_HORIZONTAL
  • NVMEDIA_RENDER_FLAG_FLIP_VERTICAL
Returns
NvMediaStatus The completion status of the operation. Possible values are:
NvMediaStatus NvMediaIJPDResize ( NvMediaIJPD decoder,
uint16_t  maxWidth,
uint16_t  maxHeight,
uint32_t  maxBitstreamBytes 
)

Resizes an existing image JPEG decoder.

Parameters
[in]decoderA pointer to the JPEG decoder to use.
[in]maxWidthThe new maximum width of output surface to support.
[in]maxHeightThe new maximum height of output surface to support.
[in]maxBitstreamBytesThe new maximum JPEG bitstream size in bytes to support.
Returns
NvMediaStatus The completion status of the operation. Possible values are:
NvMediaStatus NvMediaIJPDSetAttributes ( NvMediaIJPD decoder,
uint32_t  attributeMask,
void *  attributes 
)

Sets attributes of an existing image JPEG decoder.

Parameters
[in]decoderA pointer to the JPEG decoder to use.
[in]attributeMaskAn attribute mask. Supported mask are:
[in]attributesAttributes data. Supported attribute structures:
Returns
NvMediaStatus The completion status of the operation. Possible values are: