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, the parameter value is 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 [32, 8192].
    heightThe height of the input picture. The range of values is [32, 8192].
    qualityFactorThe encoding quality takes values in the range [1, 100], recommended value 50, the smaller the value the worse the picture quality.
    outBufCountThe count of JPU internal output buffers. The range of values is [1, 1000], recommended 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.
    • [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 HB_VP_IMAGE_FORMAT_NV12 or HB_VP_IMAGE_FORMAT_YUV420, the width must be aligned to 16 and the height must be aligned to 8, with the encoder processing data in 16x16 units.
    • When imageFormat is HB_VP_IMAGE_FORMAT_YUV444 or HB_VP_IMAGE_FORMAT_YUV444_P, both the width and height must be aligned to 8, with the encoder processing data in 8x8 units.
    • Due to hardware limitations, for unaligned data, the encoder will add random padding to the final part of the data. These padding bytes will not affect the valid content or the encoded resolution but may cause differences in md5 checksum results, which should be noted.
    • 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.
  • 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 Input YUV Image.
    • [in] context The encoder context.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • Only asynchronous task creation is supported.
    • To avoid wasting system resources and improve JPU encoding performance, it is recommended to reuse input addresses.
int32_t hbVPGetJPEGEncOutputBuffer(hbVPArray *outBuf, 
                                   hbUCPTaskHandle_t taskHandle);

The API for calling the JPEG encoding output buffer.

  • Parameter
    • [out] outBuf Output JPEG file.
    • [in] taskHandle Task handles are responsible for the interaction of the operator with the UCP architecture.
  • Return Value
    • Return 0 means the API was successfully executed, otherwise the execution failed.
  • Description of interface limitations
    • The JPEG buffer outBuf 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.