{"id":8731,"url":"https://patchwork.libcamera.org/api/patches/8731/?format=json","web_url":"https://patchwork.libcamera.org/patch/8731/","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":"<20200709132835.112593-17-paul.elder@ideasonboard.com>","date":"2020-07-09T13:28:28","name":"[libcamera-devel,v5,16/23] libcamera: simple: Fill stride and frameSize at config validation","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"277840c4b5388012184d679d5f9e066f16e25d73","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8731/mbox/","series":[{"id":1093,"url":"https://patchwork.libcamera.org/api/series/1093/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1093","date":"2020-07-09T13:28:12","name":"Clean up formats in v4l2-compat and pipeline handlers","version":5,"mbox":"https://patchwork.libcamera.org/series/1093/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8731/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8731/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 CD344BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jul 2020 13:29:29 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CEEF6124D;\n\tThu,  9 Jul 2020 15:29:29 +0200 (CEST)","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 150BA61184\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jul 2020 15:29:29 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A5D8525;\n\tThu,  9 Jul 2020 15:29:26 +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=\"FUAaUp2T\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594301368;\n\tbh=/nRUNLn4J1x6/qZih/bqQpzsiZ/RvCQCLK51RbG2xG4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FUAaUp2ThlT/rrdeYwewRUkKwfz3NBCnA1dbtAWtkEkVa4qscKyNqN1bXNtp9tEpd\n\teQHXs7pgS46bjcfuDIG9izv87DAKkD1l+cBSof7KSVpAzma81DNR/jljx6pceyaRYr\n\tGQySAw/fCS0u1DqkKEh6Qn4Fj3zHhVNgebtGeDww=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  9 Jul 2020 22:28:28 +0900","Message-Id":"<20200709132835.112593-17-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200709132835.112593-1-paul.elder@ideasonboard.com>","References":"<20200709132835.112593-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 16/23] libcamera: simple: Fill stride\n\tand frameSize at config validation","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>","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>"},"content":"Fill the stride and frameSize fields of the StreamConfiguration at\nconfiguration validation time instead of at camera configuration time.\nThis allows applications to get the stride when trying a configuration\nwithout modifying the active configuration of the camera.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nCosmetic change in v5\n\nChanges in v4:\n- fix converter's stride and frameSize (get it via tryFormat instead of\n  calculation)\n- merge converter's stride and frameSize to one function\n- return error if tryFormat fails\n- mention motivation in commit message\n\nNew in v3\n---\n src/libcamera/pipeline/simple/converter.cpp | 19 +++++++++++++++\n src/libcamera/pipeline/simple/converter.h   |  4 ++++\n src/libcamera/pipeline/simple/simple.cpp    | 26 +++++++++++++++++++--\n 3 files changed, 47 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\nindex e5e2f0f..cef1503 100644\n--- a/src/libcamera/pipeline/simple/converter.cpp\n+++ b/src/libcamera/pipeline/simple/converter.cpp\n@@ -261,4 +261,23 @@ void SimpleConverter::outputBufferReady(FrameBuffer *buffer)\n \t}\n }\n \n+int SimpleConverter::strideAndFrameSize(const Size &size,\n+\t\t\t\t\tconst PixelFormat &pixelFormat,\n+\t\t\t\t\tunsigned int *strideOut,\n+\t\t\t\t\tunsigned int *frameSizeOut)\n+{\n+\tV4L2DeviceFormat format = {};\n+\tformat.fourcc = m2m_->capture()->toV4L2PixelFormat(pixelFormat);\n+\tformat.size = size;\n+\n+\tint ret = m2m_->capture()->tryFormat(&format);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\t*strideOut = format.planes[0].bpl;\n+\t*frameSizeOut = format.planes[0].size;\n+\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h\nindex ef18cf7..3e46988 100644\n--- a/src/libcamera/pipeline/simple/converter.h\n+++ b/src/libcamera/pipeline/simple/converter.h\n@@ -46,6 +46,10 @@ public:\n \n \tint queueBuffers(FrameBuffer *input, FrameBuffer *output);\n \n+\tint strideAndFrameSize(const Size &size, const PixelFormat &pixelFormat,\n+\t\t\t       unsigned int *strideOut,\n+\t\t\t       unsigned int *frameSizeOut);\n+\n \tSignal<FrameBuffer *, FrameBuffer *> bufferReady;\n \n private:\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 1ec8d0f..2ca57d0 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -457,6 +457,30 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n \n \tcfg.bufferCount = 3;\n \n+\t/* Set the stride and frameSize. */\n+\tif (!needConversion_) {\n+\t\tV4L2DeviceFormat format = {};\n+\t\tformat.fourcc = data_->video_->toV4L2PixelFormat(cfg.pixelFormat);\n+\t\tformat.size = cfg.size;\n+\n+\t\tint ret = data_->video_->tryFormat(&format);\n+\t\tif (ret < 0)\n+\t\t\treturn Invalid;\n+\n+\t\tcfg.stride = format.planes[0].bpl;\n+\t\tcfg.frameSize = format.planes[0].size;\n+\n+\t\treturn status;\n+\t}\n+\n+\tSimplePipelineHandler *pipe = static_cast<SimplePipelineHandler *>(data_->pipe_);\n+\tSimpleConverter *converter = pipe->converter();\n+\n+\tint ret = converter->strideAndFrameSize(cfg.size, cfg.pixelFormat,\n+\t\t\t\t\t\t&cfg.stride, &cfg.frameSize);\n+\tif (ret < 0)\n+\t\treturn Invalid;\n+\n \treturn status;\n }\n \n@@ -557,8 +581,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \t\treturn -EINVAL;\n \t}\n \n-\tcfg.stride = captureFormat.planes[0].bpl;\n-\n \t/* Configure the converter if required. */\n \tuseConverter_ = config->needConversion();\n \n","prefixes":["libcamera-devel","v5","16/23"]}