waylandsink : 1. develop to combine rotate with flip for correct flip rendering
authorHyunil <hyunil46.park@samsung.com>
Thu, 31 Mar 2016 01:16:01 +0000 (10:16 +0900)
committerHyunil <hyunil46.park@samsung.com>
Fri, 1 Apr 2016 03:30:27 +0000 (12:30 +0900)
              2. support to convert from TBM_FORMAT_NV12MT to GST_VIDEO_FORMAT_ST12 for caps negotiation.
              3. remove warning build log

Change-Id: I5d094a205ce7b9fae79a869b2e59d2fdc8465e3c
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
ext/wayland/gstwaylandsink.c
ext/wayland/wlwindow.c
ext/wayland/wlwindow.h

index 74f0891..ffdbbe1 100755 (executable)
@@ -883,13 +883,17 @@ gst_wayland_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
         tbm_fmt = g_array_index (formats, uint32_t, i);
         g_value_set_string (&value, gst_wl_tbm_format_to_string (tbm_fmt));
         gst_value_list_append_value (&list, &value);
-        /* TBM doesn't support SN12. So we add SN12 manually as supported format.
-         * SN12 is exactly same with NV12.
+        /* TBM doesn't support SN12 and ST12. So we add SN12 and ST12 manually as supported format.
+         * SN12 is same with NV12, ST12 is same with NV12MT
          */
         if (tbm_fmt == TBM_FORMAT_NV12) {
           g_value_set_string (&value,
               gst_video_format_to_string (GST_VIDEO_FORMAT_SN12));
           gst_value_list_append_value (&list, &value);
+        } else if (tbm_fmt == TBM_FORMAT_NV12MT) {
+          g_value_set_string (&value,
+              gst_video_format_to_string (GST_VIDEO_FORMAT_ST12));
+          gst_value_list_append_value (&list, &value);
         }
       } else {                  /* USE SHM */
         fmt = g_array_index (formats, uint32_t, i);
@@ -1210,7 +1214,7 @@ render_last_buffer (GstWaylandSink * sink)
     gst_wl_window_render (sink->window, wlbuffer, info);
   else {
     if (G_UNLIKELY (info)) {
-      gst_wl_window_set_video_info (sink->window, &info);
+      gst_wl_window_set_video_info (sink->window, info);
     }
   }
 #else
@@ -1553,7 +1557,7 @@ gst_wayland_sink_set_wl_window_wl_surface_id (GstVideoOverlay * overlay,
   g_mutex_lock (&sink->render_lock);
   g_clear_object (&sink->window);
 
-  GST_INFO ("wl_surface_id %d %p", (int) wl_surface_id,
+  GST_INFO ("wl_surface_id %d %x", (int) wl_surface_id,
       (guintptr) wl_surface_id);
 
   if (wl_surface_id) {
index d48da84..a3222ff 100644 (file)
 #include "wlshmallocator.h"
 #include "wlbuffer.h"
 
+enum
+{
+  ROTATE_0_FLIP_NONE,
+  ROTATE_0_FLIP_HORIZONTAL,
+  ROTATE_0_FLIP_VERTICAL,
+  ROTATE_0_FLIP_BOTH,
+  ROTATE_90_FLIP_NONE = 10,
+  ROTATE_90_FLIP_HORIZONTAL,
+  ROTATE_90_FLIP_VERTICAL,
+  ROTATE_90_FLIP_BOTH,
+  ROTATE_180_FLIP_NONE = 20,
+  ROTATE_180_FLIP_HORIZONTAL,
+  ROTATE_180_FLIP_VERTICAL,
+  ROTATE_180_FLIP_BOTH,
+  ROTATE_270_FLIP_NONE = 30,
+  ROTATE_270_FLIP_HORIZONTAL,
+  ROTATE_270_FLIP_VERTICAL,
+  ROTATE_270_FLIP_BOTH,
+  ROTATE_NUM,
+};
+
 GST_DEBUG_CATEGORY_EXTERN (gstwayland_debug);
 #define GST_CAT_DEFAULT gstwayland_debug
 
@@ -325,6 +346,69 @@ gst_wl_window_is_toplevel (GstWlWindow * window)
   return (window->shell_surface != NULL);
 }
 
+#ifdef GST_WLSINK_ENHANCEMENT
+static gint
+gst_wl_window_find_transform (guint rotate_angle, guint flip)
+{
+  gint transform;
+  guint combine = rotate_angle * 10 + flip;
+  FUNCTION;
+  GST_DEBUG ("rotate %d, flip %d, combine %d", rotate_angle, flip, combine);
+  switch (combine) {
+    case ROTATE_0_FLIP_NONE:
+      transform = WL_OUTPUT_TRANSFORM_NORMAL;
+      break;
+    case ROTATE_0_FLIP_HORIZONTAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED;
+      break;
+    case ROTATE_0_FLIP_VERTICAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
+      break;
+    case ROTATE_0_FLIP_BOTH:
+      transform = WL_OUTPUT_TRANSFORM_180;
+      break;
+    case ROTATE_90_FLIP_NONE:
+      transform = WL_OUTPUT_TRANSFORM_90;
+      break;
+    case ROTATE_90_FLIP_HORIZONTAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
+      break;
+    case ROTATE_90_FLIP_VERTICAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
+      break;
+    case ROTATE_90_FLIP_BOTH:
+      transform = WL_OUTPUT_TRANSFORM_270;
+      break;
+    case ROTATE_180_FLIP_NONE:
+      transform = WL_OUTPUT_TRANSFORM_180;
+      break;
+    case ROTATE_180_FLIP_HORIZONTAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
+      break;
+    case ROTATE_180_FLIP_VERTICAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED;
+      break;
+    case ROTATE_180_FLIP_BOTH:
+      transform = WL_OUTPUT_TRANSFORM_NORMAL;
+      break;
+    case ROTATE_270_FLIP_NONE:
+      transform = WL_OUTPUT_TRANSFORM_270;
+      break;
+    case ROTATE_270_FLIP_HORIZONTAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
+      break;
+    case ROTATE_270_FLIP_VERTICAL:
+      transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
+      break;
+    case ROTATE_270_FLIP_BOTH:
+      transform = WL_OUTPUT_TRANSFORM_90;
+      break;
+  }
+
+  return transform;
+}
+
+#endif
 static void
 gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
 {
@@ -414,41 +498,7 @@ gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
       break;
   }
 
-  switch (window->rotate_angle) {
-    case DEGREE_0:
-      transform = WL_OUTPUT_TRANSFORM_NORMAL;
-      break;
-    case DEGREE_90:
-      transform = WL_OUTPUT_TRANSFORM_90;
-      break;
-    case DEGREE_180:
-      transform = WL_OUTPUT_TRANSFORM_180;
-      break;
-    case DEGREE_270:
-      transform = WL_OUTPUT_TRANSFORM_270;
-      break;
-
-    default:
-      GST_ERROR ("Unsupported rotation [%d]... set DEGREE 0.",
-          window->rotate_angle);
-      break;
-  }
-
-  switch (window->flip) {
-    case FLIP_NONE:
-      break;
-    case FLIP_VERTICAL:
-      transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
-      break;
-    case FLIP_HORIZONTAL:
-      transform = WL_OUTPUT_TRANSFORM_FLIPPED;
-      break;
-    case FLIP_BOTH:
-      transform = WL_OUTPUT_TRANSFORM_180;
-      break;
-    default:
-      GST_ERROR ("Unsupported flip [%d]... set FLIP_NONE.", window->flip);
-  }
+  transform = gst_wl_window_find_transform (window->rotate_angle, window->flip);
 
   GST_INFO
       ("window[%d x %d] src[%d,%d,%d x %d],dst[%d,%d,%d x %d],input[%d,%d,%d x %d],result[%d,%d,%d x %d]",
@@ -604,7 +654,7 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
 
 #ifdef GST_WLSINK_ENHANCEMENT
 void
-gst_wl_window_set_video_info (GstWlWindow * window, GstVideoInfo * info)
+gst_wl_window_set_video_info (GstWlWindow * window, const GstVideoInfo * info)
 {
   FUNCTION;
   g_return_if_fail (window != NULL);
index 2547408..981199b 100644 (file)
@@ -85,7 +85,7 @@ void gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer,
 void gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
     gint w, gint h);
 #ifdef GST_WLSINK_ENHANCEMENT
-void gst_wl_window_set_video_info (GstWlWindow * window, GstVideoInfo * info);
+void gst_wl_window_set_video_info (GstWlWindow * window, const GstVideoInfo * info);
 void gst_wl_window_set_rotate_angle (GstWlWindow * window, guint rotate_angle);
 void gst_wl_window_set_disp_geo_method (GstWlWindow * window,
     guint disp_geo_method);