Since people can't agree whether the first line of a bayer pattern is a blue/green line or a green/red line make it configurable. Signed-off-by: Sascha Hauer --- gst/bayer/gstbayer2rgb.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) Index: gst-plugins-bad-0.10.8/gst/bayer/gstbayer2rgb.c =================================================================== --- gst-plugins-bad-0.10.8.orig/gst/bayer/gstbayer2rgb.c +++ gst-plugins-bad-0.10.8/gst/bayer/gstbayer2rgb.c @@ -108,6 +108,7 @@ struct _GstBayer2RGB int r_off; /* offset for red */ int g_off; /* offset for green */ int b_off; /* offset for blue */ + gboolean bg_first; /* first line is blue/green */ }; struct _GstBayer2RGBClass @@ -138,7 +139,8 @@ GST_ELEMENT_DETAILS ("Bayer to RGB decod enum { - PROP_0 + PROP_0, + PROP_BGFIRST, }; #define DEBUG_INIT(bla) \ @@ -195,6 +197,13 @@ gst_bayer2rgb_class_init (GstBayer2RGBCl GST_DEBUG_FUNCPTR (gst_bayer2rgb_set_caps); GST_BASE_TRANSFORM_CLASS (klass)->transform = GST_DEBUG_FUNCPTR (gst_bayer2rgb_transform); + + g_object_class_install_property(gobject_class, PROP_BGFIRST, + g_param_spec_boolean("bg_first", + "B/G first", + "First line is a blue/green line", + TRUE, + G_PARAM_READWRITE)); } static void @@ -209,8 +218,12 @@ static void gst_bayer2rgb_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { + GstBayer2RGB *filter = GST_BAYER2RGB (object); switch (prop_id) { + case PROP_BGFIRST: + filter->bg_first = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -221,8 +234,12 @@ static void gst_bayer2rgb_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { + GstBayer2RGB *filter = GST_BAYER2RGB (object); switch (prop_id) { + case PROP_BGFIRST: + g_value_set_boolean(value, filter->bg_first); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -291,6 +308,7 @@ gst_bayer2rgb_reset (GstBayer2RGB * filt filter->r_off = 0; filter->g_off = 0; filter->b_off = 0; + filter->bg_first = 1; } static GstCaps * @@ -468,19 +486,19 @@ do_row0_col0 (uint8_t * input, uint8_t * int type; /* Horizontal edges */ - hborder (input, output, 0, GREENB, filter); + hborder (input, output, 0, filter->bg_first ? GREENB : RED, filter); if (filter->height & 1) - type = GREENB; /* odd # rows, "bottom" edge same as top */ + type = filter->bg_first ? GREENB : RED; /* odd # rows, "bottom" edge same as top */ else - type = RED; /* even #, bottom side different */ + type = filter->bg_first ? RED : GREENB; /* even #, bottom side different */ hborder (input, output, 1, type, filter); /* Vertical edges */ - vborder (input, output, 0, GREENR, filter); + vborder (input, output, 0, filter->bg_first ? GREENR : BLUE, filter); if (filter->width & 1) - type = GREENR; /* odd # cols, "right" edge same as left */ + type = filter->bg_first ? GREENR : BLUE; /* odd # cols, "right" edge same as left */ else - type = RED; /* even #, right side different */ + type = filter->bg_first ? RED : GREENB; /* even #, right side different */ vborder (input, output, 1, type, filter); } @@ -565,9 +583,9 @@ do_body (uint8_t * input, uint8_t * outp * be RED for odd-numbered rows and GREENB for even rows. */ if (h & 1) - type = RED; + type = filter->bg_first ? RED : GREENB; else - type = GREENB; + type = filter->bg_first ? GREENB : RED; /* Calculate the starting position for the row */ op = h * filter->width * filter->pixsize; /* output (converted) pos */ ip = h * filter->stride; /* input (bayer data) pos */ -- Dipl.-Ing. Sascha Hauer | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Handelsregister: Amtsgericht Hildesheim, HRA 2686 Hannoversche Str. 2, 31134 Hildesheim, Germany Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9