Re: [PATCH/RFC] V4L2: add a generic function to find the nearest discrete format

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

 



Hi Guennadi,

On Saturday 07 August 2010 15:20:58 Guennadi Liakhovetski wrote:
> On Sat, 7 Aug 2010, lawrence rust wrote:

[snip]

> > A mean squared error metric such as hypot() could be better but requires
> > FP.  An integer only version wouldn't be too difficult.
> 
> No FP in the kernel. And I don't think this simple task justifies any
> numerical acrobatic. But we can just compare x^2 + y^2 - without an sqrt.
> Is it worth it?

What about comparing areas ? The uvcvideo driver does (rw and rh are the 
request width and request height, format is a structure containing an array of 
supported sizes)

        /* Find the closest image size. The distance between image sizes is
         * the size in pixels of the non-overlapping regions between the
         * requested size and the frame-specified size.
         */
        rw = fmt->fmt.pix.width;
        rh = fmt->fmt.pix.height;
        maxd = (unsigned int)-1;

        for (i = 0; i < format->nframes; ++i) {
                __u16 w = format->frame[i].wWidth;
                __u16 h = format->frame[i].wHeight;

                d = min(w, rw) * min(h, rh);
                d = w*h + rw*rh - 2*d;
                if (d < maxd) {
                        maxd = d;
                        frame = &format->frame[i];
                }

                if (maxd == 0)
                        break;
        }

-- 
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