From patchwork Thu Feb 25 18:36:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11390 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 8B99CBD1F1 for ; Thu, 25 Feb 2021 18:37:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5630C68A64; Thu, 25 Feb 2021 19:37:06 +0100 (CET) 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="hzigwtkI"; dkim-atps=neutral Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A849F68A59 for ; Thu, 25 Feb 2021 19:37:05 +0100 (CET) Received: by mail-lj1-x230.google.com with SMTP id q23so7630775lji.8 for ; Thu, 25 Feb 2021 10:37:05 -0800 (PST) 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; bh=veWN98fZcbakbj7dt4jyzAprw0las+6G3CgLk/aoTdY=; b=hzigwtkIor+w/Zn9D8e4f8twrCfppK2sv4k4ZXs9c9D8kZjcYh1TUhQeQIgOqsca1a GPjUlCTwkKh7d8AqAksxe1j9GUMd2cebf18oJY3wFxJYwGcmLDuOpVo38qp58+CEpEke WkEgx2E/Wr6m7pbI0NdG59387sukdkGFSmqAExXwY/lvAdn+49BRP05/YGSmCiLc6gbi 644CZz6X1DvyV+t7Nlu+cfZk9l/Ih/TsResEK85d+FL1MwBBchh0cYti/t2pVKVu7ATN /0/MrxCr5Mp4OcSiN8uaVOjIIosZj9cayvPaCMDqqVdl1cyRQw4YtcPcor6W84E9tsQD qXWg== 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; bh=veWN98fZcbakbj7dt4jyzAprw0las+6G3CgLk/aoTdY=; b=HtgTKOM/DgtWVx/eoYHYbmdaida6fNA34E1ljZblWYPipg0Sg1Snw86PGmne/zmgR1 A6rmApSrCrZazGGP0Wd0wh1NpQ4Dxo4gynQmhQibS6pJXoYFYluznQRpKUg/CIijRQ4m hoFAr+MKQghdXOzJ04brCJZW7RTin2ekSiBXcajMhY0PPX1SJL66pyuBXP6ZIwCBelI0 rbYHpBfM6q6xAfOQOfY2qMw1c8gFbFbjlGWz4/wT6tie/seqexUPNUuRk5JE2BQ8Pzyn JsLKK/Xjfy0qESBJxI/t8YxSnARE996uQudcbRreNLgJbteTdoUV4qNhQ+p0u0U7TyKg Jq0Q== X-Gm-Message-State: AOAM530a6cH088gwtoWcwDWaR1boUG4YdXFuBv+84XekyYd1b/ONMBVA yZCequ2kfYWdiENqSI/L74vyrJOZnxesXA== X-Google-Smtp-Source: ABdhPJy1CUwpfAic1BBQLg1WCsB4jLk4vC5TILTsrUue4WGXjpac+qz4j0j6BAeBlWil4UV7jmOywA== X-Received: by 2002:a2e:b4f9:: with SMTP id s25mr2275648ljm.49.1614278225055; Thu, 25 Feb 2021 10:37:05 -0800 (PST) Received: from localhost.localdomain ([85.249.43.69]) by smtp.googlemail.com with ESMTPSA id x1sm1136772ljh.62.2021.02.25.10.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 10:37:04 -0800 (PST) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org, laurent.pinchart@ideasonboard.com Date: Thu, 25 Feb 2021 21:36:24 +0300 Message-Id: <20210225183626.28288-4-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210225183626.28288-1-andrey.konovalov@linaro.org> References: <20210225183626.28288-1-andrey.konovalov@linaro.org> Subject: [libcamera-devel] [PATCH 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 MIME-Version: 1.0 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 */