summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2003-12-21 22:43:09 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2003-12-21 22:43:09 +0000
commit26da56b423a834192f5edf413c3cb1be257f845a (patch)
tree4182e5351f49767eaf5447091a8050d27bd69474
parent0d9a29465920184a2f1ae1d21be9d8598dd33b93 (diff)
downloadgstreamer-plugins-bad-26da56b423a834192f5edf413c3cb1be257f845a.tar.gz
Port lame, libfame and xvid to new CAPS
Original commit message from CVS: Port lame, libfame and xvid to new CAPS Fix varargs in jpegdec and pngenc Make GstStaticPadTemplates static in gsmdec Add integer versions of the RGB masks in video.h Fix inverted logic in gstvideotestsrc
-rw-r--r--ext/gsm/gstgsmdec.c4
-rw-r--r--ext/libfame/gstlibfame.c85
-rw-r--r--ext/xvid/gstxviddec.c121
-rw-r--r--ext/xvid/gstxviddec.h6
-rw-r--r--ext/xvid/gstxvidenc.c215
-rw-r--r--ext/xvid/gstxvidenc.h6
-rw-r--r--gst-libs/gst/video/video.h24
7 files changed, 212 insertions, 249 deletions
diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c
index 2a218c838..7a35b1552 100644
--- a/ext/gsm/gstgsmdec.c
+++ b/ext/gsm/gstgsmdec.c
@@ -75,7 +75,7 @@ gst_gsmdec_get_type(void) {
return gsmdec_type;
}
-GstStaticPadTemplate gsmdec_sink_template =
+static GstStaticPadTemplate gsmdec_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
@@ -87,7 +87,7 @@ GST_STATIC_PAD_TEMPLATE (
)
);
-GstStaticPadTemplate gsmdec_src_template =
+static GstStaticPadTemplate gsmdec_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
diff --git a/ext/libfame/gstlibfame.c b/ext/libfame/gstlibfame.c
index be2404d5d..6b8d30534 100644
--- a/ext/libfame/gstlibfame.c
+++ b/ext/libfame/gstlibfame.c
@@ -60,54 +60,34 @@ enum {
/* FILL ME */
};
-GST_PAD_TEMPLATE_FACTORY (sink_template_factory,
+static GstStaticPadTemplate sink_template =
+GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "fameenc_sink_caps",
- "video/x-raw-yuv",
- "format",
- GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')),
- "width", GST_PROPS_INT_RANGE (16, 4096),
- "height", GST_PROPS_INT_RANGE (16, 4096),
- "framerate", GST_PROPS_LIST (
- GST_PROPS_FLOAT (24/1.001),
- GST_PROPS_FLOAT (24.),
- GST_PROPS_FLOAT (25.),
- GST_PROPS_FLOAT (30/1.001),
- GST_PROPS_FLOAT (30.),
- GST_PROPS_FLOAT (50.),
- GST_PROPS_FLOAT (60/1.001),
- GST_PROPS_FLOAT (60.)
- )
+ GST_STATIC_CAPS (
+ "video/x-raw-yuv, "
+ "format = (fourcc) I420, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }"
)
-)
+);
-GST_PAD_TEMPLATE_FACTORY (src_template_factory,
+static GstStaticPadTemplate src_template =
+GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_CAPS_NEW (
- "fameenc_src_caps",
- "video/mpeg",
- "mpegversion", GST_PROPS_LIST (
- GST_PROPS_INT (1),
- GST_PROPS_INT (4)
- ),
- "systemstream", GST_PROPS_BOOLEAN (FALSE),
- "width", GST_PROPS_INT_RANGE (16, 4096),
- "height", GST_PROPS_INT_RANGE (16, 4096),
- "framerate", GST_PROPS_LIST (
- GST_PROPS_FLOAT (24/1.001),
- GST_PROPS_FLOAT (24.),
- GST_PROPS_FLOAT (25.),
- GST_PROPS_FLOAT (30/1.001),
- GST_PROPS_FLOAT (30.),
- GST_PROPS_FLOAT (50.),
- GST_PROPS_FLOAT (60/1.001),
- GST_PROPS_FLOAT (60.)
- )
+ GST_STATIC_CAPS (
+ "video/mpeg, "
+ "mpegversion = (int) { 1, 4 }, "
+ "systemstream = (boolean) FALSE, "
+ "width = (int) [ 16, 4096 ], "
+ "height = (int) [ 16, 4096 ], "
+ "framerate = (double) { 23.976024, 24.0, 25.0, 29.970030, 30.0, "
+ " 50.0, 59.940060, 60.0 }"
)
);
@@ -205,9 +185,9 @@ gst_fameenc_base_init (GstFameEncClass *klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- GST_PAD_TEMPLATE_GET (sink_template_factory));
+ gst_static_pad_template_get (&sink_template));
gst_element_class_add_pad_template (element_class,
- GST_PAD_TEMPLATE_GET (src_template_factory));
+ gst_static_pad_template_get (&src_template));
gst_element_class_set_details (element_class, &gst_fameenc_details);
}
@@ -318,25 +298,24 @@ gst_fameenc_class_init (GstFameEncClass *klass)
}
static GstPadLinkReturn
-gst_fameenc_sinkconnect (GstPad *pad, GstCaps *caps)
+gst_fameenc_sink_link (GstPad *pad, const GstCaps2 *caps)
{
gint width, height, fps_idx;
- gfloat fps;
+ gdouble fps;
GstFameEnc *fameenc;
+ GstStructure *structure;
fameenc = GST_FAMEENC (gst_pad_get_parent (pad));
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
if (fameenc->initialized) {
GST_DEBUG ("error: fameenc encoder already initialized !");
return GST_PAD_LINK_REFUSED;
}
- gst_caps_get_int (caps, "width", &width);
- gst_caps_get_int (caps, "height", &height);
- gst_caps_get_float (caps, "framerate", &fps);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "height", &height);
+ gst_structure_get_double (structure, "framerate", &fps);
/* fameenc requires width and height to be multiples of 16 */
if (width % 16 != 0 || height % 16 != 0)
@@ -380,13 +359,13 @@ gst_fameenc_init (GstFameEnc *fameenc)
/* create the sink and src pads */
fameenc->sinkpad = gst_pad_new_from_template (
- GST_PAD_TEMPLATE_GET (sink_template_factory), "sink");
+ gst_static_pad_template_get (&sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->sinkpad);
gst_pad_set_chain_function (fameenc->sinkpad, gst_fameenc_chain);
- gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sinkconnect);
+ gst_pad_set_link_function (fameenc->sinkpad, gst_fameenc_sink_link);
fameenc->srcpad = gst_pad_new_from_template (
- GST_PAD_TEMPLATE_GET (src_template_factory), "src");
+ gst_static_pad_template_get (&src_template), "src");
gst_element_add_pad (GST_ELEMENT (fameenc), fameenc->srcpad);
/* FIXME: set some more handler functions here */
diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c
index 3cfdfaa70..afc123431 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 GstCaps2 *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);
@@ -276,7 +263,7 @@ static GstPadLinkReturn
gst_xviddec_negotiate (GstXvidDec *xviddec)
{
GstPadLinkReturn ret;
- GstCaps *caps;
+ GstCaps2 *caps;
struct {
guint32 fourcc;
gint depth, bpp;
@@ -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_caps2_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_caps2_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 GstCaps2 *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_caps2_get_nth_cap (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 76fc6d898..a614bd81d 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 f526df5aa..e3cad2940 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 GstCaps2 *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 GstCaps2 *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_caps2_get_n_structures (vscaps) == 1, GST_PAD_LINK_REFUSED);
+ structure = gst_caps2_get_nth_cap (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;
+ GstCaps2 *new_caps;
- ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps);
+ new_caps = gst_caps2_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 7597e1961..12f4d2fd6 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 {
diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h
index d10f6d42c..7f5a1fdf4 100644
--- a/gst-libs/gst/video/video.h
+++ b/gst-libs/gst/video/video.h
@@ -47,6 +47,30 @@
#define G_MASK_15 "0x03e0"
#define B_MASK_15 "0x001f"
+#define R_MASK_32_INT 0xff000000
+#define G_MASK_32_INT 0x00ff0000
+#define B_MASK_32_INT 0x0000ff00
+
+#define R_MASK_32_REVERSE_INT 0x000000ff
+#define G_MASK_32_REVERSE_INT 0x0000ff00
+#define B_MASK_32_REVERSE_INT 0x00ff0000
+
+#define R_MASK_24_INT 0xff0000
+#define G_MASK_24_INT 0x00ff00
+#define B_MASK_24_INT 0x0000ff
+
+#define R_MASK_24_REVERSE_INT 0x0000ff
+#define G_MASK_24_REVERSE_INT 0x00ff00
+#define B_MASK_24_REVERSE_INT 0xff0000
+
+#define R_MASK_16_INT 0xf800
+#define G_MASK_16_INT 0x07e0
+#define B_MASK_16_INT 0x001f
+
+#define R_MASK_15_INT 0x7c00
+#define G_MASK_15_INT 0x03e0
+#define B_MASK_15_INT 0x001f
+
#define SIZE_RANGE "(int) [ 16, 4096 ]"
#define FPS_RANGE "(double) [ 0, max ]"