summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2002-06-21 18:29:13 +0000
committerWim Taymans <wim.taymans@gmail.com>2002-06-21 18:29:13 +0000
commit9251ed656ad51ab6ae43b4076de16c9b335fa23d (patch)
treeab4a9b68c3ea7542fa0f239e8eae81ab636b7c7e
parent43d17ede7a099635c0af06fb7840e37ac58face6 (diff)
downloadgst-plugins-bad-9251ed656ad51ab6ae43b4076de16c9b335fa23d.tar.gz
gst-plugins-bad-9251ed656ad51ab6ae43b4076de16c9b335fa23d.tar.bz2
gst-plugins-bad-9251ed656ad51ab6ae43b4076de16c9b335fa23d.zip
Fixed problem with color conversion
Original commit message from CVS: Fixed problem with color conversion Added conversion between YV12 and I420
-rw-r--r--ext/hermes/gstcolorspace.c29
-rw-r--r--ext/hermes/gstcolorspace.h1
-rw-r--r--ext/hermes/yuv2rgb.c12
-rw-r--r--ext/hermes/yuv2yuv.c23
-rw-r--r--ext/hermes/yuv2yuv.h3
5 files changed, 57 insertions, 11 deletions
diff --git a/ext/hermes/gstcolorspace.c b/ext/hermes/gstcolorspace.c
index 68167e4a..eda27295 100644
--- a/ext/hermes/gstcolorspace.c
+++ b/ext/hermes/gstcolorspace.c
@@ -21,6 +21,7 @@
#include "gstcolorspace.h"
#include "yuv2rgb.h"
+#include "yuv2yuv.h"
static GstElementDetails colorspace_details = {
@@ -54,6 +55,7 @@ GST_PAD_TEMPLATE_FACTORY (colorspace_src_template_factory,
"video/raw",
"format", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
+ GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
),
@@ -71,6 +73,7 @@ GST_PAD_TEMPLATE_FACTORY (colorspace_sink_template_factory,
"video/raw",
"format", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
+ GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")),
GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
),
@@ -98,8 +101,6 @@ static GstElementStateReturn
gst_colorspace_change_state (GstElement *element);
/* FIXME */
-extern void gst_colorspace_yuy2_to_i420 (unsigned char *src, unsigned char *dest,
- guint width, guint height);
extern void gst_colorspace_rgb32_to_i420 (unsigned char *src, unsigned char *dest,
guint width, guint height);
extern void gst_colorspace_rgb32_to_yv12 (unsigned char *src, unsigned char *dest,
@@ -218,6 +219,10 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t
space->type = GST_COLORSPACE_NONE;
space->destbpp = 12;
return TRUE;
+ case GST_MAKE_FOURCC ('Y','V','1','2'):
+ space->type = GST_COLORSPACE_420_SWAP;
+ space->destbpp = 12;
+ return TRUE;
}
break;
@@ -231,6 +236,17 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t
space->type = GST_COLORSPACE_NONE;
space->destbpp = 16;
return TRUE;
+ case GST_MAKE_FOURCC ('R','G','B',' '):
+ GST_INFO (GST_CAT_NEGOTIATION, "colorspace: YUY2 to RGB not implemented!!");
+ return FALSE;
+ }
+ break;
+ case GST_MAKE_FOURCC ('Y','V','1','2'):
+ switch (to_space) {
+ case GST_MAKE_FOURCC ('I','4','2','0'):
+ space->type = GST_COLORSPACE_420_SWAP;
+ space->destbpp = 12;
+ return TRUE;
}
break;
}
@@ -279,7 +295,7 @@ gst_colorspace_sinkconnect (GstPad *pad, GstCaps *caps)
peer = gst_pad_get_peer (pad);
if (peer) {
- if (!gst_colorspace_srcconnect_func (pad, gst_pad_get_allowed_caps (space->srcpad), FALSE)) {
+ if (gst_colorspace_srcconnect_func (pad, gst_pad_get_allowed_caps (space->srcpad), FALSE) < 1) {
space->sinkcaps = NULL;
return GST_PAD_CONNECT_REFUSED;
}
@@ -347,7 +363,6 @@ gst_colorspace_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps)
peercaps = peercaps->next;
}
- gst_element_error (GST_ELEMENT (space), "could not agree on caps with peer pads");
/* we disable ourself here */
space->disabled = TRUE;
@@ -475,6 +490,12 @@ gst_colorspace_chain (GstPad *pad,GstBuffer *buf)
space->width,
space->height);
}
+ else if (space->type == GST_COLORSPACE_420_SWAP) {
+ gst_colorspace_i420_to_yv12 (GST_BUFFER_DATA (buf),
+ GST_BUFFER_DATA (outbuf),
+ space->width,
+ space->height);
+ }
else if (space->type == GST_COLORSPACE_RGB32_I420) {
gst_colorspace_rgb32_to_i420 (GST_BUFFER_DATA (buf),
GST_BUFFER_DATA (outbuf),
diff --git a/ext/hermes/gstcolorspace.h b/ext/hermes/gstcolorspace.h
index 1b89d603..37a80c5c 100644
--- a/ext/hermes/gstcolorspace.h
+++ b/ext/hermes/gstcolorspace.h
@@ -59,6 +59,7 @@ typedef enum {
GST_COLORSPACE_YUY2_I420,
GST_COLORSPACE_RGB32_I420,
GST_COLORSPACE_RGB32_YV12,
+ GST_COLORSPACE_420_SWAP,
} GstColorSpaceConverterType;
struct _GstColorspace {
diff --git a/ext/hermes/yuv2rgb.c b/ext/hermes/yuv2rgb.c
index 8fcce91d..c89c35d5 100644
--- a/ext/hermes/yuv2rgb.c
+++ b/ext/hermes/yuv2rgb.c
@@ -24,10 +24,10 @@
#include "yuv2rgb.h"
-/*#undef HAVE_LIBMMX */
+/* #define HAVE_LIBMMX */
-#ifdef HAVE_LIBMMX
-#include "mmx.h"
+#ifdef HAVE_LIBMMX
+#include <mmx.h>
#endif
#define CB_BASE 1
@@ -187,8 +187,8 @@ static void gst_colorspace_yuv420P_to_rgb32(GstColorSpaceConverter *space, unsig
gst_colorspace_yuv_to_rgb32(space->color_tables,
src, /* Y component */
- src+size+(size>>2), /* cb component */
src+size, /* cr component */
+ src+size+(size>>2), /* cb component */
dest,
space->height,
space->width);
@@ -203,8 +203,8 @@ static void gst_colorspace_yuv420P_to_rgb24(GstColorSpaceConverter *space, unsig
gst_colorspace_yuv_to_rgb24(space->color_tables,
src, /* Y component */
- src+size+(size>>2), /* cb component */
src+size, /* cr component */
+ src+size+(size>>2), /* cb component */
dest,
space->height,
space->width);
@@ -219,8 +219,8 @@ static void gst_colorspace_yuv420P_to_rgb16(GstColorSpaceConverter *space, unsig
gst_colorspace_yuv_to_rgb16(space->color_tables,
src, /* Y component */
- src+size+(size>>2), /* cb component */
src+size, /* cr component */
+ src+size+(size>>2), /* cb component */
dest,
space->height,
space->width);
diff --git a/ext/hermes/yuv2yuv.c b/ext/hermes/yuv2yuv.c
index 0c36da33..4499af83 100644
--- a/ext/hermes/yuv2yuv.c
+++ b/ext/hermes/yuv2yuv.c
@@ -53,3 +53,26 @@ void gst_colorspace_yuy2_to_i420(unsigned char *src, unsigned char *dest, guint
}
}
}
+
+void gst_colorspace_i420_to_yv12(unsigned char *src, unsigned char *dest, guint width, guint height)
+{
+ int size, i;
+ guint8 *destcr, *destcb;
+
+ size = width * height;
+
+ memcpy (dest, src, size);
+
+ src += size;
+ destcr = dest + size;
+ size >>=2;
+ destcb = destcr + size;
+
+ i=size;
+ while (i--)
+ *destcb++ = *src++;
+ i=size;
+ while (i--)
+ *destcr++ = *src++;
+}
+
diff --git a/ext/hermes/yuv2yuv.h b/ext/hermes/yuv2yuv.h
index 66de03ad..e42894cf 100644
--- a/ext/hermes/yuv2yuv.h
+++ b/ext/hermes/yuv2yuv.h
@@ -22,7 +22,8 @@
#include <gst/gst.h>
-void gst_colorspace_yuy2_to_i420( guchar *src, guchar *dest, guint width, guint height);
+void gst_colorspace_yuy2_to_i420 (guchar *src, guchar *dest, guint width, guint height);
+void gst_colorspace_i420_to_yv12 (guchar *src, guchar *dest, guint width, guint height);
#endif