Some more goom fixes

Original commit message from CVS:
Some more goom fixes
This commit is contained in:
Wim Taymans 2002-02-02 13:51:56 +00:00
parent 4d3b1472e7
commit 39af162cb1

View file

@ -40,18 +40,13 @@ struct _GstGOOM {
// the timestamp of the next frame // the timestamp of the next frame
guint64 next_time; guint64 next_time;
gint16 datain[2][512];
// video state // video state
gint bpp; gint fps;
gint depth;
gint width; gint width;
gint height; gint height;
gboolean first_buffer; gboolean first_buffer;
gint samplerate;
gint framerate; // desired frame rate
gint samples_between_frames; // number of samples between start of successive frames
gint samples_since_last_frame; // number of samples between start of successive frames
}; };
struct _GstGOOMClass { struct _GstGOOMClass {
@ -79,6 +74,9 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_WIDTH,
ARG_HEIGHT,
ARG_FPS,
/* FILL ME */ /* FILL ME */
}; };
@ -169,6 +167,16 @@ gst_goom_class_init(GstGOOMClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH,
g_param_spec_int ("width","Width","The Width",
0, 2048, 320, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT,
g_param_spec_int ("height","Height","The height",
0, 2048, 320, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FPS,
g_param_spec_int ("fps","FPS","Frames per second",
1, 100, 25, G_PARAM_READWRITE));
gobject_class->set_property = gst_goom_set_property; gobject_class->set_property = gst_goom_set_property;
gobject_class->get_property = gst_goom_get_property; gobject_class->get_property = gst_goom_get_property;
} }
@ -191,18 +199,11 @@ gst_goom_init (GstGOOM *goom)
goom->peerpool = NULL; goom->peerpool = NULL;
// reset the initial video state // reset the initial video state
goom->bpp = 32;
goom->depth = 32;
goom->first_buffer = TRUE; goom->first_buffer = TRUE;
goom->width = 320; goom->width = 320;
goom->height = 200; goom->height = 200;
goom->fps = 25; // desired frame rate
goom->samplerate = -1;
goom->framerate = 25; // desired frame rate
goom->samples_between_frames = 0; // number of samples between start of successive frames
goom->samples_since_last_frame = 0;
goom_init (goom->width, goom->height);
} }
static GstPadConnectReturn static GstPadConnectReturn
@ -215,12 +216,6 @@ gst_goom_sinkconnect (GstPad *pad, GstCaps *caps)
return GST_PAD_CONNECT_DELAYED; return GST_PAD_CONNECT_DELAYED;
} }
goom->samplerate = gst_caps_get_int (caps, "rate");
goom->samples_between_frames = goom->samplerate / goom->framerate;
GST_DEBUG (0, "GOOM: new sink caps: rate %d\n",
goom->samplerate);
return GST_PAD_CONNECT_OK; return GST_PAD_CONNECT_OK;
} }
@ -230,7 +225,8 @@ gst_goom_chain (GstPad *pad, GstBuffer *bufin)
GstGOOM *goom; GstGOOM *goom;
GstBuffer *bufout; GstBuffer *bufout;
guint32 samples_in; guint32 samples_in;
gint16 datain[2][512]; gint16 *data;
gint i;
goom = GST_GOOM (gst_pad_get_parent (pad)); goom = GST_GOOM (gst_pad_get_parent (pad));
@ -240,12 +236,21 @@ gst_goom_chain (GstPad *pad, GstBuffer *bufin)
GST_DEBUG (0, "input buffer has %d samples\n", samples_in); GST_DEBUG (0, "input buffer has %d samples\n", samples_in);
if (goom->next_time <= GST_BUFFER_TIMESTAMP (bufin)) { if (GST_BUFFER_TIMESTAMP (bufin) < goom->next_time || samples_in < 1024) {
goom->next_time = GST_BUFFER_TIMESTAMP (bufin); gst_buffer_unref (bufin);
GST_DEBUG (0, "in: %lld\n", GST_BUFFER_TIMESTAMP (bufin)); return;
} }
data = (gint16 *) GST_BUFFER_DATA (bufin);
for (i=0; i < 512; i++) {
goom->datain[0][i] = *data++;
goom->datain[1][i] = *data++;
}
if (goom->first_buffer) { if (goom->first_buffer) {
GstCaps *caps; GstCaps *caps;
goom_init (goom->width, goom->height);
GST_DEBUG (0, "making new pad\n"); GST_DEBUG (0, "making new pad\n");
@ -253,8 +258,8 @@ gst_goom_chain (GstPad *pad, GstBuffer *bufin)
"goomsrc", "goomsrc",
"video/raw", "video/raw",
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")),
"bpp", GST_PROPS_INT (goom->bpp), "bpp", GST_PROPS_INT (32),
"depth", GST_PROPS_INT (goom->depth), "depth", GST_PROPS_INT (32),
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "endianness", GST_PROPS_INT (G_BYTE_ORDER),
"red_mask", GST_PROPS_INT (0xff0000), "red_mask", GST_PROPS_INT (0xff0000),
"green_mask", GST_PROPS_INT (0x00ff00), "green_mask", GST_PROPS_INT (0x00ff00),
@ -270,19 +275,20 @@ gst_goom_chain (GstPad *pad, GstBuffer *bufin)
goom->first_buffer = FALSE; goom->first_buffer = FALSE;
} }
memcpy (&datain[0][0], GST_BUFFER_DATA (bufin), 512);
memcpy (&datain[1][0], GST_BUFFER_DATA (bufin), 512);
bufout = gst_buffer_new (); bufout = gst_buffer_new ();
GST_BUFFER_DATA (bufout) = (guchar *) goom_update (datain);
GST_BUFFER_SIZE (bufout) = goom->width * goom->height * 4; GST_BUFFER_SIZE (bufout) = goom->width * goom->height * 4;
GST_BUFFER_DATA (bufout) = (guchar *) goom_update (goom->datain);
GST_BUFFER_TIMESTAMP (bufout) = goom->next_time;
GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_DONTFREE); GST_BUFFER_FLAG_SET (bufout, GST_BUFFER_DONTFREE);
goom->next_time += 40000LL;
gst_pad_push (goom->srcpad, bufout); gst_pad_push (goom->srcpad, bufout);
gst_buffer_unref (bufin); gst_buffer_unref (bufin);
GST_DEBUG (0, "GOOM: exiting chainfunc\n"); GST_DEBUG (0, "GOOM: exiting chainfunc\n");
} }
static void static void
@ -295,6 +301,15 @@ gst_goom_set_property (GObject *object, guint prop_id, const GValue *value, GPar
goom = GST_GOOM (object); goom = GST_GOOM (object);
switch (prop_id) { switch (prop_id) {
case ARG_WIDTH:
goom->width = g_value_get_int (value);
break;
case ARG_HEIGHT:
goom->height = g_value_get_int (value);
break;
case ARG_FPS:
goom->fps = g_value_get_int (value);
break;
default: default:
break; break;
} }
@ -310,6 +325,15 @@ gst_goom_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec
goom = GST_GOOM (object); goom = GST_GOOM (object);
switch (prop_id) { switch (prop_id) {
case ARG_WIDTH:
g_value_set_int (value, goom->width);
break;
case ARG_HEIGHT:
g_value_set_int (value, goom->height);
break;
case ARG_FPS:
g_value_set_int (value, goom->fps);
break;
default: default:
break; break;
} }