From 7a3827395c7ebcbbc9409f6d15381a6fb11e7954 Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Fri, 22 Nov 2024 04:14:00 -0300 Subject: [PATCH] libpng: interlaced support --- src/core/libraries/libpng/pngdec.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/libraries/libpng/pngdec.cpp b/src/core/libraries/libpng/pngdec.cpp index 64ab00782..2329ea825 100644 --- a/src/core/libraries/libpng/pngdec.cpp +++ b/src/core/libraries/libpng/pngdec.cpp @@ -158,17 +158,20 @@ s32 PS4_SYSV_ABI scePngDecDecode(OrbisPngDecHandle handle, const OrbisPngDecDeco color_type == PNG_COLOR_TYPE_PALETTE) png_set_add_alpha(pngh->png_ptr, param->alphaValue, PNG_FILLER_AFTER); + int pass = png_set_interlace_handling(pngh->png_ptr); png_read_update_info(pngh->png_ptr, pngh->info_ptr); - auto ptr = (png_bytep)param->imageMemAddr; - auto const numChannels = png_get_channels(pngh->png_ptr, pngh->info_ptr); auto horizontal_bytes = numChannels * width; int stride = param->imagePitch > 0 ? param->imagePitch : horizontal_bytes; - for (int y = 0; y < height; y++) { - png_read_row(pngh->png_ptr, ptr, NULL); - ptr += stride; + + for (int j = 0; j < pass; j++) { // interlaced + auto ptr = (png_bytep)param->imageMemAddr; + for (int y = 0; y < height; y++) { + png_read_row(pngh->png_ptr, ptr, nullptr); + ptr += stride; + } } return (width > 32767 || height > 32767) ? 0 : (width << 16) | height;