mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
Add parameter to set the type of test pattern. Fix black test pattern.
Original commit message from CVS: Add parameter to set the type of test pattern. Fix black test pattern.
This commit is contained in:
parent
7d5843f31f
commit
fcb4b55a0c
3 changed files with 61 additions and 12 deletions
|
@ -52,6 +52,7 @@ enum
|
|||
ARG_HEIGHT,
|
||||
ARG_FOURCC,
|
||||
ARG_RATE,
|
||||
ARG_TYPE,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
|
@ -59,6 +60,7 @@ static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
|
|||
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
|
||||
static GstElementStateReturn gst_videotestsrc_change_state (GstElement * element);
|
||||
|
||||
static void gst_videotestsrc_set_pattern (GstVideotestsrc *src, int pattern_type);
|
||||
static void gst_videotestsrc_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
||||
|
@ -77,7 +79,7 @@ videotestsrc_src_template_factory(void)
|
|||
static GstPadTemplate *templ = NULL;
|
||||
|
||||
if(!templ){
|
||||
GstCaps *caps = GST_CAPS_NEW("ack","video/raw",
|
||||
GstCaps *caps = GST_CAPS_NEW("src","video/raw",
|
||||
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
||||
"height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||
|
||||
|
@ -111,6 +113,25 @@ gst_videotestsrc_get_type (void)
|
|||
return videotestsrc_type;
|
||||
}
|
||||
|
||||
#define GST_TYPE_VIDEOTESTSRC_PATTERN (gst_videotestsrc_pattern_get_type ())
|
||||
static GType
|
||||
gst_videotestsrc_pattern_get_type (void)
|
||||
{
|
||||
static GType videotestsrc_pattern_type = 0;
|
||||
static GEnumValue pattern_types[] = {
|
||||
{ GST_VIDEOTESTSRC_SMPTE, "smpte", "SMPTE 100% color bars" },
|
||||
{ GST_VIDEOTESTSRC_SNOW, "snow", "Random (television snow)" },
|
||||
{ GST_VIDEOTESTSRC_BLACK, "black", "0% Black" },
|
||||
{ 0, NULL, NULL },
|
||||
};
|
||||
|
||||
if (!videotestsrc_pattern_type){
|
||||
videotestsrc_pattern_type = g_enum_register_static("GstVideotestsrcPattern",
|
||||
pattern_types);
|
||||
}
|
||||
return videotestsrc_pattern_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
|
||||
{
|
||||
|
@ -132,6 +153,9 @@ gst_videotestsrc_class_init (GstVideotestsrcClass * klass)
|
|||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RATE,
|
||||
g_param_spec_int ("rate", "Rate", "Frame rate",
|
||||
1, 100, 30, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TYPE,
|
||||
g_param_spec_enum ("pattern", "Pattern", "Type of test pattern to generate",
|
||||
GST_TYPE_VIDEOTESTSRC_PATTERN, 1, G_PARAM_READWRITE));
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||
|
||||
|
@ -160,8 +184,6 @@ gst_videotestsrc_srcconnect (GstPad * pad, GstCaps * caps)
|
|||
gst_caps_get_int (caps, "width", &videotestsrc->width);
|
||||
gst_caps_get_int (caps, "height", &videotestsrc->height);
|
||||
|
||||
videotestsrc->make_image = gst_videotestsrc_smpte;
|
||||
videotestsrc->make_image = gst_videotestsrc_black;
|
||||
videotestsrc->bpp = videotestsrc->fourcc->bitspp;
|
||||
|
||||
GST_DEBUG (0, "size %d x %d", videotestsrc->width, videotestsrc->height);
|
||||
|
@ -258,6 +280,7 @@ gst_videotestsrc_init (GstVideotestsrc * videotestsrc)
|
|||
videotestsrc->interval = GST_SECOND / videotestsrc->rate;
|
||||
|
||||
videotestsrc->pool = NULL;
|
||||
gst_videotestsrc_set_pattern(videotestsrc, GST_VIDEOTESTSRC_SMPTE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,6 +322,27 @@ gst_videotestsrc_get (GstPad * pad)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_videotestsrc_set_pattern (GstVideotestsrc *src, int pattern_type)
|
||||
{
|
||||
src->type = pattern_type;
|
||||
|
||||
g_print("setting pattern to %d\n",pattern_type);
|
||||
switch(pattern_type){
|
||||
case GST_VIDEOTESTSRC_SMPTE:
|
||||
src->make_image = gst_videotestsrc_smpte;
|
||||
break;
|
||||
case GST_VIDEOTESTSRC_SNOW:
|
||||
src->make_image = gst_videotestsrc_snow;
|
||||
break;
|
||||
case GST_VIDEOTESTSRC_BLACK:
|
||||
src->make_image = gst_videotestsrc_black;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_videotestsrc_set_property (GObject * object, guint prop_id, const GValue * value,
|
||||
GParamSpec * pspec)
|
||||
|
@ -325,6 +369,9 @@ gst_videotestsrc_set_property (GObject * object, guint prop_id, const GValue * v
|
|||
src->rate = g_value_get_int (value);
|
||||
src->interval = GST_SECOND/src->rate;
|
||||
break;
|
||||
case ARG_TYPE:
|
||||
gst_videotestsrc_set_pattern (src, g_value_get_enum (value));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -353,6 +400,9 @@ gst_videotestsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
case ARG_RATE:
|
||||
g_value_set_int (value, src->rate);
|
||||
break;
|
||||
case ARG_TYPE:
|
||||
g_value_set_enum (value, src->type);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
|
@ -40,11 +40,10 @@ G_BEGIN_DECLS
|
|||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOTESTSRC))
|
||||
|
||||
typedef enum {
|
||||
GST_VIDEOTESTSRC_POINT_SAMPLE,
|
||||
GST_VIDEOTESTSRC_NEAREST,
|
||||
GST_VIDEOTESTSRC_BILINEAR,
|
||||
GST_VIDEOTESTSRC_BICUBIC
|
||||
} GstVideoTestSrcMethod;
|
||||
GST_VIDEOTESTSRC_SMPTE,
|
||||
GST_VIDEOTESTSRC_SNOW,
|
||||
GST_VIDEOTESTSRC_BLACK,
|
||||
} GstVideotestsrcPattern;
|
||||
|
||||
typedef struct _GstVideotestsrc GstVideotestsrc;
|
||||
typedef struct _GstVideotestsrcClass GstVideotestsrcClass;
|
||||
|
@ -66,6 +65,7 @@ struct _GstVideotestsrc {
|
|||
gint64 interval;
|
||||
gint bpp;
|
||||
int rate;
|
||||
int type;
|
||||
GstClock *clock;
|
||||
|
||||
GstBufferPool *pool;
|
||||
|
|
|
@ -593,7 +593,6 @@ gst_videotestsrc_black (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
|||
paintinfo pi;
|
||||
paintinfo *p = π
|
||||
struct fourcc_list_struct *fourcc;
|
||||
struct vts_color_struct color;
|
||||
|
||||
p->width = w;
|
||||
p->height = h;
|
||||
|
@ -604,10 +603,10 @@ gst_videotestsrc_black (GstVideotestsrc * v, unsigned char *dest, int w, int h)
|
|||
fourcc->paint_setup (p, dest);
|
||||
p->paint_hline = fourcc->paint_hline;
|
||||
|
||||
color = vts_colors[COLOR_BLACK];
|
||||
p->color = vts_colors + COLOR_BLACK;
|
||||
|
||||
for (i = 0; i < w; i++) {
|
||||
p->paint_hline (p, i, 0, w);
|
||||
for (i = 0; i < h; i++) {
|
||||
p->paint_hline (p, 0, i, w);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue