Skip to content

Commit

Permalink
Move strcmp outside of while loops
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 21, 2023
1 parent 7a633e3 commit e57b08a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libImaging/BcnDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -874,6 +879,7 @@ decode_bcn(
}
}
break;
}
DECODE_LOOP(7, 16, rgba);
#undef DECODE_LOOP
}
Expand Down

0 comments on commit e57b08a

Please sign in to comment.