From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: liming.gao@intel.com) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by groups.io with SMTP; Thu, 19 Sep 2019 23:01:15 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2019 23:01:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,527,1559545200"; d="scan'208";a="212474866" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga004.fm.intel.com with ESMTP; 19 Sep 2019 23:01:14 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Sep 2019 23:01:13 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Sep 2019 23:01:13 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.195]) with mapi id 14.03.0439.000; Fri, 20 Sep 2019 14:01:11 +0800 From: "Liming Gao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Feng, Bob C" Subject: Re: [PATCH v4] BaseTools/LzmaCompress: Add two switches Thread-Topic: [PATCH v4] BaseTools/LzmaCompress: Add two switches Thread-Index: AQHVb1s4HCgK4HW1tkC5zmeUOT5FCKc0EthQ Date: Fri, 20 Sep 2019 06:01:10 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4FF2F7@SHSMSX104.ccr.corp.intel.com> References: <20190920022902.42808-1-shenglei.zhang@intel.com> In-Reply-To: <20190920022902.42808-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTkzMmYzMzgtZjBhYi00MDZhLThhM2UtZjJkZmI0YzM2Y2JkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVDVPdmRESUR0aFdWdlpcL0F6eTU4MzlhUEhUSDRvamZlWWtJelhYWEtZcVwvTzZaeENld0lKOVJOZVdMNU5UeEdwIn0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This version is good. Reviewed-by: Liming Gao > -----Original Message----- > From: Zhang, Shenglei > Sent: Friday, September 20, 2019 10:29 AM > To: devel@edk2.groups.io > Cc: Zhang, Shenglei ; Feng, Bob C ; Gao, Liming > Subject: [PATCH v4] BaseTools/LzmaCompress: Add two switches >=20 > From: "Zhang, Shenglei" >=20 > 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) >=20 > Cc: Bob Feng > Cc: Liming Gao > Signed-off-by: Shenglei Zhang > --- >=20 > v2: 1.Update DictionarySize to mDictionarySize. > 2.Update CompressionMode to mCompressionMode. > 3.Use CLzmaEncProps *props as the input parameter of the > function Encode. >=20 > v3: Remove the component "mDictionarySize >=3D 0" in the if judgement.lin= e 303 > This is to fix the build failure under Mac OS. Beacuse the type of > mDictionarySize is UINT64, which is always >=3D 0. >=20 > v4: Update type of "props" when declaring and the consequent usage. > The encoding functionality has been tested under Windows OS, Linux OS= and > Mac OS. >=20 > .../Source/C/LzmaCompress/LzmaCompress.c | 41 +++++++++++++++---- > BaseTools/Source/C/LzmaCompress/GNUmakefile | 4 +- > BaseTools/Source/C/LzmaCompress/Makefile | 4 +- > 3 files changed, 38 insertions(+), 11 deletions(-) >=20 > diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/S= ource/C/LzmaCompress/LzmaCompress.c > index a3607f9b2084..856fcf9ffb17 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 = file"; > 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, defau= lt: 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_V= ERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION); > } >=20 > -static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UIn= t64 fileSize) > +static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UIn= t64 fileSize, CLzmaEncProps *props) > { > SRes res; > size_t inSize =3D (size_t)fileSize; > @@ -95,10 +102,6 @@ static SRes Encode(ISeqOutStream *outStream, ISeqInSt= ream *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, ISeqInSt= ream *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,10 @@ int main2(int numArgs, const char *args[], char *rs) > const char *outputFile =3D "file.tmp"; > int param; > UInt64 fileSize; > + CLzmaEncProps props; > + > + LzmaEncProps_Init(&props); > + LzmaEncProps_Normalize(&props); >=20 > FileSeqInStream_CreateVTable(&inStream); > File_Construct(&inStream.file); > @@ -280,6 +287,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 +360,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/Sour= ce/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 > -- > 2.18.0.windows.1