From nobody Fri May 3 22:48:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47467+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47467+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568795461; cv=none; d=zoho.com; s=zohoarc; b=EK1JCwd9dboY3A9cX9cMaTK4bjzEd++j7IQ0riTPBq1UIHQgHasYjklmXmSwo6D7Ii4GGxM/jVx+1DfnLZ5O+A5BB8KLsFk1JSOXbOjs3Zw4U/vmFYyictmvNeXLLPE/wNdqrUgTvtnjDW0m3PVi4EwSrU0OMnX01OkpqYYg76s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568795461; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=Msy/CdWJTkm+5YOKwfdGBsrRl5gErvqxvsLbnDf1lKY=; b=XYlipoiqw9q/DpCCRZPglWj5KLkP17iFWZ1eh0+hd/EWhJrcXJzztWcEFHvrIFnDclkdaryJYKk5vR7XL/NoteU/Xd5vvBOHyeR34GfrQJCA5mZbg7KvH+iP4HDcVw84c1do1dI+H0/pvBt4Nd/Q0OEUVfbUt7rB7FiLY7GAMSo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47467+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568795461192134.84017152005902; Wed, 18 Sep 2019 01:31:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9I3sYY1788612xSVmSc6DQYJ; Wed, 18 Sep 2019 01:31:00 -0700 X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Wed, 18 Sep 2019 01:30:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2019 01:30:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,520,1559545200"; d="scan'208";a="191653869" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 18 Sep 2019 01:30:58 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: "Zhang, Shenglei" , Bob Feng , Liming Gao Subject: [edk2-devel] [PATCH v3] BaseTools/LzmaCompress: Add two switches Date: Wed, 18 Sep 2019 16:30:56 +0800 Message-Id: <20190918083056.43708-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,shenglei.zhang@intel.com X-Gm-Message-State: TZ2DAwWTpA4dywvYZ0KnFzmOx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568795460; bh=0ZRodJ3ApcieCeJ+q+LPSVd54HkO6BJc2EPkz78mAjs=; h=Cc:Date:From:Reply-To:Subject:To; b=pOi5aNZcEu111s4Lh7O+noNnWOBnTZCGKBWISZuAo663G1/bzj3K3khPrP/Ry8lnEMV yMbimuNsZpVpykwyEyBINiwbBt3BY7TWiU1zVttd1JZiv5pXxYVj+//hT0i7r0K0+IYhA 6XUoLMSQP95jwgCHT+juJ28cDPe9E+PhR7Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Zhang, Shenglei" As is requested in the BZ 2077, add two switches to support setting compression mode and dictionary size. (https://bugzilla.tianocore.org/show_bug.cgi?id=3D2077) Cc: Bob Feng Cc: Liming Gao Signed-off-by: Shenglei Zhang --- v2: 1.Update DictionarySize to mDictionarySize. 2.Update CompressionMode to mCompressionMode. 3.Use CLzmaEncProps *props as the input parameter of the function Encode. v3: Remove the component "mDictionarySize >=3D 0" in the if judgement.line = 303 This is to fix the build failure under Mac OS. Beacuse the type of mDictionarySize is UINT64, which is always >=3D 0. =20 .../Source/C/LzmaCompress/LzmaCompress.c | 43 +++++++++++++++---- BaseTools/Source/C/LzmaCompress/GNUmakefile | 4 +- BaseTools/Source/C/LzmaCompress/Makefile | 4 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Sou= rce/C/LzmaCompress/LzmaCompress.c index a3607f9b2084..328ecfa930da 100644 --- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c +++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c @@ -5,7 +5,7 @@ LzmaUtil.c -- Test application for LZMA compression 2018-04-30 : Igor Pavlov : Public domain =20 - Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -23,6 +23,7 @@ #include "Sdk/C/LzmaEnc.h" #include "Sdk/C/Bra.h" #include "CommonLib.h" +#include "ParseInf.h" =20 #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8) =20 @@ -36,10 +37,14 @@ const char *kCantReadMessage =3D "Can not read input fi= le"; const char *kCantWriteMessage =3D "Can not write output file"; const char *kCantAllocateMessage =3D "Can not allocate memory"; const char *kDataErrorMessage =3D "Data error"; +const char *kInvalidParamValMessage =3D "Invalid parameter value"; =20 static Bool mQuietMode =3D False; static CONVERTER_TYPE mConType =3D NoConverter; =20 +UINT64 mDictionarySize =3D 31; +UINT64 mCompressionMode =3D 2; + #define UTILITY_NAME "LzmaCompress" #define UTILITY_MAJOR_VERSION 0 #define UTILITY_MINOR_VERSION 2 @@ -58,6 +63,8 @@ void PrintHelp(char *buffer) " -v, --verbose: increase output messages\n" " -q, --quiet: reduce output messages\n" " --debug [0-9]: set debug level\n" + " -a: set compression mode 0 =3D fast, 1 =3D normal, default= : 1 (normal)\n" + " d: sets Dictionary size - [0, 30], default: 23 (8MB)\n" " --version: display the program version and exit\n" " -h, --help: display this help text\n" ); @@ -87,7 +94,7 @@ void PrintVersion(char *buffer) sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VER= SION, UTILITY_MINOR_VERSION, __BUILD_VERSION); } =20 -static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt6= 4 fileSize) +static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt6= 4 fileSize, CLzmaEncProps *props) { SRes res; size_t inSize =3D (size_t)fileSize; @@ -95,10 +102,6 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStre= am *inStream, UInt64 file Byte *outBuffer =3D 0; Byte *filteredStream =3D 0; size_t outSize; - CLzmaEncProps props; - - LzmaEncProps_Init(&props); - LzmaEncProps_Normalize(&props); =20 if (inSize !=3D 0) { inBuffer =3D (Byte *)MyAlloc(inSize); @@ -151,7 +154,7 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInStre= am *inStream, UInt64 file =20 res =3D LzmaEncode(outBuffer + LZMA_HEADER_SIZE, &outSizeProcessed, mConType !=3D NoConverter ? filteredStream : inBuffer, inSize, - &props, outBuffer, &outPropsSize, 0, + props, outBuffer, &outPropsSize, 0, NULL, &g_Alloc, &g_Alloc); =20 if (res !=3D SZ_OK) @@ -246,6 +249,12 @@ int main2(int numArgs, const char *args[], char *rs) const char *outputFile =3D "file.tmp"; int param; UInt64 fileSize; + CLzmaEncProps *props; + + props =3D (CLzmaEncProps *)AllocateZeroPool(sizeof(CLzmaEncProps)); + + LzmaEncProps_Init(props); + LzmaEncProps_Normalize(props); =20 FileSeqInStream_CreateVTable(&inStream); File_Construct(&inStream.file); @@ -280,6 +289,24 @@ int main2(int numArgs, const char *args[], char *rs) // parameter compatibility with other build tools. // param++; + } else if (strcmp(args[param], "-a") =3D=3D 0) { + AsciiStringToUint64(args[param + 1],FALSE,&mCompressionMode); + if ((mCompressionMode =3D=3D 0)||(mCompressionMode =3D=3D 1)){ + props->algo =3D (int)mCompressionMode; + param++; + continue; + } else { + return PrintError(rs, kInvalidParamValMessage); + } + } else if (strcmp(args[param], "d") =3D=3D 0) { + AsciiStringToUint64(args[param + 1],FALSE,&mDictionarySize); + if (mDictionarySize <=3D 30){ + props->dictSize =3D (UINT32)mDictionarySize; + param++; + continue; + } else { + return PrintError(rs, kInvalidParamValMessage); + } } else if ( strcmp(args[param], "-h") =3D=3D 0 || strcmp(args[param], "--help") =3D=3D 0 @@ -335,7 +362,7 @@ int main2(int numArgs, const char *args[], char *rs) if (!mQuietMode) { printf("Encoding\n"); } - res =3D Encode(&outStream.vt, &inStream.vt, fileSize); + res =3D Encode(&outStream.vt, &inStream.vt, fileSize, props); } else { diff --git a/BaseTools/Source/C/LzmaCompress/GNUmakefile b/BaseTools/Source= /C/LzmaCompress/GNUmakefile index 533f0a59a0af..c837e7782373 100644 --- a/BaseTools/Source/C/LzmaCompress/GNUmakefile +++ b/BaseTools/Source/C/LzmaCompress/GNUmakefile @@ -1,13 +1,15 @@ ## @file # GNU/Linux makefile for 'LzmaCompress' module build. # -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # MAKEROOT ?=3D .. =20 APPNAME =3D LzmaCompress =20 +LIBS =3D -lCommon + SDK_C =3D Sdk/C =20 OBJECTS =3D \ diff --git a/BaseTools/Source/C/LzmaCompress/Makefile b/BaseTools/Source/C/= LzmaCompress/Makefile index 12be48de2940..055f5d3ac3ca 100644 --- a/BaseTools/Source/C/LzmaCompress/Makefile +++ b/BaseTools/Source/C/LzmaCompress/Makefile @@ -1,14 +1,14 @@ ## @file # Windows makefile for 'LzmaCompress' module build. # -# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # !INCLUDE ..\Makefiles\ms.common =20 APPNAME =3D LzmaCompress =20 -#LIBS =3D $(LIB_PATH)\Common.lib +LIBS =3D $(LIB_PATH)\Common.lib =20 SDK_C =3D Sdk\C =20 --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47467): https://edk2.groups.io/g/devel/message/47467 Mute This Topic: https://groups.io/mt/34185750/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-