From e57b08affdb7ee9b1ede35db11bc80e05a8e5d3a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 21 Sep 2023 16:38:19 +1000 Subject: [PATCH] Move strcmp outside of while loops --- src/libImaging/BcnDecode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libImaging/BcnDecode.c b/src/libImaging/BcnDecode.c index dfd4b3e07a4..24c800677ca 100644 --- a/src/libImaging/BcnDecode.c +++ b/src/libImaging/BcnDecode.c @@ -850,10 +850,12 @@ decode_bcn( DECODE_LOOP(3, 16, rgba); DECODE_LOOP(4, 8, lum); case 5: + { + int sign = strcmp(pixel_format, "BC5S") == 0 ? 1 : 0; while (bytes >= 16) { rgba col[16]; memset(col, 0, 16 * sizeof(col[0])); - decode_bc5_block(col, ptr, strcmp(pixel_format, "BC5S") == 0 ? 1 : 0); + decode_bc5_block(col, ptr, sign); put_block(im, state, (const char *)col, sizeof(col[0]), C); ptr += 16; bytes -= 16; @@ -862,10 +864,13 @@ decode_bcn( } } break; + } case 6: + { + int sign = strcmp(pixel_format, "BC6HS") == 0 ? 1 : 0; while (bytes >= 16) { rgba col[16]; - decode_bc6_block(col, ptr, strcmp(pixel_format, "BC6HS") == 0 ? 1 : 0); + decode_bc6_block(col, ptr, sign); put_block(im, state, (const char *)col, sizeof(col[0]), C); ptr += 16; bytes -= 16; @@ -874,6 +879,7 @@ decode_bcn( } } break; + } DECODE_LOOP(7, 16, rgba); #undef DECODE_LOOP }