Patch Detail
Show a patch.
GET /api/1.1/patches/12693/?format=api
{ "id": 12693, "url": "https://patchwork.libcamera.org/api/1.1/patches/12693/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12693/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210622134652.1279260-10-andrey.konovalov@linaro.org>", "date": "2021-06-22T13:46:52", "name": "[libcamera-devel,RFC,v5,9/9] qcam: viewfinder_gl: bayer_8.frag: compute the coordinates manually", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "966d2853e48e9a043c40db5dadefdca2e5734f06", "submitter": { "id": 25, "url": "https://patchwork.libcamera.org/api/1.1/people/25/?format=api", "name": "Andrey Konovalov", "email": "andrey.konovalov@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/12693/mbox/", "series": [ { "id": 2168, "url": "https://patchwork.libcamera.org/api/1.1/series/2168/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2168", "date": "2021-06-22T13:46:43", "name": "qcam: viewfinder_gl: add RAW8, RAW10P and RAW12P formats", "version": 5, "mbox": "https://patchwork.libcamera.org/series/2168/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12693/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12693/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 0E88EC321B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Jun 2021 13:47:30 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BE09A68935;\n\tTue, 22 Jun 2021 15:47:29 +0200 (CEST)", "from mail-lj1-x235.google.com (mail-lj1-x235.google.com\n\t[IPv6:2a00:1450:4864:20::235])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BD61060292\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jun 2021 15:47:28 +0200 (CEST)", "by mail-lj1-x235.google.com with SMTP id c11so30228354ljd.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Jun 2021 06:47:28 -0700 (PDT)", "from localhost.localdomain ([85.249.44.185])\n\tby smtp.googlemail.com with ESMTPSA id\n\tb19sm163125ljo.37.2021.06.22.06.47.27\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Jun 2021 06:47:27 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"X3PO4JM2\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=BAvEJ84VEQWmiF5nH6jedi2+7DTSJ/Dd6CWNQQoblKM=;\n\tb=X3PO4JM2ieRIyhbE0kk68dp4O3+0MBEuGA71zGBS9Yo8n832lueq0FH5MtywGgEzXS\n\tQK9RQ4Vj+50vwziry/AOSSNTHHdCtG5/GOUWMTgX4EyyicjnCQfWXRPq/hxfFki4jL0F\n\tJEHDeRgsMiCQDPw5mc8pSZUPX+3T+XXRwUSE5EZRBlpb3IFjCc+b34SZMnu+7lL81Da1\n\tI8HOYfxZAI7//Umdr4NrA9kfGZD6mKB06tJJf6oBPasVaZ9TGjeSl3X6qK+UOesEHVx4\n\tRMFPeUDzTJyxs3Az8SkZZdsOkqiZi1YsVAv3w31Ao4QuTbgqS4fqHMV+5CIY/LPhD2zp\n\t5KhA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=BAvEJ84VEQWmiF5nH6jedi2+7DTSJ/Dd6CWNQQoblKM=;\n\tb=QVh/UcpzfWGrB4cZ9WZOQ4eiXSYxmTYXvQa3dR87FErgXpcmZE75nBubbmDjmnnBfb\n\tOvQxLxoiUxv6SUXtFxhpk9YoEM159zBIgkNkU1mL07cqVp3fcyey1zrXZ0JJ1m6/ox88\n\tRoP8gBG5NrJFWzbix2GKdpWHUql3OlSqo0UBPzH6lAWOS6FStcG8yfXvW7Jf7cynJXIA\n\tEwVUG+GmO3ZcjcEOmwdhpnM3mm2rX9q3NTchyS3CqE52gYoDc/SAU5gsVQnMNRs5RUAh\n\tNVVOMAPVrZSblUflFLlkx90ibHmqaleFkfoFaoyaBmQTcQrNFz71DemIw0chUshKMzh5\n\tH3yg==", "X-Gm-Message-State": "AOAM53034YZZy/nFM26ts2sXM3O++SwAXjiiT2RjvIIlj5Pp3yHxwH5H\n\tFjnuQZj/xPUt+IZlFMpv5EthQyPDezaA7Q==", "X-Google-Smtp-Source": "ABdhPJxAbZw1aNb+1fAB4omI6YzAS/lzn+PwtJXjFM/ujDT5Si40ivI7P6WXqJTvkod8qhbHO3D28Q==", "X-Received": "by 2002:a2e:a612:: with SMTP id\n\tv18mr3389208ljp.358.1624369648247; \n\tTue, 22 Jun 2021 06:47:28 -0700 (PDT)", "From": "Andrey Konovalov <andrey.konovalov@linaro.org>", "To": "libcamera-devel@lists.libcamera.org,\n\tlaurent.pinchart@ideasonboard.com", "Date": "Tue, 22 Jun 2021 16:46:52 +0300", "Message-Id": "<20210622134652.1279260-10-andrey.konovalov@linaro.org>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20210622134652.1279260-1-andrey.konovalov@linaro.org>", "References": "<20210622134652.1279260-1-andrey.konovalov@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH v5 9/9] qcam: viewfinder_gl:\n\tbayer_8.frag: compute the coordinates manually", "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": "morgan@casual-effects.com", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Use the identity vertex shader, and compute the coordinates in the\nfragment shader without using the hardware interpolator.\nThe texture coordinates passed to the fragment shader are ajusted\nto point to the nearest pixel in the image. This prevents artifacts\nwhen the image is scaled from the frame resolution to the window size.\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/qcam/assets/shader/bayer_8.frag | 38 ++++++++++++++++++++++++++---\n src/qcam/viewfinder_gl.cpp | 4 ---\n 2 files changed, 34 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/qcam/assets/shader/bayer_8.frag b/src/qcam/assets/shader/bayer_8.frag\nindex 4ece44ab..be23913b 100644\n--- a/src/qcam/assets/shader/bayer_8.frag\n+++ b/src/qcam/assets/shader/bayer_8.frag\n@@ -10,21 +10,51 @@ This paper appears in issue Volume 13, Number 4.\n ---------------------------------------------------------\n Copyright (c) 2008, Morgan McGuire. All rights reserved.\n \n-Modified by Linaro Ltd to integrate it into libcamera.\n+\n+Modified by Linaro Ltd to integrate it into libcamera, and to\n+fix the artifacts due to pixel coordinates interpolation.\n Copyright (C) 2021, Linaro\n */\n \n //Pixel Shader\n \n+varying vec2 textureOut;\n+\n+uniform vec2 tex_size; /* The texture size in pixels */\n+uniform vec2 tex_step;\n+\n+/** Pixel position of the first red pixel in the */\n+/** Bayer pattern. [{0,1}, {0, 1}]*/\n+uniform vec2 tex_bayer_first_red;\n+\n /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/\n uniform sampler2D tex_y;\n-varying vec4 center;\n-varying vec4 yCoord;\n-varying vec4 xCoord;\n \n void main(void) {\n #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r\n \n+ /** .xy = Pixel being sampled in the fragment shader on the range [0, 1]\n+ .zw = ...on the range [0, sourceSize], offset by firstRed */\n+ vec4 center;\n+\n+ /** center.x + (-2/w, -1/w, 1/w, 2/w); These are the x-positions */\n+ /** of the adjacent pixels.*/\n+ vec4 xCoord;\n+\n+ /** center.y + (-2/h, -1/h, 1/h, 2/h); These are the y-positions */\n+ /** of the adjacent pixels.*/\n+ vec4 yCoord;\n+\n+ /* Align the center coordinates to the nearest pixel */\n+ center.zw = floor(textureOut * tex_size);\n+ center.xy = center.zw * tex_step;\n+ center.zw += tex_bayer_first_red;\n+\n+ xCoord = center.x + vec4(-2.0 * tex_step.x,\n+ -tex_step.x, tex_step.x, 2.0 * tex_step.x);\n+ yCoord = center.y + vec4(-2.0 * tex_step.y,\n+ -tex_step.y, tex_step.y, 2.0 * tex_step.y);\n+\n float C = texture2D(tex_y, center.xy).r; // ( 0, 0)\n const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0;\n \ndiff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex e7c8620c..a5b1bfbe 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -231,28 +231,24 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)\n \tcase libcamera::formats::SBGGR8:\n \t\tfirstRed_.setX(1.0);\n \t\tfirstRed_.setY(1.0);\n-\t\tvertexShaderFile_ = \":bayer_8.vert\";\n \t\tfragmentShaderFile_ = \":bayer_8.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SGBRG8:\n \t\tfirstRed_.setX(0.0);\n \t\tfirstRed_.setY(1.0);\n-\t\tvertexShaderFile_ = \":bayer_8.vert\";\n \t\tfragmentShaderFile_ = \":bayer_8.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SGRBG8:\n \t\tfirstRed_.setX(1.0);\n \t\tfirstRed_.setY(0.0);\n-\t\tvertexShaderFile_ = \":bayer_8.vert\";\n \t\tfragmentShaderFile_ = \":bayer_8.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SRGGB8:\n \t\tfirstRed_.setX(0.0);\n \t\tfirstRed_.setY(0.0);\n-\t\tvertexShaderFile_ = \":bayer_8.vert\";\n \t\tfragmentShaderFile_ = \":bayer_8.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n", "prefixes": [ "libcamera-devel", "RFC", "v5", "9/9" ] }