Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

investigate roadroller for compression #17

Open
KilledByAPixel opened this issue Aug 24, 2021 · 0 comments
Open

investigate roadroller for compression #17

KilledByAPixel opened this issue Aug 24, 2021 · 0 comments

Comments

@KilledByAPixel
Copy link
Owner

Investigate using a variant of roadroller to improve compression...

const options = {
    inBits: 7,
    outBits: -81,
    sparseSelectors: [0, 1, 2, 3, 6, 7, 13, 21, 25, 42, 50, 57],
    contextBits: 12,
    precision: 16,
    modelMaxCount: 127,
    recipLearningRate: 128,
    //preset: [...preset].map(c => c.charCodeAt(0)),
    modelQuotes: true,
};
let model;
                                                                                                     
model = new DefaultModel(options);
const compressed = compressWithModel(input, model, options);
                                                                                                     
model = new DefaultModel(options);
const decompressed = decompressWithModel(compressed, model, options);
t.deepEqual(decompressed, input);
                                                                                                     
// .#..#.######################.#.############################....#.##########################...#.
const SYMBOLS = "!$&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
let out = '';
let state = compressed.state; // 21 bits
for (let i = 0; i < 4; ++i) {
    out = SYMBOLS[state % SYMBOLS.length] + out;
    state = state / SYMBOLS.length | 0;
}
out += compressed.buf.map(i => SYMBOLS[i]).join('');
console.warn(out, out.length);

Result from ZzFX example (857 bytes)...

K?.BaP7Np*wg;4XAq&-pkT6lDY@!/wI0O~M/rNM,0nX?v;B4EvWwQ*v6Bqc8IY@uCTz+B6C.d;DGRFuQDAPJ:&fJRXplr7RX/S7Ch'FC3$3q@7VD?A+EIWXhRCcV~0'xOfOTs=dS,di2j$)2)EKp:cn(dSS7eeal~znz/.ycA')XAH2XEUuM1i@U5JgYTe-:4N+A!Nkjs2hoyyB?r(H+I,!mp7xlA1Uzq8m1cHK)Nz,-JD/k7Oeekvy)@sXx/YZsQZTVhD@kIXrCglwnak63U=**CC-SdMDSrb~@V8jv&J6UEfC$$?7UZam!=voPB&9M-5I?IamvSfuqHiKKABX=uYo~Bw~4c',IN&.F_VH=1KTx/8=.vlP;7(b)a@,jT&1c0Mbr$rMHyR*~fi~qVu*-c6k$-p':yoq*zyr/BXIKP@gBu5od6+z@s?9o+UzGkt-SHiplp=_pEP5SorwPLe6=_')-:o.Yfl9Vuk;sPOhuG4TK_6T3FgtBPbH(WmU(rZ4;i9UYFKegWRev:42J$aiWkjl:3eZTVy1&-M5.sjf($lg*5qRs.yT=ZS~WVEp;BZH@SZQDlNH8R5J8)FC0e&3B9hp/.@KRTXo~xV?YyN~:=$CIUp,idD~,OwMiRvpFfNKMG'NmV1qYG,unLHWM+Y!~JqoNgzYHAD+bxfhZxDs+P_VgekJ(UF2p)C--sI~0@1:QIiY.'g5'y_,(UyJA/A=27an;2-5MPm1AzCY6jOQTVo-8+'zy(+:LSapNrSw/)OH2lySYDF;YD0nEH(3HGjM/NC**OGQ@i?qFxJ6.f;C'/stP9++yyUWblOgpGvKS@meIesC7Kj,=;u.!WVVb4v5kc!8:N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant