codecs/image: comments to specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
95a6b03f70
30 files changed
+224
-770
No files matched your search
@@ -1,17 +1,11 @@
|
||||
--!strict
|
||||
--!native
|
||||
--!optimize 2
|
||||
-- codecs/image/Half: IEEE 754 binary16 ("half") <-> number, for the float texel formats (DDS / KTX R16F..., BC6H,
|
||||
-- OpenEXR HALF channels). New in rosetta. Never throws.
|
||||
--
|
||||
-- local f = Half.TABLE[h] -- the number of every half bit pattern 0..65535 (a 65536-entry table)
|
||||
-- local f = Half.toFloat(h) -- the same, computed
|
||||
-- local h = Half.fromFloat(f) -- round to nearest even; overflow -> infinity, NaN -> a quiet NaN
|
||||
-- codecs/image/Half: IEEE 754 binary16 <-> number (round to nearest even, overflow to infinity). New in rosetta.
|
||||
local Half = {}
|
||||
|
||||
local band, bor, rshift, lshift = bit32.band, bit32.bor, bit32.rshift, bit32.lshift
|
||||
|
||||
-- toFloat(h) -> number (h a 16-bit pattern)
|
||||
local function toFloat(h: number): number
|
||||
local s = if h >= 32768 then -1 else 1
|
||||
local e = band(rshift(h, 10), 31)
|
||||
@@ -33,7 +27,6 @@ Half.TABLE = TABLE
|
||||
|
||||
local scratch = buffer.create(4)
|
||||
|
||||
-- fromFloat(f) -> the nearest half bit pattern (ties to even)
|
||||
function Half.fromFloat(f: number): number
|
||||
if f ~= f then
|
||||
return 0x7E00
|
||||
|
||||
Reference in new issue
Block a user