about summary refs log tree commit diff stats
path: root/adapter/img
Commit message (Collapse)AuthorAgeFilesLines
* sixel: faster quantizationbptato2024-09-111-80/+92
| | | | | | | | | | | Reduce eager allocation of whole branches for leaves; now it's done only after the first conflict (or repeated color). This makes quantization ~2x faster for images without large runs of the same color and ~2x slower for images with a lot of those. No noticeable loss in quality. I also disabled refc for the octree and turned the nodes into tagged unions, which again resulted in a ~2x speedup.
* sixel: misc optimizationsbptato2024-09-091-42/+43
|
* sixel: small optimizationbptato2024-09-081-29/+27
| | | | | | For large palettes, looping over the entire chunk list is quite slow. Store the list of active chunks in a separate sequence so we can skip the unused ones.
* term: sixel sizing & output fixesbptato2024-09-051-7/+7
| | | | | | | | | | | | * round down to number divisible by 6 for height * make pager's dispw match term's dispw even after width clamping * make *BE procs actually emit/consume big-endian (lol) * fix borked sixel set raster attributes & control string I mixed up SRA with the device control string's parameters, so instead of toggling transparency in the DCS, I was setting the second SRA parameter to 0. Which, by the way, defines the aspect ratio's denominator, and has nothing to do with transparency. Whoops.
* sixel, stbi, sandbox: fix fstat sandbox violationbptato2024-09-042-50/+44
| | | | | | | Until recently, glibc used to implement it as fstatat. So don't trap for fstatat (and for consistency, fstat), but return EPERM. Just to be sure, rewrite sixel & stbi to never call fread.
* sixel: special case search for few color registersbptato2024-09-011-17/+58
| | | | | | See comment for details. (Also, set the palette size based on quality for toBlob.)
* canvas: make sure we don't link to QJSbptato2024-09-011-2/+1
|
* canvas: move to separate CGI scriptbptato2024-09-013-3/+148
| | | | | | | | | | * stream: and passFd is now client-based, and accessible for buffers * Bitmap's width & height is now int, not uint64 * no more non-network Bitmap special case in the pager for canvas I just shoehorned it into the static image model, so it still doesn't render changes after page load. But at least now it doesn't crash the browser.
* sixel: fix oobbptato2024-08-301-3/+2
| | | | whoops
* term, sixel: misc image fixes, sixel optimizationbptato2024-08-301-55/+97
| | | | | | | | * expand allowed color range somewhat * update maximum sixel size on window resize * fix kitty image cropping * use faster algorithm for sixel compression (also produces less wasteful output)
* sixel: ditheringbptato2024-08-291-42/+73
| | | | | | | | | | | | | uses floyd-steinberg - I originally tried atkinson, but liked the results with fs a bit more. also, I got rid of the half hearted attempt to skip tree traversals for color lookups, as it performs horribly with dithering. it *did* work if I set Y as the key, but it still felt wrong - well, as it turns out, octree traversal is faster anyway, so just do that. it works out nicely because we can fill in holes (from dithering) with a linear search for the nearest match as we go.
* sixel: fix borked approximation schemebptato2024-08-291-41/+29
| | | | | | | | | | | ok, of course if you search for the nearest entry after setting blue as the lowest index bits the search will be biased towards blue... let's just skip the trouble of reconstructing closest color relations by storing hashes in the octree - this way, I can ensure that the final merged colors are present in the buckets that getColor then looks at (while we're at it, also fix the color run merging code in quantize.)
* sixel: minor optimizationsbptato2024-08-281-51/+86
| | | | | | * don't emit transparency request when we don't need it * add lookup table for missing hash entries * write(2)'ize
* sixel, term: fix off-by-1's in croppingbptato2024-08-281-2/+6
| | | | & clean up outputSixelImage in general
* sixel: proper color quantizationbptato2024-08-271-37/+215
| | | | | | | | just use an octree. works fine afaict, though obviously somewhat slower than the static method (encoding is 2-pass now) & still has banding issues with many colors (will need dithering) also, fixed a bug that caused initial masks of bands to get misplaced
* stbi, jebp: use read/write instead of fread/fwritebptato2024-08-262-58/+116
| | | | | | | | glibc likes to do weird things (such as calling stat) when you use fread(3) and friends, so try to use functions that are more likely to just do a single syscall. Also, copy over some more paranoid read/write procedures to http.
* sixel: break out into a separate cgi scriptbptato2024-08-241-0/+202
| | | | | | | | This caches sixel output. Works best when the line height is a multiple of 6px, but should still be faster than the previous solution everywhere else too (simply by virtue of encoding separate images in parallel). Next step: actual color quantization
* jebp: fix NEON simd bugbptato2024-07-231-1/+1
| | | | | | SRCtype and DSTtype were mixed up. See https://todo.sr.ht/~bptato/chawan/14
* img: add webp decoder (jebp)bptato2024-07-203-0/+4852
| | | | | | | | | | It works fine AFAICT, just missing VP8 deblocking filters, so lossy WebP images don't look great. I have extended the API a bit to allow reading from stdin, not just paths. Otherwise, it's the same as matanui159/jebp. TODO: add loop filters
* stbi: fix incompatible function pointer typebptato2024-07-181-2/+2
| | | | clang complains about this
* img, makefile: remove png, update uninstall targetbptato2024-07-031-553/+0
|
* pager: PNGify kitty images, clear images on buffer switchbptato2024-07-021-2/+10
| | | | | | | | | | | Saves bandwidth; it's especially useful over SSH. Still not sure if this is the right solution, since it now needs two select cycles instead of one, and it does yet another copy of the image. (Unnecessarily, because stbi cannot stream its output, and stbiw cannot stream its input.) Also, to save memory, we now discard decoded images of buffers that are not being viewed.
* stbi: fix broken allocation in resizingbptato2024-06-291-1/+1
| | | | ;_;
* img, loader: add image resizing, misc fixesbptato2024-06-283-10/+2688
| | | | | | | | | | | | | | | * resize images with stb_image_resize * use tee for output handle redirection (redirectToFile blocks) * cache original image files * accept lseek in sandbox * misc stbi fixes For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in size, not sure if it's worth the cost. (Either way, we can always switch later if needed, since the API is almost the same.) Next step: move sixel/kitty encoders to CGI, and cache their output in memory instead of the intermediate RGBA representation.
* stbi: allow x-unknownbptato2024-06-221-1/+1
|
* stbi: add encodersbptato2024-06-213-17/+1807
|
* img: use stb_image, drop zlib as dependencybptato2024-06-204-19/+8087
| | | | | | | Now we have decoders for gif, jpeg, bmp. Also, the in-house PNG decoder has been replaced in favor of the stbi implementation; this means we no longer depend on zlib, since stbi comes with a built in inflate implementation.
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-0/+544
* multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.