* <refsect2>
* <title>Example launch line</title>
* |[
- * gst-launch -v videotestsrc ! warptv ! ffmpegcolorspace ! autovideosink
+ * gst-launch -v videotestsrc ! warptv ! videoconvert ! autovideosink
* ]| This pipeline shows the effect of warptv on a test stream.
* </refsect2>
*/
#include <math.h>
#include "gstwarp.h"
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
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 =
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;
}
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;
gint x, y;
-#ifdef PS2
- float m;
-#else
float m;
-#endif
halfw = width >> 1;
halfh = height >> 1;
gint width, height;
gint xw, yw, cw;
gint32 c, i, x, y, dx, dy, maxx, maxy;
- gint32 skip, *ctptr, *distptr;
+ gint32 *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);
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);
distptr = warptv->disttable;
ctable = warptv->ctable;
- skip = 0; /* video_width*sizeof(RGB32)/4 - video_width;; */
c = 0;
for (x = 0; x < 512; x++) {
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;
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_VIDEO_META);
+ 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;
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);
initSinTable ();
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 */
}