More cleanup.
This commit is contained in:
parent
9ae9ec1975
commit
c8bf853ba4
@ -9,7 +9,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
|
|
||||||
See the License for the specific language governing permissions and limitations under the License.
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef _BITS_H
|
#ifndef _BITS_H
|
||||||
#define _BITS_H
|
#define _BITS_H
|
||||||
|
|
||||||
@ -70,4 +70,4 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
|
|
||||||
See the License for the specific language governing permissions and limitations under the License.
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef _SHAPES_TWO_H
|
#ifndef _SHAPES_TWO_H
|
||||||
#define _SHAPES_TWO_H
|
#define _SHAPES_TWO_H
|
||||||
|
|
||||||
|
@ -9,19 +9,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
|
|
||||||
See the License for the specific language governing permissions and limitations under the License.
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef _TILE_H
|
#ifndef _TILE_H
|
||||||
#define _TILE_H
|
#define _TILE_H
|
||||||
|
|
||||||
//#include <ImfArray.h>
|
|
||||||
//#include <ImfRgba.h>
|
|
||||||
//#include <half.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include "nvmath/Vector.h"
|
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define DBL_MAX (1.0e37) // doesn't have to be really dblmax, just bigger than any possible squared error
|
#include "nvmath/Vector.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
//#define USE_IMPORTANCE_MAP 1 // define this if you want to increase importance of some pixels in tile
|
//#define USE_IMPORTANCE_MAP 1 // define this if you want to increase importance of some pixels in tile
|
||||||
class Tile
|
class Tile
|
||||||
@ -81,32 +78,6 @@ public:
|
|||||||
Vector3 data[TILE_H][TILE_W];
|
Vector3 data[TILE_H][TILE_W];
|
||||||
float importance_map[TILE_H][TILE_W];
|
float importance_map[TILE_H][TILE_W];
|
||||||
int size_x, size_y; // actual size of tile
|
int size_x, size_y; // actual size of tile
|
||||||
|
|
||||||
// pixels -> tile
|
|
||||||
/*void inline insert(const Array2D<Rgba> &pixels, int x, int y)
|
|
||||||
{
|
|
||||||
for (int y0=0; y0<size_y; ++y0)
|
|
||||||
for (int x0=0; x0<size_x; ++x0)
|
|
||||||
{
|
|
||||||
data[y0][x0].x = half2float((pixels[y+y0][x+x0]).r);
|
|
||||||
data[y0][x0].y = half2float((pixels[y+y0][x+x0]).g);
|
|
||||||
data[y0][x0].z = half2float((pixels[y+y0][x+x0]).b);
|
|
||||||
}
|
|
||||||
generate_importance_map();
|
|
||||||
}
|
|
||||||
|
|
||||||
// tile -> pixels
|
|
||||||
void inline extract(Array2D<Rgba> &pixels, int x, int y)
|
|
||||||
{
|
|
||||||
for (int y0=0; y0<size_y; ++y0)
|
|
||||||
for (int x0=0; x0<size_x; ++x0)
|
|
||||||
{
|
|
||||||
pixels[y+y0][x+x0].r = float2half(data[y0][x0].x);
|
|
||||||
pixels[y+y0][x+x0].g = float2half(data[y0][x0].y);
|
|
||||||
pixels[y+y0][x+x0].b = float2half(data[y0][x0].z);
|
|
||||||
pixels[y+y0][x+x0].a = 0; // set it to a known value
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _TILE_H
|
||||||
|
@ -13,17 +13,15 @@ See the License for the specific language governing permissions and limitations
|
|||||||
// Utility and common routines
|
// Utility and common routines
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
//#include <half.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
static int denom7_weights_64[] = {0, 9, 18, 27, 37, 46, 55, 64}; // divided by 64
|
static int denom7_weights_64[] = {0, 9, 18, 27, 37, 46, 55, 64}; // divided by 64
|
||||||
static int denom15_weights_64[] = {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}; // divided by 64
|
static int denom15_weights_64[] = {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}; // divided by 64
|
||||||
|
|
||||||
int Utils::lerp(int a, int b, int i, int denom)
|
int Utils::lerp(int a, int b, int i, int denom)
|
||||||
{
|
{
|
||||||
assert (denom == 3 || denom == 7 || denom == 15);
|
nvDebugCheck (denom == 3 || denom == 7 || denom == 15);
|
||||||
assert (i >= 0 && i <= denom);
|
nvDebugCheck (i >= 0 && i <= denom);
|
||||||
|
|
||||||
int round = 32, shift = 6, *weights;
|
int round = 32, shift = 6, *weights;
|
||||||
|
|
||||||
@ -32,7 +30,7 @@ int Utils::lerp(int a, int b, int i, int denom)
|
|||||||
case 3: denom *= 5; i *= 5; // fall through to case 15
|
case 3: denom *= 5; i *= 5; // fall through to case 15
|
||||||
case 15: weights = denom15_weights_64; break;
|
case 15: weights = denom15_weights_64; break;
|
||||||
case 7: weights = denom7_weights_64; break;
|
case 7: weights = denom7_weights_64; break;
|
||||||
default: assert(0);
|
default: nvDebugCheck(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (a*weights[denom-i] +b*weights[i] + round) >> shift;
|
return (a*weights[denom-i] +b*weights[i] + round) >> shift;
|
||||||
@ -40,8 +38,8 @@ int Utils::lerp(int a, int b, int i, int denom)
|
|||||||
|
|
||||||
Vector3 Utils::lerp(const Vector3& a, const Vector3 &b, int i, int denom)
|
Vector3 Utils::lerp(const Vector3& a, const Vector3 &b, int i, int denom)
|
||||||
{
|
{
|
||||||
assert (denom == 3 || denom == 7 || denom == 15);
|
nvDebugCheck (denom == 3 || denom == 7 || denom == 15);
|
||||||
assert (i >= 0 && i <= denom);
|
nvDebugCheck (i >= 0 && i <= denom);
|
||||||
|
|
||||||
int shift = 6, *weights;
|
int shift = 6, *weights;
|
||||||
|
|
||||||
@ -50,7 +48,7 @@ Vector3 Utils::lerp(const Vector3& a, const Vector3 &b, int i, int denom)
|
|||||||
case 3: denom *= 5; i *= 5; // fall through to case 15
|
case 3: denom *= 5; i *= 5; // fall through to case 15
|
||||||
case 15: weights = denom15_weights_64; break;
|
case 15: weights = denom15_weights_64; break;
|
||||||
case 7: weights = denom7_weights_64; break;
|
case 7: weights = denom7_weights_64; break;
|
||||||
default: assert(0);
|
default: nvAssume(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to round these as this is an exact division
|
// no need to round these as this is an exact division
|
||||||
@ -93,7 +91,7 @@ void Utils::clamp(Vector3 &v)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert (0);
|
nvAssume (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,12 +130,12 @@ unsigned short Utils::format_to_ushort(int input)
|
|||||||
switch (Utils::FORMAT)
|
switch (Utils::FORMAT)
|
||||||
{
|
{
|
||||||
case UNSIGNED_F16:
|
case UNSIGNED_F16:
|
||||||
assert (input >= 0 && input <= F16MAX);
|
nvDebugCheck (input >= 0 && input <= F16MAX);
|
||||||
out = input;
|
out = input;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGNED_F16:
|
case SIGNED_F16:
|
||||||
assert (input >= -F16MAX && input <= F16MAX);
|
nvDebugCheck (input >= -F16MAX && input <= F16MAX);
|
||||||
// convert to sign-magnitude
|
// convert to sign-magnitude
|
||||||
int s;
|
int s;
|
||||||
if (input < 0) { s = F16S_MASK; input = -input; }
|
if (input < 0) { s = F16S_MASK; input = -input; }
|
||||||
@ -153,7 +151,7 @@ int Utils::quantize(float value, int prec)
|
|||||||
{
|
{
|
||||||
int q, ivalue, s;
|
int q, ivalue, s;
|
||||||
|
|
||||||
assert (prec > 1); // didn't bother to make it work for 1
|
nvDebugCheck (prec > 1); // didn't bother to make it work for 1
|
||||||
|
|
||||||
value = (float)floor(value + 0.5);
|
value = (float)floor(value + 0.5);
|
||||||
|
|
||||||
@ -162,14 +160,14 @@ int Utils::quantize(float value, int prec)
|
|||||||
switch (Utils::FORMAT)
|
switch (Utils::FORMAT)
|
||||||
{
|
{
|
||||||
case UNSIGNED_F16:
|
case UNSIGNED_F16:
|
||||||
assert (value >= 0 && value <= F16MAX);
|
nvDebugCheck (value >= 0 && value <= F16MAX);
|
||||||
ivalue = (int)value;
|
ivalue = (int)value;
|
||||||
q = ((ivalue << prec) + bias) / (F16MAX+1);
|
q = ((ivalue << prec) + bias) / (F16MAX+1);
|
||||||
assert (q >= 0 && q < (1 << prec));
|
nvDebugCheck (q >= 0 && q < (1 << prec));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGNED_F16:
|
case SIGNED_F16:
|
||||||
assert (value >= -F16MAX && value <= F16MAX);
|
nvDebugCheck (value >= -F16MAX && value <= F16MAX);
|
||||||
// convert to sign-magnitude
|
// convert to sign-magnitude
|
||||||
ivalue = (int)value;
|
ivalue = (int)value;
|
||||||
if (ivalue < 0) { s = 1; ivalue = -ivalue; } else s = 0;
|
if (ivalue < 0) { s = 1; ivalue = -ivalue; } else s = 0;
|
||||||
@ -177,7 +175,7 @@ int Utils::quantize(float value, int prec)
|
|||||||
q = ((ivalue << (prec-1)) + bias) / (F16MAX+1);
|
q = ((ivalue << (prec-1)) + bias) / (F16MAX+1);
|
||||||
if (s)
|
if (s)
|
||||||
q = -q;
|
q = -q;
|
||||||
assert (q > -(1 << (prec-1)) && q < (1 << (prec-1)));
|
nvDebugCheck (q > -(1 << (prec-1)) && q < (1 << (prec-1)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +202,7 @@ int Utils::unquantize(int q, int prec)
|
|||||||
{
|
{
|
||||||
int unq, s;
|
int unq, s;
|
||||||
|
|
||||||
assert (prec > 1); // not implemented for prec 1
|
nvDebugCheck (prec > 1); // not implemented for prec 1
|
||||||
|
|
||||||
switch (Utils::FORMAT)
|
switch (Utils::FORMAT)
|
||||||
{
|
{
|
||||||
@ -335,7 +333,7 @@ static void mpsnrmap(const Vector3 &in, int exposure, Vector3 &out)
|
|||||||
h = in.y; g = h;
|
h = in.y; g = h;
|
||||||
h = in.z; b = h;
|
h = in.z; b = h;
|
||||||
|
|
||||||
assert (exposure > -32 && exposure < 32);
|
nvDebugCheck (exposure > -32 && exposure < 32);
|
||||||
if (exposure > 0)
|
if (exposure > 0)
|
||||||
{
|
{
|
||||||
r *= 1 << exposure;
|
r *= 1 << exposure;
|
||||||
@ -419,13 +417,13 @@ void Utils::parse(const char *encoding, int &ptr, Field &field, int &endbit, int
|
|||||||
if (ptr <= 0) return;
|
if (ptr <= 0) return;
|
||||||
--ptr;
|
--ptr;
|
||||||
if (encoding[ptr] == ',') --ptr;
|
if (encoding[ptr] == ',') --ptr;
|
||||||
assert (encoding[ptr] == ']');
|
nvDebugCheck (encoding[ptr] == ']');
|
||||||
--ptr;
|
--ptr;
|
||||||
endbit = 0;
|
endbit = 0;
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
while (encoding[ptr] != ':' && encoding[ptr] != '[')
|
while (encoding[ptr] != ':' && encoding[ptr] != '[')
|
||||||
{
|
{
|
||||||
assert(encoding[ptr] >= '0' && encoding[ptr] <= '9');
|
nvDebugCheck(encoding[ptr] >= '0' && encoding[ptr] <= '9');
|
||||||
endbit += (encoding[ptr--] - '0') * scale;
|
endbit += (encoding[ptr--] - '0') * scale;
|
||||||
scale *= 10;
|
scale *= 10;
|
||||||
}
|
}
|
||||||
@ -437,7 +435,7 @@ void Utils::parse(const char *encoding, int &ptr, Field &field, int &endbit, int
|
|||||||
ptr--;
|
ptr--;
|
||||||
while (encoding[ptr] != '[')
|
while (encoding[ptr] != '[')
|
||||||
{
|
{
|
||||||
assert(encoding[ptr] >= '0' && encoding[ptr] <= '9');
|
nvDebugCheck(encoding[ptr] >= '0' && encoding[ptr] <= '9');
|
||||||
startbit += (encoding[ptr--] - '0') * scale;
|
startbit += (encoding[ptr--] - '0') * scale;
|
||||||
scale *= 10;
|
scale *= 10;
|
||||||
}
|
}
|
||||||
@ -448,13 +446,13 @@ void Utils::parse(const char *encoding, int &ptr, Field &field, int &endbit, int
|
|||||||
else if (encoding[ptr] == 'd') field = FIELD_D;
|
else if (encoding[ptr] == 'd') field = FIELD_D;
|
||||||
else {
|
else {
|
||||||
// it's wxyz
|
// it's wxyz
|
||||||
assert (encoding[ptr] >= 'w' && encoding[ptr] <= 'z');
|
nvDebugCheck (encoding[ptr] >= 'w' && encoding[ptr] <= 'z');
|
||||||
int foo = encoding[ptr--] - 'w';
|
int foo = encoding[ptr--] - 'w';
|
||||||
// now it is r g or b
|
// now it is r g or b
|
||||||
if (encoding[ptr] == 'r') foo += 10;
|
if (encoding[ptr] == 'r') foo += 10;
|
||||||
else if (encoding[ptr] == 'g') foo += 20;
|
else if (encoding[ptr] == 'g') foo += 20;
|
||||||
else if (encoding[ptr] == 'b') foo += 30;
|
else if (encoding[ptr] == 'b') foo += 30;
|
||||||
else assert(0);
|
else nvDebugCheck(0);
|
||||||
field = (Field) foo;
|
field = (Field) foo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,4 +70,4 @@ public:
|
|||||||
static Vector3 lerp(const Vector3 & a, const Vector3 & b, int i, int denom);
|
static Vector3 lerp(const Vector3 & a, const Vector3 & b, int i, int denom);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _UTILS_H
|
||||||
|
@ -9,16 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
|
|
||||||
See the License for the specific language governing permissions and limitations under the License.
|
See the License for the specific language governing permissions and limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#ifndef _ZOH_H
|
#ifndef _ZOH_H
|
||||||
#define _ZOH_H
|
#define _ZOH_H
|
||||||
|
|
||||||
//#include <string>
|
|
||||||
|
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
|
||||||
//using namespace std;
|
|
||||||
|
|
||||||
// UNUSED ZOH MODES are 0x13, 0x17, 0x1b, 0x1f
|
// UNUSED ZOH MODES are 0x13, 0x17, 0x1b, 0x1f
|
||||||
|
|
||||||
#define EXTERNAL_RELEASE 1 // define this if we're releasing this code externally
|
#define EXTERNAL_RELEASE 1 // define this if we're releasing this code externally
|
||||||
@ -39,14 +35,14 @@ struct FltEndpts
|
|||||||
|
|
||||||
struct IntEndpts
|
struct IntEndpts
|
||||||
{
|
{
|
||||||
int A[NCHANNELS];
|
int A[NCHANNELS];
|
||||||
int B[NCHANNELS];
|
int B[NCHANNELS];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ComprEndpts
|
struct ComprEndpts
|
||||||
{
|
{
|
||||||
unsigned int A[NCHANNELS];
|
uint A[NCHANNELS];
|
||||||
unsigned int B[NCHANNELS];
|
uint B[NCHANNELS];
|
||||||
};
|
};
|
||||||
|
|
||||||
class ZOH
|
class ZOH
|
||||||
@ -56,8 +52,6 @@ public:
|
|||||||
static const int BITSIZE=128;
|
static const int BITSIZE=128;
|
||||||
static Format FORMAT;
|
static Format FORMAT;
|
||||||
|
|
||||||
//static void compress(string inf, string zohf);
|
|
||||||
//static void decompress(string zohf, string outf);
|
|
||||||
static void compress(const Tile &t, char *block);
|
static void compress(const Tile &t, char *block);
|
||||||
static void decompress(const char *block, Tile &t);
|
static void decompress(const char *block, Tile &t);
|
||||||
|
|
||||||
@ -75,4 +69,4 @@ public:
|
|||||||
static bool isone(const char *block);
|
static bool isone(const char *block);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _ZOH_H
|
||||||
|
@ -20,7 +20,6 @@ See the License for the specific language governing permissions and limitations
|
|||||||
|
|
||||||
#include "nvmath/Fitting.h"
|
#include "nvmath/Fitting.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h> // strlen
|
#include <string.h> // strlen
|
||||||
#include <float.h> // FLT_MAX
|
#include <float.h> // FLT_MAX
|
||||||
|
|
||||||
@ -64,10 +63,10 @@ struct Pattern
|
|||||||
|
|
||||||
static Pattern patterns[NPATTERNS] =
|
static Pattern patterns[NPATTERNS] =
|
||||||
{
|
{
|
||||||
{{{16, 4}, {16, 4}, {16, 4}}, 1, 0x0f, 5, "bw[10],bw[11],bw[12],bw[13],bw[14],bw[15],bx[3:0],gw[10],gw[11],gw[12],gw[13],gw[14],gw[15],gx[3:0],rw[10],rw[11],rw[12],rw[13],rw[14],rw[15],rx[3:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]"},
|
16,4, 16,4, 16,4, 1, 0x0f, 5, "bw[10],bw[11],bw[12],bw[13],bw[14],bw[15],bx[3:0],gw[10],gw[11],gw[12],gw[13],gw[14],gw[15],gx[3:0],rw[10],rw[11],rw[12],rw[13],rw[14],rw[15],rx[3:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]",
|
||||||
{{{12, 8}, {12, 8}, {12, 8}}, 1, 0x0b, 5, "bw[10],bw[11],bx[7:0],gw[10],gw[11],gx[7:0],rw[10],rw[11],rx[7:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]"},
|
12,8, 12,8, 12,8, 1, 0x0b, 5, "bw[10],bw[11],bx[7:0],gw[10],gw[11],gx[7:0],rw[10],rw[11],rx[7:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]",
|
||||||
{{{11, 9}, {11, 9}, {11, 9}}, 1, 0x07, 5, "bw[10],bx[8:0],gw[10],gx[8:0],rw[10],rx[8:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]"},
|
11,9, 11,9, 11,9, 1, 0x07, 5, "bw[10],bx[8:0],gw[10],gx[8:0],rw[10],rx[8:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]",
|
||||||
{{{10,10}, {10,10}, {10,10}}, 0, 0x03, 5, "bx[9:0],gx[9:0],rx[9:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]"},
|
10,10, 10,10, 10,10, 0, 0x03, 5, "bx[9:0],gx[9:0],rx[9:0],bw[9:0],gw[9:0],rw[9:0],m[4:0]",
|
||||||
};
|
};
|
||||||
|
|
||||||
// mapping of mode to the corresponding index in pattern
|
// mapping of mode to the corresponding index in pattern
|
||||||
@ -159,7 +158,7 @@ static void swap_indices(IntEndpts endpts[NREGIONS_ONE], int indices[Tile::TILE_
|
|||||||
{
|
{
|
||||||
int x = index_positions[region] & 3;
|
int x = index_positions[region] & 3;
|
||||||
int y = (index_positions[region] >> 2) & 3;
|
int y = (index_positions[region] >> 2) & 3;
|
||||||
assert(REGION(x,y,shapeindex) == region); // double check the table
|
nvDebugCheck(REGION(x,y,shapeindex) == region); // double check the table
|
||||||
if (indices[y][x] & HIGH_INDEXBIT)
|
if (indices[y][x] & HIGH_INDEXBIT)
|
||||||
{
|
{
|
||||||
// high bit is set, swap the endpts and indices for this region
|
// high bit is set, swap the endpts and indices for this region
|
||||||
@ -221,7 +220,7 @@ static void write_header(const ComprEndpts endpts[NREGIONS_ONE], const Pattern &
|
|||||||
case FIELD_GZ:
|
case FIELD_GZ:
|
||||||
case FIELD_BY:
|
case FIELD_BY:
|
||||||
case FIELD_BZ:
|
case FIELD_BZ:
|
||||||
default: assert(0);
|
default: nvAssume(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,8 +234,8 @@ static void read_header(Bits &in, ComprEndpts endpts[NREGIONS_ONE], Pattern &p)
|
|||||||
|
|
||||||
int pat_index = mode_to_pat[mode];
|
int pat_index = mode_to_pat[mode];
|
||||||
|
|
||||||
assert (pat_index >= 0 && pat_index < NPATTERNS);
|
nvDebugCheck (pat_index >= 0 && pat_index < NPATTERNS);
|
||||||
assert (in.getptr() == patterns[pat_index].modebits);
|
nvDebugCheck (in.getptr() == patterns[pat_index].modebits);
|
||||||
|
|
||||||
p = patterns[pat_index];
|
p = patterns[pat_index];
|
||||||
|
|
||||||
@ -276,11 +275,11 @@ static void read_header(Bits &in, ComprEndpts endpts[NREGIONS_ONE], Pattern &p)
|
|||||||
case FIELD_GZ:
|
case FIELD_GZ:
|
||||||
case FIELD_BY:
|
case FIELD_BY:
|
||||||
case FIELD_BZ:
|
case FIELD_BZ:
|
||||||
default: assert(0);
|
default: nvAssume(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (in.getptr() == 128 - 63);
|
nvDebugCheck (in.getptr() == 128 - 63);
|
||||||
|
|
||||||
endpts[0].A[0] = rw; endpts[0].B[0] = rx;
|
endpts[0].A[0] = rw; endpts[0].B[0] = rx;
|
||||||
endpts[0].A[1] = gw; endpts[0].B[1] = gx;
|
endpts[0].A[1] = gw; endpts[0].B[1] = gx;
|
||||||
@ -307,7 +306,7 @@ static void emit_block(const ComprEndpts endpts[NREGIONS_ONE], int shapeindex, c
|
|||||||
|
|
||||||
write_indices(indices, shapeindex, out);
|
write_indices(indices, shapeindex, out);
|
||||||
|
|
||||||
assert(out.getptr() == ZOH::BITSIZE);
|
nvDebugCheck(out.getptr() == ZOH::BITSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_palette_quantized(const IntEndpts &endpts, int prec, Vector3 palette[NINDICES])
|
static void generate_palette_quantized(const IntEndpts &endpts, int prec, Vector3 palette[NINDICES])
|
||||||
@ -371,7 +370,7 @@ void ZOH::decompressone(const char *block, Tile &t)
|
|||||||
|
|
||||||
read_indices(in, shapeindex, indices);
|
read_indices(in, shapeindex, indices);
|
||||||
|
|
||||||
assert(in.getptr() == ZOH::BITSIZE);
|
nvDebugCheck(in.getptr() == ZOH::BITSIZE);
|
||||||
|
|
||||||
// lookup
|
// lookup
|
||||||
for (int y = 0; y < Tile::TILE_H; y++)
|
for (int y = 0; y < Tile::TILE_H; y++)
|
||||||
@ -627,7 +626,7 @@ double ZOH::refineone(const Tile &tile, int shapeindex_best, const FltEndpts end
|
|||||||
for (int sp = 0; sp < NPATTERNS; ++sp)
|
for (int sp = 0; sp < NPATTERNS; ++sp)
|
||||||
{
|
{
|
||||||
// precisions for all channels need to be the same
|
// precisions for all channels need to be the same
|
||||||
for (int i=1; i<NCHANNELS; ++i) assert (patterns[sp].chan[0].prec[0] == patterns[sp].chan[i].prec[0]);
|
for (int i=1; i<NCHANNELS; ++i) nvDebugCheck (patterns[sp].chan[0].prec[0] == patterns[sp].chan[i].prec[0]);
|
||||||
|
|
||||||
quantize_endpts(endpts, patterns[sp].chan[0].prec[0], orig_endpts);
|
quantize_endpts(endpts, patterns[sp].chan[0].prec[0], orig_endpts);
|
||||||
assign_indices(tile, shapeindex_best, orig_endpts, patterns[sp].chan[0].prec[0], orig_indices, orig_err);
|
assign_indices(tile, shapeindex_best, orig_endpts, patterns[sp].chan[0].prec[0], orig_indices, orig_err);
|
||||||
|
@ -25,7 +25,7 @@ See the License for the specific language governing permissions and limitations
|
|||||||
transform and get bit delta.
|
transform and get bit delta.
|
||||||
if the bit delta fits, exit
|
if the bit delta fits, exit
|
||||||
if we ended up with no candidates somehow, choose the tail set of EC candidates and retry. this should happen hardly ever.
|
if we ended up with no candidates somehow, choose the tail set of EC candidates and retry. this should happen hardly ever.
|
||||||
add a state variable to assert we only do this once.
|
add a state variable to nvDebugCheck we only do this once.
|
||||||
convert to bit stream.
|
convert to bit stream.
|
||||||
return the error.
|
return the error.
|
||||||
|
|
||||||
@ -44,7 +44,6 @@ See the License for the specific language governing permissions and limitations
|
|||||||
|
|
||||||
#include "nvmath/Fitting.h"
|
#include "nvmath/Fitting.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h> // strlen
|
#include <string.h> // strlen
|
||||||
#include <float.h> // FLT_MAX
|
#include <float.h> // FLT_MAX
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ static void swap_indices(IntEndpts endpts[NREGIONS_TWO], int indices[Tile::TILE_
|
|||||||
|
|
||||||
int x = POS_TO_X(position);
|
int x = POS_TO_X(position);
|
||||||
int y = POS_TO_Y(position);
|
int y = POS_TO_Y(position);
|
||||||
assert(REGION(x,y,shapeindex) == region); // double check the table
|
nvDebugCheck(REGION(x,y,shapeindex) == region); // double check the table
|
||||||
if (indices[y][x] & HIGH_INDEXBIT)
|
if (indices[y][x] & HIGH_INDEXBIT)
|
||||||
{
|
{
|
||||||
// high bit is set, swap the endpts and indices for this region
|
// high bit is set, swap the endpts and indices for this region
|
||||||
@ -278,7 +277,7 @@ static void write_header(const ComprEndpts endpts[NREGIONS_TWO], int shapeindex,
|
|||||||
case FIELD_BX: out.write(bx >> endbit, len); break;
|
case FIELD_BX: out.write(bx >> endbit, len); break;
|
||||||
case FIELD_BY: out.write(by >> endbit, len); break;
|
case FIELD_BY: out.write(by >> endbit, len); break;
|
||||||
case FIELD_BZ: out.write(bz >> endbit, len); break;
|
case FIELD_BZ: out.write(bz >> endbit, len); break;
|
||||||
default: assert(0);
|
default: nvAssume(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,8 +294,8 @@ static bool read_header(Bits &in, ComprEndpts endpts[NREGIONS_TWO], int &shapein
|
|||||||
if (pat_index == -2)
|
if (pat_index == -2)
|
||||||
return false; // reserved mode found
|
return false; // reserved mode found
|
||||||
|
|
||||||
assert (pat_index >= 0 && pat_index < NPATTERNS);
|
nvDebugCheck (pat_index >= 0 && pat_index < NPATTERNS);
|
||||||
assert (in.getptr() == patterns[pat_index].modebits);
|
nvDebugCheck (in.getptr() == patterns[pat_index].modebits);
|
||||||
|
|
||||||
p = patterns[pat_index];
|
p = patterns[pat_index];
|
||||||
|
|
||||||
@ -335,11 +334,11 @@ static bool read_header(Bits &in, ComprEndpts endpts[NREGIONS_TWO], int &shapein
|
|||||||
case FIELD_BX: bx |= in.read(len) << endbit; break;
|
case FIELD_BX: bx |= in.read(len) << endbit; break;
|
||||||
case FIELD_BY: by |= in.read(len) << endbit; break;
|
case FIELD_BY: by |= in.read(len) << endbit; break;
|
||||||
case FIELD_BZ: bz |= in.read(len) << endbit; break;
|
case FIELD_BZ: bz |= in.read(len) << endbit; break;
|
||||||
default: assert(0);
|
default: nvAssume(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (in.getptr() == 128 - 46);
|
nvDebugCheck (in.getptr() == 128 - 46);
|
||||||
|
|
||||||
shapeindex = d;
|
shapeindex = d;
|
||||||
endpts[0].A[0] = rw; endpts[0].B[0] = rx; endpts[1].A[0] = ry; endpts[1].B[0] = rz;
|
endpts[0].A[0] = rw; endpts[0].B[0] = rx; endpts[1].A[0] = ry; endpts[1].B[0] = rz;
|
||||||
@ -378,7 +377,7 @@ static void emit_block(const ComprEndpts compr_endpts[NREGIONS_TWO], int shapein
|
|||||||
|
|
||||||
write_indices(indices, shapeindex, out);
|
write_indices(indices, shapeindex, out);
|
||||||
|
|
||||||
assert(out.getptr() == ZOH::BITSIZE);
|
nvDebugCheck(out.getptr() == ZOH::BITSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_palette_quantized(const IntEndpts &endpts, int prec, Vector3 palette[NINDICES])
|
static void generate_palette_quantized(const IntEndpts &endpts, int prec, Vector3 palette[NINDICES])
|
||||||
@ -458,7 +457,7 @@ void ZOH::decompresstwo(const char *block, Tile &t)
|
|||||||
|
|
||||||
read_indices(in, shapeindex, indices);
|
read_indices(in, shapeindex, indices);
|
||||||
|
|
||||||
assert(in.getptr() == ZOH::BITSIZE);
|
nvDebugCheck(in.getptr() == ZOH::BITSIZE);
|
||||||
|
|
||||||
// lookup
|
// lookup
|
||||||
for (int y = 0; y < Tile::TILE_H; y++)
|
for (int y = 0; y < Tile::TILE_H; y++)
|
||||||
@ -714,7 +713,7 @@ double ZOH::refinetwo(const Tile &tile, int shapeindex_best, const FltEndpts end
|
|||||||
for (int sp = 0; sp < NPATTERNS; ++sp)
|
for (int sp = 0; sp < NPATTERNS; ++sp)
|
||||||
{
|
{
|
||||||
// precisions for all channels need to be the same
|
// precisions for all channels need to be the same
|
||||||
for (int i=1; i<NCHANNELS; ++i) assert (patterns[sp].chan[0].prec[0] == patterns[sp].chan[i].prec[0]);
|
for (int i=1; i<NCHANNELS; ++i) nvDebugCheck (patterns[sp].chan[0].prec[0] == patterns[sp].chan[i].prec[0]);
|
||||||
|
|
||||||
quantize_endpts(endpts, patterns[sp].chan[0].prec[0], orig_endpts);
|
quantize_endpts(endpts, patterns[sp].chan[0].prec[0], orig_endpts);
|
||||||
assign_indices(tile, shapeindex_best, orig_endpts, patterns[sp].chan[0].prec[0], orig_indices, orig_err);
|
assign_indices(tile, shapeindex_best, orig_endpts, patterns[sp].chan[0].prec[0], orig_indices, orig_err);
|
||||||
|
Loading…
Reference in New Issue
Block a user