From 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 14 Mar 2004 22:34:33 +0000 Subject: gst-indent Original commit message from CVS: gst-indent --- ext/xvid/gstxviddec.c | 251 +++++++++++++++++++++++--------------------------- 1 file changed, 117 insertions(+), 134 deletions(-) (limited to 'ext/xvid/gstxviddec.c') diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c index 1266bcdb..cab1a027 100644 --- a/ext/xvid/gstxviddec.c +++ b/ext/xvid/gstxviddec.c @@ -35,90 +35,76 @@ GstElementDetails gst_xviddec_details = { "Ronald Bultje ", }; -static GstStaticPadTemplate sink_template = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "video/x-xvid, " - "width = (int) [ 0, MAX ], " - "height = (int) [ 0, MAX ], " - "framerate = (double) [ 0, MAX ]" - ) -); - -static GstStaticPadTemplate src_template = -GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") "; " - RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, 0x000000ff) "; " - RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, 0x0000ff00) "; " - RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, 0xff000000) "; " - RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, 0x00ff0000) "; " - RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, 0xff0000) "; " - GST_VIDEO_CAPS_RGB_15 "; " - GST_VIDEO_CAPS_RGB_16 - ) -); +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-xvid, " + "width = (int) [ 0, MAX ], " + "height = (int) [ 0, MAX ], " "framerate = (double) [ 0, MAX ]") + ); + +static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2, YV12, YVYU, UYVY }") + "; " RGB_24_32_STATIC_CAPS (32, 0x00ff0000, 0x0000ff00, + 0x000000ff) "; " RGB_24_32_STATIC_CAPS (32, 0xff000000, 0x00ff0000, + 0x0000ff00) "; " RGB_24_32_STATIC_CAPS (32, 0x0000ff00, 0x00ff0000, + 0xff000000) "; " RGB_24_32_STATIC_CAPS (32, 0x000000ff, 0x0000ff00, + 0x00ff0000) "; " RGB_24_32_STATIC_CAPS (24, 0x0000ff, 0x00ff00, + 0xff0000) "; " GST_VIDEO_CAPS_RGB_15 "; " GST_VIDEO_CAPS_RGB_16) + ); /* XvidDec signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 - /* FILL ME */ + /* FILL ME */ }; -static void gst_xviddec_base_init (gpointer g_class); -static void gst_xviddec_class_init (GstXvidDecClass *klass); -static void gst_xviddec_init (GstXvidDec *xviddec); -static void gst_xviddec_chain (GstPad *pad, - GstData *data); +static void gst_xviddec_base_init (gpointer g_class); +static void gst_xviddec_class_init (GstXvidDecClass * klass); +static void gst_xviddec_init (GstXvidDec * xviddec); +static void gst_xviddec_chain (GstPad * pad, GstData * data); static GstPadLinkReturn - gst_xviddec_sink_link (GstPad *pad, - const GstCaps *vscapslist); +gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscapslist); static GstPadLinkReturn - gst_xviddec_src_link (GstPad *pad, - const GstCaps *vscapslist); -static GstCaps * - gst_xviddec_src_getcaps (GstPad *pad); -static GstElementStateReturn - gst_xviddec_change_state (GstElement *element); +gst_xviddec_src_link (GstPad * pad, const GstCaps * vscapslist); +static GstCaps *gst_xviddec_src_getcaps (GstPad * pad); +static GstElementStateReturn gst_xviddec_change_state (GstElement * element); static GstElementClass *parent_class = NULL; + /* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_xviddec_get_type(void) +gst_xviddec_get_type (void) { static GType xviddec_type = 0; - if (!xviddec_type) - { + if (!xviddec_type) { static const GTypeInfo xviddec_info = { - sizeof(GstXvidDecClass), + sizeof (GstXvidDecClass), gst_xviddec_base_init, NULL, (GClassInitFunc) gst_xviddec_class_init, NULL, NULL, - sizeof(GstXvidDec), + sizeof (GstXvidDec), 0, (GInstanceInitFunc) gst_xviddec_init, }; - xviddec_type = g_type_register_static(GST_TYPE_ELEMENT, - "GstXvidDec", - &xviddec_info, 0); + xviddec_type = g_type_register_static (GST_TYPE_ELEMENT, + "GstXvidDec", &xviddec_info, 0); } return xviddec_type; } @@ -128,47 +114,47 @@ gst_xviddec_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_template)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_template)); gst_element_class_set_details (element_class, &gst_xviddec_details); } static void -gst_xviddec_class_init (GstXvidDecClass *klass) +gst_xviddec_class_init (GstXvidDecClass * klass) { GstElementClass *gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gstelement_class->change_state = gst_xviddec_change_state; } static void -gst_xviddec_init (GstXvidDec *xviddec) +gst_xviddec_init (GstXvidDec * xviddec) { - gst_xvid_init(); + gst_xvid_init (); /* create the sink pad */ - xviddec->sinkpad = gst_pad_new_from_template( - gst_static_pad_template_get (&sink_template), - "sink"); - gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->sinkpad); + xviddec->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sink_template), + "sink"); + gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->sinkpad); - gst_pad_set_chain_function(xviddec->sinkpad, gst_xviddec_chain); - gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_sink_link); + gst_pad_set_chain_function (xviddec->sinkpad, gst_xviddec_chain); + gst_pad_set_link_function (xviddec->sinkpad, gst_xviddec_sink_link); /* create the src pad */ - xviddec->srcpad = gst_pad_new_from_template( - gst_static_pad_template_get (&src_template), - "src"); - gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad); + xviddec->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&src_template), + "src"); + gst_element_add_pad (GST_ELEMENT (xviddec), xviddec->srcpad); gst_pad_set_getcaps_function (xviddec->srcpad, gst_xviddec_src_getcaps); - gst_pad_set_link_function(xviddec->srcpad, gst_xviddec_src_link); + gst_pad_set_link_function (xviddec->srcpad, gst_xviddec_src_link); /* size, etc. */ xviddec->width = xviddec->height = xviddec->csp = -1; @@ -179,16 +165,16 @@ gst_xviddec_init (GstXvidDec *xviddec) static void -gst_xviddec_unset (GstXvidDec *xviddec) +gst_xviddec_unset (GstXvidDec * xviddec) { /* unref this instance */ - xvid_decore(xviddec->handle, XVID_DEC_DESTROY, NULL, NULL); + xvid_decore (xviddec->handle, XVID_DEC_DESTROY, NULL, NULL); xviddec->handle = NULL; } static gboolean -gst_xviddec_setup (GstXvidDec *xviddec) +gst_xviddec_setup (GstXvidDec * xviddec) { xvid_dec_create_t xdec; int ret; @@ -199,12 +185,11 @@ gst_xviddec_setup (GstXvidDec *xviddec) xdec.height = xviddec->height; xdec.handle = NULL; - if ((ret = xvid_decore(NULL, XVID_DEC_CREATE, - &xdec, NULL)) < 0) { + if ((ret = xvid_decore (NULL, XVID_DEC_CREATE, &xdec, NULL)) < 0) { GST_ELEMENT_ERROR (xviddec, LIBRARY, SETTINGS, (NULL), - ("Setting parameters %dx%d@%d failed: %s (%d)", - xviddec->width, xviddec->height, xviddec->csp, - gst_xvid_error(ret), ret)); + ("Setting parameters %dx%d@%d failed: %s (%d)", + xviddec->width, xviddec->height, xviddec->csp, + gst_xvid_error (ret), ret)); return FALSE; } @@ -215,68 +200,65 @@ gst_xviddec_setup (GstXvidDec *xviddec) static void -gst_xviddec_chain (GstPad *pad, - GstData *_data) +gst_xviddec_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); - GstXvidDec *xviddec = GST_XVIDDEC(GST_OBJECT_PARENT(pad)); + GstXvidDec *xviddec = GST_XVIDDEC (GST_OBJECT_PARENT (pad)); GstBuffer *outbuf; xvid_dec_frame_t xframe; int ret; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); if (!xviddec->handle) { GST_ELEMENT_ERROR (xviddec, CORE, NEGOTIATION, (NULL), - ("format wasn't negotiated before chain function")); - gst_buffer_unref(buf); + ("format wasn't negotiated before chain function")); + gst_buffer_unref (buf); return; } - outbuf = gst_buffer_new_and_alloc(xviddec->width * - xviddec->height * - xviddec->bpp / 8); - GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); - GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf); - GST_BUFFER_SIZE(outbuf) = xviddec->width * - xviddec->height * - xviddec->bpp / 8; + outbuf = gst_buffer_new_and_alloc (xviddec->width * + xviddec->height * xviddec->bpp / 8); + GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); + GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); + GST_BUFFER_SIZE (outbuf) = xviddec->width * + xviddec->height * xviddec->bpp / 8; /* decode and so ... */ gst_xvid_init_struct (xframe); xframe.general = 0; - xframe.bitstream = (void *) GST_BUFFER_DATA(buf); - xframe.length = GST_BUFFER_SIZE(buf); + xframe.bitstream = (void *) GST_BUFFER_DATA (buf); + xframe.length = GST_BUFFER_SIZE (buf); xframe.output.csp = xviddec->csp; if (xviddec->width == xviddec->stride) { - xframe.output.plane[0] = GST_BUFFER_DATA(outbuf); - xframe.output.plane[1] = xframe.output.plane[0] + (xviddec->width * xviddec->height); - xframe.output.plane[2] = xframe.output.plane[1] + (xviddec->width * xviddec->height / 4); + xframe.output.plane[0] = GST_BUFFER_DATA (outbuf); + xframe.output.plane[1] = + xframe.output.plane[0] + (xviddec->width * xviddec->height); + xframe.output.plane[2] = + xframe.output.plane[1] + (xviddec->width * xviddec->height / 4); xframe.output.stride[0] = xviddec->width; xframe.output.stride[1] = xviddec->width / 2; xframe.output.stride[2] = xviddec->width / 2; } else { - xframe.output.plane[0] = GST_BUFFER_DATA(outbuf); + xframe.output.plane[0] = GST_BUFFER_DATA (outbuf); xframe.output.stride[0] = xviddec->stride; } - if ((ret = xvid_decore(xviddec->handle, XVID_DEC_DECODE, - &xframe, NULL)) < 0) { + if ((ret = xvid_decore (xviddec->handle, XVID_DEC_DECODE, &xframe, NULL)) < 0) { GST_ELEMENT_ERROR (xviddec, STREAM, DECODE, (NULL), - ("Error decoding xvid frame: %s (%d)\n", - gst_xvid_error(ret), ret)); - gst_buffer_unref(buf); - gst_buffer_unref(outbuf); + ("Error decoding xvid frame: %s (%d)\n", gst_xvid_error (ret), ret)); + gst_buffer_unref (buf); + gst_buffer_unref (outbuf); return; } - gst_pad_push(xviddec->srcpad, GST_DATA (outbuf)); - gst_buffer_unref(buf); + gst_pad_push (xviddec->srcpad, GST_DATA (outbuf)); + gst_buffer_unref (buf); } static GstCaps * -gst_xviddec_src_getcaps (GstPad *pad) +gst_xviddec_src_getcaps (GstPad * pad) { GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad)); GstCaps *caps; @@ -300,13 +282,15 @@ gst_xviddec_src_getcaps (GstPad *pad) if (!GST_PAD_CAPS (xviddec->sinkpad)) { GstPadTemplate *templ = gst_static_pad_template_get (&src_template); + return gst_caps_copy (gst_pad_template_get_caps (templ)); } caps = gst_caps_new_empty (); for (i = 0; csp[i] != 0; i++) { GstCaps *one = gst_xvid_csp_to_caps (csp[i], xviddec->width, - xviddec->height, xviddec->fps); + xviddec->height, xviddec->fps); + gst_caps_append (caps, one); } @@ -314,10 +298,9 @@ gst_xviddec_src_getcaps (GstPad *pad) } static GstPadLinkReturn -gst_xviddec_src_link (GstPad *pad, - const GstCaps *vscaps) +gst_xviddec_src_link (GstPad * pad, const GstCaps * vscaps) { - GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad)); + GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad)); GstStructure *structure = gst_caps_get_structure (vscaps, 0); if (!GST_PAD_CAPS (xviddec->sinkpad)) @@ -325,55 +308,55 @@ gst_xviddec_src_link (GstPad *pad, /* if there's something old around, remove it */ if (xviddec->handle) { - gst_xviddec_unset(xviddec); + gst_xviddec_unset (xviddec); } -g_print ("out: %s\n", gst_caps_to_string (vscaps)); + g_print ("out: %s\n", gst_caps_to_string (vscaps)); xviddec->csp = gst_xvid_structure_to_csp (structure, xviddec->width, - &xviddec->stride, - &xviddec->bpp); + &xviddec->stride, &xviddec->bpp); if (xviddec->csp < 0) return GST_PAD_LINK_REFUSED; - if (!gst_xviddec_setup(xviddec)) + if (!gst_xviddec_setup (xviddec)) return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_OK; } static GstPadLinkReturn -gst_xviddec_sink_link (GstPad *pad, - const GstCaps *vscaps) +gst_xviddec_sink_link (GstPad * pad, const GstCaps * vscaps) { - GstXvidDec *xviddec = GST_XVIDDEC(gst_pad_get_parent (pad)); + GstXvidDec *xviddec = GST_XVIDDEC (gst_pad_get_parent (pad)); GstStructure *structure; /* if there's something old around, remove it */ if (xviddec->handle) { - gst_xviddec_unset(xviddec); + gst_xviddec_unset (xviddec); } /* if we get here, we know the input is xvid. we * only need to bother with the output colorspace, * which the src_link function takes care of. */ structure = gst_caps_get_structure (vscaps, 0); - gst_structure_get_int(structure, "width", &xviddec->width); - gst_structure_get_int(structure, "height", &xviddec->height); - gst_structure_get_double(structure, "framerate", &xviddec->fps); -g_print ("in: %dx%d\n", xviddec->width, xviddec->height); + gst_structure_get_int (structure, "width", &xviddec->width); + gst_structure_get_int (structure, "height", &xviddec->height); + gst_structure_get_double (structure, "framerate", &xviddec->fps); + g_print ("in: %dx%d\n", xviddec->width, xviddec->height); /* re-nego? or just await src nego? */ - if (GST_PAD_CAPS(xviddec->srcpad)) { + if (GST_PAD_CAPS (xviddec->srcpad)) { GstPadLinkReturn ret; GstCaps *vscaps = gst_pad_get_allowed_caps (xviddec->srcpad), *new; gint i, csp; for (i = 0; i < gst_caps_get_size (vscaps); i++) { csp = gst_xvid_structure_to_csp (gst_caps_get_structure (vscaps, i), - 0, NULL, NULL); - new = gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height, xviddec->fps); - ret = gst_pad_try_set_caps(xviddec->srcpad, new); + 0, NULL, NULL); + new = + gst_xvid_csp_to_caps (csp, xviddec->width, xviddec->height, + xviddec->fps); + ret = gst_pad_try_set_caps (xviddec->srcpad, new); if (ret != GST_PAD_LINK_REFUSED) - return ret; + return ret; } return GST_PAD_LINK_REFUSED; @@ -383,14 +366,14 @@ g_print ("in: %dx%d\n", xviddec->width, xviddec->height); } static GstElementStateReturn -gst_xviddec_change_state (GstElement *element) +gst_xviddec_change_state (GstElement * element) { GstXvidDec *xviddec = GST_XVIDDEC (element); switch (GST_STATE_PENDING (element)) { case GST_STATE_PAUSED_TO_READY: if (xviddec->handle) { - gst_xviddec_unset (xviddec); + gst_xviddec_unset (xviddec); } break; default: -- cgit v1.2.1