Waylandsink: Add plane_size info to tbm_surface for s/w codec output 62/133062/4
authorHyunil <hyunil46.park@samsung.com>
Fri, 9 Jun 2017 00:45:40 +0000 (09:45 +0900)
committerHyunil <hyunil46.park@samsung.com>
Fri, 9 Jun 2017 01:50:15 +0000 (10:50 +0900)
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
Change-Id: I8579f88ea423dac399153ac66deb7e192cd0b154

ext/wayland/wlshmallocator.c
packaging/gst-plugins-bad.spec

index 9cc70f7..91ead3b 100644 (file)
@@ -357,6 +357,7 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display,
   GstWlShmMemory *shm_mem = (GstWlShmMemory *) mem;
   gint width, height, stride, offset;
   gsize size;
+  gint plane_size[GST_VIDEO_MAX_PLANES], n_planes, i;
   enum wl_shm_format format;
   struct wl_shm_pool *wl_pool;
   struct wl_buffer *wbuffer;
@@ -429,17 +430,43 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display,
           display->dump_video = FALSE;
       }
 
+      n_planes = GST_VIDEO_INFO_N_PLANES (info);
+      switch (n_planes) {
+        case 1:
+          plane_size[0] = info->size;
+          break;
+        case 2:
+          plane_size[0] = GST_VIDEO_INFO_PLANE_OFFSET (info, 1);
+          plane_size[1] = info->size - plane_size[0];
+          break;
+        case 3:
+          plane_size[0] = GST_VIDEO_INFO_PLANE_OFFSET (info, 1);
+          plane_size[1] = GST_VIDEO_INFO_PLANE_OFFSET (info, 2) - plane_size[0];
+          plane_size[2] = info->size - GST_VIDEO_INFO_PLANE_OFFSET (info, 2);
+          break;
+        case 4:
+          plane_size[0] = GST_VIDEO_INFO_PLANE_OFFSET (info, 1);
+          plane_size[1] = GST_VIDEO_INFO_PLANE_OFFSET (info, 2) - plane_size[0];
+          plane_size[2] = GST_VIDEO_INFO_PLANE_OFFSET (info, 3)
+              - GST_VIDEO_INFO_PLANE_OFFSET (info, 2);
+          plane_size[3] = info->size - GST_VIDEO_INFO_PLANE_OFFSET (info, 3);
+          break;
+
+        default:
+          break;
+      }
+
       ts_info.width = width;
       ts_info.height = height;
       ts_info.format = format;
       ts_info.bpp = tbm_surface_internal_get_bpp (ts_info.format);
       ts_info.num_planes = tbm_surface_internal_get_num_planes (ts_info.format);
-      ts_info.planes[0].stride = GST_VIDEO_INFO_PLANE_STRIDE (info, 0);
-      ts_info.planes[1].stride = GST_VIDEO_INFO_PLANE_STRIDE (info, 1);
-      ts_info.planes[2].stride = GST_VIDEO_INFO_PLANE_STRIDE (info, 2);
-      ts_info.planes[0].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, 0);
-      ts_info.planes[1].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, 1);
-      ts_info.planes[2].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, 2);
+
+      for (i = 0; i < n_planes; i++) {
+        ts_info.planes[i].stride = GST_VIDEO_INFO_PLANE_STRIDE (info, i);
+        ts_info.planes[i].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, i);
+        ts_info.planes[i].size = plane_size[i];
+      }
 
       GST_LOG ("tbm_bo (%p)", shm_mem->tbm_bo_ptr);
 
index 4660f0d..799ba63 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:           gst-plugins-bad
 Version:        1.6.1
-Release:        13
+Release:        14
 Summary:        GStreamer Streaming-Media Framework Plug-Ins
 License:        LGPL-2.0+
 Group:          Multimedia/Framework