Let’s say I have a value 10 and a baseline of 4. I expect the diff between these two to be 6 but the calculation of the diff makes it -6.
int diff = (int)(baseline - value);
Is this intended? Is it better for compression or something?
Let’s say I have a value 10 and a baseline of 4. I expect the diff between these two to be 6 but the calculation of the diff makes it -6.
int diff = (int)(baseline - value);
Is this intended? Is it better for compression or something?
Good question! I’m not sure what the original rationale was for this choice, but my understanding of the code is that ultimately it shouldn’t matter too much since negative values are interleaved with positive ones in the packed representation of integers (sequence is 0, -1, 1, -2, 2…).
In your example, -6 ends up being stored in the stream as unsigned integer 11, whereas positive 6 would end up being stored as unsigned integer 12.