7z-iterator 0.1.10 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sevenz/codecs/BcjArm.d.cts +20 -0
- package/dist/cjs/sevenz/codecs/BcjArm.d.ts +20 -0
- package/dist/cjs/sevenz/codecs/BcjArm.js +62 -0
- package/dist/cjs/sevenz/codecs/BcjArm.js.map +1 -0
- package/dist/cjs/sevenz/codecs/BcjArm64.d.cts +21 -0
- package/dist/cjs/sevenz/codecs/BcjArm64.d.ts +21 -0
- package/dist/cjs/sevenz/codecs/BcjArm64.js +65 -0
- package/dist/cjs/sevenz/codecs/BcjArm64.js.map +1 -0
- package/dist/cjs/sevenz/codecs/BcjArmt.d.cts +19 -0
- package/dist/cjs/sevenz/codecs/BcjArmt.d.ts +19 -0
- package/dist/cjs/sevenz/codecs/BcjArmt.js +76 -0
- package/dist/cjs/sevenz/codecs/BcjArmt.js.map +1 -0
- package/dist/cjs/sevenz/codecs/BcjIa64.d.cts +15 -0
- package/dist/cjs/sevenz/codecs/BcjIa64.d.ts +15 -0
- package/dist/cjs/sevenz/codecs/BcjIa64.js +141 -0
- package/dist/cjs/sevenz/codecs/BcjIa64.js.map +1 -0
- package/dist/cjs/sevenz/codecs/BcjPpc.d.cts +20 -0
- package/dist/cjs/sevenz/codecs/BcjPpc.d.ts +20 -0
- package/dist/cjs/sevenz/codecs/BcjPpc.js +64 -0
- package/dist/cjs/sevenz/codecs/BcjPpc.js.map +1 -0
- package/dist/cjs/sevenz/codecs/BcjSparc.d.cts +19 -0
- package/dist/cjs/sevenz/codecs/BcjSparc.d.ts +19 -0
- package/dist/cjs/sevenz/codecs/BcjSparc.js +69 -0
- package/dist/cjs/sevenz/codecs/BcjSparc.js.map +1 -0
- package/dist/cjs/sevenz/codecs/index.js +44 -1
- package/dist/cjs/sevenz/codecs/index.js.map +1 -1
- package/dist/cjs/sevenz/constants.d.cts +7 -0
- package/dist/cjs/sevenz/constants.d.ts +7 -0
- package/dist/cjs/sevenz/constants.js +41 -0
- package/dist/cjs/sevenz/constants.js.map +1 -1
- package/dist/esm/sevenz/codecs/BcjArm.d.ts +20 -0
- package/dist/esm/sevenz/codecs/BcjArm.js +53 -0
- package/dist/esm/sevenz/codecs/BcjArm.js.map +1 -0
- package/dist/esm/sevenz/codecs/BcjArm64.d.ts +21 -0
- package/dist/esm/sevenz/codecs/BcjArm64.js +57 -0
- package/dist/esm/sevenz/codecs/BcjArm64.js.map +1 -0
- package/dist/esm/sevenz/codecs/BcjArmt.d.ts +19 -0
- package/dist/esm/sevenz/codecs/BcjArmt.js +66 -0
- package/dist/esm/sevenz/codecs/BcjArmt.js.map +1 -0
- package/dist/esm/sevenz/codecs/BcjIa64.d.ts +15 -0
- package/dist/esm/sevenz/codecs/BcjIa64.js +127 -0
- package/dist/esm/sevenz/codecs/BcjIa64.js.map +1 -0
- package/dist/esm/sevenz/codecs/BcjPpc.d.ts +20 -0
- package/dist/esm/sevenz/codecs/BcjPpc.js +55 -0
- package/dist/esm/sevenz/codecs/BcjPpc.js.map +1 -0
- package/dist/esm/sevenz/codecs/BcjSparc.d.ts +19 -0
- package/dist/esm/sevenz/codecs/BcjSparc.js +59 -0
- package/dist/esm/sevenz/codecs/BcjSparc.js.map +1 -0
- package/dist/esm/sevenz/codecs/index.js +44 -1
- package/dist/esm/sevenz/codecs/index.js.map +1 -1
- package/dist/esm/sevenz/constants.d.ts +7 -0
- package/dist/esm/sevenz/constants.js +42 -0
- package/dist/esm/sevenz/constants.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// BCJ (ARM Thumb) filter codec - converts ARM Thumb branch instruction addresses
|
|
2
|
+
// This filter makes ARM Thumb executables more compressible by LZMA
|
|
3
|
+
//
|
|
4
|
+
// ARM Thumb uses 16-bit instructions, but BL (branch with link) spans two 16-bit words.
|
|
5
|
+
// The filter converts relative addresses to absolute during compression.
|
|
6
|
+
//
|
|
7
|
+
// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
|
|
8
|
+
import { bufferFrom } from 'extract-base-iterator';
|
|
9
|
+
import createBufferingDecoder from './createBufferingDecoder.js';
|
|
10
|
+
/**
|
|
11
|
+
* Decode ARM Thumb BCJ filtered data
|
|
12
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
13
|
+
*
|
|
14
|
+
* ARM Thumb BL instruction format (2 x 16-bit):
|
|
15
|
+
* - First half-word: 1111 0xxx xxxx xxxx (high bits of offset)
|
|
16
|
+
* - Second half-word: 1111 1xxx xxxx xxxx (low bits of offset)
|
|
17
|
+
*
|
|
18
|
+
* @param input - ARM Thumb BCJ filtered data
|
|
19
|
+
* @param _properties - Unused for ARM Thumb BCJ
|
|
20
|
+
* @param _unpackSize - Unused for ARM Thumb BCJ
|
|
21
|
+
* @returns Unfiltered data
|
|
22
|
+
*/ export function decodeBcjArmt(input, _properties, _unpackSize) {
|
|
23
|
+
var output = bufferFrom(input); // Copy since we modify in place
|
|
24
|
+
var pos = 0;
|
|
25
|
+
// Process 2-byte aligned positions
|
|
26
|
+
while(pos + 4 <= output.length){
|
|
27
|
+
// Read two 16-bit values (little-endian)
|
|
28
|
+
var w0 = output[pos] | output[pos + 1] << 8;
|
|
29
|
+
var w1 = output[pos + 2] | output[pos + 3] << 8;
|
|
30
|
+
// Check for BL instruction pair:
|
|
31
|
+
// First word: 0xF000-0xF7FF (1111 0xxx xxxx xxxx)
|
|
32
|
+
// Second word: 0xF800-0xFFFF (1111 1xxx xxxx xxxx)
|
|
33
|
+
if ((w0 & 0xf800) === 0xf000 && (w1 & 0xf800) === 0xf800) {
|
|
34
|
+
// Extract and combine the offset parts
|
|
35
|
+
// High 11 bits from w0, low 11 bits from w1
|
|
36
|
+
var hi = w0 & 0x7ff;
|
|
37
|
+
var lo = w1 & 0x7ff;
|
|
38
|
+
// Combine into 22-bit offset (in half-words)
|
|
39
|
+
var addr = hi << 11 | lo;
|
|
40
|
+
// Sign-extend 22-bit to 32-bit
|
|
41
|
+
if (addr & 0x200000) {
|
|
42
|
+
addr |= 0xffc00000;
|
|
43
|
+
}
|
|
44
|
+
// Convert absolute to relative:
|
|
45
|
+
// Subtract current position (in half-words, so divide by 2)
|
|
46
|
+
// Thumb PC is 2 half-words (4 bytes) ahead
|
|
47
|
+
var relAddr = addr - (pos >>> 1);
|
|
48
|
+
// Write back
|
|
49
|
+
var newHi = relAddr >>> 11 & 0x7ff;
|
|
50
|
+
var newLo = relAddr & 0x7ff;
|
|
51
|
+
output[pos] = newHi & 0xff;
|
|
52
|
+
output[pos + 1] = 0xf0 | newHi >>> 8 & 0x07;
|
|
53
|
+
output[pos + 2] = newLo & 0xff;
|
|
54
|
+
output[pos + 3] = 0xf8 | newLo >>> 8 & 0x07;
|
|
55
|
+
pos += 4;
|
|
56
|
+
} else {
|
|
57
|
+
pos += 2;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return output;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create an ARM Thumb BCJ decoder Transform stream
|
|
64
|
+
*/ export function createBcjArmtDecoder(properties, unpackSize) {
|
|
65
|
+
return createBufferingDecoder(decodeBcjArmt, properties, unpackSize);
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjArmt.ts"],"sourcesContent":["// BCJ (ARM Thumb) filter codec - converts ARM Thumb branch instruction addresses\n// This filter makes ARM Thumb executables more compressible by LZMA\n//\n// ARM Thumb uses 16-bit instructions, but BL (branch with link) spans two 16-bit words.\n// The filter converts relative addresses to absolute during compression.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode ARM Thumb BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * ARM Thumb BL instruction format (2 x 16-bit):\n * - First half-word: 1111 0xxx xxxx xxxx (high bits of offset)\n * - Second half-word: 1111 1xxx xxxx xxxx (low bits of offset)\n *\n * @param input - ARM Thumb BCJ filtered data\n * @param _properties - Unused for ARM Thumb BCJ\n * @param _unpackSize - Unused for ARM Thumb BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjArmt(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n var output = bufferFrom(input); // Copy since we modify in place\n var pos = 0;\n\n // Process 2-byte aligned positions\n while (pos + 4 <= output.length) {\n // Read two 16-bit values (little-endian)\n var w0 = output[pos] | (output[pos + 1] << 8);\n var w1 = output[pos + 2] | (output[pos + 3] << 8);\n\n // Check for BL instruction pair:\n // First word: 0xF000-0xF7FF (1111 0xxx xxxx xxxx)\n // Second word: 0xF800-0xFFFF (1111 1xxx xxxx xxxx)\n if ((w0 & 0xf800) === 0xf000 && (w1 & 0xf800) === 0xf800) {\n // Extract and combine the offset parts\n // High 11 bits from w0, low 11 bits from w1\n var hi = w0 & 0x7ff;\n var lo = w1 & 0x7ff;\n\n // Combine into 22-bit offset (in half-words)\n var addr = (hi << 11) | lo;\n\n // Sign-extend 22-bit to 32-bit\n if (addr & 0x200000) {\n addr |= 0xffc00000;\n }\n\n // Convert absolute to relative:\n // Subtract current position (in half-words, so divide by 2)\n // Thumb PC is 2 half-words (4 bytes) ahead\n var relAddr = addr - (pos >>> 1);\n\n // Write back\n var newHi = (relAddr >>> 11) & 0x7ff;\n var newLo = relAddr & 0x7ff;\n\n output[pos] = newHi & 0xff;\n output[pos + 1] = 0xf0 | ((newHi >>> 8) & 0x07);\n output[pos + 2] = newLo & 0xff;\n output[pos + 3] = 0xf8 | ((newLo >>> 8) & 0x07);\n\n pos += 4;\n } else {\n pos += 2;\n }\n }\n\n return output;\n}\n\n/**\n * Create an ARM Thumb BCJ decoder Transform stream\n */\nexport function createBcjArmtDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjArmt, properties, unpackSize);\n}\n"],"names":["bufferFrom","createBufferingDecoder","decodeBcjArmt","input","_properties","_unpackSize","output","pos","length","w0","w1","hi","lo","addr","relAddr","newHi","newLo","createBcjArmtDecoder","properties","unpackSize"],"mappings":"AAAA,iFAAiF;AACjF,oEAAoE;AACpE,EAAE;AACF,wFAAwF;AACxF,yEAAyE;AACzE,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,cAAcC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACrF,IAAIC,SAASN,WAAWG,QAAQ,gCAAgC;IAChE,IAAII,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKD,OAAOE,MAAM,CAAE;QAC/B,yCAAyC;QACzC,IAAIC,KAAKH,MAAM,CAACC,IAAI,GAAID,MAAM,CAACC,MAAM,EAAE,IAAI;QAC3C,IAAIG,KAAKJ,MAAM,CAACC,MAAM,EAAE,GAAID,MAAM,CAACC,MAAM,EAAE,IAAI;QAE/C,iCAAiC;QACjC,kDAAkD;QAClD,mDAAmD;QACnD,IAAI,AAACE,CAAAA,KAAK,MAAK,MAAO,UAAU,AAACC,CAAAA,KAAK,MAAK,MAAO,QAAQ;YACxD,uCAAuC;YACvC,4CAA4C;YAC5C,IAAIC,KAAKF,KAAK;YACd,IAAIG,KAAKF,KAAK;YAEd,6CAA6C;YAC7C,IAAIG,OAAO,AAACF,MAAM,KAAMC;YAExB,+BAA+B;YAC/B,IAAIC,OAAO,UAAU;gBACnBA,QAAQ;YACV;YAEA,gCAAgC;YAChC,4DAA4D;YAC5D,2CAA2C;YAC3C,IAAIC,UAAUD,OAAQN,CAAAA,QAAQ,CAAA;YAE9B,aAAa;YACb,IAAIQ,QAAQ,AAACD,YAAY,KAAM;YAC/B,IAAIE,QAAQF,UAAU;YAEtBR,MAAM,CAACC,IAAI,GAAGQ,QAAQ;YACtBT,MAAM,CAACC,MAAM,EAAE,GAAG,OAAQ,AAACQ,UAAU,IAAK;YAC1CT,MAAM,CAACC,MAAM,EAAE,GAAGS,QAAQ;YAC1BV,MAAM,CAACC,MAAM,EAAE,GAAG,OAAQ,AAACS,UAAU,IAAK;YAE1CT,OAAO;QACT,OAAO;YACLA,OAAO;QACT;IACF;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASW,qBAAqBC,UAAmB,EAAEC,UAAmB;IAC3E,OAAOlB,uBAAuBC,eAAegB,YAAYC;AAC3D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Transform } from 'readable-stream';
|
|
2
|
+
/**
|
|
3
|
+
* Decode IA64 BCJ filtered data
|
|
4
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
5
|
+
*
|
|
6
|
+
* @param input - IA64 BCJ filtered data
|
|
7
|
+
* @param _properties - Unused for IA64 BCJ
|
|
8
|
+
* @param _unpackSize - Unused for IA64 BCJ
|
|
9
|
+
* @returns Unfiltered data
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeBcjIa64(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer;
|
|
12
|
+
/**
|
|
13
|
+
* Create an IA64 BCJ decoder Transform stream
|
|
14
|
+
*/
|
|
15
|
+
export declare function createBcjIa64Decoder(properties?: Buffer, unpackSize?: number): Transform;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// BCJ (IA64/Itanium) filter codec - converts IA64 branch instruction addresses
|
|
2
|
+
// This filter makes IA64 executables more compressible by LZMA
|
|
3
|
+
//
|
|
4
|
+
// IA64 uses 128-bit instruction bundles with 3 instructions per bundle.
|
|
5
|
+
// Branch instructions use 21-bit signed offsets (in bundles).
|
|
6
|
+
//
|
|
7
|
+
// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
|
|
8
|
+
import { bufferFrom } from 'extract-base-iterator';
|
|
9
|
+
import createBufferingDecoder from './createBufferingDecoder.js';
|
|
10
|
+
// IA64 branch instruction slot mask
|
|
11
|
+
// Each bundle has a 5-bit template and 3 x 41-bit instruction slots
|
|
12
|
+
var kBranchTable = [
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0,
|
|
16
|
+
0,
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0,
|
|
24
|
+
0,
|
|
25
|
+
0,
|
|
26
|
+
0,
|
|
27
|
+
0,
|
|
28
|
+
0,
|
|
29
|
+
4,
|
|
30
|
+
4,
|
|
31
|
+
6,
|
|
32
|
+
6,
|
|
33
|
+
0,
|
|
34
|
+
0,
|
|
35
|
+
7,
|
|
36
|
+
7,
|
|
37
|
+
4,
|
|
38
|
+
4,
|
|
39
|
+
0,
|
|
40
|
+
0,
|
|
41
|
+
4,
|
|
42
|
+
4,
|
|
43
|
+
0,
|
|
44
|
+
0
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Decode IA64 BCJ filtered data
|
|
48
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
49
|
+
*
|
|
50
|
+
* @param input - IA64 BCJ filtered data
|
|
51
|
+
* @param _properties - Unused for IA64 BCJ
|
|
52
|
+
* @param _unpackSize - Unused for IA64 BCJ
|
|
53
|
+
* @returns Unfiltered data
|
|
54
|
+
*/ export function decodeBcjIa64(input, _properties, _unpackSize) {
|
|
55
|
+
var output = bufferFrom(input); // Copy since we modify in place
|
|
56
|
+
var pos = 0;
|
|
57
|
+
// Process 16-byte aligned bundles
|
|
58
|
+
while(pos + 16 <= output.length){
|
|
59
|
+
// Get template (low 5 bits of first byte)
|
|
60
|
+
var template = output[pos] & 0x1f;
|
|
61
|
+
var mask = kBranchTable[template];
|
|
62
|
+
// Check each instruction slot (3 slots per bundle)
|
|
63
|
+
for(var slot = 0; slot < 3; slot++){
|
|
64
|
+
if ((mask & 1 << slot) === 0) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
// Calculate bit position for this slot
|
|
68
|
+
// Slot 0: bits 5-45, Slot 1: bits 46-86, Slot 2: bits 87-127
|
|
69
|
+
var bitPos = 5 + slot * 41;
|
|
70
|
+
var bytePos = bitPos >>> 3;
|
|
71
|
+
var bitOffset = bitPos & 7;
|
|
72
|
+
// Read 8 bytes to get the instruction (may span bytes)
|
|
73
|
+
// We need at least 6 bytes for a 41-bit instruction
|
|
74
|
+
if (pos + bytePos + 6 > output.length) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
// Extract instruction bytes
|
|
78
|
+
var instr0 = output[pos + bytePos];
|
|
79
|
+
var instr1 = output[pos + bytePos + 1];
|
|
80
|
+
var instr2 = output[pos + bytePos + 2];
|
|
81
|
+
var instr3 = output[pos + bytePos + 3];
|
|
82
|
+
var instr4 = output[pos + bytePos + 4];
|
|
83
|
+
var instr5 = output[pos + bytePos + 5];
|
|
84
|
+
// Build instruction value (we only need the immediate field)
|
|
85
|
+
// The immediate is in bits 13-32 of the instruction (20 bits)
|
|
86
|
+
// Plus bit 36 as the sign bit
|
|
87
|
+
// For decoding, we extract the address that was encoded and convert back
|
|
88
|
+
var instrLo = instr0 >>> bitOffset | instr1 << 8 - bitOffset | instr2 << 16 - bitOffset | instr3 << 24 - bitOffset;
|
|
89
|
+
var instrHi = instr4 >>> bitOffset | instr5 << 8 - bitOffset;
|
|
90
|
+
// Check opcode for branch (opcode 4 or 5 in bits 37-40)
|
|
91
|
+
var opcode = instrHi >>> 37 - 32 - bitOffset & 0xf;
|
|
92
|
+
if (opcode !== 4 && opcode !== 5) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
// Extract 21-bit immediate (bits 13-32 + sign bit 36)
|
|
96
|
+
var imm20 = instrLo >>> 13 & 0xfffff;
|
|
97
|
+
var sign = instrHi >>> 36 - 32 & 1;
|
|
98
|
+
// Combine into 21-bit signed value
|
|
99
|
+
var addr = imm20 | sign << 20;
|
|
100
|
+
if (sign) {
|
|
101
|
+
addr |= 0xffe00000; // Sign-extend
|
|
102
|
+
}
|
|
103
|
+
// Convert absolute to relative: subtract current position (in bundles)
|
|
104
|
+
var relAddr = addr - (pos >>> 4);
|
|
105
|
+
// Write back
|
|
106
|
+
var newImm20 = relAddr & 0xfffff;
|
|
107
|
+
var newSign = relAddr >>> 20 & 1;
|
|
108
|
+
// Clear old immediate and write new one
|
|
109
|
+
instrLo = instrLo & ~(0xfffff << 13) | newImm20 << 13;
|
|
110
|
+
instrHi = instrHi & ~(1 << 36 - 32) | newSign << 36 - 32;
|
|
111
|
+
// Write back bytes
|
|
112
|
+
output[pos + bytePos] = output[pos + bytePos] & (1 << bitOffset) - 1 | (instrLo & 0xff) << bitOffset;
|
|
113
|
+
output[pos + bytePos + 1] = instrLo >>> 8 - bitOffset & 0xff;
|
|
114
|
+
output[pos + bytePos + 2] = instrLo >>> 16 - bitOffset & 0xff;
|
|
115
|
+
output[pos + bytePos + 3] = instrLo >>> 24 - bitOffset & 0xff;
|
|
116
|
+
output[pos + bytePos + 4] = instrLo >>> 32 - bitOffset & (1 << bitOffset) - 1 | (instrHi & 0xff) << bitOffset;
|
|
117
|
+
output[pos + bytePos + 5] = output[pos + bytePos + 5] & ~((1 << bitOffset) - 1) | instrHi >>> 8 - bitOffset & (1 << bitOffset) - 1;
|
|
118
|
+
}
|
|
119
|
+
pos += 16;
|
|
120
|
+
}
|
|
121
|
+
return output;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Create an IA64 BCJ decoder Transform stream
|
|
125
|
+
*/ export function createBcjIa64Decoder(properties, unpackSize) {
|
|
126
|
+
return createBufferingDecoder(decodeBcjIa64, properties, unpackSize);
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjIa64.ts"],"sourcesContent":["// BCJ (IA64/Itanium) filter codec - converts IA64 branch instruction addresses\n// This filter makes IA64 executables more compressible by LZMA\n//\n// IA64 uses 128-bit instruction bundles with 3 instructions per bundle.\n// Branch instructions use 21-bit signed offsets (in bundles).\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n// IA64 branch instruction slot mask\n// Each bundle has a 5-bit template and 3 x 41-bit instruction slots\nvar kBranchTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 6, 6, 0, 0, 7, 7, 4, 4, 0, 0, 4, 4, 0, 0];\n\n/**\n * Decode IA64 BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * @param input - IA64 BCJ filtered data\n * @param _properties - Unused for IA64 BCJ\n * @param _unpackSize - Unused for IA64 BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjIa64(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n var output = bufferFrom(input); // Copy since we modify in place\n var pos = 0;\n\n // Process 16-byte aligned bundles\n while (pos + 16 <= output.length) {\n // Get template (low 5 bits of first byte)\n var template = output[pos] & 0x1f;\n var mask = kBranchTable[template];\n\n // Check each instruction slot (3 slots per bundle)\n for (var slot = 0; slot < 3; slot++) {\n if ((mask & (1 << slot)) === 0) {\n continue;\n }\n\n // Calculate bit position for this slot\n // Slot 0: bits 5-45, Slot 1: bits 46-86, Slot 2: bits 87-127\n var bitPos = 5 + slot * 41;\n var bytePos = bitPos >>> 3;\n var bitOffset = bitPos & 7;\n\n // Read 8 bytes to get the instruction (may span bytes)\n // We need at least 6 bytes for a 41-bit instruction\n if (pos + bytePos + 6 > output.length) {\n break;\n }\n\n // Extract instruction bytes\n var instr0 = output[pos + bytePos];\n var instr1 = output[pos + bytePos + 1];\n var instr2 = output[pos + bytePos + 2];\n var instr3 = output[pos + bytePos + 3];\n var instr4 = output[pos + bytePos + 4];\n var instr5 = output[pos + bytePos + 5];\n\n // Build instruction value (we only need the immediate field)\n // The immediate is in bits 13-32 of the instruction (20 bits)\n // Plus bit 36 as the sign bit\n\n // For decoding, we extract the address that was encoded and convert back\n var instrLo = (instr0 >>> bitOffset) | (instr1 << (8 - bitOffset)) | (instr2 << (16 - bitOffset)) | (instr3 << (24 - bitOffset));\n\n var instrHi = (instr4 >>> bitOffset) | (instr5 << (8 - bitOffset));\n\n // Check opcode for branch (opcode 4 or 5 in bits 37-40)\n var opcode = (instrHi >>> (37 - 32 - bitOffset)) & 0xf;\n if (opcode !== 4 && opcode !== 5) {\n continue;\n }\n\n // Extract 21-bit immediate (bits 13-32 + sign bit 36)\n var imm20 = (instrLo >>> 13) & 0xfffff;\n var sign = (instrHi >>> (36 - 32)) & 1;\n\n // Combine into 21-bit signed value\n var addr = imm20 | (sign << 20);\n if (sign) {\n addr |= 0xffe00000; // Sign-extend\n }\n\n // Convert absolute to relative: subtract current position (in bundles)\n var relAddr = addr - (pos >>> 4);\n\n // Write back\n var newImm20 = relAddr & 0xfffff;\n var newSign = (relAddr >>> 20) & 1;\n\n // Clear old immediate and write new one\n instrLo = (instrLo & ~(0xfffff << 13)) | (newImm20 << 13);\n instrHi = (instrHi & ~(1 << (36 - 32))) | (newSign << (36 - 32));\n\n // Write back bytes\n output[pos + bytePos] = (output[pos + bytePos] & ((1 << bitOffset) - 1)) | ((instrLo & 0xff) << bitOffset);\n output[pos + bytePos + 1] = (instrLo >>> (8 - bitOffset)) & 0xff;\n output[pos + bytePos + 2] = (instrLo >>> (16 - bitOffset)) & 0xff;\n output[pos + bytePos + 3] = (instrLo >>> (24 - bitOffset)) & 0xff;\n output[pos + bytePos + 4] = ((instrLo >>> (32 - bitOffset)) & ((1 << bitOffset) - 1)) | ((instrHi & 0xff) << bitOffset);\n output[pos + bytePos + 5] = (output[pos + bytePos + 5] & ~((1 << bitOffset) - 1)) | ((instrHi >>> (8 - bitOffset)) & ((1 << bitOffset) - 1));\n }\n\n pos += 16;\n }\n\n return output;\n}\n\n/**\n * Create an IA64 BCJ decoder Transform stream\n */\nexport function createBcjIa64Decoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjIa64, properties, unpackSize);\n}\n"],"names":["bufferFrom","createBufferingDecoder","kBranchTable","decodeBcjIa64","input","_properties","_unpackSize","output","pos","length","template","mask","slot","bitPos","bytePos","bitOffset","instr0","instr1","instr2","instr3","instr4","instr5","instrLo","instrHi","opcode","imm20","sign","addr","relAddr","newImm20","newSign","createBcjIa64Decoder","properties","unpackSize"],"mappings":"AAAA,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,8DAA8D;AAC9D,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE,oCAAoC;AACpC,oEAAoE;AACpE,IAAIC,eAAe;IAAC;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;IAAG;CAAE;AAEnH;;;;;;;;CAQC,GACD,OAAO,SAASC,cAAcC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACrF,IAAIC,SAASP,WAAWI,QAAQ,gCAAgC;IAChE,IAAII,MAAM;IAEV,kCAAkC;IAClC,MAAOA,MAAM,MAAMD,OAAOE,MAAM,CAAE;QAChC,0CAA0C;QAC1C,IAAIC,WAAWH,MAAM,CAACC,IAAI,GAAG;QAC7B,IAAIG,OAAOT,YAAY,CAACQ,SAAS;QAEjC,mDAAmD;QACnD,IAAK,IAAIE,OAAO,GAAGA,OAAO,GAAGA,OAAQ;YACnC,IAAI,AAACD,CAAAA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AAM;YAEjC,wCAAwC;YACxCN,UAAU,AAACA,UAAU,CAAE,CAAA,WAAW,EAAC,IAAOO,YAAY;YACtDN,UAAU,AAACA,UAAU,CAAE,CAAA,KAAM,KAAK,EAAE,IAAOO,WAAY,KAAK;YAE5D,mBAAmB;YACnBvB,MAAM,CAACC,MAAMM,QAAQ,GAAG,AAACP,MAAM,CAACC,MAAMM,QAAQ,GAAI,AAAC,CAAA,KAAKC,SAAQ,IAAK,IAAO,AAACO,CAAAA,UAAU,IAAG,KAAMP;YAChGR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACQ,YAAa,IAAIP,YAAc;YAC5DR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACQ,YAAa,KAAKP,YAAc;YAC7DR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACQ,YAAa,KAAKP,YAAc;YAC7DR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAAEQ,YAAa,KAAKP,YAAe,AAAC,CAAA,KAAKA,SAAQ,IAAK,IAAO,AAACQ,CAAAA,UAAU,IAAG,KAAMR;YAC7GR,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,AAACP,MAAM,CAACC,MAAMM,UAAU,EAAE,GAAG,CAAE,CAAA,AAAC,CAAA,KAAKC,SAAQ,IAAK,CAAA,IAAO,AAACQ,YAAa,IAAIR,YAAe,AAAC,CAAA,KAAKA,SAAQ,IAAK;QAC3I;QAEAP,OAAO;IACT;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASwB,qBAAqBC,UAAmB,EAAEC,UAAmB;IAC3E,OAAOhC,uBAAuBE,eAAe6B,YAAYC;AAC3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Transform } from 'readable-stream';
|
|
2
|
+
/**
|
|
3
|
+
* Decode PowerPC BCJ filtered data
|
|
4
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
5
|
+
*
|
|
6
|
+
* PowerPC B/BL instruction format (big-endian):
|
|
7
|
+
* - 4 bytes aligned
|
|
8
|
+
* - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)
|
|
9
|
+
* - Bits 6-29 are 24-bit signed offset (in words)
|
|
10
|
+
*
|
|
11
|
+
* @param input - PowerPC BCJ filtered data
|
|
12
|
+
* @param _properties - Unused for PowerPC BCJ
|
|
13
|
+
* @param _unpackSize - Unused for PowerPC BCJ
|
|
14
|
+
* @returns Unfiltered data
|
|
15
|
+
*/
|
|
16
|
+
export declare function decodeBcjPpc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer;
|
|
17
|
+
/**
|
|
18
|
+
* Create a PowerPC BCJ decoder Transform stream
|
|
19
|
+
*/
|
|
20
|
+
export declare function createBcjPpcDecoder(properties?: Buffer, unpackSize?: number): Transform;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// BCJ (PowerPC) filter codec - converts PowerPC branch instruction addresses
|
|
2
|
+
// This filter makes PowerPC executables more compressible by LZMA
|
|
3
|
+
//
|
|
4
|
+
// PowerPC is big-endian. Branch instructions use 26-bit signed offsets.
|
|
5
|
+
//
|
|
6
|
+
// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
|
|
7
|
+
import { bufferFrom } from 'extract-base-iterator';
|
|
8
|
+
import createBufferingDecoder from './createBufferingDecoder.js';
|
|
9
|
+
/**
|
|
10
|
+
* Decode PowerPC BCJ filtered data
|
|
11
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
12
|
+
*
|
|
13
|
+
* PowerPC B/BL instruction format (big-endian):
|
|
14
|
+
* - 4 bytes aligned
|
|
15
|
+
* - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)
|
|
16
|
+
* - Bits 6-29 are 24-bit signed offset (in words)
|
|
17
|
+
*
|
|
18
|
+
* @param input - PowerPC BCJ filtered data
|
|
19
|
+
* @param _properties - Unused for PowerPC BCJ
|
|
20
|
+
* @param _unpackSize - Unused for PowerPC BCJ
|
|
21
|
+
* @returns Unfiltered data
|
|
22
|
+
*/ export function decodeBcjPpc(input, _properties, _unpackSize) {
|
|
23
|
+
var output = bufferFrom(input); // Copy since we modify in place
|
|
24
|
+
var pos = 0;
|
|
25
|
+
// Process 4-byte aligned positions
|
|
26
|
+
while(pos + 4 <= output.length){
|
|
27
|
+
// Read 32-bit value (big-endian)
|
|
28
|
+
var instr = output[pos] << 24 | output[pos + 1] << 16 | output[pos + 2] << 8 | output[pos + 3];
|
|
29
|
+
// Check for B/BL instruction: (instr & 0xFC000003) === 0x48000001
|
|
30
|
+
if ((instr & 0xfc000003) === 0x48000001) {
|
|
31
|
+
// Extract 26-bit offset (bits 2-27, the LI field)
|
|
32
|
+
var addr = instr & 0x03fffffc;
|
|
33
|
+
// Sign-extend 26-bit to 32-bit
|
|
34
|
+
if (addr & 0x02000000) {
|
|
35
|
+
addr |= 0xfc000000;
|
|
36
|
+
}
|
|
37
|
+
// Convert absolute to relative: subtract current position
|
|
38
|
+
var relAddr = addr - pos;
|
|
39
|
+
// Clear old offset and write new one
|
|
40
|
+
instr = instr & 0xfc000003 | relAddr & 0x03fffffc;
|
|
41
|
+
// Write back (big-endian)
|
|
42
|
+
output[pos] = instr >>> 24 & 0xff;
|
|
43
|
+
output[pos + 1] = instr >>> 16 & 0xff;
|
|
44
|
+
output[pos + 2] = instr >>> 8 & 0xff;
|
|
45
|
+
output[pos + 3] = instr & 0xff;
|
|
46
|
+
}
|
|
47
|
+
pos += 4;
|
|
48
|
+
}
|
|
49
|
+
return output;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a PowerPC BCJ decoder Transform stream
|
|
53
|
+
*/ export function createBcjPpcDecoder(properties, unpackSize) {
|
|
54
|
+
return createBufferingDecoder(decodeBcjPpc, properties, unpackSize);
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjPpc.ts"],"sourcesContent":["// BCJ (PowerPC) filter codec - converts PowerPC branch instruction addresses\n// This filter makes PowerPC executables more compressible by LZMA\n//\n// PowerPC is big-endian. Branch instructions use 26-bit signed offsets.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode PowerPC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * PowerPC B/BL instruction format (big-endian):\n * - 4 bytes aligned\n * - Opcode 0x48 in high byte with AA=0, LK=1 (0x48000001 mask 0xFC000003)\n * - Bits 6-29 are 24-bit signed offset (in words)\n *\n * @param input - PowerPC BCJ filtered data\n * @param _properties - Unused for PowerPC BCJ\n * @param _unpackSize - Unused for PowerPC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjPpc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n var output = bufferFrom(input); // Copy since we modify in place\n var pos = 0;\n\n // Process 4-byte aligned positions\n while (pos + 4 <= output.length) {\n // Read 32-bit value (big-endian)\n var instr = (output[pos] << 24) | (output[pos + 1] << 16) | (output[pos + 2] << 8) | output[pos + 3];\n\n // Check for B/BL instruction: (instr & 0xFC000003) === 0x48000001\n if ((instr & 0xfc000003) === 0x48000001) {\n // Extract 26-bit offset (bits 2-27, the LI field)\n var addr = instr & 0x03fffffc;\n\n // Sign-extend 26-bit to 32-bit\n if (addr & 0x02000000) {\n addr |= 0xfc000000;\n }\n\n // Convert absolute to relative: subtract current position\n var relAddr = addr - pos;\n\n // Clear old offset and write new one\n instr = (instr & 0xfc000003) | (relAddr & 0x03fffffc);\n\n // Write back (big-endian)\n output[pos] = (instr >>> 24) & 0xff;\n output[pos + 1] = (instr >>> 16) & 0xff;\n output[pos + 2] = (instr >>> 8) & 0xff;\n output[pos + 3] = instr & 0xff;\n }\n pos += 4;\n }\n\n return output;\n}\n\n/**\n * Create a PowerPC BCJ decoder Transform stream\n */\nexport function createBcjPpcDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjPpc, properties, unpackSize);\n}\n"],"names":["bufferFrom","createBufferingDecoder","decodeBcjPpc","input","_properties","_unpackSize","output","pos","length","instr","addr","relAddr","createBcjPpcDecoder","properties","unpackSize"],"mappings":"AAAA,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,wEAAwE;AACxE,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,aAAaC,KAAa,EAAEC,WAAoB,EAAEC,WAAoB;IACpF,IAAIC,SAASN,WAAWG,QAAQ,gCAAgC;IAChE,IAAII,MAAM;IAEV,mCAAmC;IACnC,MAAOA,MAAM,KAAKD,OAAOE,MAAM,CAAE;QAC/B,iCAAiC;QACjC,IAAIC,QAAQ,AAACH,MAAM,CAACC,IAAI,IAAI,KAAOD,MAAM,CAACC,MAAM,EAAE,IAAI,KAAOD,MAAM,CAACC,MAAM,EAAE,IAAI,IAAKD,MAAM,CAACC,MAAM,EAAE;QAEpG,kEAAkE;QAClE,IAAI,AAACE,CAAAA,QAAQ,UAAS,MAAO,YAAY;YACvC,kDAAkD;YAClD,IAAIC,OAAOD,QAAQ;YAEnB,+BAA+B;YAC/B,IAAIC,OAAO,YAAY;gBACrBA,QAAQ;YACV;YAEA,0DAA0D;YAC1D,IAAIC,UAAUD,OAAOH;YAErB,qCAAqC;YACrCE,QAAQ,AAACA,QAAQ,aAAeE,UAAU;YAE1C,0BAA0B;YAC1BL,MAAM,CAACC,IAAI,GAAG,AAACE,UAAU,KAAM;YAC/BH,MAAM,CAACC,MAAM,EAAE,GAAG,AAACE,UAAU,KAAM;YACnCH,MAAM,CAACC,MAAM,EAAE,GAAG,AAACE,UAAU,IAAK;YAClCH,MAAM,CAACC,MAAM,EAAE,GAAGE,QAAQ;QAC5B;QACAF,OAAO;IACT;IAEA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASM,oBAAoBC,UAAmB,EAAEC,UAAmB;IAC1E,OAAOb,uBAAuBC,cAAcW,YAAYC;AAC1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Transform } from 'readable-stream';
|
|
2
|
+
/**
|
|
3
|
+
* Decode SPARC BCJ filtered data
|
|
4
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
5
|
+
*
|
|
6
|
+
* SPARC CALL instruction matching (big-endian):
|
|
7
|
+
* - First byte 0x40 and (second byte & 0xC0) == 0x00, OR
|
|
8
|
+
* - First byte 0x7F and (second byte & 0xC0) == 0xC0
|
|
9
|
+
*
|
|
10
|
+
* @param input - SPARC BCJ filtered data
|
|
11
|
+
* @param _properties - Unused for SPARC BCJ
|
|
12
|
+
* @param _unpackSize - Unused for SPARC BCJ
|
|
13
|
+
* @returns Unfiltered data
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodeBcjSparc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer;
|
|
16
|
+
/**
|
|
17
|
+
* Create a SPARC BCJ decoder Transform stream
|
|
18
|
+
*/
|
|
19
|
+
export declare function createBcjSparcDecoder(properties?: Buffer, unpackSize?: number): Transform;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// BCJ (SPARC) filter codec - converts SPARC branch instruction addresses
|
|
2
|
+
// This filter makes SPARC executables more compressible by LZMA
|
|
3
|
+
//
|
|
4
|
+
// SPARC is big-endian. CALL instructions use 30-bit signed offsets.
|
|
5
|
+
// The filter only transforms CALL instructions with specific byte patterns.
|
|
6
|
+
//
|
|
7
|
+
// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c
|
|
8
|
+
import { bufferFrom } from 'extract-base-iterator';
|
|
9
|
+
import createBufferingDecoder from './createBufferingDecoder.js';
|
|
10
|
+
/**
|
|
11
|
+
* Decode SPARC BCJ filtered data
|
|
12
|
+
* Reverses the BCJ transformation by converting absolute addresses back to relative
|
|
13
|
+
*
|
|
14
|
+
* SPARC CALL instruction matching (big-endian):
|
|
15
|
+
* - First byte 0x40 and (second byte & 0xC0) == 0x00, OR
|
|
16
|
+
* - First byte 0x7F and (second byte & 0xC0) == 0xC0
|
|
17
|
+
*
|
|
18
|
+
* @param input - SPARC BCJ filtered data
|
|
19
|
+
* @param _properties - Unused for SPARC BCJ
|
|
20
|
+
* @param _unpackSize - Unused for SPARC BCJ
|
|
21
|
+
* @returns Unfiltered data
|
|
22
|
+
*/ export function decodeBcjSparc(input, _properties, _unpackSize) {
|
|
23
|
+
var output = bufferFrom(input); // Copy since we modify in place
|
|
24
|
+
var pos = 0;
|
|
25
|
+
// Process 4-byte aligned positions
|
|
26
|
+
while(pos + 4 <= output.length){
|
|
27
|
+
var b0 = output[pos];
|
|
28
|
+
var b1 = output[pos + 1];
|
|
29
|
+
// Check for CALL instruction with specific byte patterns:
|
|
30
|
+
// (b0 == 0x40 && (b1 & 0xC0) == 0x00) || (b0 == 0x7F && (b1 & 0xC0) == 0xC0)
|
|
31
|
+
if (b0 === 0x40 && (b1 & 0xc0) === 0x00 || b0 === 0x7f && (b1 & 0xc0) === 0xc0) {
|
|
32
|
+
// Read 32-bit value (big-endian)
|
|
33
|
+
var src = b0 << 24 | b1 << 16 | output[pos + 2] << 8 | output[pos + 3];
|
|
34
|
+
// Shift left by 2 (multiply by 4 for word addressing)
|
|
35
|
+
src <<= 2;
|
|
36
|
+
// Decoding: subtract position
|
|
37
|
+
var dest = src - pos;
|
|
38
|
+
// Shift right by 2
|
|
39
|
+
dest >>>= 2;
|
|
40
|
+
// Reconstruct with sign extension and opcode
|
|
41
|
+
// (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000
|
|
42
|
+
var signBit = dest >>> 22 & 1;
|
|
43
|
+
var signExtend = signBit ? 0x3fc00000 : 0;
|
|
44
|
+
dest = signExtend | dest & 0x3fffff | 0x40000000;
|
|
45
|
+
// Write back (big-endian)
|
|
46
|
+
output[pos] = dest >>> 24 & 0xff;
|
|
47
|
+
output[pos + 1] = dest >>> 16 & 0xff;
|
|
48
|
+
output[pos + 2] = dest >>> 8 & 0xff;
|
|
49
|
+
output[pos + 3] = dest & 0xff;
|
|
50
|
+
}
|
|
51
|
+
pos += 4;
|
|
52
|
+
}
|
|
53
|
+
return output;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a SPARC BCJ decoder Transform stream
|
|
57
|
+
*/ export function createBcjSparcDecoder(properties, unpackSize) {
|
|
58
|
+
return createBufferingDecoder(decodeBcjSparc, properties, unpackSize);
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/BcjSparc.ts"],"sourcesContent":["// BCJ (SPARC) filter codec - converts SPARC branch instruction addresses\n// This filter makes SPARC executables more compressible by LZMA\n//\n// SPARC is big-endian. CALL instructions use 30-bit signed offsets.\n// The filter only transforms CALL instructions with specific byte patterns.\n//\n// Reference: https://github.com/kornelski/7z/blob/main/C/Bra.c\n\nimport { bufferFrom } from 'extract-base-iterator';\nimport type { Transform } from 'readable-stream';\nimport createBufferingDecoder from './createBufferingDecoder.ts';\n\n/**\n * Decode SPARC BCJ filtered data\n * Reverses the BCJ transformation by converting absolute addresses back to relative\n *\n * SPARC CALL instruction matching (big-endian):\n * - First byte 0x40 and (second byte & 0xC0) == 0x00, OR\n * - First byte 0x7F and (second byte & 0xC0) == 0xC0\n *\n * @param input - SPARC BCJ filtered data\n * @param _properties - Unused for SPARC BCJ\n * @param _unpackSize - Unused for SPARC BCJ\n * @returns Unfiltered data\n */\nexport function decodeBcjSparc(input: Buffer, _properties?: Buffer, _unpackSize?: number): Buffer {\n var output = bufferFrom(input); // Copy since we modify in place\n var pos = 0;\n\n // Process 4-byte aligned positions\n while (pos + 4 <= output.length) {\n var b0 = output[pos];\n var b1 = output[pos + 1];\n\n // Check for CALL instruction with specific byte patterns:\n // (b0 == 0x40 && (b1 & 0xC0) == 0x00) || (b0 == 0x7F && (b1 & 0xC0) == 0xC0)\n if ((b0 === 0x40 && (b1 & 0xc0) === 0x00) || (b0 === 0x7f && (b1 & 0xc0) === 0xc0)) {\n // Read 32-bit value (big-endian)\n var src = (b0 << 24) | (b1 << 16) | (output[pos + 2] << 8) | output[pos + 3];\n\n // Shift left by 2 (multiply by 4 for word addressing)\n src <<= 2;\n\n // Decoding: subtract position\n var dest = src - pos;\n\n // Shift right by 2\n dest >>>= 2;\n\n // Reconstruct with sign extension and opcode\n // (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000\n var signBit = (dest >>> 22) & 1;\n var signExtend = signBit ? 0x3fc00000 : 0;\n dest = signExtend | (dest & 0x3fffff) | 0x40000000;\n\n // Write back (big-endian)\n output[pos] = (dest >>> 24) & 0xff;\n output[pos + 1] = (dest >>> 16) & 0xff;\n output[pos + 2] = (dest >>> 8) & 0xff;\n output[pos + 3] = dest & 0xff;\n }\n\n pos += 4;\n }\n\n return output;\n}\n\n/**\n * Create a SPARC BCJ decoder Transform stream\n */\nexport function createBcjSparcDecoder(properties?: Buffer, unpackSize?: number): Transform {\n return createBufferingDecoder(decodeBcjSparc, properties, unpackSize);\n}\n"],"names":["bufferFrom","createBufferingDecoder","decodeBcjSparc","input","_properties","_unpackSize","output","pos","length","b0","b1","src","dest","signBit","signExtend","createBcjSparcDecoder","properties","unpackSize"],"mappings":"AAAA,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,EAAE;AACF,+DAA+D;AAE/D,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,OAAOC,4BAA4B,8BAA8B;AAEjE;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,eAAe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Password, setPassword } from './Aes.js';
|
|
5
5
|
import { createBcjDecoder, decodeBcj } from './Bcj.js';
|
|
6
6
|
import { createBcj2Decoder, decodeBcj2, decodeBcj2Multi } from './Bcj2.js';
|
|
7
|
+
import { createBcjArmDecoder, decodeBcjArm } from './BcjArm.js';
|
|
8
|
+
import { createBcjArm64Decoder, decodeBcjArm64 } from './BcjArm64.js';
|
|
9
|
+
import { createBcjArmtDecoder, decodeBcjArmt } from './BcjArmt.js';
|
|
10
|
+
import { createBcjIa64Decoder, decodeBcjIa64 } from './BcjIa64.js';
|
|
11
|
+
import { createBcjPpcDecoder, decodeBcjPpc } from './BcjPpc.js';
|
|
12
|
+
import { createBcjSparcDecoder, decodeBcjSparc } from './BcjSparc.js';
|
|
7
13
|
import { createBzip2Decoder, decodeBzip2 } from './BZip2.js';
|
|
8
14
|
import { createCopyDecoder, decodeCopy } from './Copy.js';
|
|
9
15
|
import { createDeflateDecoder, decodeDeflate } from './Deflate.js';
|
|
@@ -60,7 +66,14 @@ var codecs = {};
|
|
|
60
66
|
if (codecIdEquals(id, CodecId.LZMA)) return 'LZMA';
|
|
61
67
|
if (codecIdEquals(id, CodecId.LZMA2)) return 'LZMA2';
|
|
62
68
|
if (codecIdEquals(id, CodecId.BCJ_X86)) return 'BCJ (x86)';
|
|
69
|
+
if (codecIdEquals(id, CodecId.BCJ_ARM)) return 'BCJ (ARM)';
|
|
70
|
+
if (codecIdEquals(id, CodecId.BCJ_ARMT)) return 'BCJ (ARM Thumb)';
|
|
71
|
+
if (codecIdEquals(id, CodecId.BCJ_ARM64)) return 'BCJ (ARM64)';
|
|
72
|
+
if (codecIdEquals(id, CodecId.BCJ_PPC)) return 'BCJ (PowerPC)';
|
|
73
|
+
if (codecIdEquals(id, CodecId.BCJ_IA64)) return 'BCJ (IA64)';
|
|
74
|
+
if (codecIdEquals(id, CodecId.BCJ_SPARC)) return 'BCJ (SPARC)';
|
|
63
75
|
if (codecIdEquals(id, CodecId.BCJ2)) return 'BCJ2';
|
|
76
|
+
if (codecIdEquals(id, CodecId.PPMD)) return 'PPMd';
|
|
64
77
|
if (codecIdEquals(id, CodecId.DELTA)) return 'Delta';
|
|
65
78
|
if (codecIdEquals(id, CodecId.DEFLATE)) return 'Deflate';
|
|
66
79
|
if (codecIdEquals(id, CodecId.BZIP2)) return 'BZip2';
|
|
@@ -95,6 +108,36 @@ registerCodec(CodecId.BCJ_X86, {
|
|
|
95
108
|
decode: decodeBcj,
|
|
96
109
|
createDecoder: createBcjDecoder
|
|
97
110
|
});
|
|
111
|
+
// BCJ (ARM) filter
|
|
112
|
+
registerCodec(CodecId.BCJ_ARM, {
|
|
113
|
+
decode: decodeBcjArm,
|
|
114
|
+
createDecoder: createBcjArmDecoder
|
|
115
|
+
});
|
|
116
|
+
// BCJ (ARM Thumb) filter
|
|
117
|
+
registerCodec(CodecId.BCJ_ARMT, {
|
|
118
|
+
decode: decodeBcjArmt,
|
|
119
|
+
createDecoder: createBcjArmtDecoder
|
|
120
|
+
});
|
|
121
|
+
// BCJ (ARM64) filter
|
|
122
|
+
registerCodec(CodecId.BCJ_ARM64, {
|
|
123
|
+
decode: decodeBcjArm64,
|
|
124
|
+
createDecoder: createBcjArm64Decoder
|
|
125
|
+
});
|
|
126
|
+
// BCJ (PowerPC) filter
|
|
127
|
+
registerCodec(CodecId.BCJ_PPC, {
|
|
128
|
+
decode: decodeBcjPpc,
|
|
129
|
+
createDecoder: createBcjPpcDecoder
|
|
130
|
+
});
|
|
131
|
+
// BCJ (IA64) filter
|
|
132
|
+
registerCodec(CodecId.BCJ_IA64, {
|
|
133
|
+
decode: decodeBcjIa64,
|
|
134
|
+
createDecoder: createBcjIa64Decoder
|
|
135
|
+
});
|
|
136
|
+
// BCJ (SPARC) filter
|
|
137
|
+
registerCodec(CodecId.BCJ_SPARC, {
|
|
138
|
+
decode: decodeBcjSparc,
|
|
139
|
+
createDecoder: createBcjSparcDecoder
|
|
140
|
+
});
|
|
98
141
|
// Delta filter
|
|
99
142
|
registerCodec(CodecId.DELTA, {
|
|
100
143
|
decode: decodeDelta,
|
|
@@ -120,4 +163,4 @@ registerCodec(CodecId.AES, {
|
|
|
120
163
|
registerCodec(CodecId.BCJ2, {
|
|
121
164
|
decode: decodeBcj2,
|
|
122
165
|
createDecoder: createBcj2Decoder
|
|
123
|
-
});
|
|
166
|
+
}); // Note: PPMd codec is not implemented. See FUTURE_ENHANCEMENTS.md
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/index.ts"],"sourcesContent":["// Codec registry for 7z decompression\n// Each codec provides a decode function and optionally a streaming decoder\n\nimport type { Transform } from 'readable-stream';\nimport { CodecId, createCodedError, ErrorCode } from '../constants.ts';\nimport { createAesDecoder, decodeAes, getPassword, setPassword } from './Aes.ts';\nimport { createBcjDecoder, decodeBcj } from './Bcj.ts';\nimport { createBcj2Decoder, decodeBcj2, decodeBcj2Multi } from './Bcj2.ts';\nimport { createBzip2Decoder, decodeBzip2 } from './BZip2.ts';\nimport { createCopyDecoder, decodeCopy } from './Copy.ts';\nimport { createDeflateDecoder, decodeDeflate } from './Deflate.ts';\nimport { createDeltaDecoder, decodeDelta } from './Delta.ts';\nimport { createLzmaDecoder, decodeLzma } from './Lzma.ts';\nimport { createLzma2Decoder, decodeLzma2 } from './Lzma2.ts';\n\n// Re-export password functions for API access\nexport { getPassword, setPassword };\n\nexport interface Codec {\n decode: (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n createDecoder: (properties?: Buffer, unpackSize?: number) => Transform;\n}\n\n// Registry of supported codecs\nvar codecs: { [key: string]: Codec } = {};\n\n/**\n * Convert codec ID bytes to a string key\n */\nfunction codecIdToKey(id: number[]): string {\n var parts: string[] = [];\n for (var i = 0; i < id.length; i++) {\n parts.push(id[i].toString(16).toUpperCase());\n }\n return parts.join('-');\n}\n\n/**\n * Check if two codec IDs match\n */\nfunction codecIdEquals(a: number[], b: number[]): boolean {\n if (a.length !== b.length) return false;\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Register a codec\n */\nexport function registerCodec(id: number[], codec: Codec): void {\n codecs[codecIdToKey(id)] = codec;\n}\n\n/**\n * Get a codec by ID\n * @throws Error if codec is not supported\n */\nexport function getCodec(id: number[]): Codec {\n var key = codecIdToKey(id);\n var codec = codecs[key];\n if (!codec) {\n throw createCodedError(`Unsupported codec: ${key}`, ErrorCode.UNSUPPORTED_CODEC);\n }\n return codec;\n}\n\n/**\n * Check if a codec is supported\n */\nexport function isCodecSupported(id: number[]): boolean {\n return codecs[codecIdToKey(id)] !== undefined;\n}\n\n/**\n * Get human-readable codec name\n */\nexport function getCodecName(id: number[]): string {\n if (codecIdEquals(id, CodecId.COPY)) return 'Copy';\n if (codecIdEquals(id, CodecId.LZMA)) return 'LZMA';\n if (codecIdEquals(id, CodecId.LZMA2)) return 'LZMA2';\n if (codecIdEquals(id, CodecId.BCJ_X86)) return 'BCJ (x86)';\n if (codecIdEquals(id, CodecId.BCJ2)) return 'BCJ2';\n if (codecIdEquals(id, CodecId.DELTA)) return 'Delta';\n if (codecIdEquals(id, CodecId.DEFLATE)) return 'Deflate';\n if (codecIdEquals(id, CodecId.BZIP2)) return 'BZip2';\n if (codecIdEquals(id, CodecId.AES)) return 'AES-256';\n return `Unknown (${codecIdToKey(id)})`;\n}\n\n/**\n * Check if a codec ID matches BCJ2\n */\nexport function isBcj2Codec(id: number[]): boolean {\n return codecIdEquals(id, CodecId.BCJ2);\n}\n\n// Re-export BCJ2 multi-stream decoder for special handling\nexport { decodeBcj2Multi };\n\n// Register built-in codecs\n\n// Copy codec (no compression)\nregisterCodec(CodecId.COPY, {\n decode: decodeCopy,\n createDecoder: createCopyDecoder,\n});\n\n// LZMA codec\nregisterCodec(CodecId.LZMA, {\n decode: decodeLzma,\n createDecoder: createLzmaDecoder,\n});\n\n// LZMA2 codec\nregisterCodec(CodecId.LZMA2, {\n decode: decodeLzma2,\n createDecoder: createLzma2Decoder,\n});\n\n// BCJ (x86) filter\nregisterCodec(CodecId.BCJ_X86, {\n decode: decodeBcj,\n createDecoder: createBcjDecoder,\n});\n\n// Delta filter\nregisterCodec(CodecId.DELTA, {\n decode: decodeDelta,\n createDecoder: createDeltaDecoder,\n});\n\n// Deflate codec\nregisterCodec(CodecId.DEFLATE, {\n decode: decodeDeflate,\n createDecoder: createDeflateDecoder,\n});\n\n// BZip2 codec\nregisterCodec(CodecId.BZIP2, {\n decode: decodeBzip2,\n createDecoder: createBzip2Decoder,\n});\n\n// AES-256-CBC codec (encryption)\nregisterCodec(CodecId.AES, {\n decode: decodeAes,\n createDecoder: createAesDecoder,\n});\n\n// BCJ2 (x86-64) filter - multi-stream\n// Note: BCJ2 requires special handling in SevenZipParser due to 4-stream architecture\nregisterCodec(CodecId.BCJ2, {\n decode: decodeBcj2,\n createDecoder: createBcj2Decoder,\n});\n"],"names":["CodecId","createCodedError","ErrorCode","createAesDecoder","decodeAes","getPassword","setPassword","createBcjDecoder","decodeBcj","createBcj2Decoder","decodeBcj2","decodeBcj2Multi","createBzip2Decoder","decodeBzip2","createCopyDecoder","decodeCopy","createDeflateDecoder","decodeDeflate","createDeltaDecoder","decodeDelta","createLzmaDecoder","decodeLzma","createLzma2Decoder","decodeLzma2","codecs","codecIdToKey","id","parts","i","length","push","toString","toUpperCase","join","codecIdEquals","a","b","registerCodec","codec","getCodec","key","UNSUPPORTED_CODEC","isCodecSupported","undefined","getCodecName","COPY","LZMA","LZMA2","BCJ_X86","BCJ2","DELTA","DEFLATE","BZIP2","AES","isBcj2Codec","decode","createDecoder"],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;AAG3E,SAASA,OAAO,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,kBAAkB;AACvE,SAASC,gBAAgB,EAAEC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ,WAAW;AACjF,SAASC,gBAAgB,EAAEC,SAAS,QAAQ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BAAmB;AACnBe,cAAcrC,QAAQgD,OAAO,EAAE;IAC7BO,QAAQ/C;IACRgD,eAAejD;AACjB;AAEA,eAAe;AACf8B,cAAcrC,QAAQkD,KAAK,EAAE;IAC3BK,QAAQpC;IACRqC,eAAetC;AACjB;AAEA,gBAAgB;AAChBmB,cAAcrC,QAAQmD,OAAO,EAAE;IAC7BI,QAAQtC;IACRuC,eAAexC;AACjB;AAEA,cAAc;AACdqB,cAAcrC,QAAQoD,KAAK,EAAE;IAC3BG,QAAQ1C;IACR2C,eAAe5C;AACjB;AAEA,iCAAiC;AACjCyB,cAAcrC,QAAQqD,GAAG,EAAE;IACzBE,QAAQnD;IACRoD,eAAerD;AACjB;AAEA,sCAAsC;AACtC,sFAAsF;AACtFkC,cAAcrC,QAAQiD,IAAI,EAAE;IAC1BM,QAAQ7C;IACR8C,eAAe/C;AACjB"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/7z-iterator/src/sevenz/codecs/index.ts"],"sourcesContent":["// Codec registry for 7z decompression\n// Each codec provides a decode function and optionally a streaming decoder\n\nimport type { Transform } from 'readable-stream';\nimport { CodecId, createCodedError, ErrorCode } from '../constants.ts';\nimport { createAesDecoder, decodeAes, getPassword, setPassword } from './Aes.ts';\nimport { createBcjDecoder, decodeBcj } from './Bcj.ts';\nimport { createBcj2Decoder, decodeBcj2, decodeBcj2Multi } from './Bcj2.ts';\nimport { createBcjArmDecoder, decodeBcjArm } from './BcjArm.ts';\nimport { createBcjArm64Decoder, decodeBcjArm64 } from './BcjArm64.ts';\nimport { createBcjArmtDecoder, decodeBcjArmt } from './BcjArmt.ts';\nimport { createBcjIa64Decoder, decodeBcjIa64 } from './BcjIa64.ts';\nimport { createBcjPpcDecoder, decodeBcjPpc } from './BcjPpc.ts';\nimport { createBcjSparcDecoder, decodeBcjSparc } from './BcjSparc.ts';\nimport { createBzip2Decoder, decodeBzip2 } from './BZip2.ts';\nimport { createCopyDecoder, decodeCopy } from './Copy.ts';\nimport { createDeflateDecoder, decodeDeflate } from './Deflate.ts';\nimport { createDeltaDecoder, decodeDelta } from './Delta.ts';\nimport { createLzmaDecoder, decodeLzma } from './Lzma.ts';\nimport { createLzma2Decoder, decodeLzma2 } from './Lzma2.ts';\n\n// Re-export password functions for API access\nexport { getPassword, setPassword };\n\nexport interface Codec {\n decode: (input: Buffer, properties?: Buffer, unpackSize?: number) => Buffer;\n createDecoder: (properties?: Buffer, unpackSize?: number) => Transform;\n}\n\n// Registry of supported codecs\nvar codecs: { [key: string]: Codec } = {};\n\n/**\n * Convert codec ID bytes to a string key\n */\nfunction codecIdToKey(id: number[]): string {\n var parts: string[] = [];\n for (var i = 0; i < id.length; i++) {\n parts.push(id[i].toString(16).toUpperCase());\n }\n return parts.join('-');\n}\n\n/**\n * Check if two codec IDs match\n */\nfunction codecIdEquals(a: number[], b: number[]): boolean {\n if (a.length !== b.length) return false;\n for (var i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\n/**\n * Register a codec\n */\nexport function registerCodec(id: number[], codec: Codec): void {\n codecs[codecIdToKey(id)] = codec;\n}\n\n/**\n * Get a codec by ID\n * @throws Error if codec is not supported\n */\nexport function getCodec(id: number[]): Codec {\n var key = codecIdToKey(id);\n var codec = codecs[key];\n if (!codec) {\n throw createCodedError(`Unsupported codec: ${key}`, ErrorCode.UNSUPPORTED_CODEC);\n }\n return codec;\n}\n\n/**\n * Check if a codec is supported\n */\nexport function isCodecSupported(id: number[]): boolean {\n return codecs[codecIdToKey(id)] !== undefined;\n}\n\n/**\n * Get human-readable codec name\n */\nexport function getCodecName(id: number[]): string {\n if (codecIdEquals(id, CodecId.COPY)) return 'Copy';\n if (codecIdEquals(id, CodecId.LZMA)) return 'LZMA';\n if (codecIdEquals(id, CodecId.LZMA2)) return 'LZMA2';\n if (codecIdEquals(id, CodecId.BCJ_X86)) return 'BCJ (x86)';\n if (codecIdEquals(id, CodecId.BCJ_ARM)) return 'BCJ (ARM)';\n if (codecIdEquals(id, CodecId.BCJ_ARMT)) return 'BCJ (ARM Thumb)';\n if (codecIdEquals(id, CodecId.BCJ_ARM64)) return 'BCJ (ARM64)';\n if (codecIdEquals(id, CodecId.BCJ_PPC)) return 'BCJ (PowerPC)';\n if (codecIdEquals(id, CodecId.BCJ_IA64)) return 'BCJ (IA64)';\n if (codecIdEquals(id, CodecId.BCJ_SPARC)) return 'BCJ (SPARC)';\n if (codecIdEquals(id, CodecId.BCJ2)) return 'BCJ2';\n if (codecIdEquals(id, CodecId.PPMD)) return 'PPMd';\n if (codecIdEquals(id, CodecId.DELTA)) return 'Delta';\n if (codecIdEquals(id, CodecId.DEFLATE)) return 'Deflate';\n if (codecIdEquals(id, CodecId.BZIP2)) return 'BZip2';\n if (codecIdEquals(id, CodecId.AES)) return 'AES-256';\n return `Unknown (${codecIdToKey(id)})`;\n}\n\n/**\n * Check if a codec ID matches BCJ2\n */\nexport function isBcj2Codec(id: number[]): boolean {\n return codecIdEquals(id, CodecId.BCJ2);\n}\n\n// Re-export BCJ2 multi-stream decoder for special handling\nexport { decodeBcj2Multi };\n\n// Register built-in codecs\n\n// Copy codec (no compression)\nregisterCodec(CodecId.COPY, {\n decode: decodeCopy,\n createDecoder: createCopyDecoder,\n});\n\n// LZMA codec\nregisterCodec(CodecId.LZMA, {\n decode: decodeLzma,\n createDecoder: createLzmaDecoder,\n});\n\n// LZMA2 codec\nregisterCodec(CodecId.LZMA2, {\n decode: decodeLzma2,\n createDecoder: createLzma2Decoder,\n});\n\n// BCJ (x86) filter\nregisterCodec(CodecId.BCJ_X86, {\n decode: decodeBcj,\n createDecoder: createBcjDecoder,\n});\n\n// BCJ (ARM) filter\nregisterCodec(CodecId.BCJ_ARM, {\n decode: decodeBcjArm,\n createDecoder: createBcjArmDecoder,\n});\n\n// BCJ (ARM Thumb) filter\nregisterCodec(CodecId.BCJ_ARMT, {\n decode: decodeBcjArmt,\n createDecoder: createBcjArmtDecoder,\n});\n\n// BCJ (ARM64) filter\nregisterCodec(CodecId.BCJ_ARM64, {\n decode: decodeBcjArm64,\n createDecoder: createBcjArm64Decoder,\n});\n\n// BCJ (PowerPC) filter\nregisterCodec(CodecId.BCJ_PPC, {\n decode: decodeBcjPpc,\n createDecoder: createBcjPpcDecoder,\n});\n\n// BCJ (IA64) filter\nregisterCodec(CodecId.BCJ_IA64, {\n decode: decodeBcjIa64,\n createDecoder: createBcjIa64Decoder,\n});\n\n// BCJ (SPARC) filter\nregisterCodec(CodecId.BCJ_SPARC, {\n decode: decodeBcjSparc,\n createDecoder: createBcjSparcDecoder,\n});\n\n// Delta filter\nregisterCodec(CodecId.DELTA, {\n decode: decodeDelta,\n createDecoder: createDeltaDecoder,\n});\n\n// Deflate codec\nregisterCodec(CodecId.DEFLATE, {\n decode: decodeDeflate,\n createDecoder: createDeflateDecoder,\n});\n\n// BZip2 codec\nregisterCodec(CodecId.BZIP2, {\n decode: decodeBzip2,\n createDecoder: createBzip2Decoder,\n});\n\n// AES-256-CBC codec (encryption)\nregisterCodec(CodecId.AES, {\n decode: decodeAes,\n createDecoder: createAesDecoder,\n});\n\n// BCJ2 (x86-64) filter - multi-stream\n// Note: BCJ2 requires special handling in SevenZipParser due to 4-stream architecture\nregisterCodec(CodecId.BCJ2, {\n decode: decodeBcj2,\n createDecoder: createBcj2Decoder,\n});\n\n// Note: PPMd codec is not implemented. See FUTURE_ENHANCEMENTS.md\n"],"names":["CodecId","createCodedError","ErrorCode","createAesDecoder","decodeAes","getPassword","setPassword","createBcjDecoder","decodeBcj","createBcj2Decoder","decodeBcj2","decodeBcj2Multi","createBcjArmDecoder","decodeBcjArm","createBcjArm64Decoder","decodeBcjArm64","createBcjArmtDecoder","decodeBcjArmt","createBcjIa64Decoder","decodeBcjIa64","createBcjPpcDecoder","decodeBcjPpc","createBcjSparcDecoder","decodeBcjSparc","createBzip2Decoder","decodeBzip2","createCopyDecoder","decodeCopy","createDeflateDecoder","decodeDeflate","createDeltaDecoder","decodeDelta","createLzmaDecoder","decodeLzma","createLzma2Decoder","decodeLzma2","codecs","codecIdToKey","id","parts","i","length","push","toString","toUpperCase","join","codecIdEquals","a","b","registerCodec","codec","getCodec","key","UNSUPPORTED_CODEC","isCodecSupported","undefined","getCodecName","COPY","LZMA","LZMA2","BCJ_X86","BCJ_ARM","BCJ_ARMT","BCJ_ARM64","BCJ_PPC","BCJ_IA64","BCJ_SPARC","BCJ2","PPMD","DELTA","DEFLATE","BZIP2","AES","isBcj2Codec","decode","createDecoder"],"mappings":"AAAA,sCAAsC;AACtC,2EAA2E;AAG3E,SAASA,OAAO,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,kBAAkB;AACvE,SAASC,gBAAgB,EAAEC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ,WAAW;AACjF,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,WAAW;AACvD,SAASC,iBAAiB,EAAEC,UAAU,EAAEC,eAAe,QAAQ,YAAY;AAC3E,SAASC,mBAAmB,EAAEC,YAAY,QAAQ,cAAc;AAChE,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,gBAAgB;AACtE,SAASC,oBAAoB,EAAEC,aAAa,QAAQ,eAAe;AACnE,SAASC,oBAAoB,EAAEC,aAAa,QAAQ,eAAe;AACnE,SAASC,mBAAmB,EAAEC,YAAY,QAAQ,cAAc;AAChE,SAASC,qBAAqB,EAAEC,cAAc,QAAQ,gBAAgB;AACtE,SAASC,kBAAkB,EAAEC,WAAW,QAAQ,aAAa;AAC7D,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,YAAY;AAC1D,SAASC,oBAAoB,EAAEC,aAAa,QAAQ,eAAe;AACnE,SAASC,kBAAkB,EAAEC,WAAW,QAAQ,aAAa;AAC7D,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,YAAY;AAC1D,SAASC,kBAAkB,EAAEC,WAAW,QAAQ,aAAa;AAE7D,8CAA8C;AAC9C,SAAS9B,WAAW,EAAEC,WAAW,GAAG;AAOpC,+BAA+B;A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40
|
+
BCJ_ARM: number[];
|
|
41
|
+
BCJ_ARMT: number[];
|
|
42
|
+
BCJ_SPARC: number[];
|
|
43
|
+
BCJ_ARM64: number[];
|
|
38
44
|
BCJ2: number[];
|
|
45
|
+
PPMD: number[];
|
|
39
46
|
DEFLATE: number[];
|
|
40
47
|
BZIP2: number[];
|
|
41
48
|
AES: number[];
|
|
@@ -43,6 +43,7 @@ export var PropertyId = {
|
|
|
43
43
|
};
|
|
44
44
|
// Codec IDs
|
|
45
45
|
// 7z uses variable-length codec IDs
|
|
46
|
+
// Reference: 7za i output shows hex codec IDs (e.g., 3030501 = ARM)
|
|
46
47
|
export var CodecId = {
|
|
47
48
|
COPY: [
|
|
48
49
|
0x00
|
|
@@ -64,12 +65,53 @@ export var CodecId = {
|
|
|
64
65
|
0x01,
|
|
65
66
|
0x03
|
|
66
67
|
],
|
|
68
|
+
BCJ_PPC: [
|
|
69
|
+
0x03,
|
|
70
|
+
0x03,
|
|
71
|
+
0x02,
|
|
72
|
+
0x05
|
|
73
|
+
],
|
|
74
|
+
BCJ_IA64: [
|
|
75
|
+
0x03,
|
|
76
|
+
0x03,
|
|
77
|
+
0x04,
|
|
78
|
+
0x01
|
|
79
|
+
],
|
|
80
|
+
BCJ_ARM: [
|
|
81
|
+
0x03,
|
|
82
|
+
0x03,
|
|
83
|
+
0x05,
|
|
84
|
+
0x01
|
|
85
|
+
],
|
|
86
|
+
BCJ_ARMT: [
|
|
87
|
+
0x03,
|
|
88
|
+
0x03,
|
|
89
|
+
0x07,
|
|
90
|
+
0x01
|
|
91
|
+
],
|
|
92
|
+
BCJ_SPARC: [
|
|
93
|
+
0x03,
|
|
94
|
+
0x03,
|
|
95
|
+
0x08,
|
|
96
|
+
0x05
|
|
97
|
+
],
|
|
98
|
+
BCJ_ARM64: [
|
|
99
|
+
0x03,
|
|
100
|
+
0x03,
|
|
101
|
+
0x0a,
|
|
102
|
+
0x01
|
|
103
|
+
],
|
|
67
104
|
BCJ2: [
|
|
68
105
|
0x03,
|
|
69
106
|
0x03,
|
|
70
107
|
0x01,
|
|
71
108
|
0x1b
|
|
72
109
|
],
|
|
110
|
+
PPMD: [
|
|
111
|
+
0x03,
|
|
112
|
+
0x04,
|
|
113
|
+
0x01
|
|
114
|
+
],
|
|
73
115
|
DEFLATE: [
|
|
74
116
|
0x04,
|
|
75
117
|
0x01,
|