[{"id":16612,"web_url":"https://patchwork.libcamera.org/comment/16612/","msgid":"<YIeReIiGptlk22BM@pendragon.ideasonboard.com>","date":"2021-04-27T04:22:16","subject":"Re: [libcamera-devel] [RFC PATCH v2 03/12] android: CameraDevice:\n\tReport proper min and max frame durations","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, Apr 22, 2021 at 06:40:53PM +0900, Paul Elder wrote:\n> The HAL layer was getting the min and max frame durations from from the\n\ns/from from/from/\n\n> camera, then rounding it to fps to report as available fps ranges. The\n> same min and max frame durations were then being reported as min and max\n> frame durations. Since the fps are integer values while the frame\n> durations are in ns, this caused a rounding error making it seem like we\n> were reporting an available max fps that was higher than was was allowed\n> by the minimum frame duration.\n> \n> An example is if the minimum frame duration is reported as 33366700ns.\n> The HAL layer would then convert it to fps, which is 29.97, but it would\n> be rounded and reported as 30 fps. When 30 fps is converted to a frame\n> duration it is 33333333ns, which is less than the minimum frame duration\n> that we report. Thus the minimum frame duration that we report\n> contradicts the fps rage that we report.\n\ns/rage/range/\n\n> Fix this by recalculating the frame durations based on the rounded fps\n> values.\n> \n> This allows the following CTS test to pass:\n> - android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.cpp | 4 ++++\n>  1 file changed, 4 insertions(+)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 76863877..a11ad848 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -900,6 +900,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \t\tint32_t minFps = std::round(1e9 / maxFrameDurationNsec);\n>  \t\tminFps = std::max(1, minFps);\n>  \n> +\t\t/* Avoid rounding errors when we reuse these variables later */\n\nIsn't it the other way around, aren't you're forcing rounding errors ?\nThe change could be fine (although it seems a bit weird that CTS would\nchoke on this, as it's obvious that rounding errors would occur), but\nthe comment, and possibly the commit message, should be updated.\n\n> +\t\tminFrameDurationNsec = 1e9 / maxFps;\n> +\t\tmaxFrameDurationNsec = 1e9 / minFps;\n> +\n>  \t\t/*\n>  \t\t * Register to the camera service {min, max} and {max, max}\n>  \t\t * intervals as requested by the metadata documentation.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E56EEBDCA6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Apr 2021 04:22:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43DAA68878;\n\tTue, 27 Apr 2021 06:22:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3E8C760512\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Apr 2021 06:22:23 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AB2B5E9;\n\tTue, 27 Apr 2021 06:22:22 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nPr9plzJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619497342;\n\tbh=/mxvXmhFjdQFTwaAW3KcHWvUvfHLxo+PgDqIskgZ4bA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nPr9plzJUyHoG1kbPaJhqj7Q3ySOd/gxj2t8U0zobS/OJhFD2DJwX7f9CCy+sbl5G\n\tf6y08v3zzyzYzJl5yYs0fw3eUntHSGygtsBvH3pk7HPljmef8bNRCn2VWwIlUj8wFS\n\tVaI8htlqDqE+umgnYYaMbe6vgVzW4iilHjI/269w=","Date":"Tue, 27 Apr 2021 07:22:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YIeReIiGptlk22BM@pendragon.ideasonboard.com>","References":"<20210422094102.371772-1-paul.elder@ideasonboard.com>\n\t<20210422094102.371772-4-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210422094102.371772-4-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 03/12] android: CameraDevice:\n\tReport proper min and max frame durations","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":16641,"web_url":"https://patchwork.libcamera.org/comment/16641/","msgid":"<20210427074402.d4bowu42pzi6zh73@uno.localdomain>","date":"2021-04-27T07:44:02","subject":"Re: [libcamera-devel] [RFC PATCH v2 03/12] android: CameraDevice:\n\tReport proper min and max frame durations","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Paul,\n\nOn Thu, Apr 22, 2021 at 06:40:53PM +0900, Paul Elder wrote:\n> The HAL layer was getting the min and max frame durations from from the\n\nfrom from\n\n> camera, then rounding it to fps to report as available fps ranges. The\n> same min and max frame durations were then being reported as min and max\n> frame durations. Since the fps are integer values while the frame\n> durations are in ns, this caused a rounding error making it seem like we\n> were reporting an available max fps that was higher than was was allowed\n\ns/was was/what was/\n\n> by the minimum frame duration.\n>\n> An example is if the minimum frame duration is reported as 33366700ns.\n> The HAL layer would then convert it to fps, which is 29.97, but it would\n> be rounded and reported as 30 fps. When 30 fps is converted to a frame\n> duration it is 33333333ns, which is less than the minimum frame duration\n> that we report. Thus the minimum frame duration that we report\n> contradicts the fps rage that we report.\n\nNot easy to explain :)\n\n>\n> Fix this by recalculating the frame durations based on the rounded fps\n> values.\n>\n> This allows the following CTS test to pass:\n> - android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange\n>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  src/android/camera_device.cpp | 4 ++++\n>  1 file changed, 4 insertions(+)\n>\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 76863877..a11ad848 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -900,6 +900,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \t\tint32_t minFps = std::round(1e9 / maxFrameDurationNsec);\n>  \t\tminFps = std::max(1, minFps);\n>\n> +\t\t/* Avoid rounding errors when we reuse these variables later */\n> +\t\tminFrameDurationNsec = 1e9 / maxFps;\n> +\t\tmaxFrameDurationNsec = 1e9 / minFps;\n> +\n\nAgreed\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n>  \t\t/*\n>  \t\t * Register to the camera service {min, max} and {max, max}\n>  \t\t * intervals as requested by the metadata documentation.\n> --\n> 2.27.0\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 85051BDCC3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Apr 2021 07:43:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0B19C688BB;\n\tTue, 27 Apr 2021 09:43:22 +0200 (CEST)","from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D49B7688B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Apr 2021 09:43:20 +0200 (CEST)","from uno.localdomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 5EB15FF814;\n\tTue, 27 Apr 2021 07:43:20 +0000 (UTC)"],"X-Originating-IP":"93.61.96.190","Date":"Tue, 27 Apr 2021 09:44:02 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<20210427074402.d4bowu42pzi6zh73@uno.localdomain>","References":"<20210422094102.371772-1-paul.elder@ideasonboard.com>\n\t<20210422094102.371772-4-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210422094102.371772-4-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 03/12] android: CameraDevice:\n\tReport proper min and max frame durations","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]