summaryrefslogtreecommitdiffstats
path: root/ext/xvid
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2004-03-14 22:34:33 +0000
commit7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch)
treef863b467dea9559a6ec9c48affbfae11f8104164 /ext/xvid
parenta19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff)
downloadgst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2
gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip
gst-indent
Original commit message from CVS: gst-indent
Diffstat (limited to 'ext/xvid')
-rw-r--r--ext/xvid/gstxvid.c296
-rw-r--r--ext/xvid/gstxvid.h14
-rw-r--r--ext/xvid/gstxviddec.c251
-rw-r--r--ext/xvid/gstxviddec.h45
-rw-r--r--ext/xvid/gstxvidenc.c346
-rw-r--r--ext/xvid/gstxvidenc.h65
6 files changed, 494 insertions, 523 deletions
diff --git a/ext/xvid/gstxvid.c b/ext/xvid/gstxvid.c
index 4b8826d5..1e22dbfd 100644
--- a/ext/xvid/gstxvid.c
+++ b/ext/xvid/gstxvid.c
@@ -42,17 +42,16 @@ gst_xvid_init (void)
/* set up xvid initially (function pointers, CPU flags) */
gst_xvid_init_struct (xinit);
- if ((ret = xvid_global(NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
- g_warning("Failed to initialize XviD: %s (%d)",
- gst_xvid_error(ret), ret);
+ if ((ret = xvid_global (NULL, XVID_GBL_INIT, &xinit, NULL)) < 0) {
+ g_warning ("Failed to initialize XviD: %s (%d)", gst_xvid_error (ret), ret);
return FALSE;
}
GST_LOG ("Initted XviD version %d.%d.%d (API %d.%d)",
- XVID_VERSION_MAJOR (XVID_VERSION),
- XVID_VERSION_MINOR (XVID_VERSION),
- XVID_VERSION_PATCH (XVID_VERSION),
- XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
+ XVID_VERSION_MAJOR (XVID_VERSION),
+ XVID_VERSION_MINOR (XVID_VERSION),
+ XVID_VERSION_PATCH (XVID_VERSION),
+ XVID_API_MAJOR (XVID_API), XVID_API_MINOR (XVID_API));
is_init = TRUE;
return TRUE;
@@ -88,8 +87,8 @@ gst_xvid_error (int errorcode)
}
gint
-gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *_stride, gint *_bpp)
+gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * _stride, gint * _bpp)
{
const gchar *mime = gst_structure_get_name (structure);
gint xvid_cs = -1, stride = -1, bpp = -1;
@@ -99,70 +98,70 @@ gst_xvid_structure_to_csp (GstStructure *structure,
gst_structure_get_fourcc (structure, "format", &fourcc);
switch (fourcc) {
- case GST_MAKE_FOURCC('I','4','2','0'):
- xvid_cs = XVID_CSP_I420;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
- xvid_cs = XVID_CSP_YUY2;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
- xvid_cs = XVID_CSP_YV12;
- stride = w;
- bpp = 12;
- break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
- xvid_cs = XVID_CSP_UYVY;
- stride = w * 2;
- bpp = 16;
- break;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
- xvid_cs = XVID_CSP_YVYU;
- stride = w * 2;
- bpp = 16;
- break;
+ case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+ xvid_cs = XVID_CSP_I420;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+ xvid_cs = XVID_CSP_YUY2;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+ xvid_cs = XVID_CSP_YV12;
+ stride = w;
+ bpp = 12;
+ break;
+ case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+ xvid_cs = XVID_CSP_UYVY;
+ stride = w * 2;
+ bpp = 16;
+ break;
+ case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'):
+ xvid_cs = XVID_CSP_YVYU;
+ stride = w * 2;
+ bpp = 16;
+ break;
}
} else {
gint depth, r_mask;
- gst_structure_get_int(structure, "depth", &depth);
- gst_structure_get_int(structure, "bpp", &bpp);
- gst_structure_get_int(structure, "red_mask", &r_mask);
+ gst_structure_get_int (structure, "depth", &depth);
+ gst_structure_get_int (structure, "bpp", &bpp);
+ gst_structure_get_int (structure, "red_mask", &r_mask);
switch (depth) {
case 15:
- xvid_cs = XVID_CSP_RGB555;
- break;
+ xvid_cs = XVID_CSP_RGB555;
+ break;
case 16:
- xvid_cs = XVID_CSP_RGB565;
- break;
+ xvid_cs = XVID_CSP_RGB565;
+ break;
case 24:
- if (bpp == 24) {
- xvid_cs = XVID_CSP_BGR;
- } else {
- switch (r_mask) {
- case 0xff000000:
- xvid_cs = XVID_CSP_RGBA;
- break;
+ if (bpp == 24) {
+ xvid_cs = XVID_CSP_BGR;
+ } else {
+ switch (r_mask) {
+ case 0xff000000:
+ xvid_cs = XVID_CSP_RGBA;
+ break;
#ifdef XVID_CSP_ARGB
- case 0x00ff0000:
- xvid_cs = XVID_CSP_ARGB;
- break;
+ case 0x00ff0000:
+ xvid_cs = XVID_CSP_ARGB;
+ break;
#endif
- case 0x0000ff00:
- xvid_cs = XVID_CSP_BGRA;
- break;
- case 0x000000ff:
- xvid_cs = XVID_CSP_ABGR;
- break;
- }
- }
- break;
+ case 0x0000ff00:
+ xvid_cs = XVID_CSP_BGRA;
+ break;
+ case 0x000000ff:
+ xvid_cs = XVID_CSP_ABGR;
+ break;
+ }
+ }
+ break;
default:
- break;
+ break;
}
stride = w * bpp / 8;
@@ -190,58 +189,81 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
#ifdef XVID_CSP_ARGB
case XVID_CSP_ARGB:
#endif
- case XVID_CSP_RGBA: {
+ case XVID_CSP_RGBA:{
gint r_mask = 0, b_mask = 0, g_mask = 0,
- endianness = 0, bpp = 0, depth = 0;
+ endianness = 0, bpp = 0, depth = 0;
switch (csp) {
- case XVID_CSP_RGB555:
- r_mask = GST_VIDEO_RED_MASK_15_INT;
- g_mask = GST_VIDEO_GREEN_MASK_15_INT;
- b_mask = GST_VIDEO_BLUE_MASK_15_INT;
- endianness = G_BYTE_ORDER; depth = 15; bpp = 16;
- break;
- case XVID_CSP_RGB565:
- r_mask = GST_VIDEO_RED_MASK_16_INT;
- g_mask = GST_VIDEO_GREEN_MASK_16_INT;
- b_mask = GST_VIDEO_BLUE_MASK_16_INT;
- endianness = G_BYTE_ORDER; depth = 16; bpp = 16;
- break;
- case XVID_CSP_BGR:
- r_mask = 0x0000ff; g_mask = 0x00ff00; b_mask = 0xff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 24;
- break;
- case XVID_CSP_ABGR:
- r_mask = 0x000000ff; g_mask = 0x0000ff00; b_mask = 0x00ff0000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
- case XVID_CSP_BGRA:
- r_mask = 0x0000ff00; g_mask = 0x00ff0000; b_mask = 0xff000000;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGB555:
+ r_mask = GST_VIDEO_RED_MASK_15_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_15_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_15_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 15;
+ bpp = 16;
+ break;
+ case XVID_CSP_RGB565:
+ r_mask = GST_VIDEO_RED_MASK_16_INT;
+ g_mask = GST_VIDEO_GREEN_MASK_16_INT;
+ b_mask = GST_VIDEO_BLUE_MASK_16_INT;
+ endianness = G_BYTE_ORDER;
+ depth = 16;
+ bpp = 16;
+ break;
+ case XVID_CSP_BGR:
+ r_mask = 0x0000ff;
+ g_mask = 0x00ff00;
+ b_mask = 0xff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 24;
+ break;
+ case XVID_CSP_ABGR:
+ r_mask = 0x000000ff;
+ g_mask = 0x0000ff00;
+ b_mask = 0x00ff0000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
+ case XVID_CSP_BGRA:
+ r_mask = 0x0000ff00;
+ g_mask = 0x00ff0000;
+ b_mask = 0xff000000;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#ifdef XVID_CSP_ARGB
- case XVID_CSP_ARGB:
- r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_ARGB:
+ r_mask = 0x00ff0000;
+ g_mask = 0x0000ff00;
+ b_mask = 0x000000ff;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
#endif
- case XVID_CSP_RGBA:
- r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00;
- endianness = G_BIG_ENDIAN; depth = 24; bpp = 32;
- break;
+ case XVID_CSP_RGBA:
+ r_mask = 0xff000000;
+ g_mask = 0x00ff0000;
+ b_mask = 0x0000ff00;
+ endianness = G_BIG_ENDIAN;
+ depth = 24;
+ bpp = 32;
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-rgb",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "depth", G_TYPE_INT, depth,
- "bpp", G_TYPE_INT, bpp,
- "endianness", G_TYPE_INT, endianness,
- "red_mask", G_TYPE_INT, r_mask,
- "green_mask", G_TYPE_INT, g_mask,
- "blue_mask", G_TYPE_INT, b_mask,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "depth", G_TYPE_INT, depth,
+ "bpp", G_TYPE_INT, bpp,
+ "endianness", G_TYPE_INT, endianness,
+ "red_mask", G_TYPE_INT, r_mask,
+ "green_mask", G_TYPE_INT, g_mask,
+ "blue_mask", G_TYPE_INT, b_mask,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
@@ -249,33 +271,32 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
case XVID_CSP_YVYU:
case XVID_CSP_UYVY:
case XVID_CSP_I420:
- case XVID_CSP_YV12: {
+ case XVID_CSP_YV12:{
guint32 fourcc = 0;
switch (csp) {
- case XVID_CSP_YUY2:
- fourcc = GST_MAKE_FOURCC ('Y','U','Y','2');
- break;
- case XVID_CSP_YVYU:
- fourcc = GST_MAKE_FOURCC ('Y','V','Y','U');
- break;
- case XVID_CSP_UYVY:
- fourcc = GST_MAKE_FOURCC ('U','Y','V','Y');
- break;
- case XVID_CSP_I420:
- fourcc = GST_MAKE_FOURCC ('I','4','2','0');
- break;
- case XVID_CSP_YV12:
- fourcc = GST_MAKE_FOURCC ('Y','V','1','2');
- break;
+ case XVID_CSP_YUY2:
+ fourcc = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2');
+ break;
+ case XVID_CSP_YVYU:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U');
+ break;
+ case XVID_CSP_UYVY:
+ fourcc = GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y');
+ break;
+ case XVID_CSP_I420:
+ fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
+ break;
+ case XVID_CSP_YV12:
+ fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
+ break;
}
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "format", GST_TYPE_FOURCC, fourcc,
- "framerate", G_TYPE_DOUBLE, fps,
- NULL);
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h,
+ "format", GST_TYPE_FOURCC, fourcc,
+ "framerate", G_TYPE_DOUBLE, fps, NULL);
break;
}
}
@@ -285,22 +306,15 @@ gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps)
static gboolean
-plugin_init (GstPlugin *plugin)
+plugin_init (GstPlugin * plugin)
{
return (gst_element_register (plugin, "xvidenc",
- GST_RANK_NONE, GST_TYPE_XVIDENC) &&
- gst_element_register (plugin, "xviddec",
- GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
+ GST_RANK_NONE, GST_TYPE_XVIDENC) &&
+ gst_element_register (plugin, "xviddec",
+ GST_RANK_SECONDARY, GST_TYPE_XVIDDEC));
}
-GST_PLUGIN_DEFINE (
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "xvid",
- "XviD plugin library",
- plugin_init,
- VERSION,
- "GPL",
- GST_PACKAGE,
- GST_ORIGIN
-)
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "xvid",
+ "XviD plugin library", plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN)
diff --git a/ext/xvid/gstxvid.h b/ext/xvid/gstxvid.h
index 100f93b8..e204ae4a 100644
--- a/ext/xvid/gstxvid.h
+++ b/ext/xvid/gstxvid.h
@@ -23,13 +23,11 @@
#include <gst/gst.h>
G_BEGIN_DECLS
-
#define gst_xvid_init_struct(s) \
do { \
memset (&s, 0, sizeof(s)); \
s.version = XVID_VERSION; \
} while (0);
-
#define RGB_24_32_STATIC_CAPS(bpp, r_mask,g_mask,b_mask) \
"video/x-raw-rgb, " \
"width = (int) [ 0, MAX ], " \
@@ -41,14 +39,12 @@ G_BEGIN_DECLS
"red_mask = (int) " G_STRINGIFY (r_mask) ", " \
"green_mask = (int) " G_STRINGIFY (g_mask) ", " \
"blue_mask = (int) " G_STRINGIFY (b_mask)
+extern gchar *gst_xvid_error (int errorcode);
+extern gboolean gst_xvid_init (void);
-extern gchar * gst_xvid_error (int errorcode);
-extern gboolean gst_xvid_init (void);
-
-extern gint gst_xvid_structure_to_csp (GstStructure *structure,
- gint w, gint *stride, gint *bpp);
-extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
+extern gint gst_xvid_structure_to_csp (GstStructure * structure,
+ gint w, gint * stride, gint * bpp);
+extern GstCaps *gst_xvid_csp_to_caps (gint csp, gint w, gint h, gdouble fps);
G_END_DECLS
-
#endif /* __GST_XVID_H__ */
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 <rbultje@ronald.bitfreak.net>",
};
-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:
diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h
index fa90d06a..10538175 100644
--- a/ext/xvid/gstxviddec.h
+++ b/ext/xvid/gstxviddec.h
@@ -24,8 +24,9 @@
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDDEC \
@@ -39,32 +40,34 @@ extern "C" {
#define GST_IS_XVIDDEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDDEC))
-typedef struct _GstXvidDec GstXvidDec;
-typedef struct _GstXvidDecClass GstXvidDecClass;
+ typedef struct _GstXvidDec GstXvidDec;
+ typedef struct _GstXvidDecClass GstXvidDecClass;
-struct _GstXvidDec {
- GstElement element;
+ struct _GstXvidDec
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* xvid handle */
- void *handle;
+ /* xvid handle */
+ void *handle;
- /* video (output) settings */
- gint csp, bpp, stride;
- gint width, height;
- double fps;
-};
+ /* video (output) settings */
+ gint csp, bpp, stride;
+ gint width, height;
+ double fps;
+ };
-struct _GstXvidDecClass {
- GstElementClass parent_class;
-};
+ struct _GstXvidDecClass
+ {
+ GstElementClass parent_class;
+ };
-GType gst_xviddec_get_type(void);
+ GType gst_xviddec_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDDEC_H__ */
+#endif /* __GST_XVIDDEC_H__ */
diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c
index a98d31cf..5a9b34ba 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -36,78 +36,63 @@ GstElementDetails gst_xvidenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-static GstStaticPadTemplate sink_template =
-GST_STATIC_PAD_TEMPLATE (
- "sink",
- GST_PAD_SINK,
- 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 src_template =
-GST_STATIC_PAD_TEMPLATE (
- "src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS (
- "video/x-xvid, "
- "width = (int) [ 0, MAX ], "
- "height = (int) [ 0, MAX ], "
- "framerate = (double) [ 0.0, MAX ]"
- )
-);
+static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ 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 src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], " "framerate = (double) [ 0.0, MAX ]")
+ );
/* XvidEnc signals and args */
-enum {
+enum
+{
FRAME_ENCODED,
LAST_SIGNAL
};
-enum {
+enum
+{
ARG_0,
ARG_PROFILE,
ARG_BITRATE,
ARG_MAXKEYINTERVAL,
ARG_BUFSIZE
- /* FILL ME:
- * - ME
- * - VOP
- * - VOL
- * - PAR
- * - max b frames
- */
+ /* FILL ME:
+ * - ME
+ * - VOP
+ * - VOL
+ * - PAR
+ * - max b frames
+ */
};
-static void gst_xvidenc_base_init (gpointer g_class);
-static void gst_xvidenc_class_init (GstXvidEncClass *klass);
-static void gst_xvidenc_init (GstXvidEnc *xvidenc);
-static void gst_xvidenc_chain (GstPad *pad,
- GstData *data);
+static void gst_xvidenc_base_init (gpointer g_class);
+static void gst_xvidenc_class_init (GstXvidEncClass * klass);
+static void gst_xvidenc_init (GstXvidEnc * xvidenc);
+static void gst_xvidenc_chain (GstPad * pad, GstData * data);
static GstPadLinkReturn
- gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscapslist);
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscapslist);
/* properties */
-static void gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static GstElementStateReturn
- gst_xvidenc_change_state (GstElement *element);
+static void gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+static GstElementStateReturn gst_xvidenc_change_state (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_xvidenc_signals[LAST_SIGNAL] = { 0 };
@@ -121,51 +106,52 @@ gst_xvidenc_profile_get_type (void)
if (!xvidenc_profile_type) {
static const GEnumValue xvidenc_profiles[] = {
- { XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0" },
- { XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1" },
- { XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2" },
- { XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3" },
- { XVID_PROFILE_ARTS_L1, "ARTS_L1", "Advanced real-time simple profile, L1" },
- { XVID_PROFILE_ARTS_L2, "ARTS_L2", "Advanced real-time simple profile, L2" },
- { XVID_PROFILE_ARTS_L3, "ARTS_L3", "Advanced real-time simple profile, L3" },
- { XVID_PROFILE_ARTS_L4, "ARTS_L4", "Advanced real-time simple profile, L4" },
- { XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0" },
- { XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1" },
- { XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2" },
- { XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3" },
- { XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4" },
- { 0, NULL, NULL },
+ {XVID_PROFILE_S_L0, "S_L0", "Simple profile, L0"},
+ {XVID_PROFILE_S_L1, "S_L1", "Simple profile, L1"},
+ {XVID_PROFILE_S_L2, "S_L2", "Simple profile, L2"},
+ {XVID_PROFILE_S_L3, "S_L3", "Simple profile, L3"},
+ {XVID_PROFILE_ARTS_L1, "ARTS_L1",
+ "Advanced real-time simple profile, L1"},
+ {XVID_PROFILE_ARTS_L2, "ARTS_L2",
+ "Advanced real-time simple profile, L2"},
+ {XVID_PROFILE_ARTS_L3, "ARTS_L3",
+ "Advanced real-time simple profile, L3"},
+ {XVID_PROFILE_ARTS_L4, "ARTS_L4",
+ "Advanced real-time simple profile, L4"},
+ {XVID_PROFILE_AS_L0, "AS_L0", "Advanced simple profile, L0"},
+ {XVID_PROFILE_AS_L1, "AS_L1", "Advanced simple profile, L1"},
+ {XVID_PROFILE_AS_L2, "AS_L2", "Advanced simple profile, L2"},
+ {XVID_PROFILE_AS_L3, "AS_L3", "Advanced simple profile, L3"},
+ {XVID_PROFILE_AS_L4, "AS_L4", "Advanced simple profile, L4"},
+ {0, NULL, NULL},
};
xvidenc_profile_type =
- g_enum_register_static ("GstXvidEncProfiles",
- xvidenc_profiles);
+ g_enum_register_static ("GstXvidEncProfiles", xvidenc_profiles);
}
return xvidenc_profile_type;
}
GType
-gst_xvidenc_get_type(void)
+gst_xvidenc_get_type (void)
{
static GType xvidenc_type = 0;
- if (!xvidenc_type)
- {
+ if (!xvidenc_type) {
static const GTypeInfo xvidenc_info = {
- sizeof(GstXvidEncClass),
+ sizeof (GstXvidEncClass),
gst_xvidenc_base_init,
NULL,
(GClassInitFunc) gst_xvidenc_class_init,
NULL,
NULL,
- sizeof(GstXvidEnc),
+ sizeof (GstXvidEnc),
0,
(GInstanceInitFunc) gst_xvidenc_init,
};
- xvidenc_type = g_type_register_static(GST_TYPE_ELEMENT,
- "GstXvidEnc",
- &xvidenc_info, 0);
+ xvidenc_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstXvidEnc", &xvidenc_info, 0);
}
return xvidenc_type;
}
@@ -176,14 +162,14 @@ gst_xvidenc_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_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_xvidenc_details);
}
static void
-gst_xvidenc_class_init (GstXvidEncClass *klass)
+gst_xvidenc_class_init (GstXvidEncClass * klass)
{
GstElementClass *gstelement_class;
GObjectClass *gobject_class;
@@ -191,70 +177,66 @@ gst_xvidenc_class_init (GstXvidEncClass *klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
- parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
/* encoding profile */
- g_object_class_install_property(gobject_class, ARG_PROFILE,
- g_param_spec_enum("profile", "Profile", "XviD/MPEG-4 encoding profile",
- GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0,
- G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_PROFILE,
+ g_param_spec_enum ("profile", "Profile", "XviD/MPEG-4 encoding profile",
+ GST_TYPE_XVIDENC_PROFILE, XVID_PROFILE_S_L0, G_PARAM_READWRITE));
/* bitrate */
- g_object_class_install_property(gobject_class, ARG_BITRATE,
- g_param_spec_int("bitrate","Bitrate",
- "Target video bitrate (kbps)",
- 0,G_MAXINT,512,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BITRATE,
+ g_param_spec_int ("bitrate", "Bitrate",
+ "Target video bitrate (kbps)", 0, G_MAXINT, 512, G_PARAM_READWRITE));
/* keyframe interval */
- g_object_class_install_property(gobject_class, ARG_MAXKEYINTERVAL,
- g_param_spec_int("max_key_interval","Max. Key Interval",
- "Maximum number of frames between two keyframes",
- 0,G_MAXINT,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_MAXKEYINTERVAL,
+ g_param_spec_int ("max_key_interval", "Max. Key Interval",
+ "Maximum number of frames between two keyframes",
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
- g_object_class_install_property(gobject_class, ARG_BUFSIZE,
- g_param_spec_ulong("buffer_size", "Buffer Size",
- "Size of the video buffers",
- 0,G_MAXULONG,0,G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_BUFSIZE,
+ g_param_spec_ulong ("buffer_size", "Buffer Size",
+ "Size of the video buffers", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
gobject_class->set_property = gst_xvidenc_set_property;
gobject_class->get_property = gst_xvidenc_get_property;
gstelement_class->change_state = gst_xvidenc_change_state;
gst_xvidenc_signals[FRAME_ENCODED] =
- g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("frame-encoded", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstXvidEncClass, frame_encoded),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-gst_xvidenc_init (GstXvidEnc *xvidenc)
+gst_xvidenc_init (GstXvidEnc * xvidenc)
{
- gst_xvid_init();
+ gst_xvid_init ();
/* create the sink pad */
- xvidenc->sinkpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&sink_template),
- "sink");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->sinkpad);
+ xvidenc->sinkpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&sink_template),
+ "sink");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->sinkpad);
- gst_pad_set_chain_function(xvidenc->sinkpad, gst_xvidenc_chain);
- gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_link);
+ gst_pad_set_chain_function (xvidenc->sinkpad, gst_xvidenc_chain);
+ gst_pad_set_link_function (xvidenc->sinkpad, gst_xvidenc_link);
/* create the src pad */
- xvidenc->srcpad = gst_pad_new_from_template(
- gst_static_pad_template_get (&src_template),
- "src");
- gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->srcpad);
+ xvidenc->srcpad =
+ gst_pad_new_from_template (gst_static_pad_template_get (&src_template),
+ "src");
+ gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->srcpad);
/* bitrate, etc. */
xvidenc->width = xvidenc->height = xvidenc->csp = xvidenc->stride = -1;
xvidenc->profile = XVID_PROFILE_S_L0;
xvidenc->bitrate = 512;
xvidenc->max_b_frames = 2;
- xvidenc->max_key_interval = -1; /* default - 2*fps */
+ xvidenc->max_key_interval = -1; /* default - 2*fps */
xvidenc->buffer_size = 512;
/* set xvid handle to NULL */
@@ -263,7 +245,7 @@ gst_xvidenc_init (GstXvidEnc *xvidenc)
static gboolean
-gst_xvidenc_setup (GstXvidEnc *xvidenc)
+gst_xvidenc_setup (GstXvidEnc * xvidenc)
{
xvid_enc_create_t xenc;
xvid_enc_plugin_t xplugin;
@@ -277,11 +259,11 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
xenc.height = xvidenc->height;
xenc.max_bframes = xvidenc->max_b_frames;
xenc.global = XVID_GLOBAL_PACKED;
+
xenc.fbase = 1000000;
- xenc.fincr = (int)(xenc.fbase / xvidenc->fps);
+ xenc.fincr = (int) (xenc.fbase / xvidenc->fps);
xenc.max_key_interval = (xvidenc->max_key_interval == -1) ?
- (2 * xenc.fbase / xenc.fincr) :
- xvidenc->max_key_interval;
+ (2 * xenc.fbase / xenc.fincr) : xvidenc->max_key_interval;
xenc.handle = NULL;
/* CBR bitrate/quant for now */
@@ -297,11 +279,9 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
xenc.plugins[0].func = xvid_plugin_single;
xenc.plugins[0].param = &xsingle;
- if ((ret = xvid_encore(NULL, XVID_ENC_CREATE,
- &xenc, NULL)) < 0) {
+ if ((ret = xvid_encore (NULL, XVID_ENC_CREATE, &xenc, NULL)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, INIT, (NULL),
- ("Error setting up xvid encoder: %s (%d)",
- gst_xvid_error(ret), ret));
+ ("Error setting up xvid encoder: %s (%d)", gst_xvid_error (ret), ret));
return FALSE;
}
@@ -312,75 +292,73 @@ gst_xvidenc_setup (GstXvidEnc *xvidenc)
static void
-gst_xvidenc_chain (GstPad *pad,
- GstData *_data)
+gst_xvidenc_chain (GstPad * pad, GstData * _data)
{
GstBuffer *buf = GST_BUFFER (_data);
- GstXvidEnc *xvidenc = GST_XVIDENC(GST_OBJECT_PARENT(pad));
+ GstXvidEnc *xvidenc = GST_XVIDENC (GST_OBJECT_PARENT (pad));
GstBuffer *outbuf;
xvid_enc_frame_t xframe;
xvid_enc_stats_t xstats;
gint 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));
- outbuf = gst_buffer_new_and_alloc(xvidenc->buffer_size << 10);
- GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
- GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf);
+ outbuf = gst_buffer_new_and_alloc (xvidenc->buffer_size << 10);
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
/* encode and so ... */
gst_xvid_init_struct (xframe);
- xframe.vol_flags = XVID_VOL_MPEGQUANT |
- XVID_VOL_GMC;
+ xframe.vol_flags = XVID_VOL_MPEGQUANT | XVID_VOL_GMC;
xframe.par = XVID_PAR_11_VGA;
xframe.vop_flags = XVID_VOP_TRELLISQUANT;
xframe.motion = 0;
xframe.input.csp = xvidenc->csp;
if (xvidenc->width == xvidenc->stride) {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
- xframe.input.plane[1] = xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
- xframe.input.plane[2] = xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
+ xframe.input.plane[1] =
+ xframe.input.plane[0] + (xvidenc->width * xvidenc->height);
+ xframe.input.plane[2] =
+ xframe.input.plane[1] + (xvidenc->width * xvidenc->height / 4);
xframe.input.stride[0] = xvidenc->width;
xframe.input.stride[1] = xvidenc->width / 2;
xframe.input.stride[2] = xvidenc->width / 2;
} else {
- xframe.input.plane[0] = GST_BUFFER_DATA(buf);
+ xframe.input.plane[0] = GST_BUFFER_DATA (buf);
xframe.input.stride[0] = xvidenc->stride;
}
xframe.type = XVID_TYPE_AUTO;
- xframe.bitstream = (void *) GST_BUFFER_DATA(outbuf);
- xframe.length = GST_BUFFER_MAXSIZE(outbuf);
+ xframe.bitstream = (void *) GST_BUFFER_DATA (outbuf);
+ xframe.length = GST_BUFFER_MAXSIZE (outbuf);
gst_xvid_init_struct (xstats);
- if ((ret = xvid_encore(xvidenc->handle, XVID_ENC_ENCODE,
- &xframe, &xstats)) < 0) {
+ if ((ret = xvid_encore (xvidenc->handle, XVID_ENC_ENCODE,
+ &xframe, &xstats)) < 0) {
GST_ELEMENT_ERROR (xvidenc, LIBRARY, ENCODE, (NULL),
- ("Error encoding xvid frame: %s (%d)",
- gst_xvid_error(ret), ret));
- gst_buffer_unref(buf);
- gst_buffer_unref(outbuf);
+ ("Error encoding xvid frame: %s (%d)", gst_xvid_error (ret), ret));
+ gst_buffer_unref (buf);
+ gst_buffer_unref (outbuf);
return;
}
- GST_BUFFER_SIZE(outbuf) = xstats.length;
+ GST_BUFFER_SIZE (outbuf) = xstats.length;
if (xframe.out_flags & XVID_KEYFRAME)
- GST_BUFFER_FLAG_SET(outbuf, GST_BUFFER_KEY_UNIT);
+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
/* go out, multiply! */
- gst_pad_push(xvidenc->srcpad, GST_DATA (outbuf));
+ gst_pad_push (xvidenc->srcpad, GST_DATA (outbuf));
/* proclaim destiny */
- g_signal_emit(G_OBJECT(xvidenc),gst_xvidenc_signals[FRAME_ENCODED], 0);
+ g_signal_emit (G_OBJECT (xvidenc), gst_xvidenc_signals[FRAME_ENCODED], 0);
/* until the final judgement */
- gst_buffer_unref(buf);
+ gst_buffer_unref (buf);
}
static GstPadLinkReturn
-gst_xvidenc_link (GstPad *pad,
- const GstCaps *vscaps)
+gst_xvidenc_link (GstPad * pad, const GstCaps * vscaps)
{
GstXvidEnc *xvidenc;
GstStructure *structure;
@@ -389,11 +367,11 @@ gst_xvidenc_link (GstPad *pad,
double fps;
gint xvid_cs = -1, stride = -1;
- xvidenc = GST_XVIDENC(gst_pad_get_parent (pad));
+ xvidenc = GST_XVIDENC (gst_pad_get_parent (pad));
/* if there's something old around, remove it */
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
xvidenc->handle = NULL;
}
@@ -414,19 +392,18 @@ gst_xvidenc_link (GstPad *pad,
xvidenc->stride = stride;
xvidenc->fps = fps;
- if (gst_xvidenc_setup(xvidenc)) {
+ if (gst_xvidenc_setup (xvidenc)) {
GstPadLinkReturn ret;
GstCaps *new_caps;
- new_caps = gst_caps_new_simple("video/x-xvid",
- "width", G_TYPE_INT, w,
- "height", G_TYPE_INT, h,
- "framerate", G_TYPE_DOUBLE, fps, NULL);
- ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps);
+ new_caps = gst_caps_new_simple ("video/x-xvid",
+ "width", G_TYPE_INT, w,
+ "height", G_TYPE_INT, h, "framerate", G_TYPE_DOUBLE, fps, NULL);
+ ret = gst_pad_try_set_caps (xvidenc->srcpad, new_caps);
if (GST_PAD_LINK_FAILED (ret)) {
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
}
@@ -439,30 +416,27 @@ gst_xvidenc_link (GstPad *pad,
static void
-gst_xvidenc_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_PROFILE:
- xvidenc->profile = g_value_get_enum(value);
+ xvidenc->profile = g_value_get_enum (value);
break;
case ARG_BITRATE:
- xvidenc->bitrate = g_value_get_int(value);
+ xvidenc->bitrate = g_value_get_int (value);
break;
case ARG_BUFSIZE:
- xvidenc->buffer_size = g_value_get_int(value);
+ xvidenc->buffer_size = g_value_get_int (value);
break;
case ARG_MAXKEYINTERVAL:
- xvidenc->max_key_interval = g_value_get_int(value);
+ xvidenc->max_key_interval = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -472,29 +446,27 @@ gst_xvidenc_set_property (GObject *object,
static void
-gst_xvidenc_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gst_xvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
GstXvidEnc *xvidenc;
/* it's not null if we got it, but it might not be ours */
g_return_if_fail (GST_IS_XVIDENC (object));
- xvidenc = GST_XVIDENC(object);
+ xvidenc = GST_XVIDENC (object);
switch (prop_id) {
case ARG_PROFILE:
- g_value_set_enum(value, xvidenc->profile);
+ g_value_set_enum (value, xvidenc->profile);
break;
case ARG_BITRATE:
- g_value_set_int(value, xvidenc->bitrate);
+ g_value_set_int (value, xvidenc->bitrate);
break;
case ARG_BUFSIZE:
- g_value_set_int(value, xvidenc->buffer_size);
+ g_value_set_int (value, xvidenc->buffer_size);
break;
case ARG_MAXKEYINTERVAL:
- g_value_set_int(value, xvidenc->max_key_interval);
+ g_value_set_int (value, xvidenc->max_key_interval);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -503,15 +475,15 @@ gst_xvidenc_get_property (GObject *object,
}
static GstElementStateReturn
-gst_xvidenc_change_state (GstElement *element)
+gst_xvidenc_change_state (GstElement * element)
{
GstXvidEnc *xvidenc = GST_XVIDENC (element);
switch (GST_STATE_PENDING (element)) {
case GST_STATE_PAUSED_TO_READY:
if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
+ xvid_encore (xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
}
break;
default:
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index 356ce53f..fa786617 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -24,8 +24,9 @@
#include "gstxvid.h"
#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+extern "C"
+{
+#endif /* __cplusplus */
#define GST_TYPE_XVIDENC \
@@ -39,46 +40,48 @@ extern "C" {
#define GST_IS_XVIDENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIDENC))
-typedef struct _GstXvidEnc GstXvidEnc;
-typedef struct _GstXvidEncClass GstXvidEncClass;
+ typedef struct _GstXvidEnc GstXvidEnc;
+ typedef struct _GstXvidEncClass GstXvidEncClass;
-struct _GstXvidEnc {
- GstElement element;
+ struct _GstXvidEnc
+ {
+ GstElement element;
- /* pads */
- GstPad *sinkpad, *srcpad;
+ /* pads */
+ GstPad *sinkpad, *srcpad;
- /* encoding profile */
- gint profile;
+ /* encoding profile */
+ gint profile;
- /* quality of encoded image */
- gint bitrate;
- gint buffer_size;
+ /* quality of encoded image */
+ gint bitrate;
+ gint buffer_size;
- /* max number of B frames between I/P */
- gint max_b_frames;
+ /* max number of B frames between I/P */
+ gint max_b_frames;
- /* max key interval */
- gint max_key_interval;
+ /* max key interval */
+ gint max_key_interval;
- /* xvid handle */
- void *handle;
- gint csp;
- gint width, height, stride;
- gdouble fps;
-};
+ /* xvid handle */
+ void *handle;
+ gint csp;
+ gint width, height, stride;
+ gdouble fps;
+ };
-struct _GstXvidEncClass {
- GstElementClass parent_class;
+ struct _GstXvidEncClass
+ {
+ GstElementClass parent_class;
- /* signals */
- void (*frame_encoded) (GstElement *element);
-};
+ /* signals */
+ void (*frame_encoded) (GstElement * element);
+ };
-GType gst_xvidenc_get_type(void);
+ GType gst_xvidenc_get_type (void);
#ifdef __cplusplus
}
-#endif /* __cplusplus */
+#endif /* __cplusplus */
-#endif /* __GST_XVIDENC_H__ */
+#endif /* __GST_XVIDENC_H__ */