hbVPJPEGEncode

typedef void *hbVPJPEGContext;

hbVPJPEGEncode operator and the context description handle for the hbVPJPEGDecode operator, the handle contains the necessary description information to run on the JPU and can be reused.

typedef struct { uint8_t extendedSequential; uint8_t imageFormat; int32_t width; int32_t height; uint32_t qualityFactor; uint32_t outBufCount; } hbVPJPEGEncParam;

Encoding parameter for JPEG coding.

  • Member

    Member NameDescription
    extendedSequentialOnly 8bit encoding is supported, default value 0.
    imageFormatInput image format. Currently supports HB_VP_IMAGE_FORMAT_NV12, HB_VP_IMAGE_FORMAT_YUV420, HB_VP_IMAGE_FORMAT_YUV444 and HB_VP_IMAGE_FORMAT_YUV444_P format.
    widthThe width of the input picture. The range of values is [16, 32768].
    heightThe height of the input picture. The range of values is [16, 32768].
    qualityFactorThe encoding quality takes values in the range [0, 100], default value 50, the smaller the value the worse the picture quality.
    outBufCountThe count of JPU internal output buffers. The range of values is [1, 65536], default value 5.
int32_t hbVPCreateJPEGEncContext(hbVPJPEGContext *context, hbVPJPEGEncParam *param);

Create the encoder context API and initialize context to nullptr in advance before creation.

  • Parameter
    • [out] context The encoder context pointer.
    • [in] param Pointer to the encoding parameter.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • When imageFormat is in HB_VP_IMAGE_FORMAT_NV12 or HB_VP_IMAGE_FORMAT_YUV420 format, it is required that width satisfies 16 alignment and height satisfies 8 alignment.
    • When imageFormat is in HB_VP_IMAGE_FORMAT_YUV444 or HB_VP_IMAGE_FORMAT_YUV444_P format, it is required that width satisfies 8 alignment and height satisfies 8 alignment.
    • Due to hardware limitations, the encoder internally encodes in 16x16 units. When the data to be encoded is not 16x16 aligned, there will be a difference in the last part of the encoded data that is randomly filled, but it will not affect the valid data, and the encoded data resolution will not be changed. So you need to pay attention to this point when doing md5 comparison.
    • JPU supports the creation of contexts for the highest 64-way encoding or decoding.
    • JPU only support 8bit data encoding.
int32_t hbVPReleaseJPEGEncContext(hbVPJPEGContext context);

Release the encoder context API.

  • Parameter
    • [in] context The encoder context pointer.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
int32_t hbVPJPEGEncode(hbUCPTaskHandle_t *taskHandle, hbVPImage const *srcImg, hbVPJPEGContext context);

The API for calling the JPEG encoding.

  • Parameter
    • [out] taskHandle Task handles are responsible for the interaction of the operator with the UCP architecture.
    • [in] srcImg The memory address pointer where the encoded picture is stored.
    • [in] context The encoder context pointer.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • Only asynchronous task creation is supported.
int32_t hbVPGetJPEGEncOutputBuffer(hbUCPTaskHandle_t taskHandle, hbVPArray *dstBuf);

The API for calling the JPEG encoding output buffer.

  • Parameter
    • [in] taskHandle Task handles are responsible for the interaction of the operator with the UCP architecture.
    • [out] dstBuf The memory address pointer where the encoded JPEG data is stored.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • The JPEG buffer dstBuf is allocated internally by the JPU.
    • The buffer contains valid data upon the task is successfully completed, and is released during the task release phase.