saitoha / libsixel

A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel).
MIT License
2.43k stars 82 forks source link

Skipping repeated sixels #52

Open hodefoting opened 7 years ago

hodefoting commented 7 years ago

I am stuck trying to figure out if there is a good way in the libsixel code to skip drawing sixels that contain the same pixels as the previously drawn frame. This would, in combination with ordered/positionally stable dithers which I have already implemented - probably result in size/bandwidth savings for some uses like qemu/sdl/vnc/video.

See http://pippin.gimp.org/a_dither/ for examples of similar size savings for GIF animations, and https://github.com/hodefoting/libsixel for a branch with a commit adding positionally stable dithers - and a commit starting to work on tracking frame deltas.

saitoha commented 7 years ago

In SIXEL terminals as far as I know, there is no way to apply delta frames into the last frame.

Instead, we can overwrite SIXEL image in a unit of a text cell area. In SDL1.2-SIXEL and Xsixel, only the cells including the updated rectangle is rendered.

Or we might be able to reduce the number of colors while maintaining the quality of images, by using dithering along the time axis.

Since libsixel have only error diffusion algorithm, I'm interested in your dither algorithm. PR is welcome.

hodefoting commented 7 years ago

Updating single cells would be the next best thing over updating a full sixel (or even just some pixels within a sixel). I haven't looked into the details of how multiple layes of color are put down, but was imagining it to be some form of per color overwrite... a pull request with the positional methods have been made :)

hodefoting commented 7 years ago

Have looked into documentation on the sixel format. The initialization sequence for sixel takes, and have implemented a converter https://gist.github.com/hodefoting/272889a5d9d7859cb8aabc187901e6bc for taking a PNG and turning it into a 15grays put down in layers converter. (scale images down before converting). This works as expected and thus permits partial frame updates with xerm, however with mlterm the contents is always replaced with backgrour color - not sure what behavior actual terminals have.

vw.sixel.txt