From 20c504056f74ae576dc74c7e93fc781adc0d8b33 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 8 Oct 2012 18:51:41 -0400 Subject: [PATCH] - Add flag to specify whether or not we'd like to collect stats - Fix amount of interpolation points to use during shape estimation --- BPTCEncoder/src/BC7Compressor.cpp | 7 +++---- CLTool/src/clunix.cpp | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/BPTCEncoder/src/BC7Compressor.cpp b/BPTCEncoder/src/BC7Compressor.cpp index 0d5d632..6289471 100755 --- a/BPTCEncoder/src/BC7Compressor.cpp +++ b/BPTCEncoder/src/BC7Compressor.cpp @@ -37,7 +37,7 @@ #define ALIGN_SSE __attribute__((aligned(16))) #endif -#define USE_PCA_FOR_SHAPE_ESTIMATION +// #define USE_PCA_FOR_SHAPE_ESTIMATION enum EBlockStats { eBlockStat_Path, @@ -1710,7 +1710,7 @@ namespace BC7C error += 1.0; } #else - error += c.QuantizedError(Min, Max, 4, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); + error += c.QuantizedError(Min, Max, 8, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); #endif return error; } @@ -1730,7 +1730,6 @@ namespace BC7C double eigOne = c.GetPrincipalEigenvalue(); double eigTwo = c.GetSecondEigenvalue(); - // printf("EigOne: %08.3f\tEigTwo: %08.3f\n", eigOne, eigTwo); if(eigOne != 0.0) { error += eigTwo / eigOne; } @@ -1738,7 +1737,7 @@ namespace BC7C error += 1.0; } #else - error += c.QuantizedError(Min, Max, 4, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); + error += c.QuantizedError(Min, Max, 2, 0xFFFFFFFF, RGBAVector(w[0], w[1], w[2], w[3])); #endif return error; } diff --git a/CLTool/src/clunix.cpp b/CLTool/src/clunix.cpp index 64ebe60..bbc1c53 100644 --- a/CLTool/src/clunix.cpp +++ b/CLTool/src/clunix.cpp @@ -8,7 +8,7 @@ #include "Image.h" void PrintUsage() { - fprintf(stderr, "Usage: tc [-s|-t ] \n"); + fprintf(stderr, "Usage: tc [-l] [-q ] [-n ] [-simd] [-t [-j ]] \n"); } int main(int argc, char **argv) { @@ -24,6 +24,7 @@ int main(int argc, char **argv) { int numThreads = 1; int numCompressions = 1; bool bUseSIMD = false; + bool bSaveLog = false; bool knowArg = false; do { @@ -41,8 +42,15 @@ int main(int argc, char **argv) { knowArg = true; continue; } + + if(strcmp(argv[fileArg], "-l") == 0) { + fileArg++; + bSaveLog = true; + knowArg = true; + continue; + } - if(strcmp(argv[fileArg], "-s") == 0) { + if(strcmp(argv[fileArg], "-simd") == 0) { fileArg++; bUseSIMD = true; knowArg = true; @@ -90,6 +98,12 @@ int main(int argc, char **argv) { } while(knowArg && fileArg < argc); + if(numThreads > 1 && bSaveLog) { + bSaveLog = false; + fprintf(stderr, "WARNING: Will not save log because implementation is not thread safe.\n" + "If you'd like, send a complaint to pavel@cs.unc.edu to get this done faster.\n"); + } + if(fileArg == argc) { PrintUsage(); exit(1); @@ -105,7 +119,10 @@ int main(int argc, char **argv) { const Image *img = file.GetImage(); int numBlocks = (img->GetWidth() * img->GetHeight())/16; - BlockStatManager *statManager = new BlockStatManager(numBlocks); + BlockStatManager *statManager = NULL; + if(bSaveLog) { + statManager = new BlockStatManager(numBlocks); + } SCompressionSettings settings; settings.bUseSIMD = bUseSIMD; @@ -129,11 +146,14 @@ int main(int argc, char **argv) { fprintf(stderr, "Error computing PSNR\n"); } - statManager->ToFile(strcat(argv[fileArg], "-log.txt")); + if(bSaveLog) { + statManager->ToFile(strcat(argv[fileArg], ".log")); + } // Cleanup delete ci; - delete statManager; + if(statManager) + delete statManager; return 0; }