Backport decompression updates from new_engine

This commit is contained in:
vit9696 2018-05-08 19:22:07 +03:00
parent b3f7beb236
commit f507d71ead
11 changed files with 3296 additions and 3312 deletions

View file

@ -58,13 +58,13 @@ SetEncodedSizeOfBuf (
}
}
INT32
EFI_STATUS
EFIAPI
LzmaCompress (
CONST UINT8 *Source,
UINTN SourceSize,
UINT32 SourceSize,
UINT8 *Destination,
UINTN *DestinationSize
UINT32 *DestinationSize
)
{
SRes LzmaResult;
@ -72,13 +72,14 @@ LzmaCompress(
SizeT propsSize = LZMA_PROPS_SIZE;
SizeT destLen = SourceSize + SourceSize / 3 + 128;
if (*DestinationSize < destLen)
if (*DestinationSize < (UINT32)destLen)
{
*DestinationSize = (UINTN)destLen;
return ERR_BUFFER_TOO_SMALL;
*DestinationSize = (UINT32)destLen;
return EFI_BUFFER_TOO_SMALL;
}
LzmaEncProps_Init(&props);
// TODO: need to detect this instead of hardcoding
props.dictSize = LZMA_DICTIONARY_SIZE;
props.level = 9;
props.fb = 273;
@ -87,7 +88,7 @@ LzmaCompress(
(Byte*)((UINT8*)Destination + LZMA_HEADER_SIZE),
&destLen,
Source,
SourceSize,
(SizeT)SourceSize,
&props,
(UINT8*)Destination,
&propsSize,
@ -96,14 +97,14 @@ LzmaCompress(
&SzAllocForLzma,
&SzAllocForLzma);
*DestinationSize = destLen + LZMA_HEADER_SIZE;
*DestinationSize = (UINT32)(destLen + LZMA_HEADER_SIZE);
SetEncodedSizeOfBuf(SourceSize, Destination);
if (LzmaResult == SZ_OK) {
return ERR_SUCCESS;
return EFI_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
return EFI_INVALID_PARAMETER;
}
}

View file

@ -11,8 +11,8 @@
*/
#ifndef __LZMACOMPRESS_H__
#define __LZMACOMPRESS_H__
#ifndef LZMACOMPRESS_H
#define LZMACOMPRESS_H
#include "SDK/C/Types.h"
#include "../basetypes.h"
@ -24,16 +24,17 @@ extern "C" {
#define LZMA_DICTIONARY_SIZE 0x800000
#define _LZMA_SIZE_OPT
INT32
EFI_STATUS
EFIAPI
LzmaCompress (
const UINT8 *Source,
UINTN SourceSize,
UINT32 SourceSize,
UINT8 *Destination,
UINTN *DestinationSize
UINT32 *DestinationSize
);
#ifdef __cplusplus
}
#endif
#endif
#endif // LZMACOMPRESS_H

View file

@ -85,19 +85,28 @@ DestinationSize and the size of the scratch
buffer was returned ScratchSize.
*/
INT32
EFI_STATUS
EFIAPI
LzmaGetInfo (
CONST VOID *Source,
UINTN SourceSize,
UINTN *DestinationSize
UINT32 SourceSize,
UINT32 *DestinationSize
)
{
ASSERT(SourceSize >= LZMA_HEADER_SIZE); (void)SourceSize;
UINT64 DecodedSize;
ASSERT(SourceSize >= LZMA_HEADER_SIZE);
(void)SourceSize;
*DestinationSize = (UINTN)GetDecodedSizeOfBuf((UINT8*)Source);
DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
if (DecodedSize <= UINT32_MAX) {
*DestinationSize = (UINT32)DecodedSize;
return ERR_SUCCESS;
}
else {
return ERR_INVALID_PARAMETER;
}
}
/*
Decompresses a Lzma compressed source buffer.
@ -118,11 +127,11 @@ the uncompressed buffer is returned Destination.
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFI_STATUS
EFIAPI
LzmaDecompress (
CONST VOID *Source,
UINTN SourceSize,
UINT32 SourceSize,
VOID *Destination
)
{

View file

@ -11,8 +11,8 @@
*/
#ifndef __LZMADECOMPRESS_H__
#define __LZMADECOMPRESS_H__
#ifndef LZMADECOMPRESS_H
#define LZMADECOMPRESS_H
#include "../basetypes.h"
#include "SDK/C/LzmaDec.h"
@ -23,13 +23,6 @@ extern "C" {
#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
UINT64
EFIAPI
LShiftU64(
UINT64 Operand,
UINT32 Count
);
/*
Given a Lzma compressed source buffer, this function retrieves the size of
the uncompressed buffer and the size of the scratch buffer required
@ -57,12 +50,12 @@ extern "C" {
buffer was returned ScratchSize.
*/
INT32
EFI_STATUS
EFIAPI
LzmaGetInfo (
const VOID *Source,
UINTN SourceSize,
UINTN *DestinationSize
CONST VOID *Source,
UINT32 SourceSize,
UINT32 *DestinationSize
);
/*
@ -84,15 +77,16 @@ extern "C" {
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFI_STATUS
EFIAPI
LzmaDecompress (
const VOID *Source,
UINTN SourceSize,
CONST VOID *Source,
UINT32 SourceSize,
VOID *Destination
);
#ifdef __cplusplus
}
#endif
#endif
#endif // LZMADECOMPRESS_H

View file

@ -332,8 +332,7 @@ Returns:
if (mCompSize + 1 + 8 > *DstSize) {
*DstSize = mCompSize + 1 + 8;
return EFI_BUFFER_TOO_SMALL;
}
else {
} else {
*DstSize = mCompSize + 1 + 8;
return EFI_SUCCESS;
}
@ -493,19 +492,23 @@ Returns:
UINT32 i;
mText = malloc (WNDSIZ * 2 + MAXMATCH);
if (NULL == mText)
return EFI_OUT_OF_RESOURCES;
if (!mText) return EFI_OUT_OF_RESOURCES;
for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {
mText[i] = 0;
}
mLevel = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mLevel));
if (!mLevel) return EFI_OUT_OF_RESOURCES;
mChildCount = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mChildCount));
if (!mChildCount) return EFI_OUT_OF_RESOURCES;
mPosition = malloc((WNDSIZ + UINT8_MAX + 1) * sizeof(*mPosition));
if (!mPosition) return EFI_OUT_OF_RESOURCES;
mParent = malloc(WNDSIZ * 2 * sizeof(*mParent));
if (!mParent) return EFI_OUT_OF_RESOURCES;
mPrev = malloc(WNDSIZ * 2 * sizeof(*mPrev));
if (!mPrev) return EFI_OUT_OF_RESOURCES;
mNext = malloc((MAX_HASH_VAL + 1) * sizeof(*mNext));
if (!mNext) return EFI_OUT_OF_RESOURCES;
mBufSiz = 16 * 1024U;
while ((mBuf = malloc(mBufSiz)) == NULL) {
@ -677,7 +680,7 @@ Returns: (VOID)
STATIC
VOID
Split (
IN NODE Old
NODE Old
)
/*++
@ -755,8 +758,7 @@ Returns: (VOID)
if (t < (NODE)WNDSIZ) {
mPosition[t] = (NODE)(mPos | PERC_FLAG);
}
}
else {
} else {
//
// Locate the target tree
@ -782,8 +784,7 @@ Returns: (VOID)
if (r >= (NODE)WNDSIZ) {
j = MAXMATCH;
mMatchPos = r;
}
else {
} else {
j = mLevel[r];
mMatchPos = (NODE)(mPosition[r] & ~PERC_FLAG);
}
@ -987,8 +988,7 @@ Returns:
//
Output(mText[mPos - 1], 0);
}
else {
} else {
//
// Outputting a pointer is beneficial enough, do it.
@ -1045,19 +1045,15 @@ Returns: (VOID)
}
if (Count <= 2) {
mTFreq[0] = (UINT16)(mTFreq[0] + Count);
}
else if (Count <= 18) {
} else if (Count <= 18) {
mTFreq[1]++;
}
else if (Count == 19) {
} else if (Count == 19) {
mTFreq[0]++;
mTFreq[1]++;
}
else {
} else {
mTFreq[2]++;
}
}
else {
} else {
mTFreq[k + 2]++;
}
}
@ -1097,8 +1093,7 @@ Returns: (VOID)
k = mPTLen[i++];
if (k <= 6) {
PutBits(3, k);
}
else {
} else {
PutBits(k - 3, (1U << (k - 3)) - 2);
}
if (i == Special) {
@ -1145,22 +1140,18 @@ Returns: (VOID)
for (k = 0; k < Count; k++) {
PutBits(mPTLen[0], mPTCode[0]);
}
}
else if (Count <= 18) {
} else if (Count <= 18) {
PutBits(mPTLen[1], mPTCode[1]);
PutBits(4, Count - 3);
}
else if (Count == 19) {
} else if (Count == 19) {
PutBits(mPTLen[0], mPTCode[0]);
PutBits(mPTLen[1], mPTCode[1]);
PutBits(4, 15);
}
else {
} else {
PutBits(mPTLen[2], mPTCode[2]);
PutBits(CBIT, Count - 20);
}
}
else {
} else {
PutBits(mPTLen[k + 2], mPTCode[k + 2]);
}
}
@ -1221,14 +1212,12 @@ Returns: (VOID)
Root = MakeTree(NT, mTFreq, mPTLen, mPTCode);
if (Root >= NT) {
WritePTLen(NT, TBIT, 3);
}
else {
} else {
PutBits(TBIT, 0);
PutBits(TBIT, Root);
}
WriteCLen();
}
else {
} else {
PutBits(TBIT, 0);
PutBits(TBIT, 0);
PutBits(CBIT, 0);
@ -1237,8 +1226,7 @@ Returns: (VOID)
Root = MakeTree(NP, mPFreq, mPTLen, mPTCode);
if (Root >= NP) {
WritePTLen(NP, gPBIT, -1);
}
else {
} else {
PutBits(gPBIT, 0);
PutBits(gPBIT, Root);
}
@ -1246,8 +1234,7 @@ Returns: (VOID)
for (i = 0; i < Size; i++) {
if (i % UINT8_BIT == 0) {
Flags = mBuf[Pos++];
}
else {
} else {
Flags <<= 1;
}
if (Flags & (1U << (UINT8_BIT - 1))) {
@ -1255,8 +1242,7 @@ Returns: (VOID)
k = mBuf[Pos++] << UINT8_BIT;
k += mBuf[Pos++];
EncodeP(k);
}
else {
} else {
EncodeC(mBuf[Pos++]);
}
}
@ -1359,8 +1345,7 @@ MakeCrcTable()
for (j = 0; j < UINT8_BIT; j++) {
if (r & 1) {
r = (r >> 1) ^ CRCPOLY;
}
else {
} else {
r >>= 1;
}
}
@ -1393,8 +1378,7 @@ Returns: (VOID)
if (n < mBitCount) {
mSubBitBuf |= x << (mBitCount -= n);
}
else {
} else {
Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount)));
if (mDst < mDstUpperLimit) {
@ -1404,8 +1388,7 @@ Returns: (VOID)
if (n < UINT8_BIT) {
mSubBitBuf = x << (mBitCount = UINT8_BIT - n);
}
else {
} else {
Temp = (UINT8)(x >> (n - UINT8_BIT));
if (mDst < mDstUpperLimit) {
@ -1488,8 +1471,7 @@ Returns: (VOID)
if (i < mN) {
mLenCnt[(Depth < 16) ? Depth : 16]++;
}
else {
} else {
Depth++;
CountLen(mLeft [i]);
CountLen(mRight[i]);

View file

@ -20,8 +20,8 @@ Header file for compression routine.
*/
#ifndef _EFITIANOCOMPRESS_H_
#define _EFITIANOCOMPRESS_H_
#ifndef EFITIANOCOMPRESS_H
#define EFITIANOCOMPRESS_H
#include <string.h>
#include <stdlib.h>
@ -57,11 +57,12 @@ extern "C" {
--*/
EFI_STATUS
TianoCompress(
IN CONST VOID *SrcBuffer,
IN UINT32 SrcSize,
IN VOID *DstBuffer,
IN OUT UINT32 *DstSize
);
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
EFI_STATUS
TianoCompressLegacy(
@ -69,7 +70,8 @@ extern "C" {
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
);
)
;
/*++
Routine Description:
@ -95,21 +97,22 @@ extern "C" {
--*/
EFI_STATUS
EfiCompress(
IN CONST VOID *SrcBuffer,
IN UINT32 SrcSize,
IN VOID *DstBuffer,
IN OUT UINT32 *DstSize
);
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
)
;
EFI_STATUS
EfiCompressLegacy(
CONST VOID *SrcBuffer,
UINT32 SrcSize,
VOID *DstBuffer,
UINT32 *DstSize
);
)
;
#ifdef __cplusplus
}
#endif
#endif
#endif // EFITIANOCOMPRESS_H

View file

@ -463,8 +463,7 @@ EFI_INVALID_PARAMETER - Parameter supplied is wrong.
if (mCompSize + 1 + 8 > *DstSize) {
*DstSize = mCompSize + 1 + 8;
return EFI_BUFFER_TOO_SMALL;
}
else {
} else {
*DstSize = mCompSize + 1 + 8;
return EFI_SUCCESS;
}
@ -531,19 +530,23 @@ EFI_OUT_OF_RESOURCES - Allocation fails
UINT32 Index;
mText = malloc (WNDSIZ * 2 + MAXMATCH);
if (NULL == mText)
return EFI_OUT_OF_RESOURCES;
if (!mText) return EFI_OUT_OF_RESOURCES;
for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {
mText[Index] = 0;
}
mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));
if (!mLevel) return EFI_OUT_OF_RESOURCES;
mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));
if (!mChildCount) return EFI_OUT_OF_RESOURCES;
mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));
if (!mPosition) return EFI_OUT_OF_RESOURCES;
mParent = malloc (WNDSIZ * 2 * sizeof (*mParent));
if (!mParent) return EFI_OUT_OF_RESOURCES;
mPrev = malloc (WNDSIZ * 2 * sizeof (*mPrev));
if (!mPrev) return EFI_OUT_OF_RESOURCES;
mNext = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));
if (!mNext) return EFI_OUT_OF_RESOURCES;
mBufSiz = BLKSIZ;
mBuf = malloc (mBufSiz);
@ -817,8 +820,7 @@ Returns: (VOID)
if (NodeT < (NODE) WNDSIZ) {
mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG);
}
}
else {
} else {
//
// Locate the target tree
//
@ -842,8 +844,7 @@ Returns: (VOID)
if (NodeR >= (NODE) WNDSIZ) {
Index2 = MAXMATCH;
mMatchPos = NodeR;
}
else {
} else {
Index2 = mLevel[NodeR];
mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);
}
@ -1082,8 +1083,7 @@ EFI_OUT_0F_RESOURCES - Not enough memory for compression process
//
Output (mText[mPos - 1], 0);
}
else {
} else {
if (LastMatchLen == THRESHOLD) {
if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) {
@ -1158,19 +1158,15 @@ Returns: (VOID)
if (Count <= 2) {
mTFreq[0] = (UINT16) (mTFreq[0] + Count);
}
else if (Count <= 18) {
} else if (Count <= 18) {
mTFreq[1]++;
}
else if (Count == 19) {
} else if (Count == 19) {
mTFreq[0]++;
mTFreq[1]++;
}
else {
} else {
mTFreq[2]++;
}
}
else {
} else {
mTFreq[Index3 + 2]++;
}
}
@ -1212,8 +1208,7 @@ Returns: (VOID)
Index3 = mPTLen[Index++];
if (Index3 <= 6) {
PutBits (3, Index3);
}
else {
} else {
PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);
}
@ -1269,22 +1264,18 @@ Returns: (VOID)
for (Index3 = 0; Index3 < Count; Index3++) {
PutBits (mPTLen[0], mPTCode[0]);
}
}
else if (Count <= 18) {
} else if (Count <= 18) {
PutBits (mPTLen[1], mPTCode[1]);
PutBits (4, Count - 3);
}
else if (Count == 19) {
} else if (Count == 19) {
PutBits (mPTLen[0], mPTCode[0]);
PutBits (mPTLen[1], mPTCode[1]);
PutBits (4, 15);
}
else {
} else {
PutBits (mPTLen[2], mPTCode[2]);
PutBits (CBIT, Count - 20);
}
}
else {
} else {
PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]);
}
}
@ -1357,15 +1348,13 @@ Returns:
Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);
if (Root >= NT) {
WritePTLen (NT, TBIT, 3);
}
else {
} else {
PutBits (TBIT, 0);
PutBits (TBIT, Root);
}
WriteCLen ();
}
else {
} else {
PutBits (TBIT, 0);
PutBits (TBIT, 0);
PutBits (CBIT, 0);
@ -1375,8 +1364,7 @@ Returns:
Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);
if (Root >= NP) {
WritePTLen (NP, mPbit, -1);
}
else {
} else {
PutBits (mPbit, 0);
PutBits (mPbit, Root);
}
@ -1385,8 +1373,7 @@ Returns:
for (Index = 0; Index < Size; Index++) {
if (Index % UINT8_BIT == 0) {
Flags = mBuf[Pos++];
}
else {
} else {
Flags <<= 1;
}
@ -1399,8 +1386,7 @@ Returns:
}
EncodeP (Index3);
}
else {
} else {
EncodeC (mBuf[Pos++]);
}
}
@ -1523,8 +1509,7 @@ MakeCrcTable(
for (Index2 = 0; Index2 < UINT8_BIT; Index2++) {
if (Temp & 1) {
Temp = (Temp >> 1) ^ CRCPOLY;
}
else {
} else {
Temp >>= 1;
}
}
@ -1648,8 +1633,7 @@ Returns: (VOID)
if (Index < mN) {
mLenCnt[(Depth < 16) ? Depth : 16]++;
}
else {
} else {
Depth++;
CountLen (mLeft[Index]);
CountLen (mRight[Index]);

View file

@ -21,8 +21,8 @@ Providing both EFI and Tiano decompress algorithms.
--*/
#ifndef _EFITIANODECOMPRESS_H_
#define _EFITIANODECOMPRESS_H_
#ifndef EFITIANODECOMPRESS_H
#define EFITIANODECOMPRESS_H
#include <string.h>
#include <stdlib.h>
@ -32,17 +32,18 @@ Providing both EFI and Tiano decompress algorithms.
extern "C" {
#endif
typedef struct {
typedef struct EFI_TIANO_HEADER_ {
UINT32 CompSize;
UINT32 OrigSize;
} EFI_TIANO_HEADER;
EFI_STATUS
EFIAPI
EfiTianoGetInfo(
IN const VOID *Source,
IN UINT32 SrcSize,
OUT UINT32 *DstSize,
OUT UINT32 *ScratchSize
const VOID *Source,
UINT32 SrcSize,
UINT32 *DstSize,
UINT32 *ScratchSize
)
/*++
@ -52,7 +53,6 @@ extern "C" {
Arguments:
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
DstSize - The size of destination buffer.
@ -69,13 +69,13 @@ extern "C" {
EFI_STATUS
EFIAPI
EfiDecompress(
IN const VOID *Source,
IN UINT32 SrcSize,
IN OUT VOID *Destination,
IN UINT32 DstSize,
IN OUT VOID *Scratch,
IN UINT32 ScratchSize
)
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
);
/*++
Routine Description:
@ -84,7 +84,6 @@ extern "C" {
Arguments:
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
@ -103,12 +102,12 @@ extern "C" {
EFI_STATUS
EFIAPI
TianoDecompress(
IN const VOID *Source,
IN UINT32 SrcSize,
IN OUT VOID *Destination,
IN UINT32 DstSize,
IN OUT VOID *Scratch,
IN UINT32 ScratchSize
const VOID *Source,
UINT32 SrcSize,
VOID *Destination,
UINT32 DstSize,
VOID *Scratch,
UINT32 ScratchSize
)
/*++
@ -118,7 +117,6 @@ extern "C" {
Arguments:
This - The protocol instance pointer
Source - The source buffer containing the compressed data.
SrcSize - The size of source buffer
Destination - The destination buffer to store the decompressed data
@ -137,4 +135,4 @@ extern "C" {
#ifdef __cplusplus
}
#endif
#endif
#endif // EFITIANODECOMPRESS_H

View file

@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
typedef uint8_t BOOLEAN;
typedef int8_t INT8;
@ -28,7 +29,7 @@ typedef int64_t INT64;
typedef uint64_t UINT64;
typedef char CHAR8;
typedef uint16_t CHAR16;
typedef unsigned int UINTN;
typedef size_t UINTN;
#define CONST const
#define VOID void

View file

@ -2741,7 +2741,13 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
else if (algorithm)
*algorithm = COMPRESSION_ALGORITHM_TIANO;
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
if (decompressedSize > INT32_MAX) {
delete[] decompressed;
delete[] scratch;
return ERR_STANDARD_DECOMPRESSION_FAILED;
}
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
delete[] decompressed;
delete[] scratch;
@ -2778,7 +2784,8 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
}
// Decompress section data again
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)) {
if (ERR_SUCCESS != LzmaDecompress(data, dataSize, decompressed)
|| decompressedSize > INT32_MAX) {
if (algorithm)
*algorithm = COMPRESSION_ALGORITHM_UNKNOWN;
delete[] decompressed;
@ -2787,13 +2794,17 @@ UINT8 FfsEngine::decompress(const QByteArray & compressedData, const UINT8 compr
else {
if (algorithm)
*algorithm = COMPRESSION_ALGORITHM_IMLZMA;
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
}
}
else {
if (decompressedSize > INT32_MAX) {
delete[] decompressed;
return ERR_CUSTOMIZED_DECOMPRESSION_FAILED;
}
if (algorithm)
*algorithm = COMPRESSION_ALGORITHM_LZMA;
decompressedData = QByteArray((const char*)decompressed, decompressedSize);
decompressedData = QByteArray((const char*)decompressed, (int)decompressedSize);
}
delete[] decompressed;