/** @file
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Abstract:
Decompressor. Algorithm Ported from OPSD code (Decomp.asm)
for Efi and Tiano compress algorithm.
--*/
#include <stdlib.h>
#include <string.h>
#include "Decompress.h"
//
// Decompression algorithm begins here
//
//
// C: Char&Len Set; P: Position Set; T: exTra Set
//
#else
#endif
typedef struct {
} SCRATCH_DATA;
FillBuf (
)
/*++
Routine Description:
Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
Arguments:
Sd - The global scratch data
NumOfBit - The number of bits to shift and read.
Returns: (VOID)
--*/
{
//
// Get 1 byte into SubBitBuf
//
Sd->mSubBitBuf = 0;
} else {
//
// No more bits from the source, just pad zero bit.
//
Sd->mSubBitBuf = 0;
}
}
}
GetBits (
)
/*++
Routine Description:
Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
NumOfBits of bits from source. Returns NumOfBits of bits that are
popped out.
Arguments:
Sd - The global scratch data.
NumOfBits - The number of bits to pop and read.
Returns:
The bits that are popped out.
--*/
{
return OutBits;
}
)
/*++
Routine Description:
Creates Huffman Code mapping table according to code length array.
Arguments:
Sd - The global scratch data
NumOfChar - Number of symbols in the symbol set
BitLen - Code length array
TableBits - The width of the mapping table
Table - The table
Returns:
0 - OK.
BAD_TABLE - The table is corrupted.
--*/
{
}
}
Start[1] = 0;
}
if (Start[17] != 0) {
/*(1U << 16)*/
}
}
while (Index <= 16) {
Index++;
}
if (Index != 0) {
}
}
if (Len == 0) {
continue;
}
}
} else {
while (Index != 0) {
if (*Pointer == 0) {
}
} else {
}
Index3 <<= 1;
Index--;
}
}
}
//
// Succeeds
//
return 0;
}
DecodeP (
)
/*++
Routine Description:
Decodes a position value.
Arguments:
Sd - the global scratch data
Returns:
The position value decoded.
--*/
{
do {
} else {
}
Mask >>= 1;
}
//
// Advance what we have read
//
if (Val > 1) {
}
return Pos;
}
)
/*++
Routine Description:
Reads code lengths for the Extra Set or the Position Set
Arguments:
Sd - The global scratch data
nn - Number of symbols
nbit - Number of bits needed to represent nn
Special - The special symbol that needs to be taken care of
Returns:
0 - OK.
BAD_TABLE - Table is corrupted.
--*/
{
if (Number == 0) {
}
}
return 0;
}
Index = 0;
if (CharC == 7) {
Mask >>= 1;
CharC += 1;
}
}
CharC--;
CharC--;
}
}
}
}
}
ReadCLen (
)
/*++
Routine Description:
Reads code lengths for Char&Len Set.
Arguments:
Sd - the global scratch data
Returns: (VOID)
--*/
{
if (Number == 0) {
}
}
return ;
}
Index = 0;
do {
} else {
}
Mask >>= 1;
}
//
// Advance what we have read
//
if (CharC <= 2) {
if (CharC == 0) {
CharC = 1;
} else if (CharC == 1) {
} else if (CharC == 2) {
}
CharC--;
CharC--;
}
} else {
}
}
}
return ;
}
DecodeC (
)
/*++
Routine Description:
Arguments:
Sd - The global scratch data.
Returns:
The value decoded.
--*/
{
if (Sd->mBlockSize == 0) {
//
// Starting a new block
//
if (Sd->mBadTableFlag != 0) {
return 0;
}
if (Sd->mBadTableFlag != 0) {
return 0;
}
}
Sd->mBlockSize--;
do {
} else {
}
Mask >>= 1;
}
//
// Advance what we have read
//
return Index2;
}
Decode (
)
/*++
Routine Description:
Decode the source data and put the resulting data into the destination buffer.
Arguments:
Sd - The global scratch data
Returns: (VOID)
--*/
{
DataIdx = 0;
for (;;) {
if (Sd->mBadTableFlag != 0) {
return ;
}
if (CharC < 256) {
//
// Process an Original character
//
return ;
}
} else {
//
// Process a Pointer
//
BytesRemain = CharC;
BytesRemain--;
while ((INT16) (BytesRemain) >= 0) {
return ;
}
BytesRemain--;
}
}
}
return ;
}
GetInfo (
)
/*++
Routine Description:
The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination buffer.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
*ScratchSize = sizeof (SCRATCH_DATA);
if (SrcSize < 8) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
)
/*++
Routine Description:
The implementation Efi and Tiano Decompress().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - Decompression is successfull
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
Dst = Destination;
if (ScratchSize < sizeof (SCRATCH_DATA)) {
return EFI_INVALID_PARAMETER;
}
if (SrcSize < 8) {
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
}
//
// Fill the first BITBUFSIZ bits
//
//
// Decompress it
//
if (Sd->mBadTableFlag != 0) {
//
// Something wrong with the source
//
}
return Status;
}
)
/*++
Routine Description:
The implementation Efi Decompress GetInfo().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination buffer.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
}
)
/*++
Routine Description:
The implementation Tiano Decompress GetInfo().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination buffer.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
}
)
/*++
Routine Description:
The implementation of Efi Decompress().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - Decompression is successfull
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
}
)
/*++
Routine Description:
The implementation of Tiano Decompress().
Arguments:
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
DstSize - The size of destination buffer.
Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
ScratchSize - The size of scratch buffer.
Returns:
EFI_SUCCESS - Decompression is successfull
EFI_INVALID_PARAMETER - The source data is corrupted
--*/
{
}
Extract (
)
{
switch (Algorithm) {
case 0:
if (*Destination != NULL) {
} else {
}
break;
case 1:
if (Status == EFI_SUCCESS) {
} else {
}
}
break;
case 2:
if (Status == EFI_SUCCESS) {
} else {
}
}
break;
default:
}
return Status;
}