{"id":13694,"url":"https://patchwork.libcamera.org/api/1.1/patches/13694/?format=json","web_url":"https://patchwork.libcamera.org/patch/13694/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210906225636.14683-28-laurent.pinchart@ideasonboard.com>","date":"2021-09-06T22:56:34","name":"[libcamera-devel,v3,28/30] qcam: viewfinder_gl: Support multi-planar buffers","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d71e3ba8e25b39b3b0e838e1748f3068e67ab3db","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13694/mbox/","series":[{"id":2482,"url":"https://patchwork.libcamera.org/api/1.1/series/2482/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2482","date":"2021-09-06T22:54:20","name":"libcamera: Handle fallout of FrameBuffer offset support","version":3,"mbox":"https://patchwork.libcamera.org/series/2482/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13694/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13694/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 4F606BE175\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Sep 2021 22:57:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03E9F69185;\n\tTue,  7 Sep 2021 00:57:51 +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 2F2236918A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Sep 2021 00:57:10 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACB44993;\n\tTue,  7 Sep 2021 00:57:09 +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=\"cBvLb4kf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630969029;\n\tbh=mjp6bsNyrmQYd+BbqSpInOVicnd2/UieEMCHU/KAj4g=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=cBvLb4kfbJWZkxpC22qvt40OtzHLlDyPKC7ft1aRh0BlskJL7OhhuZwLBVe9f7mc9\n\t29hhH417R4kx4LTjSPSUMyqV2DlXHexXk/au/mulFHwqGRUWeDElMlLxqo0rp3K1Kk\n\tNkhsZCwnMH/SqZKm5MkgnnAhyos46xRuthg/wz6s=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  7 Sep 2021 01:56:34 +0300","Message-Id":"<20210906225636.14683-28-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>","References":"<20210906225420.13275-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 28/30] qcam: viewfinder_gl: Support\n\tmulti-planar buffers","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>"},"content":"Now that the ViewFinderGL receives an Image, it can trivially support\nmulti-planar buffers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/qcam/viewfinder_gl.cpp | 38 +++++++++++++++++---------------------\n src/qcam/viewfinder_gl.h   |  2 +-\n 2 files changed, 18 insertions(+), 22 deletions(-)","diff":"diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex 87e4fe03cb8d..32232faa2ad8 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -56,7 +56,7 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n };\n \n ViewFinderGL::ViewFinderGL(QWidget *parent)\n-\t: QOpenGLWidget(parent), buffer_(nullptr), data_(nullptr),\n+\t: QOpenGLWidget(parent), buffer_(nullptr), image_(nullptr),\n \t  vertexBuffer_(QOpenGLBuffer::VertexBuffer)\n {\n }\n@@ -102,6 +102,7 @@ void ViewFinderGL::stop()\n \tif (buffer_) {\n \t\trenderComplete(buffer_);\n \t\tbuffer_ = nullptr;\n+\t\timage_ = nullptr;\n \t}\n }\n \n@@ -114,15 +115,10 @@ QImage ViewFinderGL::getCurrentImage()\n \n void ViewFinderGL::render(libcamera::FrameBuffer *buffer, Image *image)\n {\n-\tif (buffer->planes().size() != 1) {\n-\t\tqWarning() << \"Multi-planar buffers are not supported\";\n-\t\treturn;\n-\t}\n-\n \tif (buffer_)\n \t\trenderComplete(buffer_);\n \n-\tdata_ = image->data(0).data();\n+\timage_ = image;\n \t/*\n \t * \\todo Get the stride from the buffer instead of computing it naively\n \t */\n@@ -489,7 +485,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \n \t\t/* Activate texture UV/VU */\n@@ -503,7 +499,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE_ALPHA,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_ + size_.width() * size_.height());\n+\t\t\t     image_->data(1).data());\n \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n \t\tbreak;\n \n@@ -519,7 +515,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \n \t\t/* Activate texture U */\n@@ -533,7 +529,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_ + size_.width() * size_.height());\n+\t\t\t     image_->data(1).data());\n \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n \n \t\t/* Activate texture V */\n@@ -547,7 +543,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_ + size_.width() * size_.height() * 5 / 4);\n+\t\t\t     image_->data(2).data());\n \t\tshaderProgram_.setUniformValue(textureUniformV_, 2);\n \t\tbreak;\n \n@@ -563,7 +559,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \n \t\t/* Activate texture V */\n@@ -577,7 +573,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_ + size_.width() * size_.height());\n+\t\t\t     image_->data(1).data());\n \t\tshaderProgram_.setUniformValue(textureUniformV_, 2);\n \n \t\t/* Activate texture U */\n@@ -591,7 +587,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_ + size_.width() * size_.height() * 5 / 4);\n+\t\t\t     image_->data(2).data());\n \t\tshaderProgram_.setUniformValue(textureUniformU_, 1);\n \t\tbreak;\n \n@@ -602,7 +598,7 @@ void ViewFinderGL::doRender()\n \t\t/*\n \t\t * Packed YUV formats are stored in a RGBA texture to match the\n \t\t * OpenGL texel size with the 4 bytes repeating pattern in YUV.\n-\t\t * The texture width is thus half of the image with.\n+\t\t * The texture width is thus half of the image_ with.\n \t\t */\n \t\tglActiveTexture(GL_TEXTURE0);\n \t\tconfigureTexture(*textures_[0]);\n@@ -614,7 +610,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_RGBA,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \n \t\t/*\n@@ -642,7 +638,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_RGBA,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \t\tbreak;\n \n@@ -658,7 +654,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_RGB,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \t\tbreak;\n \n@@ -689,7 +685,7 @@ void ViewFinderGL::doRender()\n \t\t\t     0,\n \t\t\t     GL_LUMINANCE,\n \t\t\t     GL_UNSIGNED_BYTE,\n-\t\t\t     data_);\n+\t\t\t     image_->data(0).data());\n \t\tshaderProgram_.setUniformValue(textureUniformY_, 0);\n \t\tshaderProgram_.setUniformValue(textureUniformBayerFirstRed_,\n \t\t\t\t\t       firstRed_);\n@@ -714,7 +710,7 @@ void ViewFinderGL::paintGL()\n \t\t\t\t   << \"create fragment shader failed.\";\n \t\t}\n \n-\tif (data_) {\n+\tif (image_) {\n \t\tglClearColor(0.0, 0.0, 0.0, 1.0);\n \t\tglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n \ndiff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\nindex 7cd8ef3316b9..72a60ecb9159 100644\n--- a/src/qcam/viewfinder_gl.h\n+++ b/src/qcam/viewfinder_gl.h\n@@ -67,7 +67,7 @@ private:\n \tlibcamera::PixelFormat format_;\n \tQSize size_;\n \tunsigned int stride_;\n-\tunsigned char *data_;\n+\tImage *image_;\n \n \t/* Shaders */\n \tQOpenGLShaderProgram shaderProgram_;\n","prefixes":["libcamera-devel","v3","28/30"]}