Commit 249836e5 by Rémi Verschelde

squish: Update to upstream 1.14

Sources are untouched, tarball from https://sourceforge.net/projects/libsquish
parent 8311a78d
......@@ -160,9 +160,8 @@ Files extracted from upstream source:
## squish
- Upstream: https://code.google.com/archive/p/libsquish
and patches from https://github.com/Cavewhere/squish
- Version: 1.11
- Upstream: https://sourceforge.net/projects/libsquish
- Version: 1.14
- License: MIT
Files extracted from upstream source:
......
......@@ -24,6 +24,7 @@
-------------------------------------------------------------------------- */
#include "alpha.h"
#include <climits>
#include <algorithm>
......
......@@ -26,7 +26,7 @@
#ifndef SQUISH_ALPHA_H
#define SQUISH_ALPHA_H
#include <squish.h>
#include "squish.h"
namespace squish {
......
......@@ -31,22 +31,21 @@
namespace squish {
ClusterFit::ClusterFit( ColourSet const* colours, int flags )
ClusterFit::ClusterFit( ColourSet const* colours, int flags, float* metric )
: ColourFit( colours, flags )
{
// set the iteration count
m_iterationCount = ( m_flags & kColourIterativeClusterFit ) ? kMaxIterations : 1;
// initialise the best error
m_besterror = VEC4_CONST( FLT_MAX );
// initialise the metric
bool perceptual = ( ( m_flags & kColourMetricPerceptual ) != 0 );
if( perceptual )
m_metric = Vec4( 0.2126f, 0.7152f, 0.0722f, 0.0f );
// initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f)
if( metric )
m_metric = Vec4( metric[0], metric[1], metric[2], 1.0f );
else
m_metric = VEC4_CONST( 1.0f );
// initialise the best error
m_besterror = VEC4_CONST( FLT_MAX );
// cache some values
int const count = m_colours->GetCount();
Vec3 const* values = m_colours->GetPoints();
......
......@@ -27,7 +27,7 @@
#ifndef SQUISH_CLUSTERFIT_H
#define SQUISH_CLUSTERFIT_H
#include <squish.h>
#include "squish.h"
#include "maths.h"
#include "simd.h"
#include "colourfit.h"
......@@ -37,7 +37,7 @@ namespace squish {
class ClusterFit : public ColourFit
{
public:
ClusterFit( ColourSet const* colours, int flags );
ClusterFit( ColourSet const* colours, int flags, float* metric );
private:
bool ConstructOrdering( Vec3 const& axis, int iteration );
......
......@@ -26,7 +26,7 @@
#ifndef SQUISH_COLOURBLOCK_H
#define SQUISH_COLOURBLOCK_H
#include <squish.h>
#include "squish.h"
#include "maths.h"
namespace squish {
......
......@@ -34,6 +34,10 @@ ColourFit::ColourFit( ColourSet const* colours, int flags )
{
}
ColourFit::~ColourFit()
{
}
void ColourFit::Compress( void* block )
{
bool isDxt1 = ( ( m_flags & kDxt1 ) != 0 );
......
......@@ -26,9 +26,11 @@
#ifndef SQUISH_COLOURFIT_H
#define SQUISH_COLOURFIT_H
#include <squish.h>
#include "squish.h"
#include "maths.h"
#include <climits>
namespace squish {
class ColourSet;
......@@ -37,6 +39,7 @@ class ColourFit
{
public:
ColourFit( ColourSet const* colours, int flags );
virtual ~ColourFit();
void Compress( void* block );
......
......@@ -26,7 +26,7 @@
#ifndef SQUISH_COLOURSET_H
#define SQUISH_COLOURSET_H
#include <squish.h>
#include "squish.h"
#include "maths.h"
namespace squish {
......
......@@ -36,7 +36,7 @@
#define SQUISH_USE_SSE 0
#endif
// Internally et SQUISH_USE_SIMD when either Altivec or SSE is available.
// Internally set SQUISH_USE_SIMD when either Altivec or SSE is available.
#if SQUISH_USE_ALTIVEC && SQUISH_USE_SSE
#error "Cannot enable both Altivec and SSE!"
#endif
......
......@@ -30,6 +30,7 @@
*/
#include "maths.h"
#include "simd.h"
#include <cfloat>
namespace squish {
......@@ -44,6 +45,7 @@ Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weight
total += weights[i];
centroid += weights[i]*points[i];
}
if( total > FLT_EPSILON )
centroid /= total;
// accumulate the covariance matrix
......@@ -65,6 +67,8 @@ Sym3x3 ComputeWeightedCovariance( int n, Vec3 const* points, float const* weight
return covariance;
}
#if 0
static Vec3 GetMultiplicity1Evector( Sym3x3 const& matrix, float evalue )
{
// compute M
......@@ -224,4 +228,32 @@ Vec3 ComputePrincipleComponent( Sym3x3 const& matrix )
}
}
#else
#define POWER_ITERATION_COUNT 8
Vec3 ComputePrincipleComponent( Sym3x3 const& matrix )
{
Vec4 const row0( matrix[0], matrix[1], matrix[2], 0.0f );
Vec4 const row1( matrix[1], matrix[3], matrix[4], 0.0f );
Vec4 const row2( matrix[2], matrix[4], matrix[5], 0.0f );
Vec4 v = VEC4_CONST( 1.0f );
for( int i = 0; i < POWER_ITERATION_COUNT; ++i )
{
// matrix multiply
Vec4 w = row0*v.SplatX();
w = MultiplyAdd(row1, v.SplatY(), w);
w = MultiplyAdd(row2, v.SplatZ(), w);
// get max component from xyz in all channels
Vec4 a = Max(w.SplatX(), Max(w.SplatY(), w.SplatZ()));
// divide through and advance
v = w*Reciprocal(a);
}
return v.GetVec3();
}
#endif
} // namespace squish
......@@ -30,13 +30,12 @@
namespace squish {
RangeFit::RangeFit( ColourSet const* colours, int flags )
RangeFit::RangeFit( ColourSet const* colours, int flags, float* metric )
: ColourFit( colours, flags )
{
// initialise the metric
bool perceptual = ( ( m_flags & kColourMetricPerceptual ) != 0 );
if( perceptual )
m_metric = Vec3( 0.2126f, 0.7152f, 0.0722f );
// initialise the metric (old perceptual = 0.2126f, 0.7152f, 0.0722f)
if( metric )
m_metric = Vec3( metric[0], metric[1], metric[2] );
else
m_metric = Vec3( 1.0f );
......
......@@ -26,7 +26,7 @@
#ifndef SQUISH_RANGEFIT_H
#define SQUISH_RANGEFIT_H
#include <squish.h>
#include "squish.h"
#include "colourfit.h"
#include "maths.h"
......@@ -37,7 +37,7 @@ class ColourSet;
class RangeFit : public ColourFit
{
public:
RangeFit( ColourSet const* colours, int flags );
RangeFit( ColourSet const* colours, int flags, float* metric );
private:
virtual void Compress3( void* block );
......
......@@ -31,7 +31,7 @@
namespace squish {
#define VEC4_CONST( X ) Vec4( ( vector float )( X ) )
#define VEC4_CONST( X ) Vec4( ( vector float ){ X } )
class Vec4
{
......@@ -96,7 +96,7 @@ public:
Vec4& operator*=( Arg v )
{
m_v = vec_madd( m_v, v.m_v, ( vector float )( -0.0f ) );
m_v = vec_madd( m_v, v.m_v, ( vector float ){ -0.0f } );
return *this;
}
......@@ -112,7 +112,7 @@ public:
friend Vec4 operator*( Vec4::Arg left, Vec4::Arg right )
{
return Vec4( vec_madd( left.m_v, right.m_v, ( vector float )( -0.0f ) ) );
return Vec4( vec_madd( left.m_v, right.m_v, ( vector float ){ -0.0f } ) );
}
//! Returns a*b + c
......@@ -133,7 +133,7 @@ public:
vector float estimate = vec_re( v.m_v );
// one round of Newton-Rhaphson refinement
vector float diff = vec_nmsub( estimate, v.m_v, ( vector float )( 1.0f ) );
vector float diff = vec_nmsub( estimate, v.m_v, ( vector float ){ 1.0f } );
return Vec4( vec_madd( diff, estimate, estimate ) );
}
......
......@@ -26,7 +26,6 @@
#include "singlecolourfit.h"
#include "colourset.h"
#include "colourblock.h"
#include <climits>
namespace squish {
......
......@@ -26,7 +26,7 @@
#ifndef SQUISH_SINGLECOLOURFIT_H
#define SQUISH_SINGLECOLOURFIT_H
#include <squish.h>
#include "squish.h"
#include "colourfit.h"
namespace squish {
......
/* -----------------------------------------------------------------------------
Copyright (c) 2006 Simon Brown si@sjbrown.co.uk
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------- */
static SingleColourLookup const lookup_5_3[] =
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment