d3dhelpers: Swap UV planes properly for YV12 as compared to I420
authorSebastian Dröge <sebastian@centricular.com>
Thu, 3 Jul 2014 17:05:22 +0000 (19:05 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 3 Jul 2014 17:06:26 +0000 (19:06 +0200)
If we only do it in one place colors will look funny.

sys/d3dvideosink/d3dhelpers.c

index 03ed6ee..386f607 100644 (file)
@@ -629,14 +629,25 @@ gst_d3dsurface_buffer_pool_alloc_buffer (GstBufferPool * bpool,
     case GST_VIDEO_FORMAT_YV12:
       offset[0] = 0;
       stride[0] = lr.Pitch;
-      offset[2] =
-          offset[0] + stride[0] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 0);
-      stride[2] = lr.Pitch / 2;
-      offset[1] =
-          offset[2] + stride[2] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 2);
-      stride[1] = lr.Pitch / 2;
-      size =
-          offset[1] + stride[1] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 1);
+      if (GST_VIDEO_INFO_FORMAT (&pool->info) == GST_VIDEO_FORMAT_YV12) {
+        offset[1] =
+            offset[0] + stride[0] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 0);
+        stride[1] = lr.Pitch / 2;
+        offset[2] =
+            offset[1] + stride[1] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 1);
+        stride[2] = lr.Pitch / 2;
+        size =
+            offset[2] + stride[2] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 2);
+      } else {
+        offset[2] =
+            offset[0] + stride[0] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 0);
+        stride[2] = lr.Pitch / 2;
+        offset[1] =
+            offset[2] + stride[2] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 2);
+        stride[1] = lr.Pitch / 2;
+        size =
+            offset[1] + stride[1] * GST_VIDEO_INFO_COMP_HEIGHT (&pool->info, 1);
+      }
       break;
     case GST_VIDEO_FORMAT_NV12:
       offset[0] = 0;