OSDN Git Service

add Android.mk to build for android
[android-x86/external-s2tc.git] / s2tc_libtxc_dxtn.cpp
index fa296a7..077270d 100644 (file)
@@ -45,7 +45,7 @@ void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
        {
                case 0:                        break;
                case 1:  c = c1;               break;
-               case 3:  if(c1 > c) { c = 0;   break; }
+               case 3:  if(c1 >= c) { c = 0;  break; }
                default: if((i^j) & 1) c = c1; break;
        }
        t[0] = ((c >> 11) & 0x1F); t[0] = (t[0] << 3) | (t[0] >> 2);
@@ -67,7 +67,7 @@ void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata,
        {
                case 0:                        t[3] = 255; break;
                case 1:  c = c1;               t[3] = 255; break;
-               case 3:  if(c1 > c) { c = 0;   t[3] =   0; break; }
+               case 3:  if(c1 >= c) { c = 0;  t[3] =   0; break; }
                default: if((i^j) & 1) c = c1; t[3] = 255; break;
        }
        t[0] = ((c >> 11) & 0x1F); t[0] = (t[0] << 3) | (t[0] >> 2);
@@ -130,11 +130,11 @@ void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
                ab |= 4;
        switch(ab)
        {
-               case 0:                        break;
-               case 1:  a = a1;               break;
-               case 6:  a = 0;                break;
-               case 7:  a = 255;              break;
-               default: if((i^j) & 1) a = a1; break;
+               case 0:                         break;
+               case 1:  a = a1;                break;
+               case 6:  if(a1 >= a) { a = 0;   break; }
+               case 7:  if(a1 >= a) { a = 255; break; }
+               default: if((i^j) & 1) a = a1;  break;
        }
        t[3] = a;
 }
@@ -183,12 +183,12 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                                cd = SRGB;
                        else if(!strcasecmp(v, "SRGB_MIXED"))
                                cd = SRGB_MIXED;
-                       else if(!strcasecmp(v, "LAB"))
-                               cd = LAB;
                        else if(!strcasecmp(v, "AVG"))
                                cd = AVG;
                        else if(!strcasecmp(v, "WAVG"))
                                cd = WAVG;
+                       else if(!strcasecmp(v, "W0AVG"))
+                               cd = W0AVG;
                        else if(!strcasecmp(v, "NORMALMAP"))
                                cd = NORMALMAP;
                        else
@@ -208,8 +208,6 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                                refine = REFINE_NEVER;
                        else if(!strcasecmp(v, "ALWAYS"))
                                refine = REFINE_ALWAYS;
-                       else if(!strcasecmp(v, "CHECK"))
-                               refine = REFINE_CHECK;
                        else if(!strcasecmp(v, "LOOP"))
                                refine = REFINE_LOOP;
                        else
@@ -221,15 +219,15 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
                case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
                        dxt = DXT1;
-                       rgb565_image(rgba, srcPixData, width, height, srccomps, 0, 1, dither);
+                       rgb565_image(rgba, srcPixData, width, height, srccomps, 1, dither);
                        break;
                case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
                        dxt = DXT3;
-                       rgb565_image(rgba, srcPixData, width, height, srccomps, 0, 4, dither);
+                       rgb565_image(rgba, srcPixData, width, height, srccomps, 4, dither);
                        break;
                case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
                        dxt = DXT5;
-                       rgb565_image(rgba, srcPixData, width, height, srccomps, 0, 8, dither);
+                       rgb565_image(rgba, srcPixData, width, height, srccomps, 8, dither);
                        break;
                default:
                        free(rgba);