From 56ffc8f7c9a218b448a9e56f81b9d0154a2dbf7f Mon Sep 17 00:00:00 2001 From: Laiho Date: Sat, 6 Jul 2024 15:38:58 +0300 Subject: [PATCH] read huf from file --- src/parser/src/second_pass/huf.b | Bin 0 -> 262142 bytes src/parser/src/second_pass/parser_settings.rs | 88 +----------------- 2 files changed, 5 insertions(+), 83 deletions(-) create mode 100644 src/parser/src/second_pass/huf.b diff --git a/src/parser/src/second_pass/huf.b b/src/parser/src/second_pass/huf.b new file mode 100644 index 0000000000000000000000000000000000000000..52322f7271cfb1d7122051d002dc33cc359c5dbc GIT binary patch literal 262142 zcmeI*-EvjO6$D@~f(T>>DZh4bFt+35{ogPaTRUO*jcA6deMa+LQ7Y=xfu8QwvsTZH zo<0B1H_x75zkK%b&*xX$pH~k*-#q;M&8y?zzkj{`y#M`UpZ{lk{`GbD`TYJrl%LP< z|4@EDzyD47`TYK$O8oNszb!wX-~Xcg_viQj`%Slg`TeV}|3Aw0OZc z@qc#x|9U(2|EK>BKl~?zvIu>uK)ah41fOL;g|J~{yY4>w*LQhGxq)bzr!#2 zZ~x!nm;BfNclag$_0i^4qcR=l>mk$$$Re;g|g9{~dnG zKmOn0m;B@Z9e&9_{@>x3{2TRu{r?#L^xxq}{~KO={vrSG_>=YT?EN48ck4(0m!<#j zQ-}FEF@9=wS^?!E#%l|w6(*K6no?qGjcl^ovclP{`|99(0|MdTq?*GaE>A!iu zHtQe%@A$+2kN#o)*YPLyH=6&r|2KyJ?EU|{w`2eR)$70cU&o*HzuD{m?E2ULcl=HN zrT-2;`rq){=ci}S|MdSIf9e0o-_`ej{J+!BQ>*{{f9>_3UH|g`j=%h$|39VtPybK< z^1sjj{he9=XZL^oKmF7Hy87q;^iTim>i?De-~0dG|9^gSwfVsH%k9rSpSybadH?&T zw*Tk<{Gb1?>;L+H`ltVO_0Rw5pZ?d?zx<#6>3?1Q^MCrM|8@1R|EGWYUswP9pZ@88 zUH$)jJI4Rj?|-@f)A8r2-T#{X{4f9S_?z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n2^{a=>;`G3b>`akk__5N@6{$Ku2|K9(8=KR0&|IYtA z|L^?2^Z(BOJOBUL_aA28|Lgzl|LyTRkY5sqlpF027@h9i+ z&i{4zrT(1%>+nnd&A$Ja|BtOd|L^e2`s4gxhhNqo=l?qVl7HU+>+nnd$^Se2l7DCK z|KzDlJ{~dnGfBxU$ zm;B@Z9e&9_{@>x3{Nw)}e#yVH{r|_??%!|yH@x=yoBY4yPx7Dtclf3L_c{@<-% z@}K{A_$B}Oe}`Z4kNx3{5#wK|8&>=`>p?mm;8Ujf&M%FT$=v9|I@8s)<66I4!`8T{eOpF z@^5tium2yzpZ+`i=zqg&-#?zc|L6Z5f3yD5e}^CaUzYym{~dqn|Hxncf5)G!fBe70 hFZJjBzYf3TpZEVd{E~m(|LgEe{>?uBxs?6?e*q$=V>JK( literal 0 HcmV?d00001 diff --git a/src/parser/src/second_pass/parser_settings.rs b/src/parser/src/second_pass/parser_settings.rs index 64082b87..de125104 100644 --- a/src/parser/src/second_pass/parser_settings.rs +++ b/src/parser/src/second_pass/parser_settings.rs @@ -312,89 +312,11 @@ impl SpecialIDs { } } -fn msb(mut val: u32) -> u32 { - let mut cnt = 0; - while val > 0 { - cnt = cnt + 1; - val = val >> 1; - } - cnt -} - pub fn create_huffman_lookup_table() -> Vec<(u8, u8)> { - let mut huffman_table = vec![(255, 255); HUF_LOOKUPTABLE_MAXVALUE as usize]; - let mut huffman_rev_table = vec![(255, 255); HUF_LOOKUPTABLE_MAXVALUE as usize]; - - huffman_table[0] = (0, 1); - huffman_table[2] = (39, 2); - huffman_table[24] = (8, 5); - huffman_table[50] = (2, 6); - huffman_table[51] = (29, 6); - huffman_table[100] = (2, 6); - huffman_table[101] = (29, 6); - huffman_table[26] = (4, 5); - huffman_table[432] = (30, 9); - huffman_table[866] = (38, 10); - huffman_table[55488] = (35, 16); - huffman_table[55489] = (34, 16); - huffman_table[27745] = (27, 15); - huffman_table[55492] = (25, 16); - huffman_table[55493] = (24, 16); - huffman_table[55494] = (33, 16); - huffman_table[55495] = (28, 16); - huffman_table[55496] = (13, 16); - huffman_table[110994] = (15, 17); - huffman_table[110995] = (14, 17); - huffman_table[27749] = (6, 15); - huffman_table[111000] = (21, 17); - huffman_table[111001] = (20, 17); - huffman_table[111002] = (23, 17); - huffman_table[111003] = (22, 17); - huffman_table[111004] = (17, 17); - huffman_table[111005] = (16, 17); - huffman_table[111006] = (19, 17); - huffman_table[111007] = (18, 17); - huffman_table[3469] = (5, 12); - huffman_table[1735] = (36, 11); - huffman_table[217] = (10, 8); - huffman_table[218] = (7, 8); - huffman_table[438] = (12, 9); - huffman_table[439] = (37, 9); - huffman_table[220] = (9, 8); - huffman_table[442] = (31, 9); - huffman_table[443] = (26, 9); - huffman_table[222] = (32, 8); - huffman_table[223] = (3, 8); - huffman_table[14] = (1, 4); - huffman_table[15] = (11, 4); - huffman_table[0] = (255, 255); - - const RIGHTSHIFT_BITORDER: u32 = 64 - 17; - let mut v: Vec = vec![]; - for (idx, x) in huffman_table.iter().enumerate() { - if x.0 != 255 { - v.push(idx as u32); - } - } - let mut idx_msb_map = Vec::with_capacity(HUF_LOOKUPTABLE_MAXVALUE as usize); - for i in 0..HUF_LOOKUPTABLE_MAXVALUE { - idx_msb_map.push(msb(i)); - } - for x in v { - let shifta = msb(x); - for (idx, pair) in idx_msb_map.iter().enumerate() { - if x == idx as u32 >> pair.wrapping_sub(shifta) { - let peekbits = (idx as u64).reverse_bits() >> RIGHTSHIFT_BITORDER; - huffman_table[idx as usize] = huffman_table[x as usize]; - huffman_rev_table[peekbits as usize] = huffman_table[x as usize]; - } - } - } - for v in 0..HUF_LOOKUPTABLE_MAXVALUE { - let p: u64 = (v as u64).reverse_bits() >> RIGHTSHIFT_BITORDER; - if p & 1 == 0 { - huffman_rev_table[p as usize] = (0, 1); - } + let buf = include_bytes!("huf.b"); + let mut huf2 = Vec::with_capacity(HUF_LOOKUPTABLE_MAXVALUE as usize); + for chunk in buf.chunks_exact(2) { + huf2.push((chunk[0], chunk[1])); } - huffman_rev_table + return huf2; }