aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorXiang, Haihao <[email protected]>2007-03-18 18:34:21 +0800
committerXiang, Haihao <[email protected]>2007-03-18 18:34:21 +0800
commitb6fe1bdd4da806895f90f3f5be4fb364d6f1f64a (patch)
tree080538422f2f44d677700ddaf4aad1e1c9c902db /src/mesa/main
parent84081774e62a8af18e6bf894ea69f63b97dcfe96 (diff)
mesa: enhance fxt1_quantize_ALPHA1
If possible, let minCol != maxCol
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/texcompress_fxt1.c77
1 files changed, 44 insertions, 33 deletions
diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
index d3011cedce4..411d51cfcc6 100644
--- a/src/mesa/main/texcompress_fxt1.c
+++ b/src/mesa/main/texcompress_fxt1.c
@@ -752,44 +752,55 @@ fxt1_quantize_ALPHA1 (GLuint *cc,
GLint minColL = 0, maxColL = 0;
GLint minColR = 0, maxColR = 0;
GLint sumL = 0, sumR = 0;
-
+ GLint nn_comp;
/* Our solution here is to find the darkest and brightest colors in
* the 4x4 tile and use those as the two representative colors.
* There are probably better algorithms to use (histogram-based).
*/
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (k = 0; k < N_TEXELS / 2; k++) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColL = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColL = k;
- }
- sumL += sum;
+ nn_comp = n_comp;
+ while ((minColL == maxColL) && nn_comp) {
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint sum = 0;
+ for (i = 0; i < nn_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ sumL += sum;
+ }
+
+ nn_comp--;
}
- minSum = 2000; /* big enough */
- maxSum = -1; /* small enough */
- for (; k < N_TEXELS; k++) {
- GLint sum = 0;
- for (i = 0; i < n_comp; i++) {
- sum += input[k][i];
- }
- if (minSum > sum) {
- minSum = sum;
- minColR = k;
- }
- if (maxSum < sum) {
- maxSum = sum;
- maxColR = k;
- }
- sumR += sum;
+
+ nn_comp = n_comp;
+ while ((minColR == maxColR) && nn_comp) {
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = N_TEXELS / 2; k < N_TEXELS; k++) {
+ GLint sum = 0;
+ for (i = 0; i < nn_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ sumR += sum;
+ }
+
+ nn_comp--;
}
/* choose the common vector (yuck!) */