3 Test application for LZMA Decoder
4 LZMA SDK 4.01 Copyright (c) 1999-2004 Igor Pavlov (2004-02-15)
7 #include <linux/kernel.h>
8 #include <linux/string.h>
9 #include "LzmaDecode.h"
10 #include "LzmaWrapper.h"
12 static int internal_size
;
13 static unsigned char *internal_data
=0;
14 //static int dictionary_size;
16 int lzma_workspace_size(void)
22 return (LZMA_BASE_SIZE
+ (LZMA_LIT_SIZE
<< (lc
+ lp
)))* sizeof(CProb
);
25 int lzma_init(unsigned char *data
, int size
)
33 unsigned char *source
,
38 /* Get the properties */
39 unsigned int check_internal_size
;
40 unsigned char properties
[5];
44 unsigned int dictionary_size
= 0;
45 unsigned int encoded_size
;
48 /* Can't even get properities, just exit */
52 /* Get the size of the uncompressed buffer */
54 source
[0] | (source
[1] << 8) | (source
[2] << 16) | (source
[3] << 24);
57 /* We use this to check that the size of internal data structures
58 are big enough. If it isn't, then we flag it. */
59 memcpy(properties
, source
, sizeof(properties
));
60 prop0
= properties
[0];
63 for (pb
= 0; prop0
>= (9 * 5);
64 pb
++, prop0
-= (9 * 5));
65 for (lp
= 0; prop0
>= 9;
72 (LZMA_BASE_SIZE
+ (LZMA_LIT_SIZE
<< (lc
+ lp
)))* sizeof(CProb
);
74 for (i
= 0; i
< 4; i
++)
75 dictionary_size
+= (UInt32
)(properties
[1 + i
]) << (i
* 8);
77 if(check_internal_size
> internal_size
){
78 printk("internal_size = %d, header size = %d\n", internal_size
, check_internal_size
);
79 printk("lc = %d, lp=%d, pb=%d\n", lc
, lp
, pb
);
80 printk("byte=%x, dictionary size = %8.8x\n", prop0
, dictionary_size
);
84 res
= LzmaDecode(internal_data
, internal_size
,
86 (unsigned char *)source
, s_len
,
87 (unsigned char *)dest
, encoded_size
, d_len
);