From patchwork Thu May 27 10:55:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12450 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C9249C3203 for ; Thu, 27 May 2021 10:55:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0447568930; Thu, 27 May 2021 12:55:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="r83vRxX1"; dkim-atps=neutral Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F83768923 for ; Thu, 27 May 2021 12:55:28 +0200 (CEST) Received: by mail-lj1-x231.google.com with SMTP id o8so268822ljp.0 for ; Thu, 27 May 2021 03:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qAip27BP+CSOHYaYAUIBsQQCEYbNM1TjHaCu7Zmcni4=; b=r83vRxX1CYVmXaxL5WRtsgGfEFnQqMmvgIwVBEz35NmD3g/frGwVGkPY/DMbvq01gk LMJzQU0c8m5P3nE5xMVqu3cdh8Vjo0cmwhPqZRwFXpZBUkMuX74t/bOqLUFjIBxEuKes 32JNNufNePFM05tHLmTQrWkbOIMtoFgrJmlreZB7dishoVsaHtfO9kHohsyi7cTgxODb z5PpU61P6IfSA+wx8qc8oBK0FIjQNOvurZJoT+74vZTI9wxaUOQCUD8Gas5gIHI2Jvtr uPuMMU26Oy5BFHtxg53YHdJekDVHMpUdH1gVWKVUvz14BThriAl9mYz6uqI9ei5ajD0j mcjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qAip27BP+CSOHYaYAUIBsQQCEYbNM1TjHaCu7Zmcni4=; b=ILtIi45yJC9WGsaUaSNs7gGn+OECKFRxmwYVrb2cBteVyCljhOGwu/yEAiYwbLqBEs 9L+DCuAaaXP+2F/UF5mcZn21aolJmXTze6Z+OgFQ2GvNqC9fXHcpXPB+QPpzJ4J4kx51 fXU5tg8mdAXRsXpzmGm3vfIzA3VNfiFQF/kNbFmnDHqnsKWQNMvqiw2mvBuoODyNZAR4 xpsYH8pYgKRHV+M06T0JGxjq9hpd65Ytu5hmUHyPSgZn8RA27EznoqLHsDAcp3Gw4B30 mESwzUemGTmocQrqAOo6eqH/Nh7Qm2W6yl7avTbgvRlQXk01reYKM1Osir3lhxC0+Lr1 BXNw== X-Gm-Message-State: AOAM531NFi7/W5Ym7LsWQE4sOaqvP8xw5ENgQgSqOMOV0rIZy0Uu79YO P/HASFS3D74GXsjKQCN5xIjgUGD9orw75A== X-Google-Smtp-Source: ABdhPJzF2B4pbHcYAiaDMIkLdFIQi6pZMf320MSbq/CShFlGs5NaZOi+8fkgbH+f2db7wbOGSbQRIA== X-Received: by 2002:a05:651c:3db:: with SMTP id f27mr2026396ljp.241.1622112927387; Thu, 27 May 2021 03:55:27 -0700 (PDT) Received: from localhost.localdomain ([85.249.41.56]) by smtp.googlemail.com with ESMTPSA id h23sm170148lfc.52.2021.05.27.03.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 03:55:26 -0700 (PDT) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com Date: Thu, 27 May 2021 13:55:09 +0300 Message-Id: <20210527105511.447089-4-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527105511.447089-1-andrey.konovalov@linaro.org> References: <20210527105511.447089-1-andrey.konovalov@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] qcam: viewfinder_gl: RAW10P: handle the padding bytes properly X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: morgan@casual-effects.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The texture size must account for the padding bytes which may be present at the end of the lines in the frame. Signed-off-by: Andrey Konovalov --- src/qcam/viewfinder_gl.cpp | 11 +++++++---- src/qcam/viewfinder_gl.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index b324d77f..9db536a6 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -111,6 +111,10 @@ void ViewFinderGL::render(libcamera::FrameBuffer *buffer, MappedBuffer *map) renderComplete(buffer_); data_ = static_cast(map->memory); + /* + * \todo Get the stride from the buffer instead of computing it naively + */ + stride_ = buffer->metadata().planes[0].bytesused / size_.height(); update(); buffer_ = buffer; } @@ -594,14 +598,13 @@ void ViewFinderGL::doRender() /* * Packed raw Bayer 10-bit formats are stored in GL_RED texture. * The texture width is 10/8 of the image width. - * TODO: account for padding bytes at the end of the line. */ glActiveTexture(GL_TEXTURE0); configureTexture(*textures_[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, - size_.width() * 5 / 4, + stride_, size_.height(), 0, GL_RED, @@ -611,12 +614,12 @@ void ViewFinderGL::doRender() shaderProgram_.setUniformValue(textureUniformBayerFirstRed_, firstRed_); shaderProgram_.setUniformValue(textureUniformSize_, - size_.width() * 5 / 4, + stride_, size_.height(), size_.width(), size_.height()); shaderProgram_.setUniformValue(textureUniformStep_, - 1.0f / (size_.width() * 5 / 4 - 1), + 1.0f / (stride_ - 1), 1.0f / (size_.height() - 1)); break; diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index 337718e3..49f8364a 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -66,6 +66,7 @@ private: libcamera::FrameBuffer *buffer_; libcamera::PixelFormat format_; QSize size_; + int stride_; unsigned char *data_; /* Shaders */