[{"id":4854,"web_url":"https://patchwork.libcamera.org/comment/4854/","msgid":"<20200519140325.GJ470768@oden.dyn.berto.se>","date":"2020-05-19T14:03:25","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple: Add\n\tscaling support","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-05-19 06:06:24 +0300, Laurent Pinchart wrote:\n> Use the converter to implement scaling.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 30 +++++++++++++++---------\n>  1 file changed, 19 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index b21ad82e1a05..dbaacbeafefa 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -75,7 +75,8 @@ public:\n>  \tstruct Configuration {\n>  \t\tuint32_t code;\n>  \t\tPixelFormat pixelFormat;\n> -\t\tSize size;\n> +\t\tSize captureSize;\n> +\t\tSizeRange outputSizes;\n>  \t};\n>  \n>  \tStream stream_;\n> @@ -301,13 +302,16 @@ int SimpleCameraData::init()\n>  \t\t\tConfiguration config;\n>  \t\t\tconfig.code = code;\n>  \t\t\tconfig.pixelFormat = pixelFormat;\n> -\t\t\tconfig.size = format.size;\n> +\t\t\tconfig.captureSize = format.size;\n>  \n>  \t\t\tif (!converter) {\n> +\t\t\t\tconfig.outputSizes = config.captureSize;\n>  \t\t\t\tformats_[pixelFormat] = config;\n>  \t\t\t\tcontinue;\n>  \t\t\t}\n>  \n> +\t\t\tconfig.outputSizes = converter->sizes(format.size);\n> +\n>  \t\t\tfor (PixelFormat format : converter->formats(pixelFormat))\n>  \t\t\t\tformats_[format] = config;\n>  \t\t}\n> @@ -440,15 +444,16 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>  \t}\n>  \n>  \tconst SimpleCameraData::Configuration &pipeConfig = it->second;\n> -\tif (cfg.size != pipeConfig.size) {\n> +\tif (!pipeConfig.outputSizes.contains(cfg.size)) {\n>  \t\tLOG(SimplePipeline, Debug)\n>  \t\t\t<< \"Adjusting size from \" << cfg.size.toString()\n> -\t\t\t<< \" to \" << pipeConfig.size.toString();\n> -\t\tcfg.size = pipeConfig.size;\n> +\t\t\t<< \" to \" << pipeConfig.captureSize.toString();\n> +\t\tcfg.size = pipeConfig.captureSize;\n>  \t\tstatus = Adjusted;\n>  \t}\n>  \n> -\tneedConversion_ = cfg.pixelFormat != pipeConfig.pixelFormat;\n> +\tneedConversion_ = cfg.pixelFormat != pipeConfig.pixelFormat\n> +\t\t\t|| cfg.size != pipeConfig.captureSize;\n>  \n>  \tcfg.bufferCount = 3;\n>  \n> @@ -485,7 +490,7 @@ CameraConfiguration *SimplePipelineHandler::generateConfiguration(Camera *camera\n>  \t\t       std::inserter(formats, formats.end()),\n>  \t\t       [](const auto &format) -> decltype(formats)::value_type {\n>  \t\t\t       const PixelFormat &pixelFormat = format.first;\n> -\t\t\t       const Size &size = format.second.size;\n> +\t\t\t       const Size &size = format.second.captureSize;\n>  \t\t\t       return { pixelFormat, { size } };\n>  \t\t       });\n>  \n> @@ -537,15 +542,18 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  \n>  \tV4L2DeviceFormat captureFormat = {};\n>  \tcaptureFormat.fourcc = videoFormat;\n> -\tcaptureFormat.size = cfg.size;\n> +\tcaptureFormat.size = pipeConfig.captureSize;\n>  \n>  \tret = video->setFormat(&captureFormat);\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> -\tif (captureFormat.fourcc != videoFormat || captureFormat.size != cfg.size) {\n> +\tif (captureFormat.fourcc != videoFormat ||\n> +\t    captureFormat.size != pipeConfig.captureSize) {\n>  \t\tLOG(SimplePipeline, Error)\n> -\t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n> +\t\t\t<< \"Unable to configure capture in \"\n> +\t\t\t<< pipeConfig.captureSize.toString() << \"-\"\n> +\t\t\t<< videoFormat.toString();\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> @@ -554,7 +562,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  \n>  \tif (useConverter_) {\n>  \t\tint ret = converter_->configure(pipeConfig.pixelFormat,\n> -\t\t\t\t\t\tcfg.size, &cfg);\n> +\t\t\t\t\t\tpipeConfig.captureSize, &cfg);\n>  \t\tif (ret < 0) {\n>  \t\t\tLOG(SimplePipeline, Error)\n>  \t\t\t\t<< \"Unable to configure converter\";\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B6B40603D9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 16:03:27 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id v16so9803558ljc.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 May 2020 07:03:27 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tt20sm6897341lfl.17.2020.05.19.07.03.25\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 19 May 2020 07:03:25 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"c/plbyLF\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=u/qbIqZ1rqAkeZU8OJvPL31UYWFBb296e79F6NlYpV4=;\n\tb=c/plbyLFTJ+1CfCSgnVt8i3cz5XW0VYLsaEdqe0y8Pm2URvgMuRc1gyJkGWkyTI+OX\n\tR8mX509WKOuB6KyCIWv9BKSzZD5VGQ1HrZsZdUirr80Lscp9pTwFfpVvouUTqdEnMjFC\n\txCjBh3uUwIA1oKeTzos9j9p+qfOTwPbw1Q649t3ef/3nJ50aPpOnJGCE3Y/oiWShtDHW\n\tuZubl+GN3v5k1Lnrq2KDSsHG3y1n21KNxu/TC9jXV4Q78SsRFy7pBNS1dCKwqMMeyXKI\n\tvaY+ZNIgUBjADyvWJRV+eLq4KJLjBQYkqExJ6K3TD3YPGge4VKcy+HBOYln0JLOm7WY5\n\tGkzQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=u/qbIqZ1rqAkeZU8OJvPL31UYWFBb296e79F6NlYpV4=;\n\tb=QVHegEfXlrio4GCdjsYFGFXs0ICsK9SS7nbGcogy4KG1PKRXYQndwjYYCSqTUo10EK\n\tPqLho8wMMnsFLU5S9bcpSvhhDePAy2Ag1N+bkM7QivpAbNFpeCH0tsSBz1nYrPdVILhm\n\tGuzLlCGb0oU4woEVBBSlhKyuz2osTjTzyepovhw2u1coEMLw6e/pW6ZpFxmXGJkMJQPG\n\tV+j4VXrY+wBPeZiowCPRjlNYXdh9RfyYzW3u560vnFYt3tzvVQkSOcYDDb8iJ4xI2OAM\n\t5n53o0BpeJw5hHXU9jy8HBPt04gDEL69mh16yGWetY+MUeRtqnnRhzq4HhtqqMtL35YY\n\tJWpw==","X-Gm-Message-State":"AOAM533y91CfPT2/+mEfpCc+0ai8nCorFOWyM23gVP/DoaqTsXRLZ0K1\n\tK/mjav4VRBm1FV+2GKSBAf00IP8JawiizQ==","X-Google-Smtp-Source":"ABdhPJxV2+pTyEDtlEjXyXxOycqFeclfY5rMZtqqqYk6xNMK8sAYMw7uAcVSCBEoWHg59BQXjOn2yw==","X-Received":"by 2002:a2e:9641:: with SMTP id\n\tz1mr13977394ljh.201.1589897006971; \n\tTue, 19 May 2020 07:03:26 -0700 (PDT)","Date":"Tue, 19 May 2020 16:03:25 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200519140325.GJ470768@oden.dyn.berto.se>","References":"<20200519030624.15985-1-laurent.pinchart@ideasonboard.com>\n\t<20200519030624.15985-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200519030624.15985-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: simple: Add\n\tscaling support","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>","X-List-Received-Date":"Tue, 19 May 2020 14:03:28 -0000"}}]