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