Patch Detail
Show a patch.
GET /api/1.1/patches/10943/?format=api
{ "id": 10943, "url": "https://patchwork.libcamera.org/api/1.1/patches/10943/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10943/", "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": "<20210122092335.254626-2-hiroh@chromium.org>", "date": "2021-01-22T09:23:35", "name": "[libcamera-devel,2/2] android: libyuv: Introduce PostProcessorLibyuv", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "026a995b8eed2817562bda32c5696cd95251c9cb", "submitter": { "id": 63, "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api", "name": "Hirokazu Honda", "email": "hiroh@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10943/mbox/", "series": [ { "id": 1595, "url": "https://patchwork.libcamera.org/api/1.1/series/1595/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1595", "date": "2021-01-22T09:23:34", "name": "[libcamera-devel,1/2] android: post_processor: Change the type destination in process()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1595/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10943/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10943/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 A4210BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jan 2021 09:23:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7330C68234;\n\tFri, 22 Jan 2021 10:23:47 +0100 (CET)", "from mail-pf1-x430.google.com (mail-pf1-x430.google.com\n\t[IPv6:2607:f8b0:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 49F8468231\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jan 2021 10:23:45 +0100 (CET)", "by mail-pf1-x430.google.com with SMTP id i63so3305793pfg.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jan 2021 01:23:45 -0800 (PST)", "from hiroh.c.googlers.com.com\n\t(128.141.236.35.bc.googleusercontent.com. [35.236.141.128])\n\tby smtp.gmail.com with ESMTPSA id\n\tmv17sm8466031pjb.17.2021.01.22.01.23.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 22 Jan 2021 01:23:42 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Vur8YXST\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=8Wq+PS/uRinNEcnYjMG14qJ4bHumshR/fp+X8IXeppQ=;\n\tb=Vur8YXSTNCx7+nJKokQndz1tL3OzvAz+q+S53RlC7MwTh8El38rsPnn2GWW2Kgc449\n\t1UXvYowbiUePvDx0oQ9s4uiKc7ECh7KV4DOFgxIJLLM+cQKPcsQ3dOAWUIjzSqJ0N8/K\n\tw0ECrjOMESxMWvmRX+gZ0vyp/wPQPqU0gmpOc=", "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=8Wq+PS/uRinNEcnYjMG14qJ4bHumshR/fp+X8IXeppQ=;\n\tb=cCas60LLj8ARB8gf1vfsTK6iNB/T7ZDEf5rdrSTVrv5tguN/n9NmYYJXQNpR5ySbYi\n\ttPV08B+fO/5n7xRyBQanky1rCfRheJ4EpcRwMUkF+7Te4bGC8S5W107ezHtuf6oqSZX2\n\t+mBCaMH3FtpoUrNL+tITMrrIlfuEEax4YPERNmUBaUQqoM4H+YhBnStUyH6yLfW5k8QA\n\tGCC7eBUEvnnbOCol6qQEVkpG1HihnbChdm+vzk0F2S73w2J+FfGJMSbGXUjeyDax8U7t\n\t6sTCZ+/3ACp8zYW6wQ63e8aYsUvn8tNyaXe9CX2fEmbg+GFuGO9b7ApUPeE3YTbwBFfi\n\tsrCA==", "X-Gm-Message-State": "AOAM532+Mjy3d/iGhNPPQTijUai3V/mdoyGbGLSUGruBQBo/oaTXnsxS\n\t5S9Qtl28oUIJqQcyNEx1zPmaOrt0rO25hTJI", "X-Google-Smtp-Source": "ABdhPJzv2wo0ixciHGdUtJFyRgduZoLQb26TKIaIdRWTTRL1SErDNLG+mtZZqszEUbzagydRGEHJ0w==", "X-Received": "by 2002:a62:8801:0:b029:1b9:c4af:8148 with SMTP id\n\tl1-20020a6288010000b02901b9c4af8148mr4151520pfd.18.1611307423460; \n\tFri, 22 Jan 2021 01:23:43 -0800 (PST)", "From": "Hirokazu Honda <hiroh@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 22 Jan 2021 09:23:35 +0000", "Message-Id": "<20210122092335.254626-2-hiroh@chromium.org>", "X-Mailer": "git-send-email 2.30.0.280.ga3ce27912f-goog", "In-Reply-To": "<20210122092335.254626-1-hiroh@chromium.org>", "References": "<20210122092335.254626-1-hiroh@chromium.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 2/2] android: libyuv: Introduce\n\tPostProcessorLibyuv", "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": "This adds PostProcessorLibyuv. It supports NV12 buffer scaling.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/libyuv/post_processor_libyuv.cpp | 120 +++++++++++++++++++\n src/android/libyuv/post_processor_libyuv.h | 33 +++++\n src/android/meson.build | 1 +\n 3 files changed, 154 insertions(+)\n create mode 100644 src/android/libyuv/post_processor_libyuv.cpp\n create mode 100644 src/android/libyuv/post_processor_libyuv.h\n\n--\n2.30.0.280.ga3ce27912f-goog", "diff": "diff --git a/src/android/libyuv/post_processor_libyuv.cpp b/src/android/libyuv/post_processor_libyuv.cpp\nnew file mode 100644\nindex 00000000..7cfa0539\n--- /dev/null\n+++ b/src/android/libyuv/post_processor_libyuv.cpp\n@@ -0,0 +1,120 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * post_processor_libyuv.cpp - Post Processor using libyuv\n+ */\n+\n+#include \"post_processor_libyuv.h\"\n+\n+#include <libyuv/scale.h>\n+\n+#include <libcamera/formats.h>\n+#include <libcamera/geometry.h>\n+#include <libcamera/internal/formats.h>\n+#include <libcamera/internal/log.h>\n+#include <libcamera/pixel_format.h>\n+\n+using namespace libcamera;\n+\n+LOG_DEFINE_CATEGORY(LIBYUV)\n+\n+namespace {\n+void getNV12Length(Size size, unsigned int length[2])\n+{\n+\tauto nv12Info = PixelFormatInfo::info(PixelFormat(formats::NV12));\n+\tfor (unsigned int i = 0; i < 2; i++) {\n+\t\tconst unsigned int vertSubSample =\n+\t\t\tnv12Info.planes[i].verticalSubSampling;\n+\t\tlength[i] = nv12Info.stride(size.width, i, /*align=*/1) *\n+\t\t\t ((size.height + vertSubSample - 1) / vertSubSample);\n+\t}\n+}\n+\n+unsigned int getNV12Stride(Size size, unsigned int i)\n+{\n+\tauto nv12Info = PixelFormatInfo::info(PixelFormat(formats::NV12));\n+\treturn nv12Info.stride(size.width, i, 1);\n+}\n+} // namespace\n+\n+PostProcessorLibyuv::PostProcessorLibyuv() = default;\n+\n+int PostProcessorLibyuv::configure(const StreamConfiguration &inCfg,\n+\t\t\t\t const StreamConfiguration &outCfg)\n+{\n+\tif (inCfg.pixelFormat != outCfg.pixelFormat ||\n+\t inCfg.size < outCfg.size) {\n+\t\tLOG(LIBYUV, Error) << \"Only down-scaling is supported\";\n+\t\treturn -EINVAL;\n+\t}\n+\tif (inCfg.pixelFormat == formats::NV12) {\n+\t\tLOG(LIBYUV, Error) << \"Only NV12 is supported\";\n+\t\treturn -EINVAL;\n+\t}\n+\tinCfg_ = inCfg;\n+\toutCfg_ = outCfg;\n+\treturn 0;\n+}\n+\n+int PostProcessorLibyuv::process(const FrameBuffer &source,\n+\t\t\t\t libcamera::MappedBuffer *destination,\n+\t\t\t\t CameraMetadata * /*metadata*/)\n+{\n+\tif (!IsValidNV12Buffers(source, *destination)) {\n+\t\tLOG(LIBYUV, Error) << \"Invalid source and destination\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tconst MappedFrameBuffer sourceMapped(&source, PROT_READ);\n+\tif (!sourceMapped.isValid()) {\n+\t\tLOG(LIBYUV, Error) << \"Failed to mmap camera frame buffer\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0 == libyuv::NV12Scale(sourceMapped.maps()[0].data(),\n+\t\t\t\t getNV12Stride(inCfg_.size, 0),\n+\t\t\t\t sourceMapped.maps()[1].data(),\n+\t\t\t\t getNV12Stride(inCfg_.size, 1),\n+\t\t\t\t inCfg_.size.height, inCfg_.size.width,\n+\t\t\t\t destination->maps()[0].data(),\n+\t\t\t\t getNV12Stride(outCfg_.size, 0),\n+\t\t\t\t destination->maps()[1].data(),\n+\t\t\t\t getNV12Stride(outCfg_.size, 1),\n+\t\t\t\t outCfg_.size.width, outCfg_.size.height,\n+\t\t\t\t libyuv::FilterMode::kFilterBilinear);\n+}\n+\n+bool PostProcessorLibyuv::IsValidNV12Buffers(\n+\tconst FrameBuffer &source,\n+\tconst libcamera::MappedBuffer &destination) const\n+{\n+\tif (source.planes().size() != 2u) {\n+\t\tLOG(LIBYUV, Error) << \"The number of source planes is not 2\";\n+\t\treturn false;\n+\t}\n+\tif (destination.maps().size() != 2u) {\n+\t\tLOG(LIBYUV, Error)\n+\t\t\t<< \"The number of destination planes is not 2\";\n+\t\treturn false;\n+\t}\n+\n+\tunsigned int sourceLength[2] = {};\n+\tunsigned int destinationLength[2] = {};\n+\tgetNV12Length(inCfg_.size, sourceLength);\n+\tgetNV12Length(outCfg_.size, destinationLength);\n+\n+\tif (source.planes()[0].length < sourceLength[0] ||\n+\t source.planes()[1].length < sourceLength[1]) {\n+\t\tLOG(LIBYUV, Error)\n+\t\t\t<< \"The source planes lengths are too small\";\n+\t\treturn false;\n+\t}\n+\tif (destination.maps()[0].size() < destinationLength[0] ||\n+\t destination.maps()[1].size() < destinationLength[1]) {\n+\t\tLOG(LIBYUV, Error)\n+\t\t\t<< \"The destination planes lengths are too small\";\n+\t\treturn false;\n+\t}\n+\treturn true;\n+}\ndiff --git a/src/android/libyuv/post_processor_libyuv.h b/src/android/libyuv/post_processor_libyuv.h\nnew file mode 100644\nindex 00000000..860a664b\n--- /dev/null\n+++ b/src/android/libyuv/post_processor_libyuv.h\n@@ -0,0 +1,33 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * post_processor_libyuv.h - Post Processor using libyuv\n+ */\n+#ifndef __ANDROID_POST_PROCESSOR_LIBYUV_H__\n+#define __ANDROID_POST_PROCESSOR_LIBYUV_H__\n+\n+#include \"../post_processor.h\"\n+\n+class CameraDevice;\n+\n+class PostProcessorLibyuv : public PostProcessor\n+{\n+public:\n+\tPostProcessorLibyuv();\n+\n+\tint configure(const libcamera::StreamConfiguration &incfg,\n+\t\t const libcamera::StreamConfiguration &outcfg) override;\n+\tint process(const libcamera::FrameBuffer &source,\n+\t\t libcamera::MappedBuffer *destination,\n+\t\t CameraMetadata *metadata) override;\n+\n+private:\n+\tbool IsValidNV12Buffers(const libcamera::FrameBuffer &source,\n+\t\t\t\tconst libcamera::MappedBuffer &destination) const;\n+\n+\tlibcamera::StreamConfiguration inCfg_;\n+\tlibcamera::StreamConfiguration outCfg_;\n+};\n+\n+#endif /* __ANDROID_POST_PROCESSOR_LIBYUV_H__ */\ndiff --git a/src/android/meson.build b/src/android/meson.build\nindex 3d4d3be4..ff067d12 100644\n--- a/src/android/meson.build\n+++ b/src/android/meson.build\n@@ -26,6 +26,7 @@ android_hal_sources = files([\n 'jpeg/exif.cpp',\n 'jpeg/post_processor_jpeg.cpp',\n 'jpeg/thumbnailer.cpp',\n+ 'libyuv/post_processor_libyuv.cpp'\n ])\n\n android_camera_metadata_sources = files([\n", "prefixes": [ "libcamera-devel", "2/2" ] }