Decode

Function Usage

Image decoding API of the ImageProcessor class. The Image memory allocated by this API does not need to be managed or destroyed by users. Only the memory allocated on the host can be used as the input of this API. Currently, the data type of the input image memory can be JPEG or PNG. For details, see Image Decoding.

Prototype

1
APP_ERROR ImageProcessor::Decode(const std::shared_ptr<uint8_t> dataPtr, const uint32_t dataSize, Image& outputImage, const ImageFormat decodeFormat = ImageFormat::YUV_SP_420);
1
APP_ERROR ImageProcessor::Decode(const std::string inputPath, Image& outputImage, const ImageFormat decodeFormat = ImageFormat::YUV_SP_420);

Parameters

Parameter

Input/Output

Description

dataPtr

Input

Memory address of the image data to be decoded. This address needs to be managed by the user before decoding.

dataSize

Input

Memory size of the image data to be decoded. The value must be the same as the actual memory size of dataPtr.

  • If the header information of the image cannot be completely read by the user-defined dataSize, an exception is returned.
  • If the value of the user-defined dataSize is greater than the size of the header information and less than the actual memory size, partial decoding is performed based on the value of dataSize.

  • If the value of the user-defined dataSize is greater than the actual memory size, the value of image EOF is used.

decodeFormat

Input

Format of the decoded image

  • For JPG/JPEG images, the default value of decodeFormat is YUV_SP_420. Set this parameter as required.
  • For PNG images, BGR_888 is valid only when the input image channel is in RGB/GRAY format. In other cases, this parameter is invalid and decoding is performed based on the PNG input format.
    • If the PNG image channel is in RGB/GRAY format, the format of the decoded output image is RGB_888.
    • If the PNG image channel is in RGBA/AGRAY format, the format of the decoded output image is RGBA_8888.

inputPath

Input

Path of the image to be decoded.

outputImage

Output

Decoded Image class.

The original and aligned widths and heights of the image are automatically integrated into outputImage.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.