Hi all,
Here are some Bayer format conversion and v4l2src related patches. I'm not very familiar with gstreamer yet, so please review carefully ;) The patches are created against the stable version, but I can rebase them against CVS if needed. Any comments welcome Regards, Sascha -- 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
The code calculates the wrong color offsets for 24bpp packed
pixel formats. Fix it. While at it, rename int offset to the more name 'mask' Signed-off-by: Sascha Hauer <[hidden email]> --- gst/bayer/gstbayer2rgb.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 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 @@ -231,19 +231,21 @@ gst_bayer2rgb_get_property (GObject * ob /* Routine to convert colormask value into relative byte offset */ static int -get_pix_offset (int offset) +get_pix_offset (int mask, int bpp) { - switch (offset) { + int bpp32 = (bpp / 8) - 3; + + switch (mask) { case 255: - return 3; + return 2 + bpp32; case 65280: - return 2; + return 1 + bpp32; case 16711680: - return 1; + return 0 + bpp32; case -16777216: return 0; default: - GST_ERROR ("Invalid color mask 0x%08x", offset); + GST_ERROR ("Invalid color mask 0x%08x", mask); return -1; } } @@ -254,7 +256,7 @@ gst_bayer2rgb_set_caps (GstBaseTransform { GstBayer2RGB *filter = GST_BAYER2RGB (base); GstStructure *structure; - int val; + int val, bpp; GST_DEBUG ("in caps %" GST_PTR_FORMAT " out caps %" GST_PTR_FORMAT, incaps, outcaps); @@ -267,14 +269,14 @@ gst_bayer2rgb_set_caps (GstBaseTransform /* To cater for different RGB formats, we need to set params for later */ structure = gst_caps_get_structure (outcaps, 0); - gst_structure_get_int (structure, "bpp", &val); - filter->pixsize = val / 8; + gst_structure_get_int (structure, "bpp", &bpp); + filter->pixsize = bpp / 8; gst_structure_get_int (structure, "red_mask", &val); - filter->r_off = get_pix_offset (val); + filter->r_off = get_pix_offset (val, bpp); gst_structure_get_int (structure, "green_mask", &val); - filter->g_off = get_pix_offset (val); + filter->g_off = get_pix_offset (val, bpp); gst_structure_get_int (structure, "blue_mask", &val); - filter->b_off = get_pix_offset (val); + filter->b_off = get_pix_offset (val, bpp); return TRUE; } -- 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Sascha Hauer
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 <[hidden email]> --- 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Sascha Hauer
Signed-off-by: Sascha Hauer <[hidden email]>
--- sys/v4l2/gstv4l2src.c | 5 +++++ 1 file changed, 5 insertions(+) Index: gst-plugins-good-0.10.9/sys/v4l2/gstv4l2src.c =================================================================== --- gst-plugins-good-0.10.9.orig/sys/v4l2/gstv4l2src.c +++ gst-plugins-good-0.10.9/sys/v4l2/gstv4l2src.c @@ -679,6 +679,9 @@ gst_v4l2src_v4l2fourcc_to_structure (gui break; } case V4L2_PIX_FMT_GREY: /* 8 Greyscale */ + structure = gst_structure_new ("video/x-raw-gray", + "bpp", G_TYPE_INT, 8, NULL); + break; case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */ case V4L2_PIX_FMT_HI240: /* 8 8-bit color */ /* FIXME: get correct fourccs here */ @@ -990,6 +993,8 @@ gst_v4l2_get_caps_info (GstV4l2Src * v4l fourcc = V4L2_PIX_FMT_JPEG; } else if (strcmp (mimetype, "video/x-raw-bayer") == 0) { fourcc = V4L2_PIX_FMT_SBGGR8; + } else if (strcmp (mimetype, "video/x-raw-gray") == 0) { + fourcc = V4L2_PIX_FMT_GREY; } if (fourcc == 0) -- 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
In reply to this post by Sascha Hauer
Hi,
Sascha Hauer wrote: > The code calculates the wrong color offsets for 24bpp packed > pixel formats. Fix it. While at it, rename int offset to the > more name 'mask' > > Signed-off-by: Sascha Hauer <[hidden email]> > > --- > gst/bayer/gstbayer2rgb.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 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 > @@ -231,19 +231,21 @@ gst_bayer2rgb_get_property (GObject * ob > > /* Routine to convert colormask value into relative byte offset */ > static int > -get_pix_offset (int offset) > +get_pix_offset (int mask, int bpp) > { > - switch (offset) { > + int bpp32 = (bpp / 8) - 3; > + > what prevents bpp32 from being negative ? > + switch (mask) { > case 255: > - return 3; > + return 2 + bpp32; > case 65280: > - return 2; > + return 1 + bpp32; > case 16711680: > - return 1; > + return 0 + bpp32; > case -16777216: > return 0; > default: > - GST_ERROR ("Invalid color mask 0x%08x", offset); > + GST_ERROR ("Invalid color mask 0x%08x", mask); > return -1; > } > } > @@ -254,7 +256,7 @@ gst_bayer2rgb_set_caps (GstBaseTransform > { > GstBayer2RGB *filter = GST_BAYER2RGB (base); > GstStructure *structure; > - int val; > + int val, bpp; > > GST_DEBUG ("in caps %" GST_PTR_FORMAT " out caps %" GST_PTR_FORMAT, incaps, > outcaps); > @@ -267,14 +269,14 @@ gst_bayer2rgb_set_caps (GstBaseTransform > > /* To cater for different RGB formats, we need to set params for later */ > structure = gst_caps_get_structure (outcaps, 0); > - gst_structure_get_int (structure, "bpp", &val); > - filter->pixsize = val / 8; > + gst_structure_get_int (structure, "bpp", &bpp); > + filter->pixsize = bpp / 8; > gst_structure_get_int (structure, "red_mask", &val); > - filter->r_off = get_pix_offset (val); > + filter->r_off = get_pix_offset (val, bpp); > gst_structure_get_int (structure, "green_mask", &val); > - filter->g_off = get_pix_offset (val); > + filter->g_off = get_pix_offset (val, bpp); > gst_structure_get_int (structure, "blue_mask", &val); > - filter->b_off = get_pix_offset (val); > + filter->b_off = get_pix_offset (val, bpp); > > return TRUE; > } > -- Benoit Fouet Purple Labs S.A. www.purplelabs.com ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
On Fri, Oct 17, 2008 at 11:32:02AM +0200, Benoit Fouet wrote:
> Hi, > > Sascha Hauer wrote: > > The code calculates the wrong color offsets for 24bpp packed > > pixel formats. Fix it. While at it, rename int offset to the > > more name 'mask' > > > > Signed-off-by: Sascha Hauer <[hidden email]> > > > > --- > > gst/bayer/gstbayer2rgb.c | 26 ++++++++++++++------------ > > 1 file changed, 14 insertions(+), 12 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 > > @@ -231,19 +231,21 @@ gst_bayer2rgb_get_property (GObject * ob > > > > /* Routine to convert colormask value into relative byte offset */ > > static int > > -get_pix_offset (int offset) > > +get_pix_offset (int mask, int bpp) > > { > > - switch (offset) { > > + int bpp32 = (bpp / 8) - 3; > > + > > > > what prevents bpp32 from being negative ? The plugin only handles 24bpp and 32bpp, so the result should be positive. But maybe there are better methods to calculate the bit offset from a given mask. I wonder if gstreamer provides such a function? > > > + switch (mask) { > > case 255: > > - return 3; > > + return 2 + bpp32; > > case 65280: > > - return 2; > > + return 1 + bpp32; > > case 16711680: > > - return 1; > > + return 0 + bpp32; > > case -16777216: > > return 0; > > default: > > - GST_ERROR ("Invalid color mask 0x%08x", offset); > > + GST_ERROR ("Invalid color mask 0x%08x", mask); > > return -1; > > } > > } > > @@ -254,7 +256,7 @@ gst_bayer2rgb_set_caps (GstBaseTransform > > { > > GstBayer2RGB *filter = GST_BAYER2RGB (base); > > GstStructure *structure; > > - int val; > > + int val, bpp; > > > > GST_DEBUG ("in caps %" GST_PTR_FORMAT " out caps %" GST_PTR_FORMAT, incaps, > > outcaps); > > @@ -267,14 +269,14 @@ gst_bayer2rgb_set_caps (GstBaseTransform > > > > /* To cater for different RGB formats, we need to set params for later */ > > structure = gst_caps_get_structure (outcaps, 0); > > - gst_structure_get_int (structure, "bpp", &val); > > - filter->pixsize = val / 8; > > + gst_structure_get_int (structure, "bpp", &bpp); > > + filter->pixsize = bpp / 8; > > gst_structure_get_int (structure, "red_mask", &val); > > - filter->r_off = get_pix_offset (val); > > + filter->r_off = get_pix_offset (val, bpp); > > gst_structure_get_int (structure, "green_mask", &val); > > - filter->g_off = get_pix_offset (val); > > + filter->g_off = get_pix_offset (val, bpp); > > gst_structure_get_int (structure, "blue_mask", &val); > > - filter->b_off = get_pix_offset (val); > > + filter->b_off = get_pix_offset (val, bpp); > > > > return TRUE; > > } > > > > -- > Benoit Fouet > Purple Labs S.A. > www.purplelabs.com > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > gstreamer-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel > -- 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 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |