[vlc-devel] [PATCH] png:decoder: use png_set_scale_16

Tristan Matthews tmatth at videolan.org
Mon Nov 6 23:38:32 CET 2017


It's supposedly more accurate than png_set_strip_16 and available since libpng 1.5.4
The fallback may be overkill (contrib expects at least 1.5.4 already).

---
 modules/codec/png.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/codec/png.c b/modules/codec/png.c
index 645577f7ca..af9e7fcdbf 100644
--- a/modules/codec/png.c
+++ b/modules/codec/png.c
@@ -264,7 +264,14 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
         png_set_alpha_mode( p_png, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB );
 
     /* Strip to 8 bits per channel */
-    if( i_bit_depth == 16 ) png_set_strip_16( p_png );
+    if( i_bit_depth == 16 )
+    {
+#if PNG_LIBPNG_VER >= 10504
+        png_set_scale_16( p_png );
+#else
+        png_set_strip_16( p_png );
+#endif
+    }
 
     if( png_get_valid( p_png, p_info, PNG_INFO_tRNS ) )
     {
-- 
2.15.0



More information about the vlc-devel mailing list