diff --git a/EtcLib/Etc/EtcFilter.cpp b/EtcLib/Etc/EtcFilter.cpp index 298e144..bc899a5 100644 --- a/EtcLib/Etc/EtcFilter.cpp +++ b/EtcLib/Etc/EtcFilter.cpp @@ -6,7 +6,7 @@ namespace Etc { -static const double M_PI = 3.14159265358979323846; +static const double PiConst = 3.14159265358979323846; inline double sinc(double x) { @@ -15,7 +15,7 @@ inline double sinc(double x) return 1.0; } - return sin(M_PI * x) / (M_PI * x); + return sin(PiConst * x) / (PiConst * x); } //inline float sincf( float x ) @@ -296,10 +296,10 @@ int FilterTwoPass( RGBCOLOR *pSrcImage, int srcWidth, int srcHeight, } pPixel = pDestImage + (iRow * destWidth) + iCol; - pPixel->rgba[0] = (unsigned char)(__max( 0, __min( 255.0, dRed))); - pPixel->rgba[1] = (unsigned char)(__max( 0, __min( 255.0, dGreen))); - pPixel->rgba[2] = (unsigned char)(__max( 0, __min( 255.0, dBlue))); - pPixel->rgba[3] = (unsigned char)(__max( 0, __min( 255.0, dAlpha))); + pPixel->rgba[0] = (unsigned char)(std::max( 0.0, std::min( 255.0, dRed))); + pPixel->rgba[1] = (unsigned char)(std::max( 0.0, std::min( 255.0, dGreen))); + pPixel->rgba[2] = (unsigned char)(std::max( 0.0, std::min( 255.0, dBlue))); + pPixel->rgba[3] = (unsigned char)(std::max( 0.0, std::min( 255.0, dAlpha))); } } diff --git a/EtcTool/EtcSourceImage.cpp b/EtcTool/EtcSourceImage.cpp index 0c64fea..fcb1ac0 100644 --- a/EtcTool/EtcSourceImage.cpp +++ b/EtcTool/EtcSourceImage.cpp @@ -97,12 +97,12 @@ namespace Etc { unsigned char* paucPixels = nullptr; - int iWidth; - int iHeight; - int iBitsPerPixel; + int iWidth = 0; + int iHeight = 0; bool bool16BitImage = false; #if USE_STB_IMAGE_LOAD + int iBitsPerPixel; //if stb_iamge is available, only use it to load files other than png char *fileExt = strrchr(m_pstrFilename, '.'); diff --git a/README.md b/README.md index 632f72a..96678f1 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Options: -effort number between 0 and 100 to specify the encoding quality (100 is the highest quality) -errormetric specify the error metric, the options are - rgba, rec709, numeric and normalxyz + rgba, rgbx, rec709, numeric and normalxyz -format ETC1, RGB8, SRGB8, RGBA8, SRGB8, RGB8A1, SRGB8A1 or R11 -help prints this message @@ -120,6 +120,8 @@ Options: -normalizexyz normalize RGB to have a length of 1 -verbose or -v shows status information during the encoding process + -mipmaps or -m sets the maximum number of mipaps to generate (default=1) + -mipwrap or -w sets the mipmap filter wrap mode (default=clamp) * -analyze will run an analysis of the encoding and place it in folder "analysis_folder" (e.g. ../analysis/kodim05). within the analysis_folder, a folder @@ -140,10 +142,12 @@ will dictate what error analysis is used in the comparison. to apply during the encoding. * -errormetric selects the fitting algorithm used by the encoder. "rgba" calculates -RMS error using RGB components that are weighted by A. "rec709" is similar to "rgba", -except the RGB components are also weighted according to Rec709. "numeric" -calculates RMS error using unweighted RGBA components. "normalize" calculates error -based on dot product and vector length for RGB and RMS error for A. +RMS error using RGB components that are weighted by A. "rgbx" calculates RMS error +using RGBA components, where A is treated as an additional data channel, instead of +as alpha. "rec709" is similar to "rgba", except the RGB components are also weighted +according to Rec709. "numeric" calculates RMS error using unweighted RGBA components. +"normalize" calculates error based on dot product and vector length for RGB and RMS +error for A. * -help prints out the usage message @@ -154,6 +158,14 @@ based on dot product and vector length for RGB and RMS error for A. * -verbose shows information on the current encoding process. It will then display the PSNR and time time it took to encode the image. +* -mipmaps takes an argument that specifies how many mipmaps to generate from the +source image. The mipmaps are generated with a lanczos3 filter using edge clamping. +If the mipmaps option is not specified no mipmaps are created. + +* -mipwrap takes an argument that specifies the mipmap filter wrap mode. The options +are "x", "y" and "xy" which specify wrapping in x only, y only or x and y respectively. +The default options are clamping in both x and y. + Note: Path names can use slashes or backslashes. The tool will convert the slashes to the appropriate polarity for the current platform.