On 03/04/2016 04:52 AM, Thomas Hellstrom wrote:
Makes the code significantly more readable.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
---
  src/gallium/auxiliary/vl/vl_csc.c | 36 +++++++++++++++++++++---------------
  1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_csc.c 
b/src/gallium/auxiliary/vl/vl_csc.c
index bb2cc58..66cedd9 100644
--- a/src/gallium/auxiliary/vl/vl_csc.c
+++ b/src/gallium/auxiliary/vl/vl_csc.c
@@ -153,6 +153,7 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
     float s = p->saturation;
     float b = p->brightness;
     float h = p->hue;
+   float x, y, z;

     const vl_csc_matrix *cstd;

@@ -162,6 +163,11 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
        s *= 1.138f/1.164f; /* Adjust for the chroma range */
     }

+   /* Parameter substitutions */
+   x = c * s * cosf(h);
+   y = c * s * sinf(h);
+   z = c * b;
+
     assert(matrix);

     switch (cs) {
@@ -182,23 +188,23 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
     }

     (*matrix)[0][0] = c * (*cstd)[0][0];
-   (*matrix)[0][1] = c * (*cstd)[0][1] * s * cosf(h) - c * (*cstd)[0][2] * s * 
sinf(h);
-   (*matrix)[0][2] = c * (*cstd)[0][2] * s * cosf(h) + c * (*cstd)[0][1] * s * 
sinf(h);
-   (*matrix)[0][3] = (*cstd)[0][3] + (*cstd)[0][0] * c * b +
-                     (*cstd)[0][1] * (c * cbbias * s * cosf(h) + c * crbias * 
s * sinf(h)) +
-                     (*cstd)[0][2] * (c * crbias * s * cosf(h) - c * cbbias * 
s * sinf(h));
+   (*matrix)[0][1] = (*cstd)[0][1] * x - (*cstd)[0][2] * y;
+   (*matrix)[0][2] = (*cstd)[0][2] * x + (*cstd)[0][1] * y;
+   (*matrix)[0][3] = (*cstd)[0][3] + (*cstd)[0][0] * z +
+                     (*cstd)[0][1] * (x * cbbias + y * crbias) +
+                     (*cstd)[0][2] * (x * crbias - y * cbbias);

     (*matrix)[1][0] = c * (*cstd)[1][0];
-   (*matrix)[1][1] = c * (*cstd)[1][1] * s * cosf(h) - c * (*cstd)[1][2] * s * 
sinf(h);
-   (*matrix)[1][2] = c * (*cstd)[1][2] * s * cosf(h) + c * (*cstd)[1][1] * s * 
sinf(h);
-   (*matrix)[1][3] = (*cstd)[1][3] + (*cstd)[1][0] * c * b +
-                     (*cstd)[1][1] * (c * cbbias * s * cosf(h) + c * crbias * 
s * sinf(h)) +
-                     (*cstd)[1][2] * (c * crbias * s * cosf(h) - c * cbbias * 
s * sinf(h));
+   (*matrix)[1][1] = (*cstd)[1][1] * x - (*cstd)[1][2] * y;
+   (*matrix)[1][2] = (*cstd)[1][2] * x + (*cstd)[1][1] * y;
+   (*matrix)[1][3] = (*cstd)[1][3] + (*cstd)[1][0] * z +
+                     (*cstd)[1][1] * (x * cbbias + y * crbias) +
+                     (*cstd)[1][2] * (x * crbias - y * cbbias);

     (*matrix)[2][0] = c * (*cstd)[2][0];
-   (*matrix)[2][1] = c * (*cstd)[2][1] * s * cosf(h) - c * (*cstd)[2][2] * s * 
sinf(h);
-   (*matrix)[2][2] = c * (*cstd)[2][2] * s * cosf(h) + c * (*cstd)[2][1] * s * 
sinf(h);
-   (*matrix)[2][3] = (*cstd)[2][3] + (*cstd)[2][0] * c * b +
-                     (*cstd)[2][1] * (c * cbbias * s * cosf(h) + c * crbias * 
s * sinf(h)) +
-                     (*cstd)[2][2] * (c * crbias * s * cosf(h) - c * cbbias * 
s * sinf(h));
+   (*matrix)[2][1] = (*cstd)[2][1] * x - (*cstd)[2][2] * y;
+   (*matrix)[2][2] = (*cstd)[2][2] * x + (*cstd)[2][1] * y;
+   (*matrix)[2][3] = (*cstd)[2][3] + (*cstd)[2][0] * z +
+                     (*cstd)[2][1] * (x * cbbias + y * crbias) +
+                     (*cstd)[2][2] * (x * crbias - y * cbbias);
  }


For the series, Reviewed-by: Brian Paul <bri...@vmware.com>

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to