For the Ascend 310 AI Processor, this function is not supported in the current version.
For the Ascend 910 AI Processor, this function is not supported in the current version.
PNG Decoder (PNGD) decodes PNG images using hardware.
PNGD supports retaining the source image format during image decoding. That is, the image encoding 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:
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 |
During image decoding, hi_mpi_dvpp_malloc and hi_mpi_dvpp_free are called to allocate and free the input and output buffers on the device. The buffer lifetime is managed by the user.
If the output image format is unknown, set it to HI_PIXEL_FORMAT_UNKNOWN:
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.
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 |
PNGD can decode only complete PNG images rather than data packets split from a PNG image.