mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
Update for videofilter changes
Original commit message from CVS: Update for videofilter changes
This commit is contained in:
parent
918ae14118
commit
33e36146bc
1 changed files with 50 additions and 104 deletions
|
@ -27,27 +27,22 @@
|
||||||
* Copyright (C) 2001 Sun Microsystems
|
* Copyright (C) 2001 Sun Microsystems
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file was (probably) generated from gsttimeoverlay.c,
|
||||||
|
* gsttimeoverlay.c,v 1.7 2003/11/08 02:48:59 dschleef Exp
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*#define DEBUG_ENABLED */
|
/*#define DEBUG_ENABLED */
|
||||||
#include <gsttimeoverlay.h>
|
#include <gsttimeoverlay.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
#include <pango/pangoft2.h>
|
#include <pango/pangoft2.h>
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* elementfactory information */
|
|
||||||
static GstElementDetails timeoverlay_details = {
|
|
||||||
"Video Filter Template",
|
|
||||||
"Filter/Video",
|
|
||||||
"Template for a video filter",
|
|
||||||
"David Schleef <ds@schleef.org>",
|
|
||||||
};
|
|
||||||
|
|
||||||
/* GstTimeoverlay signals and args */
|
/* GstTimeoverlay signals and args */
|
||||||
enum {
|
enum {
|
||||||
|
@ -60,9 +55,9 @@ enum {
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_timeoverlay_base_init (gpointer g_class);
|
static void gst_timeoverlay_base_init (gpointer g_class);
|
||||||
static void gst_timeoverlay_class_init (GstTimeoverlayClass *klass);
|
static void gst_timeoverlay_class_init (gpointer g_class, gpointer class_data);
|
||||||
static void gst_timeoverlay_init (GstTimeoverlay *timeoverlay);
|
static void gst_timeoverlay_init (GTypeInstance *instance, gpointer g_class);
|
||||||
|
|
||||||
static void gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
static void gst_timeoverlay_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||||
static void gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
static void gst_timeoverlay_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||||
|
@ -70,10 +65,6 @@ static void gst_timeoverlay_get_property (GObject *object, guint prop_id, GValu
|
||||||
static void gst_timeoverlay_planar411(GstVideofilter *videofilter, void *dest, void *src);
|
static void gst_timeoverlay_planar411(GstVideofilter *videofilter, void *dest, void *src);
|
||||||
static void gst_timeoverlay_setup(GstVideofilter *videofilter);
|
static void gst_timeoverlay_setup(GstVideofilter *videofilter);
|
||||||
|
|
||||||
static GstTimeoverlayClass *this_class = NULL;
|
|
||||||
static GstVideofilterClass *parent_class = NULL;
|
|
||||||
static GstElementClass *element_class = NULL;
|
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_timeoverlay_get_type (void)
|
gst_timeoverlay_get_type (void)
|
||||||
{
|
{
|
||||||
|
@ -84,14 +75,15 @@ gst_timeoverlay_get_type (void)
|
||||||
sizeof(GstTimeoverlayClass),
|
sizeof(GstTimeoverlayClass),
|
||||||
gst_timeoverlay_base_init,
|
gst_timeoverlay_base_init,
|
||||||
NULL,
|
NULL,
|
||||||
(GClassInitFunc)gst_timeoverlay_class_init,
|
gst_timeoverlay_class_init,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
sizeof(GstTimeoverlay),
|
sizeof(GstTimeoverlay),
|
||||||
0,
|
0,
|
||||||
(GInstanceInitFunc)gst_timeoverlay_init,
|
gst_timeoverlay_init,
|
||||||
};
|
};
|
||||||
timeoverlay_type = g_type_register_static(GST_TYPE_VIDEOFILTER, "GstTimeoverlay", &timeoverlay_info, 0);
|
timeoverlay_type = g_type_register_static(GST_TYPE_VIDEOFILTER,
|
||||||
|
"GstTimeoverlay", &timeoverlay_info, 0);
|
||||||
}
|
}
|
||||||
return timeoverlay_type;
|
return timeoverlay_type;
|
||||||
}
|
}
|
||||||
|
@ -100,112 +92,63 @@ static GstVideofilterFormat gst_timeoverlay_formats[] = {
|
||||||
{ "I420", 12, gst_timeoverlay_planar411, },
|
{ "I420", 12, gst_timeoverlay_planar411, },
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstCaps *gst_timeoverlay_get_capslist(void)
|
|
||||||
{
|
|
||||||
GstVideofilterClass *klass;
|
|
||||||
|
|
||||||
klass = g_type_class_ref(GST_TYPE_VIDEOFILTER);
|
|
||||||
|
|
||||||
return gst_videofilter_class_get_capslist(klass);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadTemplate *
|
|
||||||
gst_timeoverlay_src_template_factory(void)
|
|
||||||
{
|
|
||||||
static GstPadTemplate *templ = NULL;
|
|
||||||
|
|
||||||
if(!templ){
|
|
||||||
GstCaps *caps = GST_CAPS_NEW("src","video/x-raw-yuv",
|
|
||||||
"width", GST_PROPS_INT_RANGE (1, G_MAXINT),
|
|
||||||
"height", GST_PROPS_INT_RANGE (1, G_MAXINT),
|
|
||||||
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
|
|
||||||
|
|
||||||
caps = gst_caps_intersect(caps, gst_timeoverlay_get_capslist ());
|
|
||||||
|
|
||||||
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
|
|
||||||
}
|
|
||||||
return templ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstPadTemplate *
|
|
||||||
gst_timeoverlay_sink_template_factory(void)
|
|
||||||
{
|
|
||||||
static GstPadTemplate *templ = NULL;
|
|
||||||
|
|
||||||
if(!templ){
|
|
||||||
GstCaps *caps = GST_CAPS_NEW("sink","video/x-raw-yuv",
|
|
||||||
"width", GST_PROPS_INT_RANGE (1, G_MAXINT),
|
|
||||||
"height", GST_PROPS_INT_RANGE (1, G_MAXINT),
|
|
||||||
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT));
|
|
||||||
|
|
||||||
caps = gst_caps_intersect(caps, gst_timeoverlay_get_capslist ());
|
|
||||||
|
|
||||||
templ = GST_PAD_TEMPLATE_NEW("src", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
|
||||||
}
|
|
||||||
return templ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_timeoverlay_base_init (gpointer g_class)
|
gst_timeoverlay_base_init (gpointer g_class)
|
||||||
{
|
{
|
||||||
|
static GstElementDetails timeoverlay_details = GST_ELEMENT_DETAILS (
|
||||||
|
"Time Overlay",
|
||||||
|
"Filter/Video",
|
||||||
|
"Overlays the time on a video stream",
|
||||||
|
"David Schleef <ds@schleef.org>"
|
||||||
|
);
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
||||||
|
GstVideofilterClass *videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
|
||||||
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_timeoverlay_sink_template_factory));
|
int i;
|
||||||
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (gst_timeoverlay_src_template_factory));
|
|
||||||
gst_element_class_set_details (element_class, &timeoverlay_details);
|
gst_element_class_set_details (element_class, &timeoverlay_details);
|
||||||
|
|
||||||
|
for(i=0;i<G_N_ELEMENTS(gst_timeoverlay_formats);i++){
|
||||||
|
gst_videofilter_class_add_format(videofilter_class,
|
||||||
|
gst_timeoverlay_formats + i);
|
||||||
|
}
|
||||||
|
|
||||||
gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
|
gst_videofilter_class_add_pad_templates (GST_VIDEOFILTER_CLASS (g_class));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_timeoverlay_class_init (GstTimeoverlayClass *klass)
|
gst_timeoverlay_class_init (gpointer g_class, gpointer class_data)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstVideofilterClass *videofilter_class;
|
||||||
GstVideofilterClass *gstvideofilter_class;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
gobject_class = (GObjectClass*)klass;
|
gobject_class = G_OBJECT_CLASS (g_class);
|
||||||
gstelement_class = (GstElementClass*)klass;
|
videofilter_class = GST_VIDEOFILTER_CLASS (g_class);
|
||||||
gstvideofilter_class = (GstVideofilterClass *)klass;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_METHOD,
|
g_object_class_install_property(gobject_class, ARG_METHOD,
|
||||||
g_param_spec_enum("method","method","method",
|
g_param_spec_enum("method","method","method",
|
||||||
GST_TYPE_TIMEOVERLAY_METHOD, GST_TIMEOVERLAY_METHOD_90R,
|
GST_TYPE_TIMEOVERLAY_METHOD, GST_TIMEOVERLAY_METHOD_1,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this_class = klass;
|
|
||||||
parent_class = g_type_class_ref(GST_TYPE_VIDEOFILTER);
|
|
||||||
element_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_timeoverlay_set_property;
|
gobject_class->set_property = gst_timeoverlay_set_property;
|
||||||
gobject_class->get_property = gst_timeoverlay_get_property;
|
gobject_class->get_property = gst_timeoverlay_get_property;
|
||||||
|
|
||||||
gstvideofilter_class->setup = gst_timeoverlay_setup;
|
videofilter_class->setup = gst_timeoverlay_setup;
|
||||||
|
|
||||||
for(i=0;i<G_N_ELEMENTS(gst_timeoverlay_formats);i++){
|
|
||||||
gst_videofilter_class_add_format(gstvideofilter_class, gst_timeoverlay_formats + i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_timeoverlay_init (GstTimeoverlay *timeoverlay)
|
gst_timeoverlay_init (GTypeInstance *instance, gpointer g_class)
|
||||||
{
|
{
|
||||||
|
GstTimeoverlay *timeoverlay = GST_TIMEOVERLAY (instance);
|
||||||
GstVideofilter *videofilter;
|
GstVideofilter *videofilter;
|
||||||
|
|
||||||
GST_DEBUG("gst_timeoverlay_init");
|
GST_DEBUG("gst_timeoverlay_init");
|
||||||
|
|
||||||
videofilter = GST_VIDEOFILTER(timeoverlay);
|
videofilter = GST_VIDEOFILTER(timeoverlay);
|
||||||
|
|
||||||
videofilter->sinkpad = gst_pad_new_from_template (
|
/* do stuff */
|
||||||
GST_PAD_TEMPLATE_GET (gst_timeoverlay_sink_template_factory),
|
|
||||||
"sink");
|
|
||||||
|
|
||||||
videofilter->srcpad = gst_pad_new_from_template (
|
|
||||||
GST_PAD_TEMPLATE_GET (gst_timeoverlay_src_template_factory),
|
|
||||||
"src");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -255,10 +198,8 @@ static gboolean plugin_init (GstPlugin *plugin)
|
||||||
if(!gst_library_load("gstvideofilter"))
|
if(!gst_library_load("gstvideofilter"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "timeoverlay", GST_RANK_NONE, GST_TYPE_TIMEOVERLAY))
|
return gst_element_register (plugin, "timeoverlay", GST_RANK_NONE,
|
||||||
return FALSE;
|
GST_TYPE_TIMEOVERLAY);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (
|
GST_PLUGIN_DEFINE (
|
||||||
|
@ -268,10 +209,11 @@ GST_PLUGIN_DEFINE (
|
||||||
"Time overlay",
|
"Time overlay",
|
||||||
plugin_init,
|
plugin_init,
|
||||||
VERSION,
|
VERSION,
|
||||||
"LGPL",
|
GST_LICENSE,
|
||||||
GST_COPYRIGHT,
|
GST_COPYRIGHT,
|
||||||
GST_PACKAGE,
|
GST_PACKAGE,
|
||||||
GST_ORIGIN)
|
GST_ORIGIN
|
||||||
|
)
|
||||||
|
|
||||||
static void gst_timeoverlay_setup(GstVideofilter *videofilter)
|
static void gst_timeoverlay_setup(GstVideofilter *videofilter)
|
||||||
{
|
{
|
||||||
|
@ -330,8 +272,8 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
|
||||||
void *dest, void *src)
|
void *dest, void *src)
|
||||||
{
|
{
|
||||||
GstTimeoverlay *timeoverlay;
|
GstTimeoverlay *timeoverlay;
|
||||||
int height;
|
|
||||||
int width;
|
int width;
|
||||||
|
int height;
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
int b_height, b_width;
|
int b_height, b_width;
|
||||||
|
@ -345,6 +287,9 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
|
||||||
width = gst_videofilter_get_input_width(videofilter);
|
width = gst_videofilter_get_input_width(videofilter);
|
||||||
height = gst_videofilter_get_input_height(videofilter);
|
height = gst_videofilter_get_input_height(videofilter);
|
||||||
|
|
||||||
|
width = gst_videofilter_get_input_width(videofilter);
|
||||||
|
height = gst_videofilter_get_input_height(videofilter);
|
||||||
|
|
||||||
layout = pango_layout_new (timeoverlay->context);
|
layout = pango_layout_new (timeoverlay->context);
|
||||||
string = gst_timeoverlay_print_smpte_time(GST_BUFFER_TIMESTAMP(videofilter->in_buf));
|
string = gst_timeoverlay_print_smpte_time(GST_BUFFER_TIMESTAMP(videofilter->in_buf));
|
||||||
pango_layout_set_text (layout, string, strlen(string));
|
pango_layout_set_text (layout, string, strlen(string));
|
||||||
|
@ -367,7 +312,7 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
|
||||||
for(i=0;i<b_height/2;i++){
|
for(i=0;i<b_height/2;i++){
|
||||||
memset(dest + width*height + i*(width/2), 128, b_width/2);
|
memset(dest + width*height + i*(width/2), 128, b_width/2);
|
||||||
memset(dest + width*height + (width/2)*(height/2) + i*(width/2), 128,
|
memset(dest + width*height + (width/2)*(height/2) + i*(width/2), 128,
|
||||||
b_width/2);
|
b_width/2);
|
||||||
}
|
}
|
||||||
bitmap.rows = b_height;
|
bitmap.rows = b_height;
|
||||||
bitmap.width = b_width;
|
bitmap.width = b_width;
|
||||||
|
@ -378,3 +323,4 @@ static void gst_timeoverlay_planar411(GstVideofilter *videofilter,
|
||||||
|
|
||||||
pango_ft2_render_layout (&bitmap, layout, 0, 0);
|
pango_ft2_render_layout (&bitmap, layout, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue