/** @file\r
-Compression routine. The compression algorithm is a mixture of LZ77 and Huffman \r
-coding. LZ77 transforms the source data into a sequence of Original Characters \r
-and Pointers to repeated strings. This sequence is further divided into Blocks \r
+Compression routine. The compression algorithm is a mixture of LZ77 and Huffman\r
+coding. LZ77 transforms the source data into a sequence of Original Characters\r
+and Pointers to repeated strings. This sequence is further divided into Blocks\r
and Huffman codings are applied to each Block.\r
- \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
**/\r
\r
Routine Description:\r
\r
Put a dword to output stream\r
- \r
+\r
Arguments:\r
\r
Data - the dword to put\r
- \r
+\r
Returns: (VOID)\r
- \r
+\r
--*/\r
{\r
if (mDst < mDstUpperLimit) {\r
Routine Description:\r
\r
Allocate memory spaces for data structures used in compression process\r
- \r
-Argements: \r
+\r
+Argements:\r
VOID\r
\r
Returns:\r
Routine Description:\r
\r
Called when compression is completed to free memory previously allocated.\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
Routine Description:\r
\r
Initialize String Info Log data structures\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
Routine Description:\r
\r
Find child node given the parent node and the edge character\r
- \r
+\r
Arguments:\r
\r
NodeQ - the parent node\r
CharC - the edge character\r
- \r
+\r
Returns:\r
\r
- The child node (NIL if not found) \r
- \r
+ The child node (NIL if not found)\r
+\r
--*/\r
{\r
NODE NodeR;\r
Routine Description:\r
\r
Create a new child for a given parent node.\r
- \r
+\r
Arguments:\r
\r
Parent - the parent node\r
CharC - the edge character\r
Child - the child node\r
- \r
+\r
Returns: (VOID)\r
\r
--*/\r
Routine Description:\r
\r
Split a node.\r
- \r
+\r
Arguments:\r
\r
Old - the node to split\r
- \r
+\r
Returns: (VOID)\r
\r
--*/\r
Routine Description:\r
\r
Insert string info for current position into the String Info Log\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
\r
Delete outdated string info. (The Usage of PERC_FLAG\r
ensures a clean deletion)\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
Arguments: (VOID)\r
\r
Returns:\r
- \r
+\r
EFI_SUCCESS - The compression is successful\r
EFI_OUT_0F_RESOURCES - Not enough memory for compression process\r
\r
Routine Description:\r
\r
Count the frequencies for the Extra Set\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
Routine Description:\r
\r
Outputs the code length array for the Extra Set or the Position Set.\r
- \r
+\r
Arguments:\r
\r
Number - the number of symbols\r
nbit - the number of bits needed to represent 'n'\r
Special - the special symbol that needs to be take care of\r
- \r
+\r
Returns: (VOID)\r
\r
--*/\r
Routine Description:\r
\r
Outputs the code length array for Char&Length Set\r
- \r
+\r
Arguments: (VOID)\r
\r
Returns: (VOID)\r
Routine Description:\r
\r
Huffman code the block and output it.\r
- \r
-Arguments: \r
+\r
+Arguments:\r
(VOID)\r
\r
-Returns: \r
+Returns:\r
(VOID)\r
\r
--*/\r
Arguments:\r
\r
Number - the rightmost n bits of the data is used\r
- x - the data \r
+ x - the data\r
\r
Returns: (VOID)\r
\r
Routine Description:\r
\r
Read in source data\r
- \r
+\r
Arguments:\r
\r
Pointer - the buffer to hold the data\r
Returns:\r
\r
number of bytes actually read\r
- \r
+\r
--*/\r
{\r
INT32 Index;\r
Routine Description:\r
\r
Count the number of each code length for a Huffman tree.\r
- \r
+\r
Arguments:\r
\r
Index - the top node\r
- \r
+\r
Returns: (VOID)\r
\r
--*/\r
Routine Description:\r
\r
Create code length array for a Huffman tree\r
- \r
+\r
Arguments:\r
\r
Root - the root of the tree\r
- \r
+\r
Returns:\r
\r
VOID\r
Routine Description:\r
\r
Assign code to each symbol based on the code length array\r
- \r
+\r
Arguments:\r
\r
Number - number of symbols\r
Routine Description:\r
\r
Generates Huffman codes given a frequency distribution of symbols\r
- \r
+\r
Arguments:\r
\r
NParm - number of symbols\r
FreqParm - frequency of each symbol\r
LenParm - code length for each symbol\r
CodeParm - code for each symbol\r
- \r
+\r
Returns:\r
\r
Root of the Huffman tree.\r
- \r
+\r
--*/\r
{\r
INT32 Index;\r