state_trackers/vdpau: Implement VdpGenerateCSCMatrix
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Mon, 31 Oct 2011 09:23:03 +0000 (10:23 +0100)
committerChristian König <deathsimple@vodafone.de>
Thu, 3 Nov 2011 12:52:00 +0000 (13:52 +0100)
With the smpte240 profile, which was missing.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
src/gallium/auxiliary/vl/vl_csc.c
src/gallium/auxiliary/vl/vl_csc.h
src/gallium/state_trackers/vdpau/mixer.c

index 21da95f3ceb543dc0633df8556bd04a00d6c3ea1..56e662157ef831c5ddf7e12d83fd75fc10c9f922 100644 (file)
@@ -147,6 +147,22 @@ static const float bt_709_full[16] =
    0.0f,    0.0f,    0.0f,   1.0f
 };
 
+static const float smpte240m[16] =
+{
+   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
+};
+
+static const float smpte240m_full[16] =
+{
+   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
+};
+
 static const float identity[16] =
 {
    1.0f, 0.0f, 0.0f, 0.0f,
@@ -188,6 +204,9 @@ void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
       case VL_CSC_COLOR_STANDARD_BT_709:
          cstd = full_range ? &bt_709_full[0] : &bt_709[0];
          break;
+      case VL_CSC_COLOR_STANDARD_SMPTE_240M:
+         cstd = full_range ? &smpte240m_full[0] : &smpte240m[0];
+         break;
       case VL_CSC_COLOR_STANDARD_IDENTITY:
       default:
          assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
index a6fb1fdba5130ec00dfb959d1ef57c08f4360ec3..7a31dd4eb26c856426ad651b6d7f118785f9b21a 100644 (file)
@@ -42,7 +42,8 @@ enum VL_CSC_COLOR_STANDARD
 {
    VL_CSC_COLOR_STANDARD_IDENTITY,
    VL_CSC_COLOR_STANDARD_BT_601,
-   VL_CSC_COLOR_STANDARD_BT_709
+   VL_CSC_COLOR_STANDARD_BT_709,
+   VL_CSC_COLOR_STANDARD_SMPTE_240M
 };
 
 extern const struct vl_procamp vl_default_procamp;
index 8728157e8a5f7cbce5fed143d5af451b0859ba5b..ed5a64640882ceaeb38c6393d043c8dafd24c2fd 100644 (file)
@@ -257,9 +257,27 @@ vlVdpGenerateCSCMatrix(VdpProcamp *procamp,
                        VdpColorStandard standard,
                        VdpCSCMatrix *csc_matrix)
 {
-   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Generating CSCMatrix\n");
+   float matrix[16];
+   enum VL_CSC_COLOR_STANDARD vl_std;
+   struct vl_procamp camp;
+
    if (!(csc_matrix && procamp))
       return VDP_STATUS_INVALID_POINTER;
 
+   if (procamp->struct_version > VDP_PROCAMP_VERSION)
+      return VDP_STATUS_INVALID_STRUCT_VERSION;
+
+   switch (standard) {
+      case VDP_COLOR_STANDARD_ITUR_BT_601: vl_std = VL_CSC_COLOR_STANDARD_BT_601; break;
+      case VDP_COLOR_STANDARD_ITUR_BT_709: vl_std = VL_CSC_COLOR_STANDARD_BT_709; break;
+      case VDP_COLOR_STANDARD_SMPTE_240M:  vl_std = VL_CSC_COLOR_STANDARD_SMPTE_240M; break;
+      default: return VDP_STATUS_INVALID_COLOR_STANDARD;
+   }
+   camp.brightness = procamp->brightness;
+   camp.contrast = procamp->contrast;
+   camp.saturation = procamp->saturation;
+   camp.hue = procamp->hue;
+   vl_csc_get_matrix(vl_std, &camp, 1, matrix);
+   memcpy(csc_matrix, matrix, sizeof(float)*12);
    return VDP_STATUS_OK;
 }