about summary refs log tree commit diff stats
path: root/adapter/img/stbi.nim
Commit message (Collapse)AuthorAgeFilesLines
* dynstream: fix memory leakbptato2024-10-041-1/+1
| | | | now I know why overloading dealloc felt wrong
* loader: mmap intermediate image files, misc refactoringbptato2024-09-221-42/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor parseHeader * optimize response blob() * add direct "to cache" mode for loader requests which sets stdout to a file, and use it for image processing * move image resizing into a separate process * mmap cache files in between processing steps when possible At last, resize is no longer a part of image decoding. Also, it feels much nicer to keep encoded image data in the same cache as everything else. The mmap operations *should* be more efficient than copying the whole RGBA data through a pipe. In practice, it only makes a difference for loading (well, now just mmapping) the encoded image into the pager, where it singlehandedly speeds up image display by 10x on my test image. For the other steps, the unfortunate fact that "tocache" must delay the next fork/exec in the pipeline until the entire image is processed seems to equal out any wins we might have gotten from skipping a single raw RGBA copy. I have tried moving the delay before the exec (it's possible with yet another pipe), but it didn't help much and made the code much uglier. (Not that tocache didn't, but I can live with this...)
* sixel, stbi, sandbox: fix fstat sandbox violationbptato2024-09-041-3/+4
| | | | | | | 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.
* stbi, jebp: use read/write instead of fread/fwritebptato2024-08-261-37/+70
| | | | | | | | 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.
* stbi: fix incompatible function pointer typebptato2024-07-181-2/+2
| | | | clang complains about this
* 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-281-10/+52
| | | | | | | | | | | | | | | * 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-211-17/+80
|
* img: use stb_image, drop zlib as dependencybptato2024-06-201-0/+57
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.