Skip to content

Commit 5f1f8a9

Browse files
authored
Align with KDFS 1.4.0 rounding update (#548)
Updates the codec rounding for sRGB to align with the KDFS 1.4.0 specification update, which reverts the alpha channel endpoint expansion behavior to match an earlier version of the specification. This changes the alpha channel to use the same method ((x << 8) | 0x80) as the RGB channels. The previous behavior for alpha was doing ((x << 8) | x). The impact of this change is differences in the LSB for sRGB images. Fixes #547
1 parent d66e8a1 commit 5f1f8a9

8 files changed

+607
-616
lines changed

Docs/ChangeLog-5x.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ header. We always recommend rebuilding your client-side code using the
1818
header from the same release to avoid compatibility issues.
1919

2020
* **General:**
21+
* **Change:** Changed sRGB alpha channel endpoint expansion to match the
22+
revised Khronos Data Format Specification (v1.4.0), which reverts an
23+
unintended specification change. Compared to previous releases, this change
24+
can cause LSB bit differences in the alpha channel of compressed images.
2125
* **Feature:** Arm64 builds for Linux added to the GitHub Actions builds, and
2226
Arm64 binaries for NEON, 128-bit SVE 128 and 256-bit SVE added to release
2327
builds.

Source/astcenc_color_unquantize.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -925,15 +925,8 @@ void unpack_color_endpoints(
925925
alpha_hdr = false;
926926
}
927927

928-
vmask4 mask(true, true, true, false);
929-
930-
vint4 output0rgb = lsl<8>(output0) | vint4(0x80);
931-
vint4 output0a = output0 * 257;
932-
output0 = select(output0a, output0rgb, mask);
933-
934-
vint4 output1rgb = lsl<8>(output1) | vint4(0x80);
935-
vint4 output1a = output1 * 257;
936-
output1 = select(output1a, output1rgb, mask);
928+
output0 = lsl<8>(output0) | vint4(0x80);
929+
output1 = lsl<8>(output1) | vint4(0x80);
937930
}
938931
// An HDR profile decode, but may be using linear LDR endpoints
939932
// Linear LDR 8-bit endpoints are expanded to 16-bit by replication

Source/astcenc_internal.h

+4-10
Original file line numberDiff line numberDiff line change
@@ -1583,19 +1583,13 @@ static inline vmask4 get_u8_component_mask(
15831583
astcenc_profile decode_mode,
15841584
const image_block& blk
15851585
) {
1586-
vmask4 u8_mask(false);
1587-
// Decode mode writing to a unorm8 output value
1588-
if (blk.decode_unorm8)
1586+
// Decode mode or sRGB forces writing to unorm8 output value
1587+
if (blk.decode_unorm8 || decode_mode == ASTCENC_PRF_LDR_SRGB)
15891588
{
1590-
u8_mask = vmask4(true);
1591-
}
1592-
// SRGB writing to a unorm8 RGB value
1593-
else if (decode_mode == ASTCENC_PRF_LDR_SRGB)
1594-
{
1595-
u8_mask = vmask4(true, true, true, false);
1589+
return vmask4(true);
15961590
}
15971591

1598-
return u8_mask;
1592+
return vmask4(false);
15991593
}
16001594

16011595
/**

Test/Images/Small/astc_reference-main-avx2_fast_results.csv

+149-149
Large diffs are not rendered by default.

Test/Images/Small/astc_reference-main-avx2_fastest_results.csv

+149-149
Large diffs are not rendered by default.

Test/Images/Small/astc_reference-main-avx2_medium_results.csv

+149-149
Large diffs are not rendered by default.

Test/Images/Small/astc_reference-main-avx2_thorough_results.csv

+149-149
Large diffs are not rendered by default.

Test/astc_test_image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def parse_command_line():
319319
parser.add_argument("--encoder", dest="encoders", default="avx2",
320320
choices=coders, help="test encoder variant")
321321

322-
parser.add_argument("--reference", dest="reference", default="ref-5.0-avx2",
322+
parser.add_argument("--reference", dest="reference", default="ref-main-avx2",
323323
choices=refcoders, help="reference encoder variant")
324324

325325
astcProfile = ["ldr", "ldrs", "hdr", "all"]

0 commit comments

Comments
 (0)