BC4 interpolation formulas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ---- Intel decoder impl | |
| # matches 2014 HSW laptop | |
| weights8_intel = [round(256*x/7) for x in range(8)] | |
| weights6_intel = [round(256*x/5) for x in range(8)] | |
| def intel_lerp8(a, b, w): | |
| return ((256-w)*a + w*b + 128) >> 8 | |
| def interp_int_8col(a, b, x): | |
| # 16-bit interpolation, 8-color mode (e0 > e1) | |
| # not right yet! | |
| return ((7-x)*a + x*b) * 257 // 7 | |
| def interp_int_6col(a, b, x): | |
| # 16-bit interpolation, 6-color mode (e0 <= e1) | |
| # not right yet! | |
| return ((5-x)*a + x*b) * 257 // 5 | |
| def interp_int_8col_u8(a, b, x): | |
| # 8-bit interpolation, 8-color mode (e0 > e1) | |
| # this agrees exactly | |
| return intel_lerp8(a, b, weights8_intel[x]) | |
| def interp_int_6col_u8(a, b, x): | |
| # 8-bit interpolation, 6-color mode (e0 <= e1) | |
| # this agrees exactly | |
| return intel_lerp8(a, b, weights6_intel[x]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment