TinyVG / specification

The specification for TinyVG. This is the central authority for the file system

Home Page:https://tinyvg.tech/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Double delta encoding

Jure-BB opened this issue · comments

commented

Hi,

I wonder, if double delta encoding was considered for points collections and if it would bring the size down even further?

Can you make an example for that? I'm not sure what you're referring to

commented

Sure. Instead of storing the points of a polygon like this:

[p1, p2, p3 ... pN]

where each Point consists of x and y fields that hold the distance to the origin, coordinates could be double delta encoded (holding delta of delta distance to a previous point) to lower the number of required bits to store the encoded value.

To simplify, let's look at just a single dimension [x1, x2, x3, x4 ... xN] where each x stores distance to origin:

Values:                 `[100, 105, 110, 121, 130]`
Delta encoded:          `[100,   5,   5,  11,   9]`
Delta-of-delta encoded: `[100,   5,   0,   6,  -2]`

Note that in delta-of-delta encoded array, first value holds distance to origin, second value holds distance to first value (ie. delta). From third value forward, values are double delta encoded.

These values can then be written as VarInts (or with some other scheme like Simple8b or RLE), so that each value takes only as many bits as necessary.

Since, points of vector graphics polygons usually follow some general direction, delta-of-delta encoding could be efficient.

https://pypi.org/project/delta-of-delta/
https://www.timescale.com/blog/time-series-compression-algorithms-explained/