summaryrefslogtreecommitdiff
path: root/gst/effectv
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2011-07-27 12:42:21 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2011-07-27 12:42:21 +0100
commit13d0ad188fd4563bccb923cd62ff36b1379d6419 (patch)
tree1de284df13661e6338730e0834253aa7afe5ee78 /gst/effectv
parent443e9f7c1dcd7a68a0a528382a4a2061bec9eb6e (diff)
downloadgstreamer-plugins-good-13d0ad188fd4563bccb923cd62ff36b1379d6419.tar.gz
warp: add stride support
Diffstat (limited to 'gst/effectv')
-rw-r--r--gst/effectv/gstwarp.c47
-rw-r--r--gst/effectv/gstwarp.h1
2 files changed, 29 insertions, 19 deletions
diff --git a/gst/effectv/gstwarp.c b/gst/effectv/gstwarp.c
index c46021716..f4a617f34 100644
--- a/gst/effectv/gstwarp.c
+++ b/gst/effectv/gstwarp.c
@@ -54,6 +54,7 @@
#include <math.h>
#include "gstwarp.h"
+#include <gst/video/gstmetavideo.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
@@ -63,7 +64,6 @@
G_DEFINE_TYPE (GstWarpTV, gst_warptv, GST_TYPE_VIDEO_FILTER);
static void initSinTable ();
-static void initOffsTable (GstWarpTV * filter, gint width, gint height);
static void initDistTable (GstWarpTV * filter, gint width, gint height);
static GstStaticPadTemplate gst_warptv_src_template =
@@ -97,10 +97,7 @@ gst_warptv_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
height = GST_VIDEO_INFO_HEIGHT (&info);
g_free (filter->disttable);
- g_free (filter->offstable);
- filter->offstable = g_malloc (height * sizeof (guint32));
filter->disttable = g_malloc (width * height * sizeof (guint32));
- initOffsTable (filter, width, height);
initDistTable (filter, width, height);
return TRUE;
@@ -131,16 +128,6 @@ initSinTable (void)
}
static void
-initOffsTable (GstWarpTV * filter, gint width, gint height)
-{
- gint y;
-
- for (y = 0; y < height; y++) {
- filter->offstable[y] = y * width;
- }
-}
-
-static void
initDistTable (GstWarpTV * filter, gint width, gint height)
{
gint32 halfw, halfh, *distptr;
@@ -177,6 +164,7 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
gint32 skip, *ctptr, *distptr;
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);
@@ -185,6 +173,9 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
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) / 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);
@@ -226,9 +217,10 @@ gst_warptv_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
dy = 0;
else if (dy > maxy)
dy = maxy;
- *dest++ = src[warptv->offstable[dy] + dx];
+
+ dest[x] = src[dy * sstride + dx];
}
- dest += skip;
+ dest += dstride;
}
warptv->tval = (warptv->tval + 1) & 511;
@@ -250,13 +242,30 @@ gst_warptv_start (GstBaseTransform * trans)
return TRUE;
}
+static gboolean
+gst_wraptv_setup_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_meta (config, GST_META_API_VIDEO);
+ gst_buffer_pool_set_config (pool, config);
+ }
+ return TRUE;
+}
+
static void
gst_warptv_finalize (GObject * object)
{
GstWarpTV *warptv = GST_WARPTV (object);
- g_free (warptv->offstable);
- warptv->offstable = NULL;
g_free (warptv->disttable);
warptv->disttable = NULL;
@@ -284,6 +293,8 @@ gst_warptv_class_init (GstWarpTVClass * klass)
trans_class->start = GST_DEBUG_FUNCPTR (gst_warptv_start);
trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_warptv_set_caps);
+ trans_class->setup_allocation =
+ GST_DEBUG_FUNCPTR (gst_wraptv_setup_allocation);
trans_class->transform = GST_DEBUG_FUNCPTR (gst_warptv_transform);
initSinTable ();
diff --git a/gst/effectv/gstwarp.h b/gst/effectv/gstwarp.h
index 3609b5bfa..4c53499d0 100644
--- a/gst/effectv/gstwarp.h
+++ b/gst/effectv/gstwarp.h
@@ -52,7 +52,6 @@ struct _GstWarpTV
/* < private > */
GstVideoInfo info;
- gint *offstable;
gint32 *disttable;
gint32 ctable[1024];
gint tval;