[gst-devel] [patch 1/3] gst-plugins-bad bayer2rgb: Fix 24bpp rgb

Sascha Hauer s.hauer at pengutronix.de
Fri Oct 17 12:59:34 CEST 2008


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 <s.hauer at pengutronix.de>
> >
> > ---
> >  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
> gstreamer-devel at lists.sourceforge.net
> 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




More information about the gstreamer-devel mailing list