v4l2videodec: Increase v4l2videodecoder rank
[platform/upstream/gst-plugins-good.git] / gst / effectv / gstwarp.c
index 72a45c0..841ed8c 100644 (file)
@@ -17,8 +17,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /*
@@ -41,7 +41,7 @@
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch -v videotestsrc ! warptv ! videoconvert ! autovideosink
+ * gst-launch-1.0 -v videotestsrc ! warptv ! videoconvert ! autovideosink
  * ]| This pipeline shows the effect of warptv on a test stream.
  * </refsect2>
  */
@@ -54,7 +54,7 @@
 #include <math.h>
 
 #include "gstwarp.h"
-#include <gst/video/gstmetavideo.h>
+#include <gst/video/gstvideometa.h>
 #include <gst/video/gstvideopool.h>
 
 #ifndef M_PI
@@ -82,33 +82,20 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     );
 
 static gboolean
-gst_warptv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
-    GstCaps * outcaps)
+gst_warptv_set_info (GstVideoFilter * vfilter, GstCaps * incaps,
+    GstVideoInfo * in_info, GstCaps * outcaps, GstVideoInfo * out_info)
 {
-  GstWarpTV *filter = GST_WARPTV (btrans);
-  GstVideoInfo info;
+  GstWarpTV *filter = GST_WARPTV (vfilter);
   gint width, height;
 
-  if (!gst_video_info_from_caps (&info, incaps))
-    goto invalid_caps;
-
-  filter->info = info;
-
-  width = GST_VIDEO_INFO_WIDTH (&info);
-  height = GST_VIDEO_INFO_HEIGHT (&info);
+  width = GST_VIDEO_INFO_WIDTH (in_info);
+  height = GST_VIDEO_INFO_HEIGHT (in_info);
 
   g_free (filter->disttable);
   filter->disttable = g_malloc (width * height * sizeof (guint32));
   initDistTable (filter, width, height);
 
   return TRUE;
-
-  /* ERRORS */
-invalid_caps:
-  {
-    GST_DEBUG_OBJECT (filter, "invalid caps received");
-    return FALSE;
-  }
 }
 
 static gint32 sintable[1024 + 256];
@@ -133,11 +120,7 @@ initDistTable (GstWarpTV * filter, gint width, gint height)
 {
   gint32 halfw, halfh, *distptr;
   gint x, y;
-#ifdef PS2
   float m;
-#else
-  float m;
-#endif
 
   halfw = width >> 1;
   halfh = height >> 1;
@@ -156,9 +139,10 @@ initDistTable (GstWarpTV * filter, gint width, gint height)
 }
 
 static GstFlowReturn
-gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
+gst_warptv_transform_frame (GstVideoFilter * filter, GstVideoFrame * in_frame,
+    GstVideoFrame * out_frame)
 {
-  GstWarpTV *warptv = GST_WARPTV (trans);
+  GstWarpTV *warptv = GST_WARPTV (filter);
   gint width, height;
   gint xw, yw, cw;
   gint32 c, i, x, y, dx, dy, maxx, maxy;
@@ -166,19 +150,15 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
   gint32 *ctable;
   guint32 *src, *dest;
   gint sstride, dstride;
-  GstVideoFrame in_frame, out_frame;
 
-  gst_video_frame_map (&in_frame, &warptv->info, in, GST_MAP_READ);
-  gst_video_frame_map (&out_frame, &warptv->info, out, GST_MAP_WRITE);
+  src = GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0);
+  dest = GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0);
 
-  src = GST_VIDEO_FRAME_PLANE_DATA (&in_frame, 0);
-  dest = GST_VIDEO_FRAME_PLANE_DATA (&out_frame, 0);
+  sstride = GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 0);
+  dstride = GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 0);
 
-  sstride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0) / 4;
-  dstride = GST_VIDEO_FRAME_PLANE_STRIDE (&out_frame, 0) / 4;
-
-  width = GST_VIDEO_FRAME_WIDTH (&in_frame);
-  height = GST_VIDEO_FRAME_HEIGHT (&in_frame);
+  width = GST_VIDEO_FRAME_WIDTH (in_frame);
+  height = GST_VIDEO_FRAME_HEIGHT (in_frame);
 
   GST_OBJECT_LOCK (warptv);
   xw = (gint) (sin ((warptv->tval + 100) * M_PI / 128) * 30);
@@ -218,17 +198,14 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
       else if (dy > maxy)
         dy = maxy;
 
-      dest[x] = src[dy * sstride + dx];
+      dest[x] = src[dy * sstride / 4 + dx];
     }
-    dest += dstride;
+    dest += dstride / 4;
   }
 
   warptv->tval = (warptv->tval + 1) & 511;
   GST_OBJECT_UNLOCK (warptv);
 
-  gst_video_frame_unmap (&in_frame);
-  gst_video_frame_unmap (&out_frame);
-
   return GST_FLOW_OK;
 }
 
@@ -242,26 +219,6 @@ gst_warptv_start (GstBaseTransform * trans)
   return TRUE;
 }
 
-static gboolean
-gst_wraptv_decide_allocation (GstBaseTransform * trans, GstQuery * query)
-{
-  GstBufferPool *pool = NULL;
-  guint size, min, max, prefix, alignment;
-
-  gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
-      &alignment, &pool);
-
-  if (pool) {
-    GstStructure *config;
-
-    config = gst_buffer_pool_get_config (pool);
-    gst_buffer_pool_config_add_option (config,
-        GST_BUFFER_POOL_OPTION_META_VIDEO);
-    gst_buffer_pool_set_config (pool, config);
-  }
-  return TRUE;
-}
-
 static void
 gst_warptv_finalize (GObject * object)
 {
@@ -279,24 +236,25 @@ gst_warptv_class_init (GstWarpTVClass * klass)
   GObjectClass *gobject_class = (GObjectClass *) klass;
   GstElementClass *gstelement_class = (GstElementClass *) klass;
   GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
+  GstVideoFilterClass *vfilter_class = (GstVideoFilterClass *) klass;
 
   gobject_class->finalize = gst_warptv_finalize;
 
-  gst_element_class_set_details_simple (gstelement_class, "WarpTV effect",
+  gst_element_class_set_static_metadata (gstelement_class, "WarpTV effect",
       "Filter/Effect/Video",
       "WarpTV does realtime goo'ing of the video input",
       "Sam Lantinga <slouken@devolution.com>");
 
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_warptv_sink_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&gst_warptv_src_template));
+  gst_element_class_add_static_pad_template (gstelement_class,
+      &gst_warptv_sink_template);
+  gst_element_class_add_static_pad_template (gstelement_class,
+      &gst_warptv_src_template);
 
   trans_class->start = GST_DEBUG_FUNCPTR (gst_warptv_start);
-  trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_warptv_set_caps);
-  trans_class->decide_allocation =
-      GST_DEBUG_FUNCPTR (gst_wraptv_decide_allocation);
-  trans_class->transform = GST_DEBUG_FUNCPTR (gst_warptv_transform);
+
+  vfilter_class->set_info = GST_DEBUG_FUNCPTR (gst_warptv_set_info);
+  vfilter_class->transform_frame =
+      GST_DEBUG_FUNCPTR (gst_warptv_transform_frame);
 
   initSinTable ();
 }
@@ -304,6 +262,5 @@ gst_warptv_class_init (GstWarpTVClass * klass)
 static void
 gst_warptv_init (GstWarpTV * warptv)
 {
-  gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (warptv));
-  gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SINK_PAD (warptv));
+  /* nothing to do */
 }