From patchwork Tue Apr 26 11:43:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 15728 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2EB47C3256 for ; Tue, 26 Apr 2022 11:43:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9FF3B604A9; Tue, 26 Apr 2022 13:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650973419; bh=AWrQNCirM/xZOf9NT5g+Vnj7pSNijjCIMer3vMRqzy8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kVq/9iiMuibAnLzwOwuwsQ4QVOMK5ME6ykhePDr0FCaHl03nW68osx1meI1W8K/3f NnS+P4392mySPLHd4Vc/s0M41N7EtAsXFdBMmg9Xsg7aoP496SK7Y7tF6Wp4BJlZVR Oe0JUAsj7E6h/Qaq34EvOueUB9Qk6mQ3S44a0TSLa5ZK9QQKj9c4sDZDBe59KmSAd7 ONz3IqkKP9bRAPy2thI0H6a3cmqcPHE5PH/y7C4LCiX7cysG/UTWpb1dwDmvGSnx+d NJXAyH39K0oqfZH7mvMHoADI928Cb+0i9lS0BOCEimB447rstQUqsr4C4T+udI4rA/ Jqpymk4Q318kg== Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 20D9260431 for ; Tue, 26 Apr 2022 13:43:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="n4Mgzvn2"; dkim-atps=neutral Received: by mail-pf1-x436.google.com with SMTP id a11so6493962pff.1 for ; Tue, 26 Apr 2022 04:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=glXOQ5MihTl6mbnTQP5NS6PzGkWKfJTdAq5aTZlWJ5I=; b=n4Mgzvn2uJba1etUbw4nBHmwMR6F/PfFhLq8pMinmCM6x/ul6vNd8ygRJTs+6ESJhT fwlnpLMZ3MSduiL8Q0lnellgqEDeEaK4lC7USam7LUugvI3V84JWA+5CovcP34VaEGAQ Bw7LgclCkRl6Dnf8wmYsjWnsbtACSvMFR4MfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=glXOQ5MihTl6mbnTQP5NS6PzGkWKfJTdAq5aTZlWJ5I=; b=bowPG/Y66tK09V0g3/hNmEs2OPkH4rcfXWsi4MZs3WcKjS6VqrXuZTCCRFowI1yh6T lEDpxYjsAyzXLwL1o7oSKxRuf8zY2udtizExyhLj9zjJ+ZV6crCaaoxD0aCA069hwOAk q/WKFkEXva5HuL7J+A9RRAjqiPqIQOcIGxA5Rp2vLrqmxHixbH1H2JrKS++gebsaWfx7 rFJbu8diDQ8Q2oK0in4ZmobaOsQK7b5623AaabdGsQ9iqsiZfKfvROtDI+rfAjXop5jI tsby06yNb7t0PbWGZdWgne7z0idB5ZQp5SO5s8A+X7FDZJ1jd7ln0jHuAreQOpzYDoo8 wWyg== X-Gm-Message-State: AOAM532uheKsVFH71Dgrm7vFQofnM9t+bfzbbIhdpFv6PfBr2bs8RVVa mkVHqbbw8N05LSmGOEXDANpZuESnytQE6g== X-Google-Smtp-Source: ABdhPJzgFmkGTx1T35nHQ8VcqG2lu0SngDnuzvTI4d1+aCfEWP0ixpixe0XTVgwFiZ4eVScdlEfXGw== X-Received: by 2002:a63:6b09:0:b0:3aa:c8d7:4c67 with SMTP id g9-20020a636b09000000b003aac8d74c67mr17668498pgc.600.1650973416454; Tue, 26 Apr 2022 04:43:36 -0700 (PDT) Received: from localhost ([2401:fa00:1:17:255:33c4:eb32:373b]) by smtp.gmail.com with UTF8SMTPSA id h10-20020a056a001a4a00b004f7c76f29c3sm15436004pfv.24.2022.04.26.04.43.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Apr 2022 04:43:36 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Apr 2022 19:43:30 +0800 Message-Id: <20220426114330.675768-1-hanlinchen@chromium.org> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] android: camera_capabilities: Adjust minimum frame duration to match FPS X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Han-Lin Chen via libcamera-devel From: Hanlin Chen Reply-To: Han-Lin Chen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CTS calculates FPS with a rounding formula: See Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration() fps = floor(1e9 / minFrameDuration + 0.05f) The android adapter reports it as the AE target FPS. The patch adjusts the reported minimum frame duration to match the reported FPS. The requirement comes from ChromeOS which only allows the stream configuration with the minimum frame duration achieves the target FPS. Signed-off-by: Han-Lin Chen Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 55d651f3..5242055c 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -687,6 +687,21 @@ int CameraCapabilities::initializeStreamConfigurations() minFrameDuration = minFrameDurationCap; } + /* + * Calculate FPS as CTS does: see + * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration() + */ + unsigned int fps = + static_cast(floor(1e9 / minFrameDuration + 0.05f)); + + /* + * Adjust the minimum frame duration to match the + * calculated FPS.The requirement comes from ChromeOS + * which only allows the stream configuration with the + * minimum frame duration achieves the target FPS. + */ + minFrameDuration = 1e9 / fps; + streamConfigurations_.push_back({ res, androidFormat, minFrameDuration, maxFrameDuration, }); @@ -1287,12 +1302,10 @@ int CameraCapabilities::initializeStaticMetadata() * recording profile. Inspecting the Intel IPU3 HAL * implementation confirms this but no reference has been found * in the metadata documentation. - * - * Calculate FPS as CTS does: see - * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration() */ - unsigned int fps = static_cast - (floor(1e9 / entry.minFrameDurationNsec + 0.05f)); + unsigned int fps = + static_cast(floor(1e9 / entry.minFrameDurationNsec)); + if (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30) continue;