[{"id":22168,"web_url":"https://patchwork.libcamera.org/comment/22168/","msgid":"<164457713628.83878.7318442184748376500@Monstersaurus>","date":"2022-02-11T10:58:56","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting David Plowman (2022-02-09 12:08:04)\n> We must calculate the initial scaler crop when the camera is\n> configured, otherwise the metadata will report this rectangle as being\n> all zeroes.\n> \n\nI tried to check to see if this is something that should be initialised\nearlier. I'd almost be tempted to make an init() for the RPi Camera Data\nclass, to make sure there's a common location to initialise all of it's\ndata ..., but I don't think that actually helps for this patch (unless\nwe re-initialise things before reconfiguring?).\n\nI think in configure is ok here too, as it's not something that should\nbe changed in validate(), and I think it's something that may need to\nreset/configured correctly after any previous configuration that may\nhave had a different scalerCrop_ set.\n\nSo ...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 583ee798..d6c57e7a 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -887,6 +887,11 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n>         if (ret)\n>                 LOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n>  \n> +       /* Set the scaler crop to the value that we are using. */\n> +       data->scalerCrop_ = data->ispCrop_.scaledBy(data->sensorInfo_.analogCrop.size(),\n> +                                                   data->sensorInfo_.outputSize);\n> +       data->scalerCrop_.translateBy(data->sensorInfo_.analogCrop.topLeft());\n> +\n>         /*\n>          * Configure the Unicam embedded data output format only if the sensor\n>          * supports it.\n> -- \n> 2.30.2\n>","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 3DBCEBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Feb 2022 10:59:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D802610F5;\n\tFri, 11 Feb 2022 11:59:02 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C0FFC61092\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Feb 2022 11:58:59 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D4A7F93;\n\tFri, 11 Feb 2022 11:58:58 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VytSlGEf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1644577138;\n\tbh=c1/ta+pxim1ulRdC/miBMNuiC6TSlEsiQwlniJZ/7aE=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=VytSlGEfjIzegBJQoxJu3hDGrPoS5cgiSrorahl8JabpWxS2qJd2c0+LJhvGEPw52\n\thS7JLEz/ouKmKCs7AxLlR6cH1yS1qX3PZDhJ6WNLLsds9dZD2dXQOmT/wzqUK7raOT\n\tyzRx6QpKZsQBgpZTLXWz0CocM+l8EDq6CJl5dMHo=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220209120804.21352-1-david.plowman@raspberrypi.com>","References":"<20220209120804.21352-1-david.plowman@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 11 Feb 2022 10:58:56 +0000","Message-ID":"<164457713628.83878.7318442184748376500@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22210,"web_url":"https://patchwork.libcamera.org/comment/22210/","msgid":"<Yh4vDxc5ABFHKELL@pendragon.ideasonboard.com>","date":"2022-03-01T14:34:55","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hello,\n\nOn Fri, Feb 11, 2022 at 10:58:56AM +0000, Kieran Bingham wrote:\n> Quoting David Plowman (2022-02-09 12:08:04)\n> > We must calculate the initial scaler crop when the camera is\n> > configured, otherwise the metadata will report this rectangle as being\n> > all zeroes.\n> \n> I tried to check to see if this is something that should be initialised\n> earlier. I'd almost be tempted to make an init() for the RPi Camera Data\n> class, to make sure there's a common location to initialise all of it's\n> data ..., but I don't think that actually helps for this patch (unless\n> we re-initialise things before reconfiguring?).\n> \n> I think in configure is ok here too, as it's not something that should\n> be changed in validate(), and I think it's something that may need to\n> reset/configured correctly after any previous configuration that may\n> have had a different scalerCrop_ set.\n> \n> So ...\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 5 +++++\n> >  1 file changed, 5 insertions(+)\n> > \n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index 583ee798..d6c57e7a 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -887,6 +887,11 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n> >         if (ret)\n> >                 LOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n> >  \n> > +       /* Set the scaler crop to the value that we are using. */\n> > +       data->scalerCrop_ = data->ispCrop_.scaledBy(data->sensorInfo_.analogCrop.size(),\n> > +                                                   data->sensorInfo_.outputSize);\n> > +       data->scalerCrop_.translateBy(data->sensorInfo_.analogCrop.topLeft());\n> > +\n\nThis is the same calculation as in RPiCameraData::applyScalerCrop().\nShould it be factored out to a separate function ?\n\n> >         /*\n> >          * Configure the Unicam embedded data output format only if the sensor\n> >          * supports it.","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 A399CBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Mar 2022 14:35:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1030461101;\n\tTue,  1 Mar 2022 15:35:09 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A0C89604EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Mar 2022 15:35:07 +0100 (CET)","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 16E4EA67;\n\tTue,  1 Mar 2022 15:35:07 +0100 (CET)"],"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=\"m3NcgzQR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1646145307;\n\tbh=K9rLpeBSJqzI0MtFUt5aZAan33k6tFjxhpWl06v6uCE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=m3NcgzQRZ5WCq7R6UCtKYq2knq7EQn7+HjEFPSWwpbzW/+r4UgVXpParQlYZghkcX\n\txwr5CeH8WJFK0DVA4cWHFxqvBiRpQSA0LmMt7NmFSF8LBph+fjDkQatMdnN1KPvWQe\n\ttPnc5fvg5ueYd1J5jV+ESG4Zdvw16uwoJUxPSMfA=","Date":"Tue, 1 Mar 2022 16:34:55 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<Yh4vDxc5ABFHKELL@pendragon.ideasonboard.com>","References":"<20220209120804.21352-1-david.plowman@raspberrypi.com>\n\t<164457713628.83878.7318442184748376500@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<164457713628.83878.7318442184748376500@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22216,"web_url":"https://patchwork.libcamera.org/comment/22216/","msgid":"<CAHW6GYJfEU812v901BfMxfJZ5UYZgpkZokycHyXSfFy4K+mesw@mail.gmail.com>","date":"2022-03-03T12:07:51","subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for looking at this!\n\nOn Tue, 1 Mar 2022 at 14:35, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hello,\n>\n> On Fri, Feb 11, 2022 at 10:58:56AM +0000, Kieran Bingham wrote:\n> > Quoting David Plowman (2022-02-09 12:08:04)\n> > > We must calculate the initial scaler crop when the camera is\n> > > configured, otherwise the metadata will report this rectangle as being\n> > > all zeroes.\n> >\n> > I tried to check to see if this is something that should be initialised\n> > earlier. I'd almost be tempted to make an init() for the RPi Camera Data\n> > class, to make sure there's a common location to initialise all of it's\n> > data ..., but I don't think that actually helps for this patch (unless\n> > we re-initialise things before reconfiguring?).\n> >\n> > I think in configure is ok here too, as it's not something that should\n> > be changed in validate(), and I think it's something that may need to\n> > reset/configured correctly after any previous configuration that may\n> > have had a different scalerCrop_ set.\n> >\n> > So ...\n> >\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 5 +++++\n> > >  1 file changed, 5 insertions(+)\n> > >\n> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > index 583ee798..d6c57e7a 100644\n> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > @@ -887,6 +887,11 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n> > >         if (ret)\n> > >                 LOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n> > >\n> > > +       /* Set the scaler crop to the value that we are using. */\n> > > +       data->scalerCrop_ = data->ispCrop_.scaledBy(data->sensorInfo_.analogCrop.size(),\n> > > +                                                   data->sensorInfo_.outputSize);\n> > > +       data->scalerCrop_.translateBy(data->sensorInfo_.analogCrop.topLeft());\n> > > +\n>\n> This is the same calculation as in RPiCameraData::applyScalerCrop().\n> Should it be factored out to a separate function ?\n\nActually this did cross my mind, but for the sake of two statements I\nended up being a bit lazy! But let me submit a v2 that does this, and\nperhaps we will prefer it.\n\nThanks\nDavid\n\n>\n> > >         /*\n> > >          * Configure the Unicam embedded data output format only if the sensor\n> > >          * supports it.\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 8C5B7BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Mar 2022 12:08:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD3C360475;\n\tThu,  3 Mar 2022 13:08:04 +0100 (CET)","from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 88413601FF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Mar 2022 13:08:02 +0100 (CET)","by mail-wm1-x335.google.com with SMTP id i66so3000988wma.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 03 Mar 2022 04:08:02 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"hNlvczk1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=Dfi7ciZDGRIVvenZ/f/Mq+0QgJwxfTDAfFhEhUmVpkY=;\n\tb=hNlvczk1IexaI0pgP4U7WWO1aYK6+ZbtSIMflz8UbyPzTbuP8wM8TS0YCe+IvBHx7Z\n\tlSPQZr8S8siLkfLvkZvVErO2+2qzAOfuPo23SsxkzdsPktV1AyTAPuYtrhUB7tvDLa6f\n\teR2wxAZg/kA0XRG/w517ByOLelOlqTrMTM+2Wg5S4QeGRPX290e4xIwBRDB9iOb5qjyn\n\tRm2v3RR5HItJuvNn3OidnawfDfn/kb/tfHPzBK6Y8gJzuAypWKmAL7MYIw3+wxW+6KnI\n\tuxM/hEL2KVQjW6Ehuch86cjHpHgN/2oZ9zKMzbS73PjboWhM7qQQinpzzvOh+G20EAMM\n\t6AWg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=Dfi7ciZDGRIVvenZ/f/Mq+0QgJwxfTDAfFhEhUmVpkY=;\n\tb=iUANvgbA2VAbg33vKgvABNeIN5+a5VpFRNq8NiJUsW71w9I5js/XYM9qonV2wOTdh7\n\tr3GV33Op6b3IpYVX1YqNS4NVc1w/f+rXjptol8vViAbyGGnSKOO1X2zabNTKtVJyYQyR\n\tmyU4cynNYaFp3ovyQZDPnH6M6+w2G61qEyXOQdPgZydNrZbTM46KxDHFoyuqp9ZgZKxa\n\tj8h9/0E4rG2o9QGbTf7Z67l+WJdX+C/xQ+Z75fPjGT+ebS98w5NqWRuC2bvaD3qidymx\n\t9YqP9oluMK40jEt7lWO5bqpOuKU9BCVnvlgxKWG85T0qa0BfbiEE2cDMp51tPHwu+78C\n\t8GwQ==","X-Gm-Message-State":"AOAM532KTqwPM6CWTk7dDlfynXDNFvRvtWcH9ynH3h5goq+WbV4fdykk\n\t3M4NjbXgyXFDjh/bMDoIp/rcyIsIsQD/5Jpkt0Ihyw==","X-Google-Smtp-Source":"ABdhPJxOrM2Gc675mAKjp93ApCRag/UXxZvxvIRXN/qIhIgMXOMdPuanMlI4RXTtz7bJ8Z5mtJcJ0sq2bBZpfjX8pzU=","X-Received":"by 2002:a7b:c0cb:0:b0:385:cad0:d483 with SMTP id\n\ts11-20020a7bc0cb000000b00385cad0d483mr3471527wmh.163.1646309282040;\n\tThu, 03 Mar 2022 04:08:02 -0800 (PST)","MIME-Version":"1.0","References":"<20220209120804.21352-1-david.plowman@raspberrypi.com>\n\t<164457713628.83878.7318442184748376500@Monstersaurus>\n\t<Yh4vDxc5ABFHKELL@pendragon.ideasonboard.com>","In-Reply-To":"<Yh4vDxc5ABFHKELL@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Thu, 3 Mar 2022 12:07:51 +0000","Message-ID":"<CAHW6GYJfEU812v901BfMxfJZ5UYZgpkZokycHyXSfFy4K+mesw@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: pipeline: raspberrypi: Fix\n\tscaler crop when sensor is configured","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 <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]