Codebergdnkl
foot
master
1#!/usr/bin/env python3
3import argparse
4import math
6# Note: we use a pure gamma 2.2 function, rather than the piece-wise
7# sRGB transfer function, since that is what all compositors do.
9def srgb_to_linear(f: float) -> float:
10 assert(f >= 0 and f <= 1.0)
11 return math.pow(f, 2.2)
14def linear_to_srgb(f: float) -> float:
15 return math.pow(f, 1 / 2.2)
18def main() -> None:
19 parser = argparse.ArgumentParser()
20 parser.add_argument('c_output', type=argparse.FileType('w'))
21 parser.add_argument('h_output', type=argparse.FileType('w'))
22 opts = parser.parse_args()
24 linear_table: list[int] = []
26 for i in range(256):
27 linear_table.append(int(srgb_to_linear(float(i) / 255) * 65535 + 0.5))
30 opts.h_output.write("#pragma once\n")
31 opts.h_output.write("#include <stdint.h>\n")
32 opts.h_output.write("\n")
33 opts.h_output.write('/* 8-bit input, 16-bit output */\n')
34 opts.h_output.write("extern const uint16_t srgb_decode_8_to_16_table[256];")
36 opts.h_output.write('\n')
37 opts.h_output.write('static inline uint16_t\n')
38 opts.h_output.write('srgb_decode_8_to_16(uint8_t v)\n')
39 opts.h_output.write('{\n')
40 opts.h_output.write(' return srgb_decode_8_to_16_table[v];\n')
41 opts.h_output.write('}\n')
43 opts.h_output.write('\n')
44 opts.h_output.write('/* 8-bit input, 8-bit output */\n')
45 opts.h_output.write("extern const uint8_t srgb_decode_8_to_8_table[256];\n")
47 opts.h_output.write('\n')
48 opts.h_output.write('static inline uint8_t\n')
49 opts.h_output.write('srgb_decode_8_to_8(uint8_t v)\n')
50 opts.h_output.write('{\n')
51 opts.h_output.write(' return srgb_decode_8_to_8_table[v];\n')
52 opts.h_output.write('}\n')
54 opts.c_output.write('#include "srgb.h"\n')
55 opts.c_output.write('\n')
57 opts.c_output.write("const uint16_t srgb_decode_8_to_16_table[256] = {\n")
58 for i in range(256):
59 opts.c_output.write(f' {linear_table[i]},\n')
60 opts.c_output.write('};\n')
62 opts.c_output.write("const uint8_t srgb_decode_8_to_8_table[256] = {\n")
63 for i in range(256):
64 opts.c_output.write(f' {linear_table[i] >> 8},\n')
65 opts.c_output.write('};\n')
68if __name__ == '__main__':
69 main()
Diagnostics5 git calls · 23 ms
CallStatusSizeTime023 ms
discover200178 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=178 git.server.agent=git/2.56.1-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=178 git.pkt.payload.max=35
ls-refs20010 KiB · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=10322 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=108 git.pkt.data=107 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=10322 git.pkt.payload.max=106 git.ls_refs.count=107 git.ls_refs.head=refs/heads/master
fetchtree:0 · deepen 102009.3 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=9489 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=9489 git.pkt.payload.max=9389 git.sideband.band1.bytes=9389 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=9389 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=de930681b6073ba5b599a0f956bfbd114762ad5a git.pack.full=10Open pack map
fetchcombine:blob:none+tree:2 · deepen 12008.6 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=18 git.response.bytes=8830 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=8830 git.pkt.payload.max=8730 git.sideband.band1.bytes=8730 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=14 git.pack.bytes=8730 git.fetch.wide.objects=14 git.fetch.wide.extra_bytes=9909 git.fetch.wide.blobs=0
fetch200718 B · hit18 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=718 git.response.cache=HIT git.response.duration_ms=18 git.fetch.wants=fb718bcfce0d1d6c2520958a7f2c31c91a84f074 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=718 git.pkt.payload.max=691 git.sideband.band1.bytes=691 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://codeberg.org/dnkl/foot
- Ref
- refs/heads/master
- Commit
- c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
- cf-ray
- a5e22c4b5a482a83
- Request
- 91fbe21f…
- Protocol
- v2 · sha1
- Agent
- git/2.56.1-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format