summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-02-29 15:12:42 +0100
committerChristian König <[email protected]>2012-03-02 13:14:21 +0100
commit14766f820069ca987543918bce96410c481e5d20 (patch)
treefddc9d5ac54d9767c760cd6c93376c4dbc19c5b5 /src/gallium/auxiliary
parent74a4e9089488e7f341d21053bbf2d4aa52b99b70 (diff)
vl/csc: simplify matrix handling
A csc matrix is only 4x3 not 4x4, also define a VDPAU compatible type for it. Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c12
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h3
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.c114
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.h4
4 files changed, 64 insertions, 69 deletions
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index 94d937714ba..35958360e41 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -52,8 +52,6 @@ enum VS_OUTPUT
VS_O_VBOTTOM,
};
-typedef float csc_matrix[16];
-
static void *
create_vert_shader(struct vl_compositor *c)
{
@@ -804,7 +802,7 @@ vl_compositor_cleanup(struct vl_compositor *c)
}
void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *s, const float matrix[16])
+vl_compositor_set_csc_matrix(struct vl_compositor_state *s, vl_csc_matrix const *matrix)
{
struct pipe_transfer *buf_transfer;
@@ -816,7 +814,7 @@ vl_compositor_set_csc_matrix(struct vl_compositor_state *s, const float matrix[1
PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
&buf_transfer),
matrix,
- sizeof(csc_matrix)
+ sizeof(vl_csc_matrix)
);
pipe_buffer_unmap(s->pipe, buf_transfer);
@@ -1052,7 +1050,7 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)
bool
vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pipe)
{
- csc_matrix csc_matrix;
+ vl_csc_matrix csc_matrix;
assert(s);
@@ -1078,8 +1076,8 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
vl_compositor_clear_layers(s);
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, csc_matrix);
- vl_compositor_set_csc_matrix(s, csc_matrix);
+ vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, &csc_matrix);
+ vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix);
return true;
}
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index f8f3dc0de98..6de6ca06521 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -35,6 +35,7 @@
#include "util/u_rect.h"
#include "vl_types.h"
+#include "vl_csc.h"
struct pipe_context;
@@ -126,7 +127,7 @@ vl_compositor_init_state(struct vl_compositor_state *state, struct pipe_context
* set yuv -> rgba conversion matrix
*/
void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *settings, const float mat[16]);
+vl_compositor_set_csc_matrix(struct vl_compositor_state *settings, const vl_csc_matrix *matrix);
/**
* reset dirty area, so it's cleared with the clear colour
diff --git a/src/gallium/auxiliary/vl/vl_csc.c b/src/gallium/auxiliary/vl/vl_csc.c
index 56e662157ef..2ce690755f7 100644
--- a/src/gallium/auxiliary/vl/vl_csc.c
+++ b/src/gallium/auxiliary/vl/vl_csc.c
@@ -100,12 +100,11 @@
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
-static const float bt_601[16] =
+static const vl_csc_matrix bt_601 =
{
- 1.0f, 0.0f, 1.371f, 0.0f,
- 1.0f, -0.336f, -0.698f, 0.0f,
- 1.0f, 1.732f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.0f, 0.0f, 1.371f, 0.0f, },
+ { 1.0f, -0.336f, -0.698f, 0.0f, },
+ { 1.0f, 1.732f, 0.0f, 0.0f, }
};
/*
@@ -113,12 +112,11 @@ static const float bt_601[16] =
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [0,255]
*/
-static const float bt_601_full[16] =
+static const vl_csc_matrix bt_601_full =
{
- 1.164f, 0.0f, 1.596f, 0.0f,
- 1.164f, -0.391f, -0.813f, 0.0f,
- 1.164f, 2.018f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.164f, 0.0f, 1.596f, 0.0f, },
+ { 1.164f, -0.391f, -0.813f, 0.0f, },
+ { 1.164f, 2.018f, 0.0f, 0.0f, }
};
/*
@@ -126,12 +124,11 @@ static const float bt_601_full[16] =
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [16,235]
*/
-static const float bt_709[16] =
+static const vl_csc_matrix bt_709 =
{
- 1.0f, 0.0f, 1.540f, 0.0f,
- 1.0f, -0.183f, -0.459f, 0.0f,
- 1.0f, 1.816f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.0f, 0.0f, 1.540f, 0.0f, },
+ { 1.0f, -0.183f, -0.459f, 0.0f, },
+ { 1.0f, 1.816f, 0.0f, 0.0f, }
};
/*
@@ -139,36 +136,32 @@ static const float bt_709[16] =
* Y is in [16,235], Cb and Cr are in [16,240]
* R, G, and B are in [0,255]
*/
-static const float bt_709_full[16] =
+static const vl_csc_matrix bt_709_full =
{
- 1.164f, 0.0f, 1.793f, 0.0f,
- 1.164f, -0.213f, -0.534f, 0.0f,
- 1.164f, 2.115f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.164f, 0.0f, 1.793f, 0.0f, },
+ { 1.164f, -0.213f, -0.534f, 0.0f, },
+ { 1.164f, 2.115f, 0.0f, 0.0f, }
};
-static const float smpte240m[16] =
+static const vl_csc_matrix smpte240m =
{
- 1.0f, 0.0f, 1.582f, 0.0f,
- 1.0f, -0.228f, -0.478f, 0.0f,
- 1.0f, 1.833f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.0f, 0.0f, 1.582f, 0.0f, },
+ { 1.0f, -0.228f, -0.478f, 0.0f, },
+ { 1.0f, 1.833f, 0.0f, 0.0f, }
};
-static const float smpte240m_full[16] =
+static const vl_csc_matrix smpte240m_full =
{
- 1.164f, 0.0f, 1.794f, 0.0f,
- 1.164f, -0.258f, -0.543f, 0.0f,
- 1.164f, 2.079f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.164f, 0.0f, 1.794f, 0.0f, },
+ { 1.164f, -0.258f, -0.543f, 0.0f, },
+ { 1.164f, 2.079f, 0.0f, 0.0f, }
};
-static const float identity[16] =
+static const vl_csc_matrix identity =
{
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
+ { 1.0f, 0.0f, 0.0f, 0.0f, },
+ { 0.0f, 1.0f, 0.0f, 0.0f, },
+ { 0.0f, 0.0f, 1.0f, 0.0f, }
};
const struct vl_procamp vl_default_procamp = {
@@ -181,7 +174,7 @@ const struct vl_procamp vl_default_procamp = {
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
- float *matrix)
+ vl_csc_matrix *matrix)
{
float ybias = full_range ? -16.0f/255.0f : 0.0f;
float cbbias = -128.0f/255.0f;
@@ -193,44 +186,45 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
float b = p->brightness;
float h = p->hue;
- const float *cstd;
+ const vl_csc_matrix *cstd;
assert(matrix);
switch (cs) {
case VL_CSC_COLOR_STANDARD_BT_601:
- cstd = full_range ? &bt_601_full[0] : &bt_601[0];
+ cstd = full_range ? &bt_601_full : &bt_601;
break;
case VL_CSC_COLOR_STANDARD_BT_709:
- cstd = full_range ? &bt_709_full[0] : &bt_709[0];
+ cstd = full_range ? &bt_709_full : &bt_709;
break;
case VL_CSC_COLOR_STANDARD_SMPTE_240M:
- cstd = full_range ? &smpte240m_full[0] : &smpte240m[0];
+ cstd = full_range ? &smpte240m_full : &smpte240m;
break;
case VL_CSC_COLOR_STANDARD_IDENTITY:
default:
assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
- memcpy(matrix, &identity[0], sizeof(float) * 16);
+ memcpy(matrix, identity, sizeof(vl_csc_matrix));
return;
}
- matrix[ 0] = c*cstd[ 0];
- matrix[ 1] = c*cstd[ 1]*s*cosf(h) - c*cstd[ 2]*s*sinf(h);
- matrix[ 2] = c*cstd[ 2]*s*cosf(h) + c*cstd[ 1]*s*sinf(h);
- matrix[ 3] = cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 2]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 4] = c*cstd[ 4];
- matrix[ 5] = c*cstd[ 5]*s*cosf(h) - c*cstd[ 6]*s*sinf(h);
- matrix[ 6] = c*cstd[ 6]*s*cosf(h) + c*cstd[ 5]*s*sinf(h);
- matrix[ 7] = cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 6]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 8] = c*cstd[ 8];
- matrix[ 9] = c*cstd[ 9]*s*cosf(h) - c*cstd[10]*s*sinf(h);
- matrix[10] = c*cstd[10]*s*cosf(h) + c*cstd[ 9]*s*sinf(h);
- matrix[11] = cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[10]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[12] = c*cstd[12];
- matrix[13] = c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h);
- matrix[14] = c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h);
- matrix[15] = cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h));
+ (*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] * (b + c * ybias) +
+ (*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)[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] * (b + c * ybias) +
+ (*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)[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] * (b + c * ybias) +
+ (*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));
}
diff --git a/src/gallium/auxiliary/vl/vl_csc.h b/src/gallium/auxiliary/vl/vl_csc.h
index 7a31dd4eb26..4e36e0b0eda 100644
--- a/src/gallium/auxiliary/vl/vl_csc.h
+++ b/src/gallium/auxiliary/vl/vl_csc.h
@@ -30,6 +30,8 @@
#include "pipe/p_compiler.h"
+typedef float vl_csc_matrix[3][4];
+
struct vl_procamp
{
float brightness;
@@ -51,6 +53,6 @@ extern const struct vl_procamp vl_default_procamp;
void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
struct vl_procamp *procamp,
bool full_range,
- float *matrix);
+ vl_csc_matrix *matrix);
#endif /* vl_csc_h */