summaryrefslogtreecommitdiffstats
path: root/ext/xvid
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
committerDavid Schleef <ds@schleef.org>2003-12-22 01:47:09 +0000
commitb144bc6c58979f49a6e8e04a04a65f771247297a (patch)
tree648bc437ca5562bc7c67224ad71ef90dfacc12d1 /ext/xvid
parent2309d726b7b0c37dbd9c57c653e2053ec6258ac8 (diff)
downloadgst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.gz
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.tar.bz2
gst-plugins-bad-b144bc6c58979f49a6e8e04a04a65f771247297a.zip
Merge CAPS branch
Original commit message from CVS: Merge CAPS branch
Diffstat (limited to 'ext/xvid')
-rw-r--r--ext/xvid/gstxviddec.c119
-rw-r--r--ext/xvid/gstxviddec.h6
-rw-r--r--ext/xvid/gstxvidenc.c215
-rw-r--r--ext/xvid/gstxvidenc.h6
4 files changed, 153 insertions, 193 deletions
diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c
index 3cfdfaa7..84af838d 100644
--- a/ext/xvid/gstxviddec.c
+++ b/ext/xvid/gstxviddec.c
@@ -33,45 +33,30 @@ GstElementDetails gst_xviddec_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-GST_PAD_TEMPLATE_FACTORY(sink_template,
+static GstStaticPadTemplate sink_template =
+GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_CAPS_NEW("xviddec_sink",
- "video/x-xvid",
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT))
-)
-
-GST_PAD_TEMPLATE_FACTORY(src_template,
+ 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_caps_new(
- "xviddec_sink",
- "video/x-raw-yuv",
- GST_VIDEO_YUV_PAD_TEMPLATE_PROPS (
- GST_PROPS_LIST(
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y'))
- )
- )
- ),
- gst_caps_new(
- "xviddec_sink_rgb24_32",
- "video/x-raw-rgb",
- GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32
- ),
- gst_caps_new(
- "xviddec_sink_rgb15_16",
- "video/x-raw-rgb",
- GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16
+ GST_STATIC_CAPS (
+ GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
+ GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 "; "
+ GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16
)
-)
+);
/* XvidDec signals and args */
@@ -91,9 +76,9 @@ static void gst_xviddec_init (GstXvidDec *xviddec);
static void gst_xviddec_dispose (GObject *object);
static void gst_xviddec_chain (GstPad *pad,
GstData *data);
-static GstPadLinkReturn gst_xviddec_connect (GstPad *pad,
- GstCaps *vscapslist);
-static GstPadLinkReturn gst_xviddec_negotiate (GstXvidDec *xviddec);
+static GstPadLinkReturn gst_xviddec_link (GstPad *pad,
+ const GstCaps *vscapslist);
+static GstPadLinkReturn gst_xviddec_negotiate (GstXvidDec *xviddec);
static GstElementClass *parent_class = NULL;
/* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */
@@ -129,8 +114,10 @@ gst_xviddec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template));
- gst_element_class_add_pad_template (element_class, GST_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);
}
@@ -153,16 +140,16 @@ gst_xviddec_init (GstXvidDec *xviddec)
{
/* create the sink pad */
xviddec->sinkpad = gst_pad_new_from_template(
- GST_PAD_TEMPLATE_GET(sink_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_connect);
+ gst_pad_set_link_function(xviddec->sinkpad, gst_xviddec_link);
/* create the src pad */
xviddec->srcpad = gst_pad_new_from_template(
- GST_PAD_TEMPLATE_GET(src_template),
+ gst_static_pad_template_get (&src_template),
"src");
gst_element_add_pad(GST_ELEMENT(xviddec), xviddec->srcpad);
@@ -309,36 +296,36 @@ gst_xviddec_negotiate (GstXvidDec *xviddec)
break;
case 16:
endianness = G_BYTE_ORDER;
- r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f;
+ r_mask = R_MASK_16_INT; g_mask = G_MASK_16_INT; b_mask = B_MASK_16_INT;
break;
case 24:
endianness = G_BIG_ENDIAN;
- r_mask = R_MASK_24; g_mask = G_MASK_24; b_mask = B_MASK_24;
+ r_mask = R_MASK_24_INT; g_mask = G_MASK_24_INT; b_mask = B_MASK_24_INT;
break;
case 32:
endianness = G_BIG_ENDIAN;
- r_mask = R_MASK_32; g_mask = G_MASK_32; b_mask = B_MASK_32;
+ r_mask = R_MASK_32_INT; g_mask = G_MASK_32_INT; b_mask = B_MASK_32_INT;
break;
}
- caps = GST_CAPS_NEW("xviddec_src_pad_rgb",
+ caps = gst_caps_new_simple (
"video/x-raw-rgb",
- "width", GST_PROPS_INT(xviddec->width),
- "height", GST_PROPS_INT(xviddec->height),
- "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),
- "framerate", GST_PROPS_FLOAT(xviddec->fps),
+ "width", G_TYPE_INT, xviddec->width,
+ "height", G_TYPE_INT, xviddec->height,
+ "depth", G_TYPE_INT, fmt_list[i].depth,
+ "bpp", G_TYPE_INT, fmt_list[i].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, xviddec->fps,
NULL);
} else {
- caps = GST_CAPS_NEW("xviddec_src_pad_yuv",
+ caps = gst_caps_new_simple (
"video/x-raw-yuv",
- "width", GST_PROPS_INT(xviddec->width),
- "height", GST_PROPS_INT(xviddec->height),
- "format", GST_PROPS_FOURCC(fmt_list[i].fourcc),
- "framerate", GST_PROPS_FLOAT(xviddec->fps),
+ "width", G_TYPE_INT, xviddec->width,
+ "height", G_TYPE_INT, xviddec->height,
+ "format", GST_TYPE_FOURCC, fmt_list[i].fourcc,
+ "framerate", G_TYPE_DOUBLE, xviddec->fps,
NULL);
}
@@ -358,10 +345,11 @@ gst_xviddec_negotiate (GstXvidDec *xviddec)
static GstPadLinkReturn
-gst_xviddec_connect (GstPad *pad,
- GstCaps *vscaps)
+gst_xviddec_link (GstPad *pad,
+ const GstCaps *vscaps)
{
GstXvidDec *xviddec;
+ GstStructure *structure;
xviddec = GST_XVIDDEC(gst_pad_get_parent (pad));
@@ -370,15 +358,12 @@ gst_xviddec_connect (GstPad *pad,
gst_xviddec_unset(xviddec);
}
- /* we are not going to act on variable caps */
- if (!GST_CAPS_IS_FIXED(vscaps))
- return GST_PAD_LINK_DELAYED;
-
/* if we get here, we know the input is xvid. we
* only need to bother with the output colorspace */
- gst_caps_get_int(vscaps, "width", &xviddec->width);
- gst_caps_get_int(vscaps, "height", &xviddec->height);
- gst_caps_get_float(vscaps, "framerate", &xviddec->fps);
+ 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);
return gst_xviddec_negotiate(xviddec);
}
diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h
index 76fc6d89..a614bd81 100644
--- a/ext/xvid/gstxviddec.h
+++ b/ext/xvid/gstxviddec.h
@@ -53,9 +53,9 @@ struct _GstXvidDec {
void *handle;
/* video (output) settings */
- int csp, bpp;
- int width, height;
- float fps;
+ gint csp, bpp;
+ gint width, height;
+ double fps;
};
struct _GstXvidDecClass {
diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c
index f526df5a..ce2e71e9 100644
--- a/ext/xvid/gstxvidenc.c
+++ b/ext/xvid/gstxvidenc.c
@@ -34,45 +34,30 @@ GstElementDetails gst_xvidenc_details = {
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
};
-GST_PAD_TEMPLATE_FACTORY(sink_template,
+static GstStaticPadTemplate sink_template =
+GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- gst_caps_new(
- "xvidenc_sink",
- "video/x-raw-yuv",
- GST_VIDEO_YUV_PAD_TEMPLATE_PROPS (
- GST_PROPS_LIST(
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')),
- GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y'))
- )
- )
- ),
- gst_caps_new(
- "xvidenc_sink_rgb24_32",
- "video/x-raw-rgb",
- GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32
- ),
- gst_caps_new(
- "xvidenc_sink_rgb15_16",
- "video/x-raw-rgb",
- GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16
+ GST_STATIC_CAPS (
+ GST_VIDEO_YUV_PAD_TEMPLATE_CAPS ("{ I420, YUY2, YV12, YVYU, UYVY }") "; "
+ GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_24_32 "; "
+ GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_15_16
)
-)
+);
-GST_PAD_TEMPLATE_FACTORY(src_template,
+static GstStaticPadTemplate src_template =
+GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_CAPS_NEW("xvidenc_src",
- "video/x-xvid",
- "width", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "height", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT))
-)
+ GST_STATIC_CAPS (
+ "video/x-xvid, "
+ "width = (int) [ 0, MAX ], "
+ "height = (int) [ 0, MAX ], "
+ "framerate = (double) [ 0.0, MAX ]"
+ )
+);
/* XvidEnc signals and args */
@@ -93,8 +78,8 @@ 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_connect (GstPad *pad,
- GstCaps *vscapslist);
+static GstPadLinkReturn gst_xvidenc_link (GstPad *pad,
+ const GstCaps *vscapslist);
/* properties */
static void gst_xvidenc_set_property (GObject *object,
@@ -140,8 +125,8 @@ gst_xvidenc_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (sink_template));
- gst_element_class_add_pad_template (element_class, GST_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_xvidenc_details);
}
@@ -190,16 +175,16 @@ gst_xvidenc_init (GstXvidEnc *xvidenc)
{
/* create the sink pad */
xvidenc->sinkpad = gst_pad_new_from_template(
- GST_PAD_TEMPLATE_GET(sink_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_connect);
+ gst_pad_set_link_function(xvidenc->sinkpad, gst_xvidenc_link);
/* create the src pad */
xvidenc->srcpad = gst_pad_new_from_template(
- GST_PAD_TEMPLATE_GET(src_template),
+ gst_static_pad_template_get (&src_template),
"src");
gst_element_add_pad(GST_ELEMENT(xvidenc), xvidenc->srcpad);
@@ -312,11 +297,15 @@ gst_xvidenc_chain (GstPad *pad,
static GstPadLinkReturn
-gst_xvidenc_connect (GstPad *pad,
- GstCaps *vscaps)
+gst_xvidenc_link (GstPad *pad,
+ const GstCaps *vscaps)
{
GstXvidEnc *xvidenc;
- GstCaps *caps;
+ GstStructure *structure;
+ gint w,h,d;
+ double fps;
+ guint32 fourcc;
+ gint xvid_cs = -1;
xvidenc = GST_XVIDENC(gst_pad_get_parent (pad));
@@ -326,95 +315,81 @@ gst_xvidenc_connect (GstPad *pad,
xvidenc->handle = NULL;
}
- /* we are not going to act on variable caps */
- if (!GST_CAPS_IS_FIXED(vscaps))
- return GST_PAD_LINK_DELAYED;
+ g_return_val_if_fail (gst_caps_get_size (vscaps) == 1, GST_PAD_LINK_REFUSED);
+ structure = gst_caps_get_structure (vscaps, 0);
+
+ gst_structure_get_int (structure, "width", &w);
+ gst_structure_get_int (structure, "height", &h);
+ gst_structure_get_double (structure, "framerate", &fps);
+ if (gst_structure_has_field_typed (structure, "format", GST_TYPE_FOURCC))
+ gst_structure_get_fourcc (structure, "format", &fourcc);
+ else
+ fourcc = GST_MAKE_FOURCC('R','G','B',' ');
- for (caps = vscaps; caps != NULL; caps = caps->next)
+ switch (fourcc)
{
- int w,h,d;
- float fps;
- guint32 fourcc;
- gint xvid_cs;
-
- gst_caps_get_int(caps, "width", &w);
- gst_caps_get_int(caps, "height", &h);
- gst_caps_get_float(caps, "framerate", &fps);
- if (gst_caps_has_property(caps, "format"))
- gst_caps_get_fourcc_int(caps, "format", &fourcc);
- else
- fourcc = GST_MAKE_FOURCC('R','G','B',' ');
-
- switch (fourcc)
- {
- case GST_MAKE_FOURCC('I','4','2','0'):
- case GST_MAKE_FOURCC('I','Y','U','V'):
- xvid_cs = XVID_CSP_I420;
- break;
- case GST_MAKE_FOURCC('Y','U','Y','2'):
- xvid_cs = XVID_CSP_YUY2;
- break;
- case GST_MAKE_FOURCC('Y','V','1','2'):
- xvid_cs = XVID_CSP_YV12;
- break;
- case GST_MAKE_FOURCC('U','Y','V','Y'):
- xvid_cs = XVID_CSP_UYVY;
- break;
- case GST_MAKE_FOURCC('Y','V','Y','U'):
- xvid_cs = XVID_CSP_YVYU;
- break;
- case GST_MAKE_FOURCC('R','G','B',' '):
- gst_caps_get_int(caps, "depth", &d);
- switch (d) {
- case 15:
- xvid_cs = XVID_CSP_RGB555;
- break;
- case 16:
- xvid_cs = XVID_CSP_RGB565;
- break;
- case 24:
- xvid_cs = XVID_CSP_RGB24;
- break;
- case 32:
- xvid_cs = XVID_CSP_RGB32;
- break;
- default:
- goto trynext;
- }
- break;
- default:
- goto trynext;
- }
+ case GST_MAKE_FOURCC('I','4','2','0'):
+ case GST_MAKE_FOURCC('I','Y','U','V'):
+ xvid_cs = XVID_CSP_I420;
+ break;
+ case GST_MAKE_FOURCC('Y','U','Y','2'):
+ xvid_cs = XVID_CSP_YUY2;
+ break;
+ case GST_MAKE_FOURCC('Y','V','1','2'):
+ xvid_cs = XVID_CSP_YV12;
+ break;
+ case GST_MAKE_FOURCC('U','Y','V','Y'):
+ xvid_cs = XVID_CSP_UYVY;
+ break;
+ case GST_MAKE_FOURCC('Y','V','Y','U'):
+ xvid_cs = XVID_CSP_YVYU;
+ break;
+ case GST_MAKE_FOURCC('R','G','B',' '):
+ gst_structure_get_int(structure, "depth", &d);
+ switch (d) {
+ case 15:
+ xvid_cs = XVID_CSP_RGB555;
+ break;
+ case 16:
+ xvid_cs = XVID_CSP_RGB565;
+ break;
+ case 24:
+ xvid_cs = XVID_CSP_RGB24;
+ break;
+ case 32:
+ xvid_cs = XVID_CSP_RGB32;
+ break;
+ }
+ break;
+ }
- xvidenc->csp = xvid_cs;
- xvidenc->width = w;
- xvidenc->height = h;
- xvidenc->fps = fps;
+ g_return_val_if_fail (xvid_cs != -1, GST_PAD_LINK_REFUSED);
- if (gst_xvidenc_setup(xvidenc)) {
- GstPadLinkReturn ret;
- GstCaps *new_caps;
+ xvidenc->csp = xvid_cs;
+ xvidenc->width = w;
+ xvidenc->height = h;
+ xvidenc->fps = fps;
- new_caps = GST_CAPS_NEW("xvidenc_src_caps",
- "video/x-xvid",
- "width", GST_PROPS_INT(w),
- "height", GST_PROPS_INT(h),
- "framerate", GST_PROPS_FLOAT (fps));
+ if (gst_xvidenc_setup(xvidenc)) {
+ GstPadLinkReturn ret;
+ GstCaps *new_caps;
- 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);
- if (ret <= 0) {
- if (xvidenc->handle) {
- xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
- xvidenc->handle = NULL;
- }
- }
+ ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps);
- return ret;
+ if (ret <= 0) {
+ if (xvidenc->handle) {
+ xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL);
+ xvidenc->handle = NULL;
+ }
}
-trynext:
- continue;
+ return ret;
}
/* if we got here - it's not good */
diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h
index 7597e196..12f4d2fd 100644
--- a/ext/xvid/gstxvidenc.h
+++ b/ext/xvid/gstxvidenc.h
@@ -59,9 +59,9 @@ struct _GstXvidEnc {
/* xvid handle */
void *handle;
- int csp;
- int width, height;
- float fps;
+ gint csp;
+ gint width, height;
+ double fps;
};
struct _GstXvidEncClass {