Add option to select decompression algorithm to test suite.
This commit is contained in:
parent
f2090df7a5
commit
5ac76b68c9
@ -39,9 +39,9 @@ using namespace nv;
|
|||||||
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
|
uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
|
||||||
{
|
{
|
||||||
// Does bit expansion before interpolation.
|
// Does bit expansion before interpolation.
|
||||||
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
|
|
||||||
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
|
||||||
color_array[0].r = (col0.r << 3) | (col0.r >> 2);
|
color_array[0].r = (col0.r << 3) | (col0.r >> 2);
|
||||||
|
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
||||||
|
color_array[0].b = (col0.b << 3) | (col0.b >> 2);
|
||||||
color_array[0].a = 0xFF;
|
color_array[0].a = 0xFF;
|
||||||
|
|
||||||
// @@ Same as above, but faster?
|
// @@ Same as above, but faster?
|
||||||
@ -97,14 +97,14 @@ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const
|
|||||||
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
|
uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
|
||||||
{
|
{
|
||||||
// Does bit expansion before interpolation.
|
// Does bit expansion before interpolation.
|
||||||
color_array[0].b = col0.b * 22 / 8;
|
color_array[0].r = (3 * col0.r * 22) / 8;
|
||||||
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
color_array[0].g = (col0.g << 2) | (col0.g >> 4);
|
||||||
color_array[0].r = col0.r * 22 / 8;
|
color_array[0].b = (3 * col0.b * 22) / 8;
|
||||||
color_array[0].a = 0xFF;
|
color_array[0].a = 0xFF;
|
||||||
|
|
||||||
color_array[1].r = col1.r * 22 / 8;
|
color_array[1].r = (3 * col1.r * 22) / 8;
|
||||||
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
|
color_array[1].g = (col1.g << 2) | (col1.g >> 4);
|
||||||
color_array[1].b = col1.b * 22 / 8;
|
color_array[1].b = (3 * col1.b * 22) / 8;
|
||||||
color_array[1].a = 0xFF;
|
color_array[1].a = 0xFF;
|
||||||
|
|
||||||
if( col0.u > col1.u ) {
|
if( col0.u > col1.u ) {
|
||||||
@ -117,8 +117,8 @@ uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const
|
|||||||
color_array[3].r = (2 * col1.r + col0.r) * 22 / 8;
|
color_array[3].r = (2 * col1.r + col0.r) * 22 / 8;
|
||||||
color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256;
|
color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256;
|
||||||
color_array[3].b = (2 * col1.b + col0.b) * 22 / 8;
|
color_array[3].b = (2 * col1.b + col0.b) * 22 / 8;
|
||||||
color_array[3].a = 0xFF;
|
|
||||||
|
|
||||||
|
color_array[3].a = 0xFF;
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -207,6 +207,25 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const
|
||||||
|
{
|
||||||
|
nvDebugCheck(block != NULL);
|
||||||
|
|
||||||
|
// Decode color block.
|
||||||
|
Color32 color_array[4];
|
||||||
|
evaluatePalette(color_array);
|
||||||
|
evaluatePaletteNV5x(color_array);
|
||||||
|
|
||||||
|
// Write color block.
|
||||||
|
for( uint j = 0; j < 4; j++ ) {
|
||||||
|
for( uint i = 0; i < 4; i++ ) {
|
||||||
|
uint idx = (row[j] >> (2 * i)) & 3;
|
||||||
|
block->color(i, j) = color_array[idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BlockDXT1::setIndices(int * idx)
|
void BlockDXT1::setIndices(int * idx)
|
||||||
{
|
{
|
||||||
indices = 0;
|
indices = 0;
|
||||||
|
@ -53,6 +53,7 @@ namespace nv
|
|||||||
void evaluatePalette4(Color32 color_array[4]) const;
|
void evaluatePalette4(Color32 color_array[4]) const;
|
||||||
|
|
||||||
void decodeBlock(ColorBlock * block) const;
|
void decodeBlock(ColorBlock * block) const;
|
||||||
|
void decodeBlockNV5x(ColorBlock * block) const;
|
||||||
|
|
||||||
void setIndices(int * idx);
|
void setIndices(int * idx);
|
||||||
|
|
||||||
|
@ -119,6 +119,11 @@ static ImageSet s_imageSets[] = {
|
|||||||
};
|
};
|
||||||
const int s_imageSetCount = sizeof(s_imageSets)/sizeof(s_imageSets[0]);
|
const int s_imageSetCount = sizeof(s_imageSets)/sizeof(s_imageSets[0]);
|
||||||
|
|
||||||
|
enum Decoder
|
||||||
|
{
|
||||||
|
Decoder_Reference,
|
||||||
|
Decoder_NVIDIA,
|
||||||
|
};
|
||||||
|
|
||||||
struct MyOutputHandler : public nvtt::OutputHandler
|
struct MyOutputHandler : public nvtt::OutputHandler
|
||||||
{
|
{
|
||||||
@ -145,7 +150,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image * decompress(nvtt::Format format)
|
Image * decompress(nvtt::Format format, Decoder decoder)
|
||||||
{
|
{
|
||||||
int bw = (m_width + 3) / 4;
|
int bw = (m_width + 3) / 4;
|
||||||
int bh = (m_height + 3) / 4;
|
int bh = (m_height + 3) / 4;
|
||||||
@ -162,7 +167,12 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
for (int x = 0; x < bw; x++)
|
for (int x = 0; x < bw; x++)
|
||||||
{
|
{
|
||||||
ColorBlock colors;
|
ColorBlock colors;
|
||||||
block->decodeBlock(&colors);
|
if (decoder == Decoder_Reference) {
|
||||||
|
block->decodeBlock(&colors);
|
||||||
|
}
|
||||||
|
else if (decoder == Decoder_NVIDIA) {
|
||||||
|
block->decodeBlockNV5x(&colors);
|
||||||
|
}
|
||||||
|
|
||||||
for (int yy = 0; yy < 4; yy++)
|
for (int yy = 0; yy < 4; yy++)
|
||||||
{
|
{
|
||||||
@ -235,6 +245,7 @@ int main(int argc, char *argv[])
|
|||||||
bool fast = false;
|
bool fast = false;
|
||||||
bool nocuda = false;
|
bool nocuda = false;
|
||||||
bool showHelp = false;
|
bool showHelp = false;
|
||||||
|
Decoder decoder = Decoder_Reference;
|
||||||
const char * basePath = "";
|
const char * basePath = "";
|
||||||
const char * outPath = "output";
|
const char * outPath = "output";
|
||||||
const char * regressPath = NULL;
|
const char * regressPath = NULL;
|
||||||
@ -249,6 +260,13 @@ int main(int argc, char *argv[])
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strcmp("-dec", argv[i]) == 0)
|
||||||
|
{
|
||||||
|
if (i+1 < argc && argv[i+1][0] != '-') {
|
||||||
|
decoder = (Decoder)atoi(argv[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strcmp("-fast", argv[i]) == 0)
|
else if (strcmp("-fast", argv[i]) == 0)
|
||||||
{
|
{
|
||||||
fast = true;
|
fast = true;
|
||||||
@ -289,9 +307,16 @@ int main(int argc, char *argv[])
|
|||||||
printf("usage: nvtestsuite [options]\n\n");
|
printf("usage: nvtestsuite [options]\n\n");
|
||||||
|
|
||||||
printf("Input options:\n");
|
printf("Input options:\n");
|
||||||
printf(" -path <path>\tInput image path.\n");
|
printf(" -path <path> \tInput image path.\n");
|
||||||
printf(" -set [0:2]\tImage set.\n");
|
|
||||||
printf(" -regress <path>\tRegression directory.\n");
|
printf(" -regress <path>\tRegression directory.\n");
|
||||||
|
printf(" -set [0:2] \tImage set.\n");
|
||||||
|
printf(" 0: \tKodak.\n");
|
||||||
|
printf(" 1: \tWaterloo.\n");
|
||||||
|
printf(" 2: \tEpic.\n");
|
||||||
|
printf(" 3: \tFarbrausch.\n");
|
||||||
|
printf(" -dec x \tDecompressor.\n");
|
||||||
|
printf(" 0: \tReference.\n");
|
||||||
|
printf(" 1: \tNVIDIA.\n");
|
||||||
|
|
||||||
printf("Compression options:\n");
|
printf("Compression options:\n");
|
||||||
printf(" -fast \tFast compression.\n");
|
printf(" -fast \tFast compression.\n");
|
||||||
@ -365,7 +390,7 @@ int main(int argc, char *argv[])
|
|||||||
printf(" Time: \t%.3f sec\n", float(end-start) / CLOCKS_PER_SEC);
|
printf(" Time: \t%.3f sec\n", float(end-start) / CLOCKS_PER_SEC);
|
||||||
totalTime += float(end-start);
|
totalTime += float(end-start);
|
||||||
|
|
||||||
AutoPtr<Image> img_out( outputHandler.decompress(nvtt::Format_BC1) );
|
AutoPtr<Image> img_out( outputHandler.decompress(nvtt::Format_BC1, decoder) );
|
||||||
|
|
||||||
Path outputFileName;
|
Path outputFileName;
|
||||||
outputFileName.format("%s/%s", outPath, fileNames[i]);
|
outputFileName.format("%s/%s", outPath, fileNames[i]);
|
||||||
|
Loading…
Reference in New Issue
Block a user