From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: liming.gao@intel.com) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Sun, 15 Sep 2019 22:28:24 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Sep 2019 22:28:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,510,1559545200"; d="scan'208";a="216088413" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 15 Sep 2019 22:28:23 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 15 Sep 2019 22:28:23 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 15 Sep 2019 22:28:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.32]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.86]) with mapi id 14.03.0439.000; Mon, 16 Sep 2019 13:28:21 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "Zhang, Shenglei" CC: "Feng, Bob C" Subject: Re: [edk2-devel] [PATCH] BaseTools/LzmaCompress: Add two switches Thread-Topic: [edk2-devel] [PATCH] BaseTools/LzmaCompress: Add two switches Thread-Index: AQHVaRN1f+z2X3ZlKk2fZB5TTSTmCactyxtg Date: Mon, 16 Sep 2019 05:28:20 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4F84D0@SHSMSX104.ccr.corp.intel.com> References: <20190912024028.39868-1-shenglei.zhang@intel.com> In-Reply-To: <20190912024028.39868-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 Shenglei: I add my comments.=20 Thanks Liming >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Zhang, Shenglei >Sent: Thursday, September 12, 2019 10:40 AM >To: devel@edk2.groups.io >Cc: Feng, Bob C ; Gao, Liming >Subject: [edk2-devel] [PATCH] BaseTools/LzmaCompress: Add two switches > >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 >--- > .../Source/C/LzmaCompress/LzmaCompress.c | 39 +++++++++++++++---- > BaseTools/Source/C/LzmaCompress/Makefile | 4 +- > 2 files changed, 34 insertions(+), 9 deletions(-) > >diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c >b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c >index a3607f9b2084..e18a1e0365f6 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 > >- 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 > > **/ >@@ -23,6 +23,7 @@ > #include "Sdk/C/LzmaEnc.h" > #include "Sdk/C/Bra.h" > #include "CommonLib.h" >+#include "ParseInf.h" > > #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8) > >@@ -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"; > > static Bool mQuietMode =3D False; > static CONVERTER_TYPE mConType =3D NoConverter; > >+UINT64 DictionarySize =3D 31; >+UINT64 CompressionMode =3D 2; Module level global variable is with "m" as the prefix name.=20 >+ > #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_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION); > } > >-static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, >UInt64 fileSize) >+static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, >UInt64 fileSize, CLzmaEncProps props) Please use CLzmaEncProps *props as the function input parameter.=20 Thanks Liming > { > SRes res; > size_t inSize =3D (size_t)fileSize; >@@ -95,10 +102,6 @@ static SRes Encode(ISeqOutStream *outStream, >ISeqInStream *inStream, UInt64 file > Byte *outBuffer =3D 0; > Byte *filteredStream =3D 0; > size_t outSize; >- CLzmaEncProps props; >- >- LzmaEncProps_Init(&props); >- LzmaEncProps_Normalize(&props); > > if (inSize !=3D 0) { > inBuffer =3D (Byte *)MyAlloc(inSize); >@@ -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); > > 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,&CompressionMode); >+ if ((CompressionMode =3D=3D 0)||(CompressionMode =3D=3D 1)){ >+ props.algo =3D (int)CompressionMode; >+ =09param++; >+ continue; >+ } else { >+ return PrintError(rs, kInvalidParamValMessage); >+ } >+ } else if (strcmp(args[param], "d") =3D=3D 0) { >+ AsciiStringToUint64(args[param + 1],FALSE,&DictionarySize); >+ if ((DictionarySize >=3D 0)&&(DictionarySize <=3D 30)){ >+ props.dictSize =3D (UINT32)DictionarySize; >+ =09param++; >+ 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/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 > > APPNAME =3D LzmaCompress > >-#LIBS =3D $(LIB_PATH)\Common.lib >+LIBS =3D $(LIB_PATH)\Common.lib > > SDK_C =3D Sdk\C > >-- >2.18.0.windows.1 > > >