From a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 14 Mar 2004 20:47:18 +0000 Subject: indentation test Original commit message from CVS: indentation test --- ext/divx/gstdivxdec.c | 423 +++++++++++++++++++++++++------------------------- 1 file changed, 211 insertions(+), 212 deletions(-) (limited to 'ext/divx/gstdivxdec.c') diff --git a/ext/divx/gstdivxdec.c b/ext/divx/gstdivxdec.c index de89c72f..737a14ec 100644 --- a/ext/divx/gstdivxdec.c +++ b/ext/divx/gstdivxdec.c @@ -33,55 +33,49 @@ GstElementDetails gst_divxdec_details = { "Ronald Bultje " }; -static GstStaticPadTemplate sink_template = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "video/x-divx, " - "divxversion = (int) [ 3, 5 ], " - "width = (int) [ 16, 4096 ], " - "height = (int) [ 16, 4096 ], " - "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, UYVY }") - /* FIXME: 15/16/24/32bpp RGB */ - ) -); +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-divx, " + "divxversion = (int) [ 3, 5 ], " + "width = (int) [ 16, 4096 ], " + "height = (int) [ 16, 4096 ], " "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, UYVY }") + /* FIXME: 15/16/24/32bpp RGB */ + ) + ); /* DivxDec signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 - /* FILL ME */ + /* FILL ME */ }; -static void gst_divxdec_base_init (GstDivxDecClass *klass); -static void gst_divxdec_class_init (GstDivxDecClass *klass); -static void gst_divxdec_init (GstDivxDec *divxdec); -static void gst_divxdec_dispose (GObject *object); -static void gst_divxdec_chain (GstPad *pad, - GstData *data); -static GstPadLinkReturn gst_divxdec_connect (GstPad *pad, - const GstCaps *vscapslist); -static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec); +static void gst_divxdec_base_init (GstDivxDecClass * klass); +static void gst_divxdec_class_init (GstDivxDecClass * klass); +static void gst_divxdec_init (GstDivxDec * divxdec); +static void gst_divxdec_dispose (GObject * object); +static void gst_divxdec_chain (GstPad * pad, GstData * data); +static GstPadLinkReturn gst_divxdec_connect (GstPad * pad, + const GstCaps * vscapslist); +static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec * divxdec); static GstElementClass *parent_class = NULL; + /* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */ @@ -115,72 +109,70 @@ gst_divxdec_error (int errorcode) } GType -gst_divxdec_get_type(void) +gst_divxdec_get_type (void) { static GType divxdec_type = 0; - if (!divxdec_type) - { + if (!divxdec_type) { static const GTypeInfo divxdec_info = { - sizeof(GstDivxDecClass), + sizeof (GstDivxDecClass), (GBaseInitFunc) gst_divxdec_base_init, NULL, (GClassInitFunc) gst_divxdec_class_init, NULL, NULL, - sizeof(GstDivxDec), + sizeof (GstDivxDec), 0, (GInstanceInitFunc) gst_divxdec_init, }; - divxdec_type = g_type_register_static(GST_TYPE_ELEMENT, - "GstDivxDec", - &divxdec_info, 0); + divxdec_type = g_type_register_static (GST_TYPE_ELEMENT, + "GstDivxDec", &divxdec_info, 0); } return divxdec_type; } static void -gst_divxdec_base_init (GstDivxDecClass *klass) +gst_divxdec_base_init (GstDivxDecClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&sink_template)); + gst_static_pad_template_get (&sink_template)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&src_template)); + gst_static_pad_template_get (&src_template)); gst_element_class_set_details (element_class, &gst_divxdec_details); } static void -gst_divxdec_class_init (GstDivxDecClass *klass) +gst_divxdec_class_init (GstDivxDecClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gobject_class->dispose = gst_divxdec_dispose; } static void -gst_divxdec_init (GstDivxDec *divxdec) +gst_divxdec_init (GstDivxDec * divxdec) { /* create the sink pad */ - divxdec->sinkpad = gst_pad_new_from_template( - gst_static_pad_template_get (&sink_template), - "sink"); - gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->sinkpad); - gst_pad_set_chain_function(divxdec->sinkpad, gst_divxdec_chain); - gst_pad_set_link_function(divxdec->sinkpad, gst_divxdec_connect); + divxdec->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sink_template), + "sink"); + gst_element_add_pad (GST_ELEMENT (divxdec), divxdec->sinkpad); + gst_pad_set_chain_function (divxdec->sinkpad, gst_divxdec_chain); + gst_pad_set_link_function (divxdec->sinkpad, gst_divxdec_connect); /* create the src pad */ - divxdec->srcpad = gst_pad_new_from_template( - gst_static_pad_template_get (&src_template), - "src"); - gst_element_add_pad(GST_ELEMENT(divxdec), divxdec->srcpad); + divxdec->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&src_template), + "src"); + gst_element_add_pad (GST_ELEMENT (divxdec), divxdec->srcpad); gst_pad_use_explicit_caps (divxdec->srcpad); /* bitrate, etc. */ @@ -193,18 +185,18 @@ gst_divxdec_init (GstDivxDec *divxdec) static void -gst_divxdec_unset (GstDivxDec *divxdec) +gst_divxdec_unset (GstDivxDec * divxdec) { if (divxdec->handle) { /* unref this instance */ - decore(divxdec->handle, DEC_OPT_RELEASE, NULL, NULL); + decore (divxdec->handle, DEC_OPT_RELEASE, NULL, NULL); divxdec->handle = NULL; } } static gboolean -gst_divxdec_setup (GstDivxDec *divxdec) +gst_divxdec_setup (GstDivxDec * divxdec) { void *handle; DEC_INIT xinit; @@ -212,7 +204,7 @@ gst_divxdec_setup (GstDivxDec *divxdec) int ret; /* initialize the handle */ - memset(&xinit, 0, sizeof(DEC_INIT)); + memset (&xinit, 0, sizeof (DEC_INIT)); xinit.smooth_playback = 0; switch (divxdec->version) { case 3: @@ -228,9 +220,9 @@ gst_divxdec_setup (GstDivxDec *divxdec) xinit.codec_version = 0; break; } - if ((ret = decore(&handle, DEC_OPT_INIT, &xinit, NULL)) != 0) { + if ((ret = decore (&handle, DEC_OPT_INIT, &xinit, NULL)) != 0) { GST_ELEMENT_ERROR (divxdec, LIBRARY, INIT, (NULL), - ("divx library error: %s (%d)", gst_divxdec_error (ret), ret)); + ("divx library error: %s (%d)", gst_divxdec_error (ret), ret)); return FALSE; } @@ -238,19 +230,17 @@ gst_divxdec_setup (GstDivxDec *divxdec) divxdec->handle = handle; /* initialise parameters, see divx documentation */ - memset(&output, 0, sizeof(DivXBitmapInfoHeader)); - output.biSize = sizeof(DivXBitmapInfoHeader); + memset (&output, 0, sizeof (DivXBitmapInfoHeader)); + output.biSize = sizeof (DivXBitmapInfoHeader); output.biWidth = divxdec->width; output.biHeight = divxdec->height; output.biBitCount = divxdec->bitcnt; output.biCompression = divxdec->csp; - if ((ret = decore(divxdec->handle, DEC_OPT_SETOUT, - &output, NULL)) != 0) { + if ((ret = decore (divxdec->handle, DEC_OPT_SETOUT, &output, NULL)) != 0) { GST_ELEMENT_ERROR (divxdec, LIBRARY, SETTINGS, (NULL), - ("error setting output: %s (%d)", - gst_divxdec_error (ret), ret)); - gst_divxdec_unset(divxdec); + ("error setting output: %s (%d)", gst_divxdec_error (ret), ret)); + gst_divxdec_unset (divxdec); return FALSE; } @@ -259,17 +249,16 @@ gst_divxdec_setup (GstDivxDec *divxdec) static void -gst_divxdec_dispose (GObject *object) +gst_divxdec_dispose (GObject * object) { - GstDivxDec *divxdec = GST_DIVXDEC(object); + GstDivxDec *divxdec = GST_DIVXDEC (object); - gst_divxdec_unset(divxdec); + gst_divxdec_unset (divxdec); } static void -gst_divxdec_chain (GstPad *pad, - GstData *_data) +gst_divxdec_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstDivxDec *divxdec; @@ -277,146 +266,162 @@ gst_divxdec_chain (GstPad *pad, DEC_FRAME xframe; int ret; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); - divxdec = GST_DIVXDEC(GST_OBJECT_PARENT(pad)); + divxdec = GST_DIVXDEC (GST_OBJECT_PARENT (pad)); if (!divxdec->handle) { - if (gst_divxdec_negotiate(divxdec) <= 0) { + if (gst_divxdec_negotiate (divxdec) <= 0) { GST_ELEMENT_ERROR (divxdec, CORE, TOO_LAZY, (NULL), - ("No format set - aborting")); - gst_buffer_unref(buf); + ("No format set - aborting")); + gst_buffer_unref (buf); return; } } - outbuf = gst_buffer_new_and_alloc(divxdec->width * - divxdec->height * - divxdec->bpp / 8); - GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); - GST_BUFFER_SIZE(outbuf) = divxdec->width * - divxdec->height * - divxdec->bpp / 8; + outbuf = gst_buffer_new_and_alloc (divxdec->width * + divxdec->height * divxdec->bpp / 8); + GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); + GST_BUFFER_SIZE (outbuf) = divxdec->width * + divxdec->height * divxdec->bpp / 8; /* encode and so ... */ - xframe.bitstream = (void *) GST_BUFFER_DATA(buf); - xframe.bmp = (void *) GST_BUFFER_DATA(outbuf); - xframe.length = GST_BUFFER_SIZE(buf); + xframe.bitstream = (void *) GST_BUFFER_DATA (buf); + xframe.bmp = (void *) GST_BUFFER_DATA (outbuf); + xframe.length = GST_BUFFER_SIZE (buf); xframe.stride = 0; xframe.render_flag = 1; - if ((ret = decore(divxdec->handle, DEC_OPT_FRAME, - &xframe, NULL))) { + if ((ret = decore (divxdec->handle, DEC_OPT_FRAME, &xframe, NULL))) { GST_ELEMENT_ERROR (divxdec, STREAM, DECODE, (NULL), - ("Error decoding divx frame: %s (%d)", - gst_divxdec_error(ret), ret)); - gst_buffer_unref(buf); + ("Error decoding divx frame: %s (%d)", gst_divxdec_error (ret), ret)); + gst_buffer_unref (buf); return; } - gst_pad_push(divxdec->srcpad, GST_DATA (outbuf)); - gst_buffer_unref(buf); + gst_pad_push (divxdec->srcpad, GST_DATA (outbuf)); + gst_buffer_unref (buf); } -static GstPadLinkReturn -gst_divxdec_negotiate (GstDivxDec *divxdec) +/* FIXME: moved all the bits out here that are broken so the syntax + * stays clear */ + +/* { - GstCaps *caps; - struct { - guint32 fourcc; - gint depth, bpp; - guint32 csp; - gint bitcnt; - } fmt_list[] = { - { GST_MAKE_FOURCC('Y','U','Y','2'), 16, 16, - GST_MAKE_FOURCC('Y','U','Y','2'), 0 }, - { GST_MAKE_FOURCC('U','Y','V','Y'), 16, 16, - GST_MAKE_FOURCC('U','Y','V','Y'), 0 }, - { GST_MAKE_FOURCC('I','4','2','0'), 12, 12, - GST_MAKE_FOURCC('I','4','2','0'), 0 }, - { GST_MAKE_FOURCC('Y','V','1','2'), 12, 12, - GST_MAKE_FOURCC('Y','V','1','2'), 0 }, -#if 0 - /* FIXME: someone fix RGB here please */ - { GST_MAKE_FOURCC('R','G','B',' '), 32, 32, + GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 32, 32, #if (G_BYTE_ORDER == G_BIG_ENDIAN) - GST_MAKE_FOURCC('A','B','G','R'), 32 }, +GST_MAKE_FOURCC ('A', 'B', 'G', 'R'), 32} + +, #else - 0, 32 }, +0, 32} + +, #endif - { GST_MAKE_FOURCC('R','G','B',' '), 24, 24, +{ + GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 24, 24, #if (G_BYTE_ORDER == G_BIG_ENDIAN) - GST_MAKE_FOURCC('A','B','G','R'), 24 }, +GST_MAKE_FOURCC ('A', 'B', 'G', 'R'), 24} + +, #else - 0, 24 }, +0, 24} + +, #endif - { GST_MAKE_FOURCC('R','G','B',' '), 16, 16, - 3, 16 }, - { GST_MAKE_FOURCC('R','G','B',' '), 15, 16, - 0, 16 }, +{ +GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 16, 16, 3, 16} + +, { +GST_MAKE_FOURCC ('R', 'G', 'B', ' '), 15, 16, 0, 16} + +, +#endif + if (fmt_list[i].fourcc == GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) { + guint32 r_mask = 0, b_mask = 0, g_mask = 0; + gint endianness = 0; + + switch (fmt_list[i].depth) { + case 15: + endianness = G_BYTE_ORDER; + r_mask = 0xf800; + g_mask = 0x07c0; + b_mask = 0x003e; + break; + case 16: + endianness = G_BYTE_ORDER; + r_mask = 0xf800; + g_mask = 0x07e0; + b_mask = 0x001f; + break; + case 24: + endianness = G_BIG_ENDIAN; + r_mask = GST_VIDEO_BYTE1_MASK_24_INT; + g_mask = GST_VIDEO_BYTE2_MASK_24_INT; + b_mask = GST_VIDEO_BYTE3_MASK_24_INT break; + case 32: + endianness = G_BIG_ENDIAN; + r_mask = GST_VIDEO_BYTE1_MASK_32_INT; + g_mask = GST_VIDEO_BYTE2_MASK_32_INT; + b_mask = GST_VIDEO_BYTE3_MASK_32_INT break; + } + caps = GST_CAPS_NEW ("divxdec_src_pad_rgb", + "video/x-raw-rgb", + "width", GST_PROPS_INT (divxdec->width), + "height", GST_PROPS_INT (divxdec->height), + "framerate", GST_PROPS_FLOAT (divxdec->fps), + "depth", GST_PROPS_INT (fmt_list[i].depth), + "bpp", GST_PROPS_INT (fmt_list[i].bpp), + "endianness", GST_PROPS_INT (endianness), + "red_mask", GST_PROPS_INT (r_mask), + "green_mask", GST_PROPS_INT (g_mask), + "blue_mask", GST_PROPS_INT (b_mask)); +} else { #endif - { 0, 0, 0, 0, 0 } + +#endif +*/ + +static GstPadLinkReturn +gst_divxdec_negotiate (GstDivxDec * divxdec) +{ + GstCaps *caps; + struct + { + guint32 fourcc; + gint depth, bpp; + guint32 csp; + gint bitcnt; + } fmt_list[] = { + { + GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 16, 16, + GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'), 0}, { + GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), 16, 16, + GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'), 0}, { + GST_MAKE_FOURCC ('I', '4', '2', '0'), 12, 12, + GST_MAKE_FOURCC ('I', '4', '2', '0'), 0}, { + GST_MAKE_FOURCC ('Y', 'V', '1', '2'), 12, 12, + GST_MAKE_FOURCC ('Y', 'V', '1', '2'), 0}, { + 0, 0, 0, 0, 0} }; gint i; for (i = 0; fmt_list[i].fourcc != 0; i++) { divxdec->csp = fmt_list[i].csp; -#if 0 - /* try making a caps to set on the other side */ - if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) { - guint32 r_mask = 0, b_mask = 0, g_mask = 0; - gint endianness = 0; - switch (fmt_list[i].depth) { - case 15: - endianness = G_BYTE_ORDER; - r_mask = 0xf800; g_mask = 0x07c0; b_mask = 0x003e; - break; - case 16: - endianness = G_BYTE_ORDER; - r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f; - break; - case 24: - endianness = G_BIG_ENDIAN; - r_mask = GST_VIDEO_BYTE1_MASK_24_INT; - g_mask = GST_VIDEO_BYTE2_MASK_24_INT; - b_mask = GST_VIDEO_BYTE3_MASK_24_INT - break; - case 32: - endianness = G_BIG_ENDIAN; - r_mask = GST_VIDEO_BYTE1_MASK_32_INT; - g_mask = GST_VIDEO_BYTE2_MASK_32_INT; - b_mask = GST_VIDEO_BYTE3_MASK_32_INT - break; - } - caps = GST_CAPS_NEW("divxdec_src_pad_rgb", - "video/x-raw-rgb", - "width", GST_PROPS_INT(divxdec->width), - "height", GST_PROPS_INT(divxdec->height), - "framerate", GST_PROPS_FLOAT(divxdec->fps), - "depth", GST_PROPS_INT(fmt_list[i].depth), - "bpp", GST_PROPS_INT(fmt_list[i].bpp), - "endianness", GST_PROPS_INT(endianness), - "red_mask", GST_PROPS_INT(r_mask), - "green_mask", GST_PROPS_INT(g_mask), - "blue_mask", GST_PROPS_INT(b_mask)); - } else { -#endif - caps = gst_caps_new_simple ("video/x-raw-yuv", - "width", G_TYPE_INT, divxdec->width, - "height", G_TYPE_INT, divxdec->height, - "framerate", G_TYPE_DOUBLE, divxdec->fps, - "format", GST_TYPE_FOURCC, fmt_list[i].fourcc, - NULL); - /*}*/ - - if (gst_divxdec_setup(divxdec) && - gst_pad_set_explicit_caps(divxdec->srcpad, caps)) { - divxdec->csp = fmt_list[i].csp; - divxdec->bpp = fmt_list[i].bpp; + caps = gst_caps_new_simple ("video/x-raw-yuv", + "width", G_TYPE_INT, divxdec->width, + "height", G_TYPE_INT, divxdec->height, + "framerate", G_TYPE_DOUBLE, divxdec->fps, + "format", GST_TYPE_FOURCC, fmt_list[i].fourcc, NULL); + + if (gst_divxdec_setup (divxdec) && + gst_pad_set_explicit_caps (divxdec->srcpad, caps)) { + divxdec->csp = fmt_list[i].csp; + divxdec->bpp = fmt_list[i].bpp; divxdec->bitcnt = fmt_list[i].bitcnt; return GST_PAD_LINK_OK; } @@ -428,61 +433,55 @@ gst_divxdec_negotiate (GstDivxDec *divxdec) static GstPadLinkReturn -gst_divxdec_connect (GstPad *pad, - const GstCaps *caps) +gst_divxdec_connect (GstPad * pad, const GstCaps * caps) { GstDivxDec *divxdec; GstStructure *structure = gst_caps_get_structure (caps, 0); - divxdec = GST_DIVXDEC(gst_pad_get_parent (pad)); + divxdec = GST_DIVXDEC (gst_pad_get_parent (pad)); /* if there's something old around, remove it */ if (divxdec->handle) { - gst_divxdec_unset(divxdec); + gst_divxdec_unset (divxdec); } /* we are not going to act on variable caps */ - if (!gst_caps_is_fixed(caps)) + if (!gst_caps_is_fixed (caps)) return GST_PAD_LINK_DELAYED; /* if we get here, we know the input is divx. we * only need to bother with the output colorspace */ - gst_structure_get_int(structure, "width", &divxdec->width); - gst_structure_get_int(structure, "height", &divxdec->height); - gst_structure_get_double(structure, "framerate", &divxdec->fps); - gst_structure_get_int(structure, "divxversion", &divxdec->version); + gst_structure_get_int (structure, "width", &divxdec->width); + gst_structure_get_int (structure, "height", &divxdec->height); + gst_structure_get_double (structure, "framerate", &divxdec->fps); + gst_structure_get_int (structure, "divxversion", &divxdec->version); - return gst_divxdec_negotiate(divxdec); + return gst_divxdec_negotiate (divxdec); } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { int lib_version; - lib_version = decore(NULL, DEC_OPT_VERSION, 0, 0); + lib_version = decore (NULL, DEC_OPT_VERSION, 0, 0); if (lib_version != DECORE_VERSION) { - g_warning("Version mismatch! This plugin was compiled for " - "DivX version %d, while your library has version %d!", - DECORE_VERSION, lib_version); + g_warning ("Version mismatch! This plugin was compiled for " + "DivX version %d, while your library has version %d!", + DECORE_VERSION, lib_version); return FALSE; } /* create an elementfactory for the v4lmjpegsrcparse element */ - return gst_element_register(plugin, "divxdec", - GST_RANK_SECONDARY, GST_TYPE_DIVXDEC); + return gst_element_register (plugin, "divxdec", + GST_RANK_SECONDARY, GST_TYPE_DIVXDEC); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "divxdec", - "DivX decoder", - plugin_init, - "5.03", - GST_LICENSE_UNKNOWN, - "divx4linux", - "http://www.divx.com/" -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "divxdec", + "DivX decoder", + plugin_init, + "5.03", GST_LICENSE_UNKNOWN, "divx4linux", "http://www.divx.com/"); -- cgit v1.2.1