{"id":17085,"url":"https://patchwork.libcamera.org/api/patches/17085/?format=json","web_url":"https://patchwork.libcamera.org/patch/17085/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220812090103.1781246-1-hanlinchen@chromium.org>","date":"2022-08-12T09:01:03","name":"[libcamera-devel,v2] libcamera: ipu3: Use std::max() instead of expandTo() to get the max resolution","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"2ac37f8ebb07345a09f635fce388dc0a5fddca3c","submitter":{"id":98,"url":"https://patchwork.libcamera.org/api/people/98/?format=json","name":"Hanlin Chen","email":"hanlinchen@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17085/mbox/","series":[{"id":3407,"url":"https://patchwork.libcamera.org/api/series/3407/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3407","date":"2022-08-12T09:01:03","name":"[libcamera-devel,v2] libcamera: ipu3: Use std::max() instead of expandTo() to get the max resolution","version":2,"mbox":"https://patchwork.libcamera.org/series/3407/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17085/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17085/checks/","tags":{},"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 4E654BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Aug 2022 09:01:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A378E6332A;\n\tFri, 12 Aug 2022 11:01:11 +0200 (CEST)","from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com\n\t[IPv6:2607:f8b0:4864:20::102d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D47C463326\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Aug 2022 11:01:09 +0200 (CEST)","by mail-pj1-x102d.google.com with SMTP id\n\tq9-20020a17090a2dc900b001f58bcaca95so7767542pjm.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Aug 2022 02:01:09 -0700 (PDT)","from localhost ([2401:fa00:1:17:1705:d284:d114:2e24])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tt21-20020a634455000000b00419b128cf98sm935151pgk.54.2022.08.12.02.01.07\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tFri, 12 Aug 2022 02:01:07 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660294871;\n\tbh=QQbmlaTru7HANm0+BKbT7CuZ8c33iZRKAzLvB+Cn5tA=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Kj0GUxYuHMCshroWwKwT+SzIWhVxNwHNN6yR2bGGeW5ydYur+1PdZ+SAehaZtA1uq\n\t/nV4AZjvHXJlqOlcth8xOuEst6xzQF00bvGDCk8NVNLYFNWPhnaDbnyLRl1bw8dnu3\n\t7EYgFFUZ5Rqh1br1quBBRaIgrvaG/H3bNbMCQ5et4LqOdH/o0mAbeaVULK5m0Wqz45\n\t84q1tMQfij/k/XsDrtmMsnAAxTmJh/txCufxBQz6ZtWB9qLgmyMvr0jGFLGkWqfFW8\n\tvLAib67hOD0q2bECbbi5XWx6fT5KHXv1vbIwhPE0v5K3EUXtwOFOLDRmwBfQbb+3PK\n\tU8m6+HmsfzrjQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc;\n\tbh=pXnSr914+nO/rhkBxzopHGK/cxQKlKvOmTElXFME5zI=;\n\tb=Hvdtj9Ndd9Ko2hKXeD/u6erUBlQ3+zHd87adBOSFXtzuH5k39FZ4KT8xyVxf8edPnt\n\t0Ag/QU2ijC/SdtikMO7f/KEY79EJ5Z7YJo55C8pbuu0Rt9nX4O+0PKQnfi0ujAkAbUbZ\n\tNMCV7BOfszCRKmY24OAsQ7+jh3iKO3/32K+jY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=chromium.org\n\theader.i=@chromium.org header.b=\"Hvdtj9Nd\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc;\n\tbh=pXnSr914+nO/rhkBxzopHGK/cxQKlKvOmTElXFME5zI=;\n\tb=2FEFBG+PLvnJKPQHWNVpfAxdU4L5zm97czR5tvTDm6Z4Rylhv2ppmS9ndwJpavU1Y9\n\tKB57thMiKNz5Fz5StGAP6dDe0CMUv1Og4Lf8oApTMOZipuW/JpdEE2WxKydj+Sp+TBZh\n\thYm08bgCV9Gy/LMIV/fO1N1tVNG/EvaLWUyKhor3v/0NRXSfdUZZ4mlIultJGMfw18qd\n\tOqGqO54e8Q7KErLKUlfgGpVghrvCS7E+s3E0F2XPKM089xw65HP6DHsWvEuaEeQN7epV\n\tH/x5AfFROGcxFyZaxHJvFIJNdoMm09lmzmjjDnuMfhXsJiv6IjAI6M0OiMlZSadVCspP\n\tDTuA==","X-Gm-Message-State":"ACgBeo0oD6g3Kkc+cPeDSKAeJJFcns8wnS7wemciE92Gp3S3p7ERT5Rd\n\tCkwk317rrvgUzvZgJbvYcbHTbeokgmK57A==","X-Google-Smtp-Source":"AA6agR6GtLvCQQLHdo1xoQ1PYoeDx3cfCBjrzKfCdCVLVmS7FAbOu7eZrO9Bz5qCCScEOqBhEeCjbw==","X-Received":"by 2002:a17:90b:350a:b0:1f5:6a5e:5d12 with SMTP id\n\tls10-20020a17090b350a00b001f56a5e5d12mr12949640pjb.46.1660294868164; \n\tFri, 12 Aug 2022 02:01:08 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 12 Aug 2022 17:01:03 +0800","Message-Id":"<20220812090103.1781246-1-hanlinchen@chromium.org>","X-Mailer":"git-send-email 2.37.1.595.g718a3a8f04-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] libcamera: ipu3: Use std::max()\n\tinstead of expandTo() to get the max resolution","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>","From":"Han-Lin Chen via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Han-Lin Chen <hanlinchen@chromium.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Using Size::expandTo() to find the max resolution might generate a non-existent\nresolution. For example, when application request streams for 1920x1080 and\n1600x1200, the max resolution will be wrongly 1920x1200 and fails the\nconfiguration.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=139\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 22 ++++++++++++----------\n 1 file changed, 12 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f65db3c8..47311953 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -247,6 +247,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \t */\n \tunsigned int rawCount = 0;\n \tunsigned int yuvCount = 0;\n+\tSize rawRequirement;\n \tSize maxYuvSize;\n \tSize rawSize;\n \n@@ -255,10 +256,11 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \n \t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n \t\t\trawCount++;\n-\t\t\trawSize.expandTo(cfg.size);\n+\t\t\trawSize = std::max(rawSize, cfg.size);\n \t\t} else {\n \t\t\tyuvCount++;\n-\t\t\tmaxYuvSize.expandTo(cfg.size);\n+\t\t\tmaxYuvSize = std::max(maxYuvSize, cfg.size);\n+\t\t\trawRequirement.expandTo(cfg.size);\n \t\t}\n \t}\n \n@@ -287,17 +289,17 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \t * The output YUV streams will be limited in size to the maximum frame\n \t * size requested for the RAW stream, if present.\n \t *\n-\t * If no raw stream is requested generate a size as large as the maximum\n-\t * requested YUV size aligned to the ImgU constraints and bound by the\n-\t * sensor's maximum resolution. See\n+\t * If no raw stream is requested generate a size as large as the span\n+\t * of all requested YUV size aligned to the ImgU constraints and bound\n+\t * by the sensor's maximum resolution. See\n \t * https://bugs.libcamera.org/show_bug.cgi?id=32\n \t */\n \tif (rawSize.isNull())\n-\t\trawSize = maxYuvSize.expandedTo({ ImgUDevice::kIFMaxCropWidth,\n-\t\t\t\t\t\t  ImgUDevice::kIFMaxCropHeight })\n-\t\t\t\t    .grownBy({ ImgUDevice::kOutputMarginWidth,\n-\t\t\t\t\t       ImgUDevice::kOutputMarginHeight })\n-\t\t\t\t    .boundedTo(data_->cio2_.sensor()->resolution());\n+\t\trawSize = rawRequirement.expandedTo({ ImgUDevice::kIFMaxCropWidth,\n+\t\t\t\t\t\t      ImgUDevice::kIFMaxCropHeight })\n+\t\t\t\t  .grownBy({ ImgUDevice::kOutputMarginWidth,\n+\t\t\t\t\t     ImgUDevice::kOutputMarginHeight })\n+\t\t\t\t  .boundedTo(data_->cio2_.sensor()->resolution());\n \n \tcio2Configuration_ = data_->cio2_.generateConfiguration(rawSize);\n \tif (!cio2Configuration_.pixelFormat.isValid())\n","prefixes":["libcamera-devel","v2"]}