[Mesa-dev] [PATCH] state_trackers/vdpau: Implement VdpGenerateCSCMatrix partially

Maarten Lankhorst m.b.lankhorst at gmail.com
Tue Oct 25 10:35:09 PDT 2011


Signed-off-by: Maarten Lankhorst <m.b.lankhorst at gmail.com

---

diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index 8728157..83daddf 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -257,9 +257,37 @@ vlVdpGenerateCSCMatrix(VdpProcamp *procamp,
                        VdpColorStandard standard,
                        VdpCSCMatrix *csc_matrix)
 {
-   VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Generating CSCMatrix\n");
+   double Kry, Kby, Ry = 219., Rc = 112., ofsy = 16., Scb, Scr;
+   VdpProcamp mat;
    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: Kry = 0.299; Kby = .114; break;
+      case VDP_COLOR_STANDARD_ITUR_BT_709: Kry = 0.2126; Kby = .0722; break;
+      case VDP_COLOR_STANDARD_SMPTE_240M:  Kry = 0.212; Kby = .087; break;
+      default: return VDP_STATUS_INVALID_COLOR_STANDARD;
+   }
+   if (procamp->hue != 0.f || procamp->saturation != 1.f || procamp->contrast != 1.f || procamp->brightness != 0.f)
+      VDPAU_MSG(VDPAU_WARN, "No support yet for color options\n");
+
+   mat[0][0] = mat[1][0] = mat[2][0] = 255. / Ry;
+   mat[0][3] = mat[1][3] = mat[2][3] = -ofsy / Ry;
+   Scr = (1. - Kry) / Rc;
+   mat[0][1] = 0.;
+   mat[0][2] = 255. * Scr;
+   mat[0][3] -= 128. * Scr;
+   Scb = -(1. - Kby) * Kby / ((1. - Kby) + (1. - Kry) - 1.) / Rc;
+   Scr = -(1. - Kry) * Kry / ((1. - Kby) + (1. - Kry) - 1.) / Rc;
+   mat[1][1] = 255. * Scb;
+   mat[1][2] = 255. * Scr;
+   mat[1][3] -= 128. * (Scb + Scr);
+   Scb = (1. - Kby) / Rc;
+   mat[2][1] = 255. * Scb;
+   mat[2][2] = 0.;
+   mat[2][3] -= 128. * Scb;
    return VDP_STATUS_OK;
 }




More information about the mesa-dev mailing list