From aff59c22b8dfc9e8b356cab52ac98c1146e4461a Mon Sep 17 00:00:00 2001 From: castano Date: Fri, 14 Mar 2008 08:40:11 +0000 Subject: [PATCH] remove unused compressors --- src/nvtt/FastCompressDXT.cpp | 220 ----------------------------------- src/nvtt/FastCompressDXT.h | 3 - 2 files changed, 223 deletions(-) diff --git a/src/nvtt/FastCompressDXT.cpp b/src/nvtt/FastCompressDXT.cpp index b45165f..150290e 100644 --- a/src/nvtt/FastCompressDXT.cpp +++ b/src/nvtt/FastCompressDXT.cpp @@ -354,29 +354,6 @@ void nv::compressBlock_BoundsRangeAlpha(const ColorBlock & rgba, BlockDXT1 * blo } -// Compressor that uses the best fit axis. -void nv::compressBlock_BestFitAxis(const ColorBlock & rgba, BlockDXT1 * block) -{ - Color32 c0, c1; - rgba.bestFitRange(&c0, &c1); - - block->col0 = toColor16(c0); - block->col1 = toColor16(c1); - - // Use 4 color mode only. - if (block->col0.u < block->col1.u) { - swap(block->col0.u, block->col1.u); - } - else if (block->col0.u == block->col1.u) { - block->col0.u++; - } - - Color32 palette[4]; - block->evaluatePalette4(palette); - - block->indices = computeIndices(rgba, palette); -} - // Compressor that tests all input color pairs. void nv::compressBlock_TestAllPairs(const ColorBlock & rgba, BlockDXT1 * block) @@ -413,203 +390,6 @@ void nv::compressBlock_TestAllPairs(const ColorBlock & rgba, BlockDXT1 * block) } -// Compressor that tests all pairs in the best fit axis. -void nv::compressBlock_AnalyzeBestFitAxis(const ColorBlock & rgba, BlockDXT1 * block) -{ - uint best_error = uint(-1); - Color16 best_col0, best_col1; - - Color32 palette[4]; - - - // Find bounds of the search space. - int r_min = 32; - int r_max = 0; - int g_min = 64; - int g_max = 0; - int b_min = 32; - int b_max = 0; - - for(uint i = 0; i < 16; i++) { - Color16 color = toColor16(rgba.color(i)); - - r_min = min(r_min, int(color.r)); - r_max = max(r_max, int(color.r)); - g_min = min(g_min, int(color.g)); - g_max = max(g_max, int(color.g)); - b_min = min(b_min, int(color.b)); - b_max = max(b_max, int(color.b)); - } - - const int r_pad = 4 * max(1, (r_max - r_min)); - const int g_pad = 4 * max(1, (g_max - g_min)); - const int b_pad = 4 * max(1, (b_max - b_min)); - - r_min = max(0, r_min - r_pad); - r_max = min(31, r_max + r_pad); - g_min = max(0, g_min - g_pad); - g_max = min(63, g_max + g_pad); - b_min = max(0, b_min - b_pad); - b_max = min(31, b_max + b_pad); - - const Line3 line = rgba.bestFitLine(); - - if( fabs(line.direction().x()) > fabs(line.direction().y()) && fabs(line.direction().x()) > fabs(line.direction().z()) ) { - for(int r0 = r_min; r0 <= r_max; r0++) { - const float x0 = float((r0 << 3) | (r0 >> 2)); - const float t0 = (x0 - line.origin().x()) / line.direction().x(); - const float y0 = line.origin().y() + t0 * line.direction().y(); - const float z0 = line.origin().z() + t0 * line.direction().z(); - - const int g0 = clamp(int(y0), 0, 255) >> 2; - const int b0 = clamp(int(z0), 0, 255) >> 3; - - for(int r1 = r_min; r1 <= r_max; r1++) { - const float x1 = float((r1 << 3) | (r1 >> 2)); - const float t1 = (x1 - line.origin().x()) / line.direction().x(); - const float y1 = line.origin().y() + t1 * line.direction().y(); - const float z1 = line.origin().z() + t1 * line.direction().z(); - - const int g1 = clamp(int(y1), 0, 255) >> 2; - const int b1 = clamp(int(z1), 0, 255) >> 3; - - // Test one pixel around. - for (int i0 = -1; i0 <= 1; i0++) { - for (int j0 = -1; j0 <= 1; j0++) { - for (int i1 = -1; i1 <= 1; i1++) { - for (int j1 = -1; j1 <= 1; j1++) { - if( g0+i0 >= 0 && g0+i0 < 64 && g1+i1 >= 0 && g1+i1 < 64 && - b0+j0 >= 0 && b0+j0 < 32 && b1+j1 >= 0 && b1+j1 < 32 ) - { - block->col0.r = r0; - block->col0.g = g0 + i0; - block->col0.b = b0 + j0; - block->col1.r = r1; - block->col1.g = g1 + i1; - block->col1.b = b1 + j1; - block->evaluatePalette(palette); - - const uint error = paletteError(rgba, palette); - if(error < best_error) { - best_error = error; - best_col0 = block->col0; - best_col1 = block->col1; - } - } - } - } - } - } - } - } - } - else if( fabs(line.direction().y()) > fabs(line.direction().z()) ) { - for(int g0 = g_min; g0 <= g_max; g0++) { - const float y0 = float((g0 << 2) | (g0 >> 4)); - const float t0 = (y0 - line.origin().y()) / line.direction().y(); - const float x0 = line.origin().x() + t0 * line.direction().x(); - const float z0 = line.origin().z() + t0 * line.direction().z(); - - const int r0 = clamp(int(x0), 0, 255) >> 3; - const int b0 = clamp(int(z0), 0, 255) >> 3; - - for(int g1 = g_min; g1 <= g_max; g1++) { - const float y1 = float((g1 << 2) | (g1 >> 4)); - const float t1 = (y1 - line.origin().y()) / line.direction().y(); - const float x1 = line.origin().x() + t1 * line.direction().x(); - const float z1 = line.origin().z() + t1 * line.direction().z(); - - const int r1 = clamp(int(x1), 0, 255) >> 2; - const int b1 = clamp(int(z1), 0, 255) >> 3; - - // Test one pixel around. - for (int i0 = -1; i0 <= 1; i0++) { - for (int j0 = -1; j0 <= 1; j0++) { - for (int i1 = -1; i1 <= 1; i1++) { - for (int j1 = -1; j1 <= 1; j1++) { - if( r0+i0 >= 0 && r0+i0 < 32 && r1+i1 >= 0 && r1+i1 < 32 && - b0+j0 >= 0 && b0+j0 < 32 && b1+j1 >= 0 && b1+j1 < 32 ) - { - block->col0.r = r0 + i0; - block->col0.g = g0; - block->col0.b = b0 + j0; - block->col1.r = r1 + i1; - block->col1.g = g1; - block->col1.b = b1 + j1; - block->evaluatePalette(palette); - - const uint error = paletteError(rgba, palette); - if(error < best_error) { - best_error = error; - best_col0 = block->col0; - best_col1 = block->col1; - } - } - } - } - } - } - } - } - } - else { - for(int b0 = b_min; b0 <= b_max; b0++) { - const float z0 = float((b0 << 3) | (b0 >> 2)); - const float t0 = (z0 - line.origin().z()) / line.direction().z(); - const float y0 = line.origin().y() + t0 * line.direction().y(); - const float x0 = line.origin().x() + t0 * line.direction().x(); - - const int g0 = clamp(int(y0), 0, 255) >> 2; - const int r0 = clamp(int(x0), 0, 255) >> 3; - - for(int b1 = b_min; b1 <= b_max; b1++) { - const float z1 = float((b1 << 3) | (b1 >> 2)); - const float t1 = (z1 - line.origin().z()) / line.direction().z(); - const float y1 = line.origin().y() + t1 * line.direction().y(); - const float x1 = line.origin().x() + t1 * line.direction().x(); - - const int g1 = clamp(int(y1), 0, 255) >> 2; - const int r1 = clamp(int(x1), 0, 255) >> 3; - - // Test one pixel around. - for (int i0 = -1; i0 <= 1; i0++) { - for (int j0 = -1; j0 <= 1; j0++) { - for (int i1 = -1; i1 <= 1; i1++) { - for (int j1 = -1; j1 <= 1; j1++) { - if( g0+i0 >= 0 && g0+i0 < 64 && g1+i1 >= 0 && g1+i1 < 64 && - r0+j0 >= 0 && r0+j0 < 32 && r1+j1 >= 0 && r1+j1 < 32 ) - { - block->col0.r = r0 + j0; - block->col0.g = g0 + i0; - block->col0.b = b0; - block->col1.r = r1 + j1; - block->col1.g = g1 + i1; - block->col1.b = b1; - block->evaluatePalette(palette); - - const uint error = paletteError(rgba, palette); - if(error < best_error) { - best_error = error; - best_col0 = block->col0; - best_col1 = block->col1; - } - } - } - } - } - } - } - } - } - - block->col0 = best_col0; - block->col1 = best_col1; - block->evaluatePalette(palette); - - block->indices = computeIndices(rgba, palette); -} - - // Improve palette iteratively using alternate 3d search as suggested by Dave Moore. void nv::refineSolution_3dSearch(const ColorBlock & rgba, BlockDXT1 * block) { diff --git a/src/nvtt/FastCompressDXT.h b/src/nvtt/FastCompressDXT.h index be9f619..6ffe23a 100644 --- a/src/nvtt/FastCompressDXT.h +++ b/src/nvtt/FastCompressDXT.h @@ -49,9 +49,6 @@ namespace nv // Compressor that uses bounding box and takes alpha into account. void compressBlock_BoundsRangeAlpha(const ColorBlock & rgba, BlockDXT1 * block); - // Compressor that uses the best fit axis. - void compressBlock_BestFitAxis(const ColorBlock & rgba, BlockDXT1 * block); - // Simple, but slow compressor that tests all color pairs. void compressBlock_TestAllPairs(const ColorBlock & rgba, BlockDXT1 * block);