ebml-specification icon indicating copy to clipboard operation
ebml-specification copied to clipboard

add handling of encodings others than binary

Open retokromer opened this issue 7 years ago • 3 comments

Add a vector in the specification, which allows to define other encodings than binary, like the Gray codes.

retokromer avatar Jan 26 '18 15:01 retokromer

For the example I presented in Vienna (I guess it’s the simplest one), the conversion Gray to binary would be:

b3 = g3
b2 = b3 ⊕ g2
b1 = b2 ⊕ g1
b0 = b1 ⊕ g0

or:

unsigned int Gray_to_Bin(unsigned int g) {
    num = g ^ (g >> 32);
    num = g ^ (g >> 16);
    num = g ^ (g >> 8);
    num = g ^ (g >> 4);
    num = g ^ (g >> 2);
    num = g ^ (g >> 1);
    return g;
}

and binary to Gray:

g3 = b3
g2 = b3 ⊕ b2
g1 = b2 ⊕ b1
g0 = b1 ⊕ b0

or:

unsigned int Bin_to_Gray(unsigned int b) {
    return b ^ (b >> 1);
}

retokromer avatar Feb 25 '18 16:02 retokromer

Would that be for the integers stored in EBML or the EBML ID and Length fields ? In any case must cover more than 32 bits values.

robUx4 avatar Apr 15 '18 14:04 robUx4

We must indeed cover more than 32-bit values. This is just the example I presented in Vienna in order to explain the idea. And yes this are integers.

retokromer avatar Sep 07 '19 11:09 retokromer