0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JavaScriptでLZMA decoderを812 bytesで書く

Last updated at Posted at 2024-01-23

LZMAとは

LZ法と二値Range符号を組み合わせた汎用圧縮programで、高い圧縮率を誇っていらっしゃいます。圧縮速度は控え目ですが、伸長速度は超特急です。
言わずと知れた7zip、RAR、FreeArc等の書庫製造噐で採用されています。つまりあまりにも高性能過ぎるかもしれないので、皆さん遠慮なくLZMAを酷使無双し、こき使いまくってLZMA中毒重症患者になりましょうって話な訳がありません。

decoder

都合上Base64形式で掲載。復号すればきっちり828bytesとなります(制御文字多数混在)。関数名はfです。ちなみに大域変数 _ が存在します。
828 bytes版

Zm9yKGY9JzoxVjw8VVVlVC0tUyxuUik6UTUsUD4+Pk9oT04sY00yNTY7THArfmJLPmE/SmE9N0pJaz1IZm9yKEc7RztGKytdRTEpRDFELEN8fChCZihsLGRBdCx0PXZAMTYrH10sHh5hKh9kKSkdKHUsHDpyHDMsYSofGz1kGik7GT1jGChmWxdlPRY7ZDxMKRU9HGFNKT0+FD1iLGI9E2w9b1twRT0SPTERUzspEHVbYV0PHmEpPygOaWYoDGVsc2V7C3JldHVybiAJHmQpKzIsSQhSPW5VOHxzW2lFB2QrGisGZhcFKUcVBkEpBD5lO2IrGFQrKykGGD0FNh5kAyxOMjRCaFU9OAcZAhR7dmFyIGQ9AWYBdVswHhZkLzksZgEPQg8RMDI0GWMaKihOQ2MYPm5PMD8oaBgsDys9MjA0OC1kT1AwUShoLRhSLRgsDy0aT1BEAgljfSxxFGYcMCk/ZhxEPx9yHDgsRBsyNkQrOBs1Q3IBMSwWYUZhEAZmHGQrYxkJMVReZH0scz11LHQsdix3GiU5LGosbFIsbRFUL1BnEVQlUHAaPWE9MCxiLG89Wx5oETZ8Z1NVOCxpETgtaCxrRmgQZltoXT1bXQdGO2Q9cCZtLUQMBTAdewwWBTEeYSkpBTIOBTMOBTQOFmosaj10URZAURZ2LEgwLHYTZVEoSCEF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JAG2FEYREHHHUWK2MdCWReRn0scz11LHQsdix3PWQlORksbCxuLG1GLzUsZ0YlNSxwPWQ9MCxiLG89Wx5oSDZ8Z1NHOCxpSDgtaCxrRGgRH2hdPVtdCEQ7ZD1wJm0tQw4GMRd7DgYbVzAeYSkpBjIPBjMPBjQPG2oZUht0LHQ9dlJlEmVSKFchBjUXJiYoTTk6QmtJFR85AThUMR0LFR84ATdUMBksdBJYHzceNiw2Pms/ay0yRzZUOTIdDmI+MykOdT1iVkAVTygyfGImQ0dTdRZIND5jKUVsPRhiLWM7dQQrbB0LRTs0PHURVT1AFW4tVTNAbktoJlMaBy1jA0ViSmRHNBZIOzQEHQ5iPDApCW99fUUbUTtrERNvW2VBfQtsPR8YKGxWOC13fChwJmcpR3cpXRZIOw43PmEFOwtFG29bUV0UDldlVjcmQGVHPUAHPRUcbBZ8aysxRzgpLGNeawV9E2QtTGFLNE5hVDBOMzo2fX0nO189L1sBLR9ALVhdLy5leGVjKGYpOyl3aXRoKGYuc3BsaXQoXykpZj1qb2luKHNoaWZ0KCkpO2V2YWwoZik
使用例
a=f([93,0,0,1,0,6,0,0,0,0,0,0,0,0,49,24,74,43,255,186,138,31,255,255,111,92]);
console.log(a,String.fromCharCode.apply(0,a))

第一引数に数値配列を渡せば良い。戻り値はArray Objectとなります。上記例では[98,97,110,97,110,97]が返されています。String.fromCharCodeに渡された結果bananaという文字列が出現。

無圧縮版

圧縮版とは若干処理が異なる

1057bytes
f=u=>{for(var a=0,b,c,d=u[0],e=d/9,f=(b,a,d=b[a]||(b[a]=1024),c=d*(h>>>11))=>(c=c>n>>>0?(h=c,b[a]+=2048-d>>5,0):(h-=c,n-=c,b[a]-=d>>5,1),h>>24||(h<<=8,n=n<<8|u[i++]),c),q=(b,a)=>f(b,0)?f(b,1)?18+r(b,8,1):10+r(b,3,a*16+261):2+r(b,3,a*16+511),r=(b,a,c,d=1,e=a)=>{for(;a--;)d+=d+f(b,d+c);return 1<<e^d},s,t,v,w=d%9,j,l,n,m=1<<e/5,g=1<<e%5,p=d=0,o=[],h=16|g--<<8,i=18-h,k;h--;n=n<<8|u[i++])f[h]=[];for(;;d=p&m-1)if(f(f[1],s=a*16+d)){if(f(f[e=k=0],a))f(f[2],a)?(f(f[3],a)?(f(f[4],a)?(e=j,j=t):e=t,t=v):e=v,v=b,b=e):(k=!f(f[5],s))&&(a=7>a?9:11),k||(k=q(f[9],d),a=7>a?8:11);else{k=q(f[8],d),a=7>a?7:10,j=t,t=v,v=b,b=r(f[7],6,6>k?k-2<<6:192);if(b>3){if(s=b>>1,d=14>b,l=31-b+(b=(2|b&1)<<--s),!d){for(l=0;4<s--;d+=d-c)h>>>=1,c=n-h>>>31,n-=h&--c,h>>24||(h<<=8,n=n<<8|u[i++]);b+=d<<++s}for(d=1;s>e;b+=c<<e++)d+=d+=c=f(f[6],d+l);if(b<0)return o}}for(e=p+~b;k--;)l=o[p++]=o[e++]}else{l=f[16+(l>>8-w|(p&g)<<w)],d=1;if(7>a)for(;d<256;)d+=d+f(l,d);else{for(e=o[p+~b];d<256;)if(k=e>>7&1,e+=e,d+=d+=c=f(l,d|k+1<<8),c^k)for(;d<256;)d+=d+f(l,d)}l=o[p++]=d-256;a-=4>a?a:9<a?6:3}}

制約

本家LZMA decoderとは異なり、圧縮元の大きさや辞書長を読む機能はありません。従って圧縮時に-eos optionが有効な形式にしておく必要があります(End of stream marker刻印)。
それから展開可能な大きさもArray Objectの限界値までとなります。

動作検証

See the Pen Untitled by xezz (@xezz) on CodePen.

整形版+ほのかな説明的解説

f =(u,a,c)=>{
	var d=u[0],e=d / 9,
		f =(u,a,c)=>{// 1 bit復号
			var d=u[a] ||(u[a]=1024);
			c=d *(h >>> 11),c=c > n >>> 0 ?(h=c,u[a] +=2048 - d >>> 5,0):(h -=c,n -=c,u[a] -=d >>> 5,1),h >>> 24 ||(h <<=8,n=n << 8 | s[i++]);
			return c
		},
		r =(u,a,c)=>{// n bit復号
			var d=1,e=a;
			for(;a--;)d +=d + f(u,d + c);
			return 1 << e ^ d
		},
		s=u,t,v,w=d % 9,
		j,l,n,m=1 << e / 5,
		g=1 << e % 5,
		p=d=a=0,
		b,o=[],
		h=16 | g-- << 8,
		i=18 - h,k;
	// modelとrange coder初期化
	for(;h--;)f[h]=[],n=n << 8 | s[i++];
	// main loop
	for(;;d=p & m - 1)
		if(f(f[1],a * 16 + d)){// 辞書から復元
			if(f(f[e=k=0],a))// repeated offset
				f(f[2],a)?(f(f[3],a)?(f(f[4],a)?(e=j,j=t): e=t,t=v): e=v,v=b,b=e):(k=!f(f[5],a * 16 + d))&&(a=7 > a ? 9 : 11),
				k||(c=f[9],k=f(c,0)? f(c,1)? 16 + r(c,8,1): r(c,3,d * 16 + 261)+ 8 : r(c,3,d * 16 + 511),k+=2,a=7 > a ? 8 : 11);
			else{
				// 一致長と距離
				c=f[8],k=f(c,0)? f(c,1)? 16 + r(c,8,1): r(c,3,d * 16 + 261)+ 8 : r(c,3,d * 16 + 511),k+=2,a=7 > a ? 7 : 10,j=t,t=v,v=b,b=r(f[7],6,6 > k ? k - 2 << 6 : 192);
				if(b > 3)
					if(u=b >>> 1,c=b,b =(2 | b & 1)<< --u,d=14 > c)
						for(l=16+b-c;u > e;b +=c << e++)d +=d +=c=f(f[6],d + l);
					else{
						for(;4 < u--;)h >>>=1,c=n - h >>> 31,n -=h & --c,d +=d + -c,h >>> 24 ||(h <<=8,n=n << 8 | s[i++]);
						for(b +=d << 4,d=1;4 > e;b +=c << e++)d +=d +=c=f(f[6],d);
						if(b < 0)return o
					}
			}
			for(e=p + ~b;k--;)l=o[p++]=o[e++]
		}else{// 1文字復元
			l=f[16 +(l >>> 8 - w |(p & g)<< w)],d=1;
			if(7 > a)
				for(;d < 256;)d +=d + f(l,d);
			else{
				for(e=o[p + ~b];d < 256;)
					if(k=e >>> 7 & 1,e <<=1,d +=d +=c=f(l,d | k + 1 << 8),c ^ k)
						for(;d < 256;)d +=d + f(l,d)
			}
			l=o[p++]=d - 256;
			a -=4 > a ? a : 10 > a ? 3 : 6
		}
}

よく見ると分かりますが、無駄な文字が幾つか混入しています。forvarを入れて変数宣言してないのも気になる所ですが、これらを圧縮する上ではその方が良いのです(RegPackを改造した私家版で圧縮します)。
ついでにhtml+jsで974 bytes版も作ってみました(例によってBase64変換)。js1kでも通用する変態program。関数fの仕様は微妙に変更。

PGlucHV0IHR5cGU9ZmlsZSBvbmlucHV0PSdmb3IoZj1gPj4+cWhxcEE9bToxay0tfyk6X3JyYXlabmV3IFlkcTUsWD5hP1dhPTdXVkwrfmJUMjU2O1MpKVFyKFAtPU4rPU18fChLPTFKPDxJSkllSGZvUEc7RztGMSlFMUUsRCsrXUMxLCRmWyNdLCJmKB9pHx5lPR1jLBwxNisbLGo9dBopOxljPRgsZBc7ZDxTKRZsPW9bTEM9FT12LHY9YixiPRR/OykTImEqG2RREiJhKT8oESh1LGE9MCxjKT0+EDpQHDMXKhsPHyMOdVthXQxlbHNlewtyZXR1cm4gCSxuPW5JOHxzW2lDCFlVaW50OEFaKAdkTWQrBilHFgYfbBcpBT5lO2JNY0llKyspBj0YDjZdFwQscDI0S2hJPTgIGQM9EHt2YXIgZD0CIm0fYyk/HxxFPxtQHDgsRQ8yNkUrOA81REFNMixWAWZpbGVzWzBdLmFaQnVmZmVQKS50aGVuKBBkLmhyZWY9c2VsZi5VUkwuY3JlYXRlT2JqZWN0VVJMKFlCbG9iKFsHHwd1USldURlmAgwsHWQvOSxmAgxLDEowMjQZGGQqKHBEGGM+bnEwPyhoPRwMTTIwNDgtWDBfKGhOHG5OHAxOWEUDCWN9LHICJB1hRmETBh91FytjGQlkXkh9LHM9dSx0LHYsdz1kJTkaLGwsbixCSC81LGdIJTUsTD1kPTAsYixvPVsiaEo2fGd/STgsaUo4LWgsQUZoEyNoXT1bXQhGO2Q9TCZCLUUeDjESex4OHW0wImFRDjIRDjMRDjQRHWoaXx10LHQ9dl9lFGVfKG0hDjUSJiYoVjk6REFLGCM5AThrMRkLGCM4ATdrMBosdBRQIzciNiw2PkE/QS0ySTZrOTIZHmI+MykedT1icSQYYixiPSgyfGImRUl/dRdKND5jKUdsPWIrMzEtYzt1BCtsGQtHOzQ8dRNwPSQYbi1wMyRuTmgmfxwGLWMDR2JNZEk0F0o7NAQZHmI8MCkJb319Rx1UO0ETFW9bZUN9C2w9IxsobHE4LXd8KEwmZylJdyldF0o7Hjc+YQU7C0cdb1tUXRYebWVxNyYkZUk9JAY9GB9sF3xBKzFJOCksY15BBX0VZC1TYU40V2FrMFczOjZ9fWA7Xz0vW14gISUtQkxPUlVbLV5hLWpsbm9yLX5dLy5leGVjKGYpOyl3aXRoKGYuc3BsaXQoXykpZj1qb2luKHNoaWZ0KCkpO2V2YWwoZiknPjxhIGlkPWQgZG93bmxvYWQ+REw

本家とほぼ完全互換版

圧縮時に-eosが無効だった圧縮fileでも処理できるようにしたprogramも解き放っておきます。なぜ ほぼ かと言うと、64 bits浮動小数点数で計算している都合上、正常に復号できるFileの大きさは253 bytesまでだからです。ただしArray Objectの尺の限界を超えられません。

例によってBase64変換。使い方は前述の815 bytes版と同じ

decoder 845bytes
Zm9yKGY9YDoxd2s9Wi0tWXIoWCk6Vz4+PlZoVlUyNTY7VGQ8VClTcCt+YlI+YT9RYT03UVBiLGI9T2RWNSxOLT1NPTFMPDxLTEtlSisrXUkxKUgxSCxHfHwoRj0wLEVmW0QsZENmb1hCQjsfKz0eMSwdKTscZigbYywaZT0ZMTYrGCxqPXQXYz0WXSwVbD1vW3BJPRQ9dix2PU8TWTspEhVhKhhkKSkRFWEpPygQOlgaM0MqGA9pGw51W2FdDGVsc2V7CyxuPW5LOHxzW2lJCWQeZCsIG0QHcmV0dXJuIAYpH1MIG2xDKQU+ZTtiHmNLZSsrKQg9Fgc2FWQELFUyNEZoSz04CRwDPSh1LGFFYyk9Pnt2YXIgZD0CFVobYyk/GxpIPxhYGjgsSA8yNkgrOA81R2seMixQAWYCDCwZZC85LGYCDEYMTDAyNBwWZCooVUcWYz5uVjA/KGg9GgweMjA0OC1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if(f(f[1],s=a*16+d)){if(f(f[e=k=0],a))f(f[2],a)?(f(f[3],a)?(f(f[4],a)?(e=j,j=t):e=t,t=v):e=v,v=b,b=e):(k=!f(f[5],s))&&(a=7>a?9:11),k||(k=q(f[9],d),a=7>a?8:11);else{k=q(f[8],d),a=7>a?7:10,j=t,t=v,v=b,b=r(f[7],6,6>k?k-2<<6:192);if(b>3){if(s=b>>1,d=14>b,l=31-b+(b=(2|b&1)<<--s),!d){for(l=0;4<s--;d+=d-c)h>>>=1,c=n-h>>>31,n-=h&--c,h>>24||(h<<=8,n=n<<8|u[i++]);b+=d<<++s}for(d=1;s>e;b+=c<<e++)d+=d+=c=f(f[6],d+l);if(b<0)break}}for(e=p+~b;k--;)l=o[p++]=o[e++]}else{l=f[16+(l>>8-w|(p&g)<<w)],d=1;if(7>a)for(;d<256;)d+=d+f(l,d);else{for(e=o[p+~b];d<256;)if(k=e>>7&1,e+=e,d+=d+=c=f(l,d|k+1<<8),c^k)for(;d<256;)d+=d+f(l,d)}l=o[p++]=d-256;a-=4>a?a:9<a?6:3}return o}
html+js 1003bytes
PGlucHV0IHR5cGU9ZmlsZSBvbmlucHV0PSdmb3IoZj1gPj4+cWhxcEE9bToxay0tfyk6X3JyYXlabmV3IFlkcTUsWD5hP1dhPTdXVk8rfmJUKSlTcihRLT1QfHwoTj0xTTw8S01LZUo9MCxJMSlIMUgsRysrXUZmb1FFRTtEZltDXSwkKz0jMSwiZigfaR8eZT0dYywcMTYrGyxqPXQaKTsZYz0YLGQXbD1vW09GPRY9dix2PWIsYj0VMjU2OxR/OykTJGEqG2RTEiRhKT8oESh1LGFJYyk9PhA6URwzFyobDx9DDnVbYV0MZWxzZXsLLG49bks4fHNbaUYJWVVpbnQ4QVooCGQjZCsHcmV0dXJuIAYpRGQ8FCkHH2wXKQU+ZTtiI2NLZSsrKQc9GA42XRcELHAyNE5oSz04CRkDPRB7dmFyIGQ9AiRtH2MpPx8cSD8bURw4LEgPMjZIKzgPNUdBIzIsV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AZLHQUWkY3RTYsNj5rP2stMlE2OjE5MkMeYj4zKXsedT1iBkQYYixiPSgyfGImSlFXdRdTND5jKWw9YiszMS1jOwtNbD0wOzQ8dRNoBj1EGG4taAYzRG5YaCZXHActYwNiVmRRKyt1F1N9TTt1PmU7YlZjUWUrKykHPRgONl0XK2xDHmI8MCkFb319TR1/O2sTFW9bZUh9C2w9RhoobAY4LXF8KHAmZylRcSldF1M7Hjc+YQQ7C00db1t/XRYeWWUGNyZEZVE9RAc9GB9sF3xrKzFROCksY15rBH0VZC1HO2FYNBthOjEwGzM6Nn0Fb31gO189L1teIC1CTE9SVVstfl0vLmV4ZWMoZik7KXdpdGgoZi5zcGxpdChfKSlmPWpvaW4oc2hpZnQoKSk7ZXZhbChmKSc+PGEgaWQ9ZCBkb3dubG9hZD5ETA

実演。最下点に当該programが転がっています。codepenでは仕様上iframeからtop.URLを使えないので、self.URLで妥協し995 bytes

See the Pen LZMA decoder(2) by xezz (@xezz) on CodePen.

links

  • 7zip: LZMA等の力で書庫を作る
  • LZMA-SDK: 書庫に含まれるlzma.exeで純粋なLZMA圧縮file生成
  • LZMA-JS: JavaScriptによる圧縮と展開実装の有名所。decoderは本記事のものより遥かに巨大
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?