Functions and Restrictions

The Atlas 200/300/500 Inference Product does not support the PNGD function described in this section.

The Atlas Training Series Product does not support the PNGD function described in this section.

Description

PNG Decoder (PNGD) decodes PNG images.

PNGD supports retaining the source image format during image decoding. That is, the image formats before and after decoding remain consistent. For example, if the source format is RGB, the destination format is RGB888.

If the source format of the PNG image is unknown, you can preserve the source format in either of the following methods:

  • When using the PNGD APIs, set the output image format to HI_PIXEL_FORMAT_UNKNOWN. By default, the source image format is used for output. In this method, however, the output image format is unknown. Therefore, you must allocate the output buffer as large as possible to ensure that the output image can be stored properly.

    Input Image Format

    Operation

    Actual Output Image Format

    RGB/GRAY

    Set the output image format to HI_PIXEL_FORMAT_UNKNOWN.

    RGB888

    RGBA/AGRAY

    Set the output image format to HI_PIXEL_FORMAT_UNKNOWN.

    RGBA8888

  • From the input source PNG image, obtain the width, height, width stride, height stride, output buffer, and format of the output image by using the hi_mpi_png_get_image_info call, and then set the output format by using a PNGD API based on the information obtained through the hi_mpi_png_get_image_info call.

Resolution Restrictions

  • Input resolution range:

    32 x 32 to 4096 x 4096

  • Output resolution range:

    PNGD only decodes images and does not change the image resolution. Therefore, the resolution of the output image is the same as that of the input image.

Restrictions on Image Formats, Width and Height Alignment, and Buffers

If the output image format is unknown, set it to HI_PIXEL_FORMAT_UNKNOWN:

  • Width stride

    If the input image is in RGB or GRAY format, the width stride is obtained by rounding up the width of the output image to the nearest multiple of 128 and then multiplying the result by 3. If the input image is in RGBA or AGRAY format, the width stride is obtained by rounding up the width of the output image to the nearest multiple of 128 and then multiplying the result by 4.

  • Height stride: Round up the height of the output image to the nearest multiple of 16.
Table 1 Restrictions on the image format, width and height alignment, and buffer size

Input Image Format

Output Format

Output Width and Height

Output Width Stride, Height Stride, and Buffer Size

RGB

RGB888

No alignment requirement.

Width stride: Round up the width to the nearest multiple of 1, 16, or 128 and multiply the result by 3.

Value range of the height stride: [Height of the output image, Height of the output image rounded up to a multiple of 128]

Buffer size (in bytes) = Width stride x Height stride

GRAY

RGB888

RGBA

RGB888

Width stride: Round up the width to the nearest multiple of 1, 16, or 128 and multiply the result by 3.

Value range of the height stride: [Height of the output image, Height of the output image rounded up to a multiple of 128]

Buffer size (in bytes) = Width stride x Height stride

RGBA8888 8-bit

Width stride: Round up the width to the nearest multiple of 1, 16, or 128 and multiply the result by 4.

Value range of the height stride: [Height of the output image, Height of the output image rounded up to a multiple of 128]

Buffer size (in bytes) = Width stride x Height stride

AGRAY

RGB888

Width stride: Round up the width to the nearest multiple of 1, 16, or 128 and multiply the result by 3.

Value range of the height stride: [Height of the output image, Height of the output image rounded up to a multiple of 128]

Buffer size (in bytes) = Width stride x Height stride

RGBA8888 8-bit

Width stride: Round up the width to the nearest multiple of 1, 16, or 128 and multiply the result by 4.

Value range of the height stride: [Height of the output image, Height of the output image rounded up to a multiple of 128]

Buffer size (in bytes) = Width stride x Height stride

  • For details about the definition of the output image format, see hi_pixel_format. For details about the concepts such as width stride and height stride, see Terminology.
  • If the width stride and height stride are set to 0 and passed to the corresponding APIs, PNGD will round up the width stride to the nearest multiple of 128 and round up the height stride to the nearest multiple of 16 by default based on the output image format.

Other Restrictions

PNGD can decode only complete PNG images rather than data packets split from a PNG image.