Re: [PATCH 5/8] soc-camera: Add soc_mbus_image_size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guennadi,

On Thursday 26 January 2012 16:59:23 Guennadi Liakhovetski wrote:
> On Wed, 25 Jan 2012, Laurent Pinchart wrote:
> > The function returns the minimum size of an image for a given number of
> > bytes per line (as per the V4L2 specification), width and format.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
> > ---
> > 
> >  drivers/media/video/soc_mediabus.c |   18 ++++++++++++++++++
> >  include/media/soc_mediabus.h       |    2 ++
> >  2 files changed, 20 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/media/video/soc_mediabus.c
> > b/drivers/media/video/soc_mediabus.c index a707314..3f47774 100644
> > --- a/drivers/media/video/soc_mediabus.c
> > +++ b/drivers/media/video/soc_mediabus.c
> > @@ -397,6 +397,24 @@ s32 soc_mbus_bytes_per_line(u32 width, const struct
> > soc_mbus_pixelfmt *mf)
> > 
> >  }
> >  EXPORT_SYMBOL(soc_mbus_bytes_per_line);
> > 
> > +s32 soc_mbus_image_size(u32 bytes_per_line, u32 height,
> > +			const struct soc_mbus_pixelfmt *mf)
> 
> What do you think about making mf the first parameter? :-)

I copied the parameters order from soc_mbus_bytes_per_line(). I like having 
the format first, so I'll change that for soc_mbus_image_size().

> > +{
> > +	if (mf->layout == SOC_MBUS_LAYOUT_PACKED)
> > +		return bytes_per_line * height;
> > +
> > +	switch (mf->packing) {
> > +	case SOC_MBUS_PACKING_2X8_PADHI:
> > +	case SOC_MBUS_PACKING_2X8_PADLO:
> > +		return bytes_per_line * height * 2;
> > +	case SOC_MBUS_PACKING_1_5X8:
> > +		return bytes_per_line * height * 3 / 2;
> 
> Hm, confused. Why have you decided to calculate the size based on packing
> and not on layout?

Because planar YUV 4:2:0, 4:2:2 and 4:4:4 formats would all use 
SOC_MBUS_LAYOUT_Y_U_V. I could create SOC_MBUS_LAYOUT_2Y_U_V and 
SOC_MBUS_LAYOUT_4Y_U_V instead. As existing planar formats all have a 
bits_per_sample value of 8, mf->packing was already used by 
soc_mbus_bytes_per_line() (before my patches) to compute the total line size 
in bytes, so I thought it made sense to reuse it in soc_mbus_image_size().

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux