Updated on 2022-03-13 GMT+08:00

JPEGE Parameters

Input Parameter: sJpegeIn

Table 1 Input parameter sJpegeIn

Member Variable

Description

eEncodeFormat format

Format of the YUV input data. YUV422 packed (YUYV, YVYU, UYVY, and VYUY) and YUV420 semi-planar (NV12 and NV21) are supported.

typedef enum {

JPGENC_FORMAT_UYVY = 0x0,

JPGENC_FORMAT_VYUY = 0x1,

JPGENC_FORMAT_YVYU = 0x2,

JPGENC_FORMAT_YUYV = 0x3,

JPGENC_FORMAT_NV12 = 0x10,

JPGENC_FORMAT_NV21 = 0x11,

} eEncodeFormat;

unsigned char* buf

The YUV input data needs to be allocated by the caller and must be properly aligned. For details, see the information about the stride and heightAligned parameters.

You are advised to allocate the buffer by calling HIAI_DVPP_DMalloc provided by Matrix. The allocated buffer must meet the DVPP requirements, that is, the buffer addresses of the input and output images must be in the same 4 GB space, and the start addresses must be 128-pixel aligned. For details about HIAI_DVPP_DMalloc, see Matrix API Reference.

NOTICE:

When HIAI_DVPP_DMalloc is used to allocate a buffer, ensure that the size of the allocated buffer is the same as the value of the input parameter bufSize.

uint32_t bufSize

Length of the input buffer, that is, the length of the data after the width and height are aligned

uint32_t width

Width of the input image. The value range is [32, 8192].

uint32_t height

Height of the input image. The value range is [32, 8192].

uint32_t stride

Width of the input image after alignment. The width alignment boundary can be 16 pixels or a multiple of 16 pixels, for example, 128 pixels. For YUV422 packed data, the stride must be the result after the width is multiplied by 2 and then aligned to a 16-pixel boundary.

uint32_t heightAligned

1. The value can be the same as the height. 2. The value can be the aligned image height after Matrix cross-side transmission. 3. The value supports 16-pixel alignment.

uint32_t level

Encoding quality in a range of [0, 100]. The encoding quality of level 0 is similar to that of level 100. For the value range of [1, 100], a smaller value indicates poorer output image quality.

Output Parameter: sJpegeOut

Table 2 Output parameter sJpegeOut

Member Variable

Description

unsigned char* jpgData

Start address of the JPG data in the output buffer

You are advised to allocate the buffer by calling HIAI_DVPP_DMalloc provided by Matrix. The allocated buffer must meet the DVPP requirements, that is, the buffer addresses of the input and output images must be in the same 4 GB space, and the start addresses must be 128-pixel aligned. For details about HIAI_DVPP_DMalloc, see Matrix API Reference.

NOTICE:

When HIAI_DVPP_DMalloc is used to allocate a buffer, ensure that the size of the allocated buffer is the same as the value of the input parameter jpgSize.

uint32_t jpgSize

Data length of the encoded JPG image

JpegCalBackFree cbFree

Callback function for freeing the output buffer

  • If the output buffer is specified by the user, it should also be freed by the user.
  • If the output buffer is not specified by the user, DVPP allocates the buffer internally. The cbFree() callback function should be called to free the buffer, and jpgData needs to be set to a null pointer. For details about the calling example, see Implementing the JPEGE Function.