OSDN Git Service

Implement the w0avg mode (approximation to wavg, FAST)
[android-x86/external-s2tc.git] / s2tc_algorithm.cpp
index 81f3aa2..e48977d 100644 (file)
@@ -228,6 +228,15 @@ namespace
                return ((dr*dr) << 2) + dg*dg + ((db*db) << 2);
        }
 
+       inline int color_dist_w0avg(const color_t &a, const color_t &b)
+       {
+               int dr = a.r - b.r; // multiplier: 31 (-1..1)
+               int dg = a.g - b.g; // multiplier: 63 (-1..1)
+               int db = a.b - b.b; // multiplier: 31 (-1..1)
+               return dr*dr + dg*dg + db*db;
+               // weighted 1:4:1
+       }
+
        inline int color_dist_wavg(const color_t &a, const color_t &b)
        {
                int dr = a.r - b.r; // multiplier: 31 (-1..1)
@@ -1181,6 +1190,9 @@ s2tc_encode_block_func_t s2tc_encode_block_func(DxtMode dxt, ColorDistMode cd, i
                case WAVG:
                        return s2tc_encode_block_func<color_dist_wavg>(dxt, nrandom, refine);
                        break;
+               case W0AVG:
+                       return s2tc_encode_block_func<color_dist_w0avg>(dxt, nrandom, refine);
+                       break;
                case NORMALMAP:
                        return s2tc_encode_block_func<color_dist_normalmap>(dxt, nrandom, refine);
                        break;